id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
1,200
consolle/framework
src/Foundation/Application.php
Application.storagePath
public function storagePath() { if ($this->storagePath) return $this->storagePath; return $this->storagePath ?: $this->rootPath() . DIRECTORY_SEPARATOR . 'storage'; }
php
public function storagePath() { if ($this->storagePath) return $this->storagePath; return $this->storagePath ?: $this->rootPath() . DIRECTORY_SEPARATOR . 'storage'; }
[ "public", "function", "storagePath", "(", ")", "{", "if", "(", "$", "this", "->", "storagePath", ")", "return", "$", "this", "->", "storagePath", ";", "return", "$", "this", "->", "storagePath", "?", ":", "$", "this", "->", "rootPath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "'storage'", ";", "}" ]
Get the path to the application configuration files. @return string
[ "Get", "the", "path", "to", "the", "application", "configuration", "files", "." ]
2799921d6983f31e775099eac116c337bbe29c74
https://github.com/consolle/framework/blob/2799921d6983f31e775099eac116c337bbe29c74/src/Foundation/Application.php#L288-L293
1,201
AnonymPHP/Anonym-Library
src/Anonym/Html/Form/BuildCsrfField.php
BuildCsrfField.createCsrfField
public function createCsrfField() { $fieldName = Config::get('security.csrf.field_name'); $input = new Input($this->form->expression('input'), [ 'name' => $fieldName, 'value' => $this->createToken(), 'type' => 'hidden' ]); return $input->execute(); }
php
public function createCsrfField() { $fieldName = Config::get('security.csrf.field_name'); $input = new Input($this->form->expression('input'), [ 'name' => $fieldName, 'value' => $this->createToken(), 'type' => 'hidden' ]); return $input->execute(); }
[ "public", "function", "createCsrfField", "(", ")", "{", "$", "fieldName", "=", "Config", "::", "get", "(", "'security.csrf.field_name'", ")", ";", "$", "input", "=", "new", "Input", "(", "$", "this", "->", "form", "->", "expression", "(", "'input'", ")", ",", "[", "'name'", "=>", "$", "fieldName", ",", "'value'", "=>", "$", "this", "->", "createToken", "(", ")", ",", "'type'", "=>", "'hidden'", "]", ")", ";", "return", "$", "input", "->", "execute", "(", ")", ";", "}" ]
create csrf token field @return mixed
[ "create", "csrf", "token", "field" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Html/Form/BuildCsrfField.php#L38-L49
1,202
calgamo/util
src/MacroProcessor.php
MacroProcessor.process
public function process(string $string, int $strategy = EnumMacroProcessStorategy::STRATEGY_LAST) { // find and replce macro $ret = $string; $replace_exists = false; $keyword_list = self::findMacroKeywords($ret); foreach($keyword_list as $keyword){ $replace = $this->callHandlers($keyword, $strategy); if ($replace !== null){ $replace_exists |= $this->checkIfReplaceIncludeMacro($replace); $ret = str_replace("%$keyword%",$replace,$ret); } } // call recursive if possibly macro code found. return $replace_exists ? $this->process($ret, $strategy) : $ret; }
php
public function process(string $string, int $strategy = EnumMacroProcessStorategy::STRATEGY_LAST) { // find and replce macro $ret = $string; $replace_exists = false; $keyword_list = self::findMacroKeywords($ret); foreach($keyword_list as $keyword){ $replace = $this->callHandlers($keyword, $strategy); if ($replace !== null){ $replace_exists |= $this->checkIfReplaceIncludeMacro($replace); $ret = str_replace("%$keyword%",$replace,$ret); } } // call recursive if possibly macro code found. return $replace_exists ? $this->process($ret, $strategy) : $ret; }
[ "public", "function", "process", "(", "string", "$", "string", ",", "int", "$", "strategy", "=", "EnumMacroProcessStorategy", "::", "STRATEGY_LAST", ")", "{", "// find and replce macro", "$", "ret", "=", "$", "string", ";", "$", "replace_exists", "=", "false", ";", "$", "keyword_list", "=", "self", "::", "findMacroKeywords", "(", "$", "ret", ")", ";", "foreach", "(", "$", "keyword_list", "as", "$", "keyword", ")", "{", "$", "replace", "=", "$", "this", "->", "callHandlers", "(", "$", "keyword", ",", "$", "strategy", ")", ";", "if", "(", "$", "replace", "!==", "null", ")", "{", "$", "replace_exists", "|=", "$", "this", "->", "checkIfReplaceIncludeMacro", "(", "$", "replace", ")", ";", "$", "ret", "=", "str_replace", "(", "\"%$keyword%\"", ",", "$", "replace", ",", "$", "ret", ")", ";", "}", "}", "// call recursive if possibly macro code found.", "return", "$", "replace_exists", "?", "$", "this", "->", "process", "(", "$", "ret", ",", "$", "strategy", ")", ":", "$", "ret", ";", "}" ]
Expand string by macro keyword @param string $string @param int $strategy @return string
[ "Expand", "string", "by", "macro", "keyword" ]
13ef5caf3d4cce423854a0cb8fb8010c0d40326a
https://github.com/calgamo/util/blob/13ef5caf3d4cce423854a0cb8fb8010c0d40326a/src/MacroProcessor.php#L130-L146
1,203
calgamo/util
src/MacroProcessor.php
MacroProcessor.checkIfReplaceIncludeMacro
private function checkIfReplaceIncludeMacro(string $replace) : bool { $keyword_list = self::findMacroKeywords($replace); foreach($keyword_list as $keyword){ $replace = $this->callHandlers($keyword, EnumMacroProcessStorategy::STRATEGY_FISRT); if ($replace !== null){ return true; } } return false; }
php
private function checkIfReplaceIncludeMacro(string $replace) : bool { $keyword_list = self::findMacroKeywords($replace); foreach($keyword_list as $keyword){ $replace = $this->callHandlers($keyword, EnumMacroProcessStorategy::STRATEGY_FISRT); if ($replace !== null){ return true; } } return false; }
[ "private", "function", "checkIfReplaceIncludeMacro", "(", "string", "$", "replace", ")", ":", "bool", "{", "$", "keyword_list", "=", "self", "::", "findMacroKeywords", "(", "$", "replace", ")", ";", "foreach", "(", "$", "keyword_list", "as", "$", "keyword", ")", "{", "$", "replace", "=", "$", "this", "->", "callHandlers", "(", "$", "keyword", ",", "EnumMacroProcessStorategy", "::", "STRATEGY_FISRT", ")", ";", "if", "(", "$", "replace", "!==", "null", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if replace string has macro @param string $replace @return bool
[ "Check", "if", "replace", "string", "has", "macro" ]
13ef5caf3d4cce423854a0cb8fb8010c0d40326a
https://github.com/calgamo/util/blob/13ef5caf3d4cce423854a0cb8fb8010c0d40326a/src/MacroProcessor.php#L155-L165
1,204
calgamo/util
src/MacroProcessor.php
MacroProcessor.callHandlers
private function callHandlers(string $keyword, int $strategy) { if ($this->handlers) { $stack = null; foreach($this->handlers as $handler){ $replace = $handler($keyword); if (!is_null($replace)){ if ($strategy === EnumMacroProcessStorategy::STRATEGY_FISRT){ return $replace; } $stack[] = $replace; } } if ($strategy === EnumMacroProcessStorategy::STRATEGY_LAST && !empty($stack)){ return array_pop($stack); } } return null; }
php
private function callHandlers(string $keyword, int $strategy) { if ($this->handlers) { $stack = null; foreach($this->handlers as $handler){ $replace = $handler($keyword); if (!is_null($replace)){ if ($strategy === EnumMacroProcessStorategy::STRATEGY_FISRT){ return $replace; } $stack[] = $replace; } } if ($strategy === EnumMacroProcessStorategy::STRATEGY_LAST && !empty($stack)){ return array_pop($stack); } } return null; }
[ "private", "function", "callHandlers", "(", "string", "$", "keyword", ",", "int", "$", "strategy", ")", "{", "if", "(", "$", "this", "->", "handlers", ")", "{", "$", "stack", "=", "null", ";", "foreach", "(", "$", "this", "->", "handlers", "as", "$", "handler", ")", "{", "$", "replace", "=", "$", "handler", "(", "$", "keyword", ")", ";", "if", "(", "!", "is_null", "(", "$", "replace", ")", ")", "{", "if", "(", "$", "strategy", "===", "EnumMacroProcessStorategy", "::", "STRATEGY_FISRT", ")", "{", "return", "$", "replace", ";", "}", "$", "stack", "[", "]", "=", "$", "replace", ";", "}", "}", "if", "(", "$", "strategy", "===", "EnumMacroProcessStorategy", "::", "STRATEGY_LAST", "&&", "!", "empty", "(", "$", "stack", ")", ")", "{", "return", "array_pop", "(", "$", "stack", ")", ";", "}", "}", "return", "null", ";", "}" ]
Callback all handlers @param string $keyword @param int $strategy @return bool|string
[ "Callback", "all", "handlers" ]
13ef5caf3d4cce423854a0cb8fb8010c0d40326a
https://github.com/calgamo/util/blob/13ef5caf3d4cce423854a0cb8fb8010c0d40326a/src/MacroProcessor.php#L192-L211
1,205
donbidon/core
src/Bootstrap.php
Bootstrap.initByPath
public static function initByPath( $path, array $options = [ 'registry' => Recursive::ALL_INCLUSIVE, ] ) { if (!file_exists($path) || !is_readable($path)) { throw new RuntimeException( sprintf("Cannot open config file \"%s\"", $path), self::EX_CANNOT_OPEN_CONFIG ); } $config = \donbidon\Lib\Config\Ini::parse( file_get_contents($path), true ); if (!is_array($config)) { throw new RuntimeException( sprintf("Cannot parse config file \"%s\"", $path), self::EX_CANNOT_PARSE_CONFIG ); } $registry = static::initByArray($config, $options); return $registry; }
php
public static function initByPath( $path, array $options = [ 'registry' => Recursive::ALL_INCLUSIVE, ] ) { if (!file_exists($path) || !is_readable($path)) { throw new RuntimeException( sprintf("Cannot open config file \"%s\"", $path), self::EX_CANNOT_OPEN_CONFIG ); } $config = \donbidon\Lib\Config\Ini::parse( file_get_contents($path), true ); if (!is_array($config)) { throw new RuntimeException( sprintf("Cannot parse config file \"%s\"", $path), self::EX_CANNOT_PARSE_CONFIG ); } $registry = static::initByArray($config, $options); return $registry; }
[ "public", "static", "function", "initByPath", "(", "$", "path", ",", "array", "$", "options", "=", "[", "'registry'", "=>", "Recursive", "::", "ALL_INCLUSIVE", ",", "]", ")", "{", "if", "(", "!", "file_exists", "(", "$", "path", ")", "||", "!", "is_readable", "(", "$", "path", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "\"Cannot open config file \\\"%s\\\"\"", ",", "$", "path", ")", ",", "self", "::", "EX_CANNOT_OPEN_CONFIG", ")", ";", "}", "$", "config", "=", "\\", "donbidon", "\\", "Lib", "\\", "Config", "\\", "Ini", "::", "parse", "(", "file_get_contents", "(", "$", "path", ")", ",", "true", ")", ";", "if", "(", "!", "is_array", "(", "$", "config", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "\"Cannot parse config file \\\"%s\\\"\"", ",", "$", "path", ")", ",", "self", "::", "EX_CANNOT_PARSE_CONFIG", ")", ";", "}", "$", "registry", "=", "static", "::", "initByArray", "(", "$", "config", ",", "$", "options", ")", ";", "return", "$", "registry", ";", "}" ]
Initializes environment by config file path. @param string $path @param array $options Array of options: - (int)registry - see Recursive::__construct(). @return I_Registry @throws RuntimeException If passed file doesn't exist or cannot be read. @throws RuntimeException If cannot parse config file.
[ "Initializes", "environment", "by", "config", "file", "path", "." ]
a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe
https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Bootstrap.php#L131-L155
1,206
donbidon/core
src/Bootstrap.php
Bootstrap.initByArray
public static function initByArray( array $config, array $options = [ 'registry' => Recursive::ALL_INCLUSIVE, ] ) { if (!is_array($config)) { throw new InvalidArgumentException( sprintf( "Passed argument isn't array (%s)", gettype($config) ), self::EX_INVALID_ARG ); } $registry = static::getRegistry($config, $options['registry']); // static::modifyRegistryOnStart($registry); $registry->set( 'core/env', isset($_SERVER['DOCUMENT_URI']) ? "web" : "CLI" ); $evtManager = new Event\Manager; $evtManager->setDebug($registry->get( 'core/event/debug', false )); Log\Factory::run($registry, $evtManager); $registry->set('core/event/manager', $evtManager); return $registry; }
php
public static function initByArray( array $config, array $options = [ 'registry' => Recursive::ALL_INCLUSIVE, ] ) { if (!is_array($config)) { throw new InvalidArgumentException( sprintf( "Passed argument isn't array (%s)", gettype($config) ), self::EX_INVALID_ARG ); } $registry = static::getRegistry($config, $options['registry']); // static::modifyRegistryOnStart($registry); $registry->set( 'core/env', isset($_SERVER['DOCUMENT_URI']) ? "web" : "CLI" ); $evtManager = new Event\Manager; $evtManager->setDebug($registry->get( 'core/event/debug', false )); Log\Factory::run($registry, $evtManager); $registry->set('core/event/manager', $evtManager); return $registry; }
[ "public", "static", "function", "initByArray", "(", "array", "$", "config", ",", "array", "$", "options", "=", "[", "'registry'", "=>", "Recursive", "::", "ALL_INCLUSIVE", ",", "]", ")", "{", "if", "(", "!", "is_array", "(", "$", "config", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "\"Passed argument isn't array (%s)\"", ",", "gettype", "(", "$", "config", ")", ")", ",", "self", "::", "EX_INVALID_ARG", ")", ";", "}", "$", "registry", "=", "static", "::", "getRegistry", "(", "$", "config", ",", "$", "options", "[", "'registry'", "]", ")", ";", "// static::modifyRegistryOnStart($registry);\r", "$", "registry", "->", "set", "(", "'core/env'", ",", "isset", "(", "$", "_SERVER", "[", "'DOCUMENT_URI'", "]", ")", "?", "\"web\"", ":", "\"CLI\"", ")", ";", "$", "evtManager", "=", "new", "Event", "\\", "Manager", ";", "$", "evtManager", "->", "setDebug", "(", "$", "registry", "->", "get", "(", "'core/event/debug'", ",", "false", ")", ")", ";", "Log", "\\", "Factory", "::", "run", "(", "$", "registry", ",", "$", "evtManager", ")", ";", "$", "registry", "->", "set", "(", "'core/event/manager'", ",", "$", "evtManager", ")", ";", "return", "$", "registry", ";", "}" ]
Initializes environment by config array. @param array $config @param array $options Array of options: - (int)registry - see Recursive::__construct(). @return I_Registry @throws InvalidArgumentException
[ "Initializes", "environment", "by", "config", "array", "." ]
a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe
https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Bootstrap.php#L166-L194
1,207
LaBlog/LaBlog
src/Lablog/Lablog/Category/FileCategory.php
FileCategory.exists
public function exists($category) { $ds = DIRECTORY_SEPARATOR; $path = app_path().$ds.'lablog'.$ds.$category; if ($this->fs->isDirectory($path)) { return true; } return false; }
php
public function exists($category) { $ds = DIRECTORY_SEPARATOR; $path = app_path().$ds.'lablog'.$ds.$category; if ($this->fs->isDirectory($path)) { return true; } return false; }
[ "public", "function", "exists", "(", "$", "category", ")", "{", "$", "ds", "=", "DIRECTORY_SEPARATOR", ";", "$", "path", "=", "app_path", "(", ")", ".", "$", "ds", ".", "'lablog'", ".", "$", "ds", ".", "$", "category", ";", "if", "(", "$", "this", "->", "fs", "->", "isDirectory", "(", "$", "path", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if a given category exists or not. @param string $path @return boolean
[ "Check", "if", "a", "given", "category", "exists", "or", "not", "." ]
d23f7848bd9a3993cbb5913d967626e9914a009c
https://github.com/LaBlog/LaBlog/blob/d23f7848bd9a3993cbb5913d967626e9914a009c/src/Lablog/Lablog/Category/FileCategory.php#L21-L31
1,208
LaBlog/LaBlog
src/Lablog/Lablog/Category/FileCategory.php
FileCategory.getSubCategories
public function getSubCategories($category) { $ds = DIRECTORY_SEPARATOR; $categoryPath = str_replace('/', $ds, $category); $basePath = app_path().$ds.'lablog'.$ds; $path = $basePath.$categoryPath; if (!$this->exists($category)) { return array(); } $categories = $this->fs->directories($path); $allCategories = array(); foreach ($categories as $category) { $cat = str_replace($basePath, '', $category); $allCategories[] = $this->getCategory($cat); } return $allCategories; }
php
public function getSubCategories($category) { $ds = DIRECTORY_SEPARATOR; $categoryPath = str_replace('/', $ds, $category); $basePath = app_path().$ds.'lablog'.$ds; $path = $basePath.$categoryPath; if (!$this->exists($category)) { return array(); } $categories = $this->fs->directories($path); $allCategories = array(); foreach ($categories as $category) { $cat = str_replace($basePath, '', $category); $allCategories[] = $this->getCategory($cat); } return $allCategories; }
[ "public", "function", "getSubCategories", "(", "$", "category", ")", "{", "$", "ds", "=", "DIRECTORY_SEPARATOR", ";", "$", "categoryPath", "=", "str_replace", "(", "'/'", ",", "$", "ds", ",", "$", "category", ")", ";", "$", "basePath", "=", "app_path", "(", ")", ".", "$", "ds", ".", "'lablog'", ".", "$", "ds", ";", "$", "path", "=", "$", "basePath", ".", "$", "categoryPath", ";", "if", "(", "!", "$", "this", "->", "exists", "(", "$", "category", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "categories", "=", "$", "this", "->", "fs", "->", "directories", "(", "$", "path", ")", ";", "$", "allCategories", "=", "array", "(", ")", ";", "foreach", "(", "$", "categories", "as", "$", "category", ")", "{", "$", "cat", "=", "str_replace", "(", "$", "basePath", ",", "''", ",", "$", "category", ")", ";", "$", "allCategories", "[", "]", "=", "$", "this", "->", "getCategory", "(", "$", "cat", ")", ";", "}", "return", "$", "allCategories", ";", "}" ]
Get a given categories sub categories. @param string $category @return array
[ "Get", "a", "given", "categories", "sub", "categories", "." ]
d23f7848bd9a3993cbb5913d967626e9914a009c
https://github.com/LaBlog/LaBlog/blob/d23f7848bd9a3993cbb5913d967626e9914a009c/src/Lablog/Lablog/Category/FileCategory.php#L38-L61
1,209
LaBlog/LaBlog
src/Lablog/Lablog/Category/FileCategory.php
FileCategory.getCategory
public function getCategory($category) { $ds = DIRECTORY_SEPARATOR; $categoryPath = str_replace('/', $ds, $category); $path = app_path().$ds.'lablog'.$ds.$categoryPath; if (!$this->exists($category)) { return (object) array(); } $categoryExplode = explode('/', $category); $categoryName = end($categoryExplode); $linkPrefix = \Config::get('lablog::prefix') == '/' ? '' : \Config::get('lablog::prefix'); $baseCategory = $category; $categoryLink = $linkPrefix.'/category/'.$category; $fullCategory = $category; $category = new Category; $category->name = $categoryName; $category->link = $baseCategory; $category->url = \URL::to($categoryLink); return $category; }
php
public function getCategory($category) { $ds = DIRECTORY_SEPARATOR; $categoryPath = str_replace('/', $ds, $category); $path = app_path().$ds.'lablog'.$ds.$categoryPath; if (!$this->exists($category)) { return (object) array(); } $categoryExplode = explode('/', $category); $categoryName = end($categoryExplode); $linkPrefix = \Config::get('lablog::prefix') == '/' ? '' : \Config::get('lablog::prefix'); $baseCategory = $category; $categoryLink = $linkPrefix.'/category/'.$category; $fullCategory = $category; $category = new Category; $category->name = $categoryName; $category->link = $baseCategory; $category->url = \URL::to($categoryLink); return $category; }
[ "public", "function", "getCategory", "(", "$", "category", ")", "{", "$", "ds", "=", "DIRECTORY_SEPARATOR", ";", "$", "categoryPath", "=", "str_replace", "(", "'/'", ",", "$", "ds", ",", "$", "category", ")", ";", "$", "path", "=", "app_path", "(", ")", ".", "$", "ds", ".", "'lablog'", ".", "$", "ds", ".", "$", "categoryPath", ";", "if", "(", "!", "$", "this", "->", "exists", "(", "$", "category", ")", ")", "{", "return", "(", "object", ")", "array", "(", ")", ";", "}", "$", "categoryExplode", "=", "explode", "(", "'/'", ",", "$", "category", ")", ";", "$", "categoryName", "=", "end", "(", "$", "categoryExplode", ")", ";", "$", "linkPrefix", "=", "\\", "Config", "::", "get", "(", "'lablog::prefix'", ")", "==", "'/'", "?", "''", ":", "\\", "Config", "::", "get", "(", "'lablog::prefix'", ")", ";", "$", "baseCategory", "=", "$", "category", ";", "$", "categoryLink", "=", "$", "linkPrefix", ".", "'/category/'", ".", "$", "category", ";", "$", "fullCategory", "=", "$", "category", ";", "$", "category", "=", "new", "Category", ";", "$", "category", "->", "name", "=", "$", "categoryName", ";", "$", "category", "->", "link", "=", "$", "baseCategory", ";", "$", "category", "->", "url", "=", "\\", "URL", "::", "to", "(", "$", "categoryLink", ")", ";", "return", "$", "category", ";", "}" ]
Get a given category information. @param string $category @return void
[ "Get", "a", "given", "category", "information", "." ]
d23f7848bd9a3993cbb5913d967626e9914a009c
https://github.com/LaBlog/LaBlog/blob/d23f7848bd9a3993cbb5913d967626e9914a009c/src/Lablog/Lablog/Category/FileCategory.php#L68-L94
1,210
plinker-rpc/cron
src/lib/CronFileWriter.php
CronFileWriter.create
public function create($delim = '#', $data = PHP_EOL) { //first check for existing then update if ($this->read($delim)) { $this->update($delim, $data); } else { //create new entry file_put_contents( $this->file, PHP_EOL.'# '.$delim.PHP_EOL.$data.PHP_EOL.'# \\'.$delim.PHP_EOL, FILE_APPEND ); } }
php
public function create($delim = '#', $data = PHP_EOL) { //first check for existing then update if ($this->read($delim)) { $this->update($delim, $data); } else { //create new entry file_put_contents( $this->file, PHP_EOL.'# '.$delim.PHP_EOL.$data.PHP_EOL.'# \\'.$delim.PHP_EOL, FILE_APPEND ); } }
[ "public", "function", "create", "(", "$", "delim", "=", "'#'", ",", "$", "data", "=", "PHP_EOL", ")", "{", "//first check for existing then update", "if", "(", "$", "this", "->", "read", "(", "$", "delim", ")", ")", "{", "$", "this", "->", "update", "(", "$", "delim", ",", "$", "data", ")", ";", "}", "else", "{", "//create new entry", "file_put_contents", "(", "$", "this", "->", "file", ",", "PHP_EOL", ".", "'# '", ".", "$", "delim", ".", "PHP_EOL", ".", "$", "data", ".", "PHP_EOL", ".", "'# \\\\'", ".", "$", "delim", ".", "PHP_EOL", ",", "FILE_APPEND", ")", ";", "}", "}" ]
Create or update an entry in the .htaccess file @param string $data @param string $delim
[ "Create", "or", "update", "an", "entry", "in", "the", ".", "htaccess", "file" ]
af1bd1258a22b8333239654e0cb3c371f1eda42d
https://github.com/plinker-rpc/cron/blob/af1bd1258a22b8333239654e0cb3c371f1eda42d/src/lib/CronFileWriter.php#L58-L71
1,211
plinker-rpc/cron
src/lib/CronFileWriter.php
CronFileWriter.read
public function read($delim = '#') { $file = file_get_contents($this->file); $delim = preg_quote($delim); if (preg_match("/#\s$delim\s(.*?)\s#\s\\\\$delim/s", $file, $matches)) { return trim($matches[1]); } else { return false; } }
php
public function read($delim = '#') { $file = file_get_contents($this->file); $delim = preg_quote($delim); if (preg_match("/#\s$delim\s(.*?)\s#\s\\\\$delim/s", $file, $matches)) { return trim($matches[1]); } else { return false; } }
[ "public", "function", "read", "(", "$", "delim", "=", "'#'", ")", "{", "$", "file", "=", "file_get_contents", "(", "$", "this", "->", "file", ")", ";", "$", "delim", "=", "preg_quote", "(", "$", "delim", ")", ";", "if", "(", "preg_match", "(", "\"/#\\s$delim\\s(.*?)\\s#\\s\\\\\\\\$delim/s\"", ",", "$", "file", ",", "$", "matches", ")", ")", "{", "return", "trim", "(", "$", "matches", "[", "1", "]", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Read entry from .htaccess file @param string $delim @return mixed (bool|string)
[ "Read", "entry", "from", ".", "htaccess", "file" ]
af1bd1258a22b8333239654e0cb3c371f1eda42d
https://github.com/plinker-rpc/cron/blob/af1bd1258a22b8333239654e0cb3c371f1eda42d/src/lib/CronFileWriter.php#L79-L89
1,212
plinker-rpc/cron
src/lib/CronFileWriter.php
CronFileWriter.update
public function update($delim = '#', $data = PHP_EOL) { $data = str_replace( array('$1','$2','$3','$4','$5'), array('\$1','\$2','\$3','\$4','\$5'), $data ); $delim = preg_quote($delim); file_put_contents( $this->file, trim( preg_replace( "/#\s$delim\s(.*?)\s#\s\\\\$delim/s", '# '.$delim.PHP_EOL.$data.PHP_EOL.'# \\'.$delim, file_get_contents($this->file) ) ) ); }
php
public function update($delim = '#', $data = PHP_EOL) { $data = str_replace( array('$1','$2','$3','$4','$5'), array('\$1','\$2','\$3','\$4','\$5'), $data ); $delim = preg_quote($delim); file_put_contents( $this->file, trim( preg_replace( "/#\s$delim\s(.*?)\s#\s\\\\$delim/s", '# '.$delim.PHP_EOL.$data.PHP_EOL.'# \\'.$delim, file_get_contents($this->file) ) ) ); }
[ "public", "function", "update", "(", "$", "delim", "=", "'#'", ",", "$", "data", "=", "PHP_EOL", ")", "{", "$", "data", "=", "str_replace", "(", "array", "(", "'$1'", ",", "'$2'", ",", "'$3'", ",", "'$4'", ",", "'$5'", ")", ",", "array", "(", "'\\$1'", ",", "'\\$2'", ",", "'\\$3'", ",", "'\\$4'", ",", "'\\$5'", ")", ",", "$", "data", ")", ";", "$", "delim", "=", "preg_quote", "(", "$", "delim", ")", ";", "file_put_contents", "(", "$", "this", "->", "file", ",", "trim", "(", "preg_replace", "(", "\"/#\\s$delim\\s(.*?)\\s#\\s\\\\\\\\$delim/s\"", ",", "'# '", ".", "$", "delim", ".", "PHP_EOL", ".", "$", "data", ".", "PHP_EOL", ".", "'# \\\\'", ".", "$", "delim", ",", "file_get_contents", "(", "$", "this", "->", "file", ")", ")", ")", ")", ";", "}" ]
Update entry in .htaccess file @param string $data @param string $delim
[ "Update", "entry", "in", ".", "htaccess", "file" ]
af1bd1258a22b8333239654e0cb3c371f1eda42d
https://github.com/plinker-rpc/cron/blob/af1bd1258a22b8333239654e0cb3c371f1eda42d/src/lib/CronFileWriter.php#L97-L117
1,213
plinker-rpc/cron
src/lib/CronFileWriter.php
CronFileWriter.delete
public function delete($delim = '#') { $file = file_get_contents($this->file); $delim = preg_quote($delim); if (preg_match("/#\s$delim\s(.*?)\s#\s\\\\$delim/s", $file, $matches)) { file_put_contents( $this->file, str_replace(PHP_EOL.$matches[0].PHP_EOL, '', $file) ); return true; } else { return false; } }
php
public function delete($delim = '#') { $file = file_get_contents($this->file); $delim = preg_quote($delim); if (preg_match("/#\s$delim\s(.*?)\s#\s\\\\$delim/s", $file, $matches)) { file_put_contents( $this->file, str_replace(PHP_EOL.$matches[0].PHP_EOL, '', $file) ); return true; } else { return false; } }
[ "public", "function", "delete", "(", "$", "delim", "=", "'#'", ")", "{", "$", "file", "=", "file_get_contents", "(", "$", "this", "->", "file", ")", ";", "$", "delim", "=", "preg_quote", "(", "$", "delim", ")", ";", "if", "(", "preg_match", "(", "\"/#\\s$delim\\s(.*?)\\s#\\s\\\\\\\\$delim/s\"", ",", "$", "file", ",", "$", "matches", ")", ")", "{", "file_put_contents", "(", "$", "this", "->", "file", ",", "str_replace", "(", "PHP_EOL", ".", "$", "matches", "[", "0", "]", ".", "PHP_EOL", ",", "''", ",", "$", "file", ")", ")", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Delete entry from .htaccess file @param string $delim @return bool
[ "Delete", "entry", "from", ".", "htaccess", "file" ]
af1bd1258a22b8333239654e0cb3c371f1eda42d
https://github.com/plinker-rpc/cron/blob/af1bd1258a22b8333239654e0cb3c371f1eda42d/src/lib/CronFileWriter.php#L125-L139
1,214
Dhii/tokenizer-abstract
src/TokenizerAwareTrait.php
TokenizerAwareTrait._setTokenizer
protected function _setTokenizer($tokenizer) { if ($tokenizer !== null && !($tokenizer instanceof TokenizerInterface)) { throw $this->_createInvalidArgumentException($this->__('Invalid tokenizer'), null, null, $tokenizer); } $this->tokenizer = $tokenizer; }
php
protected function _setTokenizer($tokenizer) { if ($tokenizer !== null && !($tokenizer instanceof TokenizerInterface)) { throw $this->_createInvalidArgumentException($this->__('Invalid tokenizer'), null, null, $tokenizer); } $this->tokenizer = $tokenizer; }
[ "protected", "function", "_setTokenizer", "(", "$", "tokenizer", ")", "{", "if", "(", "$", "tokenizer", "!==", "null", "&&", "!", "(", "$", "tokenizer", "instanceof", "TokenizerInterface", ")", ")", "{", "throw", "$", "this", "->", "_createInvalidArgumentException", "(", "$", "this", "->", "__", "(", "'Invalid tokenizer'", ")", ",", "null", ",", "null", ",", "$", "tokenizer", ")", ";", "}", "$", "this", "->", "tokenizer", "=", "$", "tokenizer", ";", "}" ]
Assigns a tokenizer to this instance. @since [*next-version*] @param TokenizerInterface|null $tokenizer The tokenizer.
[ "Assigns", "a", "tokenizer", "to", "this", "instance", "." ]
45588113b1fca6daf62b776aade8627d08970565
https://github.com/Dhii/tokenizer-abstract/blob/45588113b1fca6daf62b776aade8627d08970565/src/TokenizerAwareTrait.php#L41-L48
1,215
MarHue/cms-migration-tool
app/Console/Commands/CMSMigrationTool.php
CMSMigrationTool.chooseCMS
protected function chooseCMS($availableInputSystems, $availableOutputSystems) { $this->info("\n************************************************"); $this->info("\n********* CMS Migration Manager ************"); $this->info("\n************************************************"); $in = $this->choice('Which input format?', array_keys($availableInputSystems)); $out = $this->choice('Which output format?', array_keys($availableOutputSystems)); return array($in, $out); }
php
protected function chooseCMS($availableInputSystems, $availableOutputSystems) { $this->info("\n************************************************"); $this->info("\n********* CMS Migration Manager ************"); $this->info("\n************************************************"); $in = $this->choice('Which input format?', array_keys($availableInputSystems)); $out = $this->choice('Which output format?', array_keys($availableOutputSystems)); return array($in, $out); }
[ "protected", "function", "chooseCMS", "(", "$", "availableInputSystems", ",", "$", "availableOutputSystems", ")", "{", "$", "this", "->", "info", "(", "\"\\n************************************************\"", ")", ";", "$", "this", "->", "info", "(", "\"\\n********* CMS Migration Manager ************\"", ")", ";", "$", "this", "->", "info", "(", "\"\\n************************************************\"", ")", ";", "$", "in", "=", "$", "this", "->", "choice", "(", "'Which input format?'", ",", "array_keys", "(", "$", "availableInputSystems", ")", ")", ";", "$", "out", "=", "$", "this", "->", "choice", "(", "'Which output format?'", ",", "array_keys", "(", "$", "availableOutputSystems", ")", ")", ";", "return", "array", "(", "$", "in", ",", "$", "out", ")", ";", "}" ]
Starts Console Menu, Asks User to choose Input and Output CMS, returns array with the two integer @return array
[ "Starts", "Console", "Menu", "Asks", "User", "to", "choose", "Input", "and", "Output", "CMS", "returns", "array", "with", "the", "two", "integer" ]
1c285a7673f4ef3ca20818d7c7b807c630aabd46
https://github.com/MarHue/cms-migration-tool/blob/1c285a7673f4ef3ca20818d7c7b807c630aabd46/app/Console/Commands/CMSMigrationTool.php#L35-L46
1,216
MarHue/cms-migration-tool
app/Console/Commands/CMSMigrationTool.php
CMSMigrationTool.getInputAndOutputDisk
protected function getInputAndOutputDisk() { $validInputPath = FALSE; $validOutputPath = FALSE; //runs as long as user enters valid input root path while(!$validInputPath){ $goBack = FALSE; $rootInput = $this->choice('Which input disk?', array_keys(config('filesystems.disks.cms.migrations')), 0); if ($rootInput == 'custom_input') { while(!$validInputPath && !$goBack){ $rootInput = $this->ask('Please enter root-Path for Input-CMS'); if ($rootInput === 'x'){ $goBack = TRUE; } if(!file_exists($rootInput)){ $this->info('Invalid Path! Please enter valid Root-Path'); $this->info("\n" . '[x] -> Go back'); } else { $validInputPath = TRUE; } } } else{ //default-input-path $validInputPath = TRUE; } } //runs as long as user enters valid output root path while(!$validOutputPath){ $goBack = FALSE; $rootOutput = $this->choice('Which output disk?', array_keys(config('filesystems.disks.cms.migrations')), 1); if ($rootOutput == 'custom_output') { while(!$validOutputPath && !$goBack){ $rootOutput = $this->ask('Please enter root-Path for Output-CMS'); if ($rootOutput === 'x'){ $goBack = TRUE; } if(!file_exists($rootOutput)){ $this->info('Invalid Path! Please enter valid Root-Path'); $this->info("\n" . '[x] -> Go back'); } else { $validOutputPath = TRUE; } } } else{ //default-output-path $validOutputPath = TRUE; } } return array($rootInput, $rootOutput); }
php
protected function getInputAndOutputDisk() { $validInputPath = FALSE; $validOutputPath = FALSE; //runs as long as user enters valid input root path while(!$validInputPath){ $goBack = FALSE; $rootInput = $this->choice('Which input disk?', array_keys(config('filesystems.disks.cms.migrations')), 0); if ($rootInput == 'custom_input') { while(!$validInputPath && !$goBack){ $rootInput = $this->ask('Please enter root-Path for Input-CMS'); if ($rootInput === 'x'){ $goBack = TRUE; } if(!file_exists($rootInput)){ $this->info('Invalid Path! Please enter valid Root-Path'); $this->info("\n" . '[x] -> Go back'); } else { $validInputPath = TRUE; } } } else{ //default-input-path $validInputPath = TRUE; } } //runs as long as user enters valid output root path while(!$validOutputPath){ $goBack = FALSE; $rootOutput = $this->choice('Which output disk?', array_keys(config('filesystems.disks.cms.migrations')), 1); if ($rootOutput == 'custom_output') { while(!$validOutputPath && !$goBack){ $rootOutput = $this->ask('Please enter root-Path for Output-CMS'); if ($rootOutput === 'x'){ $goBack = TRUE; } if(!file_exists($rootOutput)){ $this->info('Invalid Path! Please enter valid Root-Path'); $this->info("\n" . '[x] -> Go back'); } else { $validOutputPath = TRUE; } } } else{ //default-output-path $validOutputPath = TRUE; } } return array($rootInput, $rootOutput); }
[ "protected", "function", "getInputAndOutputDisk", "(", ")", "{", "$", "validInputPath", "=", "FALSE", ";", "$", "validOutputPath", "=", "FALSE", ";", "//runs as long as user enters valid input root path", "while", "(", "!", "$", "validInputPath", ")", "{", "$", "goBack", "=", "FALSE", ";", "$", "rootInput", "=", "$", "this", "->", "choice", "(", "'Which input disk?'", ",", "array_keys", "(", "config", "(", "'filesystems.disks.cms.migrations'", ")", ")", ",", "0", ")", ";", "if", "(", "$", "rootInput", "==", "'custom_input'", ")", "{", "while", "(", "!", "$", "validInputPath", "&&", "!", "$", "goBack", ")", "{", "$", "rootInput", "=", "$", "this", "->", "ask", "(", "'Please enter root-Path for Input-CMS'", ")", ";", "if", "(", "$", "rootInput", "===", "'x'", ")", "{", "$", "goBack", "=", "TRUE", ";", "}", "if", "(", "!", "file_exists", "(", "$", "rootInput", ")", ")", "{", "$", "this", "->", "info", "(", "'Invalid Path! Please enter valid Root-Path'", ")", ";", "$", "this", "->", "info", "(", "\"\\n\"", ".", "'[x] -> Go back'", ")", ";", "}", "else", "{", "$", "validInputPath", "=", "TRUE", ";", "}", "}", "}", "else", "{", "//default-input-path", "$", "validInputPath", "=", "TRUE", ";", "}", "}", "//runs as long as user enters valid output root path", "while", "(", "!", "$", "validOutputPath", ")", "{", "$", "goBack", "=", "FALSE", ";", "$", "rootOutput", "=", "$", "this", "->", "choice", "(", "'Which output disk?'", ",", "array_keys", "(", "config", "(", "'filesystems.disks.cms.migrations'", ")", ")", ",", "1", ")", ";", "if", "(", "$", "rootOutput", "==", "'custom_output'", ")", "{", "while", "(", "!", "$", "validOutputPath", "&&", "!", "$", "goBack", ")", "{", "$", "rootOutput", "=", "$", "this", "->", "ask", "(", "'Please enter root-Path for Output-CMS'", ")", ";", "if", "(", "$", "rootOutput", "===", "'x'", ")", "{", "$", "goBack", "=", "TRUE", ";", "}", "if", "(", "!", "file_exists", "(", "$", "rootOutput", ")", ")", "{", "$", "this", "->", "info", "(", "'Invalid Path! Please enter valid Root-Path'", ")", ";", "$", "this", "->", "info", "(", "\"\\n\"", ".", "'[x] -> Go back'", ")", ";", "}", "else", "{", "$", "validOutputPath", "=", "TRUE", ";", "}", "}", "}", "else", "{", "//default-output-path", "$", "validOutputPath", "=", "TRUE", ";", "}", "}", "return", "array", "(", "$", "rootInput", ",", "$", "rootOutput", ")", ";", "}" ]
Asks User to enter Root-Path of Input and Output CMS @return array with the two strings
[ "Asks", "User", "to", "enter", "Root", "-", "Path", "of", "Input", "and", "Output", "CMS" ]
1c285a7673f4ef3ca20818d7c7b807c630aabd46
https://github.com/MarHue/cms-migration-tool/blob/1c285a7673f4ef3ca20818d7c7b807c630aabd46/app/Console/Commands/CMSMigrationTool.php#L52-L104
1,217
liftkit/core
src/Loader/File/Script.php
Script.load
public function load ($path, $data = array()) { extract($data); $fullPath = $this->transformPath($path); if (is_file($fullPath)) { return include($fullPath); } else { throw new NonexistentFileException('Script not found: ' . $fullPath); } }
php
public function load ($path, $data = array()) { extract($data); $fullPath = $this->transformPath($path); if (is_file($fullPath)) { return include($fullPath); } else { throw new NonexistentFileException('Script not found: ' . $fullPath); } }
[ "public", "function", "load", "(", "$", "path", ",", "$", "data", "=", "array", "(", ")", ")", "{", "extract", "(", "$", "data", ")", ";", "$", "fullPath", "=", "$", "this", "->", "transformPath", "(", "$", "path", ")", ";", "if", "(", "is_file", "(", "$", "fullPath", ")", ")", "{", "return", "include", "(", "$", "fullPath", ")", ";", "}", "else", "{", "throw", "new", "NonexistentFileException", "(", "'Script not found: '", ".", "$", "fullPath", ")", ";", "}", "}" ]
Includes a PHP file and returns any result returned by the file. @api @param string $path Path to file. Beware that this is not an absolute path if you set the basePath or suffix in the constructor. @param array $data An associative array of variables to be injected into the file. @return mixed @throws NonexistentFileException
[ "Includes", "a", "PHP", "file", "and", "returns", "any", "result", "returned", "by", "the", "file", "." ]
c98dcffa65450bd11332dbffe2064650c3a72aae
https://github.com/liftkit/core/blob/c98dcffa65450bd11332dbffe2064650c3a72aae/src/Loader/File/Script.php#L38-L48
1,218
webriq/core
module/Paragraph/src/Grid/Paragraph/Controller/ContentController.php
ContentController.editAction
public function editAction() { $params = $this->params(); $request = $this->getRequest(); $locator = $this->getServiceLocator(); $model = $locator->get( 'Grid\Paragraph\Model\Paragraph\Model' ) ->setLocale( $this->getAdminLocale() ); $form = $locator->get( 'Form' ) ->create( 'Grid\Paragraph\Content' ); if ( ( $id = $params->fromRoute( 'id' ) ) ) { $paragraph = $model->find( $id ); if ( empty( $paragraph ) ) { $this->getResponse() ->setStatusCode( 404 ); return; } if ( ! $paragraph->isEditable() ) { $this->getResponse() ->setStatusCode( 403 ); return; } } else { if ( ! $this->getPermissionsModel() ->isAllowed( 'paragraph.content', 'create' ) ) { $this->getResponse() ->setStatusCode( 403 ); return; } $userId = $this->getAuthenticationService() ->getIdentity() ->id; $paragraph = $model->create( array( 'type' => 'content', 'created' => time(), 'userId' => $userId, 'editUsers' => array( $userId ), ) ); } /* @var $form \Zend\Form\Form */ $form->setHydrator( $model->getMapper() ) ->bind( $paragraph ); if ( $request->isPost() ) { $form->setData( $request->getPost() ); if ( $form->isValid() && $paragraph->save() ) { $this->messenger() ->add( 'paragraph.form.content.success', 'paragraph', Message::LEVEL_INFO ); return $this->redirect() ->toRoute( 'Grid\Paragraph\Content\List', array( 'locale' => (string) $this->locale(), ) ); } else { $this->messenger() ->add( 'paragraph.form.content.failed', 'paragraph', Message::LEVEL_ERROR ); } } $form->setCancel( $this->url() ->fromRoute( 'Grid\Paragraph\Content\List', array( 'locale' => (string) $this->locale(), ) ) ); return array( 'form' => $form, 'paragraph' => $paragraph, ); }
php
public function editAction() { $params = $this->params(); $request = $this->getRequest(); $locator = $this->getServiceLocator(); $model = $locator->get( 'Grid\Paragraph\Model\Paragraph\Model' ) ->setLocale( $this->getAdminLocale() ); $form = $locator->get( 'Form' ) ->create( 'Grid\Paragraph\Content' ); if ( ( $id = $params->fromRoute( 'id' ) ) ) { $paragraph = $model->find( $id ); if ( empty( $paragraph ) ) { $this->getResponse() ->setStatusCode( 404 ); return; } if ( ! $paragraph->isEditable() ) { $this->getResponse() ->setStatusCode( 403 ); return; } } else { if ( ! $this->getPermissionsModel() ->isAllowed( 'paragraph.content', 'create' ) ) { $this->getResponse() ->setStatusCode( 403 ); return; } $userId = $this->getAuthenticationService() ->getIdentity() ->id; $paragraph = $model->create( array( 'type' => 'content', 'created' => time(), 'userId' => $userId, 'editUsers' => array( $userId ), ) ); } /* @var $form \Zend\Form\Form */ $form->setHydrator( $model->getMapper() ) ->bind( $paragraph ); if ( $request->isPost() ) { $form->setData( $request->getPost() ); if ( $form->isValid() && $paragraph->save() ) { $this->messenger() ->add( 'paragraph.form.content.success', 'paragraph', Message::LEVEL_INFO ); return $this->redirect() ->toRoute( 'Grid\Paragraph\Content\List', array( 'locale' => (string) $this->locale(), ) ); } else { $this->messenger() ->add( 'paragraph.form.content.failed', 'paragraph', Message::LEVEL_ERROR ); } } $form->setCancel( $this->url() ->fromRoute( 'Grid\Paragraph\Content\List', array( 'locale' => (string) $this->locale(), ) ) ); return array( 'form' => $form, 'paragraph' => $paragraph, ); }
[ "public", "function", "editAction", "(", ")", "{", "$", "params", "=", "$", "this", "->", "params", "(", ")", ";", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "locator", "=", "$", "this", "->", "getServiceLocator", "(", ")", ";", "$", "model", "=", "$", "locator", "->", "get", "(", "'Grid\\Paragraph\\Model\\Paragraph\\Model'", ")", "->", "setLocale", "(", "$", "this", "->", "getAdminLocale", "(", ")", ")", ";", "$", "form", "=", "$", "locator", "->", "get", "(", "'Form'", ")", "->", "create", "(", "'Grid\\Paragraph\\Content'", ")", ";", "if", "(", "(", "$", "id", "=", "$", "params", "->", "fromRoute", "(", "'id'", ")", ")", ")", "{", "$", "paragraph", "=", "$", "model", "->", "find", "(", "$", "id", ")", ";", "if", "(", "empty", "(", "$", "paragraph", ")", ")", "{", "$", "this", "->", "getResponse", "(", ")", "->", "setStatusCode", "(", "404", ")", ";", "return", ";", "}", "if", "(", "!", "$", "paragraph", "->", "isEditable", "(", ")", ")", "{", "$", "this", "->", "getResponse", "(", ")", "->", "setStatusCode", "(", "403", ")", ";", "return", ";", "}", "}", "else", "{", "if", "(", "!", "$", "this", "->", "getPermissionsModel", "(", ")", "->", "isAllowed", "(", "'paragraph.content'", ",", "'create'", ")", ")", "{", "$", "this", "->", "getResponse", "(", ")", "->", "setStatusCode", "(", "403", ")", ";", "return", ";", "}", "$", "userId", "=", "$", "this", "->", "getAuthenticationService", "(", ")", "->", "getIdentity", "(", ")", "->", "id", ";", "$", "paragraph", "=", "$", "model", "->", "create", "(", "array", "(", "'type'", "=>", "'content'", ",", "'created'", "=>", "time", "(", ")", ",", "'userId'", "=>", "$", "userId", ",", "'editUsers'", "=>", "array", "(", "$", "userId", ")", ",", ")", ")", ";", "}", "/* @var $form \\Zend\\Form\\Form */", "$", "form", "->", "setHydrator", "(", "$", "model", "->", "getMapper", "(", ")", ")", "->", "bind", "(", "$", "paragraph", ")", ";", "if", "(", "$", "request", "->", "isPost", "(", ")", ")", "{", "$", "form", "->", "setData", "(", "$", "request", "->", "getPost", "(", ")", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", "&&", "$", "paragraph", "->", "save", "(", ")", ")", "{", "$", "this", "->", "messenger", "(", ")", "->", "add", "(", "'paragraph.form.content.success'", ",", "'paragraph'", ",", "Message", "::", "LEVEL_INFO", ")", ";", "return", "$", "this", "->", "redirect", "(", ")", "->", "toRoute", "(", "'Grid\\Paragraph\\Content\\List'", ",", "array", "(", "'locale'", "=>", "(", "string", ")", "$", "this", "->", "locale", "(", ")", ",", ")", ")", ";", "}", "else", "{", "$", "this", "->", "messenger", "(", ")", "->", "add", "(", "'paragraph.form.content.failed'", ",", "'paragraph'", ",", "Message", "::", "LEVEL_ERROR", ")", ";", "}", "}", "$", "form", "->", "setCancel", "(", "$", "this", "->", "url", "(", ")", "->", "fromRoute", "(", "'Grid\\Paragraph\\Content\\List'", ",", "array", "(", "'locale'", "=>", "(", "string", ")", "$", "this", "->", "locale", "(", ")", ",", ")", ")", ")", ";", "return", "array", "(", "'form'", "=>", "$", "form", ",", "'paragraph'", "=>", "$", "paragraph", ",", ")", ";", "}" ]
Edit a content
[ "Edit", "a", "content" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Controller/ContentController.php#L31-L122
1,219
webriq/core
module/Paragraph/src/Grid/Paragraph/Controller/ContentController.php
ContentController.cloneAction
public function cloneAction() { if ( ! $this->getPermissionsModel() ->isAllowed( 'paragraph.content', 'create' ) ) { $this->getResponse() ->setStatusCode( 403 ); return; } $params = $this->params(); $locator = $this->getServiceLocator(); $model = $locator->get( 'Grid\Paragraph\Model\Paragraph\Model' ) ->setLocale( $this->getAdminLocale() ); $paragraph = $model->find( $params->fromRoute( 'id' ) ); if ( empty( $paragraph ) || $paragraph->type !== 'content' ) { $this->getResponse() ->setStatusCode( 404 ); return; } $cloneId = $model->cloneFrom( $paragraph->id ); if ( $cloneId ) { $clone = $model->find( $cloneId ); if ( ! empty( $clone ) ) { $userId = $this->getAuthenticationService() ->getIdentity() ->id; if ( empty( $clone->userId ) ) { $clone->userId = $userId; } if ( ! in_array( $userId, $clone->editUsers ) ) { $clone->editUsers = array_merge( $clone->editUsers, array( $userId ) ); } $clone->name = rtrim( $clone->name ) . ' ' . $locator->get( 'Zork\I18n\Translator\Translator' ) ->translate( 'default.cloned', 'default' ); $clone->save(); } $this->messenger() ->add( 'paragraph.action.clone.success', 'paragraph', Message::LEVEL_INFO ); } else { $this->messenger() ->add( 'paragraph.action.clone.failed', 'paragraph', Message::LEVEL_ERROR ); } return $this->redirect() ->toRoute( 'Grid\Paragraph\Content\List', array( 'locale' => (string) $this->locale(), ) ); }
php
public function cloneAction() { if ( ! $this->getPermissionsModel() ->isAllowed( 'paragraph.content', 'create' ) ) { $this->getResponse() ->setStatusCode( 403 ); return; } $params = $this->params(); $locator = $this->getServiceLocator(); $model = $locator->get( 'Grid\Paragraph\Model\Paragraph\Model' ) ->setLocale( $this->getAdminLocale() ); $paragraph = $model->find( $params->fromRoute( 'id' ) ); if ( empty( $paragraph ) || $paragraph->type !== 'content' ) { $this->getResponse() ->setStatusCode( 404 ); return; } $cloneId = $model->cloneFrom( $paragraph->id ); if ( $cloneId ) { $clone = $model->find( $cloneId ); if ( ! empty( $clone ) ) { $userId = $this->getAuthenticationService() ->getIdentity() ->id; if ( empty( $clone->userId ) ) { $clone->userId = $userId; } if ( ! in_array( $userId, $clone->editUsers ) ) { $clone->editUsers = array_merge( $clone->editUsers, array( $userId ) ); } $clone->name = rtrim( $clone->name ) . ' ' . $locator->get( 'Zork\I18n\Translator\Translator' ) ->translate( 'default.cloned', 'default' ); $clone->save(); } $this->messenger() ->add( 'paragraph.action.clone.success', 'paragraph', Message::LEVEL_INFO ); } else { $this->messenger() ->add( 'paragraph.action.clone.failed', 'paragraph', Message::LEVEL_ERROR ); } return $this->redirect() ->toRoute( 'Grid\Paragraph\Content\List', array( 'locale' => (string) $this->locale(), ) ); }
[ "public", "function", "cloneAction", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getPermissionsModel", "(", ")", "->", "isAllowed", "(", "'paragraph.content'", ",", "'create'", ")", ")", "{", "$", "this", "->", "getResponse", "(", ")", "->", "setStatusCode", "(", "403", ")", ";", "return", ";", "}", "$", "params", "=", "$", "this", "->", "params", "(", ")", ";", "$", "locator", "=", "$", "this", "->", "getServiceLocator", "(", ")", ";", "$", "model", "=", "$", "locator", "->", "get", "(", "'Grid\\Paragraph\\Model\\Paragraph\\Model'", ")", "->", "setLocale", "(", "$", "this", "->", "getAdminLocale", "(", ")", ")", ";", "$", "paragraph", "=", "$", "model", "->", "find", "(", "$", "params", "->", "fromRoute", "(", "'id'", ")", ")", ";", "if", "(", "empty", "(", "$", "paragraph", ")", "||", "$", "paragraph", "->", "type", "!==", "'content'", ")", "{", "$", "this", "->", "getResponse", "(", ")", "->", "setStatusCode", "(", "404", ")", ";", "return", ";", "}", "$", "cloneId", "=", "$", "model", "->", "cloneFrom", "(", "$", "paragraph", "->", "id", ")", ";", "if", "(", "$", "cloneId", ")", "{", "$", "clone", "=", "$", "model", "->", "find", "(", "$", "cloneId", ")", ";", "if", "(", "!", "empty", "(", "$", "clone", ")", ")", "{", "$", "userId", "=", "$", "this", "->", "getAuthenticationService", "(", ")", "->", "getIdentity", "(", ")", "->", "id", ";", "if", "(", "empty", "(", "$", "clone", "->", "userId", ")", ")", "{", "$", "clone", "->", "userId", "=", "$", "userId", ";", "}", "if", "(", "!", "in_array", "(", "$", "userId", ",", "$", "clone", "->", "editUsers", ")", ")", "{", "$", "clone", "->", "editUsers", "=", "array_merge", "(", "$", "clone", "->", "editUsers", ",", "array", "(", "$", "userId", ")", ")", ";", "}", "$", "clone", "->", "name", "=", "rtrim", "(", "$", "clone", "->", "name", ")", ".", "' '", ".", "$", "locator", "->", "get", "(", "'Zork\\I18n\\Translator\\Translator'", ")", "->", "translate", "(", "'default.cloned'", ",", "'default'", ")", ";", "$", "clone", "->", "save", "(", ")", ";", "}", "$", "this", "->", "messenger", "(", ")", "->", "add", "(", "'paragraph.action.clone.success'", ",", "'paragraph'", ",", "Message", "::", "LEVEL_INFO", ")", ";", "}", "else", "{", "$", "this", "->", "messenger", "(", ")", "->", "add", "(", "'paragraph.action.clone.failed'", ",", "'paragraph'", ",", "Message", "::", "LEVEL_ERROR", ")", ";", "}", "return", "$", "this", "->", "redirect", "(", ")", "->", "toRoute", "(", "'Grid\\Paragraph\\Content\\List'", ",", "array", "(", "'locale'", "=>", "(", "string", ")", "$", "this", "->", "locale", "(", ")", ",", ")", ")", ";", "}" ]
Clone a content
[ "Clone", "a", "content" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Controller/ContentController.php#L127-L199
1,220
webriq/core
module/Paragraph/src/Grid/Paragraph/Controller/ContentController.php
ContentController.deleteAction
public function deleteAction() { $params = $this->params(); $locator = $this->getServiceLocator(); $model = $locator->get( 'Grid\Paragraph\Model\Paragraph\Model' ); $paragraph = $model->find( $params->fromRoute( 'id' ) ); if ( empty( $paragraph ) || $paragraph->type !== 'content' ) { $this->getResponse() ->setStatusCode( 404 ); return; } if ( ! $paragraph->isDeletable() ) { $this->getResponse() ->setStatusCode( 403 ); return; } if ( $paragraph->delete() ) { $this->messenger() ->add( 'paragraph.action.delete.success', 'paragraph', Message::LEVEL_INFO ); } else { $this->messenger() ->add( 'paragraph.action.delete.failed', 'paragraph', Message::LEVEL_ERROR ); } return $this->redirect() ->toRoute( 'Grid\Paragraph\Content\List', array( 'locale' => (string) $this->locale(), ) ); }
php
public function deleteAction() { $params = $this->params(); $locator = $this->getServiceLocator(); $model = $locator->get( 'Grid\Paragraph\Model\Paragraph\Model' ); $paragraph = $model->find( $params->fromRoute( 'id' ) ); if ( empty( $paragraph ) || $paragraph->type !== 'content' ) { $this->getResponse() ->setStatusCode( 404 ); return; } if ( ! $paragraph->isDeletable() ) { $this->getResponse() ->setStatusCode( 403 ); return; } if ( $paragraph->delete() ) { $this->messenger() ->add( 'paragraph.action.delete.success', 'paragraph', Message::LEVEL_INFO ); } else { $this->messenger() ->add( 'paragraph.action.delete.failed', 'paragraph', Message::LEVEL_ERROR ); } return $this->redirect() ->toRoute( 'Grid\Paragraph\Content\List', array( 'locale' => (string) $this->locale(), ) ); }
[ "public", "function", "deleteAction", "(", ")", "{", "$", "params", "=", "$", "this", "->", "params", "(", ")", ";", "$", "locator", "=", "$", "this", "->", "getServiceLocator", "(", ")", ";", "$", "model", "=", "$", "locator", "->", "get", "(", "'Grid\\Paragraph\\Model\\Paragraph\\Model'", ")", ";", "$", "paragraph", "=", "$", "model", "->", "find", "(", "$", "params", "->", "fromRoute", "(", "'id'", ")", ")", ";", "if", "(", "empty", "(", "$", "paragraph", ")", "||", "$", "paragraph", "->", "type", "!==", "'content'", ")", "{", "$", "this", "->", "getResponse", "(", ")", "->", "setStatusCode", "(", "404", ")", ";", "return", ";", "}", "if", "(", "!", "$", "paragraph", "->", "isDeletable", "(", ")", ")", "{", "$", "this", "->", "getResponse", "(", ")", "->", "setStatusCode", "(", "403", ")", ";", "return", ";", "}", "if", "(", "$", "paragraph", "->", "delete", "(", ")", ")", "{", "$", "this", "->", "messenger", "(", ")", "->", "add", "(", "'paragraph.action.delete.success'", ",", "'paragraph'", ",", "Message", "::", "LEVEL_INFO", ")", ";", "}", "else", "{", "$", "this", "->", "messenger", "(", ")", "->", "add", "(", "'paragraph.action.delete.failed'", ",", "'paragraph'", ",", "Message", "::", "LEVEL_ERROR", ")", ";", "}", "return", "$", "this", "->", "redirect", "(", ")", "->", "toRoute", "(", "'Grid\\Paragraph\\Content\\List'", ",", "array", "(", "'locale'", "=>", "(", "string", ")", "$", "this", "->", "locale", "(", ")", ",", ")", ")", ";", "}" ]
Delete a content
[ "Delete", "a", "content" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Controller/ContentController.php#L204-L244
1,221
synapsestudios/synapse-base
src/Synapse/View/Migration/Create.php
Create.description
public function description($description = null) { if ($description === null) { return $this->description; } $this->description = $description; }
php
public function description($description = null) { if ($description === null) { return $this->description; } $this->description = $description; }
[ "public", "function", "description", "(", "$", "description", "=", "null", ")", "{", "if", "(", "$", "description", "===", "null", ")", "{", "return", "$", "this", "->", "description", ";", "}", "$", "this", "->", "description", "=", "$", "description", ";", "}" ]
Set or get the description of the migration @param string $description Migration description. If omitted, acts as a getter. @return string
[ "Set", "or", "get", "the", "description", "of", "the", "migration" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/View/Migration/Create.php#L39-L46
1,222
synapsestudios/synapse-base
src/Synapse/View/Migration/Create.php
Create.classname
public function classname($classname = null) { if ($classname === null) { return $this->classname; } $this->classname = $classname; }
php
public function classname($classname = null) { if ($classname === null) { return $this->classname; } $this->classname = $classname; }
[ "public", "function", "classname", "(", "$", "classname", "=", "null", ")", "{", "if", "(", "$", "classname", "===", "null", ")", "{", "return", "$", "this", "->", "classname", ";", "}", "$", "this", "->", "classname", "=", "$", "classname", ";", "}" ]
Set or get the name of the migration class @param string $classname Name of the migration class. If omitted, acts as a getter. @return string
[ "Set", "or", "get", "the", "name", "of", "the", "migration", "class" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/View/Migration/Create.php#L54-L61
1,223
binsoul/common
src/Decorator.php
Decorator.setDecoratedObject
public function setDecoratedObject($decorated) { if (!is_object($decorated)) { throw new \InvalidArgumentException( sprintf( 'Expected an object but got an argument of type "%s" instead.', gettype($decorated) ) ); } $this->decoratedObject = $decorated; }
php
public function setDecoratedObject($decorated) { if (!is_object($decorated)) { throw new \InvalidArgumentException( sprintf( 'Expected an object but got an argument of type "%s" instead.', gettype($decorated) ) ); } $this->decoratedObject = $decorated; }
[ "public", "function", "setDecoratedObject", "(", "$", "decorated", ")", "{", "if", "(", "!", "is_object", "(", "$", "decorated", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Expected an object but got an argument of type \"%s\" instead.'", ",", "gettype", "(", "$", "decorated", ")", ")", ")", ";", "}", "$", "this", "->", "decoratedObject", "=", "$", "decorated", ";", "}" ]
Sets the decorated object. @param object $decorated
[ "Sets", "the", "decorated", "object", "." ]
668a62dada22727c0b75e9484dce587d7a490889
https://github.com/binsoul/common/blob/668a62dada22727c0b75e9484dce587d7a490889/src/Decorator.php#L30-L42
1,224
zicht/z-plugin-lftp
lftp/Plugin.php
Plugin.parseFtpString
public function parseFtpString($ftpUrl) { if(is_null($this->ftpUsername)){ if(preg_match('/^(?:ftp:\/\/)?([^:]+):([^@]+)@(.*)$/',$ftpUrl,$matches)){ $this->ftpUsername = $matches[1]; $this->ftpPassword = $matches[2]; $this->ftpDomain = $matches[3]; }else{ throw new \Exception('Ftp string in wrong format, use [ftp://]username:[email protected]'); } } }
php
public function parseFtpString($ftpUrl) { if(is_null($this->ftpUsername)){ if(preg_match('/^(?:ftp:\/\/)?([^:]+):([^@]+)@(.*)$/',$ftpUrl,$matches)){ $this->ftpUsername = $matches[1]; $this->ftpPassword = $matches[2]; $this->ftpDomain = $matches[3]; }else{ throw new \Exception('Ftp string in wrong format, use [ftp://]username:[email protected]'); } } }
[ "public", "function", "parseFtpString", "(", "$", "ftpUrl", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "ftpUsername", ")", ")", "{", "if", "(", "preg_match", "(", "'/^(?:ftp:\\/\\/)?([^:]+):([^@]+)@(.*)$/'", ",", "$", "ftpUrl", ",", "$", "matches", ")", ")", "{", "$", "this", "->", "ftpUsername", "=", "$", "matches", "[", "1", "]", ";", "$", "this", "->", "ftpPassword", "=", "$", "matches", "[", "2", "]", ";", "$", "this", "->", "ftpDomain", "=", "$", "matches", "[", "3", "]", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Ftp string in wrong format, use [ftp://]username:[email protected]'", ")", ";", "}", "}", "}" ]
helper function to set local vars @param $ftpUrl @throws \Exception
[ "helper", "function", "to", "set", "local", "vars" ]
1d9f38de4945e1ba1709e42ca8f6d9abc8fbd840
https://github.com/zicht/z-plugin-lftp/blob/1d9f38de4945e1ba1709e42ca8f6d9abc8fbd840/lftp/Plugin.php#L50-L61
1,225
phossa2/libs
src/Phossa2/Query/Dialect/Mysql/Union.php
Union.buildUnion
protected function buildUnion( /*# string */ $prefix, array $settings )/*# : string */ { $clause = &$this->getClause('UNION'); $flat = $this->flatSettings($settings); $res = ''; foreach ($clause as $idx => $field) { $parts = []; $prefix = $idx ? $field[1] : ''; $parts[] = $this->quoteItem($field[0], $flat); $res .= $this->joinClause($prefix, '', $parts, $settings); } return ltrim($res); }
php
protected function buildUnion( /*# string */ $prefix, array $settings )/*# : string */ { $clause = &$this->getClause('UNION'); $flat = $this->flatSettings($settings); $res = ''; foreach ($clause as $idx => $field) { $parts = []; $prefix = $idx ? $field[1] : ''; $parts[] = $this->quoteItem($field[0], $flat); $res .= $this->joinClause($prefix, '', $parts, $settings); } return ltrim($res); }
[ "protected", "function", "buildUnion", "(", "/*# string */", "$", "prefix", ",", "array", "$", "settings", ")", "/*# : string */", "{", "$", "clause", "=", "&", "$", "this", "->", "getClause", "(", "'UNION'", ")", ";", "$", "flat", "=", "$", "this", "->", "flatSettings", "(", "$", "settings", ")", ";", "$", "res", "=", "''", ";", "foreach", "(", "$", "clause", "as", "$", "idx", "=>", "$", "field", ")", "{", "$", "parts", "=", "[", "]", ";", "$", "prefix", "=", "$", "idx", "?", "$", "field", "[", "1", "]", ":", "''", ";", "$", "parts", "[", "]", "=", "$", "this", "->", "quoteItem", "(", "$", "field", "[", "0", "]", ",", "$", "flat", ")", ";", "$", "res", ".=", "$", "this", "->", "joinClause", "(", "$", "prefix", ",", "''", ",", "$", "parts", ",", "$", "settings", ")", ";", "}", "return", "ltrim", "(", "$", "res", ")", ";", "}" ]
Build unioned SELECT @param string $prefix @param array $settings @return string @access protected
[ "Build", "unioned", "SELECT" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Query/Dialect/Mysql/Union.php#L72-L87
1,226
robertasproniu/tic-tac-toe-agent
src/TicTacToe.php
TicTacToe.makeMove
public function makeMove(array $boardState, $player = Game::PLAYER_A) { $this->setBoard($boardState); $recommendedMove = $this->getMove($player) ?: []; return $recommendedMove ? array_merge($recommendedMove , [$player]): []; }
php
public function makeMove(array $boardState, $player = Game::PLAYER_A) { $this->setBoard($boardState); $recommendedMove = $this->getMove($player) ?: []; return $recommendedMove ? array_merge($recommendedMove , [$player]): []; }
[ "public", "function", "makeMove", "(", "array", "$", "boardState", ",", "$", "player", "=", "Game", "::", "PLAYER_A", ")", "{", "$", "this", "->", "setBoard", "(", "$", "boardState", ")", ";", "$", "recommendedMove", "=", "$", "this", "->", "getMove", "(", "$", "player", ")", "?", ":", "[", "]", ";", "return", "$", "recommendedMove", "?", "array_merge", "(", "$", "recommendedMove", ",", "[", "$", "player", "]", ")", ":", "[", "]", ";", "}" ]
Get move for a particular player @param array $boardState @param string $player @return array
[ "Get", "move", "for", "a", "particular", "player" ]
00bc8e31e3c9770f2ee24d97d82e40dff20e3e98
https://github.com/robertasproniu/tic-tac-toe-agent/blob/00bc8e31e3c9770f2ee24d97d82e40dff20e3e98/src/TicTacToe.php#L18-L25
1,227
dankempster/axstrad-test-bundle
Functional/AbstractAxstradKernel.php
AbstractAxstradKernel.registerContainerConfiguration
public function registerContainerConfiguration(LoaderInterface $loader) { $classInfo = new \ReflectionClass($this); $dir = dirname($classInfo->getFileName()); $loader->load($dir . '/config.yml'); }
php
public function registerContainerConfiguration(LoaderInterface $loader) { $classInfo = new \ReflectionClass($this); $dir = dirname($classInfo->getFileName()); $loader->load($dir . '/config.yml'); }
[ "public", "function", "registerContainerConfiguration", "(", "LoaderInterface", "$", "loader", ")", "{", "$", "classInfo", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "$", "dir", "=", "dirname", "(", "$", "classInfo", "->", "getFileName", "(", ")", ")", ";", "$", "loader", "->", "load", "(", "$", "dir", ".", "'/config.yml'", ")", ";", "}" ]
Register container configuration @param LoaderInterface $loader Loader
[ "Register", "container", "configuration" ]
7b8272fd81fd97d493169657a1b9a8fdc6808e52
https://github.com/dankempster/axstrad-test-bundle/blob/7b8272fd81fd97d493169657a1b9a8fdc6808e52/Functional/AbstractAxstradKernel.php#L46-L51
1,228
atelierspierrot/library
src/Library/Helper/Code.php
Code.implementsInterface
public static function implementsInterface($class_name, $interface_name) { if (is_object($class_name)) { $class_name = get_class($class_name); } if (class_exists($class_name)) { $interfaces = class_implements($class_name); return (bool) in_array($interface_name, $interfaces) || in_array(trim($interface_name, '\\'), $interfaces); } return false; }
php
public static function implementsInterface($class_name, $interface_name) { if (is_object($class_name)) { $class_name = get_class($class_name); } if (class_exists($class_name)) { $interfaces = class_implements($class_name); return (bool) in_array($interface_name, $interfaces) || in_array(trim($interface_name, '\\'), $interfaces); } return false; }
[ "public", "static", "function", "implementsInterface", "(", "$", "class_name", ",", "$", "interface_name", ")", "{", "if", "(", "is_object", "(", "$", "class_name", ")", ")", "{", "$", "class_name", "=", "get_class", "(", "$", "class_name", ")", ";", "}", "if", "(", "class_exists", "(", "$", "class_name", ")", ")", "{", "$", "interfaces", "=", "class_implements", "(", "$", "class_name", ")", ";", "return", "(", "bool", ")", "in_array", "(", "$", "interface_name", ",", "$", "interfaces", ")", "||", "in_array", "(", "trim", "(", "$", "interface_name", ",", "'\\\\'", ")", ",", "$", "interfaces", ")", ";", "}", "return", "false", ";", "}" ]
Check if a class implements a certain interface @param string|object $class_name The class name to test or a full object of this class @param string $interface_name The interface name to test @return bool
[ "Check", "if", "a", "class", "implements", "a", "certain", "interface" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Code.php#L87-L97
1,229
atelierspierrot/library
src/Library/Helper/Code.php
Code.extendsClass
public static function extendsClass($class_name, $mother_name) { if (is_object($class_name)) { $class_name = get_class($class_name); } if (class_exists($class_name)) { return (bool) is_subclass_of($class_name, $mother_name); } return false; }
php
public static function extendsClass($class_name, $mother_name) { if (is_object($class_name)) { $class_name = get_class($class_name); } if (class_exists($class_name)) { return (bool) is_subclass_of($class_name, $mother_name); } return false; }
[ "public", "static", "function", "extendsClass", "(", "$", "class_name", ",", "$", "mother_name", ")", "{", "if", "(", "is_object", "(", "$", "class_name", ")", ")", "{", "$", "class_name", "=", "get_class", "(", "$", "class_name", ")", ";", "}", "if", "(", "class_exists", "(", "$", "class_name", ")", ")", "{", "return", "(", "bool", ")", "is_subclass_of", "(", "$", "class_name", ",", "$", "mother_name", ")", ";", "}", "return", "false", ";", "}" ]
Check if a class extends a certain class @param string|object $class_name The class name to test or a full object of this class @param string $mother_name The class name to extend @return bool
[ "Check", "if", "a", "class", "extends", "a", "certain", "class" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Code.php#L107-L116
1,230
atelierspierrot/library
src/Library/Helper/Code.php
Code.isClassInstance
public static function isClassInstance($object, $class_name) { if (class_exists($class_name) && is_object($object)) { return (bool) ($object instanceof $class_name); } return false; }
php
public static function isClassInstance($object, $class_name) { if (class_exists($class_name) && is_object($object)) { return (bool) ($object instanceof $class_name); } return false; }
[ "public", "static", "function", "isClassInstance", "(", "$", "object", ",", "$", "class_name", ")", "{", "if", "(", "class_exists", "(", "$", "class_name", ")", "&&", "is_object", "(", "$", "object", ")", ")", "{", "return", "(", "bool", ")", "(", "$", "object", "instanceof", "$", "class_name", ")", ";", "}", "return", "false", ";", "}" ]
Check if a an object is an instance of a class @param object $object @param string $class_name @return bool
[ "Check", "if", "a", "an", "object", "is", "an", "instance", "of", "a", "class" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Code.php#L126-L132
1,231
atelierspierrot/library
src/Library/Helper/Code.php
Code.namespaceExists
public static function namespaceExists($namespace) { $namespace = trim($namespace, self::NAMESPACE_SEPARATOR); $namespace .= self::NAMESPACE_SEPARATOR; foreach (get_declared_classes() as $name) { if (strpos($name, $namespace) === 0) { return true; } } if (class_exists($_composer_loader = self::COMPOSER_AUTOLOADER_CLASSNAME)) { $_composer_reflection = new \ReflectionClass($_composer_loader); $_loader_filename = $_composer_reflection->getFilename(); $_classmap_filename = dirname($_loader_filename) .DIRECTORY_SEPARATOR .self::COMPOSER_COMMON_NAMESPACES_AUTOLOADER; if (file_exists($_classmap_filename)) { $namespaces_map = include $_classmap_filename; foreach ($namespaces_map as $_ns=>$_dir) { $_ns = trim($_ns, self::NAMESPACE_SEPARATOR); if (strpos($_ns, $namespace) === 0) { return true; } if (substr($namespace, 0, strlen($_ns))===$_ns) { if (false !== $pos = strrpos($namespace, self::NAMESPACE_SEPARATOR)) { // namespaced class name $namespace_path = strtr(substr($namespace, 0, $pos), self::NAMESPACE_SEPARATOR, DIRECTORY_SEPARATOR); $namespace_name = substr($namespace, $pos + 1); } else { // PEAR-like class name $namespace_path = null; $namespace_name = $namespace; } $namespace_path .= strtr($namespace_name, '_', DIRECTORY_SEPARATOR); if (!is_array($_dir)) { $_dir = array($_dir); } foreach ($_dir as $_testdir) { $_d = DirectoryHelper::slashDirname($_testdir) . $namespace_path; if (file_exists($_d) && is_dir($_d)) { return true; } } } } } } return false; }
php
public static function namespaceExists($namespace) { $namespace = trim($namespace, self::NAMESPACE_SEPARATOR); $namespace .= self::NAMESPACE_SEPARATOR; foreach (get_declared_classes() as $name) { if (strpos($name, $namespace) === 0) { return true; } } if (class_exists($_composer_loader = self::COMPOSER_AUTOLOADER_CLASSNAME)) { $_composer_reflection = new \ReflectionClass($_composer_loader); $_loader_filename = $_composer_reflection->getFilename(); $_classmap_filename = dirname($_loader_filename) .DIRECTORY_SEPARATOR .self::COMPOSER_COMMON_NAMESPACES_AUTOLOADER; if (file_exists($_classmap_filename)) { $namespaces_map = include $_classmap_filename; foreach ($namespaces_map as $_ns=>$_dir) { $_ns = trim($_ns, self::NAMESPACE_SEPARATOR); if (strpos($_ns, $namespace) === 0) { return true; } if (substr($namespace, 0, strlen($_ns))===$_ns) { if (false !== $pos = strrpos($namespace, self::NAMESPACE_SEPARATOR)) { // namespaced class name $namespace_path = strtr(substr($namespace, 0, $pos), self::NAMESPACE_SEPARATOR, DIRECTORY_SEPARATOR); $namespace_name = substr($namespace, $pos + 1); } else { // PEAR-like class name $namespace_path = null; $namespace_name = $namespace; } $namespace_path .= strtr($namespace_name, '_', DIRECTORY_SEPARATOR); if (!is_array($_dir)) { $_dir = array($_dir); } foreach ($_dir as $_testdir) { $_d = DirectoryHelper::slashDirname($_testdir) . $namespace_path; if (file_exists($_d) && is_dir($_d)) { return true; } } } } } } return false; }
[ "public", "static", "function", "namespaceExists", "(", "$", "namespace", ")", "{", "$", "namespace", "=", "trim", "(", "$", "namespace", ",", "self", "::", "NAMESPACE_SEPARATOR", ")", ";", "$", "namespace", ".=", "self", "::", "NAMESPACE_SEPARATOR", ";", "foreach", "(", "get_declared_classes", "(", ")", "as", "$", "name", ")", "{", "if", "(", "strpos", "(", "$", "name", ",", "$", "namespace", ")", "===", "0", ")", "{", "return", "true", ";", "}", "}", "if", "(", "class_exists", "(", "$", "_composer_loader", "=", "self", "::", "COMPOSER_AUTOLOADER_CLASSNAME", ")", ")", "{", "$", "_composer_reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "_composer_loader", ")", ";", "$", "_loader_filename", "=", "$", "_composer_reflection", "->", "getFilename", "(", ")", ";", "$", "_classmap_filename", "=", "dirname", "(", "$", "_loader_filename", ")", ".", "DIRECTORY_SEPARATOR", ".", "self", "::", "COMPOSER_COMMON_NAMESPACES_AUTOLOADER", ";", "if", "(", "file_exists", "(", "$", "_classmap_filename", ")", ")", "{", "$", "namespaces_map", "=", "include", "$", "_classmap_filename", ";", "foreach", "(", "$", "namespaces_map", "as", "$", "_ns", "=>", "$", "_dir", ")", "{", "$", "_ns", "=", "trim", "(", "$", "_ns", ",", "self", "::", "NAMESPACE_SEPARATOR", ")", ";", "if", "(", "strpos", "(", "$", "_ns", ",", "$", "namespace", ")", "===", "0", ")", "{", "return", "true", ";", "}", "if", "(", "substr", "(", "$", "namespace", ",", "0", ",", "strlen", "(", "$", "_ns", ")", ")", "===", "$", "_ns", ")", "{", "if", "(", "false", "!==", "$", "pos", "=", "strrpos", "(", "$", "namespace", ",", "self", "::", "NAMESPACE_SEPARATOR", ")", ")", "{", "// namespaced class name", "$", "namespace_path", "=", "strtr", "(", "substr", "(", "$", "namespace", ",", "0", ",", "$", "pos", ")", ",", "self", "::", "NAMESPACE_SEPARATOR", ",", "DIRECTORY_SEPARATOR", ")", ";", "$", "namespace_name", "=", "substr", "(", "$", "namespace", ",", "$", "pos", "+", "1", ")", ";", "}", "else", "{", "// PEAR-like class name", "$", "namespace_path", "=", "null", ";", "$", "namespace_name", "=", "$", "namespace", ";", "}", "$", "namespace_path", ".=", "strtr", "(", "$", "namespace_name", ",", "'_'", ",", "DIRECTORY_SEPARATOR", ")", ";", "if", "(", "!", "is_array", "(", "$", "_dir", ")", ")", "{", "$", "_dir", "=", "array", "(", "$", "_dir", ")", ";", "}", "foreach", "(", "$", "_dir", "as", "$", "_testdir", ")", "{", "$", "_d", "=", "DirectoryHelper", "::", "slashDirname", "(", "$", "_testdir", ")", ".", "$", "namespace_path", ";", "if", "(", "file_exists", "(", "$", "_d", ")", "&&", "is_dir", "(", "$", "_d", ")", ")", "{", "return", "true", ";", "}", "}", "}", "}", "}", "}", "return", "false", ";", "}" ]
Test if a namespace can be found in declared classes or via Composer autoloader if so This method will search concerned namespace in PHP declared classes namespaces and, if found, in a Composer namespaces mapping usually stored in `vendor/composer/autoload_namespaces.php`, searching for a directory that should contains the nameapace following the [FIG standards](https://github.com/php-fig/fig-standards). @param string $namespace @return bool
[ "Test", "if", "a", "namespace", "can", "be", "found", "in", "declared", "classes", "or", "via", "Composer", "autoloader", "if", "so" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Code.php#L161-L213
1,232
atelierspierrot/library
src/Library/Helper/Code.php
Code.fetchArguments
public static function fetchArguments($method_name = null, $arguments = null, $class_name = null, &$logs = array()) { $args_def = self::organizeArguments($method_name, $arguments, $class_name, $logs); if (!empty($class_name)) { if (is_callable(array($class_name, $method_name))) { return call_user_func_array(array($class_name, $method_name), $args_def); } else { $_cls = is_object($class_name) ? get_class($class_name) : $class_name; throw new \InvalidArgumentException( sprintf('Method "%s" of class object "%s" is not callable!', $method_name, $_cls) ); } } else { return call_user_func_array($method_name, $args_def); } }
php
public static function fetchArguments($method_name = null, $arguments = null, $class_name = null, &$logs = array()) { $args_def = self::organizeArguments($method_name, $arguments, $class_name, $logs); if (!empty($class_name)) { if (is_callable(array($class_name, $method_name))) { return call_user_func_array(array($class_name, $method_name), $args_def); } else { $_cls = is_object($class_name) ? get_class($class_name) : $class_name; throw new \InvalidArgumentException( sprintf('Method "%s" of class object "%s" is not callable!', $method_name, $_cls) ); } } else { return call_user_func_array($method_name, $args_def); } }
[ "public", "static", "function", "fetchArguments", "(", "$", "method_name", "=", "null", ",", "$", "arguments", "=", "null", ",", "$", "class_name", "=", "null", ",", "&", "$", "logs", "=", "array", "(", ")", ")", "{", "$", "args_def", "=", "self", "::", "organizeArguments", "(", "$", "method_name", ",", "$", "arguments", ",", "$", "class_name", ",", "$", "logs", ")", ";", "if", "(", "!", "empty", "(", "$", "class_name", ")", ")", "{", "if", "(", "is_callable", "(", "array", "(", "$", "class_name", ",", "$", "method_name", ")", ")", ")", "{", "return", "call_user_func_array", "(", "array", "(", "$", "class_name", ",", "$", "method_name", ")", ",", "$", "args_def", ")", ";", "}", "else", "{", "$", "_cls", "=", "is_object", "(", "$", "class_name", ")", "?", "get_class", "(", "$", "class_name", ")", ":", "$", "class_name", ";", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Method \"%s\" of class object \"%s\" is not callable!'", ",", "$", "method_name", ",", "$", "_cls", ")", ")", ";", "}", "}", "else", "{", "return", "call_user_func_array", "(", "$", "method_name", ",", "$", "args_def", ")", ";", "}", "}" ]
Launch a function or class's method fetching it arguments according to its declaration @param string $method_name The method name @param mixed $arguments A set of arguments to fetch @param string $class_name The class name @param array $logs Will be filled with indexes `miss` with missing required arguments and `rest` with unused `$arguments` - Passed by reference @return mixed @throws \InvalidArgumentException if the method is not callable
[ "Launch", "a", "function", "or", "class", "s", "method", "fetching", "it", "arguments", "according", "to", "its", "declaration" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Code.php#L226-L241
1,233
tomk79/php-excellent-db
php/create.php
create.get_physical_table_name
public function get_physical_table_name($table_name){ $prefix = $this->conf()->prefix; if( strlen($prefix) ){ $prefix = preg_replace('/\_*$/', '_', $prefix); } return $prefix.$table_name; }
php
public function get_physical_table_name($table_name){ $prefix = $this->conf()->prefix; if( strlen($prefix) ){ $prefix = preg_replace('/\_*$/', '_', $prefix); } return $prefix.$table_name; }
[ "public", "function", "get_physical_table_name", "(", "$", "table_name", ")", "{", "$", "prefix", "=", "$", "this", "->", "conf", "(", ")", "->", "prefix", ";", "if", "(", "strlen", "(", "$", "prefix", ")", ")", "{", "$", "prefix", "=", "preg_replace", "(", "'/\\_*$/'", ",", "'_'", ",", "$", "prefix", ")", ";", "}", "return", "$", "prefix", ".", "$", "table_name", ";", "}" ]
getting table prefix @param string $table_name テーブル名 @return String Table Prefix
[ "getting", "table", "prefix" ]
deeacf64c090fc5647267a06f97c3fb60fdf8f68
https://github.com/tomk79/php-excellent-db/blob/deeacf64c090fc5647267a06f97c3fb60fdf8f68/php/create.php#L277-L283
1,234
dazarobbo/Cola
src/Database/MySQL/String.php
String.parse
public static function parse($object){ $len = \strlen($object); if(Number::between($len, MySQL::getConstant('CHAR_LEN_MIN'), MySQL::getConstant('CHAR_LEN_MAX'))){ return new static($len, static::CHAR); } else if(Number::between($len, MySQL::getConstant('VARCHAR_LEN_MIN'), MySQL::getConstant('VARCHAR_LEN_MAX'))){ return new static($len, static::VARCHAR); } else if(Number::between($len, MySQL::getConstant('MEDIUMTEXT_LEN_MIN'), MySQL::getConstant('MEDIUMTEXT_LEN_MAX'))){ return new static($len, static::MEDIUMTEXT); } else if(Number::between($len, MySQL::getConstant('LONGTEXT_LEN_MIN'), MySQL::getConstant('LONGTEXT_LEN_MAX'))){ return new static($len, static::LONGTEXT); } return null; }
php
public static function parse($object){ $len = \strlen($object); if(Number::between($len, MySQL::getConstant('CHAR_LEN_MIN'), MySQL::getConstant('CHAR_LEN_MAX'))){ return new static($len, static::CHAR); } else if(Number::between($len, MySQL::getConstant('VARCHAR_LEN_MIN'), MySQL::getConstant('VARCHAR_LEN_MAX'))){ return new static($len, static::VARCHAR); } else if(Number::between($len, MySQL::getConstant('MEDIUMTEXT_LEN_MIN'), MySQL::getConstant('MEDIUMTEXT_LEN_MAX'))){ return new static($len, static::MEDIUMTEXT); } else if(Number::between($len, MySQL::getConstant('LONGTEXT_LEN_MIN'), MySQL::getConstant('LONGTEXT_LEN_MAX'))){ return new static($len, static::LONGTEXT); } return null; }
[ "public", "static", "function", "parse", "(", "$", "object", ")", "{", "$", "len", "=", "\\", "strlen", "(", "$", "object", ")", ";", "if", "(", "Number", "::", "between", "(", "$", "len", ",", "MySQL", "::", "getConstant", "(", "'CHAR_LEN_MIN'", ")", ",", "MySQL", "::", "getConstant", "(", "'CHAR_LEN_MAX'", ")", ")", ")", "{", "return", "new", "static", "(", "$", "len", ",", "static", "::", "CHAR", ")", ";", "}", "else", "if", "(", "Number", "::", "between", "(", "$", "len", ",", "MySQL", "::", "getConstant", "(", "'VARCHAR_LEN_MIN'", ")", ",", "MySQL", "::", "getConstant", "(", "'VARCHAR_LEN_MAX'", ")", ")", ")", "{", "return", "new", "static", "(", "$", "len", ",", "static", "::", "VARCHAR", ")", ";", "}", "else", "if", "(", "Number", "::", "between", "(", "$", "len", ",", "MySQL", "::", "getConstant", "(", "'MEDIUMTEXT_LEN_MIN'", ")", ",", "MySQL", "::", "getConstant", "(", "'MEDIUMTEXT_LEN_MAX'", ")", ")", ")", "{", "return", "new", "static", "(", "$", "len", ",", "static", "::", "MEDIUMTEXT", ")", ";", "}", "else", "if", "(", "Number", "::", "between", "(", "$", "len", ",", "MySQL", "::", "getConstant", "(", "'LONGTEXT_LEN_MIN'", ")", ",", "MySQL", "::", "getConstant", "(", "'LONGTEXT_LEN_MAX'", ")", ")", ")", "{", "return", "new", "static", "(", "$", "len", ",", "static", "::", "LONGTEXT", ")", ";", "}", "return", "null", ";", "}" ]
Parse a string object to a MySQL string type Prefers VARCHARs over BLOBs @param mixed $object @return \static
[ "Parse", "a", "string", "object", "to", "a", "MySQL", "string", "type", "Prefers", "VARCHARs", "over", "BLOBs" ]
b101b73ebeb8a571345a303cbc75168f60d0e64f
https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/Database/MySQL/String.php#L44-L67
1,235
swoopaholic/Components
Routing/RouteProvider.php
RouteProvider.getRouteCollectionForRequest
public function getRouteCollectionForRequest(Request $request) { $slug = '/' . trim($request->getPathInfo(), '/'); $document = $this->repository->findOneBy(array('slug' => $slug)); $collection = new RouteCollection(); if ($document) { $controller = $this->templateControllers[$document->getTemplate()]; $route = new Route( $document->getSlug(), array( '_controller' => $controller, 'document' => $document ) ); $collection->add('test', $route); } return $collection; }
php
public function getRouteCollectionForRequest(Request $request) { $slug = '/' . trim($request->getPathInfo(), '/'); $document = $this->repository->findOneBy(array('slug' => $slug)); $collection = new RouteCollection(); if ($document) { $controller = $this->templateControllers[$document->getTemplate()]; $route = new Route( $document->getSlug(), array( '_controller' => $controller, 'document' => $document ) ); $collection->add('test', $route); } return $collection; }
[ "public", "function", "getRouteCollectionForRequest", "(", "Request", "$", "request", ")", "{", "$", "slug", "=", "'/'", ".", "trim", "(", "$", "request", "->", "getPathInfo", "(", ")", ",", "'/'", ")", ";", "$", "document", "=", "$", "this", "->", "repository", "->", "findOneBy", "(", "array", "(", "'slug'", "=>", "$", "slug", ")", ")", ";", "$", "collection", "=", "new", "RouteCollection", "(", ")", ";", "if", "(", "$", "document", ")", "{", "$", "controller", "=", "$", "this", "->", "templateControllers", "[", "$", "document", "->", "getTemplate", "(", ")", "]", ";", "$", "route", "=", "new", "Route", "(", "$", "document", "->", "getSlug", "(", ")", ",", "array", "(", "'_controller'", "=>", "$", "controller", ",", "'document'", "=>", "$", "document", ")", ")", ";", "$", "collection", "->", "add", "(", "'test'", ",", "$", "route", ")", ";", "}", "return", "$", "collection", ";", "}" ]
Finds routes that may potentially match the request. This may return a mixed list of class instances, but all routes returned must extend the core symfony route. The classes may also implement RouteObjectInterface to link to a content document. This method may not throw an exception based on implementation specific restrictions on the url. That case is considered a not found - returning an empty array. Exceptions are only used to abort the whole request in case something is seriously broken, like the storage backend being down. Note that implementations may not implement an optimal matching algorithm, simply a reasonable first pass. That allows for potentially very large route sets to be filtered down to likely candidates, which may then be filtered in memory more completely. @param Request $request A request against which to match. @return \Symfony\Component\Routing\RouteCollection with all Routes that could potentially match $request. Empty collection if nothing can match.
[ "Finds", "routes", "that", "may", "potentially", "match", "the", "request", "." ]
a665248a4d3285dea936579a763b5a7ecfe62c4a
https://github.com/swoopaholic/Components/blob/a665248a4d3285dea936579a763b5a7ecfe62c4a/Routing/RouteProvider.php#L80-L101
1,236
gearphp/loop
Tick/AbstractTick.php
AbstractTick.catchException
protected function catchException(\Exception $e) { foreach ($this->onException as $call) { call_user_func_array($call, [$e]); } throw $e; }
php
protected function catchException(\Exception $e) { foreach ($this->onException as $call) { call_user_func_array($call, [$e]); } throw $e; }
[ "protected", "function", "catchException", "(", "\\", "Exception", "$", "e", ")", "{", "foreach", "(", "$", "this", "->", "onException", "as", "$", "call", ")", "{", "call_user_func_array", "(", "$", "call", ",", "[", "$", "e", "]", ")", ";", "}", "throw", "$", "e", ";", "}" ]
Catch tick exception and throw it. @param \Exception $e @throws \Exception
[ "Catch", "tick", "exception", "and", "throw", "it", "." ]
53032b3e9f789b729744922c75e09b2a33845f90
https://github.com/gearphp/loop/blob/53032b3e9f789b729744922c75e09b2a33845f90/Tick/AbstractTick.php#L119-L126
1,237
FuturaSoft/Pabana
src/Parser/Ini.php
Ini.load
public function load($filename) { if (!file_exists($filename)) { throw new \Exception('Ini file "' . $filename . '" doesn\'t exist.'); return false; } $this->filename = $filename; return $this; }
php
public function load($filename) { if (!file_exists($filename)) { throw new \Exception('Ini file "' . $filename . '" doesn\'t exist.'); return false; } $this->filename = $filename; return $this; }
[ "public", "function", "load", "(", "$", "filename", ")", "{", "if", "(", "!", "file_exists", "(", "$", "filename", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Ini file \"'", ".", "$", "filename", ".", "'\" doesn\\'t exist.'", ")", ";", "return", "false", ";", "}", "$", "this", "->", "filename", "=", "$", "filename", ";", "return", "$", "this", ";", "}" ]
Load INI file @since 1.0 @param string $filename File path. @return bool|$this
[ "Load", "INI", "file" ]
b3a95eeb976042ac2a393cc10755a7adbc164c24
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Parser/Ini.php#L37-L45
1,238
calgamo/event-loop
src/EventContext.php
EventContext.pushEvent
public function pushEvent(string $name, $data = null) : Event { $event = new Event($name, $data); $this->queue->enqueue($event); return $event; }
php
public function pushEvent(string $name, $data = null) : Event { $event = new Event($name, $data); $this->queue->enqueue($event); return $event; }
[ "public", "function", "pushEvent", "(", "string", "$", "name", ",", "$", "data", "=", "null", ")", ":", "Event", "{", "$", "event", "=", "new", "Event", "(", "$", "name", ",", "$", "data", ")", ";", "$", "this", "->", "queue", "->", "enqueue", "(", "$", "event", ")", ";", "return", "$", "event", ";", "}" ]
Add an event to event queue @param string $name @param mixed $data @return Event
[ "Add", "an", "event", "to", "event", "queue" ]
f85a9c153f2548a94ddc58334c001f241dd8f12d
https://github.com/calgamo/event-loop/blob/f85a9c153f2548a94ddc58334c001f241dd8f12d/src/EventContext.php#L62-L67
1,239
buybrain/nervus-php
src/Buybrain/Nervus/Adapter/TypedAdapter.php
TypedAdapter.addHandler
protected function addHandler(TypedHandler $handler) { $this->addHandlerTypes($handler); $this->handlers[] = $handler; return $this; }
php
protected function addHandler(TypedHandler $handler) { $this->addHandlerTypes($handler); $this->handlers[] = $handler; return $this; }
[ "protected", "function", "addHandler", "(", "TypedHandler", "$", "handler", ")", "{", "$", "this", "->", "addHandlerTypes", "(", "$", "handler", ")", ";", "$", "this", "->", "handlers", "[", "]", "=", "$", "handler", ";", "return", "$", "this", ";", "}" ]
Add a handler to the adapter. The handler's supported types will be added to the adapter's supported types. @param TypedHandler $handler @return $this
[ "Add", "a", "handler", "to", "the", "adapter", ".", "The", "handler", "s", "supported", "types", "will", "be", "added", "to", "the", "adapter", "s", "supported", "types", "." ]
96e00e30571b3ea4cf3494cd26c930ffa336c3bf
https://github.com/buybrain/nervus-php/blob/96e00e30571b3ea4cf3494cd26c930ffa336c3bf/src/Buybrain/Nervus/Adapter/TypedAdapter.php#L29-L34
1,240
buybrain/nervus-php
src/Buybrain/Nervus/Adapter/TypedAdapter.php
TypedAdapter.assignToHandlers
protected function assignToHandlers(array $objects) { $result = []; $perType = TypedUtils::groupByType($objects); foreach ($this->handlers as $handler) { $remainingTypes = array_keys($perType); $handlerTypes = $handler->getSupportedEntityTypes(); $useTypes = $handlerTypes === null ? $remainingTypes : array_intersect($handlerTypes, $remainingTypes); if (count($useTypes) > 0) { $assigned = []; foreach ($useTypes as $type) { $assigned[] = $perType[$type]; unset($perType[$type]); } $result[] = [$handler, Arrays::flatten($assigned)]; if (count($perType) === 0) { // Done break; } } } return $result; }
php
protected function assignToHandlers(array $objects) { $result = []; $perType = TypedUtils::groupByType($objects); foreach ($this->handlers as $handler) { $remainingTypes = array_keys($perType); $handlerTypes = $handler->getSupportedEntityTypes(); $useTypes = $handlerTypes === null ? $remainingTypes : array_intersect($handlerTypes, $remainingTypes); if (count($useTypes) > 0) { $assigned = []; foreach ($useTypes as $type) { $assigned[] = $perType[$type]; unset($perType[$type]); } $result[] = [$handler, Arrays::flatten($assigned)]; if (count($perType) === 0) { // Done break; } } } return $result; }
[ "protected", "function", "assignToHandlers", "(", "array", "$", "objects", ")", "{", "$", "result", "=", "[", "]", ";", "$", "perType", "=", "TypedUtils", "::", "groupByType", "(", "$", "objects", ")", ";", "foreach", "(", "$", "this", "->", "handlers", "as", "$", "handler", ")", "{", "$", "remainingTypes", "=", "array_keys", "(", "$", "perType", ")", ";", "$", "handlerTypes", "=", "$", "handler", "->", "getSupportedEntityTypes", "(", ")", ";", "$", "useTypes", "=", "$", "handlerTypes", "===", "null", "?", "$", "remainingTypes", ":", "array_intersect", "(", "$", "handlerTypes", ",", "$", "remainingTypes", ")", ";", "if", "(", "count", "(", "$", "useTypes", ")", ">", "0", ")", "{", "$", "assigned", "=", "[", "]", ";", "foreach", "(", "$", "useTypes", "as", "$", "type", ")", "{", "$", "assigned", "[", "]", "=", "$", "perType", "[", "$", "type", "]", ";", "unset", "(", "$", "perType", "[", "$", "type", "]", ")", ";", "}", "$", "result", "[", "]", "=", "[", "$", "handler", ",", "Arrays", "::", "flatten", "(", "$", "assigned", ")", "]", ";", "if", "(", "count", "(", "$", "perType", ")", "===", "0", ")", "{", "// Done", "break", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
Assign every entity to the first handler that supports it @param Typed[] $objects @return array tuples of [Handler, object[]]
[ "Assign", "every", "entity", "to", "the", "first", "handler", "that", "supports", "it" ]
96e00e30571b3ea4cf3494cd26c930ffa336c3bf
https://github.com/buybrain/nervus-php/blob/96e00e30571b3ea4cf3494cd26c930ffa336c3bf/src/Buybrain/Nervus/Adapter/TypedAdapter.php#L68-L91
1,241
buybrain/nervus-php
src/Buybrain/Nervus/Adapter/TypedAdapter.php
TypedAdapter.checkUnsupportedTypes
protected function checkUnsupportedTypes(array $objects) { if ($this->supportedTypes !== null) { $unsupportedTypes = array_diff(TypedUtils::uniqueTypes($objects), $this->supportedTypes); if (count($unsupportedTypes) > 0) { throw new Exception(sprintf( 'Encountered unsupported types %s (supported: %s)', implode(', ', $unsupportedTypes), count($this->supportedTypes) > 0 ? implode(', ', $this->supportedTypes) : '*none*' )); } } }
php
protected function checkUnsupportedTypes(array $objects) { if ($this->supportedTypes !== null) { $unsupportedTypes = array_diff(TypedUtils::uniqueTypes($objects), $this->supportedTypes); if (count($unsupportedTypes) > 0) { throw new Exception(sprintf( 'Encountered unsupported types %s (supported: %s)', implode(', ', $unsupportedTypes), count($this->supportedTypes) > 0 ? implode(', ', $this->supportedTypes) : '*none*' )); } } }
[ "protected", "function", "checkUnsupportedTypes", "(", "array", "$", "objects", ")", "{", "if", "(", "$", "this", "->", "supportedTypes", "!==", "null", ")", "{", "$", "unsupportedTypes", "=", "array_diff", "(", "TypedUtils", "::", "uniqueTypes", "(", "$", "objects", ")", ",", "$", "this", "->", "supportedTypes", ")", ";", "if", "(", "count", "(", "$", "unsupportedTypes", ")", ">", "0", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Encountered unsupported types %s (supported: %s)'", ",", "implode", "(", "', '", ",", "$", "unsupportedTypes", ")", ",", "count", "(", "$", "this", "->", "supportedTypes", ")", ">", "0", "?", "implode", "(", "', '", ",", "$", "this", "->", "supportedTypes", ")", ":", "'*none*'", ")", ")", ";", "}", "}", "}" ]
Validate that all the entity types from a request are supported by this adapter @param Typed[] $objects
[ "Validate", "that", "all", "the", "entity", "types", "from", "a", "request", "are", "supported", "by", "this", "adapter" ]
96e00e30571b3ea4cf3494cd26c930ffa336c3bf
https://github.com/buybrain/nervus-php/blob/96e00e30571b3ea4cf3494cd26c930ffa336c3bf/src/Buybrain/Nervus/Adapter/TypedAdapter.php#L98-L110
1,242
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.table
final public function table($table, $getData = false, $dataType = null) { if (!empty($table)) { $this->from($table); //if getData; run getData; } return $this; }
php
final public function table($table, $getData = false, $dataType = null) { if (!empty($table)) { $this->from($table); //if getData; run getData; } return $this; }
[ "final", "public", "function", "table", "(", "$", "table", ",", "$", "getData", "=", "false", ",", "$", "dataType", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "table", ")", ")", "{", "$", "this", "->", "from", "(", "$", "table", ")", ";", "//if getData; run getData;", "}", "return", "$", "this", ";", "}" ]
Specifies the table upon which a read or write query is performed @param string $table the table name with any prefix. e.g #__users @param boolean $getData if set to true, this method returns all stored data array @param mixed $dataType @return object TuiyoDatabase
[ "Specifies", "the", "table", "upon", "which", "a", "read", "or", "write", "query", "is", "performed" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L241-L249
1,243
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.traceTableAlias
final public function traceTableAlias($table) { if (is_array($table)) { foreach ($table as $t) { $this->traceTableAlias($t); } return; } // Does the string contain a comma? If so, we need to separate // the string into discreet statements if (strpos($table, ',') !== FALSE) { return $this->traceTableAlias(explode(',', $table)); } // if a table alias is used we can recognize it by a space if (strpos($table, " ") !== FALSE) { // if the alias is written with the AS keyword, remove it $table = preg_replace('/ AS /i', ' ', $table); // Grab the alias $table = trim(strrchr($table, " ")); // Store the alias, if it doesn't already exist if (!in_array($table, $this->arrayAliasedTables)) { $this->arrayAliasedTables[] = $table; } } }
php
final public function traceTableAlias($table) { if (is_array($table)) { foreach ($table as $t) { $this->traceTableAlias($t); } return; } // Does the string contain a comma? If so, we need to separate // the string into discreet statements if (strpos($table, ',') !== FALSE) { return $this->traceTableAlias(explode(',', $table)); } // if a table alias is used we can recognize it by a space if (strpos($table, " ") !== FALSE) { // if the alias is written with the AS keyword, remove it $table = preg_replace('/ AS /i', ' ', $table); // Grab the alias $table = trim(strrchr($table, " ")); // Store the alias, if it doesn't already exist if (!in_array($table, $this->arrayAliasedTables)) { $this->arrayAliasedTables[] = $table; } } }
[ "final", "public", "function", "traceTableAlias", "(", "$", "table", ")", "{", "if", "(", "is_array", "(", "$", "table", ")", ")", "{", "foreach", "(", "$", "table", "as", "$", "t", ")", "{", "$", "this", "->", "traceTableAlias", "(", "$", "t", ")", ";", "}", "return", ";", "}", "// Does the string contain a comma? If so, we need to separate", "// the string into discreet statements", "if", "(", "strpos", "(", "$", "table", ",", "','", ")", "!==", "FALSE", ")", "{", "return", "$", "this", "->", "traceTableAlias", "(", "explode", "(", "','", ",", "$", "table", ")", ")", ";", "}", "// if a table alias is used we can recognize it by a space", "if", "(", "strpos", "(", "$", "table", ",", "\" \"", ")", "!==", "FALSE", ")", "{", "// if the alias is written with the AS keyword, remove it", "$", "table", "=", "preg_replace", "(", "'/ AS /i'", ",", "' '", ",", "$", "table", ")", ";", "// Grab the alias", "$", "table", "=", "trim", "(", "strrchr", "(", "$", "table", ",", "\" \"", ")", ")", ";", "// Store the alias, if it doesn't already exist", "if", "(", "!", "in_array", "(", "$", "table", ",", "$", "this", "->", "arrayAliasedTables", ")", ")", "{", "$", "this", "->", "arrayAliasedTables", "[", "]", "=", "$", "table", ";", "}", "}", "}" ]
This method allows us to preserve and track table aliasis as we build the query statement @access private @param string $table the table name @return void
[ "This", "method", "allows", "us", "to", "preserve", "and", "track", "table", "aliasis", "as", "we", "build", "the", "query", "statement" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L288-L315
1,244
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.identifiers
final public function identifiers($identifier) { // Convert tabs or multiple spaces into single spaces $identifier = preg_replace('/[\t ]+/', ' ', $identifier); // If the item has an alias declaration we remove it and set it aside. // Basically we remove everything to the right of the first space $alias = ''; if (strpos($identifier, ' ') !== FALSE) { $alias = strstr($identifier, " "); $identifier = substr($identifier, 0, -strlen($alias)); } if (strpos($identifier, '.') !== FALSE) { //do something } //return for now return $identifier . $alias; }
php
final public function identifiers($identifier) { // Convert tabs or multiple spaces into single spaces $identifier = preg_replace('/[\t ]+/', ' ', $identifier); // If the item has an alias declaration we remove it and set it aside. // Basically we remove everything to the right of the first space $alias = ''; if (strpos($identifier, ' ') !== FALSE) { $alias = strstr($identifier, " "); $identifier = substr($identifier, 0, -strlen($alias)); } if (strpos($identifier, '.') !== FALSE) { //do something } //return for now return $identifier . $alias; }
[ "final", "public", "function", "identifiers", "(", "$", "identifier", ")", "{", "// Convert tabs or multiple spaces into single spaces", "$", "identifier", "=", "preg_replace", "(", "'/[\\t ]+/'", ",", "' '", ",", "$", "identifier", ")", ";", "// If the item has an alias declaration we remove it and set it aside.", "// Basically we remove everything to the right of the first space", "$", "alias", "=", "''", ";", "if", "(", "strpos", "(", "$", "identifier", ",", "' '", ")", "!==", "FALSE", ")", "{", "$", "alias", "=", "strstr", "(", "$", "identifier", ",", "\" \"", ")", ";", "$", "identifier", "=", "substr", "(", "$", "identifier", ",", "0", ",", "-", "strlen", "(", "$", "alias", ")", ")", ";", "}", "if", "(", "strpos", "(", "$", "identifier", ",", "'.'", ")", "!==", "FALSE", ")", "{", "//do something", "}", "//return for now", "return", "$", "identifier", ".", "$", "alias", ";", "}" ]
Helper method for modifying any indentifiers in the query @param string $identifier @access private @return string modified identifier e.g escaped, santized etc
[ "Helper", "method", "for", "modifying", "any", "indentifiers", "in", "the", "query" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L325-L345
1,245
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.orderBy
final public function orderBy($orderby, $direction = '') { if (strtolower($direction) == 'random') { $orderby = ''; // Random results want or don't need a field name $direction = $this->_randomKeyword; } elseif (trim($direction) != '') { $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' ' . $direction : ' ASC'; } if (strpos($orderby, ',') !== FALSE) { $temp = array(); foreach (explode(',', $orderby) as $part) { $part = trim($part); if (!in_array($part, $this->arrayAliasedTables)) { $part = $this->identifiers(trim($part)); } $temp[] = $part; } $orderby = implode(', ', $temp); } else if ($direction != $this->_randomKeyword) { $orderby = $this->identifiers($orderby); } $orderbyStatement = $orderby . $direction; $this->arrayOrderBy[] = $orderbyStatement; if ($this->arrayCaching === TRUE) { $this->arrayCacheOrderBy[] = $orderbyStatement; $this->arrayCacheExists[] = 'orderby'; } return $this; }
php
final public function orderBy($orderby, $direction = '') { if (strtolower($direction) == 'random') { $orderby = ''; // Random results want or don't need a field name $direction = $this->_randomKeyword; } elseif (trim($direction) != '') { $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' ' . $direction : ' ASC'; } if (strpos($orderby, ',') !== FALSE) { $temp = array(); foreach (explode(',', $orderby) as $part) { $part = trim($part); if (!in_array($part, $this->arrayAliasedTables)) { $part = $this->identifiers(trim($part)); } $temp[] = $part; } $orderby = implode(', ', $temp); } else if ($direction != $this->_randomKeyword) { $orderby = $this->identifiers($orderby); } $orderbyStatement = $orderby . $direction; $this->arrayOrderBy[] = $orderbyStatement; if ($this->arrayCaching === TRUE) { $this->arrayCacheOrderBy[] = $orderbyStatement; $this->arrayCacheExists[] = 'orderby'; } return $this; }
[ "final", "public", "function", "orderBy", "(", "$", "orderby", ",", "$", "direction", "=", "''", ")", "{", "if", "(", "strtolower", "(", "$", "direction", ")", "==", "'random'", ")", "{", "$", "orderby", "=", "''", ";", "// Random results want or don't need a field name", "$", "direction", "=", "$", "this", "->", "_randomKeyword", ";", "}", "elseif", "(", "trim", "(", "$", "direction", ")", "!=", "''", ")", "{", "$", "direction", "=", "(", "in_array", "(", "strtoupper", "(", "trim", "(", "$", "direction", ")", ")", ",", "array", "(", "'ASC'", ",", "'DESC'", ")", ",", "TRUE", ")", ")", "?", "' '", ".", "$", "direction", ":", "' ASC'", ";", "}", "if", "(", "strpos", "(", "$", "orderby", ",", "','", ")", "!==", "FALSE", ")", "{", "$", "temp", "=", "array", "(", ")", ";", "foreach", "(", "explode", "(", "','", ",", "$", "orderby", ")", "as", "$", "part", ")", "{", "$", "part", "=", "trim", "(", "$", "part", ")", ";", "if", "(", "!", "in_array", "(", "$", "part", ",", "$", "this", "->", "arrayAliasedTables", ")", ")", "{", "$", "part", "=", "$", "this", "->", "identifiers", "(", "trim", "(", "$", "part", ")", ")", ";", "}", "$", "temp", "[", "]", "=", "$", "part", ";", "}", "$", "orderby", "=", "implode", "(", "', '", ",", "$", "temp", ")", ";", "}", "else", "if", "(", "$", "direction", "!=", "$", "this", "->", "_randomKeyword", ")", "{", "$", "orderby", "=", "$", "this", "->", "identifiers", "(", "$", "orderby", ")", ";", "}", "$", "orderbyStatement", "=", "$", "orderby", ".", "$", "direction", ";", "$", "this", "->", "arrayOrderBy", "[", "]", "=", "$", "orderbyStatement", ";", "if", "(", "$", "this", "->", "arrayCaching", "===", "TRUE", ")", "{", "$", "this", "->", "arrayCacheOrderBy", "[", "]", "=", "$", "orderbyStatement", ";", "$", "this", "->", "arrayCacheExists", "[", "]", "=", "'orderby'", ";", "}", "return", "$", "this", ";", "}" ]
Adds the ORDER BY clause to the query statement @param string $orderby @param string $direction @return ActiveRecord
[ "Adds", "the", "ORDER", "BY", "clause", "to", "the", "query", "statement" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L354-L388
1,246
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.count
final public function count($table = '', $resetselect = true) { if (!empty($table)) { $this->traceTableAlias($table); $this->fromTable($table); } $sql = $this->compile($this->_countString . $this->identifiers('totalcount'), true); $statement = $this->DBO->prepare($sql); $results = $statement->execute(); if ($resetselect) $this->resetSelect(); if ($results->rowCount() == 0) return '0'; $row = $results->fetchObject(); return $row->totalcount; }
php
final public function count($table = '', $resetselect = true) { if (!empty($table)) { $this->traceTableAlias($table); $this->fromTable($table); } $sql = $this->compile($this->_countString . $this->identifiers('totalcount'), true); $statement = $this->DBO->prepare($sql); $results = $statement->execute(); if ($resetselect) $this->resetSelect(); if ($results->rowCount() == 0) return '0'; $row = $results->fetchObject(); return $row->totalcount; }
[ "final", "public", "function", "count", "(", "$", "table", "=", "''", ",", "$", "resetselect", "=", "true", ")", "{", "if", "(", "!", "empty", "(", "$", "table", ")", ")", "{", "$", "this", "->", "traceTableAlias", "(", "$", "table", ")", ";", "$", "this", "->", "fromTable", "(", "$", "table", ")", ";", "}", "$", "sql", "=", "$", "this", "->", "compile", "(", "$", "this", "->", "_countString", ".", "$", "this", "->", "identifiers", "(", "'totalcount'", ")", ",", "true", ")", ";", "$", "statement", "=", "$", "this", "->", "DBO", "->", "prepare", "(", "$", "sql", ")", ";", "$", "results", "=", "$", "statement", "->", "execute", "(", ")", ";", "if", "(", "$", "resetselect", ")", "$", "this", "->", "resetSelect", "(", ")", ";", "if", "(", "$", "results", "->", "rowCount", "(", ")", "==", "0", ")", "return", "'0'", ";", "$", "row", "=", "$", "results", "->", "fetchObject", "(", ")", ";", "return", "$", "row", "->", "totalcount", ";", "}" ]
Counts all the records in the specified table Or records which satisfy the compiled SQL statement @param string $table @return interger
[ "Counts", "all", "the", "records", "in", "the", "specified", "table", "Or", "records", "which", "satisfy", "the", "compiled", "SQL", "statement" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L442-L460
1,247
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.where
final public function where($key, $value = NULL, $type = 'AND', $escape = TRUE) { if (empty($key)) { return $this; } if (!is_array($key)) { if (is_null($value)) { //some values could be '' return $this; } $key = array($key => $value); } //print_R($key); foreach ($key as $k => $v) { //The firs item adds the and prefix; $prefix = (count($this->arrayWhere) == 0 AND count($this->arrayCacheWhere) == 0) ? '' : $type . "\t"; if (is_null($v) && !$this->hasOperator($k)) { // value appears not to have been set, assign the test to IS NULL $k .= ' IS NULL'; } if (!is_null($v)) { if ($escape === TRUE) { $k = $this->identifiers($k); $v = '' . $this->escape($v); //$v = $this->quote( stripslashes($v) ); } if (!$this->hasOperator($k)) { $k .= ' ='; } } else { $k = $this->identifiers($k); } $this->arrayWhere[] = $prefix . $k . $v; if ($this->arrayCaching) { $this->arrayCacheWhere[] = $prefix . $k . $v; $this->arrayCacheExists[] = 'where'; } } return $this; }
php
final public function where($key, $value = NULL, $type = 'AND', $escape = TRUE) { if (empty($key)) { return $this; } if (!is_array($key)) { if (is_null($value)) { //some values could be '' return $this; } $key = array($key => $value); } //print_R($key); foreach ($key as $k => $v) { //The firs item adds the and prefix; $prefix = (count($this->arrayWhere) == 0 AND count($this->arrayCacheWhere) == 0) ? '' : $type . "\t"; if (is_null($v) && !$this->hasOperator($k)) { // value appears not to have been set, assign the test to IS NULL $k .= ' IS NULL'; } if (!is_null($v)) { if ($escape === TRUE) { $k = $this->identifiers($k); $v = '' . $this->escape($v); //$v = $this->quote( stripslashes($v) ); } if (!$this->hasOperator($k)) { $k .= ' ='; } } else { $k = $this->identifiers($k); } $this->arrayWhere[] = $prefix . $k . $v; if ($this->arrayCaching) { $this->arrayCacheWhere[] = $prefix . $k . $v; $this->arrayCacheExists[] = 'where'; } } return $this; }
[ "final", "public", "function", "where", "(", "$", "key", ",", "$", "value", "=", "NULL", ",", "$", "type", "=", "'AND'", ",", "$", "escape", "=", "TRUE", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "{", "return", "$", "this", ";", "}", "if", "(", "!", "is_array", "(", "$", "key", ")", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "//some values could be ''", "return", "$", "this", ";", "}", "$", "key", "=", "array", "(", "$", "key", "=>", "$", "value", ")", ";", "}", "//print_R($key);", "foreach", "(", "$", "key", "as", "$", "k", "=>", "$", "v", ")", "{", "//The firs item adds the and prefix;", "$", "prefix", "=", "(", "count", "(", "$", "this", "->", "arrayWhere", ")", "==", "0", "AND", "count", "(", "$", "this", "->", "arrayCacheWhere", ")", "==", "0", ")", "?", "''", ":", "$", "type", ".", "\"\\t\"", ";", "if", "(", "is_null", "(", "$", "v", ")", "&&", "!", "$", "this", "->", "hasOperator", "(", "$", "k", ")", ")", "{", "// value appears not to have been set, assign the test to IS NULL", "$", "k", ".=", "' IS NULL'", ";", "}", "if", "(", "!", "is_null", "(", "$", "v", ")", ")", "{", "if", "(", "$", "escape", "===", "TRUE", ")", "{", "$", "k", "=", "$", "this", "->", "identifiers", "(", "$", "k", ")", ";", "$", "v", "=", "''", ".", "$", "this", "->", "escape", "(", "$", "v", ")", ";", "//$v = $this->quote( stripslashes($v) );", "}", "if", "(", "!", "$", "this", "->", "hasOperator", "(", "$", "k", ")", ")", "{", "$", "k", ".=", "' ='", ";", "}", "}", "else", "{", "$", "k", "=", "$", "this", "->", "identifiers", "(", "$", "k", ")", ";", "}", "$", "this", "->", "arrayWhere", "[", "]", "=", "$", "prefix", ".", "$", "k", ".", "$", "v", ";", "if", "(", "$", "this", "->", "arrayCaching", ")", "{", "$", "this", "->", "arrayCacheWhere", "[", "]", "=", "$", "prefix", ".", "$", "k", ".", "$", "v", ";", "$", "this", "->", "arrayCacheExists", "[", "]", "=", "'where'", ";", "}", "}", "return", "$", "this", ";", "}" ]
Adds a WHERE condition to the Query statement. NOTE, to change the operatory, append the desired operator to the key names for example use where('a >', 'b'); to add an a > b rule to the statement where( array('a >'=>'b','a <'='c') ); @param mixed $key string with a single field key or array of key value pairs @param string $value If $key is string, then a sing $single String to specify the value @param string $type if adding more than one WHERE clause, use AND, OR etc.. @param boolean $escape . Should we escape the identifiers in the statement? @return TuiyoDatabase
[ "Adds", "a", "WHERE", "condition", "to", "the", "Query", "statement", ".", "NOTE", "to", "change", "the", "operatory", "append", "the", "desired", "operator", "to", "the", "key", "names", "for", "example", "use" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L709-L754
1,248
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.hasOperator
final public function hasOperator($string) { $string = trim($string); //echo $string; $matches = array(); if (!preg_match("/(\<|>|!|=|is null|BETWEEN|is not null)/i", $string, $matches)) { return FALSE; } return TRUE; }
php
final public function hasOperator($string) { $string = trim($string); //echo $string; $matches = array(); if (!preg_match("/(\<|>|!|=|is null|BETWEEN|is not null)/i", $string, $matches)) { return FALSE; } return TRUE; }
[ "final", "public", "function", "hasOperator", "(", "$", "string", ")", "{", "$", "string", "=", "trim", "(", "$", "string", ")", ";", "//echo $string;", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "!", "preg_match", "(", "\"/(\\<|>|!|=|is null|BETWEEN|is not null)/i\"", ",", "$", "string", ",", "$", "matches", ")", ")", "{", "return", "FALSE", ";", "}", "return", "TRUE", ";", "}" ]
Searches for a standard MySQL operator in a specified string @access private @param string $string @return boolean true if found or FALSE if not found
[ "Searches", "for", "a", "standard", "MySQL", "operator", "in", "a", "specified", "string" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L763-L772
1,249
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.join
final public function join($table, $cond, $type = 'LEFT') { if ($type != '') { $type = strtoupper(trim($type)); if (!in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER'))) { $type = ''; } else { $type .= ' '; } } // Extract any aliases that might exist. We use this information // in the _protect_identifiers to know whether to add a table prefix $this->traceTableAlias($table); // Strip apart the condition and protect the identifiers if (preg_match('/([\w\.]+)([\W\s]+)(.+)/', $cond, $match)) { $match[1] = $this->identifiers($match[1]); $match[3] = $this->identifiers($match[3]); $cond = $match[1] . $match[2] . $match[3]; } // Assemble the JOIN statement $join = $type . 'JOIN ' . $this->identifiers($table) . ' ON ' . $cond; $this->arrayJoin[] = $join; if ($this->arrayCaching === TRUE) { $this->arrayCacheJoin[] = $join; $this->arrayCacheExists[] = 'join'; } return $this; }
php
final public function join($table, $cond, $type = 'LEFT') { if ($type != '') { $type = strtoupper(trim($type)); if (!in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER'))) { $type = ''; } else { $type .= ' '; } } // Extract any aliases that might exist. We use this information // in the _protect_identifiers to know whether to add a table prefix $this->traceTableAlias($table); // Strip apart the condition and protect the identifiers if (preg_match('/([\w\.]+)([\W\s]+)(.+)/', $cond, $match)) { $match[1] = $this->identifiers($match[1]); $match[3] = $this->identifiers($match[3]); $cond = $match[1] . $match[2] . $match[3]; } // Assemble the JOIN statement $join = $type . 'JOIN ' . $this->identifiers($table) . ' ON ' . $cond; $this->arrayJoin[] = $join; if ($this->arrayCaching === TRUE) { $this->arrayCacheJoin[] = $join; $this->arrayCacheExists[] = 'join'; } return $this; }
[ "final", "public", "function", "join", "(", "$", "table", ",", "$", "cond", ",", "$", "type", "=", "'LEFT'", ")", "{", "if", "(", "$", "type", "!=", "''", ")", "{", "$", "type", "=", "strtoupper", "(", "trim", "(", "$", "type", ")", ")", ";", "if", "(", "!", "in_array", "(", "$", "type", ",", "array", "(", "'LEFT'", ",", "'RIGHT'", ",", "'OUTER'", ",", "'INNER'", ",", "'LEFT OUTER'", ",", "'RIGHT OUTER'", ")", ")", ")", "{", "$", "type", "=", "''", ";", "}", "else", "{", "$", "type", ".=", "' '", ";", "}", "}", "// Extract any aliases that might exist. We use this information", "// in the _protect_identifiers to know whether to add a table prefix", "$", "this", "->", "traceTableAlias", "(", "$", "table", ")", ";", "// Strip apart the condition and protect the identifiers", "if", "(", "preg_match", "(", "'/([\\w\\.]+)([\\W\\s]+)(.+)/'", ",", "$", "cond", ",", "$", "match", ")", ")", "{", "$", "match", "[", "1", "]", "=", "$", "this", "->", "identifiers", "(", "$", "match", "[", "1", "]", ")", ";", "$", "match", "[", "3", "]", "=", "$", "this", "->", "identifiers", "(", "$", "match", "[", "3", "]", ")", ";", "$", "cond", "=", "$", "match", "[", "1", "]", ".", "$", "match", "[", "2", "]", ".", "$", "match", "[", "3", "]", ";", "}", "// Assemble the JOIN statement", "$", "join", "=", "$", "type", ".", "'JOIN '", ".", "$", "this", "->", "identifiers", "(", "$", "table", ")", ".", "' ON '", ".", "$", "cond", ";", "$", "this", "->", "arrayJoin", "[", "]", "=", "$", "join", ";", "if", "(", "$", "this", "->", "arrayCaching", "===", "TRUE", ")", "{", "$", "this", "->", "arrayCacheJoin", "[", "]", "=", "$", "join", ";", "$", "this", "->", "arrayCacheExists", "[", "]", "=", "'join'", ";", "}", "return", "$", "this", ";", "}" ]
Adds a JOIN query statement @param string $table the table name @param string $cond The JOIN condition @param string $type The type of JOIN e.g LEFT, RIGHT etc. @return TuiyoDatabase
[ "Adds", "a", "JOIN", "query", "statement" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L794-L827
1,250
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.getWhere
final public function getWhere($key, $values = NULL, $type = 'AND') { return $this->where($key, $values, $type); }
php
final public function getWhere($key, $values = NULL, $type = 'AND') { return $this->where($key, $values, $type); }
[ "final", "public", "function", "getWhere", "(", "$", "key", ",", "$", "values", "=", "NULL", ",", "$", "type", "=", "'AND'", ")", "{", "return", "$", "this", "->", "where", "(", "$", "key", ",", "$", "values", ",", "$", "type", ")", ";", "}" ]
Returns the result set from a compiled Query representing the where conditions. See {@method where} for a more controlled approach @param mixed $key string or array. see {@method where} @param string $values @param string $type , e.g AND, OR @return object TuiyoDatabaseResult
[ "Returns", "the", "result", "set", "from", "a", "compiled", "Query", "representing", "the", "where", "conditions", "." ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L882-L885
1,251
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.notIn
final public function notIn($key, $values) { if (empty($key) || empty($values)) { return $this; } if (!is_array($values)) { $values = array($values); } return $this->in($key, $values, TRUE); }
php
final public function notIn($key, $values) { if (empty($key) || empty($values)) { return $this; } if (!is_array($values)) { $values = array($values); } return $this->in($key, $values, TRUE); }
[ "final", "public", "function", "notIn", "(", "$", "key", ",", "$", "values", ")", "{", "if", "(", "empty", "(", "$", "key", ")", "||", "empty", "(", "$", "values", ")", ")", "{", "return", "$", "this", ";", "}", "if", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "$", "values", "=", "array", "(", "$", "values", ")", ";", "}", "return", "$", "this", "->", "in", "(", "$", "key", ",", "$", "values", ",", "TRUE", ")", ";", "}" ]
adds a NOT IN clause to the statement @param string $key @param array $values @return ActiveRecord
[ "adds", "a", "NOT", "IN", "clause", "to", "the", "statement" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L894-L904
1,252
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.like
final public function like($field, $match = '', $type = 'AND ', $side = 'both', $not = '') { if (!is_array($field)) { $field = array($field => $match); } foreach ($field as $k => $v) { $k = $this->identifiers($k); $prefix = (count($this->arrayLike) == 0) ? '' : $type; $v = $this->escape($v); $likeStatement = ''; if ($side == 'before') { $likeStatement = $prefix . " $k $not LIKE '%{$v}'"; } elseif ($side == 'after') { $likeStatement = $prefix . " $k $not LIKE '{$v}%'"; } else { $likeStatement = $prefix . " $k $not LIKE '%{$v}%'"; } $this->arrayLike[] = $likeStatement; if ($this->arrayCaching === TRUE) { $this->arrayCacheLike[] = $likeStatement; $this->arrayCacheExists[] = 'like'; } } return $this; }
php
final public function like($field, $match = '', $type = 'AND ', $side = 'both', $not = '') { if (!is_array($field)) { $field = array($field => $match); } foreach ($field as $k => $v) { $k = $this->identifiers($k); $prefix = (count($this->arrayLike) == 0) ? '' : $type; $v = $this->escape($v); $likeStatement = ''; if ($side == 'before') { $likeStatement = $prefix . " $k $not LIKE '%{$v}'"; } elseif ($side == 'after') { $likeStatement = $prefix . " $k $not LIKE '{$v}%'"; } else { $likeStatement = $prefix . " $k $not LIKE '%{$v}%'"; } $this->arrayLike[] = $likeStatement; if ($this->arrayCaching === TRUE) { $this->arrayCacheLike[] = $likeStatement; $this->arrayCacheExists[] = 'like'; } } return $this; }
[ "final", "public", "function", "like", "(", "$", "field", ",", "$", "match", "=", "''", ",", "$", "type", "=", "'AND '", ",", "$", "side", "=", "'both'", ",", "$", "not", "=", "''", ")", "{", "if", "(", "!", "is_array", "(", "$", "field", ")", ")", "{", "$", "field", "=", "array", "(", "$", "field", "=>", "$", "match", ")", ";", "}", "foreach", "(", "$", "field", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "k", "=", "$", "this", "->", "identifiers", "(", "$", "k", ")", ";", "$", "prefix", "=", "(", "count", "(", "$", "this", "->", "arrayLike", ")", "==", "0", ")", "?", "''", ":", "$", "type", ";", "$", "v", "=", "$", "this", "->", "escape", "(", "$", "v", ")", ";", "$", "likeStatement", "=", "''", ";", "if", "(", "$", "side", "==", "'before'", ")", "{", "$", "likeStatement", "=", "$", "prefix", ".", "\" $k $not LIKE '%{$v}'\"", ";", "}", "elseif", "(", "$", "side", "==", "'after'", ")", "{", "$", "likeStatement", "=", "$", "prefix", ".", "\" $k $not LIKE '{$v}%'\"", ";", "}", "else", "{", "$", "likeStatement", "=", "$", "prefix", ".", "\" $k $not LIKE '%{$v}%'\"", ";", "}", "$", "this", "->", "arrayLike", "[", "]", "=", "$", "likeStatement", ";", "if", "(", "$", "this", "->", "arrayCaching", "===", "TRUE", ")", "{", "$", "this", "->", "arrayCacheLike", "[", "]", "=", "$", "likeStatement", ";", "$", "this", "->", "arrayCacheExists", "[", "]", "=", "'like'", ";", "}", "}", "return", "$", "this", ";", "}" ]
Adds a LIKE cluase to the query statement @param string $field @param string $match @param string $type @param string $side @param string $not @return ActiveRecord
[ "Adds", "a", "LIKE", "cluase", "to", "the", "query", "statement" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L968-L994
1,253
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.notLike
final public function notLike($field, $match = '', $type = 'AND', $side = 'both') { return $this->like($field, $match, $type, $side, 'NOT'); }
php
final public function notLike($field, $match = '', $type = 'AND', $side = 'both') { return $this->like($field, $match, $type, $side, 'NOT'); }
[ "final", "public", "function", "notLike", "(", "$", "field", ",", "$", "match", "=", "''", ",", "$", "type", "=", "'AND'", ",", "$", "side", "=", "'both'", ")", "{", "return", "$", "this", "->", "like", "(", "$", "field", ",", "$", "match", ",", "$", "type", ",", "$", "side", ",", "'NOT'", ")", ";", "}" ]
Adds a NOT LIKE to the statement @param string $field @param string $match @param string $type @param string $side @return object ActiveRecord
[ "Adds", "a", "NOT", "LIKE", "to", "the", "statement" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L1018-L1021
1,254
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.groupBy
final public function groupBy($by) { if (is_string($by)) { $by = explode(',', $by); } foreach ($by as $val) { $val = trim($val); if ($val != '') { $this->arrayGroupBy[] = $this->identifiers($val); if ($this->arrayCaching === TRUE) { $this->arrayCacheGroupBy[] = $this->identifiers($val); $this->arrayCacheExists[] = 'groupby'; } } } return $this; }
php
final public function groupBy($by) { if (is_string($by)) { $by = explode(',', $by); } foreach ($by as $val) { $val = trim($val); if ($val != '') { $this->arrayGroupBy[] = $this->identifiers($val); if ($this->arrayCaching === TRUE) { $this->arrayCacheGroupBy[] = $this->identifiers($val); $this->arrayCacheExists[] = 'groupby'; } } } return $this; }
[ "final", "public", "function", "groupBy", "(", "$", "by", ")", "{", "if", "(", "is_string", "(", "$", "by", ")", ")", "{", "$", "by", "=", "explode", "(", "','", ",", "$", "by", ")", ";", "}", "foreach", "(", "$", "by", "as", "$", "val", ")", "{", "$", "val", "=", "trim", "(", "$", "val", ")", ";", "if", "(", "$", "val", "!=", "''", ")", "{", "$", "this", "->", "arrayGroupBy", "[", "]", "=", "$", "this", "->", "identifiers", "(", "$", "val", ")", ";", "if", "(", "$", "this", "->", "arrayCaching", "===", "TRUE", ")", "{", "$", "this", "->", "arrayCacheGroupBy", "[", "]", "=", "$", "this", "->", "identifiers", "(", "$", "val", ")", ";", "$", "this", "->", "arrayCacheExists", "[", "]", "=", "'groupby'", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Adds a group by clause to a query statement @param string $by @return ActiveRecord
[ "Adds", "a", "group", "by", "clause", "to", "a", "query", "statement" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L1029-L1048
1,255
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.distinct
final public function distinct($boolean = TRUE) { $this->arrayDistinct = (is_bool($boolean)) ? $boolean : TRUE; return $this; }
php
final public function distinct($boolean = TRUE) { $this->arrayDistinct = (is_bool($boolean)) ? $boolean : TRUE; return $this; }
[ "final", "public", "function", "distinct", "(", "$", "boolean", "=", "TRUE", ")", "{", "$", "this", "->", "arrayDistinct", "=", "(", "is_bool", "(", "$", "boolean", ")", ")", "?", "$", "boolean", ":", "TRUE", ";", "return", "$", "this", ";", "}" ]
Adds a distinct clause to a select query statement @param boolean $boolean @return ActiveRecord
[ "Adds", "a", "distinct", "clause", "to", "a", "select", "query", "statement" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L1056-L1060
1,256
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.having
final public function having($key, $value = '', $type = 'AND ', $escape = TRUE) { if (!is_array($key)) { $key = array($key => $value); } foreach ($key as $k => $v) { $prefix = (count($this->arrayHaving) == 0) ? '' : $type; if ($escape === TRUE) { $k = $this->identifiers($k); } if (!$this->hasOperator($k)) { $k .= ' = '; } if ($v != '') { $v = ' ' . $this->escape($v); } $this->arrayHaving[] = $prefix . $k . $v; if ($this->arrayCaching === TRUE) { $this->arrayCacheHaving[] = $prefix . $k . $v; $this->arrayCacheExists[] = 'having'; } } return $this; }
php
final public function having($key, $value = '', $type = 'AND ', $escape = TRUE) { if (!is_array($key)) { $key = array($key => $value); } foreach ($key as $k => $v) { $prefix = (count($this->arrayHaving) == 0) ? '' : $type; if ($escape === TRUE) { $k = $this->identifiers($k); } if (!$this->hasOperator($k)) { $k .= ' = '; } if ($v != '') { $v = ' ' . $this->escape($v); } $this->arrayHaving[] = $prefix . $k . $v; if ($this->arrayCaching === TRUE) { $this->arrayCacheHaving[] = $prefix . $k . $v; $this->arrayCacheExists[] = 'having'; } } return $this; }
[ "final", "public", "function", "having", "(", "$", "key", ",", "$", "value", "=", "''", ",", "$", "type", "=", "'AND '", ",", "$", "escape", "=", "TRUE", ")", "{", "if", "(", "!", "is_array", "(", "$", "key", ")", ")", "{", "$", "key", "=", "array", "(", "$", "key", "=>", "$", "value", ")", ";", "}", "foreach", "(", "$", "key", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "prefix", "=", "(", "count", "(", "$", "this", "->", "arrayHaving", ")", "==", "0", ")", "?", "''", ":", "$", "type", ";", "if", "(", "$", "escape", "===", "TRUE", ")", "{", "$", "k", "=", "$", "this", "->", "identifiers", "(", "$", "k", ")", ";", "}", "if", "(", "!", "$", "this", "->", "hasOperator", "(", "$", "k", ")", ")", "{", "$", "k", ".=", "' = '", ";", "}", "if", "(", "$", "v", "!=", "''", ")", "{", "$", "v", "=", "' '", ".", "$", "this", "->", "escape", "(", "$", "v", ")", ";", "}", "$", "this", "->", "arrayHaving", "[", "]", "=", "$", "prefix", ".", "$", "k", ".", "$", "v", ";", "if", "(", "$", "this", "->", "arrayCaching", "===", "TRUE", ")", "{", "$", "this", "->", "arrayCacheHaving", "[", "]", "=", "$", "prefix", ".", "$", "k", ".", "$", "v", ";", "$", "this", "->", "arrayCacheExists", "[", "]", "=", "'having'", ";", "}", "}", "return", "$", "this", ";", "}" ]
Adds a having clause to a query statement @param string $key @param mixed $value @param string $type @param boolean $escape @return ActiveRecord
[ "Adds", "a", "having", "clause", "to", "a", "query", "statement" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L1071-L1100
1,257
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.limit
final public function limit($value, $offset = '') { $this->arrayLimit = $value; if ($offset != '') { $this->arrayOffset = $offset; } return $this; }
php
final public function limit($value, $offset = '') { $this->arrayLimit = $value; if ($offset != '') { $this->arrayOffset = $offset; } return $this; }
[ "final", "public", "function", "limit", "(", "$", "value", ",", "$", "offset", "=", "''", ")", "{", "$", "this", "->", "arrayLimit", "=", "$", "value", ";", "if", "(", "$", "offset", "!=", "''", ")", "{", "$", "this", "->", "arrayOffset", "=", "$", "offset", ";", "}", "return", "$", "this", ";", "}" ]
Adds a limit to the query statement @param interger $value @param interger $offset @return object ActiveRecord
[ "Adds", "a", "limit", "to", "the", "query", "statement" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L1109-L1116
1,258
budkit/budkit-framework
src/Budkit/Datastore/Activerecord.php
Activerecord.prepare
final public function prepare() { $DB = $this->DBO; $QUERY = $this->compile(); //echo $QUERY; //Compile the query; $STATEMENT = $DB->prepare($QUERY); //Return the Result Object; return $STATEMENT; }
php
final public function prepare() { $DB = $this->DBO; $QUERY = $this->compile(); //echo $QUERY; //Compile the query; $STATEMENT = $DB->prepare($QUERY); //Return the Result Object; return $STATEMENT; }
[ "final", "public", "function", "prepare", "(", ")", "{", "$", "DB", "=", "$", "this", "->", "DBO", ";", "$", "QUERY", "=", "$", "this", "->", "compile", "(", ")", ";", "//echo $QUERY;", "//Compile the query;", "$", "STATEMENT", "=", "$", "DB", "->", "prepare", "(", "$", "QUERY", ")", ";", "//Return the Result Object;", "return", "$", "STATEMENT", ";", "}" ]
Runs a compiled Statement, i.e prepare @return object Statement
[ "Runs", "a", "compiled", "Statement", "i", ".", "e", "prepare" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Activerecord.php#L1147-L1159
1,259
clacy-builders/xml-express-php
src/Markup.php
Markup.complexAttrib
public function complexAttrib($name, $value, $delimiter = ' ', $check = false) { $this->attributes->setComplexAttrib($name, $value, $delimiter, $check); return $this; }
php
public function complexAttrib($name, $value, $delimiter = ' ', $check = false) { $this->attributes->setComplexAttrib($name, $value, $delimiter, $check); return $this; }
[ "public", "function", "complexAttrib", "(", "$", "name", ",", "$", "value", ",", "$", "delimiter", "=", "' '", ",", "$", "check", "=", "false", ")", "{", "$", "this", "->", "attributes", "->", "setComplexAttrib", "(", "$", "name", ",", "$", "value", ",", "$", "delimiter", ",", "$", "check", ")", ";", "return", "$", "this", ";", "}" ]
Sets or appends to a composable attribute. @param string $name Name of the attribute. @param mixed $value One or more (array) values. @param string $delimiter The boundary string. @param boolean $check Whether multiple entries shall be removed or not. @return Xml
[ "Sets", "or", "appends", "to", "a", "composable", "attribute", "." ]
9c66fd640738b0e87b05047c3f3b8f1cba8aa7e0
https://github.com/clacy-builders/xml-express-php/blob/9c66fd640738b0e87b05047c3f3b8f1cba8aa7e0/src/Markup.php#L36-L40
1,260
clacy-builders/xml-express-php
src/Markup.php
Markup.booleanAttrib
public function booleanAttrib($name, $value = true, $comparisonAttribute = null) { $this->attributes->setBooleanAttrib($name, $value, $comparisonAttribute); return $this; }
php
public function booleanAttrib($name, $value = true, $comparisonAttribute = null) { $this->attributes->setBooleanAttrib($name, $value, $comparisonAttribute); return $this; }
[ "public", "function", "booleanAttrib", "(", "$", "name", ",", "$", "value", "=", "true", ",", "$", "comparisonAttribute", "=", "null", ")", "{", "$", "this", "->", "attributes", "->", "setBooleanAttrib", "(", "$", "name", ",", "$", "value", ",", "$", "comparisonAttribute", ")", ";", "return", "$", "this", ";", "}" ]
Sets a boolean attribute, if applicable by comparing a value with the value of another attribute. @param string $name Name of the attribute. @param mixed $value Boolean or one or more (array) values. @param string $comparisonAttribute Name of the other attribute to compare with. @return Xml
[ "Sets", "a", "boolean", "attribute", "if", "applicable", "by", "comparing", "a", "value", "with", "the", "value", "of", "another", "attribute", "." ]
9c66fd640738b0e87b05047c3f3b8f1cba8aa7e0
https://github.com/clacy-builders/xml-express-php/blob/9c66fd640738b0e87b05047c3f3b8f1cba8aa7e0/src/Markup.php#L51-L55
1,261
digipolisgent/openbib-id-api
src/Value/Structure/Collection.php
Collection.fromXml
public static function fromXml(\DOMNodeList $xml) { $items = array(); foreach ($xml as $xmlTag) { $items[] = StringLiteral::create($xmlTag->textContent); } return new static($items); }
php
public static function fromXml(\DOMNodeList $xml) { $items = array(); foreach ($xml as $xmlTag) { $items[] = StringLiteral::create($xmlTag->textContent); } return new static($items); }
[ "public", "static", "function", "fromXml", "(", "\\", "DOMNodeList", "$", "xml", ")", "{", "$", "items", "=", "array", "(", ")", ";", "foreach", "(", "$", "xml", "as", "$", "xmlTag", ")", "{", "$", "items", "[", "]", "=", "StringLiteral", "::", "create", "(", "$", "xmlTag", "->", "textContent", ")", ";", "}", "return", "new", "static", "(", "$", "items", ")", ";", "}" ]
Builds a Collection object from XML. @param \DOMNodeList $xml The list of xml tags. @return Collection A Collection object.
[ "Builds", "a", "Collection", "object", "from", "XML", "." ]
79f58dec53a91f44333d10fa4ef79f85f31fc2de
https://github.com/digipolisgent/openbib-id-api/blob/79f58dec53a91f44333d10fa4ef79f85f31fc2de/src/Value/Structure/Collection.php#L38-L45
1,262
digipolisgent/openbib-id-api
src/Value/Structure/Collection.php
Collection.first
public function first() { $this->getIterator()->rewind(); return $this->getIterator()->count() ? $this->getIterator() ->current() : false; }
php
public function first() { $this->getIterator()->rewind(); return $this->getIterator()->count() ? $this->getIterator() ->current() : false; }
[ "public", "function", "first", "(", ")", "{", "$", "this", "->", "getIterator", "(", ")", "->", "rewind", "(", ")", ";", "return", "$", "this", "->", "getIterator", "(", ")", "->", "count", "(", ")", "?", "$", "this", "->", "getIterator", "(", ")", "->", "current", "(", ")", ":", "false", ";", "}" ]
Gets the first item from the collection. @return StringLiteral|false The first item from the collection, false if the collection is empty.
[ "Gets", "the", "first", "item", "from", "the", "collection", "." ]
79f58dec53a91f44333d10fa4ef79f85f31fc2de
https://github.com/digipolisgent/openbib-id-api/blob/79f58dec53a91f44333d10fa4ef79f85f31fc2de/src/Value/Structure/Collection.php#L61-L66
1,263
PSESD/cascade-core-types
TypeIndividual/models/ObjectIndividual.php
ObjectIndividual.getPhotoEmail
public function getPhotoEmail() { $email = false; $emailType = Yii::$app->collectors['types']->getOne('EmailAddress'); if (empty($emailType->object)) { return false; } foreach ($this->children($emailType->object->primaryModel, ['where' => ['primary_child' => 1]]) as $child) { $email = $child->email_address; break; } if (!empty($email) && substr($email, -6) !== ".local") { return $email; } return false; }
php
public function getPhotoEmail() { $email = false; $emailType = Yii::$app->collectors['types']->getOne('EmailAddress'); if (empty($emailType->object)) { return false; } foreach ($this->children($emailType->object->primaryModel, ['where' => ['primary_child' => 1]]) as $child) { $email = $child->email_address; break; } if (!empty($email) && substr($email, -6) !== ".local") { return $email; } return false; }
[ "public", "function", "getPhotoEmail", "(", ")", "{", "$", "email", "=", "false", ";", "$", "emailType", "=", "Yii", "::", "$", "app", "->", "collectors", "[", "'types'", "]", "->", "getOne", "(", "'EmailAddress'", ")", ";", "if", "(", "empty", "(", "$", "emailType", "->", "object", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "this", "->", "children", "(", "$", "emailType", "->", "object", "->", "primaryModel", ",", "[", "'where'", "=>", "[", "'primary_child'", "=>", "1", "]", "]", ")", "as", "$", "child", ")", "{", "$", "email", "=", "$", "child", "->", "email_address", ";", "break", ";", "}", "if", "(", "!", "empty", "(", "$", "email", ")", "&&", "substr", "(", "$", "email", ",", "-", "6", ")", "!==", "\".local\"", ")", "{", "return", "$", "email", ";", "}", "return", "false", ";", "}" ]
Get photo email. @return [[@doctodo return_type:getPhotoEmail]] [[@doctodo return_description:getPhotoEmail]]
[ "Get", "photo", "email", "." ]
5a2bc524bd89545f0f28230e34518c9f92e7db1f
https://github.com/PSESD/cascade-core-types/blob/5a2bc524bd89545f0f28230e34518c9f92e7db1f/TypeIndividual/models/ObjectIndividual.php#L130-L146
1,264
studyportals/Utils
src/XML.php
XML.loadSimpleXML
public static function loadSimpleXML($xml_file, $verify_dtd = true){ $options = ($verify_dtd ? LIBXML_DTDVALID : null); libxml_clear_errors(); $SimpleXML = @simplexml_load_file($xml_file, null, $options); $LibXMLError = libxml_get_last_error(); if($SimpleXML === false || $LibXMLError instanceof \LibXMLError){ if($LibXMLError instanceof \LibXMLError){ $xml_base = basename($LibXMLError->file); throw new XMLException("{$LibXMLError->message} in $xml_base on line {$LibXMLError->line}"); } else{ $xml_base = basename($xml_file); throw new XMLException("SimpleXML failed to load $xml_base, unknown error"); } } return $SimpleXML; }
php
public static function loadSimpleXML($xml_file, $verify_dtd = true){ $options = ($verify_dtd ? LIBXML_DTDVALID : null); libxml_clear_errors(); $SimpleXML = @simplexml_load_file($xml_file, null, $options); $LibXMLError = libxml_get_last_error(); if($SimpleXML === false || $LibXMLError instanceof \LibXMLError){ if($LibXMLError instanceof \LibXMLError){ $xml_base = basename($LibXMLError->file); throw new XMLException("{$LibXMLError->message} in $xml_base on line {$LibXMLError->line}"); } else{ $xml_base = basename($xml_file); throw new XMLException("SimpleXML failed to load $xml_base, unknown error"); } } return $SimpleXML; }
[ "public", "static", "function", "loadSimpleXML", "(", "$", "xml_file", ",", "$", "verify_dtd", "=", "true", ")", "{", "$", "options", "=", "(", "$", "verify_dtd", "?", "LIBXML_DTDVALID", ":", "null", ")", ";", "libxml_clear_errors", "(", ")", ";", "$", "SimpleXML", "=", "@", "simplexml_load_file", "(", "$", "xml_file", ",", "null", ",", "$", "options", ")", ";", "$", "LibXMLError", "=", "libxml_get_last_error", "(", ")", ";", "if", "(", "$", "SimpleXML", "===", "false", "||", "$", "LibXMLError", "instanceof", "\\", "LibXMLError", ")", "{", "if", "(", "$", "LibXMLError", "instanceof", "\\", "LibXMLError", ")", "{", "$", "xml_base", "=", "basename", "(", "$", "LibXMLError", "->", "file", ")", ";", "throw", "new", "XMLException", "(", "\"{$LibXMLError->message} in $xml_base\n\t\t\t\t\ton line {$LibXMLError->line}\"", ")", ";", "}", "else", "{", "$", "xml_base", "=", "basename", "(", "$", "xml_file", ")", ";", "throw", "new", "XMLException", "(", "\"SimpleXML failed to load $xml_base,\n\t\t\t\t\tunknown error\"", ")", ";", "}", "}", "return", "$", "SimpleXML", ";", "}" ]
Load and verify an XML-file using SimpleXML. <p>The optional second parameter {@link $verify_dtd} can be used to disable verification of the XML DTD upon loading. By default the DTD is verified.</p> <p>When an error occurs this methods throws a XMLException.</p> @param string $xml_file @param boolean $verify_dtd @return \SimpleXMLElement @throws XMLException
[ "Load", "and", "verify", "an", "XML", "-", "file", "using", "SimpleXML", "." ]
eab69ca10ce3261480164cf8108ae7020459c847
https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/XML.php#L38-L66
1,265
marando/phpSOFA
src/Marando/IAU/iauGst00a.php
iauGst00a.Gst00a
public static function Gst00a($uta, $utb, $tta, $ttb) { $gmst00; $ee00a; $gst; $gmst00 = IAU::Gmst00($uta, $utb, $tta, $ttb); $ee00a = IAU::Ee00a($tta, $ttb); $gst = IAU::Anp($gmst00 + $ee00a); return $gst; }
php
public static function Gst00a($uta, $utb, $tta, $ttb) { $gmst00; $ee00a; $gst; $gmst00 = IAU::Gmst00($uta, $utb, $tta, $ttb); $ee00a = IAU::Ee00a($tta, $ttb); $gst = IAU::Anp($gmst00 + $ee00a); return $gst; }
[ "public", "static", "function", "Gst00a", "(", "$", "uta", ",", "$", "utb", ",", "$", "tta", ",", "$", "ttb", ")", "{", "$", "gmst00", ";", "$", "ee00a", ";", "$", "gst", ";", "$", "gmst00", "=", "IAU", "::", "Gmst00", "(", "$", "uta", ",", "$", "utb", ",", "$", "tta", ",", "$", "ttb", ")", ";", "$", "ee00a", "=", "IAU", "::", "Ee00a", "(", "$", "tta", ",", "$", "ttb", ")", ";", "$", "gst", "=", "IAU", "::", "Anp", "(", "$", "gmst00", "+", "$", "ee00a", ")", ";", "return", "$", "gst", ";", "}" ]
- - - - - - - - - - i a u G s t 0 0 a - - - - - - - - - - Greenwich apparent sidereal time (consistent with IAU 2000 resolutions). This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: canonical model. Given: uta,utb double UT1 as a 2-part Julian Date (Notes 1,2) tta,ttb double TT as a 2-part Julian Date (Notes 1,2) Returned (function value): double Greenwich apparent sidereal time (radians) Notes: 1) The UT1 and TT dates uta+utb and tta+ttb respectively, are both Julian Dates, apportioned in any convenient way between the argument pairs. For example, JD=2450123.7 could be expressed in any of these ways, among others: Part A Part B 2450123.7 0.0 (JD method) 2451545.0 -1421.3 (J2000 method) 2400000.5 50123.2 (MJD method) 2450123.5 0.2 (date & time method) The JD method is the most natural and convenient to use in cases where the loss of several decimal digits of resolution is acceptable (in the case of UT; the TT is not at all critical in this respect). The J2000 and MJD methods are good compromises between resolution and convenience. For UT, the date & time method is best matched to the algorithm that is used by the Earth Rotation Angle function, called internally: maximum precision is delivered when the uta argument is for 0hrs UT1 on the day in question and the utb argument lies in the range 0 to 1, or vice versa. 2) Both UT1 and TT are required, UT1 to predict the Earth rotation and TT to predict the effects of precession-nutation. If UT1 is used for both purposes, errors of order 100 microarcseconds result. 3) This GAST is compatible with the IAU 2000 resolutions and must be used only in conjunction with other IAU 2000 compatible components such as precession-nutation. 4) The result is returned in the range 0 to 2pi. 5) The algorithm is from Capitaine et al. (2003) and IERS Conventions 2003. Called: iauGmst00 Greenwich mean sidereal time, IAU 2000 iauEe00a equation of the equinoxes, IAU 2000A iauAnp normalize angle into range 0 to 2pi References: Capitaine, N., Wallace, P.T. and McCarthy, D.D., "Expressions to implement the IAU 2000 definition of UT1", Astronomy & Astrophysics, 406, 1135-1149 (2003) McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32, BKG (2004) This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "G", "s", "t", "0", "0", "a", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauGst00a.php#L86-L96
1,266
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeRole.php
BridgeRole.addPermission
public function addPermission($permission) { if (is_array($permission) || $permission instanceof \Traversable) return $this->addMultiplePermissions($permission); else return $this->addSinglePermission($permission); }
php
public function addPermission($permission) { if (is_array($permission) || $permission instanceof \Traversable) return $this->addMultiplePermissions($permission); else return $this->addSinglePermission($permission); }
[ "public", "function", "addPermission", "(", "$", "permission", ")", "{", "if", "(", "is_array", "(", "$", "permission", ")", "||", "$", "permission", "instanceof", "\\", "Traversable", ")", "return", "$", "this", "->", "addMultiplePermissions", "(", "$", "permission", ")", ";", "else", "return", "$", "this", "->", "addSinglePermission", "(", "$", "permission", ")", ";", "}" ]
Add a permission to the role. The argument can be the permission name, ID, Permission object, or an array of the previous @param $permission array|\Traversable|string|integer The permission to add to the current role @return \Searsaw\Drawbridge\Models\BridgePermission|\InvalidArgumentException
[ "Add", "a", "permission", "to", "the", "role", ".", "The", "argument", "can", "be", "the", "permission", "name", "ID", "Permission", "object", "or", "an", "array", "of", "the", "previous" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeRole.php#L67-L73
1,267
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeRole.php
BridgeRole.addSinglePermission
public function addSinglePermission($permission) { if (is_string($permission)) return $this->addPermissionByName($permission); elseif (is_numeric($permission)) return $this->addPermissionById($permission); elseif ($permission instanceof BridgePermission) return $this->addPermissionByObject($permission); else throw new \InvalidArgumentException('Permission must be a name, ID, or Permission object.'); }
php
public function addSinglePermission($permission) { if (is_string($permission)) return $this->addPermissionByName($permission); elseif (is_numeric($permission)) return $this->addPermissionById($permission); elseif ($permission instanceof BridgePermission) return $this->addPermissionByObject($permission); else throw new \InvalidArgumentException('Permission must be a name, ID, or Permission object.'); }
[ "public", "function", "addSinglePermission", "(", "$", "permission", ")", "{", "if", "(", "is_string", "(", "$", "permission", ")", ")", "return", "$", "this", "->", "addPermissionByName", "(", "$", "permission", ")", ";", "elseif", "(", "is_numeric", "(", "$", "permission", ")", ")", "return", "$", "this", "->", "addPermissionById", "(", "$", "permission", ")", ";", "elseif", "(", "$", "permission", "instanceof", "BridgePermission", ")", "return", "$", "this", "->", "addPermissionByObject", "(", "$", "permission", ")", ";", "else", "throw", "new", "\\", "InvalidArgumentException", "(", "'Permission must be a name, ID, or Permission object.'", ")", ";", "}" ]
Add a single permission. The argument is a string, integer, or instance of BridgePermission @param $permission string|integer|\Searsaw\Drawbridge\Models\BridgePermission @throws \InvalidArgumentException @return \Searsaw\Drawbridge\Models\BridgePermission
[ "Add", "a", "single", "permission", ".", "The", "argument", "is", "a", "string", "integer", "or", "instance", "of", "BridgePermission" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeRole.php#L97-L107
1,268
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeRole.php
BridgeRole.addPermissionByName
public function addPermissionByName($permission_name) { $permission = static::$app['db']->connection() ->table('permissions')->where('name', '=', $permission_name)->first(); if (! $permission) return new \RuntimeException('No permission with that name found.'); if (is_array($permission)) return $this->addPermissionById($permission['id']); elseif (is_object($permission)) return $this->addPermissionById($permission->id); else throw new \UnexpectedValueException('Value returned not array or instance of BridgePermission.'); }
php
public function addPermissionByName($permission_name) { $permission = static::$app['db']->connection() ->table('permissions')->where('name', '=', $permission_name)->first(); if (! $permission) return new \RuntimeException('No permission with that name found.'); if (is_array($permission)) return $this->addPermissionById($permission['id']); elseif (is_object($permission)) return $this->addPermissionById($permission->id); else throw new \UnexpectedValueException('Value returned not array or instance of BridgePermission.'); }
[ "public", "function", "addPermissionByName", "(", "$", "permission_name", ")", "{", "$", "permission", "=", "static", "::", "$", "app", "[", "'db'", "]", "->", "connection", "(", ")", "->", "table", "(", "'permissions'", ")", "->", "where", "(", "'name'", ",", "'='", ",", "$", "permission_name", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "permission", ")", "return", "new", "\\", "RuntimeException", "(", "'No permission with that name found.'", ")", ";", "if", "(", "is_array", "(", "$", "permission", ")", ")", "return", "$", "this", "->", "addPermissionById", "(", "$", "permission", "[", "'id'", "]", ")", ";", "elseif", "(", "is_object", "(", "$", "permission", ")", ")", "return", "$", "this", "->", "addPermissionById", "(", "$", "permission", "->", "id", ")", ";", "else", "throw", "new", "\\", "UnexpectedValueException", "(", "'Value returned not array or instance of BridgePermission.'", ")", ";", "}" ]
Add a single permission to the role by name @param $permission_name string The name of the permission to add @throws \UnexpectedValueException @throws \RuntimeException @return \Searsaw\Drawbridge\Models\BridgePermission
[ "Add", "a", "single", "permission", "to", "the", "role", "by", "name" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeRole.php#L119-L133
1,269
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeRole.php
BridgeRole.addPermissionByObject
public function addPermissionByObject(BridgePermission $permission_obj) { if (! $permission_obj->exists) $permission_obj->save(); $permission_id = $permission_obj->getKey(); return $this->addPermissionById($permission_id); }
php
public function addPermissionByObject(BridgePermission $permission_obj) { if (! $permission_obj->exists) $permission_obj->save(); $permission_id = $permission_obj->getKey(); return $this->addPermissionById($permission_id); }
[ "public", "function", "addPermissionByObject", "(", "BridgePermission", "$", "permission_obj", ")", "{", "if", "(", "!", "$", "permission_obj", "->", "exists", ")", "$", "permission_obj", "->", "save", "(", ")", ";", "$", "permission_id", "=", "$", "permission_obj", "->", "getKey", "(", ")", ";", "return", "$", "this", "->", "addPermissionById", "(", "$", "permission_id", ")", ";", "}" ]
Add a single permission to the role by using the Permission object @param $permission_obj \Searsaw\Drawbridge\Models\BridgePermission The Permission object to add @return \Searsaw\Drawbridge\Models\BridgePermission
[ "Add", "a", "single", "permission", "to", "the", "role", "by", "using", "the", "Permission", "object" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeRole.php#L154-L162
1,270
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeRole.php
BridgeRole.hasPermission
public function hasPermission($permission) { $permissions = $this->permissions; foreach ($permissions as $permission_obj) if ($this->checkPermission($permission, $permission_obj)) return true; return false; }
php
public function hasPermission($permission) { $permissions = $this->permissions; foreach ($permissions as $permission_obj) if ($this->checkPermission($permission, $permission_obj)) return true; return false; }
[ "public", "function", "hasPermission", "(", "$", "permission", ")", "{", "$", "permissions", "=", "$", "this", "->", "permissions", ";", "foreach", "(", "$", "permissions", "as", "$", "permission_obj", ")", "if", "(", "$", "this", "->", "checkPermission", "(", "$", "permission", ",", "$", "permission_obj", ")", ")", "return", "true", ";", "return", "false", ";", "}" ]
Checks to see if a role has a certain permission @param $permission string|integer|\Searsaw\Drawbridge\Models\BridgePermission The permission to check @return bool
[ "Checks", "to", "see", "if", "a", "role", "has", "a", "certain", "permission" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeRole.php#L171-L179
1,271
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeRole.php
BridgeRole.checkPermission
public function checkPermission($check, BridgePermission $has) { if (is_string($check)) return $this->checkPermissionByName($check, $has); elseif (is_numeric($check)) return $this->checkPermissionById($check, $has); elseif ($check instanceof BridgePermission) return $this->checkPermissionByObject($check, $has); else throw new \InvalidArgumentException('Permission to check must be a name, ID, or Permission object.'); }
php
public function checkPermission($check, BridgePermission $has) { if (is_string($check)) return $this->checkPermissionByName($check, $has); elseif (is_numeric($check)) return $this->checkPermissionById($check, $has); elseif ($check instanceof BridgePermission) return $this->checkPermissionByObject($check, $has); else throw new \InvalidArgumentException('Permission to check must be a name, ID, or Permission object.'); }
[ "public", "function", "checkPermission", "(", "$", "check", ",", "BridgePermission", "$", "has", ")", "{", "if", "(", "is_string", "(", "$", "check", ")", ")", "return", "$", "this", "->", "checkPermissionByName", "(", "$", "check", ",", "$", "has", ")", ";", "elseif", "(", "is_numeric", "(", "$", "check", ")", ")", "return", "$", "this", "->", "checkPermissionById", "(", "$", "check", ",", "$", "has", ")", ";", "elseif", "(", "$", "check", "instanceof", "BridgePermission", ")", "return", "$", "this", "->", "checkPermissionByObject", "(", "$", "check", ",", "$", "has", ")", ";", "else", "throw", "new", "\\", "InvalidArgumentException", "(", "'Permission to check must be a name, ID, or Permission object.'", ")", ";", "}" ]
Checks to see if a given permission is equal to a permission the user already has @param $check string|integer|\Searsaw\Drawbridge\Models\BridgePermission The permission to check @param $has \Searsaw\Drawbridge\Models\BridgePermission The permission the user has to check against @return mixed @throws \InvalidArgumentException
[ "Checks", "to", "see", "if", "a", "given", "permission", "is", "equal", "to", "a", "permission", "the", "user", "already", "has" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeRole.php#L190-L200
1,272
searsaw/Drawbridge
src/Searsaw/Drawbridge/models/BridgeRole.php
BridgeRole.checkPermissionByObject
public function checkPermissionByObject(BridgePermission $check, BridgePermission $has) { return $this->checkPermissionById($check->id, $has); }
php
public function checkPermissionByObject(BridgePermission $check, BridgePermission $has) { return $this->checkPermissionById($check->id, $has); }
[ "public", "function", "checkPermissionByObject", "(", "BridgePermission", "$", "check", ",", "BridgePermission", "$", "has", ")", "{", "return", "$", "this", "->", "checkPermissionById", "(", "$", "check", "->", "id", ",", "$", "has", ")", ";", "}" ]
Check to see if the Permission provided is the same as the BridgePermission object passed in @param BridgePermission $check The object to check @param BridgePermission $has The object to check against @return bool
[ "Check", "to", "see", "if", "the", "Permission", "provided", "is", "the", "same", "as", "the", "BridgePermission", "object", "passed", "in" ]
156bd8238a623d245fbbbb509eb5dd148338f5a6
https://github.com/searsaw/Drawbridge/blob/156bd8238a623d245fbbbb509eb5dd148338f5a6/src/Searsaw/Drawbridge/models/BridgeRole.php#L245-L248
1,273
vincentshiqi/laravel-p-pdo-via-oci8
src/Pdo/Oci8.php
Oci8.query
public function query($statement, $fetchMode = null, $modeArg = null, array $ctorArgs = array()) { $stmt = $this->prepare($statement); $stmt->execute(); if ($fetchMode) { $stmt->setFetchMode($fetchMode, $modeArg, $ctorArgs); } return $stmt; }
php
public function query($statement, $fetchMode = null, $modeArg = null, array $ctorArgs = array()) { $stmt = $this->prepare($statement); $stmt->execute(); if ($fetchMode) { $stmt->setFetchMode($fetchMode, $modeArg, $ctorArgs); } return $stmt; }
[ "public", "function", "query", "(", "$", "statement", ",", "$", "fetchMode", "=", "null", ",", "$", "modeArg", "=", "null", ",", "array", "$", "ctorArgs", "=", "array", "(", ")", ")", "{", "$", "stmt", "=", "$", "this", "->", "prepare", "(", "$", "statement", ")", ";", "$", "stmt", "->", "execute", "(", ")", ";", "if", "(", "$", "fetchMode", ")", "{", "$", "stmt", "->", "setFetchMode", "(", "$", "fetchMode", ",", "$", "modeArg", ",", "$", "ctorArgs", ")", ";", "}", "return", "$", "stmt", ";", "}" ]
Executes an SQL statement, returning the results as a Vincent\Pdo\Oci8\Statement object. @param string $statement The SQL statement to prepare and execute. @param int|null $fetchMode The fetch mode must be one of the PDO::FETCH_* constants. @param mixed|null $modeArg Column number, class name or object. @param array|null $ctorArgs Constructor arguments. @return Statement
[ "Executes", "an", "SQL", "statement", "returning", "the", "results", "as", "a", "Vincent", "\\", "Pdo", "\\", "Oci8", "\\", "Statement", "object", "." ]
748857d12342c7ef8d75f2b4abb58aaddbef57f6
https://github.com/vincentshiqi/laravel-p-pdo-via-oci8/blob/748857d12342c7ef8d75f2b4abb58aaddbef57f6/src/Pdo/Oci8.php#L248-L257
1,274
rseyferth/activerecord
lib/Relationship.php
AbstractRelationship.constructInnerJoinSql
public function constructInnerJoinSql(Table $fromTable, $usingThrough=false, $alias=null) { if ($usingThrough) { $joinTable = $fromTable; $joinTableName = $fromTable->getFullyQualifiedTableName(); $fromTableName = Table::load($this->className)->getFullyQualifiedTableName(); } else { $joinTable = Table::load($this->className); $joinTableName = $joinTable->getFullyQualifiedTableName(); $fromTableName = $fromTable->getFullyQualifiedTableName(); } // need to flip the logic when the key is on the other table if ($this instanceof HasMany || $this instanceof HasOne) { $this->setKeys($fromTable->class->getName()); if ($usingThrough) { $foreignKey = $this->primaryKey[0]; $joinPrimaryKey = $this->foreignKey[0]; } else { $joinPrimaryKey = $this->foreignKey[0]; $foreignKey = $this->primaryKey[0]; } } else { $foreignKey = $this->foreignKey[0]; $joinPrimaryKey = $this->primaryKey[0]; } if (!is_null($alias)) { $aliasedJoinTableName = $alias = $this->getTable()->conn->quoteName($alias); $alias .= ' '; } else $aliasedJoinTableName = $joinTableName; return "INNER JOIN $joinTableName {$alias}ON($fromTableName.$foreignKey = $aliasedJoinTableName.$joinPrimaryKey)"; }
php
public function constructInnerJoinSql(Table $fromTable, $usingThrough=false, $alias=null) { if ($usingThrough) { $joinTable = $fromTable; $joinTableName = $fromTable->getFullyQualifiedTableName(); $fromTableName = Table::load($this->className)->getFullyQualifiedTableName(); } else { $joinTable = Table::load($this->className); $joinTableName = $joinTable->getFullyQualifiedTableName(); $fromTableName = $fromTable->getFullyQualifiedTableName(); } // need to flip the logic when the key is on the other table if ($this instanceof HasMany || $this instanceof HasOne) { $this->setKeys($fromTable->class->getName()); if ($usingThrough) { $foreignKey = $this->primaryKey[0]; $joinPrimaryKey = $this->foreignKey[0]; } else { $joinPrimaryKey = $this->foreignKey[0]; $foreignKey = $this->primaryKey[0]; } } else { $foreignKey = $this->foreignKey[0]; $joinPrimaryKey = $this->primaryKey[0]; } if (!is_null($alias)) { $aliasedJoinTableName = $alias = $this->getTable()->conn->quoteName($alias); $alias .= ' '; } else $aliasedJoinTableName = $joinTableName; return "INNER JOIN $joinTableName {$alias}ON($fromTableName.$foreignKey = $aliasedJoinTableName.$joinPrimaryKey)"; }
[ "public", "function", "constructInnerJoinSql", "(", "Table", "$", "fromTable", ",", "$", "usingThrough", "=", "false", ",", "$", "alias", "=", "null", ")", "{", "if", "(", "$", "usingThrough", ")", "{", "$", "joinTable", "=", "$", "fromTable", ";", "$", "joinTableName", "=", "$", "fromTable", "->", "getFullyQualifiedTableName", "(", ")", ";", "$", "fromTableName", "=", "Table", "::", "load", "(", "$", "this", "->", "className", ")", "->", "getFullyQualifiedTableName", "(", ")", ";", "}", "else", "{", "$", "joinTable", "=", "Table", "::", "load", "(", "$", "this", "->", "className", ")", ";", "$", "joinTableName", "=", "$", "joinTable", "->", "getFullyQualifiedTableName", "(", ")", ";", "$", "fromTableName", "=", "$", "fromTable", "->", "getFullyQualifiedTableName", "(", ")", ";", "}", "// need to flip the logic when the key is on the other table", "if", "(", "$", "this", "instanceof", "HasMany", "||", "$", "this", "instanceof", "HasOne", ")", "{", "$", "this", "->", "setKeys", "(", "$", "fromTable", "->", "class", "->", "getName", "(", ")", ")", ";", "if", "(", "$", "usingThrough", ")", "{", "$", "foreignKey", "=", "$", "this", "->", "primaryKey", "[", "0", "]", ";", "$", "joinPrimaryKey", "=", "$", "this", "->", "foreignKey", "[", "0", "]", ";", "}", "else", "{", "$", "joinPrimaryKey", "=", "$", "this", "->", "foreignKey", "[", "0", "]", ";", "$", "foreignKey", "=", "$", "this", "->", "primaryKey", "[", "0", "]", ";", "}", "}", "else", "{", "$", "foreignKey", "=", "$", "this", "->", "foreignKey", "[", "0", "]", ";", "$", "joinPrimaryKey", "=", "$", "this", "->", "primaryKey", "[", "0", "]", ";", "}", "if", "(", "!", "is_null", "(", "$", "alias", ")", ")", "{", "$", "aliasedJoinTableName", "=", "$", "alias", "=", "$", "this", "->", "getTable", "(", ")", "->", "conn", "->", "quoteName", "(", "$", "alias", ")", ";", "$", "alias", ".=", "' '", ";", "}", "else", "$", "aliasedJoinTableName", "=", "$", "joinTableName", ";", "return", "\"INNER JOIN $joinTableName {$alias}ON($fromTableName.$foreignKey = $aliasedJoinTableName.$joinPrimaryKey)\"", ";", "}" ]
Creates INNER JOIN SQL for associations. @param Table $from_table the table used for the FROM SQL statement @param bool $using_through is this a THROUGH relationship? @param string $alias a table alias for when a table is being joined twice @return string SQL INNER JOIN fragment
[ "Creates", "INNER", "JOIN", "SQL", "for", "associations", "." ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Relationship.php#L331-L377
1,275
rseyferth/activerecord
lib/Relationship.php
HasMany.getForeignKeyForNewAssociation
private function getForeignKeyForNewAssociation(Model $model) { $this->setKeys($model); $primaryKey = Inflector::instance()->variablize($this->foreignKey[0]); return array( $primaryKey => $model->id, ); }
php
private function getForeignKeyForNewAssociation(Model $model) { $this->setKeys($model); $primaryKey = Inflector::instance()->variablize($this->foreignKey[0]); return array( $primaryKey => $model->id, ); }
[ "private", "function", "getForeignKeyForNewAssociation", "(", "Model", "$", "model", ")", "{", "$", "this", "->", "setKeys", "(", "$", "model", ")", ";", "$", "primaryKey", "=", "Inflector", "::", "instance", "(", ")", "->", "variablize", "(", "$", "this", "->", "foreignKey", "[", "0", "]", ")", ";", "return", "array", "(", "$", "primaryKey", "=>", "$", "model", "->", "id", ",", ")", ";", "}" ]
Get an array containing the key and value of the foreign key for the association @param Model $model @access private @return array
[ "Get", "an", "array", "containing", "the", "key", "and", "value", "of", "the", "foreign", "key", "for", "the", "association" ]
0e7b1cbddd6f967c3a09adf38753babd5f698e39
https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Relationship.php#L539-L547
1,276
jaeger-app/regex
src/Regex.php
Regex.getInstance
private function getInstance() { if (is_null($this->instance)) { $this->instance = \RegexGuard\Factory::getGuard(); } return $this->instance; }
php
private function getInstance() { if (is_null($this->instance)) { $this->instance = \RegexGuard\Factory::getGuard(); } return $this->instance; }
[ "private", "function", "getInstance", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "instance", ")", ")", "{", "$", "this", "->", "instance", "=", "\\", "RegexGuard", "\\", "Factory", "::", "getGuard", "(", ")", ";", "}", "return", "$", "this", "->", "instance", ";", "}" ]
Returns an instance of the library @return \RegexGuard\RegexGuard
[ "Returns", "an", "instance", "of", "the", "library" ]
89dc4d55d79fc933725a9aebeb23d3e676cd8820
https://github.com/jaeger-app/regex/blob/89dc4d55d79fc933725a9aebeb23d3e676cd8820/src/Regex.php#L37-L44
1,277
jaeger-app/regex
src/Regex.php
Regex.match
public function match($pattern, $subject) { if (! $this->validate($pattern)) { return false; } return $this->getInstance()->match($pattern, $subject); }
php
public function match($pattern, $subject) { if (! $this->validate($pattern)) { return false; } return $this->getInstance()->match($pattern, $subject); }
[ "public", "function", "match", "(", "$", "pattern", ",", "$", "subject", ")", "{", "if", "(", "!", "$", "this", "->", "validate", "(", "$", "pattern", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "getInstance", "(", ")", "->", "match", "(", "$", "pattern", ",", "$", "subject", ")", ";", "}" ]
Matches a regular expression @param string $pattern The regular expression to execute @param string $subject The string to search within @return boolean
[ "Matches", "a", "regular", "expression" ]
89dc4d55d79fc933725a9aebeb23d3e676cd8820
https://github.com/jaeger-app/regex/blob/89dc4d55d79fc933725a9aebeb23d3e676cd8820/src/Regex.php#L67-L74
1,278
jmpantoja/planb-utils
src/Beautifier/Template/Line.php
Line.getWords
private function getWords(string $template): array { $flags = PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY; return (array) preg_split(self::WORD_DELIMITER, $template, -1, $flags); }
php
private function getWords(string $template): array { $flags = PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY; return (array) preg_split(self::WORD_DELIMITER, $template, -1, $flags); }
[ "private", "function", "getWords", "(", "string", "$", "template", ")", ":", "array", "{", "$", "flags", "=", "PREG_SPLIT_DELIM_CAPTURE", "|", "PREG_SPLIT_NO_EMPTY", ";", "return", "(", "array", ")", "preg_split", "(", "self", "::", "WORD_DELIMITER", ",", "$", "template", ",", "-", "1", ",", "$", "flags", ")", ";", "}" ]
Devuelve una lista con las palabras que componen la linea @param string $template @return mixed[]
[ "Devuelve", "una", "lista", "con", "las", "palabras", "que", "componen", "la", "linea" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Template/Line.php#L79-L84
1,279
jmpantoja/planb-utils
src/Beautifier/Template/Line.php
Line.getTokens
private function getTokens(string $word): array { $flags = PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY; return (array) preg_split(self::TOKEN_DELIMITER, $word, -1, $flags); }
php
private function getTokens(string $word): array { $flags = PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY; return (array) preg_split(self::TOKEN_DELIMITER, $word, -1, $flags); }
[ "private", "function", "getTokens", "(", "string", "$", "word", ")", ":", "array", "{", "$", "flags", "=", "PREG_SPLIT_DELIM_CAPTURE", "|", "PREG_SPLIT_NO_EMPTY", ";", "return", "(", "array", ")", "preg_split", "(", "self", "::", "TOKEN_DELIMITER", ",", "$", "word", ",", "-", "1", ",", "$", "flags", ")", ";", "}" ]
Devuelve los tokens que componen una palabra @param string $word @return mixed[]
[ "Devuelve", "los", "tokens", "que", "componen", "una", "palabra" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Template/Line.php#L93-L98
1,280
jmpantoja/planb-utils
src/Beautifier/Template/Line.php
Line.parse
public function parse(callable $callback, int $width): string { $tokens = []; foreach ($this as $token) { $token->setLineWidth($width); $tokens[] = call_user_func($callback, $token); } return implode('', $tokens); }
php
public function parse(callable $callback, int $width): string { $tokens = []; foreach ($this as $token) { $token->setLineWidth($width); $tokens[] = call_user_func($callback, $token); } return implode('', $tokens); }
[ "public", "function", "parse", "(", "callable", "$", "callback", ",", "int", "$", "width", ")", ":", "string", "{", "$", "tokens", "=", "[", "]", ";", "foreach", "(", "$", "this", "as", "$", "token", ")", "{", "$", "token", "->", "setLineWidth", "(", "$", "width", ")", ";", "$", "tokens", "[", "]", "=", "call_user_func", "(", "$", "callback", ",", "$", "token", ")", ";", "}", "return", "implode", "(", "''", ",", "$", "tokens", ")", ";", "}" ]
Devuelve esta linea en forma de string, usando un callback para resolver cada token @param callable $callback @param int $width @return string
[ "Devuelve", "esta", "linea", "en", "forma", "de", "string", "usando", "un", "callback", "para", "resolver", "cada", "token" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Template/Line.php#L120-L129
1,281
jmpantoja/planb-utils
src/Beautifier/Template/Line.php
Line.getWidth
public function getWidth(): int { $total = 0; foreach ($this as $token) { $total += $token->width(); } return $total; }
php
public function getWidth(): int { $total = 0; foreach ($this as $token) { $total += $token->width(); } return $total; }
[ "public", "function", "getWidth", "(", ")", ":", "int", "{", "$", "total", "=", "0", ";", "foreach", "(", "$", "this", "as", "$", "token", ")", "{", "$", "total", "+=", "$", "token", "->", "width", "(", ")", ";", "}", "return", "$", "total", ";", "}" ]
Devuelve el ancho del linea @return int
[ "Devuelve", "el", "ancho", "del", "linea" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Template/Line.php#L137-L145
1,282
phlexible/media-manager
Upload/UploadHandler.php
UploadHandler.handle
public function handle(UploadedFile $uploadedFile, $folderId, $userId) { $uploadFileSource = new UploadedFileSource($uploadedFile); $volume = $this->volumeManager->getByFolderId($folderId); $folder = $volume->findFolder($folderId); $file = $volume->findFileByPath($folder->getPath().'/'.$uploadFileSource->getName()); $originalFileId = null; if ($file) { $originalFileId = $file->getId(); } $useWizard = $this->useWizard($uploadFileSource); if ($originalFileId || $useWizard) { return $this->tempStorage->store( $uploadFileSource, $folderId, $userId, $originalFileId, $useWizard ); } $file = $volume->createFile($folder, $uploadFileSource, array(), $userId); return $file; }
php
public function handle(UploadedFile $uploadedFile, $folderId, $userId) { $uploadFileSource = new UploadedFileSource($uploadedFile); $volume = $this->volumeManager->getByFolderId($folderId); $folder = $volume->findFolder($folderId); $file = $volume->findFileByPath($folder->getPath().'/'.$uploadFileSource->getName()); $originalFileId = null; if ($file) { $originalFileId = $file->getId(); } $useWizard = $this->useWizard($uploadFileSource); if ($originalFileId || $useWizard) { return $this->tempStorage->store( $uploadFileSource, $folderId, $userId, $originalFileId, $useWizard ); } $file = $volume->createFile($folder, $uploadFileSource, array(), $userId); return $file; }
[ "public", "function", "handle", "(", "UploadedFile", "$", "uploadedFile", ",", "$", "folderId", ",", "$", "userId", ")", "{", "$", "uploadFileSource", "=", "new", "UploadedFileSource", "(", "$", "uploadedFile", ")", ";", "$", "volume", "=", "$", "this", "->", "volumeManager", "->", "getByFolderId", "(", "$", "folderId", ")", ";", "$", "folder", "=", "$", "volume", "->", "findFolder", "(", "$", "folderId", ")", ";", "$", "file", "=", "$", "volume", "->", "findFileByPath", "(", "$", "folder", "->", "getPath", "(", ")", ".", "'/'", ".", "$", "uploadFileSource", "->", "getName", "(", ")", ")", ";", "$", "originalFileId", "=", "null", ";", "if", "(", "$", "file", ")", "{", "$", "originalFileId", "=", "$", "file", "->", "getId", "(", ")", ";", "}", "$", "useWizard", "=", "$", "this", "->", "useWizard", "(", "$", "uploadFileSource", ")", ";", "if", "(", "$", "originalFileId", "||", "$", "useWizard", ")", "{", "return", "$", "this", "->", "tempStorage", "->", "store", "(", "$", "uploadFileSource", ",", "$", "folderId", ",", "$", "userId", ",", "$", "originalFileId", ",", "$", "useWizard", ")", ";", "}", "$", "file", "=", "$", "volume", "->", "createFile", "(", "$", "folder", ",", "$", "uploadFileSource", ",", "array", "(", ")", ",", "$", "userId", ")", ";", "return", "$", "file", ";", "}" ]
Handle upload. @param UploadedFile $uploadedFile @param string $folderId @param string $userId @return TempFile|ExtendedFileInterface
[ "Handle", "upload", "." ]
e4835062c9be575fc0e5ab67f25f02a50a85a7f6
https://github.com/phlexible/media-manager/blob/e4835062c9be575fc0e5ab67f25f02a50a85a7f6/Upload/UploadHandler.php#L96-L124
1,283
kettari/tallanto-client-api-bundle
Api/Method/TallantoGetClassesVisitsMethod.php
TallantoGetClassesVisitsMethod.getVisits
public function getVisits($items) { $result = []; foreach ($items as $item) { $result[] = new Visit($item); } return $result; }
php
public function getVisits($items) { $result = []; foreach ($items as $item) { $result[] = new Visit($item); } return $result; }
[ "public", "function", "getVisits", "(", "$", "items", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "result", "[", "]", "=", "new", "Visit", "(", "$", "item", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns array of visits. @param array $items @return array
[ "Returns", "array", "of", "visits", "." ]
09863d2b0fed306cc1218ed602ba6c6ad461c3da
https://github.com/kettari/tallanto-client-api-bundle/blob/09863d2b0fed306cc1218ed602ba6c6ad461c3da/Api/Method/TallantoGetClassesVisitsMethod.php#L95-L103
1,284
wigedev/simple-mvc
src/Utility/ModuleControllerLoader.php
ModuleControllerLoader.loadModule
protected function loadModule() : void { $fqn = $this->getFullyQualifiedClass($this->response->getModule(), $this->response->getController()); $the_module = new $fqn(); call_user_func_array(array($the_module, $this->getActionMethodName($this->response->getAction())), [$this->response->getVariables()]); }
php
protected function loadModule() : void { $fqn = $this->getFullyQualifiedClass($this->response->getModule(), $this->response->getController()); $the_module = new $fqn(); call_user_func_array(array($the_module, $this->getActionMethodName($this->response->getAction())), [$this->response->getVariables()]); }
[ "protected", "function", "loadModule", "(", ")", ":", "void", "{", "$", "fqn", "=", "$", "this", "->", "getFullyQualifiedClass", "(", "$", "this", "->", "response", "->", "getModule", "(", ")", ",", "$", "this", "->", "response", "->", "getController", "(", ")", ")", ";", "$", "the_module", "=", "new", "$", "fqn", "(", ")", ";", "call_user_func_array", "(", "array", "(", "$", "the_module", ",", "$", "this", "->", "getActionMethodName", "(", "$", "this", "->", "response", "->", "getAction", "(", ")", ")", ")", ",", "[", "$", "this", "->", "response", "->", "getVariables", "(", ")", "]", ")", ";", "}" ]
Load a module as requested and mapped by the router.
[ "Load", "a", "module", "as", "requested", "and", "mapped", "by", "the", "router", "." ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Utility/ModuleControllerLoader.php#L69-L74
1,285
wigedev/simple-mvc
src/Utility/ModuleControllerLoader.php
ModuleControllerLoader.loadErrorModule
protected function loadErrorModule() : void { $fqn = $this->getFullyQualifiedClass('index', 'index'); $the_module = new $fqn(); $action = $this->getActionMethodName((string)$this->response->getStatusCode()); if (method_exists($fqn, $action)) { call_user_func_array(array($the_module, $action), [$this->response->getVariables()]); } else { // There is no error handler for this error, show the index but don't pass variables call_user_func_array(array($the_module, $this->getActionMethodName('index')), []); } }
php
protected function loadErrorModule() : void { $fqn = $this->getFullyQualifiedClass('index', 'index'); $the_module = new $fqn(); $action = $this->getActionMethodName((string)$this->response->getStatusCode()); if (method_exists($fqn, $action)) { call_user_func_array(array($the_module, $action), [$this->response->getVariables()]); } else { // There is no error handler for this error, show the index but don't pass variables call_user_func_array(array($the_module, $this->getActionMethodName('index')), []); } }
[ "protected", "function", "loadErrorModule", "(", ")", ":", "void", "{", "$", "fqn", "=", "$", "this", "->", "getFullyQualifiedClass", "(", "'index'", ",", "'index'", ")", ";", "$", "the_module", "=", "new", "$", "fqn", "(", ")", ";", "$", "action", "=", "$", "this", "->", "getActionMethodName", "(", "(", "string", ")", "$", "this", "->", "response", "->", "getStatusCode", "(", ")", ")", ";", "if", "(", "method_exists", "(", "$", "fqn", ",", "$", "action", ")", ")", "{", "call_user_func_array", "(", "array", "(", "$", "the_module", ",", "$", "action", ")", ",", "[", "$", "this", "->", "response", "->", "getVariables", "(", ")", "]", ")", ";", "}", "else", "{", "// There is no error handler for this error, show the index but don't pass variables", "call_user_func_array", "(", "array", "(", "$", "the_module", ",", "$", "this", "->", "getActionMethodName", "(", "'index'", ")", ")", ",", "[", "]", ")", ";", "}", "}" ]
Load an error module based on the error code.
[ "Load", "an", "error", "module", "based", "on", "the", "error", "code", "." ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Utility/ModuleControllerLoader.php#L79-L90
1,286
wigedev/simple-mvc
src/Utility/ModuleControllerLoader.php
ModuleControllerLoader.getFullyQualifiedClass
protected function getFullyQualifiedClass(string $module_name, string $controller_class) : string { return 'Application\\Module\\' . $this->getModuleName($module_name) . '\\Controller\\' . $this->getControllerName($controller_class); }
php
protected function getFullyQualifiedClass(string $module_name, string $controller_class) : string { return 'Application\\Module\\' . $this->getModuleName($module_name) . '\\Controller\\' . $this->getControllerName($controller_class); }
[ "protected", "function", "getFullyQualifiedClass", "(", "string", "$", "module_name", ",", "string", "$", "controller_class", ")", ":", "string", "{", "return", "'Application\\\\Module\\\\'", ".", "$", "this", "->", "getModuleName", "(", "$", "module_name", ")", ".", "'\\\\Controller\\\\'", ".", "$", "this", "->", "getControllerName", "(", "$", "controller_class", ")", ";", "}" ]
Get the fully qualified class name of the controller. @param string $module_name @param string $controller_class @return string
[ "Get", "the", "fully", "qualified", "class", "name", "of", "the", "controller", "." ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Utility/ModuleControllerLoader.php#L98-L101
1,287
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.getConnection
protected function getConnection($nameDB = NULL){ //Leo archivo de configuracion de BD si es la primera vez if(self::$config_db == NULL){ self::$config_db= $this->context->readConfigurationFile($this->configFile); } //Consulta la bd actual si no se indico opcion print_r(self::$config_db); if($nameDB == NULL)$nameDB= self::$config_db['actual-db']; //Cargo las opciones de la bd actual $cbd= self::$config_db[$nameDB]; $this->currentDB= $nameDB; $this->currentConfiguration= &self::$config_db[$nameDB]; //Abro una conexion try { // Desde 5.3.6 o > // $gbd->exec("set names " . $cbd['charset']); // Versiones anteriores usaba $cbd['driverbd'].':host='.$cbd['hostname'].';dbname='.$cbd['database'].';charset=utf8'; //Creo el dsn $dsn= $cbd['driverbd'].':'; //Para SQLite y el resto if($cbd['driverbd'] == "sqlite"){ $dsn .= $cbd['database']; $gbd = new \PDO($dsn); }else{ $dsn .= 'host='.$cbd['hostname'].';port='.$cbd['port']; if(isset($cbd['database'])){ $dsn.= ';dbname='.$cbd['database']; } if($cbd['user'] == ""){ $cbd['user']= NULL; $cbd['pass']= NULL; } //Abro la conexion $gbd = new \PDO($dsn, $cbd['user'], $cbd['pass'], array(\PDO::ATTR_PERSISTENT => $cbd['persistent'])); $gbd->exec("SET NAMES '".$cbd['charset']."'"); } if($this->context->getEnvironment() == 'development'){ $gbd->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); }else{ $gbd->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); } //Retorno la conexion return $gbd; } catch (\PDOException $e) { throw $e; } }
php
protected function getConnection($nameDB = NULL){ //Leo archivo de configuracion de BD si es la primera vez if(self::$config_db == NULL){ self::$config_db= $this->context->readConfigurationFile($this->configFile); } //Consulta la bd actual si no se indico opcion print_r(self::$config_db); if($nameDB == NULL)$nameDB= self::$config_db['actual-db']; //Cargo las opciones de la bd actual $cbd= self::$config_db[$nameDB]; $this->currentDB= $nameDB; $this->currentConfiguration= &self::$config_db[$nameDB]; //Abro una conexion try { // Desde 5.3.6 o > // $gbd->exec("set names " . $cbd['charset']); // Versiones anteriores usaba $cbd['driverbd'].':host='.$cbd['hostname'].';dbname='.$cbd['database'].';charset=utf8'; //Creo el dsn $dsn= $cbd['driverbd'].':'; //Para SQLite y el resto if($cbd['driverbd'] == "sqlite"){ $dsn .= $cbd['database']; $gbd = new \PDO($dsn); }else{ $dsn .= 'host='.$cbd['hostname'].';port='.$cbd['port']; if(isset($cbd['database'])){ $dsn.= ';dbname='.$cbd['database']; } if($cbd['user'] == ""){ $cbd['user']= NULL; $cbd['pass']= NULL; } //Abro la conexion $gbd = new \PDO($dsn, $cbd['user'], $cbd['pass'], array(\PDO::ATTR_PERSISTENT => $cbd['persistent'])); $gbd->exec("SET NAMES '".$cbd['charset']."'"); } if($this->context->getEnvironment() == 'development'){ $gbd->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); }else{ $gbd->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); } //Retorno la conexion return $gbd; } catch (\PDOException $e) { throw $e; } }
[ "protected", "function", "getConnection", "(", "$", "nameDB", "=", "NULL", ")", "{", "//Leo archivo de configuracion de BD si es la primera vez", "if", "(", "self", "::", "$", "config_db", "==", "NULL", ")", "{", "self", "::", "$", "config_db", "=", "$", "this", "->", "context", "->", "readConfigurationFile", "(", "$", "this", "->", "configFile", ")", ";", "}", "//Consulta la bd actual si no se indico opcion print_r(self::$config_db);", "if", "(", "$", "nameDB", "==", "NULL", ")", "$", "nameDB", "=", "self", "::", "$", "config_db", "[", "'actual-db'", "]", ";", "//Cargo las opciones de la bd actual", "$", "cbd", "=", "self", "::", "$", "config_db", "[", "$", "nameDB", "]", ";", "$", "this", "->", "currentDB", "=", "$", "nameDB", ";", "$", "this", "->", "currentConfiguration", "=", "&", "self", "::", "$", "config_db", "[", "$", "nameDB", "]", ";", "//Abro una conexion", "try", "{", "// Desde 5.3.6 o >", "// $gbd->exec(\"set names \" . $cbd['charset']);", "// Versiones anteriores usaba $cbd['driverbd'].':host='.$cbd['hostname'].';dbname='.$cbd['database'].';charset=utf8';", "//Creo el dsn", "$", "dsn", "=", "$", "cbd", "[", "'driverbd'", "]", ".", "':'", ";", "//Para SQLite y el resto", "if", "(", "$", "cbd", "[", "'driverbd'", "]", "==", "\"sqlite\"", ")", "{", "$", "dsn", ".=", "$", "cbd", "[", "'database'", "]", ";", "$", "gbd", "=", "new", "\\", "PDO", "(", "$", "dsn", ")", ";", "}", "else", "{", "$", "dsn", ".=", "'host='", ".", "$", "cbd", "[", "'hostname'", "]", ".", "';port='", ".", "$", "cbd", "[", "'port'", "]", ";", "if", "(", "isset", "(", "$", "cbd", "[", "'database'", "]", ")", ")", "{", "$", "dsn", ".=", "';dbname='", ".", "$", "cbd", "[", "'database'", "]", ";", "}", "if", "(", "$", "cbd", "[", "'user'", "]", "==", "\"\"", ")", "{", "$", "cbd", "[", "'user'", "]", "=", "NULL", ";", "$", "cbd", "[", "'pass'", "]", "=", "NULL", ";", "}", "//Abro la conexion ", "$", "gbd", "=", "new", "\\", "PDO", "(", "$", "dsn", ",", "$", "cbd", "[", "'user'", "]", ",", "$", "cbd", "[", "'pass'", "]", ",", "array", "(", "\\", "PDO", "::", "ATTR_PERSISTENT", "=>", "$", "cbd", "[", "'persistent'", "]", ")", ")", ";", "$", "gbd", "->", "exec", "(", "\"SET NAMES '\"", ".", "$", "cbd", "[", "'charset'", "]", ".", "\"'\"", ")", ";", "}", "if", "(", "$", "this", "->", "context", "->", "getEnvironment", "(", ")", "==", "'development'", ")", "{", "$", "gbd", "->", "setAttribute", "(", "\\", "PDO", "::", "ATTR_ERRMODE", ",", "\\", "PDO", "::", "ERRMODE_EXCEPTION", ")", ";", "}", "else", "{", "$", "gbd", "->", "setAttribute", "(", "\\", "PDO", "::", "ATTR_ERRMODE", ",", "\\", "PDO", "::", "ERRMODE_SILENT", ")", ";", "}", "//Retorno la conexion ", "return", "$", "gbd", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}" ]
Abre una conexion en base a la configuracion de la BD @param string $nameDB @return \PDO @throws \PDOException
[ "Abre", "una", "conexion", "en", "base", "a", "la", "configuracion", "de", "la", "BD" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L69-L117
1,288
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.catchError
protected function catchError($error){ if($this->connection->inTransaction()){ $this->errorTran[]= $error; $this->stateTran= FALSE; } $this->lastError= $error; }
php
protected function catchError($error){ if($this->connection->inTransaction()){ $this->errorTran[]= $error; $this->stateTran= FALSE; } $this->lastError= $error; }
[ "protected", "function", "catchError", "(", "$", "error", ")", "{", "if", "(", "$", "this", "->", "connection", "->", "inTransaction", "(", ")", ")", "{", "$", "this", "->", "errorTran", "[", "]", "=", "$", "error", ";", "$", "this", "->", "stateTran", "=", "FALSE", ";", "}", "$", "this", "->", "lastError", "=", "$", "error", ";", "}" ]
Almacena los errores @param string $error
[ "Almacena", "los", "errores" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L122-L129
1,289
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.connect
public function connect($nameDB = NULL, $configFile = NULL){ if($configFile != NULL){ $this->configFile= $configFile; self::$config_db= NULL; } $this->connection= $this->getConnection($nameDB); }
php
public function connect($nameDB = NULL, $configFile = NULL){ if($configFile != NULL){ $this->configFile= $configFile; self::$config_db= NULL; } $this->connection= $this->getConnection($nameDB); }
[ "public", "function", "connect", "(", "$", "nameDB", "=", "NULL", ",", "$", "configFile", "=", "NULL", ")", "{", "if", "(", "$", "configFile", "!=", "NULL", ")", "{", "$", "this", "->", "configFile", "=", "$", "configFile", ";", "self", "::", "$", "config_db", "=", "NULL", ";", "}", "$", "this", "->", "connection", "=", "$", "this", "->", "getConnection", "(", "$", "nameDB", ")", ";", "}" ]
Realiza la conexion a la base indicada o por defecto @param string $nameDB
[ "Realiza", "la", "conexion", "a", "la", "base", "indicada", "o", "por", "defecto" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L139-L145
1,290
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.select
public function select($select, $distinct = FALSE){ if($distinct){ $this->select= 'DISTINCT '; }else{ $this->select= ''; } $this->select .= $select; }
php
public function select($select, $distinct = FALSE){ if($distinct){ $this->select= 'DISTINCT '; }else{ $this->select= ''; } $this->select .= $select; }
[ "public", "function", "select", "(", "$", "select", ",", "$", "distinct", "=", "FALSE", ")", "{", "if", "(", "$", "distinct", ")", "{", "$", "this", "->", "select", "=", "'DISTINCT '", ";", "}", "else", "{", "$", "this", "->", "select", "=", "''", ";", "}", "$", "this", "->", "select", ".=", "$", "select", ";", "}" ]
Arma el Select de la consulta @param string $select @param bool $distinct
[ "Arma", "el", "Select", "de", "la", "consulta" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L177-L184
1,291
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.where
public function where($conditions, array $values){ if($this->where != ''){$this->where.='AND ';} $this->where.= $conditions . ' '; $this->where_values = array_merge($this->where_values, $values); }
php
public function where($conditions, array $values){ if($this->where != ''){$this->where.='AND ';} $this->where.= $conditions . ' '; $this->where_values = array_merge($this->where_values, $values); }
[ "public", "function", "where", "(", "$", "conditions", ",", "array", "$", "values", ")", "{", "if", "(", "$", "this", "->", "where", "!=", "''", ")", "{", "$", "this", "->", "where", ".=", "'AND '", ";", "}", "$", "this", "->", "where", ".=", "$", "conditions", ".", "' '", ";", "$", "this", "->", "where_values", "=", "array_merge", "(", "$", "this", "->", "where_values", ",", "$", "values", ")", ";", "}" ]
Arma el where de la consulta @param string $conditions @param array $values
[ "Arma", "el", "where", "de", "la", "consulta" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L206-L210
1,292
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.where_like
public function where_like($field, $match, $joker='both', $not=FALSE){ if($this->where != ''){$this->where.='AND ';} $this->like($field, $match, $joker, $not); }
php
public function where_like($field, $match, $joker='both', $not=FALSE){ if($this->where != ''){$this->where.='AND ';} $this->like($field, $match, $joker, $not); }
[ "public", "function", "where_like", "(", "$", "field", ",", "$", "match", ",", "$", "joker", "=", "'both'", ",", "$", "not", "=", "FALSE", ")", "{", "if", "(", "$", "this", "->", "where", "!=", "''", ")", "{", "$", "this", "->", "where", ".=", "'AND '", ";", "}", "$", "this", "->", "like", "(", "$", "field", ",", "$", "match", ",", "$", "joker", ",", "$", "not", ")", ";", "}" ]
Arma el where like de la consutla @param string $field @param string $match @param string $joker @param bool $not
[ "Arma", "el", "where", "like", "de", "la", "consutla" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L228-L231
1,293
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.like
protected function like($field, $match, $joker='both', $not=FALSE){ $this->where.= $field . ' '; if($not){$this->where.= 'NOT ';} $this->where.= 'LIKE '; switch ($joker){ case 'both': $this->where.= "'%$match%' "; break; case 'after': $this->where.= "'$match%' "; break; case 'before': $this->where.= "'%$match' "; break; } }
php
protected function like($field, $match, $joker='both', $not=FALSE){ $this->where.= $field . ' '; if($not){$this->where.= 'NOT ';} $this->where.= 'LIKE '; switch ($joker){ case 'both': $this->where.= "'%$match%' "; break; case 'after': $this->where.= "'$match%' "; break; case 'before': $this->where.= "'%$match' "; break; } }
[ "protected", "function", "like", "(", "$", "field", ",", "$", "match", ",", "$", "joker", "=", "'both'", ",", "$", "not", "=", "FALSE", ")", "{", "$", "this", "->", "where", ".=", "$", "field", ".", "' '", ";", "if", "(", "$", "not", ")", "{", "$", "this", "->", "where", ".=", "'NOT '", ";", "}", "$", "this", "->", "where", ".=", "'LIKE '", ";", "switch", "(", "$", "joker", ")", "{", "case", "'both'", ":", "$", "this", "->", "where", ".=", "\"'%$match%' \"", ";", "break", ";", "case", "'after'", ":", "$", "this", "->", "where", ".=", "\"'$match%' \"", ";", "break", ";", "case", "'before'", ":", "$", "this", "->", "where", ".=", "\"'%$match' \"", ";", "break", ";", "}", "}" ]
Arma el Like para el where and o or @param string $field @param string $match @param string $joker @param bool $not
[ "Arma", "el", "Like", "para", "el", "where", "and", "o", "or" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L250-L265
1,294
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.where_in
public function where_in($field, array $values, $not=FALSE){ if($this->where != ''){$this->where.='AND ';} $this->in($field, $values, $not); }
php
public function where_in($field, array $values, $not=FALSE){ if($this->where != ''){$this->where.='AND ';} $this->in($field, $values, $not); }
[ "public", "function", "where_in", "(", "$", "field", ",", "array", "$", "values", ",", "$", "not", "=", "FALSE", ")", "{", "if", "(", "$", "this", "->", "where", "!=", "''", ")", "{", "$", "this", "->", "where", ".=", "'AND '", ";", "}", "$", "this", "->", "in", "(", "$", "field", ",", "$", "values", ",", "$", "not", ")", ";", "}" ]
Arma el where in de la consulta @param string $field @param array $values @param bool $not
[ "Arma", "el", "where", "in", "de", "la", "consulta" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L272-L275
1,295
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.or_where_in
public function or_where_in($field, array $values, $not=FALSE){ if($this->where != ''){$this->where.='OR ';} $this->in($field, $values, $not); }
php
public function or_where_in($field, array $values, $not=FALSE){ if($this->where != ''){$this->where.='OR ';} $this->in($field, $values, $not); }
[ "public", "function", "or_where_in", "(", "$", "field", ",", "array", "$", "values", ",", "$", "not", "=", "FALSE", ")", "{", "if", "(", "$", "this", "->", "where", "!=", "''", ")", "{", "$", "this", "->", "where", ".=", "'OR '", ";", "}", "$", "this", "->", "in", "(", "$", "field", ",", "$", "values", ",", "$", "not", ")", ";", "}" ]
Arma el where in con or de la consulta @param string $field @param array $values @param bool $not
[ "Arma", "el", "where", "in", "con", "or", "de", "la", "consulta" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L282-L285
1,296
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.in
protected function in($field, array $values, $not=FALSE){ $this->where.= $field . ' '; if($not){$this->where.= 'NOT ';} $this->where.= 'IN ('; foreach ($values as $value) { $this->where.= "'$value',"; } $this->where= rtrim($this->where, ','); $this->where.= ') '; }
php
protected function in($field, array $values, $not=FALSE){ $this->where.= $field . ' '; if($not){$this->where.= 'NOT ';} $this->where.= 'IN ('; foreach ($values as $value) { $this->where.= "'$value',"; } $this->where= rtrim($this->where, ','); $this->where.= ') '; }
[ "protected", "function", "in", "(", "$", "field", ",", "array", "$", "values", ",", "$", "not", "=", "FALSE", ")", "{", "$", "this", "->", "where", ".=", "$", "field", ".", "' '", ";", "if", "(", "$", "not", ")", "{", "$", "this", "->", "where", ".=", "'NOT '", ";", "}", "$", "this", "->", "where", ".=", "'IN ('", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "this", "->", "where", ".=", "\"'$value',\"", ";", "}", "$", "this", "->", "where", "=", "rtrim", "(", "$", "this", "->", "where", ",", "','", ")", ";", "$", "this", "->", "where", ".=", "') '", ";", "}" ]
Arma el in para el where and o or @param string $field @param array $values @param bool $not
[ "Arma", "el", "in", "para", "el", "where", "and", "o", "or" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L292-L301
1,297
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.group
public function group($group){ if(is_array($group)){ $this->group= 'GROUP BY '; foreach ($group as $value) { $this->group .= $value.','; } $this->group= rtrim($this->group, ','); $this->group.=' '; }else{ $this->group= 'GROUP BY '.$group.' '; } }
php
public function group($group){ if(is_array($group)){ $this->group= 'GROUP BY '; foreach ($group as $value) { $this->group .= $value.','; } $this->group= rtrim($this->group, ','); $this->group.=' '; }else{ $this->group= 'GROUP BY '.$group.' '; } }
[ "public", "function", "group", "(", "$", "group", ")", "{", "if", "(", "is_array", "(", "$", "group", ")", ")", "{", "$", "this", "->", "group", "=", "'GROUP BY '", ";", "foreach", "(", "$", "group", "as", "$", "value", ")", "{", "$", "this", "->", "group", ".=", "$", "value", ".", "','", ";", "}", "$", "this", "->", "group", "=", "rtrim", "(", "$", "this", "->", "group", ",", "','", ")", ";", "$", "this", "->", "group", ".=", "' '", ";", "}", "else", "{", "$", "this", "->", "group", "=", "'GROUP BY '", ".", "$", "group", ".", "' '", ";", "}", "}" ]
Arma el group de la consulta @param string $group
[ "Arma", "el", "group", "de", "la", "consulta" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L306-L317
1,298
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.having
public function having($conditions, array $values){ if($this->having != ''){$this->having.='AND ';} $this->having.= $conditions . ' '; $this->where_values = array_merge($this->where_values, $values); }
php
public function having($conditions, array $values){ if($this->having != ''){$this->having.='AND ';} $this->having.= $conditions . ' '; $this->where_values = array_merge($this->where_values, $values); }
[ "public", "function", "having", "(", "$", "conditions", ",", "array", "$", "values", ")", "{", "if", "(", "$", "this", "->", "having", "!=", "''", ")", "{", "$", "this", "->", "having", ".=", "'AND '", ";", "}", "$", "this", "->", "having", ".=", "$", "conditions", ".", "' '", ";", "$", "this", "->", "where_values", "=", "array_merge", "(", "$", "this", "->", "where_values", ",", "$", "values", ")", ";", "}" ]
Arma el having de la consulta @param string $conditions @param array $values
[ "Arma", "el", "having", "de", "la", "consulta" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L323-L327
1,299
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.get
public function get(){ $res= FALSE; try{ //Armo y preparo la consulta $query= $this->prepareSelect($this->select, $this->from, $this->where, $this->group, $this->having, $this->order, $this->limit); //Ejecuto la consulta $query->execute($this->where_values); //Controlo que este todo bien if($this->isOk($query)){ $res= $query; } //Limpio las variables del AR $this->cleanVars(); } catch (\PDOException $e) { $this->cleanVars(); throw $e; } return $res; }
php
public function get(){ $res= FALSE; try{ //Armo y preparo la consulta $query= $this->prepareSelect($this->select, $this->from, $this->where, $this->group, $this->having, $this->order, $this->limit); //Ejecuto la consulta $query->execute($this->where_values); //Controlo que este todo bien if($this->isOk($query)){ $res= $query; } //Limpio las variables del AR $this->cleanVars(); } catch (\PDOException $e) { $this->cleanVars(); throw $e; } return $res; }
[ "public", "function", "get", "(", ")", "{", "$", "res", "=", "FALSE", ";", "try", "{", "//Armo y preparo la consulta", "$", "query", "=", "$", "this", "->", "prepareSelect", "(", "$", "this", "->", "select", ",", "$", "this", "->", "from", ",", "$", "this", "->", "where", ",", "$", "this", "->", "group", ",", "$", "this", "->", "having", ",", "$", "this", "->", "order", ",", "$", "this", "->", "limit", ")", ";", "//Ejecuto la consulta", "$", "query", "->", "execute", "(", "$", "this", "->", "where_values", ")", ";", "//Controlo que este todo bien", "if", "(", "$", "this", "->", "isOk", "(", "$", "query", ")", ")", "{", "$", "res", "=", "$", "query", ";", "}", "//Limpio las variables del AR", "$", "this", "->", "cleanVars", "(", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "$", "this", "->", "cleanVars", "(", ")", ";", "throw", "$", "e", ";", "}", "return", "$", "res", ";", "}" ]
Devuelve el resultado de la consulta armada de forma ActiveRecord @return \PDOStatement o FALSE @throws \PDOException
[ "Devuelve", "el", "resultado", "de", "la", "consulta", "armada", "de", "forma", "ActiveRecord" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L359-L377