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
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
24,900
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.removeModuleDirectory
protected function removeModuleDirectory($moduleName) { $this->files->deleteDirectory($this->getModuleDirectory($moduleName)); if($this->files->exists($this->getModuleDirectory($moduleName))) { $this->errors->add('delete_files', 'Unable to delete '.$this->getModuleDirectory($moduleName)); return false; } return true; }
php
protected function removeModuleDirectory($moduleName) { $this->files->deleteDirectory($this->getModuleDirectory($moduleName)); if($this->files->exists($this->getModuleDirectory($moduleName))) { $this->errors->add('delete_files', 'Unable to delete '.$this->getModuleDirectory($moduleName)); return false; } return true; }
[ "protected", "function", "removeModuleDirectory", "(", "$", "moduleName", ")", "{", "$", "this", "->", "files", "->", "deleteDirectory", "(", "$", "this", "->", "getModuleDirectory", "(", "$", "moduleName", ")", ")", ";", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "this", "->", "getModuleDirectory", "(", "$", "moduleName", ")", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "'delete_files'", ",", "'Unable to delete '", ".", "$", "this", "->", "getModuleDirectory", "(", "$", "moduleName", ")", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Remove module directory @param string $moduleName @return bool
[ "Remove", "module", "directory" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L319-L328
24,901
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.sysVersionDependency
protected function sysVersionDependency($version) { $sysVersion = new Version($this->sysMajorVersion.'.'.$this->sysMinorVersion.'.'.$this->sysPathVersion); $needVersion = new Version($version); if (!$sysVersion->isPartOf($needVersion)) { $this->errors->add('module_dependency_sys', 'This module not made for current version of '.$this->systemName.', made for '.$version); return false; } return false; }
php
protected function sysVersionDependency($version) { $sysVersion = new Version($this->sysMajorVersion.'.'.$this->sysMinorVersion.'.'.$this->sysPathVersion); $needVersion = new Version($version); if (!$sysVersion->isPartOf($needVersion)) { $this->errors->add('module_dependency_sys', 'This module not made for current version of '.$this->systemName.', made for '.$version); return false; } return false; }
[ "protected", "function", "sysVersionDependency", "(", "$", "version", ")", "{", "$", "sysVersion", "=", "new", "Version", "(", "$", "this", "->", "sysMajorVersion", ".", "'.'", ".", "$", "this", "->", "sysMinorVersion", ".", "'.'", ".", "$", "this", "->", "sysPathVersion", ")", ";", "$", "needVersion", "=", "new", "Version", "(", "$", "version", ")", ";", "if", "(", "!", "$", "sysVersion", "->", "isPartOf", "(", "$", "needVersion", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "'module_dependency_sys'", ",", "'This module not made for current version of '", ".", "$", "this", "->", "systemName", ".", "', made for '", ".", "$", "version", ")", ";", "return", "false", ";", "}", "return", "false", ";", "}" ]
Check system dependency @param string $version @return bool
[ "Check", "system", "dependency" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L336-L347
24,902
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.checkDependency
protected function checkDependency($dependencies = null) { $errors = array(); if (is_null($dependencies)) $dependencies = array(); $i = 0; $clean = true; foreach ($dependencies as $module => $version) { if ($module == $this->systemName) { if (!$this->sysVersionDependency($version)) $clean = false; continue; } $depModule = ModuleModel::where('module_name', $module)->first(); if (!$depModule) { $this->errors->add("module_dependency_$i", "Module $module with version $version not installed"); $clean = false; } else { $depVersion = $depModule->module_version; $needVersion = $version; $depVersion = new Version($depVersion); $needVersion = new Version($needVersion); if (!$depVersion->isPartOf($needVersion)) { $this->errors->add("module_dependency_$i", 'Module '.$module.' v'.$needVersion->getVersion().' must install, but '.$depVersion->getVersion().' installed.'); $clean = false; } } $i++; } if(!$clean) return false; return true; }
php
protected function checkDependency($dependencies = null) { $errors = array(); if (is_null($dependencies)) $dependencies = array(); $i = 0; $clean = true; foreach ($dependencies as $module => $version) { if ($module == $this->systemName) { if (!$this->sysVersionDependency($version)) $clean = false; continue; } $depModule = ModuleModel::where('module_name', $module)->first(); if (!$depModule) { $this->errors->add("module_dependency_$i", "Module $module with version $version not installed"); $clean = false; } else { $depVersion = $depModule->module_version; $needVersion = $version; $depVersion = new Version($depVersion); $needVersion = new Version($needVersion); if (!$depVersion->isPartOf($needVersion)) { $this->errors->add("module_dependency_$i", 'Module '.$module.' v'.$needVersion->getVersion().' must install, but '.$depVersion->getVersion().' installed.'); $clean = false; } } $i++; } if(!$clean) return false; return true; }
[ "protected", "function", "checkDependency", "(", "$", "dependencies", "=", "null", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "if", "(", "is_null", "(", "$", "dependencies", ")", ")", "$", "dependencies", "=", "array", "(", ")", ";", "$", "i", "=", "0", ";", "$", "clean", "=", "true", ";", "foreach", "(", "$", "dependencies", "as", "$", "module", "=>", "$", "version", ")", "{", "if", "(", "$", "module", "==", "$", "this", "->", "systemName", ")", "{", "if", "(", "!", "$", "this", "->", "sysVersionDependency", "(", "$", "version", ")", ")", "$", "clean", "=", "false", ";", "continue", ";", "}", "$", "depModule", "=", "ModuleModel", "::", "where", "(", "'module_name'", ",", "$", "module", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "depModule", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "\"module_dependency_$i\"", ",", "\"Module $module with version $version not installed\"", ")", ";", "$", "clean", "=", "false", ";", "}", "else", "{", "$", "depVersion", "=", "$", "depModule", "->", "module_version", ";", "$", "needVersion", "=", "$", "version", ";", "$", "depVersion", "=", "new", "Version", "(", "$", "depVersion", ")", ";", "$", "needVersion", "=", "new", "Version", "(", "$", "needVersion", ")", ";", "if", "(", "!", "$", "depVersion", "->", "isPartOf", "(", "$", "needVersion", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "\"module_dependency_$i\"", ",", "'Module '", ".", "$", "module", ".", "' v'", ".", "$", "needVersion", "->", "getVersion", "(", ")", ".", "' must install, but '", ".", "$", "depVersion", "->", "getVersion", "(", ")", ".", "' installed.'", ")", ";", "$", "clean", "=", "false", ";", "}", "}", "$", "i", "++", ";", "}", "if", "(", "!", "$", "clean", ")", "return", "false", ";", "return", "true", ";", "}" ]
Check module dependencies @param array $dependencies @return bool
[ "Check", "module", "dependencies" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L355-L400
24,903
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.uninstall
public function uninstall($moduleName) { $module = $this->findOrFalse('module_name', $moduleName); if ($module) { $version = $this->def($moduleName, 'version'); if ($this->checkModuleDepends($moduleName, new Version($version))) return false; $this->app['events']->fire('modules.uninstall.'.$moduleName, null); $module->delete(); if (!$this->removeAssets($moduleName)) $this->errors->add('delete_assets', "Unable to delete assets $moduleName"); if (!$this->removeModuleDirectory($moduleName)) $this->errors->add('delete_module', "Unable to delete $moduleName"); return true; } return false; }
php
public function uninstall($moduleName) { $module = $this->findOrFalse('module_name', $moduleName); if ($module) { $version = $this->def($moduleName, 'version'); if ($this->checkModuleDepends($moduleName, new Version($version))) return false; $this->app['events']->fire('modules.uninstall.'.$moduleName, null); $module->delete(); if (!$this->removeAssets($moduleName)) $this->errors->add('delete_assets', "Unable to delete assets $moduleName"); if (!$this->removeModuleDirectory($moduleName)) $this->errors->add('delete_module', "Unable to delete $moduleName"); return true; } return false; }
[ "public", "function", "uninstall", "(", "$", "moduleName", ")", "{", "$", "module", "=", "$", "this", "->", "findOrFalse", "(", "'module_name'", ",", "$", "moduleName", ")", ";", "if", "(", "$", "module", ")", "{", "$", "version", "=", "$", "this", "->", "def", "(", "$", "moduleName", ",", "'version'", ")", ";", "if", "(", "$", "this", "->", "checkModuleDepends", "(", "$", "moduleName", ",", "new", "Version", "(", "$", "version", ")", ")", ")", "return", "false", ";", "$", "this", "->", "app", "[", "'events'", "]", "->", "fire", "(", "'modules.uninstall.'", ".", "$", "moduleName", ",", "null", ")", ";", "$", "module", "->", "delete", "(", ")", ";", "if", "(", "!", "$", "this", "->", "removeAssets", "(", "$", "moduleName", ")", ")", "$", "this", "->", "errors", "->", "add", "(", "'delete_assets'", ",", "\"Unable to delete assets $moduleName\"", ")", ";", "if", "(", "!", "$", "this", "->", "removeModuleDirectory", "(", "$", "moduleName", ")", ")", "$", "this", "->", "errors", "->", "add", "(", "'delete_module'", ",", "\"Unable to delete $moduleName\"", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Uninstall module and remove assets @param string $moduleName @return bool
[ "Uninstall", "module", "and", "remove", "assets" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L420-L442
24,904
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.install
public function install($tempPath, $moduleName) { //Check module dependecies $moduleDependency = $this->def($tempPath, 'require', true); if (!$moduleDependency = $this->checkDependency($moduleDependency)) return false; //Move extracted module to modules path if (!$this->files->copyDirectory($tempPath, $this->path.'/'.$moduleName)) { $this->errors->add('move_files_permission_denied', 'Permission denied in: '.$this->path.'/'.$moduleName); return false; } $this->buildAssets($moduleName); if (!$this->registerModule($moduleName)) { $this->errors->add('register_module', 'Error in register module'); return false; } return true; }
php
public function install($tempPath, $moduleName) { //Check module dependecies $moduleDependency = $this->def($tempPath, 'require', true); if (!$moduleDependency = $this->checkDependency($moduleDependency)) return false; //Move extracted module to modules path if (!$this->files->copyDirectory($tempPath, $this->path.'/'.$moduleName)) { $this->errors->add('move_files_permission_denied', 'Permission denied in: '.$this->path.'/'.$moduleName); return false; } $this->buildAssets($moduleName); if (!$this->registerModule($moduleName)) { $this->errors->add('register_module', 'Error in register module'); return false; } return true; }
[ "public", "function", "install", "(", "$", "tempPath", ",", "$", "moduleName", ")", "{", "//Check module dependecies", "$", "moduleDependency", "=", "$", "this", "->", "def", "(", "$", "tempPath", ",", "'require'", ",", "true", ")", ";", "if", "(", "!", "$", "moduleDependency", "=", "$", "this", "->", "checkDependency", "(", "$", "moduleDependency", ")", ")", "return", "false", ";", "//Move extracted module to modules path", "if", "(", "!", "$", "this", "->", "files", "->", "copyDirectory", "(", "$", "tempPath", ",", "$", "this", "->", "path", ".", "'/'", ".", "$", "moduleName", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "'move_files_permission_denied'", ",", "'Permission denied in: '", ".", "$", "this", "->", "path", ".", "'/'", ".", "$", "moduleName", ")", ";", "return", "false", ";", "}", "$", "this", "->", "buildAssets", "(", "$", "moduleName", ")", ";", "if", "(", "!", "$", "this", "->", "registerModule", "(", "$", "moduleName", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "'register_module'", ",", "'Error in register module'", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Install module and build assets @param string $moduleName @param string path of module @return bool
[ "Install", "module", "and", "build", "assets" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L451-L472
24,905
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.updateRegisteredModule
protected function updateRegisteredModule($moduleName) { $module = $this->findOrFalse('module_name', $moduleName); $module->module_version = $this->def($moduleName, 'version'); $module->module_is_updated = 1; $module->save(); }
php
protected function updateRegisteredModule($moduleName) { $module = $this->findOrFalse('module_name', $moduleName); $module->module_version = $this->def($moduleName, 'version'); $module->module_is_updated = 1; $module->save(); }
[ "protected", "function", "updateRegisteredModule", "(", "$", "moduleName", ")", "{", "$", "module", "=", "$", "this", "->", "findOrFalse", "(", "'module_name'", ",", "$", "moduleName", ")", ";", "$", "module", "->", "module_version", "=", "$", "this", "->", "def", "(", "$", "moduleName", ",", "'version'", ")", ";", "$", "module", "->", "module_is_updated", "=", "1", ";", "$", "module", "->", "save", "(", ")", ";", "}" ]
Update metadate of module updated @param string $moduleName @return void
[ "Update", "metadate", "of", "module", "updated" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L499-L505
24,906
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.zipInit
public function zipInit($archive, $callback = null) { $tempPath = $this->getAssetDirectory().'/#tmp/'.uniqid(); $result = $this->traceZip($archive, $tempPath); $this->files->deleteDirectory($tempPath); if (!is_null($callback)) call_user_func($callback, $result[0], $result[1]); return $result[0]; }
php
public function zipInit($archive, $callback = null) { $tempPath = $this->getAssetDirectory().'/#tmp/'.uniqid(); $result = $this->traceZip($archive, $tempPath); $this->files->deleteDirectory($tempPath); if (!is_null($callback)) call_user_func($callback, $result[0], $result[1]); return $result[0]; }
[ "public", "function", "zipInit", "(", "$", "archive", ",", "$", "callback", "=", "null", ")", "{", "$", "tempPath", "=", "$", "this", "->", "getAssetDirectory", "(", ")", ".", "'/#tmp/'", ".", "uniqid", "(", ")", ";", "$", "result", "=", "$", "this", "->", "traceZip", "(", "$", "archive", ",", "$", "tempPath", ")", ";", "$", "this", "->", "files", "->", "deleteDirectory", "(", "$", "tempPath", ")", ";", "if", "(", "!", "is_null", "(", "$", "callback", ")", ")", "call_user_func", "(", "$", "callback", ",", "$", "result", "[", "0", "]", ",", "$", "result", "[", "1", "]", ")", ";", "return", "$", "result", "[", "0", "]", ";", "}" ]
Initialize zip module @param string $archive path of module zip @param callback|null $callback parameters: bool $result, string $moduleName @return bool
[ "Initialize", "zip", "module" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L515-L527
24,907
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.traceZip
protected function traceZip($archive, $tempPath) { if (!$archive = $this->extractZip($archive, $tempPath, true)) return array(false, null); //Check module has requires file if (!$this->checkRequires($tempPath)) return array(false, null); $moduleName = $this->def($tempPath, 'name', true); if ($this->moduleExists($moduleName)) return array($this->update($tempPath, $moduleName), $moduleName); else return array($this->install($tempPath, $moduleName), $moduleName); }
php
protected function traceZip($archive, $tempPath) { if (!$archive = $this->extractZip($archive, $tempPath, true)) return array(false, null); //Check module has requires file if (!$this->checkRequires($tempPath)) return array(false, null); $moduleName = $this->def($tempPath, 'name', true); if ($this->moduleExists($moduleName)) return array($this->update($tempPath, $moduleName), $moduleName); else return array($this->install($tempPath, $moduleName), $moduleName); }
[ "protected", "function", "traceZip", "(", "$", "archive", ",", "$", "tempPath", ")", "{", "if", "(", "!", "$", "archive", "=", "$", "this", "->", "extractZip", "(", "$", "archive", ",", "$", "tempPath", ",", "true", ")", ")", "return", "array", "(", "false", ",", "null", ")", ";", "//Check module has requires file", "if", "(", "!", "$", "this", "->", "checkRequires", "(", "$", "tempPath", ")", ")", "return", "array", "(", "false", ",", "null", ")", ";", "$", "moduleName", "=", "$", "this", "->", "def", "(", "$", "tempPath", ",", "'name'", ",", "true", ")", ";", "if", "(", "$", "this", "->", "moduleExists", "(", "$", "moduleName", ")", ")", "return", "array", "(", "$", "this", "->", "update", "(", "$", "tempPath", ",", "$", "moduleName", ")", ",", "$", "moduleName", ")", ";", "else", "return", "array", "(", "$", "this", "->", "install", "(", "$", "tempPath", ",", "$", "moduleName", ")", ",", "$", "moduleName", ")", ";", "}" ]
Step by Step to install or update a module zip @param string $archive path of zip @param string $tempPath path of extract zip @return array array(bool $result, string $moduleName)
[ "Step", "by", "Step", "to", "install", "or", "update", "a", "module", "zip" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L536-L552
24,908
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.checkRequires
protected function checkRequires($modulePath) { $requires = $this->getConfig('requires', array()); foreach($requires as $key => $value) { if (is_array($value)) { if (!$this->files->exists($modulePath.'/'.$key)) { $this->errors->add($this->configFile, $this->configFile.' is corrupted.'); return false; } $jsonFile = json_decode($this->app['files']->get($modulePath.'/'.$key), true); foreach($value as $key) { if (is_array($jsonFile)) { if (!array_key_exists($key, $jsonFile) || empty($jsonFile[$key])) { $this->errors->add('module_requires', 'This module has not requires files'); return false; } } else { $this->errors->add($this->configFile, $this->configFile.' is corrupted.'); return false; } } } else { if (!$this->files->exists($modulePath.'/'.$value)) { $this->errors->add('module_requires', 'This module has not requires files'); return false; } } } return true; }
php
protected function checkRequires($modulePath) { $requires = $this->getConfig('requires', array()); foreach($requires as $key => $value) { if (is_array($value)) { if (!$this->files->exists($modulePath.'/'.$key)) { $this->errors->add($this->configFile, $this->configFile.' is corrupted.'); return false; } $jsonFile = json_decode($this->app['files']->get($modulePath.'/'.$key), true); foreach($value as $key) { if (is_array($jsonFile)) { if (!array_key_exists($key, $jsonFile) || empty($jsonFile[$key])) { $this->errors->add('module_requires', 'This module has not requires files'); return false; } } else { $this->errors->add($this->configFile, $this->configFile.' is corrupted.'); return false; } } } else { if (!$this->files->exists($modulePath.'/'.$value)) { $this->errors->add('module_requires', 'This module has not requires files'); return false; } } } return true; }
[ "protected", "function", "checkRequires", "(", "$", "modulePath", ")", "{", "$", "requires", "=", "$", "this", "->", "getConfig", "(", "'requires'", ",", "array", "(", ")", ")", ";", "foreach", "(", "$", "requires", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "if", "(", "!", "$", "this", "->", "files", "->", "exists", "(", "$", "modulePath", ".", "'/'", ".", "$", "key", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "$", "this", "->", "configFile", ",", "$", "this", "->", "configFile", ".", "' is corrupted.'", ")", ";", "return", "false", ";", "}", "$", "jsonFile", "=", "json_decode", "(", "$", "this", "->", "app", "[", "'files'", "]", "->", "get", "(", "$", "modulePath", ".", "'/'", ".", "$", "key", ")", ",", "true", ")", ";", "foreach", "(", "$", "value", "as", "$", "key", ")", "{", "if", "(", "is_array", "(", "$", "jsonFile", ")", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "jsonFile", ")", "||", "empty", "(", "$", "jsonFile", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "'module_requires'", ",", "'This module has not requires files'", ")", ";", "return", "false", ";", "}", "}", "else", "{", "$", "this", "->", "errors", "->", "add", "(", "$", "this", "->", "configFile", ",", "$", "this", "->", "configFile", ".", "' is corrupted.'", ")", ";", "return", "false", ";", "}", "}", "}", "else", "{", "if", "(", "!", "$", "this", "->", "files", "->", "exists", "(", "$", "modulePath", ".", "'/'", ".", "$", "value", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "'module_requires'", ",", "'This module has not requires files'", ")", ";", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Check module has required file @param string $modulePath @return bool
[ "Check", "module", "has", "required", "file" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L560-L601
24,909
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.checkModuleDepends
public function checkModuleDepends($moduleName, Version $curVersion, Version $newVersion = null) { $modules = $this->getListAllModules(); $clean = true; $i = 0; foreach ($modules as $module) { $depends = $this->def($module['name'], 'require', false, array()); if (!is_array($depends)) { $this->errors->add($this->configFile, $this->configFile.' is corrupted.'); return false; } if (array_key_exists($moduleName, $depends)) { if (!is_null($newVersion)) //Check for update a module { $dependVersion = new Version($depends[$moduleName]); if (!$newVersion->isPartOf($dependVersion)) { $clean = false; $this->errors->add("module_depend_$i", "Can not update $moduleName, ".$module['name'].' Depend to version '.$dependVersion->getOriginalVersion().' of '.$moduleName); } } else //Check for delete a module { $clean = false; $this->errors->add("module_depend_$i", "Can not uninstall $moduleName, ".$module['name'].' Depend this module.'); } } $i++; } if (!$clean) return true; return false; }
php
public function checkModuleDepends($moduleName, Version $curVersion, Version $newVersion = null) { $modules = $this->getListAllModules(); $clean = true; $i = 0; foreach ($modules as $module) { $depends = $this->def($module['name'], 'require', false, array()); if (!is_array($depends)) { $this->errors->add($this->configFile, $this->configFile.' is corrupted.'); return false; } if (array_key_exists($moduleName, $depends)) { if (!is_null($newVersion)) //Check for update a module { $dependVersion = new Version($depends[$moduleName]); if (!$newVersion->isPartOf($dependVersion)) { $clean = false; $this->errors->add("module_depend_$i", "Can not update $moduleName, ".$module['name'].' Depend to version '.$dependVersion->getOriginalVersion().' of '.$moduleName); } } else //Check for delete a module { $clean = false; $this->errors->add("module_depend_$i", "Can not uninstall $moduleName, ".$module['name'].' Depend this module.'); } } $i++; } if (!$clean) return true; return false; }
[ "public", "function", "checkModuleDepends", "(", "$", "moduleName", ",", "Version", "$", "curVersion", ",", "Version", "$", "newVersion", "=", "null", ")", "{", "$", "modules", "=", "$", "this", "->", "getListAllModules", "(", ")", ";", "$", "clean", "=", "true", ";", "$", "i", "=", "0", ";", "foreach", "(", "$", "modules", "as", "$", "module", ")", "{", "$", "depends", "=", "$", "this", "->", "def", "(", "$", "module", "[", "'name'", "]", ",", "'require'", ",", "false", ",", "array", "(", ")", ")", ";", "if", "(", "!", "is_array", "(", "$", "depends", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "$", "this", "->", "configFile", ",", "$", "this", "->", "configFile", ".", "' is corrupted.'", ")", ";", "return", "false", ";", "}", "if", "(", "array_key_exists", "(", "$", "moduleName", ",", "$", "depends", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "newVersion", ")", ")", "//Check for update a module", "{", "$", "dependVersion", "=", "new", "Version", "(", "$", "depends", "[", "$", "moduleName", "]", ")", ";", "if", "(", "!", "$", "newVersion", "->", "isPartOf", "(", "$", "dependVersion", ")", ")", "{", "$", "clean", "=", "false", ";", "$", "this", "->", "errors", "->", "add", "(", "\"module_depend_$i\"", ",", "\"Can not update $moduleName, \"", ".", "$", "module", "[", "'name'", "]", ".", "' Depend to version '", ".", "$", "dependVersion", "->", "getOriginalVersion", "(", ")", ".", "' of '", ".", "$", "moduleName", ")", ";", "}", "}", "else", "//Check for delete a module", "{", "$", "clean", "=", "false", ";", "$", "this", "->", "errors", "->", "add", "(", "\"module_depend_$i\"", ",", "\"Can not uninstall $moduleName, \"", ".", "$", "module", "[", "'name'", "]", ".", "' Depend this module.'", ")", ";", "}", "}", "$", "i", "++", ";", "}", "if", "(", "!", "$", "clean", ")", "return", "true", ";", "return", "false", ";", "}" ]
Check others modules depends to this module or not, when update or delete module @param string $moduleName @param Chee\Version\Version $curVersion for update required @param Chee\Version\Version $newVersion for delete not required @return bool
[ "Check", "others", "modules", "depends", "to", "this", "module", "or", "not", "when", "update", "or", "delete", "module" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L671-L709
24,910
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.extractZip
protected function extractZip($archive, $target, $deleteSource = false) { if (!$this->files->exists($target)) { $this->files->makeDirectory($target, 0777, true); } $archive = new Pclzip($archive); if ($archive->extract(PCLZIP_OPT_PATH, $target) == 0) { $this->errors->add('extract_zip', $archive->error_string); return false; } if ($deleteSource) $this->files->delete($archive->zipname); return $archive; }
php
protected function extractZip($archive, $target, $deleteSource = false) { if (!$this->files->exists($target)) { $this->files->makeDirectory($target, 0777, true); } $archive = new Pclzip($archive); if ($archive->extract(PCLZIP_OPT_PATH, $target) == 0) { $this->errors->add('extract_zip', $archive->error_string); return false; } if ($deleteSource) $this->files->delete($archive->zipname); return $archive; }
[ "protected", "function", "extractZip", "(", "$", "archive", ",", "$", "target", ",", "$", "deleteSource", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "files", "->", "exists", "(", "$", "target", ")", ")", "{", "$", "this", "->", "files", "->", "makeDirectory", "(", "$", "target", ",", "0777", ",", "true", ")", ";", "}", "$", "archive", "=", "new", "Pclzip", "(", "$", "archive", ")", ";", "if", "(", "$", "archive", "->", "extract", "(", "PCLZIP_OPT_PATH", ",", "$", "target", ")", "==", "0", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "'extract_zip'", ",", "$", "archive", "->", "error_string", ")", ";", "return", "false", ";", "}", "if", "(", "$", "deleteSource", ")", "$", "this", "->", "files", "->", "delete", "(", "$", "archive", "->", "zipname", ")", ";", "return", "$", "archive", ";", "}" ]
Extract zip file @param string $archive path of archive @param string $target @param bool $deleteSource @return Chee\Pclzip\Pclzip|false
[ "Extract", "zip", "file" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L719-L738
24,911
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.moduleExists
public function moduleExists($moduleName, $returnId = false) { $module = $this->findOrFalse('module_name', $moduleName); if ($module) { if ($returnId) return $module->module_id; else return true; } return false; }
php
public function moduleExists($moduleName, $returnId = false) { $module = $this->findOrFalse('module_name', $moduleName); if ($module) { if ($returnId) return $module->module_id; else return true; } return false; }
[ "public", "function", "moduleExists", "(", "$", "moduleName", ",", "$", "returnId", "=", "false", ")", "{", "$", "module", "=", "$", "this", "->", "findOrFalse", "(", "'module_name'", ",", "$", "moduleName", ")", ";", "if", "(", "$", "module", ")", "{", "if", "(", "$", "returnId", ")", "return", "$", "module", "->", "module_id", ";", "else", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if module exists @param string $moduleName @param bool $returnId @return bool
[ "Check", "if", "module", "exists" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L747-L759
24,912
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.findOrFalse
public function findOrFalse($field, $name) { $module = ModuleModel::where($field, $name)->first(); return !is_null($module) ? $module : false; }
php
public function findOrFalse($field, $name) { $module = ModuleModel::where($field, $name)->first(); return !is_null($module) ? $module : false; }
[ "public", "function", "findOrFalse", "(", "$", "field", ",", "$", "name", ")", "{", "$", "module", "=", "ModuleModel", "::", "where", "(", "$", "field", ",", "$", "name", ")", "->", "first", "(", ")", ";", "return", "!", "is_null", "(", "$", "module", ")", "?", "$", "module", ":", "false", ";", "}" ]
Find one record from model @param string $field @param string $name @return object|false
[ "Find", "one", "record", "from", "model" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L768-L771
24,913
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.getModuleDirectory
public function getModuleDirectory($moduleName) { if ($this->files->exists($this->path.'/'.$moduleName)) return $this->path.'/'.$moduleName; else return false; }
php
public function getModuleDirectory($moduleName) { if ($this->files->exists($this->path.'/'.$moduleName)) return $this->path.'/'.$moduleName; else return false; }
[ "public", "function", "getModuleDirectory", "(", "$", "moduleName", ")", "{", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "this", "->", "path", ".", "'/'", ".", "$", "moduleName", ")", ")", "return", "$", "this", "->", "path", ".", "'/'", ".", "$", "moduleName", ";", "else", "return", "false", ";", "}" ]
Get path of specific module @param string $moduleName name of module @return string|false
[ "Get", "path", "of", "specific", "module" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L779-L786
24,914
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.getAssetDirectory
public function getAssetDirectory($moduleName = null) { if ($moduleName) return public_path().'/'.$this->getConfig('assets').'/'.$moduleName; return public_path().'/'.$this->getConfig('assets').'/'; }
php
public function getAssetDirectory($moduleName = null) { if ($moduleName) return public_path().'/'.$this->getConfig('assets').'/'.$moduleName; return public_path().'/'.$this->getConfig('assets').'/'; }
[ "public", "function", "getAssetDirectory", "(", "$", "moduleName", "=", "null", ")", "{", "if", "(", "$", "moduleName", ")", "return", "public_path", "(", ")", ".", "'/'", ".", "$", "this", "->", "getConfig", "(", "'assets'", ")", ".", "'/'", ".", "$", "moduleName", ";", "return", "public_path", "(", ")", ".", "'/'", ".", "$", "this", "->", "getConfig", "(", "'assets'", ")", ".", "'/'", ";", "}" ]
Get assets path of speciic module @param string|null $moduleName name of module @return string
[ "Get", "assets", "path", "of", "speciic", "module" ]
ccfff426f4ecf8f13687f5acd49246ba4997deee
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L794-L800
24,915
zapheus/zapheus
src/Http/Message/RequestFactory.php
RequestFactory.make
public function make() { return new Request($this->method, $this->target, $this->server, $this->cookies, $this->data, $this->files, $this->queries, $this->attributes, $this->uri, $this->headers, $this->stream, $this->version); }
php
public function make() { return new Request($this->method, $this->target, $this->server, $this->cookies, $this->data, $this->files, $this->queries, $this->attributes, $this->uri, $this->headers, $this->stream, $this->version); }
[ "public", "function", "make", "(", ")", "{", "return", "new", "Request", "(", "$", "this", "->", "method", ",", "$", "this", "->", "target", ",", "$", "this", "->", "server", ",", "$", "this", "->", "cookies", ",", "$", "this", "->", "data", ",", "$", "this", "->", "files", ",", "$", "this", "->", "queries", ",", "$", "this", "->", "attributes", ",", "$", "this", "->", "uri", ",", "$", "this", "->", "headers", ",", "$", "this", "->", "stream", ",", "$", "this", "->", "version", ")", ";", "}" ]
Creates the request instance. @return \Zapheus\Http\Message\RequestInterface
[ "Creates", "the", "request", "instance", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Http/Message/RequestFactory.php#L176-L179
24,916
bheisig/cli
src/Log.php
Log.flush
protected function flush($message) { switch ($this->output) { case self::PRINT_AS_OUTPUT: IO::out($message); break; case self::PRINT_AS_MESSAGE: IO::err($message); break; } }
php
protected function flush($message) { switch ($this->output) { case self::PRINT_AS_OUTPUT: IO::out($message); break; case self::PRINT_AS_MESSAGE: IO::err($message); break; } }
[ "protected", "function", "flush", "(", "$", "message", ")", "{", "switch", "(", "$", "this", "->", "output", ")", "{", "case", "self", "::", "PRINT_AS_OUTPUT", ":", "IO", "::", "out", "(", "$", "message", ")", ";", "break", ";", "case", "self", "::", "PRINT_AS_MESSAGE", ":", "IO", "::", "err", "(", "$", "message", ")", ";", "break", ";", "}", "}" ]
Print message to STDOUT or STDERR @param string $message Message
[ "Print", "message", "to", "STDOUT", "or", "STDERR" ]
ee77266e173335950357899cdfe86b43c00a6776
https://github.com/bheisig/cli/blob/ee77266e173335950357899cdfe86b43c00a6776/src/Log.php#L412-L421
24,917
wb-crowdfusion/crowdfusion
system/core/classes/libraries/database/DTO.php
DTO.setOrderBy
public function setOrderBy($field, $direction = null) { if (empty($field)) return $this; if (count($order = explode(' ', $field)) == 2) { $field = $order[0]; $direction = $order[1]; } $this->orderBy[$field] = empty($direction) ? 'ASC' : $direction; return $this; }
php
public function setOrderBy($field, $direction = null) { if (empty($field)) return $this; if (count($order = explode(' ', $field)) == 2) { $field = $order[0]; $direction = $order[1]; } $this->orderBy[$field] = empty($direction) ? 'ASC' : $direction; return $this; }
[ "public", "function", "setOrderBy", "(", "$", "field", ",", "$", "direction", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "field", ")", ")", "return", "$", "this", ";", "if", "(", "count", "(", "$", "order", "=", "explode", "(", "' '", ",", "$", "field", ")", ")", "==", "2", ")", "{", "$", "field", "=", "$", "order", "[", "0", "]", ";", "$", "direction", "=", "$", "order", "[", "1", "]", ";", "}", "$", "this", "->", "orderBy", "[", "$", "field", "]", "=", "empty", "(", "$", "direction", ")", "?", "'ASC'", ":", "$", "direction", ";", "return", "$", "this", ";", "}" ]
Sets the specified orderBy @param string $field The name of the field @param string $direction The direction to sort. Can be ASC or DESC (default to ASC if not specified) @return DTO $this
[ "Sets", "the", "specified", "orderBy" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L157-L168
24,918
wb-crowdfusion/crowdfusion
system/core/classes/libraries/database/DTO.php
DTO.getOrderBy
public function getOrderBy($field) { return array_key_exists($field, $this->orderBy) ? $this->orderBy[$field] : null; }
php
public function getOrderBy($field) { return array_key_exists($field, $this->orderBy) ? $this->orderBy[$field] : null; }
[ "public", "function", "getOrderBy", "(", "$", "field", ")", "{", "return", "array_key_exists", "(", "$", "field", ",", "$", "this", "->", "orderBy", ")", "?", "$", "this", "->", "orderBy", "[", "$", "field", "]", ":", "null", ";", "}" ]
Returns the OrderBy direction for the field specified @param string $field the field name to lookup @return string Returns the direction (ASC or DESC) for the field specified, or null if it doesn't exist.
[ "Returns", "the", "OrderBy", "direction", "for", "the", "field", "specified" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L177-L182
24,919
wb-crowdfusion/crowdfusion
system/core/classes/libraries/database/DTO.php
DTO.setOffset
public function setOffset($offset) { if ($offset >= PHP_INT_MAX) { $offset = false; } $this->offset = $offset; return $this; }
php
public function setOffset($offset) { if ($offset >= PHP_INT_MAX) { $offset = false; } $this->offset = $offset; return $this; }
[ "public", "function", "setOffset", "(", "$", "offset", ")", "{", "if", "(", "$", "offset", ">=", "PHP_INT_MAX", ")", "{", "$", "offset", "=", "false", ";", "}", "$", "this", "->", "offset", "=", "$", "offset", ";", "return", "$", "this", ";", "}" ]
Sets the offset if the offset is greater than the PHP_INT_MAX then the offset will be set to false @param integer $offset The offset @return DTO $this
[ "Sets", "the", "offset" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L244-L252
24,920
wb-crowdfusion/crowdfusion
system/core/classes/libraries/database/DTO.php
DTO.getResultsAsObjects
public function getResultsAsObjects($classname) { $new = array(); foreach ((array) $this->results as $result) { if (is_array($result)) $new[] = new $classname($result); else $new[] = $result; } return $new; }
php
public function getResultsAsObjects($classname) { $new = array(); foreach ((array) $this->results as $result) { if (is_array($result)) $new[] = new $classname($result); else $new[] = $result; } return $new; }
[ "public", "function", "getResultsAsObjects", "(", "$", "classname", ")", "{", "$", "new", "=", "array", "(", ")", ";", "foreach", "(", "(", "array", ")", "$", "this", "->", "results", "as", "$", "result", ")", "{", "if", "(", "is_array", "(", "$", "result", ")", ")", "$", "new", "[", "]", "=", "new", "$", "classname", "(", "$", "result", ")", ";", "else", "$", "new", "[", "]", "=", "$", "result", ";", "}", "return", "$", "new", ";", "}" ]
Returns all the results as objects of the class specified @param string $classname The name of the class to return the objects as @return array An array of the results converted into the new class
[ "Returns", "all", "the", "results", "as", "objects", "of", "the", "class", "specified" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L369-L379
24,921
wb-crowdfusion/crowdfusion
system/core/classes/libraries/database/DTO.php
DTO.getResultsAsArray
public function getResultsAsArray() { $new = array(); foreach ((array) $this->results as $result) { if ($result instanceof Object) $new[] = $result->toArray(); else if (is_array($result)) return $this->results; else throw new Exception('Cannot convert to array: '.ClassUtils::getQualifiedType($result)); } return $new; }
php
public function getResultsAsArray() { $new = array(); foreach ((array) $this->results as $result) { if ($result instanceof Object) $new[] = $result->toArray(); else if (is_array($result)) return $this->results; else throw new Exception('Cannot convert to array: '.ClassUtils::getQualifiedType($result)); } return $new; }
[ "public", "function", "getResultsAsArray", "(", ")", "{", "$", "new", "=", "array", "(", ")", ";", "foreach", "(", "(", "array", ")", "$", "this", "->", "results", "as", "$", "result", ")", "{", "if", "(", "$", "result", "instanceof", "Object", ")", "$", "new", "[", "]", "=", "$", "result", "->", "toArray", "(", ")", ";", "else", "if", "(", "is_array", "(", "$", "result", ")", ")", "return", "$", "this", "->", "results", ";", "else", "throw", "new", "Exception", "(", "'Cannot convert to array: '", ".", "ClassUtils", "::", "getQualifiedType", "(", "$", "result", ")", ")", ";", "}", "return", "$", "new", ";", "}" ]
Returns all results as an array @return array an Array of all results, each one being an array
[ "Returns", "all", "results", "as", "an", "array" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L386-L398
24,922
wb-crowdfusion/crowdfusion
system/core/classes/libraries/database/DTO.php
DTO.getColumnOfResults
public function getColumnOfResults($col) { $new = array(); foreach ((array)$this->results as $result) { if ($result instanceof Object) $new[] = $result->$col; else if (is_array($result)) $new[] = $result[$col]; } return $new; }
php
public function getColumnOfResults($col) { $new = array(); foreach ((array)$this->results as $result) { if ($result instanceof Object) $new[] = $result->$col; else if (is_array($result)) $new[] = $result[$col]; } return $new; }
[ "public", "function", "getColumnOfResults", "(", "$", "col", ")", "{", "$", "new", "=", "array", "(", ")", ";", "foreach", "(", "(", "array", ")", "$", "this", "->", "results", "as", "$", "result", ")", "{", "if", "(", "$", "result", "instanceof", "Object", ")", "$", "new", "[", "]", "=", "$", "result", "->", "$", "col", ";", "else", "if", "(", "is_array", "(", "$", "result", ")", ")", "$", "new", "[", "]", "=", "$", "result", "[", "$", "col", "]", ";", "}", "return", "$", "new", ";", "}" ]
Returns an array containing the value stored in the column specifed for each result @param string $col The column name to fetch @return array
[ "Returns", "an", "array", "containing", "the", "value", "stored", "in", "the", "column", "specifed", "for", "each", "result" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L407-L417
24,923
wb-crowdfusion/crowdfusion
system/core/classes/libraries/database/DTO.php
DTO.isRetrieveAsObjects
public function isRetrieveAsObjects($val = null) { if (!is_null($val)) { $this->retrieveAsObjects = $val; return $this; } return $this->retrieveAsObjects == true; }
php
public function isRetrieveAsObjects($val = null) { if (!is_null($val)) { $this->retrieveAsObjects = $val; return $this; } return $this->retrieveAsObjects == true; }
[ "public", "function", "isRetrieveAsObjects", "(", "$", "val", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "val", ")", ")", "{", "$", "this", "->", "retrieveAsObjects", "=", "$", "val", ";", "return", "$", "this", ";", "}", "return", "$", "this", "->", "retrieveAsObjects", "==", "true", ";", "}" ]
Determines if the DTO will retrieve the results as objects. Also acts as a setter for retrieve as objects @param boolean $val If set to true or false, then it will retrieve results as objects or arrays respectively. @return mixed Will return DTO $this if $val is specified, otherwise, returns boolean that answers the question "Retrieve as objects?"
[ "Determines", "if", "the", "DTO", "will", "retrieve", "the", "results", "as", "objects", ".", "Also", "acts", "as", "a", "setter", "for", "retrieve", "as", "objects" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L450-L458
24,924
wb-crowdfusion/crowdfusion
system/core/classes/libraries/database/DTO.php
DTO.isRetrieveTotalRecords
public function isRetrieveTotalRecords($val = null) { if (!is_null($val)) { $this->retrieveTotalRecords = $val; return $this; } return $this->retrieveTotalRecords; }
php
public function isRetrieveTotalRecords($val = null) { if (!is_null($val)) { $this->retrieveTotalRecords = $val; return $this; } return $this->retrieveTotalRecords; }
[ "public", "function", "isRetrieveTotalRecords", "(", "$", "val", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "val", ")", ")", "{", "$", "this", "->", "retrieveTotalRecords", "=", "$", "val", ";", "return", "$", "this", ";", "}", "return", "$", "this", "->", "retrieveTotalRecords", ";", "}" ]
Determines if the DTO will retrieve a count of total records for the results Also acts as a setter for retrieve total records @param boolean $val If set to true, then it will retrieve a count of total records for the results. If unspecified, the function will return the current value for retrieveTotalRecords @return mixed Will return DTO $this if $val is specified, otherwise, returns boolean that answers the question "Retrieve a count of total records?"
[ "Determines", "if", "the", "DTO", "will", "retrieve", "a", "count", "of", "total", "records", "for", "the", "results", "Also", "acts", "as", "a", "setter", "for", "retrieve", "total", "records" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L470-L478
24,925
siriusSupreme/sirius-broadcast
src/Broadcasters/Broadcaster.php
Broadcaster.extractAuthParameters
protected function extractAuthParameters($pattern, $channel, $callback) { $callbackParameters = (new ReflectionFunction($callback))->getParameters(); return collect($this->extractChannelKeys($pattern, $channel))->reject(function ($value, $key) { return is_numeric($key); })->map(function ($value, $key) use ($callbackParameters) { return $this->resolveBinding($key, $value, $callbackParameters); })->values()->all(); }
php
protected function extractAuthParameters($pattern, $channel, $callback) { $callbackParameters = (new ReflectionFunction($callback))->getParameters(); return collect($this->extractChannelKeys($pattern, $channel))->reject(function ($value, $key) { return is_numeric($key); })->map(function ($value, $key) use ($callbackParameters) { return $this->resolveBinding($key, $value, $callbackParameters); })->values()->all(); }
[ "protected", "function", "extractAuthParameters", "(", "$", "pattern", ",", "$", "channel", ",", "$", "callback", ")", "{", "$", "callbackParameters", "=", "(", "new", "ReflectionFunction", "(", "$", "callback", ")", ")", "->", "getParameters", "(", ")", ";", "return", "collect", "(", "$", "this", "->", "extractChannelKeys", "(", "$", "pattern", ",", "$", "channel", ")", ")", "->", "reject", "(", "function", "(", "$", "value", ",", "$", "key", ")", "{", "return", "is_numeric", "(", "$", "key", ")", ";", "}", ")", "->", "map", "(", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "$", "callbackParameters", ")", "{", "return", "$", "this", "->", "resolveBinding", "(", "$", "key", ",", "$", "value", ",", "$", "callbackParameters", ")", ";", "}", ")", "->", "values", "(", ")", "->", "all", "(", ")", ";", "}" ]
Extract the parameters from the given pattern and channel. @param string $pattern @param string $channel @param callable $callback @return array
[ "Extract", "the", "parameters", "from", "the", "given", "pattern", "and", "channel", "." ]
d98f47973631dbb2da0296fd7066d1a70e9b30f7
https://github.com/siriusSupreme/sirius-broadcast/blob/d98f47973631dbb2da0296fd7066d1a70e9b30f7/src/Broadcasters/Broadcaster.php#L67-L76
24,926
railken/lem
src/Attributes/BaseAttribute.php
BaseAttribute.bootPermissions
public function bootPermissions() { foreach ($this->permissions as $token => $permission) { $this->permissions[$token] = sprintf($permission, Str::kebab($this->getManager()->getName()), Str::kebab($this->getName())); } }
php
public function bootPermissions() { foreach ($this->permissions as $token => $permission) { $this->permissions[$token] = sprintf($permission, Str::kebab($this->getManager()->getName()), Str::kebab($this->getName())); } }
[ "public", "function", "bootPermissions", "(", ")", "{", "foreach", "(", "$", "this", "->", "permissions", "as", "$", "token", "=>", "$", "permission", ")", "{", "$", "this", "->", "permissions", "[", "$", "token", "]", "=", "sprintf", "(", "$", "permission", ",", "Str", "::", "kebab", "(", "$", "this", "->", "getManager", "(", ")", "->", "getName", "(", ")", ")", ",", "Str", "::", "kebab", "(", "$", "this", "->", "getName", "(", ")", ")", ")", ";", "}", "}" ]
Boot permissions.
[ "Boot", "permissions", "." ]
cff1efcd090a9504b2faf5594121885786dea67a
https://github.com/railken/lem/blob/cff1efcd090a9504b2faf5594121885786dea67a/src/Attributes/BaseAttribute.php#L115-L120
24,927
railken/lem
src/Attributes/BaseAttribute.php
BaseAttribute.newException
public function newException(string $code, $value): Exception { $exception = $this->getException($code); return new $exception( strtoupper(Str::kebab($this->getManager()->getName())), strtoupper(Str::kebab($this->getName())), $value ); }
php
public function newException(string $code, $value): Exception { $exception = $this->getException($code); return new $exception( strtoupper(Str::kebab($this->getManager()->getName())), strtoupper(Str::kebab($this->getName())), $value ); }
[ "public", "function", "newException", "(", "string", "$", "code", ",", "$", "value", ")", ":", "Exception", "{", "$", "exception", "=", "$", "this", "->", "getException", "(", "$", "code", ")", ";", "return", "new", "$", "exception", "(", "strtoupper", "(", "Str", "::", "kebab", "(", "$", "this", "->", "getManager", "(", ")", "->", "getName", "(", ")", ")", ")", ",", "strtoupper", "(", "Str", "::", "kebab", "(", "$", "this", "->", "getName", "(", ")", ")", ")", ",", "$", "value", ")", ";", "}" ]
Create a new instance of exception. @param string $code @param mixed $value @return \Exception
[ "Create", "a", "new", "instance", "of", "exception", "." ]
cff1efcd090a9504b2faf5594121885786dea67a
https://github.com/railken/lem/blob/cff1efcd090a9504b2faf5594121885786dea67a/src/Attributes/BaseAttribute.php#L130-L139
24,928
ekyna/MediaBundle
Install/MediaInstaller.php
MediaInstaller.createRootFolders
private function createRootFolders(OutputInterface $output) { $em = $this->container->get('doctrine.orm.default_entity_manager'); $repository = $this->container->get('ekyna_media.folder.repository'); $name = FolderInterface::ROOT; $output->write(sprintf( '- <comment>%s</comment> %s ', ucfirst($name), str_pad('.', 44 - mb_strlen($name), '.', STR_PAD_LEFT) )); if (null !== $folder = $repository->findRoot()) { $output->writeln('already exists.'); } else { $folder = new Folder(); $folder->setName($name); $em->persist($folder); $em->flush(); $output->writeln('created.'); } }
php
private function createRootFolders(OutputInterface $output) { $em = $this->container->get('doctrine.orm.default_entity_manager'); $repository = $this->container->get('ekyna_media.folder.repository'); $name = FolderInterface::ROOT; $output->write(sprintf( '- <comment>%s</comment> %s ', ucfirst($name), str_pad('.', 44 - mb_strlen($name), '.', STR_PAD_LEFT) )); if (null !== $folder = $repository->findRoot()) { $output->writeln('already exists.'); } else { $folder = new Folder(); $folder->setName($name); $em->persist($folder); $em->flush(); $output->writeln('created.'); } }
[ "private", "function", "createRootFolders", "(", "OutputInterface", "$", "output", ")", "{", "$", "em", "=", "$", "this", "->", "container", "->", "get", "(", "'doctrine.orm.default_entity_manager'", ")", ";", "$", "repository", "=", "$", "this", "->", "container", "->", "get", "(", "'ekyna_media.folder.repository'", ")", ";", "$", "name", "=", "FolderInterface", "::", "ROOT", ";", "$", "output", "->", "write", "(", "sprintf", "(", "'- <comment>%s</comment> %s '", ",", "ucfirst", "(", "$", "name", ")", ",", "str_pad", "(", "'.'", ",", "44", "-", "mb_strlen", "(", "$", "name", ")", ",", "'.'", ",", "STR_PAD_LEFT", ")", ")", ")", ";", "if", "(", "null", "!==", "$", "folder", "=", "$", "repository", "->", "findRoot", "(", ")", ")", "{", "$", "output", "->", "writeln", "(", "'already exists.'", ")", ";", "}", "else", "{", "$", "folder", "=", "new", "Folder", "(", ")", ";", "$", "folder", "->", "setName", "(", "$", "name", ")", ";", "$", "em", "->", "persist", "(", "$", "folder", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "output", "->", "writeln", "(", "'created.'", ")", ";", "}", "}" ]
Creates root folders. @param OutputInterface $output
[ "Creates", "root", "folders", "." ]
512cf86c801a130a9f17eba8b48d646d23acdbab
https://github.com/ekyna/MediaBundle/blob/512cf86c801a130a9f17eba8b48d646d23acdbab/Install/MediaInstaller.php#L51-L74
24,929
sil-project/VarietyBundle
src/Entity/PlantCategory.php
PlantCategory.addVariety
public function addVariety(\Librinfo\VarietiesBundle\Entity\Variety $variety) { $this->varieties[] = $variety; return $this; }
php
public function addVariety(\Librinfo\VarietiesBundle\Entity\Variety $variety) { $this->varieties[] = $variety; return $this; }
[ "public", "function", "addVariety", "(", "\\", "Librinfo", "\\", "VarietiesBundle", "\\", "Entity", "\\", "Variety", "$", "variety", ")", "{", "$", "this", "->", "varieties", "[", "]", "=", "$", "variety", ";", "return", "$", "this", ";", "}" ]
Add variety. @param \Librinfo\VarietiesBundle\Entity\Variety $variety @return PlantCategory
[ "Add", "variety", "." ]
e9508ce13a4bb277d10bdcd925fdb84bc01f453f
https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/PlantCategory.php#L90-L95
24,930
sil-project/VarietyBundle
src/Entity/PlantCategory.php
PlantCategory.removeVariety
public function removeVariety(\Librinfo\VarietiesBundle\Entity\Variety $variety) { return $this->varieties->removeElement($variety); }
php
public function removeVariety(\Librinfo\VarietiesBundle\Entity\Variety $variety) { return $this->varieties->removeElement($variety); }
[ "public", "function", "removeVariety", "(", "\\", "Librinfo", "\\", "VarietiesBundle", "\\", "Entity", "\\", "Variety", "$", "variety", ")", "{", "return", "$", "this", "->", "varieties", "->", "removeElement", "(", "$", "variety", ")", ";", "}" ]
Remove variety. @param \Librinfo\VarietiesBundle\Entity\Variety $variety @return bool tRUE if this collection contained the specified element, FALSE otherwise
[ "Remove", "variety", "." ]
e9508ce13a4bb277d10bdcd925fdb84bc01f453f
https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/PlantCategory.php#L104-L107
24,931
sil-project/VarietyBundle
src/Entity/PlantCategory.php
PlantCategory.addSpecies
public function addSpecies(\Librinfo\VarietiesBundle\Entity\Species $species) { $this->species[] = $species; return $this; }
php
public function addSpecies(\Librinfo\VarietiesBundle\Entity\Species $species) { $this->species[] = $species; return $this; }
[ "public", "function", "addSpecies", "(", "\\", "Librinfo", "\\", "VarietiesBundle", "\\", "Entity", "\\", "Species", "$", "species", ")", "{", "$", "this", "->", "species", "[", "]", "=", "$", "species", ";", "return", "$", "this", ";", "}" ]
Add species. @param \Librinfo\VarietiesBundle\Entity\Species $species @return PlantCategory
[ "Add", "species", "." ]
e9508ce13a4bb277d10bdcd925fdb84bc01f453f
https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/PlantCategory.php#L126-L131
24,932
DzikuVx/phpCache
src/File.php
File.synchronize
function synchronize() { $tCounter = 0; if ($this->changed) { $tFile = fopen ( $this->fileName, 'a' ); while ( ! flock ( $tFile, LOCK_EX ) ) { usleep ( 5 ); $tCounter ++; if ($tCounter == 100) { return false; } } $tContent = serialize ( $this->elements ); ftruncate ( $tFile, 0 ); if ($this->useZip) { $tContent = gzcompress ( $tContent ); } fputs ( $tFile, $tContent ); flock ( $tFile, LOCK_UN ); fclose ( $tFile ); return true; } return true; }
php
function synchronize() { $tCounter = 0; if ($this->changed) { $tFile = fopen ( $this->fileName, 'a' ); while ( ! flock ( $tFile, LOCK_EX ) ) { usleep ( 5 ); $tCounter ++; if ($tCounter == 100) { return false; } } $tContent = serialize ( $this->elements ); ftruncate ( $tFile, 0 ); if ($this->useZip) { $tContent = gzcompress ( $tContent ); } fputs ( $tFile, $tContent ); flock ( $tFile, LOCK_UN ); fclose ( $tFile ); return true; } return true; }
[ "function", "synchronize", "(", ")", "{", "$", "tCounter", "=", "0", ";", "if", "(", "$", "this", "->", "changed", ")", "{", "$", "tFile", "=", "fopen", "(", "$", "this", "->", "fileName", ",", "'a'", ")", ";", "while", "(", "!", "flock", "(", "$", "tFile", ",", "LOCK_EX", ")", ")", "{", "usleep", "(", "5", ")", ";", "$", "tCounter", "++", ";", "if", "(", "$", "tCounter", "==", "100", ")", "{", "return", "false", ";", "}", "}", "$", "tContent", "=", "serialize", "(", "$", "this", "->", "elements", ")", ";", "ftruncate", "(", "$", "tFile", ",", "0", ")", ";", "if", "(", "$", "this", "->", "useZip", ")", "{", "$", "tContent", "=", "gzcompress", "(", "$", "tContent", ")", ";", "}", "fputs", "(", "$", "tFile", ",", "$", "tContent", ")", ";", "flock", "(", "$", "tFile", ",", "LOCK_UN", ")", ";", "fclose", "(", "$", "tFile", ")", ";", "return", "true", ";", "}", "return", "true", ";", "}" ]
Synchronize cache with file @return boolean
[ "Synchronize", "cache", "with", "file" ]
faf3003795ab21913e7ebb02fb04d6a480b7786c
https://github.com/DzikuVx/phpCache/blob/faf3003795ab21913e7ebb02fb04d6a480b7786c/src/File.php#L101-L132
24,933
DzikuVx/phpCache
src/File.php
File.check
function check(CacheKey $key) { if (isset ( $this->elements [$key->getModule()] [$key->getProperty()] )) { return true; } else { return false; } }
php
function check(CacheKey $key) { if (isset ( $this->elements [$key->getModule()] [$key->getProperty()] )) { return true; } else { return false; } }
[ "function", "check", "(", "CacheKey", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "elements", "[", "$", "key", "->", "getModule", "(", ")", "]", "[", "$", "key", "->", "getProperty", "(", ")", "]", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Check is cache entry is set @param CacheKey $key @return boolean
[ "Check", "is", "cache", "entry", "is", "set" ]
faf3003795ab21913e7ebb02fb04d6a480b7786c
https://github.com/DzikuVx/phpCache/blob/faf3003795ab21913e7ebb02fb04d6a480b7786c/src/File.php#L176-L183
24,934
DzikuVx/phpCache
src/File.php
File.get
public function get(CacheKey $key) { if (!empty($this->elements[$key->getModule()] [$key->getProperty()])) { /** @noinspection PhpUndefinedMethodInspection */ $tValue = $this->elements[$key->getModule()] [$key->getProperty()]->getValue (); return $tValue; } else { return false; } }
php
public function get(CacheKey $key) { if (!empty($this->elements[$key->getModule()] [$key->getProperty()])) { /** @noinspection PhpUndefinedMethodInspection */ $tValue = $this->elements[$key->getModule()] [$key->getProperty()]->getValue (); return $tValue; } else { return false; } }
[ "public", "function", "get", "(", "CacheKey", "$", "key", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "elements", "[", "$", "key", "->", "getModule", "(", ")", "]", "[", "$", "key", "->", "getProperty", "(", ")", "]", ")", ")", "{", "/** @noinspection PhpUndefinedMethodInspection */", "$", "tValue", "=", "$", "this", "->", "elements", "[", "$", "key", "->", "getModule", "(", ")", "]", "[", "$", "key", "->", "getProperty", "(", ")", "]", "->", "getValue", "(", ")", ";", "return", "$", "tValue", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Get value from cache or null when not set @param CacheKey $key @return mixed
[ "Get", "value", "from", "cache", "or", "null", "when", "not", "set" ]
faf3003795ab21913e7ebb02fb04d6a480b7786c
https://github.com/DzikuVx/phpCache/blob/faf3003795ab21913e7ebb02fb04d6a480b7786c/src/File.php#L190-L199
24,935
DzikuVx/phpCache
src/File.php
File.clear
public function clear(CacheKey $key) { if (isset ( $this->elements [$key->getModule()] [$key->getProperty()] )) { unset ( $this->elements [$key->getModule()] [$key->getProperty()] ); $this->changed = true; } }
php
public function clear(CacheKey $key) { if (isset ( $this->elements [$key->getModule()] [$key->getProperty()] )) { unset ( $this->elements [$key->getModule()] [$key->getProperty()] ); $this->changed = true; } }
[ "public", "function", "clear", "(", "CacheKey", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "elements", "[", "$", "key", "->", "getModule", "(", ")", "]", "[", "$", "key", "->", "getProperty", "(", ")", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "elements", "[", "$", "key", "->", "getModule", "(", ")", "]", "[", "$", "key", "->", "getProperty", "(", ")", "]", ")", ";", "$", "this", "->", "changed", "=", "true", ";", "}", "}" ]
Unset cache value @param CacheKey $key
[ "Unset", "cache", "value" ]
faf3003795ab21913e7ebb02fb04d6a480b7786c
https://github.com/DzikuVx/phpCache/blob/faf3003795ab21913e7ebb02fb04d6a480b7786c/src/File.php#L205-L210
24,936
DzikuVx/phpCache
src/File.php
File.clearModule
function clearModule(CacheKey $key) { if (isset ( $this->elements [$key->getModule()] )) { unset ( $this->elements [$key->getModule()] ); $this->changed = true; } }
php
function clearModule(CacheKey $key) { if (isset ( $this->elements [$key->getModule()] )) { unset ( $this->elements [$key->getModule()] ); $this->changed = true; } }
[ "function", "clearModule", "(", "CacheKey", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "elements", "[", "$", "key", "->", "getModule", "(", ")", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "elements", "[", "$", "key", "->", "getModule", "(", ")", "]", ")", ";", "$", "this", "->", "changed", "=", "true", ";", "}", "}" ]
Clear whole module and all it's properties @param CacheKey $key @depreciated
[ "Clear", "whole", "module", "and", "all", "it", "s", "properties" ]
faf3003795ab21913e7ebb02fb04d6a480b7786c
https://github.com/DzikuVx/phpCache/blob/faf3003795ab21913e7ebb02fb04d6a480b7786c/src/File.php#L217-L224
24,937
lasallecms/lasallecms-l5-lasallecmsapi-pkg
src/FeaturedImageProcessing/FeaturedImageProcessing.php
FeaturedImageProcessing.process
public function process($data) { $featuredImageProcessing = []; // FEATURED_IMAGE_URL // is the featured image from an external URL? $useFeaturedImageUrl = $this->isFieldValueBlank($data['featured_image_url']); // if using the featured_image_url field, then validate it now if ( ($useFeaturedImageUrl) && ($this->validateFeaturedImageUrl($data['featured_image_url']) != "passed") ) { // validation failed $featuredImageProcessing['validationMessage'] = $this->validateFeaturedImageUrl($data['featured_image_url']); return $featuredImageProcessing; } // if using the featured_image_url field, and it passes the validation, then make it the Featured Image if ($useFeaturedImageUrl) { $featuredImageProcessing['validationMessage'] = "passed"; $featuredImageProcessing['featured_image'] = $data['featured_image_url']; return $featuredImageProcessing; } // FEATURED_IMAGE_UPLOAD // is the featured image from a local file upload? $useFeaturedImageUpload = $this->isFieldValueBlank($data['featured_image_upload']); // if using the featured_image_upload field, then validate it now if ( ($useFeaturedImageUpload) && ($this->validateFeaturedImageUpload($data['featured_image_upload']) != "passed") ) { // validation failed $featuredImageProcessing['validationMessage'] = $this->validateFeaturedImageUpload($data['featured_image_upload']); return $featuredImageProcessing; } // if using the featured_image_upload field, and it passes the validation, then make it the Featured Image if ($useFeaturedImageUpload) { // Move the file from the tmp folder to the image folder $this->moveFile($data['featured_image_upload']); $featuredImageProcessing['validationMessage'] = "passed"; $featuredImageProcessing['featured_image'] = $data['featured_image_upload']; return $featuredImageProcessing; } // FEATURED_IMAGE_SERVER // if using the featured_image_upload field, then validate it now if ($this->validateFeaturedImageServer($data['featured_image_server']) != "passed") { // validation failed $featuredImageProcessing['validationMessage'] = $this->validateFeaturedImageServer($data['featured_image_server']); return $featuredImageProcessing; } // if using the featured_image_upload field, and it passes the validation, then make it the Featured Image $featuredImageProcessing['validationMessage'] = "passed"; $featuredImageProcessing['featured_image'] = $data['featured_image_server']; return $featuredImageProcessing; }
php
public function process($data) { $featuredImageProcessing = []; // FEATURED_IMAGE_URL // is the featured image from an external URL? $useFeaturedImageUrl = $this->isFieldValueBlank($data['featured_image_url']); // if using the featured_image_url field, then validate it now if ( ($useFeaturedImageUrl) && ($this->validateFeaturedImageUrl($data['featured_image_url']) != "passed") ) { // validation failed $featuredImageProcessing['validationMessage'] = $this->validateFeaturedImageUrl($data['featured_image_url']); return $featuredImageProcessing; } // if using the featured_image_url field, and it passes the validation, then make it the Featured Image if ($useFeaturedImageUrl) { $featuredImageProcessing['validationMessage'] = "passed"; $featuredImageProcessing['featured_image'] = $data['featured_image_url']; return $featuredImageProcessing; } // FEATURED_IMAGE_UPLOAD // is the featured image from a local file upload? $useFeaturedImageUpload = $this->isFieldValueBlank($data['featured_image_upload']); // if using the featured_image_upload field, then validate it now if ( ($useFeaturedImageUpload) && ($this->validateFeaturedImageUpload($data['featured_image_upload']) != "passed") ) { // validation failed $featuredImageProcessing['validationMessage'] = $this->validateFeaturedImageUpload($data['featured_image_upload']); return $featuredImageProcessing; } // if using the featured_image_upload field, and it passes the validation, then make it the Featured Image if ($useFeaturedImageUpload) { // Move the file from the tmp folder to the image folder $this->moveFile($data['featured_image_upload']); $featuredImageProcessing['validationMessage'] = "passed"; $featuredImageProcessing['featured_image'] = $data['featured_image_upload']; return $featuredImageProcessing; } // FEATURED_IMAGE_SERVER // if using the featured_image_upload field, then validate it now if ($this->validateFeaturedImageServer($data['featured_image_server']) != "passed") { // validation failed $featuredImageProcessing['validationMessage'] = $this->validateFeaturedImageServer($data['featured_image_server']); return $featuredImageProcessing; } // if using the featured_image_upload field, and it passes the validation, then make it the Featured Image $featuredImageProcessing['validationMessage'] = "passed"; $featuredImageProcessing['featured_image'] = $data['featured_image_server']; return $featuredImageProcessing; }
[ "public", "function", "process", "(", "$", "data", ")", "{", "$", "featuredImageProcessing", "=", "[", "]", ";", "// FEATURED_IMAGE_URL", "// is the featured image from an external URL?", "$", "useFeaturedImageUrl", "=", "$", "this", "->", "isFieldValueBlank", "(", "$", "data", "[", "'featured_image_url'", "]", ")", ";", "// if using the featured_image_url field, then validate it now", "if", "(", "(", "$", "useFeaturedImageUrl", ")", "&&", "(", "$", "this", "->", "validateFeaturedImageUrl", "(", "$", "data", "[", "'featured_image_url'", "]", ")", "!=", "\"passed\"", ")", ")", "{", "// validation failed", "$", "featuredImageProcessing", "[", "'validationMessage'", "]", "=", "$", "this", "->", "validateFeaturedImageUrl", "(", "$", "data", "[", "'featured_image_url'", "]", ")", ";", "return", "$", "featuredImageProcessing", ";", "}", "// if using the featured_image_url field, and it passes the validation, then make it the Featured Image", "if", "(", "$", "useFeaturedImageUrl", ")", "{", "$", "featuredImageProcessing", "[", "'validationMessage'", "]", "=", "\"passed\"", ";", "$", "featuredImageProcessing", "[", "'featured_image'", "]", "=", "$", "data", "[", "'featured_image_url'", "]", ";", "return", "$", "featuredImageProcessing", ";", "}", "// FEATURED_IMAGE_UPLOAD", "// is the featured image from a local file upload?", "$", "useFeaturedImageUpload", "=", "$", "this", "->", "isFieldValueBlank", "(", "$", "data", "[", "'featured_image_upload'", "]", ")", ";", "// if using the featured_image_upload field, then validate it now", "if", "(", "(", "$", "useFeaturedImageUpload", ")", "&&", "(", "$", "this", "->", "validateFeaturedImageUpload", "(", "$", "data", "[", "'featured_image_upload'", "]", ")", "!=", "\"passed\"", ")", ")", "{", "// validation failed", "$", "featuredImageProcessing", "[", "'validationMessage'", "]", "=", "$", "this", "->", "validateFeaturedImageUpload", "(", "$", "data", "[", "'featured_image_upload'", "]", ")", ";", "return", "$", "featuredImageProcessing", ";", "}", "// if using the featured_image_upload field, and it passes the validation, then make it the Featured Image", "if", "(", "$", "useFeaturedImageUpload", ")", "{", "// Move the file from the tmp folder to the image folder", "$", "this", "->", "moveFile", "(", "$", "data", "[", "'featured_image_upload'", "]", ")", ";", "$", "featuredImageProcessing", "[", "'validationMessage'", "]", "=", "\"passed\"", ";", "$", "featuredImageProcessing", "[", "'featured_image'", "]", "=", "$", "data", "[", "'featured_image_upload'", "]", ";", "return", "$", "featuredImageProcessing", ";", "}", "// FEATURED_IMAGE_SERVER", "// if using the featured_image_upload field, then validate it now", "if", "(", "$", "this", "->", "validateFeaturedImageServer", "(", "$", "data", "[", "'featured_image_server'", "]", ")", "!=", "\"passed\"", ")", "{", "// validation failed", "$", "featuredImageProcessing", "[", "'validationMessage'", "]", "=", "$", "this", "->", "validateFeaturedImageServer", "(", "$", "data", "[", "'featured_image_server'", "]", ")", ";", "return", "$", "featuredImageProcessing", ";", "}", "// if using the featured_image_upload field, and it passes the validation, then make it the Featured Image", "$", "featuredImageProcessing", "[", "'validationMessage'", "]", "=", "\"passed\"", ";", "$", "featuredImageProcessing", "[", "'featured_image'", "]", "=", "$", "data", "[", "'featured_image_server'", "]", ";", "return", "$", "featuredImageProcessing", ";", "}" ]
Main featured image processing @param array $data Form field data
[ "Main", "featured", "image", "processing" ]
05083be19645d52be86d8ba4f322773db348a11d
https://github.com/lasallecms/lasallecms-l5-lasallecmsapi-pkg/blob/05083be19645d52be86d8ba4f322773db348a11d/src/FeaturedImageProcessing/FeaturedImageProcessing.php#L69-L140
24,938
lasallecms/lasallecms-l5-lasallecmsapi-pkg
src/FeaturedImageProcessing/FeaturedImageProcessing.php
FeaturedImageProcessing.validateFeaturedImageUpload
public function validateFeaturedImageUpload($featuredImageUpload) { // not acceptable file extension if (!$this->isImageFileExtensionKosher($featuredImageUpload)) { return "Your uploaded image file, ".$featuredImageUpload.", is not an accepted image file type."; } // file already exists on the server if ($this->doesImageFileExistOnServer($featuredImageUpload)) { return "Your uploaded image file, ".$featuredImageUpload.", already exists on the server."; } // file upload failed if ( ! \Input::file('featured_image_upload')->isValid() ) { return "There were problems uploading your image file, ".$featuredImageUpload."."; } return "passed"; }
php
public function validateFeaturedImageUpload($featuredImageUpload) { // not acceptable file extension if (!$this->isImageFileExtensionKosher($featuredImageUpload)) { return "Your uploaded image file, ".$featuredImageUpload.", is not an accepted image file type."; } // file already exists on the server if ($this->doesImageFileExistOnServer($featuredImageUpload)) { return "Your uploaded image file, ".$featuredImageUpload.", already exists on the server."; } // file upload failed if ( ! \Input::file('featured_image_upload')->isValid() ) { return "There were problems uploading your image file, ".$featuredImageUpload."."; } return "passed"; }
[ "public", "function", "validateFeaturedImageUpload", "(", "$", "featuredImageUpload", ")", "{", "// not acceptable file extension", "if", "(", "!", "$", "this", "->", "isImageFileExtensionKosher", "(", "$", "featuredImageUpload", ")", ")", "{", "return", "\"Your uploaded image file, \"", ".", "$", "featuredImageUpload", ".", "\", is not an accepted image file type.\"", ";", "}", "// file already exists on the server", "if", "(", "$", "this", "->", "doesImageFileExistOnServer", "(", "$", "featuredImageUpload", ")", ")", "{", "return", "\"Your uploaded image file, \"", ".", "$", "featuredImageUpload", ".", "\", already exists on the server.\"", ";", "}", "// file upload failed", "if", "(", "!", "\\", "Input", "::", "file", "(", "'featured_image_upload'", ")", "->", "isValid", "(", ")", ")", "{", "return", "\"There were problems uploading your image file, \"", ".", "$", "featuredImageUpload", ".", "\".\"", ";", "}", "return", "\"passed\"", ";", "}" ]
Validate the featured_image_upload field's data @param string $featuredImageUpload The featured_image_upload form field's value @return string "passed", or an error message
[ "Validate", "the", "featured_image_upload", "field", "s", "data" ]
05083be19645d52be86d8ba4f322773db348a11d
https://github.com/lasallecms/lasallecms-l5-lasallecmsapi-pkg/blob/05083be19645d52be86d8ba4f322773db348a11d/src/FeaturedImageProcessing/FeaturedImageProcessing.php#L175-L193
24,939
lasallecms/lasallecms-l5-lasallecmsapi-pkg
src/FeaturedImageProcessing/FeaturedImageProcessing.php
FeaturedImageProcessing.validateFeaturedImageServer
public function validateFeaturedImageServer($featuredImageServer) { // if there is no featured_image_server, then there is no featured image -- which is ok if ((!$featuredImageServer) || ($featuredImageServer == "") ) { return "passed"; } // not acceptable file extension if (!$this->isImageFileExtensionKosher($featuredImageServer)) { return "The image file you selected on your server, ".$featuredImageServer.", is not an accepted image file type."; } // file NOT already exists on the server if (!$this->doesImageFileExistOnServer($featuredImageServer)) { return "The image file you selected on your server, ".$featuredImageServer.", does NOT actually exist on the server."; } return "passed"; }
php
public function validateFeaturedImageServer($featuredImageServer) { // if there is no featured_image_server, then there is no featured image -- which is ok if ((!$featuredImageServer) || ($featuredImageServer == "") ) { return "passed"; } // not acceptable file extension if (!$this->isImageFileExtensionKosher($featuredImageServer)) { return "The image file you selected on your server, ".$featuredImageServer.", is not an accepted image file type."; } // file NOT already exists on the server if (!$this->doesImageFileExistOnServer($featuredImageServer)) { return "The image file you selected on your server, ".$featuredImageServer.", does NOT actually exist on the server."; } return "passed"; }
[ "public", "function", "validateFeaturedImageServer", "(", "$", "featuredImageServer", ")", "{", "// if there is no featured_image_server, then there is no featured image -- which is ok", "if", "(", "(", "!", "$", "featuredImageServer", ")", "||", "(", "$", "featuredImageServer", "==", "\"\"", ")", ")", "{", "return", "\"passed\"", ";", "}", "// not acceptable file extension", "if", "(", "!", "$", "this", "->", "isImageFileExtensionKosher", "(", "$", "featuredImageServer", ")", ")", "{", "return", "\"The image file you selected on your server, \"", ".", "$", "featuredImageServer", ".", "\", is not an accepted image file type.\"", ";", "}", "// file NOT already exists on the server", "if", "(", "!", "$", "this", "->", "doesImageFileExistOnServer", "(", "$", "featuredImageServer", ")", ")", "{", "return", "\"The image file you selected on your server, \"", ".", "$", "featuredImageServer", ".", "\", does NOT actually exist on the server.\"", ";", "}", "return", "\"passed\"", ";", "}" ]
Validate the featured_image_server field's data @param string $featuredImageServer The featured_image_server form field's value @return string "passed", or an error message
[ "Validate", "the", "featured_image_server", "field", "s", "data" ]
05083be19645d52be86d8ba4f322773db348a11d
https://github.com/lasallecms/lasallecms-l5-lasallecmsapi-pkg/blob/05083be19645d52be86d8ba4f322773db348a11d/src/FeaturedImageProcessing/FeaturedImageProcessing.php#L201-L219
24,940
lasallecms/lasallecms-l5-lasallecmsapi-pkg
src/FeaturedImageProcessing/FeaturedImageProcessing.php
FeaturedImageProcessing.isImageFileExtensionKosher
public function isImageFileExtensionKosher($filename) { // must have acceptable file extension $imageFileExtension = $this->ImagesHelper->filenameWithExtensionOnly($filename); $haystack = Config::get('lasallecmsfrontend.acceptable_image_extensions_for_uploading'); if (in_array(strtolower($imageFileExtension), $haystack)) { return true; } return false; }
php
public function isImageFileExtensionKosher($filename) { // must have acceptable file extension $imageFileExtension = $this->ImagesHelper->filenameWithExtensionOnly($filename); $haystack = Config::get('lasallecmsfrontend.acceptable_image_extensions_for_uploading'); if (in_array(strtolower($imageFileExtension), $haystack)) { return true; } return false; }
[ "public", "function", "isImageFileExtensionKosher", "(", "$", "filename", ")", "{", "// must have acceptable file extension", "$", "imageFileExtension", "=", "$", "this", "->", "ImagesHelper", "->", "filenameWithExtensionOnly", "(", "$", "filename", ")", ";", "$", "haystack", "=", "Config", "::", "get", "(", "'lasallecmsfrontend.acceptable_image_extensions_for_uploading'", ")", ";", "if", "(", "in_array", "(", "strtolower", "(", "$", "imageFileExtension", ")", ",", "$", "haystack", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Is the image's extension allowed? @param string $filename The image's filename @return bool
[ "Is", "the", "image", "s", "extension", "allowed?" ]
05083be19645d52be86d8ba4f322773db348a11d
https://github.com/lasallecms/lasallecms-l5-lasallecmsapi-pkg/blob/05083be19645d52be86d8ba4f322773db348a11d/src/FeaturedImageProcessing/FeaturedImageProcessing.php#L238-L250
24,941
lasallecms/lasallecms-l5-lasallecmsapi-pkg
src/FeaturedImageProcessing/FeaturedImageProcessing.php
FeaturedImageProcessing.doesImageFileExistOnServer
public function doesImageFileExistOnServer($filename) { if (\File::exists($this->ImagesHelper->pathOfImagesUploadParentFolder() . "/" . Config::get('lasallecmsfrontend.images_folder_uploaded'). '/'. $filename)) { return true; } return false; }
php
public function doesImageFileExistOnServer($filename) { if (\File::exists($this->ImagesHelper->pathOfImagesUploadParentFolder() . "/" . Config::get('lasallecmsfrontend.images_folder_uploaded'). '/'. $filename)) { return true; } return false; }
[ "public", "function", "doesImageFileExistOnServer", "(", "$", "filename", ")", "{", "if", "(", "\\", "File", "::", "exists", "(", "$", "this", "->", "ImagesHelper", "->", "pathOfImagesUploadParentFolder", "(", ")", ".", "\"/\"", ".", "Config", "::", "get", "(", "'lasallecmsfrontend.images_folder_uploaded'", ")", ".", "'/'", ".", "$", "filename", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Does the iamge file exist already on the server? @param string $filename The image's filename @return bool
[ "Does", "the", "iamge", "file", "exist", "already", "on", "the", "server?" ]
05083be19645d52be86d8ba4f322773db348a11d
https://github.com/lasallecms/lasallecms-l5-lasallecmsapi-pkg/blob/05083be19645d52be86d8ba4f322773db348a11d/src/FeaturedImageProcessing/FeaturedImageProcessing.php#L258-L264
24,942
lasallecms/lasallecms-l5-lasallecmsapi-pkg
src/FeaturedImageProcessing/FeaturedImageProcessing.php
FeaturedImageProcessing.moveFile
public function moveFile($filename) { $destinationPath = $this->ImagesHelper->pathOfImagesUploadParentFolder() . "/" . Config::get('lasallecmsfrontend.images_folder_uploaded'); \Input::file('featured_image_upload')->move($destinationPath, $filename); }
php
public function moveFile($filename) { $destinationPath = $this->ImagesHelper->pathOfImagesUploadParentFolder() . "/" . Config::get('lasallecmsfrontend.images_folder_uploaded'); \Input::file('featured_image_upload')->move($destinationPath, $filename); }
[ "public", "function", "moveFile", "(", "$", "filename", ")", "{", "$", "destinationPath", "=", "$", "this", "->", "ImagesHelper", "->", "pathOfImagesUploadParentFolder", "(", ")", ".", "\"/\"", ".", "Config", "::", "get", "(", "'lasallecmsfrontend.images_folder_uploaded'", ")", ";", "\\", "Input", "::", "file", "(", "'featured_image_upload'", ")", "->", "move", "(", "$", "destinationPath", ",", "$", "filename", ")", ";", "}" ]
Move the uploaded file from the tmp folder to its proper destination folder @param string $filename The image's filename @return null
[ "Move", "the", "uploaded", "file", "from", "the", "tmp", "folder", "to", "its", "proper", "destination", "folder" ]
05083be19645d52be86d8ba4f322773db348a11d
https://github.com/lasallecms/lasallecms-l5-lasallecmsapi-pkg/blob/05083be19645d52be86d8ba4f322773db348a11d/src/FeaturedImageProcessing/FeaturedImageProcessing.php#L277-L282
24,943
andela-doladosu/liteorm
src/Origins/BaseModel.php
BaseModel.where
public function where($table, $column, $keyword) { $connection = Connection::connect(); $selectValue = $connection->prepare('select * from '.$table.' where '.$column.' = \''.$keyword.'\''); $selectValue->execute(); return $selectValue->fetch(PDO::FETCH_ASSOC); }
php
public function where($table, $column, $keyword) { $connection = Connection::connect(); $selectValue = $connection->prepare('select * from '.$table.' where '.$column.' = \''.$keyword.'\''); $selectValue->execute(); return $selectValue->fetch(PDO::FETCH_ASSOC); }
[ "public", "function", "where", "(", "$", "table", ",", "$", "column", ",", "$", "keyword", ")", "{", "$", "connection", "=", "Connection", "::", "connect", "(", ")", ";", "$", "selectValue", "=", "$", "connection", "->", "prepare", "(", "'select * from '", ".", "$", "table", ".", "' where '", ".", "$", "column", ".", "' = \\''", ".", "$", "keyword", ".", "'\\''", ")", ";", "$", "selectValue", "->", "execute", "(", ")", ";", "return", "$", "selectValue", "->", "fetch", "(", "PDO", "::", "FETCH_ASSOC", ")", ";", "}" ]
Return details where a column is matched by the given keyword @param string $table @param string $column @param string $keyword @return array
[ "Return", "details", "where", "a", "column", "is", "matched", "by", "the", "given", "keyword" ]
e97f69e20be4ce0c078a0c25a9a777307d85e9e4
https://github.com/andela-doladosu/liteorm/blob/e97f69e20be4ce0c078a0c25a9a777307d85e9e4/src/Origins/BaseModel.php#L70-L78
24,944
andela-doladosu/liteorm
src/Origins/BaseModel.php
BaseModel.selectAll
protected static function selectAll($model, $tableName) { $connection = Connection::connect(); $getAll = $connection->prepare('select * from '.$tableName); $getAll->execute(); while ($allRows = $getAll->fetch(PDO::FETCH_ASSOC)) { array_push($model->resultRows, $allRows); } return $model; }
php
protected static function selectAll($model, $tableName) { $connection = Connection::connect(); $getAll = $connection->prepare('select * from '.$tableName); $getAll->execute(); while ($allRows = $getAll->fetch(PDO::FETCH_ASSOC)) { array_push($model->resultRows, $allRows); } return $model; }
[ "protected", "static", "function", "selectAll", "(", "$", "model", ",", "$", "tableName", ")", "{", "$", "connection", "=", "Connection", "::", "connect", "(", ")", ";", "$", "getAll", "=", "$", "connection", "->", "prepare", "(", "'select * from '", ".", "$", "tableName", ")", ";", "$", "getAll", "->", "execute", "(", ")", ";", "while", "(", "$", "allRows", "=", "$", "getAll", "->", "fetch", "(", "PDO", "::", "FETCH_ASSOC", ")", ")", "{", "array_push", "(", "$", "model", "->", "resultRows", ",", "$", "allRows", ")", ";", "}", "return", "$", "model", ";", "}" ]
Search database for all rows @param $model @param $tableName @return mixed
[ "Search", "database", "for", "all", "rows" ]
e97f69e20be4ce0c078a0c25a9a777307d85e9e4
https://github.com/andela-doladosu/liteorm/blob/e97f69e20be4ce0c078a0c25a9a777307d85e9e4/src/Origins/BaseModel.php#L88-L100
24,945
andela-doladosu/liteorm
src/Origins/BaseModel.php
BaseModel.selectOne
protected static function selectOne($model, $tableName, $id) { $connection = Connection::connect(); $getAll = $connection->prepare('select * from '.$tableName.' where id='.$id); $getAll->execute(); $row = $getAll->fetch(PDO::FETCH_ASSOC); array_push($model->resultRows, $row); return $model; }
php
protected static function selectOne($model, $tableName, $id) { $connection = Connection::connect(); $getAll = $connection->prepare('select * from '.$tableName.' where id='.$id); $getAll->execute(); $row = $getAll->fetch(PDO::FETCH_ASSOC); array_push($model->resultRows, $row); return $model; }
[ "protected", "static", "function", "selectOne", "(", "$", "model", ",", "$", "tableName", ",", "$", "id", ")", "{", "$", "connection", "=", "Connection", "::", "connect", "(", ")", ";", "$", "getAll", "=", "$", "connection", "->", "prepare", "(", "'select * from '", ".", "$", "tableName", ".", "' where id='", ".", "$", "id", ")", ";", "$", "getAll", "->", "execute", "(", ")", ";", "$", "row", "=", "$", "getAll", "->", "fetch", "(", "PDO", "::", "FETCH_ASSOC", ")", ";", "array_push", "(", "$", "model", "->", "resultRows", ",", "$", "row", ")", ";", "return", "$", "model", ";", "}" ]
Search database for one row @param $model @param $tableName @param $id @return mixed
[ "Search", "database", "for", "one", "row" ]
e97f69e20be4ce0c078a0c25a9a777307d85e9e4
https://github.com/andela-doladosu/liteorm/blob/e97f69e20be4ce0c078a0c25a9a777307d85e9e4/src/Origins/BaseModel.php#L111-L122
24,946
andela-doladosu/liteorm
src/Origins/BaseModel.php
BaseModel.updateRow
protected function updateRow() { $tableName = $this->getTableName($this->className); $assignedValues = $this->getAssignedValues(); $updateDetails = []; for ($i = 0; $i < count($assignedValues['columns']); $i++) { array_push($updateDetails, $assignedValues['columns'][$i] .' =\''. $assignedValues['values'][$i].'\''); } $connection = Connection::connect(); $allUpdates = implode(', ' , $updateDetails); $update = $connection->prepare('update '.$tableName.' set '. $allUpdates.' where id='.$this->resultRows[0]['id']); if ($update->execute()) { return 'Row updated'; } else { throw new Exception("Unable to update row"); } }
php
protected function updateRow() { $tableName = $this->getTableName($this->className); $assignedValues = $this->getAssignedValues(); $updateDetails = []; for ($i = 0; $i < count($assignedValues['columns']); $i++) { array_push($updateDetails, $assignedValues['columns'][$i] .' =\''. $assignedValues['values'][$i].'\''); } $connection = Connection::connect(); $allUpdates = implode(', ' , $updateDetails); $update = $connection->prepare('update '.$tableName.' set '. $allUpdates.' where id='.$this->resultRows[0]['id']); if ($update->execute()) { return 'Row updated'; } else { throw new Exception("Unable to update row"); } }
[ "protected", "function", "updateRow", "(", ")", "{", "$", "tableName", "=", "$", "this", "->", "getTableName", "(", "$", "this", "->", "className", ")", ";", "$", "assignedValues", "=", "$", "this", "->", "getAssignedValues", "(", ")", ";", "$", "updateDetails", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "assignedValues", "[", "'columns'", "]", ")", ";", "$", "i", "++", ")", "{", "array_push", "(", "$", "updateDetails", ",", "$", "assignedValues", "[", "'columns'", "]", "[", "$", "i", "]", ".", "' =\\''", ".", "$", "assignedValues", "[", "'values'", "]", "[", "$", "i", "]", ".", "'\\''", ")", ";", "}", "$", "connection", "=", "Connection", "::", "connect", "(", ")", ";", "$", "allUpdates", "=", "implode", "(", "', '", ",", "$", "updateDetails", ")", ";", "$", "update", "=", "$", "connection", "->", "prepare", "(", "'update '", ".", "$", "tableName", ".", "' set '", ".", "$", "allUpdates", ".", "' where id='", ".", "$", "this", "->", "resultRows", "[", "0", "]", "[", "'id'", "]", ")", ";", "if", "(", "$", "update", "->", "execute", "(", ")", ")", "{", "return", "'Row updated'", ";", "}", "else", "{", "throw", "new", "Exception", "(", "\"Unable to update row\"", ")", ";", "}", "}" ]
Edit an existing row @return bool
[ "Edit", "an", "existing", "row" ]
e97f69e20be4ce0c078a0c25a9a777307d85e9e4
https://github.com/andela-doladosu/liteorm/blob/e97f69e20be4ce0c078a0c25a9a777307d85e9e4/src/Origins/BaseModel.php#L178-L198
24,947
andela-doladosu/liteorm
src/Origins/BaseModel.php
BaseModel.destroy
public static function destroy($id) { if (self::confirmIdExists($id)) { return self::doDelete($id); } else { throw new Exception('Now rows found with ID '.$id.' in the database, it may have been already deleted'); } }
php
public static function destroy($id) { if (self::confirmIdExists($id)) { return self::doDelete($id); } else { throw new Exception('Now rows found with ID '.$id.' in the database, it may have been already deleted'); } }
[ "public", "static", "function", "destroy", "(", "$", "id", ")", "{", "if", "(", "self", "::", "confirmIdExists", "(", "$", "id", ")", ")", "{", "return", "self", "::", "doDelete", "(", "$", "id", ")", ";", "}", "else", "{", "throw", "new", "Exception", "(", "'Now rows found with ID '", ".", "$", "id", ".", "' in the database, it may have been already deleted'", ")", ";", "}", "}" ]
Call doDelete function if the specified id exists @param $id @return string
[ "Call", "doDelete", "function", "if", "the", "specified", "id", "exists" ]
e97f69e20be4ce0c078a0c25a9a777307d85e9e4
https://github.com/andela-doladosu/liteorm/blob/e97f69e20be4ce0c078a0c25a9a777307d85e9e4/src/Origins/BaseModel.php#L207-L214
24,948
andela-doladosu/liteorm
src/Origins/BaseModel.php
BaseModel.doDelete
protected static function doDelete($id) { $model = self::createModelInstance(); $tableName = $model->getTableName($model->className); $connection = Connection::connect(); $delete = $connection->prepare('delete from '.$tableName.' where id ='.$id); return $delete->execute() ? 'deleted successfully' : 'Row not deleted'; }
php
protected static function doDelete($id) { $model = self::createModelInstance(); $tableName = $model->getTableName($model->className); $connection = Connection::connect(); $delete = $connection->prepare('delete from '.$tableName.' where id ='.$id); return $delete->execute() ? 'deleted successfully' : 'Row not deleted'; }
[ "protected", "static", "function", "doDelete", "(", "$", "id", ")", "{", "$", "model", "=", "self", "::", "createModelInstance", "(", ")", ";", "$", "tableName", "=", "$", "model", "->", "getTableName", "(", "$", "model", "->", "className", ")", ";", "$", "connection", "=", "Connection", "::", "connect", "(", ")", ";", "$", "delete", "=", "$", "connection", "->", "prepare", "(", "'delete from '", ".", "$", "tableName", ".", "' where id ='", ".", "$", "id", ")", ";", "return", "$", "delete", "->", "execute", "(", ")", "?", "'deleted successfully'", ":", "'Row not deleted'", ";", "}" ]
Delete an existing row from the database @param $id @return string
[ "Delete", "an", "existing", "row", "from", "the", "database" ]
e97f69e20be4ce0c078a0c25a9a777307d85e9e4
https://github.com/andela-doladosu/liteorm/blob/e97f69e20be4ce0c078a0c25a9a777307d85e9e4/src/Origins/BaseModel.php#L222-L233
24,949
alphalemon/BootstrapBundle
Core/ActionManager/ActionManagerGenerator.php
ActionManagerGenerator.generate
public function generate($actionManager) { if ($actionManager instanceof ActionManagerInterface) { $this->actionManager = $actionManager; $this->actionManagerClass = get_class($this->actionManager); } if (is_string($actionManager) && class_exists($actionManager)) { $this->actionManager = new $actionManager(); $this->actionManagerClass = $actionManager; } }
php
public function generate($actionManager) { if ($actionManager instanceof ActionManagerInterface) { $this->actionManager = $actionManager; $this->actionManagerClass = get_class($this->actionManager); } if (is_string($actionManager) && class_exists($actionManager)) { $this->actionManager = new $actionManager(); $this->actionManagerClass = $actionManager; } }
[ "public", "function", "generate", "(", "$", "actionManager", ")", "{", "if", "(", "$", "actionManager", "instanceof", "ActionManagerInterface", ")", "{", "$", "this", "->", "actionManager", "=", "$", "actionManager", ";", "$", "this", "->", "actionManagerClass", "=", "get_class", "(", "$", "this", "->", "actionManager", ")", ";", "}", "if", "(", "is_string", "(", "$", "actionManager", ")", "&&", "class_exists", "(", "$", "actionManager", ")", ")", "{", "$", "this", "->", "actionManager", "=", "new", "$", "actionManager", "(", ")", ";", "$", "this", "->", "actionManagerClass", "=", "$", "actionManager", ";", "}", "}" ]
Generates the ActionManager object @param mixed ActionManagerInterface|string $actionManager
[ "Generates", "the", "ActionManager", "object" ]
27ff5cbc58d58149ec72a974f2a9d765a6fd37a6
https://github.com/alphalemon/BootstrapBundle/blob/27ff5cbc58d58149ec72a974f2a9d765a6fd37a6/Core/ActionManager/ActionManagerGenerator.php#L48-L59
24,950
ColibriPlatform/base
Env.php
Env.load
public static function load($file) { if (file_exists($file)) { $env = \M1\Env\Parser::parse(file_get_contents($file)); foreach ($env as $key => $value) { putenv("{$key}={$value}"); } } }
php
public static function load($file) { if (file_exists($file)) { $env = \M1\Env\Parser::parse(file_get_contents($file)); foreach ($env as $key => $value) { putenv("{$key}={$value}"); } } }
[ "public", "static", "function", "load", "(", "$", "file", ")", "{", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "$", "env", "=", "\\", "M1", "\\", "Env", "\\", "Parser", "::", "parse", "(", "file_get_contents", "(", "$", "file", ")", ")", ";", "foreach", "(", "$", "env", "as", "$", "key", "=>", "$", "value", ")", "{", "putenv", "(", "\"{$key}={$value}\"", ")", ";", "}", "}", "}" ]
Load file containing environment variables and setup environment with these variables @param string $file @return void
[ "Load", "file", "containing", "environment", "variables", "and", "setup", "environment", "with", "these", "variables" ]
b45db9c88317e28acc5b024ac98f8428685179aa
https://github.com/ColibriPlatform/base/blob/b45db9c88317e28acc5b024ac98f8428685179aa/Env.php#L27-L35
24,951
net-tools/core
src/Helpers/PdoHelper.php
PdoHelper.addForeignKey
function addForeignKey($table, $pkname, $tables) { if ( is_string($tables) ) $tables = array($tables); $this->_foreignKeys[$table] = array( 'primaryKey' => $pkname, 'tables' => $tables ); }
php
function addForeignKey($table, $pkname, $tables) { if ( is_string($tables) ) $tables = array($tables); $this->_foreignKeys[$table] = array( 'primaryKey' => $pkname, 'tables' => $tables ); }
[ "function", "addForeignKey", "(", "$", "table", ",", "$", "pkname", ",", "$", "tables", ")", "{", "if", "(", "is_string", "(", "$", "tables", ")", ")", "$", "tables", "=", "array", "(", "$", "tables", ")", ";", "$", "this", "->", "_foreignKeys", "[", "$", "table", "]", "=", "array", "(", "'primaryKey'", "=>", "$", "pkname", ",", "'tables'", "=>", "$", "tables", ")", ";", "}" ]
Add some config data for a new foreign key @param string $table Name of the foreign key table @param string $pkname Name of its primary key @param string[] $tables Array of tables referencing $table parameter
[ "Add", "some", "config", "data", "for", "a", "new", "foreign", "key" ]
51446641cee22c0cf53d2b409c76cc8bd1a187e7
https://github.com/net-tools/core/blob/51446641cee22c0cf53d2b409c76cc8bd1a187e7/src/Helpers/PdoHelper.php#L59-L69
24,952
net-tools/core
src/Helpers/PdoHelper.php
PdoHelper.pdo_query_select
function pdo_query_select($query, $values = NULL) { if ( !is_null($values) && !is_array($values) ) $values = array($values); $st = $this->prepare($query); $st->execute($values); return $st; }
php
function pdo_query_select($query, $values = NULL) { if ( !is_null($values) && !is_array($values) ) $values = array($values); $st = $this->prepare($query); $st->execute($values); return $st; }
[ "function", "pdo_query_select", "(", "$", "query", ",", "$", "values", "=", "NULL", ")", "{", "if", "(", "!", "is_null", "(", "$", "values", ")", "&&", "!", "is_array", "(", "$", "values", ")", ")", "$", "values", "=", "array", "(", "$", "values", ")", ";", "$", "st", "=", "$", "this", "->", "prepare", "(", "$", "query", ")", ";", "$", "st", "->", "execute", "(", "$", "values", ")", ";", "return", "$", "st", ";", "}" ]
Helper query method for a SQL SELECT request @param string $query The SQL query @param string[] $values An array of parameters for the query (? and :xxx placeholders concrete values) @return \PDOStatement A PDOStatement object with rows to fetch @throws \PDOException If an error occured, a exception is thrown
[ "Helper", "query", "method", "for", "a", "SQL", "SELECT", "request" ]
51446641cee22c0cf53d2b409c76cc8bd1a187e7
https://github.com/net-tools/core/blob/51446641cee22c0cf53d2b409c76cc8bd1a187e7/src/Helpers/PdoHelper.php#L120-L129
24,953
MindyPHP/Pagination
BasePagination.php
BasePagination.paginate
public function paginate() { $this->total = $this->dataSource->getTotal($this->source); if ( ($this->getPagesCount() > 0 && $this->getPage() > $this->getPagesCount()) || $this->getPage() <= 0 ) { $this->handler->wrongPageCallback(); } $this->data = $this->dataSource->applyLimit( $this->source, $this->getPage(), $this->getPageSize() ); return $this->data; }
php
public function paginate() { $this->total = $this->dataSource->getTotal($this->source); if ( ($this->getPagesCount() > 0 && $this->getPage() > $this->getPagesCount()) || $this->getPage() <= 0 ) { $this->handler->wrongPageCallback(); } $this->data = $this->dataSource->applyLimit( $this->source, $this->getPage(), $this->getPageSize() ); return $this->data; }
[ "public", "function", "paginate", "(", ")", "{", "$", "this", "->", "total", "=", "$", "this", "->", "dataSource", "->", "getTotal", "(", "$", "this", "->", "source", ")", ";", "if", "(", "(", "$", "this", "->", "getPagesCount", "(", ")", ">", "0", "&&", "$", "this", "->", "getPage", "(", ")", ">", "$", "this", "->", "getPagesCount", "(", ")", ")", "||", "$", "this", "->", "getPage", "(", ")", "<=", "0", ")", "{", "$", "this", "->", "handler", "->", "wrongPageCallback", "(", ")", ";", "}", "$", "this", "->", "data", "=", "$", "this", "->", "dataSource", "->", "applyLimit", "(", "$", "this", "->", "source", ",", "$", "this", "->", "getPage", "(", ")", ",", "$", "this", "->", "getPageSize", "(", ")", ")", ";", "return", "$", "this", "->", "data", ";", "}" ]
Apply limits to source. @throws \Exception @return array
[ "Apply", "limits", "to", "source", "." ]
9f38cc7ac219ea2639b88d9f45351c7b24ea8322
https://github.com/MindyPHP/Pagination/blob/9f38cc7ac219ea2639b88d9f45351c7b24ea8322/BasePagination.php#L204-L222
24,954
CatLabInteractive/Accounts
src/CatLab/Accounts/Module.php
Module.initialize
public function initialize ($routepath) { // Set path $this->routepath = $routepath; // Add templates Template::addPath (__DIR__ . '/templates/', 'CatLab/Accounts/'); // Add locales Text::getInstance ()->addPath ('catlab.accounts', __DIR__ . '/locales/'); // Set session variable Application::getInstance ()->on ('dispatch:before', array ($this, 'setRequestUser')); // Set the global user mapper, unless one is set already Application::getInstance ()->on ('dispatch:first', array ($this, 'setUserMapper')); // Add helper methods $helper = new LoginForm ($this); Template::addHelper ('CatLab.Accounts.LoginForm', $helper); }
php
public function initialize ($routepath) { // Set path $this->routepath = $routepath; // Add templates Template::addPath (__DIR__ . '/templates/', 'CatLab/Accounts/'); // Add locales Text::getInstance ()->addPath ('catlab.accounts', __DIR__ . '/locales/'); // Set session variable Application::getInstance ()->on ('dispatch:before', array ($this, 'setRequestUser')); // Set the global user mapper, unless one is set already Application::getInstance ()->on ('dispatch:first', array ($this, 'setUserMapper')); // Add helper methods $helper = new LoginForm ($this); Template::addHelper ('CatLab.Accounts.LoginForm', $helper); }
[ "public", "function", "initialize", "(", "$", "routepath", ")", "{", "// Set path", "$", "this", "->", "routepath", "=", "$", "routepath", ";", "// Add templates", "Template", "::", "addPath", "(", "__DIR__", ".", "'/templates/'", ",", "'CatLab/Accounts/'", ")", ";", "// Add locales", "Text", "::", "getInstance", "(", ")", "->", "addPath", "(", "'catlab.accounts'", ",", "__DIR__", ".", "'/locales/'", ")", ";", "// Set session variable", "Application", "::", "getInstance", "(", ")", "->", "on", "(", "'dispatch:before'", ",", "array", "(", "$", "this", ",", "'setRequestUser'", ")", ")", ";", "// Set the global user mapper, unless one is set already", "Application", "::", "getInstance", "(", ")", "->", "on", "(", "'dispatch:first'", ",", "array", "(", "$", "this", ",", "'setUserMapper'", ")", ")", ";", "// Add helper methods", "$", "helper", "=", "new", "LoginForm", "(", "$", "this", ")", ";", "Template", "::", "addHelper", "(", "'CatLab.Accounts.LoginForm'", ",", "$", "helper", ")", ";", "}" ]
Set template paths, config vars, etc @param string $routepath The prefix that should be added to all route paths. @return void
[ "Set", "template", "paths", "config", "vars", "etc" ]
e5465ad815c3caba5b7c1fde7b465a5fa05f3298
https://github.com/CatLabInteractive/Accounts/blob/e5465ad815c3caba5b7c1fde7b465a5fa05f3298/src/CatLab/Accounts/Module.php#L56-L77
24,955
CatLabInteractive/Accounts
src/CatLab/Accounts/Module.php
Module.setRequestUser
public function setRequestUser (Request $request) { $request->addUserCallback ('accounts', function (Request $request) { $userid = $request->getSession ()->get ('catlab-user-id'); if ($userid) { $user = MapperFactory::getUserMapper ()->getFromId ($userid); if ($user) return $user; } return null; }); }
php
public function setRequestUser (Request $request) { $request->addUserCallback ('accounts', function (Request $request) { $userid = $request->getSession ()->get ('catlab-user-id'); if ($userid) { $user = MapperFactory::getUserMapper ()->getFromId ($userid); if ($user) return $user; } return null; }); }
[ "public", "function", "setRequestUser", "(", "Request", "$", "request", ")", "{", "$", "request", "->", "addUserCallback", "(", "'accounts'", ",", "function", "(", "Request", "$", "request", ")", "{", "$", "userid", "=", "$", "request", "->", "getSession", "(", ")", "->", "get", "(", "'catlab-user-id'", ")", ";", "if", "(", "$", "userid", ")", "{", "$", "user", "=", "MapperFactory", "::", "getUserMapper", "(", ")", "->", "getFromId", "(", "$", "userid", ")", ";", "if", "(", "$", "user", ")", "return", "$", "user", ";", "}", "return", "null", ";", "}", ")", ";", "}" ]
Set user from session @param Request $request @throws \Neuron\Exceptions\InvalidParameter
[ "Set", "user", "from", "session" ]
e5465ad815c3caba5b7c1fde7b465a5fa05f3298
https://github.com/CatLabInteractive/Accounts/blob/e5465ad815c3caba5b7c1fde7b465a5fa05f3298/src/CatLab/Accounts/Module.php#L84-L99
24,956
CatLabInteractive/Accounts
src/CatLab/Accounts/Module.php
Module.login
public function login (Request $request, User $user, $registration = false) { // Check for email validation if ($this->requiresEmailValidation()) { if (!$user->isEmailVerified()) { $request->getSession()->set ('catlab-non-verified-user-id', $user->getId()); return Response::redirect(URLBuilder::getURL($this->routepath . '/notverified')); } } $request->getSession()->set('catlab-user-id', $user->getId()); return $this->postLogin($request, $user, $registration); }
php
public function login (Request $request, User $user, $registration = false) { // Check for email validation if ($this->requiresEmailValidation()) { if (!$user->isEmailVerified()) { $request->getSession()->set ('catlab-non-verified-user-id', $user->getId()); return Response::redirect(URLBuilder::getURL($this->routepath . '/notverified')); } } $request->getSession()->set('catlab-user-id', $user->getId()); return $this->postLogin($request, $user, $registration); }
[ "public", "function", "login", "(", "Request", "$", "request", ",", "User", "$", "user", ",", "$", "registration", "=", "false", ")", "{", "// Check for email validation", "if", "(", "$", "this", "->", "requiresEmailValidation", "(", ")", ")", "{", "if", "(", "!", "$", "user", "->", "isEmailVerified", "(", ")", ")", "{", "$", "request", "->", "getSession", "(", ")", "->", "set", "(", "'catlab-non-verified-user-id'", ",", "$", "user", "->", "getId", "(", ")", ")", ";", "return", "Response", "::", "redirect", "(", "URLBuilder", "::", "getURL", "(", "$", "this", "->", "routepath", ".", "'/notverified'", ")", ")", ";", "}", "}", "$", "request", "->", "getSession", "(", ")", "->", "set", "(", "'catlab-user-id'", ",", "$", "user", "->", "getId", "(", ")", ")", ";", "return", "$", "this", "->", "postLogin", "(", "$", "request", ",", "$", "user", ",", "$", "registration", ")", ";", "}" ]
Login a specific user @param Request $request @param User $user @param bool $registration @return \Neuron\Net\Response @throws DataNotSet
[ "Login", "a", "specific", "user" ]
e5465ad815c3caba5b7c1fde7b465a5fa05f3298
https://github.com/CatLabInteractive/Accounts/blob/e5465ad815c3caba5b7c1fde7b465a5fa05f3298/src/CatLab/Accounts/Module.php#L141-L153
24,957
CatLabInteractive/Accounts
src/CatLab/Accounts/Module.php
Module.postLogin
public function postLogin (Request $request, \Neuron\Interfaces\Models\User $user, $registered = false) { $parameters = array(); if ($registered) { $parameters['registered'] = 1; } // Also set in session... why wouldn't this be in session? :D $request->getSession()->set('userJustRegistered', $registered); $this->trigger('user:login', [ 'request' => $request, 'user' => $user, 'registered' => $registered ]); // Should skip welcome screen? if ($request->getSession()->get('skip-welcome-redirect')) { $redirectUrl = $this->getAndClearPostLoginRedirect($request); return Response::redirect($redirectUrl); } return $this->redirectToWelcome ([]); }
php
public function postLogin (Request $request, \Neuron\Interfaces\Models\User $user, $registered = false) { $parameters = array(); if ($registered) { $parameters['registered'] = 1; } // Also set in session... why wouldn't this be in session? :D $request->getSession()->set('userJustRegistered', $registered); $this->trigger('user:login', [ 'request' => $request, 'user' => $user, 'registered' => $registered ]); // Should skip welcome screen? if ($request->getSession()->get('skip-welcome-redirect')) { $redirectUrl = $this->getAndClearPostLoginRedirect($request); return Response::redirect($redirectUrl); } return $this->redirectToWelcome ([]); }
[ "public", "function", "postLogin", "(", "Request", "$", "request", ",", "\\", "Neuron", "\\", "Interfaces", "\\", "Models", "\\", "User", "$", "user", ",", "$", "registered", "=", "false", ")", "{", "$", "parameters", "=", "array", "(", ")", ";", "if", "(", "$", "registered", ")", "{", "$", "parameters", "[", "'registered'", "]", "=", "1", ";", "}", "// Also set in session... why wouldn't this be in session? :D", "$", "request", "->", "getSession", "(", ")", "->", "set", "(", "'userJustRegistered'", ",", "$", "registered", ")", ";", "$", "this", "->", "trigger", "(", "'user:login'", ",", "[", "'request'", "=>", "$", "request", ",", "'user'", "=>", "$", "user", ",", "'registered'", "=>", "$", "registered", "]", ")", ";", "// Should skip welcome screen?", "if", "(", "$", "request", "->", "getSession", "(", ")", "->", "get", "(", "'skip-welcome-redirect'", ")", ")", "{", "$", "redirectUrl", "=", "$", "this", "->", "getAndClearPostLoginRedirect", "(", "$", "request", ")", ";", "return", "Response", "::", "redirect", "(", "$", "redirectUrl", ")", ";", "}", "return", "$", "this", "->", "redirectToWelcome", "(", "[", "]", ")", ";", "}" ]
Called right after a user is logged in. Should be a redirect. @param Request $request @param \Neuron\Interfaces\Models\User $user @param boolean $registered @return \Neuron\Net\Response @throws DataNotSet
[ "Called", "right", "after", "a", "user", "is", "logged", "in", ".", "Should", "be", "a", "redirect", "." ]
e5465ad815c3caba5b7c1fde7b465a5fa05f3298
https://github.com/CatLabInteractive/Accounts/blob/e5465ad815c3caba5b7c1fde7b465a5fa05f3298/src/CatLab/Accounts/Module.php#L177-L200
24,958
CatLabInteractive/Accounts
src/CatLab/Accounts/Module.php
Module.postLogout
public function postLogout (Request $request) { if ($redirect = $request->getSession ()->get ('post-login-redirect')) { $request->getSession ()->set ('post-login-redirect', null); $request->getSession ()->set ('cancel-login-redirect', null); return Response::redirect ($redirect); } return Response::redirect (URLBuilder::getURL ('/')); }
php
public function postLogout (Request $request) { if ($redirect = $request->getSession ()->get ('post-login-redirect')) { $request->getSession ()->set ('post-login-redirect', null); $request->getSession ()->set ('cancel-login-redirect', null); return Response::redirect ($redirect); } return Response::redirect (URLBuilder::getURL ('/')); }
[ "public", "function", "postLogout", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "redirect", "=", "$", "request", "->", "getSession", "(", ")", "->", "get", "(", "'post-login-redirect'", ")", ")", "{", "$", "request", "->", "getSession", "(", ")", "->", "set", "(", "'post-login-redirect'", ",", "null", ")", ";", "$", "request", "->", "getSession", "(", ")", "->", "set", "(", "'cancel-login-redirect'", ",", "null", ")", ";", "return", "Response", "::", "redirect", "(", "$", "redirect", ")", ";", "}", "return", "Response", "::", "redirect", "(", "URLBuilder", "::", "getURL", "(", "'/'", ")", ")", ";", "}" ]
Called after a redirect @param Request $request @return Response @throws DataNotSet
[ "Called", "after", "a", "redirect" ]
e5465ad815c3caba5b7c1fde7b465a5fa05f3298
https://github.com/CatLabInteractive/Accounts/blob/e5465ad815c3caba5b7c1fde7b465a5fa05f3298/src/CatLab/Accounts/Module.php#L223-L234
24,959
CatLabInteractive/Accounts
src/CatLab/Accounts/Module.php
Module.setRoutes
public function setRoutes (Router $router) { // Filter $router->addFilter ('authenticated', array ($this, 'routerVerifier')); // Routes $router->match ('GET|POST', $this->routepath . '/login/{authenticator}', '\CatLab\Accounts\Controllers\LoginController@authenticator'); $router->match ('GET', $this->routepath . '/login', '\CatLab\Accounts\Controllers\LoginController@login'); $router->match ('GET', $this->routepath . '/welcome', '\CatLab\Accounts\Controllers\LoginController@welcome')->filter('authenticated'); $router->match ('GET|POST', $this->routepath . '/notverified', '\CatLab\Accounts\Controllers\LoginController@requiresVerification'); $router->match ('GET', $this->routepath . '/logout', '\CatLab\Accounts\Controllers\LoginController@logout'); $router->match ('GET', $this->routepath . '/cancel', '\CatLab\Accounts\Controllers\LoginController@cancel'); $router->match ('GET|POST', $this->routepath . '/register/{authenticator}', '\CatLab\Accounts\Controllers\RegistrationController@authenticator'); $router->match ('GET|POST', $this->routepath . '/register', '\CatLab\Accounts\Controllers\RegistrationController@register'); $router->get ($this->routepath . '/verify/{id}', '\CatLab\Accounts\Controllers\LoginController@verify'); }
php
public function setRoutes (Router $router) { // Filter $router->addFilter ('authenticated', array ($this, 'routerVerifier')); // Routes $router->match ('GET|POST', $this->routepath . '/login/{authenticator}', '\CatLab\Accounts\Controllers\LoginController@authenticator'); $router->match ('GET', $this->routepath . '/login', '\CatLab\Accounts\Controllers\LoginController@login'); $router->match ('GET', $this->routepath . '/welcome', '\CatLab\Accounts\Controllers\LoginController@welcome')->filter('authenticated'); $router->match ('GET|POST', $this->routepath . '/notverified', '\CatLab\Accounts\Controllers\LoginController@requiresVerification'); $router->match ('GET', $this->routepath . '/logout', '\CatLab\Accounts\Controllers\LoginController@logout'); $router->match ('GET', $this->routepath . '/cancel', '\CatLab\Accounts\Controllers\LoginController@cancel'); $router->match ('GET|POST', $this->routepath . '/register/{authenticator}', '\CatLab\Accounts\Controllers\RegistrationController@authenticator'); $router->match ('GET|POST', $this->routepath . '/register', '\CatLab\Accounts\Controllers\RegistrationController@register'); $router->get ($this->routepath . '/verify/{id}', '\CatLab\Accounts\Controllers\LoginController@verify'); }
[ "public", "function", "setRoutes", "(", "Router", "$", "router", ")", "{", "// Filter", "$", "router", "->", "addFilter", "(", "'authenticated'", ",", "array", "(", "$", "this", ",", "'routerVerifier'", ")", ")", ";", "// Routes", "$", "router", "->", "match", "(", "'GET|POST'", ",", "$", "this", "->", "routepath", ".", "'/login/{authenticator}'", ",", "'\\CatLab\\Accounts\\Controllers\\LoginController@authenticator'", ")", ";", "$", "router", "->", "match", "(", "'GET'", ",", "$", "this", "->", "routepath", ".", "'/login'", ",", "'\\CatLab\\Accounts\\Controllers\\LoginController@login'", ")", ";", "$", "router", "->", "match", "(", "'GET'", ",", "$", "this", "->", "routepath", ".", "'/welcome'", ",", "'\\CatLab\\Accounts\\Controllers\\LoginController@welcome'", ")", "->", "filter", "(", "'authenticated'", ")", ";", "$", "router", "->", "match", "(", "'GET|POST'", ",", "$", "this", "->", "routepath", ".", "'/notverified'", ",", "'\\CatLab\\Accounts\\Controllers\\LoginController@requiresVerification'", ")", ";", "$", "router", "->", "match", "(", "'GET'", ",", "$", "this", "->", "routepath", ".", "'/logout'", ",", "'\\CatLab\\Accounts\\Controllers\\LoginController@logout'", ")", ";", "$", "router", "->", "match", "(", "'GET'", ",", "$", "this", "->", "routepath", ".", "'/cancel'", ",", "'\\CatLab\\Accounts\\Controllers\\LoginController@cancel'", ")", ";", "$", "router", "->", "match", "(", "'GET|POST'", ",", "$", "this", "->", "routepath", ".", "'/register/{authenticator}'", ",", "'\\CatLab\\Accounts\\Controllers\\RegistrationController@authenticator'", ")", ";", "$", "router", "->", "match", "(", "'GET|POST'", ",", "$", "this", "->", "routepath", ".", "'/register'", ",", "'\\CatLab\\Accounts\\Controllers\\RegistrationController@register'", ")", ";", "$", "router", "->", "get", "(", "$", "this", "->", "routepath", ".", "'/verify/{id}'", ",", "'\\CatLab\\Accounts\\Controllers\\LoginController@verify'", ")", ";", "}" ]
Register the routes required for this module. @param Router $router @return mixed
[ "Register", "the", "routes", "required", "for", "this", "module", "." ]
e5465ad815c3caba5b7c1fde7b465a5fa05f3298
https://github.com/CatLabInteractive/Accounts/blob/e5465ad815c3caba5b7c1fde7b465a5fa05f3298/src/CatLab/Accounts/Module.php#L249-L269
24,960
aloframework/common
src/Alo.php
Alo.asciiRand
public static function asciiRand($length, $subset = self::ASCII_ALL) { switch ($subset) { case self::ASCII_ALPHANUM: $subset = self::$asciiAlphanum; break; case self::ASCII_NONALPHANUM: $subset = self::$asciNonAlphanum; break; default: $subset = array_merge(self::$asciiAlphanum, self::$asciNonAlphanum); } $count = count($subset) - 1; $r = ''; for ($i = 0; $i < $length; $i++) { $r .= $subset[mt_rand(0, $count)]; } return $r; }
php
public static function asciiRand($length, $subset = self::ASCII_ALL) { switch ($subset) { case self::ASCII_ALPHANUM: $subset = self::$asciiAlphanum; break; case self::ASCII_NONALPHANUM: $subset = self::$asciNonAlphanum; break; default: $subset = array_merge(self::$asciiAlphanum, self::$asciNonAlphanum); } $count = count($subset) - 1; $r = ''; for ($i = 0; $i < $length; $i++) { $r .= $subset[mt_rand(0, $count)]; } return $r; }
[ "public", "static", "function", "asciiRand", "(", "$", "length", ",", "$", "subset", "=", "self", "::", "ASCII_ALL", ")", "{", "switch", "(", "$", "subset", ")", "{", "case", "self", "::", "ASCII_ALPHANUM", ":", "$", "subset", "=", "self", "::", "$", "asciiAlphanum", ";", "break", ";", "case", "self", "::", "ASCII_NONALPHANUM", ":", "$", "subset", "=", "self", "::", "$", "asciNonAlphanum", ";", "break", ";", "default", ":", "$", "subset", "=", "array_merge", "(", "self", "::", "$", "asciiAlphanum", ",", "self", "::", "$", "asciNonAlphanum", ")", ";", "}", "$", "count", "=", "count", "(", "$", "subset", ")", "-", "1", ";", "$", "r", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "length", ";", "$", "i", "++", ")", "{", "$", "r", ".=", "$", "subset", "[", "mt_rand", "(", "0", ",", "$", "count", ")", "]", ";", "}", "return", "$", "r", ";", "}" ]
Generates a string of random ASCII characters @author Art <a.molcanovas@gmail.com> @param int $length The length of the string @param int $subset Which subset to use - see class' ASCII_* constants @return string @since 1.3
[ "Generates", "a", "string", "of", "random", "ASCII", "characters" ]
484ef76ea5e1b99b2758e5c35c76229572dc27cb
https://github.com/aloframework/common/blob/484ef76ea5e1b99b2758e5c35c76229572dc27cb/src/Alo.php#L189-L210
24,961
aloframework/common
src/Alo.php
Alo.getUniqid
public static function getUniqid($hash = 'sha256', $prefix = '', $entropy = 10000, $rawOutput = false) { $str = mt_rand(~PHP_INT_MAX, PHP_INT_MAX) . json_encode([$_COOKIE, $_REQUEST, $_FILES, $_ENV, $_GET, $_POST, $_SERVER]) . uniqid($prefix, true) . self::asciiRand($entropy, self::ASCII_ALL); if (function_exists('\openssl_random_pseudo_bytes')) { $algoStrong = null; $str .= \openssl_random_pseudo_bytes($entropy, $algoStrong); if ($algoStrong !== true) { trigger_error('Please update your openssl & PHP libraries. openssl_random_pseudo_bytes was unable' . ' to locate a cryptographically strong algorithm.', E_USER_WARNING); } } else { trigger_error('The openssl extension is not enabled, therefore the unique ID is not ' . 'cryptographically secure.', E_USER_WARNING); } return hash($hash, $str, $rawOutput); }
php
public static function getUniqid($hash = 'sha256', $prefix = '', $entropy = 10000, $rawOutput = false) { $str = mt_rand(~PHP_INT_MAX, PHP_INT_MAX) . json_encode([$_COOKIE, $_REQUEST, $_FILES, $_ENV, $_GET, $_POST, $_SERVER]) . uniqid($prefix, true) . self::asciiRand($entropy, self::ASCII_ALL); if (function_exists('\openssl_random_pseudo_bytes')) { $algoStrong = null; $str .= \openssl_random_pseudo_bytes($entropy, $algoStrong); if ($algoStrong !== true) { trigger_error('Please update your openssl & PHP libraries. openssl_random_pseudo_bytes was unable' . ' to locate a cryptographically strong algorithm.', E_USER_WARNING); } } else { trigger_error('The openssl extension is not enabled, therefore the unique ID is not ' . 'cryptographically secure.', E_USER_WARNING); } return hash($hash, $str, $rawOutput); }
[ "public", "static", "function", "getUniqid", "(", "$", "hash", "=", "'sha256'", ",", "$", "prefix", "=", "''", ",", "$", "entropy", "=", "10000", ",", "$", "rawOutput", "=", "false", ")", "{", "$", "str", "=", "mt_rand", "(", "~", "PHP_INT_MAX", ",", "PHP_INT_MAX", ")", ".", "json_encode", "(", "[", "$", "_COOKIE", ",", "$", "_REQUEST", ",", "$", "_FILES", ",", "$", "_ENV", ",", "$", "_GET", ",", "$", "_POST", ",", "$", "_SERVER", "]", ")", ".", "uniqid", "(", "$", "prefix", ",", "true", ")", ".", "self", "::", "asciiRand", "(", "$", "entropy", ",", "self", "::", "ASCII_ALL", ")", ";", "if", "(", "function_exists", "(", "'\\openssl_random_pseudo_bytes'", ")", ")", "{", "$", "algoStrong", "=", "null", ";", "$", "str", ".=", "\\", "openssl_random_pseudo_bytes", "(", "$", "entropy", ",", "$", "algoStrong", ")", ";", "if", "(", "$", "algoStrong", "!==", "true", ")", "{", "trigger_error", "(", "'Please update your openssl & PHP libraries. openssl_random_pseudo_bytes was unable'", ".", "' to locate a cryptographically strong algorithm.'", ",", "E_USER_WARNING", ")", ";", "}", "}", "else", "{", "trigger_error", "(", "'The openssl extension is not enabled, therefore the unique ID is not '", ".", "'cryptographically secure.'", ",", "E_USER_WARNING", ")", ";", "}", "return", "hash", "(", "$", "hash", ",", "$", "str", ",", "$", "rawOutput", ")", ";", "}" ]
Generates a unique identifier @author Art <a.molcanovas@gmail.com> @param string $hash Hash algorithm @param string $prefix Prefix for the identifier @param int $entropy Number of pseudo bytes used in entropy @param bool $rawOutput When set to true, outputs raw binary data. false outputs lowercase hexits. @return string @see https://secure.php.net/manual/en/function.hash.php @see https://secure.php.net/manual/en/function.openssl-random-pseudo-bytes.php @since 1.3.3 Default $entropy value set to 10000, a warning is triggered if openssl_random_pseudo_bytes is unable to locate a cryptographically strong algorithm.<br/> 1.3 @codeCoverageIgnore
[ "Generates", "a", "unique", "identifier" ]
484ef76ea5e1b99b2758e5c35c76229572dc27cb
https://github.com/aloframework/common/blob/484ef76ea5e1b99b2758e5c35c76229572dc27cb/src/Alo.php#L230-L256
24,962
aloframework/common
src/Alo.php
Alo.getFingerprint
public static function getFingerprint($hashAlgo = 'sha256') { return hash($hashAlgo, '#QramRAN7*s%6n%@x*53jVVPsnrz@5MY$49o^mhJ8HqY%3a09yJnSWg9lBl$O4CKUb&&S%EgYBjhUZEbhquw$keCjR6I%zMcA!Qr' . self::get($_SERVER['HTTP_USER_AGENT']) . 'OE2%fWaZh4jfZPiNXKmHfUw6ok6Z0s#PInaFa8&o#xh#nVyaFaXHPUcv^2y579PnYr5AOs6Zqb!QTAZCgRR968*%QxKc^XNuYYM8' . self::get($_SERVER['HTTP_DNT']) . '%CwyJJ^GAooDl&o0mc%7zbWlD^6tWoNSN&m3cKxWLP8kiBqO!j2PM5wACzyOoa^t7AEJ#FlDT!BMtD$luy%2iZejMVzktaiftpg*' . self::get($_SERVER['HTTP_ACCEPT_LANGUAGE']) . 'tep!uTwVXk1CedJq0osEI7p&XCxnC3ipGDWEpTXULEg8J!K1NJSxe4GPor$R3OOb**ZjzPN$$SOHe4ZDcQWQULdtT&XxP2!YYxZy'); }
php
public static function getFingerprint($hashAlgo = 'sha256') { return hash($hashAlgo, '#QramRAN7*s%6n%@x*53jVVPsnrz@5MY$49o^mhJ8HqY%3a09yJnSWg9lBl$O4CKUb&&S%EgYBjhUZEbhquw$keCjR6I%zMcA!Qr' . self::get($_SERVER['HTTP_USER_AGENT']) . 'OE2%fWaZh4jfZPiNXKmHfUw6ok6Z0s#PInaFa8&o#xh#nVyaFaXHPUcv^2y579PnYr5AOs6Zqb!QTAZCgRR968*%QxKc^XNuYYM8' . self::get($_SERVER['HTTP_DNT']) . '%CwyJJ^GAooDl&o0mc%7zbWlD^6tWoNSN&m3cKxWLP8kiBqO!j2PM5wACzyOoa^t7AEJ#FlDT!BMtD$luy%2iZejMVzktaiftpg*' . self::get($_SERVER['HTTP_ACCEPT_LANGUAGE']) . 'tep!uTwVXk1CedJq0osEI7p&XCxnC3ipGDWEpTXULEg8J!K1NJSxe4GPor$R3OOb**ZjzPN$$SOHe4ZDcQWQULdtT&XxP2!YYxZy'); }
[ "public", "static", "function", "getFingerprint", "(", "$", "hashAlgo", "=", "'sha256'", ")", "{", "return", "hash", "(", "$", "hashAlgo", ",", "'#QramRAN7*s%6n%@x*53jVVPsnrz@5MY$49o^mhJ8HqY%3a09yJnSWg9lBl$O4CKUb&&S%EgYBjhUZEbhquw$keCjR6I%zMcA!Qr'", ".", "self", "::", "get", "(", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ")", ".", "'OE2%fWaZh4jfZPiNXKmHfUw6ok6Z0s#PInaFa8&o#xh#nVyaFaXHPUcv^2y579PnYr5AOs6Zqb!QTAZCgRR968*%QxKc^XNuYYM8'", ".", "self", "::", "get", "(", "$", "_SERVER", "[", "'HTTP_DNT'", "]", ")", ".", "'%CwyJJ^GAooDl&o0mc%7zbWlD^6tWoNSN&m3cKxWLP8kiBqO!j2PM5wACzyOoa^t7AEJ#FlDT!BMtD$luy%2iZejMVzktaiftpg*'", ".", "self", "::", "get", "(", "$", "_SERVER", "[", "'HTTP_ACCEPT_LANGUAGE'", "]", ")", ".", "'tep!uTwVXk1CedJq0osEI7p&XCxnC3ipGDWEpTXULEg8J!K1NJSxe4GPor$R3OOb**ZjzPN$$SOHe4ZDcQWQULdtT&XxP2!YYxZy'", ")", ";", "}" ]
Returns a hashed browser fingerprint @author Art <a.molcanovas@gmail.com> @param string $hashAlgo Hash algorithm to use @return string @since 1.2
[ "Returns", "a", "hashed", "browser", "fingerprint" ]
484ef76ea5e1b99b2758e5c35c76229572dc27cb
https://github.com/aloframework/common/blob/484ef76ea5e1b99b2758e5c35c76229572dc27cb/src/Alo.php#L388-L397
24,963
aloframework/common
src/Alo.php
Alo.unXss
public static function unXss($input) { if (self::isTraversable($input)) { foreach ($input as &$i) { $i = self::unXss($i); } } elseif (is_scalar($input)) { $input = htmlspecialchars($input, ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE); } return $input; }
php
public static function unXss($input) { if (self::isTraversable($input)) { foreach ($input as &$i) { $i = self::unXss($i); } } elseif (is_scalar($input)) { $input = htmlspecialchars($input, ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE); } return $input; }
[ "public", "static", "function", "unXss", "(", "$", "input", ")", "{", "if", "(", "self", "::", "isTraversable", "(", "$", "input", ")", ")", "{", "foreach", "(", "$", "input", "as", "&", "$", "i", ")", "{", "$", "i", "=", "self", "::", "unXss", "(", "$", "i", ")", ";", "}", "}", "elseif", "(", "is_scalar", "(", "$", "input", ")", ")", "{", "$", "input", "=", "htmlspecialchars", "(", "$", "input", ",", "ENT_QUOTES", "|", "ENT_HTML5", "|", "ENT_SUBSTITUTE", ")", ";", "}", "return", "$", "input", ";", "}" ]
Protects the input from cross-site scripting attacks @author Art <a.molcanovas@gmail.com> @param string|array|Traversable $input The scalar input, or an array/Traversable @return string|array|Traversable The escaped string. If an array or traversable was passed on, the input withall its applicable values escaped. @since 1.3.2 ENT_SUBSTITUTE added<br/> 1.2
[ "Protects", "the", "input", "from", "cross", "-", "site", "scripting", "attacks" ]
484ef76ea5e1b99b2758e5c35c76229572dc27cb
https://github.com/aloframework/common/blob/484ef76ea5e1b99b2758e5c35c76229572dc27cb/src/Alo.php#L425-L435
24,964
mpf-soft/admin-widgets
jqueryfileupload/Uploader.php
Uploader.init
protected function init($config) { parent::init($config); if (!$this->dataUrl) { $this->dataUrl = WebApp::get()->request()->getCurrentURL(); // if dataUrl is not set then current URL will be used; } if ($this->handleRequest) { $this->_handle(); die(); } return true; }
php
protected function init($config) { parent::init($config); if (!$this->dataUrl) { $this->dataUrl = WebApp::get()->request()->getCurrentURL(); // if dataUrl is not set then current URL will be used; } if ($this->handleRequest) { $this->_handle(); die(); } return true; }
[ "protected", "function", "init", "(", "$", "config", ")", "{", "parent", "::", "init", "(", "$", "config", ")", ";", "if", "(", "!", "$", "this", "->", "dataUrl", ")", "{", "$", "this", "->", "dataUrl", "=", "WebApp", "::", "get", "(", ")", "->", "request", "(", ")", "->", "getCurrentURL", "(", ")", ";", "// if dataUrl is not set then current URL will be used;", "}", "if", "(", "$", "this", "->", "handleRequest", ")", "{", "$", "this", "->", "_handle", "(", ")", ";", "die", "(", ")", ";", "}", "return", "true", ";", "}" ]
It will take care of upload and delete requests; @param array $config @return bool @throws \Exception
[ "It", "will", "take", "care", "of", "upload", "and", "delete", "requests", ";" ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/jqueryfileupload/Uploader.php#L127-L138
24,965
mpf-soft/admin-widgets
jqueryfileupload/Uploader.php
Uploader.display
public function display() { $source = str_replace(['{VENDOR}', '{APP_ROOT}'], [LIBS_FOLDER, APP_ROOT], $this->jsSource); $url = AssetsPublisher::get()->publishFolder($source); $events = $this->getJSEvents(); $r = Form::get()->input($this->name . '[]', 'file', null, [ 'id' => $this->id, 'data-url' => $this->dataUrl, 'multiple' => 'multiple', ]) . Html::get()->scriptFile($url . "js/vendor/jquery.ui.widget.js") . Html::get()->scriptFile($url . "js/jquery.iframe-transport.js") . Html::get()->scriptFile($url . "js/jquery.fileupload.js") . Html::get()->script("\$(function () { \$('#{$this->id}').fileupload({ dataType: 'json' " . (isset($this->jsEventsHandlers['fileuploaddone'])?'': ", done: function (e, data) { $.each(data.result.files, function (index, file) { $('<p/>').text(file.name).appendTo($(\"#{$this->resultsId}\")); }); }") . " })$events; });"); if ($this->generateResultsDiv) { $r .= Html::get()->tag("div", "", ["id" => $this->resultsId]); } return $r; }
php
public function display() { $source = str_replace(['{VENDOR}', '{APP_ROOT}'], [LIBS_FOLDER, APP_ROOT], $this->jsSource); $url = AssetsPublisher::get()->publishFolder($source); $events = $this->getJSEvents(); $r = Form::get()->input($this->name . '[]', 'file', null, [ 'id' => $this->id, 'data-url' => $this->dataUrl, 'multiple' => 'multiple', ]) . Html::get()->scriptFile($url . "js/vendor/jquery.ui.widget.js") . Html::get()->scriptFile($url . "js/jquery.iframe-transport.js") . Html::get()->scriptFile($url . "js/jquery.fileupload.js") . Html::get()->script("\$(function () { \$('#{$this->id}').fileupload({ dataType: 'json' " . (isset($this->jsEventsHandlers['fileuploaddone'])?'': ", done: function (e, data) { $.each(data.result.files, function (index, file) { $('<p/>').text(file.name).appendTo($(\"#{$this->resultsId}\")); }); }") . " })$events; });"); if ($this->generateResultsDiv) { $r .= Html::get()->tag("div", "", ["id" => $this->resultsId]); } return $r; }
[ "public", "function", "display", "(", ")", "{", "$", "source", "=", "str_replace", "(", "[", "'{VENDOR}'", ",", "'{APP_ROOT}'", "]", ",", "[", "LIBS_FOLDER", ",", "APP_ROOT", "]", ",", "$", "this", "->", "jsSource", ")", ";", "$", "url", "=", "AssetsPublisher", "::", "get", "(", ")", "->", "publishFolder", "(", "$", "source", ")", ";", "$", "events", "=", "$", "this", "->", "getJSEvents", "(", ")", ";", "$", "r", "=", "Form", "::", "get", "(", ")", "->", "input", "(", "$", "this", "->", "name", ".", "'[]'", ",", "'file'", ",", "null", ",", "[", "'id'", "=>", "$", "this", "->", "id", ",", "'data-url'", "=>", "$", "this", "->", "dataUrl", ",", "'multiple'", "=>", "'multiple'", ",", "]", ")", ".", "Html", "::", "get", "(", ")", "->", "scriptFile", "(", "$", "url", ".", "\"js/vendor/jquery.ui.widget.js\"", ")", ".", "Html", "::", "get", "(", ")", "->", "scriptFile", "(", "$", "url", ".", "\"js/jquery.iframe-transport.js\"", ")", ".", "Html", "::", "get", "(", ")", "->", "scriptFile", "(", "$", "url", ".", "\"js/jquery.fileupload.js\"", ")", ".", "Html", "::", "get", "(", ")", "->", "script", "(", "\"\\$(function () {\n \\$('#{$this->id}').fileupload({\n dataType: 'json' \"", ".", "(", "isset", "(", "$", "this", "->", "jsEventsHandlers", "[", "'fileuploaddone'", "]", ")", "?", "''", ":", "\",\n done: function (e, data) {\n $.each(data.result.files, function (index, file) {\n $('<p/>').text(file.name).appendTo($(\\\"#{$this->resultsId}\\\"));\n });\n }\"", ")", ".", "\"\n })$events;\n});\"", ")", ";", "if", "(", "$", "this", "->", "generateResultsDiv", ")", "{", "$", "r", ".=", "Html", "::", "get", "(", ")", "->", "tag", "(", "\"div\"", ",", "\"\"", ",", "[", "\"id\"", "=>", "$", "this", "->", "resultsId", "]", ")", ";", "}", "return", "$", "r", ";", "}" ]
Returns the HTML code for the element. @return string
[ "Returns", "the", "HTML", "code", "for", "the", "element", "." ]
92597f9a09d086664268d6b7e0111d5a5586d8c7
https://github.com/mpf-soft/admin-widgets/blob/92597f9a09d086664268d6b7e0111d5a5586d8c7/jqueryfileupload/Uploader.php#L183-L209
24,966
stellaqua/Waltz.Stagehand
src/Waltz/Stagehand/ClassUtility/ClassObject/PhpClassObject.php
PhpClassObject.getDocComment
public function getDocComment ( $withCommentMark = false ) { $docComment = $this->_reflectionClass->getDocComment(); if ( $withCommentMark === false ) { $docComment = PhpDocCommentObject::stripCommentMarks($docComment); } return $docComment; }
php
public function getDocComment ( $withCommentMark = false ) { $docComment = $this->_reflectionClass->getDocComment(); if ( $withCommentMark === false ) { $docComment = PhpDocCommentObject::stripCommentMarks($docComment); } return $docComment; }
[ "public", "function", "getDocComment", "(", "$", "withCommentMark", "=", "false", ")", "{", "$", "docComment", "=", "$", "this", "->", "_reflectionClass", "->", "getDocComment", "(", ")", ";", "if", "(", "$", "withCommentMark", "===", "false", ")", "{", "$", "docComment", "=", "PhpDocCommentObject", "::", "stripCommentMarks", "(", "$", "docComment", ")", ";", "}", "return", "$", "docComment", ";", "}" ]
Get DocComment of class @param bool $withCommentMark @return string DocComment
[ "Get", "DocComment", "of", "class" ]
01df286751f5b9a5c90c47138dca3709e5bc383b
https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/ClassUtility/ClassObject/PhpClassObject.php#L77-L83
24,967
fridge-project/dbal
src/Fridge/DBAL/Schema/Column.php
Column.setLength
public function setLength($length) { if (($length !== null) && (!is_int($length) || ($length <= 0))) { throw SchemaException::invalidColumnLength($this->getName()); } $this->length = $length; }
php
public function setLength($length) { if (($length !== null) && (!is_int($length) || ($length <= 0))) { throw SchemaException::invalidColumnLength($this->getName()); } $this->length = $length; }
[ "public", "function", "setLength", "(", "$", "length", ")", "{", "if", "(", "(", "$", "length", "!==", "null", ")", "&&", "(", "!", "is_int", "(", "$", "length", ")", "||", "(", "$", "length", "<=", "0", ")", ")", ")", "{", "throw", "SchemaException", "::", "invalidColumnLength", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "$", "this", "->", "length", "=", "$", "length", ";", "}" ]
Sets the column length. @param integer|null $length The column length. @throws \Fridge\DBAL\Exception\SchemaException If the length is not a positive integer.
[ "Sets", "the", "column", "length", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Column.php#L117-L124
24,968
fridge-project/dbal
src/Fridge/DBAL/Schema/Column.php
Column.setPrecision
public function setPrecision($precision) { if (($precision !== null) && (!is_int($precision) || ($precision <= 0))) { throw SchemaException::invalidColumnPrecision($this->getName()); } $this->precision = $precision; }
php
public function setPrecision($precision) { if (($precision !== null) && (!is_int($precision) || ($precision <= 0))) { throw SchemaException::invalidColumnPrecision($this->getName()); } $this->precision = $precision; }
[ "public", "function", "setPrecision", "(", "$", "precision", ")", "{", "if", "(", "(", "$", "precision", "!==", "null", ")", "&&", "(", "!", "is_int", "(", "$", "precision", ")", "||", "(", "$", "precision", "<=", "0", ")", ")", ")", "{", "throw", "SchemaException", "::", "invalidColumnPrecision", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "$", "this", "->", "precision", "=", "$", "precision", ";", "}" ]
Sets the column precision. @param integer|null $precision The column precision. @throws \Fridge\DBAL\Exception\SchemaException If the precision is not a positive integer.
[ "Sets", "the", "column", "precision", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Column.php#L143-L150
24,969
fridge-project/dbal
src/Fridge/DBAL/Schema/Column.php
Column.setScale
public function setScale($scale) { if (($scale !== null) && (!is_int($scale) || ($scale < 0))) { throw SchemaException::invalidColumnScale($this->getName()); } $this->scale = $scale; }
php
public function setScale($scale) { if (($scale !== null) && (!is_int($scale) || ($scale < 0))) { throw SchemaException::invalidColumnScale($this->getName()); } $this->scale = $scale; }
[ "public", "function", "setScale", "(", "$", "scale", ")", "{", "if", "(", "(", "$", "scale", "!==", "null", ")", "&&", "(", "!", "is_int", "(", "$", "scale", ")", "||", "(", "$", "scale", "<", "0", ")", ")", ")", "{", "throw", "SchemaException", "::", "invalidColumnScale", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "$", "this", "->", "scale", "=", "$", "scale", ";", "}" ]
Sets the column scale. @param integer|null $scale The column scale. @throws \Fridge\DBAL\Exception\SchemaException If the scale is not a positive integer.
[ "Sets", "the", "column", "scale", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Column.php#L169-L176
24,970
fridge-project/dbal
src/Fridge/DBAL/Schema/Column.php
Column.setUnsigned
public function setUnsigned($unsigned) { if (($unsigned !== null) && !is_bool($unsigned)) { throw SchemaException::invalidColumnUnsignedFlag($this->getName()); } $this->unsigned = $unsigned; }
php
public function setUnsigned($unsigned) { if (($unsigned !== null) && !is_bool($unsigned)) { throw SchemaException::invalidColumnUnsignedFlag($this->getName()); } $this->unsigned = $unsigned; }
[ "public", "function", "setUnsigned", "(", "$", "unsigned", ")", "{", "if", "(", "(", "$", "unsigned", "!==", "null", ")", "&&", "!", "is_bool", "(", "$", "unsigned", ")", ")", "{", "throw", "SchemaException", "::", "invalidColumnUnsignedFlag", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "$", "this", "->", "unsigned", "=", "$", "unsigned", ";", "}" ]
Sets the column unsigned flag. @param boolean|null $unsigned The column unsigned flag. @throws \Fridge\DBAL\Exception\SchemaException If the unsigned flag is not a boolean.
[ "Sets", "the", "column", "unsigned", "flag", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Column.php#L195-L202
24,971
fridge-project/dbal
src/Fridge/DBAL/Schema/Column.php
Column.setFixed
public function setFixed($fixed) { if (($fixed !== null) && !is_bool($fixed)) { throw SchemaException::invalidColumnFixedFlag($this->getName()); } $this->fixed = $fixed; }
php
public function setFixed($fixed) { if (($fixed !== null) && !is_bool($fixed)) { throw SchemaException::invalidColumnFixedFlag($this->getName()); } $this->fixed = $fixed; }
[ "public", "function", "setFixed", "(", "$", "fixed", ")", "{", "if", "(", "(", "$", "fixed", "!==", "null", ")", "&&", "!", "is_bool", "(", "$", "fixed", ")", ")", "{", "throw", "SchemaException", "::", "invalidColumnFixedFlag", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "$", "this", "->", "fixed", "=", "$", "fixed", ";", "}" ]
Sets the column fixed flag. @param boolean $fixed The column fixed flag. @throws \Fridge\DBAL\Exception\SchemaException If the fixed flag is not a boolean.
[ "Sets", "the", "column", "fixed", "flag", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Column.php#L221-L228
24,972
fridge-project/dbal
src/Fridge/DBAL/Schema/Column.php
Column.setNotNull
public function setNotNull($notNull) { if (($notNull !== null) && !is_bool($notNull)) { throw SchemaException::invalidColumnNotNullFlag($this->getName()); } $this->notNull = $notNull; }
php
public function setNotNull($notNull) { if (($notNull !== null) && !is_bool($notNull)) { throw SchemaException::invalidColumnNotNullFlag($this->getName()); } $this->notNull = $notNull; }
[ "public", "function", "setNotNull", "(", "$", "notNull", ")", "{", "if", "(", "(", "$", "notNull", "!==", "null", ")", "&&", "!", "is_bool", "(", "$", "notNull", ")", ")", "{", "throw", "SchemaException", "::", "invalidColumnNotNullFlag", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "$", "this", "->", "notNull", "=", "$", "notNull", ";", "}" ]
Sets the column not null flag. @param boolean|null $notNull The column not null flag. @throws \Fridge\DBAL\Exception\SchemaException If the not null flag is not a boolean.
[ "Sets", "the", "column", "not", "null", "flag", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Column.php#L247-L254
24,973
fridge-project/dbal
src/Fridge/DBAL/Schema/Column.php
Column.setAutoIncrement
public function setAutoIncrement($autoIncrement) { if (($autoIncrement !== null) && !is_bool($autoIncrement)) { throw SchemaException::invalidColumnAutoIncrementFlag($this->getName()); } $this->autoIncrement = $autoIncrement; }
php
public function setAutoIncrement($autoIncrement) { if (($autoIncrement !== null) && !is_bool($autoIncrement)) { throw SchemaException::invalidColumnAutoIncrementFlag($this->getName()); } $this->autoIncrement = $autoIncrement; }
[ "public", "function", "setAutoIncrement", "(", "$", "autoIncrement", ")", "{", "if", "(", "(", "$", "autoIncrement", "!==", "null", ")", "&&", "!", "is_bool", "(", "$", "autoIncrement", ")", ")", "{", "throw", "SchemaException", "::", "invalidColumnAutoIncrementFlag", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "$", "this", "->", "autoIncrement", "=", "$", "autoIncrement", ";", "}" ]
Sets the column auto increment flag. @param boolean|null $autoIncrement The column auto increment flag. @throws \Fridge\DBAL\Exception\SchemaException If the auto increment flag is not a boolean.
[ "Sets", "the", "column", "auto", "increment", "flag", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Column.php#L293-L300
24,974
fridge-project/dbal
src/Fridge/DBAL/Schema/Column.php
Column.setComment
public function setComment($comment) { if (($comment !== null) && !is_string($comment)) { throw SchemaException::invalidColumnComment($this->getName()); } $this->comment = $comment; }
php
public function setComment($comment) { if (($comment !== null) && !is_string($comment)) { throw SchemaException::invalidColumnComment($this->getName()); } $this->comment = $comment; }
[ "public", "function", "setComment", "(", "$", "comment", ")", "{", "if", "(", "(", "$", "comment", "!==", "null", ")", "&&", "!", "is_string", "(", "$", "comment", ")", ")", "{", "throw", "SchemaException", "::", "invalidColumnComment", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "$", "this", "->", "comment", "=", "$", "comment", ";", "}" ]
Sets the column comment. @param string|null $comment The column comment. @throws \Fridge\DBAL\Exception\SchemaException If the comment is not a string.
[ "Sets", "the", "column", "comment", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Column.php#L319-L326
24,975
fridge-project/dbal
src/Fridge/DBAL/Schema/Column.php
Column.setProperties
public function setProperties(array $properties) { foreach ($properties as $property => $value) { $method = sprintf('set%s', str_replace('_', '', $property)); if (!method_exists($this, $method)) { throw SchemaException::invalidColumnProperty($this->getName(), $property); } $this->$method($value); } }
php
public function setProperties(array $properties) { foreach ($properties as $property => $value) { $method = sprintf('set%s', str_replace('_', '', $property)); if (!method_exists($this, $method)) { throw SchemaException::invalidColumnProperty($this->getName(), $property); } $this->$method($value); } }
[ "public", "function", "setProperties", "(", "array", "$", "properties", ")", "{", "foreach", "(", "$", "properties", "as", "$", "property", "=>", "$", "value", ")", "{", "$", "method", "=", "sprintf", "(", "'set%s'", ",", "str_replace", "(", "'_'", ",", "''", ",", "$", "property", ")", ")", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "throw", "SchemaException", "::", "invalidColumnProperty", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "property", ")", ";", "}", "$", "this", "->", "$", "method", "(", "$", "value", ")", ";", "}", "}" ]
Sets the column options. @param array $properties Associative array that describes property => value pairs. @throws \Fridge\DBAL\Exception\SchemaException If the property does not exist.
[ "Sets", "the", "column", "options", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Column.php#L335-L346
24,976
fridge-project/dbal
src/Fridge/DBAL/Schema/Column.php
Column.toArray
public function toArray() { return array( 'name' => $this->getName(), 'type' => $this->getType()->getName(), 'length' => $this->getLength(), 'precision' => $this->getPrecision(), 'scale' => $this->getScale(), 'unsigned' => $this->isUnsigned(), 'fixed' => $this->isFixed(), 'not_null' => $this->isNotNull(), 'default' => $this->getDefault(), 'auto_increment' => $this->isAutoIncrement(), 'comment' => $this->getComment(), ); }
php
public function toArray() { return array( 'name' => $this->getName(), 'type' => $this->getType()->getName(), 'length' => $this->getLength(), 'precision' => $this->getPrecision(), 'scale' => $this->getScale(), 'unsigned' => $this->isUnsigned(), 'fixed' => $this->isFixed(), 'not_null' => $this->isNotNull(), 'default' => $this->getDefault(), 'auto_increment' => $this->isAutoIncrement(), 'comment' => $this->getComment(), ); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array", "(", "'name'", "=>", "$", "this", "->", "getName", "(", ")", ",", "'type'", "=>", "$", "this", "->", "getType", "(", ")", "->", "getName", "(", ")", ",", "'length'", "=>", "$", "this", "->", "getLength", "(", ")", ",", "'precision'", "=>", "$", "this", "->", "getPrecision", "(", ")", ",", "'scale'", "=>", "$", "this", "->", "getScale", "(", ")", ",", "'unsigned'", "=>", "$", "this", "->", "isUnsigned", "(", ")", ",", "'fixed'", "=>", "$", "this", "->", "isFixed", "(", ")", ",", "'not_null'", "=>", "$", "this", "->", "isNotNull", "(", ")", ",", "'default'", "=>", "$", "this", "->", "getDefault", "(", ")", ",", "'auto_increment'", "=>", "$", "this", "->", "isAutoIncrement", "(", ")", ",", "'comment'", "=>", "$", "this", "->", "getComment", "(", ")", ",", ")", ";", "}" ]
Converts a column to an array. @return array The column converted to an array.
[ "Converts", "a", "column", "to", "an", "array", "." ]
d0b8c3551922d696836487aa0eb1bd74014edcd4
https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Column.php#L353-L368
24,977
eureka-framework/component-controller
src/Controller/DataCollection.php
DataCollection.add
public function add($key, $value) { $this->collection[$key] = $value; $this->indices[$this->length] = $key; $this->length++; return $this; }
php
public function add($key, $value) { $this->collection[$key] = $value; $this->indices[$this->length] = $key; $this->length++; return $this; }
[ "public", "function", "add", "(", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "collection", "[", "$", "key", "]", "=", "$", "value", ";", "$", "this", "->", "indices", "[", "$", "this", "->", "length", "]", "=", "$", "key", ";", "$", "this", "->", "length", "++", ";", "return", "$", "this", ";", "}" ]
Add data to the collection. @param string $key @param mixed $value @return self
[ "Add", "data", "to", "the", "collection", "." ]
368efb6fb9eece4f7f69233e6190e1fdbb0ace2c
https://github.com/eureka-framework/component-controller/blob/368efb6fb9eece4f7f69233e6190e1fdbb0ace2c/src/Controller/DataCollection.php#L54-L61
24,978
SagittariusX/Beluga.Core
src/Beluga/Type.php
Type.getPhpCode
public final function getPhpCode() : string { $str = $this->stringValue; switch ( $this->typeName ) { case Type::PHP_BOOLEAN: case 'boolean': return ( $this->value ? 'true' : 'false' ); case Type::PHP_DOUBLE: case Type::PHP_FLOAT: case Type::PHP_INTEGER: case 'integer': return $str; case Type::PHP_STRING: if ( \preg_match( "~[\r\n\t]+~", $str ) ) { $str = \str_replace( array( '\\', "\r", "\n", "\t", "\0", '"', '$' ), array( '\\\\','\\r','\\n','\\t','\\0','\\"','\\$' ), $str ); return '"' . $str . '"'; } return "'" . \str_replace( array( '\\', "'" ), array( '\\\\', "\\'" ), $str ) . "'"; case Type::PHP_RESOURCE: case Type::PHP_NULL: case Type::PHP_UNKNOWN: return 'null'; default: $str = \serialize( $this->value ); if ( \preg_match( "~[\r\n\t]+~", $str ) ) { $str = \str_replace( array( '\\', "\r", "\n", "\t", "\0", '"', '$' ), array( '\\\\','\\r','\\n','\\t','\\0','\\"','\\$' ), $str ); } else { $str = \str_replace( array('\\', '"', '$'), array('\\\\', '\\"', '\\$'), $str ); } return '\unserialize("' . $str . '")'; } }
php
public final function getPhpCode() : string { $str = $this->stringValue; switch ( $this->typeName ) { case Type::PHP_BOOLEAN: case 'boolean': return ( $this->value ? 'true' : 'false' ); case Type::PHP_DOUBLE: case Type::PHP_FLOAT: case Type::PHP_INTEGER: case 'integer': return $str; case Type::PHP_STRING: if ( \preg_match( "~[\r\n\t]+~", $str ) ) { $str = \str_replace( array( '\\', "\r", "\n", "\t", "\0", '"', '$' ), array( '\\\\','\\r','\\n','\\t','\\0','\\"','\\$' ), $str ); return '"' . $str . '"'; } return "'" . \str_replace( array( '\\', "'" ), array( '\\\\', "\\'" ), $str ) . "'"; case Type::PHP_RESOURCE: case Type::PHP_NULL: case Type::PHP_UNKNOWN: return 'null'; default: $str = \serialize( $this->value ); if ( \preg_match( "~[\r\n\t]+~", $str ) ) { $str = \str_replace( array( '\\', "\r", "\n", "\t", "\0", '"', '$' ), array( '\\\\','\\r','\\n','\\t','\\0','\\"','\\$' ), $str ); } else { $str = \str_replace( array('\\', '"', '$'), array('\\\\', '\\"', '\\$'), $str ); } return '\unserialize("' . $str . '")'; } }
[ "public", "final", "function", "getPhpCode", "(", ")", ":", "string", "{", "$", "str", "=", "$", "this", "->", "stringValue", ";", "switch", "(", "$", "this", "->", "typeName", ")", "{", "case", "Type", "::", "PHP_BOOLEAN", ":", "case", "'boolean'", ":", "return", "(", "$", "this", "->", "value", "?", "'true'", ":", "'false'", ")", ";", "case", "Type", "::", "PHP_DOUBLE", ":", "case", "Type", "::", "PHP_FLOAT", ":", "case", "Type", "::", "PHP_INTEGER", ":", "case", "'integer'", ":", "return", "$", "str", ";", "case", "Type", "::", "PHP_STRING", ":", "if", "(", "\\", "preg_match", "(", "\"~[\\r\\n\\t]+~\"", ",", "$", "str", ")", ")", "{", "$", "str", "=", "\\", "str_replace", "(", "array", "(", "'\\\\'", ",", "\"\\r\"", ",", "\"\\n\"", ",", "\"\\t\"", ",", "\"\\0\"", ",", "'\"'", ",", "'$'", ")", ",", "array", "(", "'\\\\\\\\'", ",", "'\\\\r'", ",", "'\\\\n'", ",", "'\\\\t'", ",", "'\\\\0'", ",", "'\\\\\"'", ",", "'\\\\$'", ")", ",", "$", "str", ")", ";", "return", "'\"'", ".", "$", "str", ".", "'\"'", ";", "}", "return", "\"'\"", ".", "\\", "str_replace", "(", "array", "(", "'\\\\'", ",", "\"'\"", ")", ",", "array", "(", "'\\\\\\\\'", ",", "\"\\\\'\"", ")", ",", "$", "str", ")", ".", "\"'\"", ";", "case", "Type", "::", "PHP_RESOURCE", ":", "case", "Type", "::", "PHP_NULL", ":", "case", "Type", "::", "PHP_UNKNOWN", ":", "return", "'null'", ";", "default", ":", "$", "str", "=", "\\", "serialize", "(", "$", "this", "->", "value", ")", ";", "if", "(", "\\", "preg_match", "(", "\"~[\\r\\n\\t]+~\"", ",", "$", "str", ")", ")", "{", "$", "str", "=", "\\", "str_replace", "(", "array", "(", "'\\\\'", ",", "\"\\r\"", ",", "\"\\n\"", ",", "\"\\t\"", ",", "\"\\0\"", ",", "'\"'", ",", "'$'", ")", ",", "array", "(", "'\\\\\\\\'", ",", "'\\\\r'", ",", "'\\\\n'", ",", "'\\\\t'", ",", "'\\\\0'", ",", "'\\\\\"'", ",", "'\\\\$'", ")", ",", "$", "str", ")", ";", "}", "else", "{", "$", "str", "=", "\\", "str_replace", "(", "array", "(", "'\\\\'", ",", "'\"'", ",", "'$'", ")", ",", "array", "(", "'\\\\\\\\'", ",", "'\\\\\"'", ",", "'\\\\$'", ")", ",", "$", "str", ")", ";", "}", "return", "'\\unserialize(\"'", ".", "$", "str", ".", "'\")'", ";", "}", "}" ]
Returns the PHP code, defining the current base value. @return string
[ "Returns", "the", "PHP", "code", "defining", "the", "current", "base", "value", "." ]
51057b362707157a4b075df42bb49f397e2d310b
https://github.com/SagittariusX/Beluga.Core/blob/51057b362707157a4b075df42bb49f397e2d310b/src/Beluga/Type.php#L298-L359
24,979
Linkvalue-Interne/MajoraOrientDBBundle
src/Majora/Component/Graph/Engine/OrientDbEngine.php
OrientDbEngine.registerConnection
public function registerConnection($name, array $configuration) { $this->configurations->set($name, new OrientDbMetadata( $configuration['host'], $configuration['port'], $configuration['timeout'], $configuration['user'], $configuration['password'], $configuration['database'], $configuration['data_type'], $configuration['storage_type'] )); }
php
public function registerConnection($name, array $configuration) { $this->configurations->set($name, new OrientDbMetadata( $configuration['host'], $configuration['port'], $configuration['timeout'], $configuration['user'], $configuration['password'], $configuration['database'], $configuration['data_type'], $configuration['storage_type'] )); }
[ "public", "function", "registerConnection", "(", "$", "name", ",", "array", "$", "configuration", ")", "{", "$", "this", "->", "configurations", "->", "set", "(", "$", "name", ",", "new", "OrientDbMetadata", "(", "$", "configuration", "[", "'host'", "]", ",", "$", "configuration", "[", "'port'", "]", ",", "$", "configuration", "[", "'timeout'", "]", ",", "$", "configuration", "[", "'user'", "]", ",", "$", "configuration", "[", "'password'", "]", ",", "$", "configuration", "[", "'database'", "]", ",", "$", "configuration", "[", "'data_type'", "]", ",", "$", "configuration", "[", "'storage_type'", "]", ")", ")", ";", "}" ]
Register a new OrientDB connection under given name @param string $name
[ "Register", "a", "new", "OrientDB", "connection", "under", "given", "name" ]
9fc9a409604472b558319c274442f75bbd055435
https://github.com/Linkvalue-Interne/MajoraOrientDBBundle/blob/9fc9a409604472b558319c274442f75bbd055435/src/Majora/Component/Graph/Engine/OrientDbEngine.php#L44-L56
24,980
Linkvalue-Interne/MajoraOrientDBBundle
src/Majora/Component/Graph/Engine/OrientDbEngine.php
OrientDbEngine.getConfiguration
public function getConfiguration($connectionName = 'default') { if (!$this->configurations->containsKey($connectionName)) { throw new \InvalidArgumentException(sprintf('Any registered configuration under given key.')); } return $this->configurations->get($connectionName); }
php
public function getConfiguration($connectionName = 'default') { if (!$this->configurations->containsKey($connectionName)) { throw new \InvalidArgumentException(sprintf('Any registered configuration under given key.')); } return $this->configurations->get($connectionName); }
[ "public", "function", "getConfiguration", "(", "$", "connectionName", "=", "'default'", ")", "{", "if", "(", "!", "$", "this", "->", "configurations", "->", "containsKey", "(", "$", "connectionName", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Any registered configuration under given key.'", ")", ")", ";", "}", "return", "$", "this", "->", "configurations", "->", "get", "(", "$", "connectionName", ")", ";", "}" ]
Return registered configuration under given connectionName @param string $connectionName @return OrientDbMetadata
[ "Return", "registered", "configuration", "under", "given", "connectionName" ]
9fc9a409604472b558319c274442f75bbd055435
https://github.com/Linkvalue-Interne/MajoraOrientDBBundle/blob/9fc9a409604472b558319c274442f75bbd055435/src/Majora/Component/Graph/Engine/OrientDbEngine.php#L76-L83
24,981
Linkvalue-Interne/MajoraOrientDBBundle
src/Majora/Component/Graph/Engine/OrientDbEngine.php
OrientDbEngine.getConnection
public function getConnection($connectionName = 'default') { if ($this->connections->containsKey($connectionName)) { return $this->connections->get($connectionName); } $configuration = $this->getConfiguration($connectionName); $this->connections->set($connectionName, $database = (new \OrientDB( $configuration->getHost(), $configuration->getPort(), $configuration->getTimeout() )) ); $database->connect( $configuration->getUser(), $configuration->getPassword() ); return $database; }
php
public function getConnection($connectionName = 'default') { if ($this->connections->containsKey($connectionName)) { return $this->connections->get($connectionName); } $configuration = $this->getConfiguration($connectionName); $this->connections->set($connectionName, $database = (new \OrientDB( $configuration->getHost(), $configuration->getPort(), $configuration->getTimeout() )) ); $database->connect( $configuration->getUser(), $configuration->getPassword() ); return $database; }
[ "public", "function", "getConnection", "(", "$", "connectionName", "=", "'default'", ")", "{", "if", "(", "$", "this", "->", "connections", "->", "containsKey", "(", "$", "connectionName", ")", ")", "{", "return", "$", "this", "->", "connections", "->", "get", "(", "$", "connectionName", ")", ";", "}", "$", "configuration", "=", "$", "this", "->", "getConfiguration", "(", "$", "connectionName", ")", ";", "$", "this", "->", "connections", "->", "set", "(", "$", "connectionName", ",", "$", "database", "=", "(", "new", "\\", "OrientDB", "(", "$", "configuration", "->", "getHost", "(", ")", ",", "$", "configuration", "->", "getPort", "(", ")", ",", "$", "configuration", "->", "getTimeout", "(", ")", ")", ")", ")", ";", "$", "database", "->", "connect", "(", "$", "configuration", "->", "getUser", "(", ")", ",", "$", "configuration", "->", "getPassword", "(", ")", ")", ";", "return", "$", "database", ";", "}" ]
Return registered connection under given connectionName @param string $connectionName @return \OrientDB
[ "Return", "registered", "connection", "under", "given", "connectionName" ]
9fc9a409604472b558319c274442f75bbd055435
https://github.com/Linkvalue-Interne/MajoraOrientDBBundle/blob/9fc9a409604472b558319c274442f75bbd055435/src/Majora/Component/Graph/Engine/OrientDbEngine.php#L92-L113
24,982
Linkvalue-Interne/MajoraOrientDBBundle
src/Majora/Component/Graph/Engine/OrientDbEngine.php
OrientDbEngine.createDatabase
public function createDatabase($connectionName) { $configuration = $this->getConfiguration($connectionName); $database = $this->getConnection($connectionName); $database->DBCreate( $configuration->getDatabase(), $configuration->getDataType(), $configuration->getStorageType() ); return $this->getDatabase($connectionName); }
php
public function createDatabase($connectionName) { $configuration = $this->getConfiguration($connectionName); $database = $this->getConnection($connectionName); $database->DBCreate( $configuration->getDatabase(), $configuration->getDataType(), $configuration->getStorageType() ); return $this->getDatabase($connectionName); }
[ "public", "function", "createDatabase", "(", "$", "connectionName", ")", "{", "$", "configuration", "=", "$", "this", "->", "getConfiguration", "(", "$", "connectionName", ")", ";", "$", "database", "=", "$", "this", "->", "getConnection", "(", "$", "connectionName", ")", ";", "$", "database", "->", "DBCreate", "(", "$", "configuration", "->", "getDatabase", "(", ")", ",", "$", "configuration", "->", "getDataType", "(", ")", ",", "$", "configuration", "->", "getStorageType", "(", ")", ")", ";", "return", "$", "this", "->", "getDatabase", "(", "$", "connectionName", ")", ";", "}" ]
Tries to create a database for given connection name @param string $name @return \OrientDB
[ "Tries", "to", "create", "a", "database", "for", "given", "connection", "name" ]
9fc9a409604472b558319c274442f75bbd055435
https://github.com/Linkvalue-Interne/MajoraOrientDBBundle/blob/9fc9a409604472b558319c274442f75bbd055435/src/Majora/Component/Graph/Engine/OrientDbEngine.php#L122-L134
24,983
Linkvalue-Interne/MajoraOrientDBBundle
src/Majora/Component/Graph/Engine/OrientDbEngine.php
OrientDbEngine.dropDatabase
public function dropDatabase($connectionName) { $configuration = $this->getConfiguration($connectionName); $database = $this->getConnection($connectionName); $database->DBDelete( $configuration->getDatabase() ); }
php
public function dropDatabase($connectionName) { $configuration = $this->getConfiguration($connectionName); $database = $this->getConnection($connectionName); $database->DBDelete( $configuration->getDatabase() ); }
[ "public", "function", "dropDatabase", "(", "$", "connectionName", ")", "{", "$", "configuration", "=", "$", "this", "->", "getConfiguration", "(", "$", "connectionName", ")", ";", "$", "database", "=", "$", "this", "->", "getConnection", "(", "$", "connectionName", ")", ";", "$", "database", "->", "DBDelete", "(", "$", "configuration", "->", "getDatabase", "(", ")", ")", ";", "}" ]
Tries to drop a database for given connection name @param string $name @return \OrientDB
[ "Tries", "to", "drop", "a", "database", "for", "given", "connection", "name" ]
9fc9a409604472b558319c274442f75bbd055435
https://github.com/Linkvalue-Interne/MajoraOrientDBBundle/blob/9fc9a409604472b558319c274442f75bbd055435/src/Majora/Component/Graph/Engine/OrientDbEngine.php#L143-L151
24,984
Linkvalue-Interne/MajoraOrientDBBundle
src/Majora/Component/Graph/Engine/OrientDbEngine.php
OrientDbEngine.getDatabase
public function getDatabase($connectionName = 'default') { if ($this->databases->containsKey($connectionName)) { return $this->databases->get($connectionName); } $configuration = $this->getConfiguration($connectionName); $database = $this->getConnection($connectionName); $database->DBOpen( $configuration->getDatabase(), $configuration->getUser(), $configuration->getPassword() ); $this->databases->set($connectionName, $database); return $this->databases->get($connectionName); }
php
public function getDatabase($connectionName = 'default') { if ($this->databases->containsKey($connectionName)) { return $this->databases->get($connectionName); } $configuration = $this->getConfiguration($connectionName); $database = $this->getConnection($connectionName); $database->DBOpen( $configuration->getDatabase(), $configuration->getUser(), $configuration->getPassword() ); $this->databases->set($connectionName, $database); return $this->databases->get($connectionName); }
[ "public", "function", "getDatabase", "(", "$", "connectionName", "=", "'default'", ")", "{", "if", "(", "$", "this", "->", "databases", "->", "containsKey", "(", "$", "connectionName", ")", ")", "{", "return", "$", "this", "->", "databases", "->", "get", "(", "$", "connectionName", ")", ";", "}", "$", "configuration", "=", "$", "this", "->", "getConfiguration", "(", "$", "connectionName", ")", ";", "$", "database", "=", "$", "this", "->", "getConnection", "(", "$", "connectionName", ")", ";", "$", "database", "->", "DBOpen", "(", "$", "configuration", "->", "getDatabase", "(", ")", ",", "$", "configuration", "->", "getUser", "(", ")", ",", "$", "configuration", "->", "getPassword", "(", ")", ")", ";", "$", "this", "->", "databases", "->", "set", "(", "$", "connectionName", ",", "$", "database", ")", ";", "return", "$", "this", "->", "databases", "->", "get", "(", "$", "connectionName", ")", ";", "}" ]
Return registered database under given name @param string $connectionName @return \OrientDB
[ "Return", "registered", "database", "under", "given", "name" ]
9fc9a409604472b558319c274442f75bbd055435
https://github.com/Linkvalue-Interne/MajoraOrientDBBundle/blob/9fc9a409604472b558319c274442f75bbd055435/src/Majora/Component/Graph/Engine/OrientDbEngine.php#L160-L178
24,985
Linkvalue-Interne/MajoraOrientDBBundle
src/Majora/Component/Graph/Engine/OrientDbEngine.php
OrientDbEngine.synchronize
public function synchronize($connectionName) { $configuration = $this->getConfiguration($connectionName); $database = $this->getDatabase($connectionName); foreach ($configuration->getVertexes() as $vertex) { try { $database->query(sprintf('CREATE CLASS %s EXTENDS V', $vertex->getName() )); $database->query(sprintf('DISPLAY RECORD 0', $vertex->getName() )); dump($res); die; } catch (\Exception $e) { if (preg_match(sprintf('/Class %s already exists in current database$/', $vertex->getName()), $e->getMessage())) { continue; } throw $e; } } }
php
public function synchronize($connectionName) { $configuration = $this->getConfiguration($connectionName); $database = $this->getDatabase($connectionName); foreach ($configuration->getVertexes() as $vertex) { try { $database->query(sprintf('CREATE CLASS %s EXTENDS V', $vertex->getName() )); $database->query(sprintf('DISPLAY RECORD 0', $vertex->getName() )); dump($res); die; } catch (\Exception $e) { if (preg_match(sprintf('/Class %s already exists in current database$/', $vertex->getName()), $e->getMessage())) { continue; } throw $e; } } }
[ "public", "function", "synchronize", "(", "$", "connectionName", ")", "{", "$", "configuration", "=", "$", "this", "->", "getConfiguration", "(", "$", "connectionName", ")", ";", "$", "database", "=", "$", "this", "->", "getDatabase", "(", "$", "connectionName", ")", ";", "foreach", "(", "$", "configuration", "->", "getVertexes", "(", ")", "as", "$", "vertex", ")", "{", "try", "{", "$", "database", "->", "query", "(", "sprintf", "(", "'CREATE CLASS %s EXTENDS V'", ",", "$", "vertex", "->", "getName", "(", ")", ")", ")", ";", "$", "database", "->", "query", "(", "sprintf", "(", "'DISPLAY RECORD 0'", ",", "$", "vertex", "->", "getName", "(", ")", ")", ")", ";", "dump", "(", "$", "res", ")", ";", "die", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "if", "(", "preg_match", "(", "sprintf", "(", "'/Class %s already exists in current database$/'", ",", "$", "vertex", "->", "getName", "(", ")", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", "{", "continue", ";", "}", "throw", "$", "e", ";", "}", "}", "}" ]
Synchronize vertexes and edges with related OrientDb database @param string $connectionName
[ "Synchronize", "vertexes", "and", "edges", "with", "related", "OrientDb", "database" ]
9fc9a409604472b558319c274442f75bbd055435
https://github.com/Linkvalue-Interne/MajoraOrientDBBundle/blob/9fc9a409604472b558319c274442f75bbd055435/src/Majora/Component/Graph/Engine/OrientDbEngine.php#L185-L207
24,986
1HappyPlace/ansi-terminal
src/ANSI/EscapeSequenceGenerator.php
EscapeSequenceGenerator.generateSequence
public function generateSequence(TerminalState $state, $reset) { // this will return null if there are no active styles $sequence = ""; // build an array of the currently active style codes $styles = []; if ($state->isBold()) {$styles[] = self::BOLD;} if ($state->isUnderscore()) {$styles[] = self::UNDERSCORE;} if ($state->getTextColor()->isValid()) {$styles[] = $state->getTextColor()->generateColorCoding($this->mode);} if ($state->getFillColor()->isValid()) {$styles[] = $state->getFillColor()->generateColorCoding($this->mode, true);} // if there is anything in the style array if (count($styles)) { // start the sequence with the control sequence introducer and a clear code $sequence = self::CSI; // if a reset was desired if ($reset) { // add the clear code $sequence .= self::CLEAR . ";"; } // go through the array of style codes for ($i = 0; $i < count($styles); ++$i) { // append the code $sequence .= $styles[$i]; // ensure this is not the last code if ($i < (count($styles) - 1)) { // add the semi-colon separator (but not after the last one) $sequence .= ";"; } } // append the closing sequence $sequence .= self::CSE; } else { // if nothing is changing, only need to send something if the reset was requested if ($reset) { // it may be that just one thing is turning off, send the clear code $sequence .= self::generateClearSequence(); } } return $sequence; }
php
public function generateSequence(TerminalState $state, $reset) { // this will return null if there are no active styles $sequence = ""; // build an array of the currently active style codes $styles = []; if ($state->isBold()) {$styles[] = self::BOLD;} if ($state->isUnderscore()) {$styles[] = self::UNDERSCORE;} if ($state->getTextColor()->isValid()) {$styles[] = $state->getTextColor()->generateColorCoding($this->mode);} if ($state->getFillColor()->isValid()) {$styles[] = $state->getFillColor()->generateColorCoding($this->mode, true);} // if there is anything in the style array if (count($styles)) { // start the sequence with the control sequence introducer and a clear code $sequence = self::CSI; // if a reset was desired if ($reset) { // add the clear code $sequence .= self::CLEAR . ";"; } // go through the array of style codes for ($i = 0; $i < count($styles); ++$i) { // append the code $sequence .= $styles[$i]; // ensure this is not the last code if ($i < (count($styles) - 1)) { // add the semi-colon separator (but not after the last one) $sequence .= ";"; } } // append the closing sequence $sequence .= self::CSE; } else { // if nothing is changing, only need to send something if the reset was requested if ($reset) { // it may be that just one thing is turning off, send the clear code $sequence .= self::generateClearSequence(); } } return $sequence; }
[ "public", "function", "generateSequence", "(", "TerminalState", "$", "state", ",", "$", "reset", ")", "{", "// this will return null if there are no active styles", "$", "sequence", "=", "\"\"", ";", "// build an array of the currently active style codes", "$", "styles", "=", "[", "]", ";", "if", "(", "$", "state", "->", "isBold", "(", ")", ")", "{", "$", "styles", "[", "]", "=", "self", "::", "BOLD", ";", "}", "if", "(", "$", "state", "->", "isUnderscore", "(", ")", ")", "{", "$", "styles", "[", "]", "=", "self", "::", "UNDERSCORE", ";", "}", "if", "(", "$", "state", "->", "getTextColor", "(", ")", "->", "isValid", "(", ")", ")", "{", "$", "styles", "[", "]", "=", "$", "state", "->", "getTextColor", "(", ")", "->", "generateColorCoding", "(", "$", "this", "->", "mode", ")", ";", "}", "if", "(", "$", "state", "->", "getFillColor", "(", ")", "->", "isValid", "(", ")", ")", "{", "$", "styles", "[", "]", "=", "$", "state", "->", "getFillColor", "(", ")", "->", "generateColorCoding", "(", "$", "this", "->", "mode", ",", "true", ")", ";", "}", "// if there is anything in the style array", "if", "(", "count", "(", "$", "styles", ")", ")", "{", "// start the sequence with the control sequence introducer and a clear code", "$", "sequence", "=", "self", "::", "CSI", ";", "// if a reset was desired", "if", "(", "$", "reset", ")", "{", "// add the clear code", "$", "sequence", ".=", "self", "::", "CLEAR", ".", "\";\"", ";", "}", "// go through the array of style codes", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "styles", ")", ";", "++", "$", "i", ")", "{", "// append the code", "$", "sequence", ".=", "$", "styles", "[", "$", "i", "]", ";", "// ensure this is not the last code", "if", "(", "$", "i", "<", "(", "count", "(", "$", "styles", ")", "-", "1", ")", ")", "{", "// add the semi-colon separator (but not after the last one)", "$", "sequence", ".=", "\";\"", ";", "}", "}", "// append the closing sequence", "$", "sequence", ".=", "self", "::", "CSE", ";", "}", "else", "{", "// if nothing is changing, only need to send something if the reset was requested", "if", "(", "$", "reset", ")", "{", "// it may be that just one thing is turning off, send the clear code", "$", "sequence", ".=", "self", "::", "generateClearSequence", "(", ")", ";", "}", "}", "return", "$", "sequence", ";", "}" ]
Generate the escape sequencing for a particular state @param TerminalState $state - the state to achieve @param boolean $reset - whether the zero reset code needs to start this sequence @return string
[ "Generate", "the", "escape", "sequencing", "for", "a", "particular", "state" ]
3a550eadb21bb87a6909436c3b961919d2731923
https://github.com/1HappyPlace/ansi-terminal/blob/3a550eadb21bb87a6909436c3b961919d2731923/src/ANSI/EscapeSequenceGenerator.php#L197-L253
24,987
1HappyPlace/ansi-terminal
src/ANSI/EscapeSequenceGenerator.php
EscapeSequenceGenerator.generate
public function generate(TerminalStateInterface $currentState, TerminalState $desiredState) { // get a state object with anything that is changing $changes = $currentState->findChanges($desiredState); // if an object is returned, then just positive changes are occurring if ($changes) { // if there are really no changes if ($changes->isClear()) { // return an empty string return ""; // there are some changes } else { // generate the sequence for the things that are actually changing return $this->generateSequence($changes, false); } // if null is returned, then something is getting turned off } else { // must generate a sequence with a clear return $this->generateSequence($desiredState, true); } }
php
public function generate(TerminalStateInterface $currentState, TerminalState $desiredState) { // get a state object with anything that is changing $changes = $currentState->findChanges($desiredState); // if an object is returned, then just positive changes are occurring if ($changes) { // if there are really no changes if ($changes->isClear()) { // return an empty string return ""; // there are some changes } else { // generate the sequence for the things that are actually changing return $this->generateSequence($changes, false); } // if null is returned, then something is getting turned off } else { // must generate a sequence with a clear return $this->generateSequence($desiredState, true); } }
[ "public", "function", "generate", "(", "TerminalStateInterface", "$", "currentState", ",", "TerminalState", "$", "desiredState", ")", "{", "// get a state object with anything that is changing", "$", "changes", "=", "$", "currentState", "->", "findChanges", "(", "$", "desiredState", ")", ";", "// if an object is returned, then just positive changes are occurring", "if", "(", "$", "changes", ")", "{", "// if there are really no changes", "if", "(", "$", "changes", "->", "isClear", "(", ")", ")", "{", "// return an empty string", "return", "\"\"", ";", "// there are some changes", "}", "else", "{", "// generate the sequence for the things that are actually changing", "return", "$", "this", "->", "generateSequence", "(", "$", "changes", ",", "false", ")", ";", "}", "// if null is returned, then something is getting turned off", "}", "else", "{", "// must generate a sequence with a clear", "return", "$", "this", "->", "generateSequence", "(", "$", "desiredState", ",", "true", ")", ";", "}", "}" ]
Generate an escape sequence based on the current state and the new desired state @param TerminalStateInterface $currentState @param TerminalState $desiredState @return string
[ "Generate", "an", "escape", "sequence", "based", "on", "the", "current", "state", "and", "the", "new", "desired", "state" ]
3a550eadb21bb87a6909436c3b961919d2731923
https://github.com/1HappyPlace/ansi-terminal/blob/3a550eadb21bb87a6909436c3b961919d2731923/src/ANSI/EscapeSequenceGenerator.php#L263-L295
24,988
Soneritics/Database
Soneritics/Database/DatabaseRecord/PDODatabaseRecord.php
PDODatabaseRecord.createMapping
private function createMapping() { $columns = $this->pdoStatement->columnCount(); if ($columns > 0) { $this->mapping = []; for ($i = 0; $i < $columns; $i++) { $meta = $this->pdoStatement->getColumnMeta($i); $this->mapping[$i] = [$meta['table'], $meta['name']]; } } }
php
private function createMapping() { $columns = $this->pdoStatement->columnCount(); if ($columns > 0) { $this->mapping = []; for ($i = 0; $i < $columns; $i++) { $meta = $this->pdoStatement->getColumnMeta($i); $this->mapping[$i] = [$meta['table'], $meta['name']]; } } }
[ "private", "function", "createMapping", "(", ")", "{", "$", "columns", "=", "$", "this", "->", "pdoStatement", "->", "columnCount", "(", ")", ";", "if", "(", "$", "columns", ">", "0", ")", "{", "$", "this", "->", "mapping", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "columns", ";", "$", "i", "++", ")", "{", "$", "meta", "=", "$", "this", "->", "pdoStatement", "->", "getColumnMeta", "(", "$", "i", ")", ";", "$", "this", "->", "mapping", "[", "$", "i", "]", "=", "[", "$", "meta", "[", "'table'", "]", ",", "$", "meta", "[", "'name'", "]", "]", ";", "}", "}", "}" ]
Create the mapping to use for mapping the column names to a result array.
[ "Create", "the", "mapping", "to", "use", "for", "mapping", "the", "column", "names", "to", "a", "result", "array", "." ]
20cb74f2a2ee8d9161d3144b5c061a6da11cd066
https://github.com/Soneritics/Database/blob/20cb74f2a2ee8d9161d3144b5c061a6da11cd066/Soneritics/Database/DatabaseRecord/PDODatabaseRecord.php#L51-L61
24,989
Soneritics/Database
Soneritics/Database/DatabaseRecord/PDODatabaseRecord.php
PDODatabaseRecord.all
public function all() { $this->reset(); $result = []; while ($row = $this->get()) { $result[] = $row; } return $result; }
php
public function all() { $this->reset(); $result = []; while ($row = $this->get()) { $result[] = $row; } return $result; }
[ "public", "function", "all", "(", ")", "{", "$", "this", "->", "reset", "(", ")", ";", "$", "result", "=", "[", "]", ";", "while", "(", "$", "row", "=", "$", "this", "->", "get", "(", ")", ")", "{", "$", "result", "[", "]", "=", "$", "row", ";", "}", "return", "$", "result", ";", "}" ]
Return an array with all the data from the query. @return array
[ "Return", "an", "array", "with", "all", "the", "data", "from", "the", "query", "." ]
20cb74f2a2ee8d9161d3144b5c061a6da11cd066
https://github.com/Soneritics/Database/blob/20cb74f2a2ee8d9161d3144b5c061a6da11cd066/Soneritics/Database/DatabaseRecord/PDODatabaseRecord.php#L80-L90
24,990
zapheus/zapheus
src/Routing/Dispatcher.php
Dispatcher.match
protected function match($method, $uri) { $result = null; foreach ((array) $this->router->routes() as $route) { $matched = preg_match($route->regex(), $uri, $matches); if ($matched && $route->method() === $method) { return array($matches, $route); } } return $result; }
php
protected function match($method, $uri) { $result = null; foreach ((array) $this->router->routes() as $route) { $matched = preg_match($route->regex(), $uri, $matches); if ($matched && $route->method() === $method) { return array($matches, $route); } } return $result; }
[ "protected", "function", "match", "(", "$", "method", ",", "$", "uri", ")", "{", "$", "result", "=", "null", ";", "foreach", "(", "(", "array", ")", "$", "this", "->", "router", "->", "routes", "(", ")", "as", "$", "route", ")", "{", "$", "matched", "=", "preg_match", "(", "$", "route", "->", "regex", "(", ")", ",", "$", "uri", ",", "$", "matches", ")", ";", "if", "(", "$", "matched", "&&", "$", "route", "->", "method", "(", ")", "===", "$", "method", ")", "{", "return", "array", "(", "$", "matches", ",", "$", "route", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Matches the route from the parsed URI. @param string $method @param string $uri @return array|null
[ "Matches", "the", "route", "from", "the", "parsed", "URI", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Routing/Dispatcher.php#L68-L83
24,991
SlabPHP/controllers
src/POSTBack.php
POSTBack.requireSubmitValue
protected function requireSubmitValue() { if ($this->system->input()->post('submit')) { echo 'LOOK: ' . $this->system->input()->post('submit') . PHP_EOL; return; } $this->setNotReady("No submit value present."); }
php
protected function requireSubmitValue() { if ($this->system->input()->post('submit')) { echo 'LOOK: ' . $this->system->input()->post('submit') . PHP_EOL; return; } $this->setNotReady("No submit value present."); }
[ "protected", "function", "requireSubmitValue", "(", ")", "{", "if", "(", "$", "this", "->", "system", "->", "input", "(", ")", "->", "post", "(", "'submit'", ")", ")", "{", "echo", "'LOOK: '", ".", "$", "this", "->", "system", "->", "input", "(", ")", "->", "post", "(", "'submit'", ")", ".", "PHP_EOL", ";", "return", ";", "}", "$", "this", "->", "setNotReady", "(", "\"No submit value present.\"", ")", ";", "}" ]
Require Submit Value
[ "Require", "Submit", "Value" ]
a1c4fded0265100a85904dd664b972a7f8687652
https://github.com/SlabPHP/controllers/blob/a1c4fded0265100a85904dd664b972a7f8687652/src/POSTBack.php#L56-L64
24,992
SlabPHP/controllers
src/POSTBack.php
POSTBack.resolveRedirectRoute
protected function resolveRedirectRoute() { if (empty($this->redirectRoute)) return; $route = $this->system->router()->getRouteByName($this->redirectRoute); if (empty($route)) { $this->setNotReady("Unable to find route " . $this->redirectRoute); return; } $this->redirectURL = $route->getPath($this->redirectParameters); }
php
protected function resolveRedirectRoute() { if (empty($this->redirectRoute)) return; $route = $this->system->router()->getRouteByName($this->redirectRoute); if (empty($route)) { $this->setNotReady("Unable to find route " . $this->redirectRoute); return; } $this->redirectURL = $route->getPath($this->redirectParameters); }
[ "protected", "function", "resolveRedirectRoute", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "redirectRoute", ")", ")", "return", ";", "$", "route", "=", "$", "this", "->", "system", "->", "router", "(", ")", "->", "getRouteByName", "(", "$", "this", "->", "redirectRoute", ")", ";", "if", "(", "empty", "(", "$", "route", ")", ")", "{", "$", "this", "->", "setNotReady", "(", "\"Unable to find route \"", ".", "$", "this", "->", "redirectRoute", ")", ";", "return", ";", "}", "$", "this", "->", "redirectURL", "=", "$", "route", "->", "getPath", "(", "$", "this", "->", "redirectParameters", ")", ";", "}" ]
Resolve redirect route
[ "Resolve", "redirect", "route" ]
a1c4fded0265100a85904dd664b972a7f8687652
https://github.com/SlabPHP/controllers/blob/a1c4fded0265100a85904dd664b972a7f8687652/src/POSTBack.php#L86-L99
24,993
Stinger-Soft/PhpCommons
src/StingerSoft/PhpCommons/Formatter/TimeFormatter.php
TimeFormatter.prettyPrintMicroTimeInterval
public static function prettyPrintMicroTimeInterval($startTime, $endTime) { $seconds = abs($endTime - $startTime); return sprintf('%02d:%02d:%02d', ($seconds / 3600), ($seconds / 60 % 60), $seconds % 60); }
php
public static function prettyPrintMicroTimeInterval($startTime, $endTime) { $seconds = abs($endTime - $startTime); return sprintf('%02d:%02d:%02d', ($seconds / 3600), ($seconds / 60 % 60), $seconds % 60); }
[ "public", "static", "function", "prettyPrintMicroTimeInterval", "(", "$", "startTime", ",", "$", "endTime", ")", "{", "$", "seconds", "=", "abs", "(", "$", "endTime", "-", "$", "startTime", ")", ";", "return", "sprintf", "(", "'%02d:%02d:%02d'", ",", "(", "$", "seconds", "/", "3600", ")", ",", "(", "$", "seconds", "/", "60", "%", "60", ")", ",", "$", "seconds", "%", "60", ")", ";", "}" ]
Pretty prints an interval specfied by two timestamps @param float $startTime Starttime as returned by microtime(true) @param float $endTime Endtime as returned by microtime(true) @param string $locale Locale used to format the result
[ "Pretty", "prints", "an", "interval", "specfied", "by", "two", "timestamps" ]
e1d7e2bb7b384fb9182903d3b6138aa3bbd05d9b
https://github.com/Stinger-Soft/PhpCommons/blob/e1d7e2bb7b384fb9182903d3b6138aa3bbd05d9b/src/StingerSoft/PhpCommons/Formatter/TimeFormatter.php#L53-L56
24,994
makinacorpus/drupal-ulink
src/EntityFinderRegistry.php
EntityFinderRegistry.all
public function all() { $ret = []; foreach ($this->instances as $instances) { $ret = array_merge($ret, $instances); } return $ret; }
php
public function all() { $ret = []; foreach ($this->instances as $instances) { $ret = array_merge($ret, $instances); } return $ret; }
[ "public", "function", "all", "(", ")", "{", "$", "ret", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "instances", "as", "$", "instances", ")", "{", "$", "ret", "=", "array_merge", "(", "$", "ret", ",", "$", "instances", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Get all instances @return EntityFinderInterface[]
[ "Get", "all", "instances" ]
4e1e54b979d72934a6fc0242aae3f12abebf41d0
https://github.com/makinacorpus/drupal-ulink/blob/4e1e54b979d72934a6fc0242aae3f12abebf41d0/src/EntityFinderRegistry.php#L55-L64
24,995
Vectrex/vxPHP
src/Http/AcceptHeaderItem.php
AcceptHeaderItem.getAttribute
public function getAttribute($name, $default = NULL) { return isset($this->attributes[$name]) ? $this->attributes[$name] : $default; }
php
public function getAttribute($name, $default = NULL) { return isset($this->attributes[$name]) ? $this->attributes[$name] : $default; }
[ "public", "function", "getAttribute", "(", "$", "name", ",", "$", "default", "=", "NULL", ")", "{", "return", "isset", "(", "$", "this", "->", "attributes", "[", "$", "name", "]", ")", "?", "$", "this", "->", "attributes", "[", "$", "name", "]", ":", "$", "default", ";", "}" ]
Returns an attribute by its name. @param string $name @param mixed $default @return mixed
[ "Returns", "an", "attribute", "by", "its", "name", "." ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Http/AcceptHeaderItem.php#L209-L213
24,996
pryley/castor-framework
src/Services/Validator.php
Validator.validate
public function validate( $data, array $rules = [] ) { $this->normalizeData( $data ); $this->setRules( $rules ); foreach( $this->rules as $attribute => $rules ) { foreach( $rules as $rule ) { $this->validateAttribute( $rule, $attribute ); if( $this->shouldStopValidating( $attribute ))break; } } return $this->errors; }
php
public function validate( $data, array $rules = [] ) { $this->normalizeData( $data ); $this->setRules( $rules ); foreach( $this->rules as $attribute => $rules ) { foreach( $rules as $rule ) { $this->validateAttribute( $rule, $attribute ); if( $this->shouldStopValidating( $attribute ))break; } } return $this->errors; }
[ "public", "function", "validate", "(", "$", "data", ",", "array", "$", "rules", "=", "[", "]", ")", "{", "$", "this", "->", "normalizeData", "(", "$", "data", ")", ";", "$", "this", "->", "setRules", "(", "$", "rules", ")", ";", "foreach", "(", "$", "this", "->", "rules", "as", "$", "attribute", "=>", "$", "rules", ")", "{", "foreach", "(", "$", "rules", "as", "$", "rule", ")", "{", "$", "this", "->", "validateAttribute", "(", "$", "rule", ",", "$", "attribute", ")", ";", "if", "(", "$", "this", "->", "shouldStopValidating", "(", "$", "attribute", ")", ")", "break", ";", "}", "}", "return", "$", "this", "->", "errors", ";", "}" ]
Run the validator's rules against its data. @param mixed $data @return array
[ "Run", "the", "validator", "s", "rules", "against", "its", "data", "." ]
cbc137d02625cd05f4cc96414d6f70e451cb821f
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Services/Validator.php#L72-L86
24,997
pryley/castor-framework
src/Services/Validator.php
Validator.addError
protected function addError( $attribute, $rule, array $parameters ) { $message = $this->getMessage( $attribute, $rule, $parameters ); $this->errors[ $attribute ]['errors'][] = $message; if( !isset( $this->errors[ $attribute ]['value'] )) { $this->errors[ $attribute ]['value'] = $this->getValue( $attribute ); } }
php
protected function addError( $attribute, $rule, array $parameters ) { $message = $this->getMessage( $attribute, $rule, $parameters ); $this->errors[ $attribute ]['errors'][] = $message; if( !isset( $this->errors[ $attribute ]['value'] )) { $this->errors[ $attribute ]['value'] = $this->getValue( $attribute ); } }
[ "protected", "function", "addError", "(", "$", "attribute", ",", "$", "rule", ",", "array", "$", "parameters", ")", "{", "$", "message", "=", "$", "this", "->", "getMessage", "(", "$", "attribute", ",", "$", "rule", ",", "$", "parameters", ")", ";", "$", "this", "->", "errors", "[", "$", "attribute", "]", "[", "'errors'", "]", "[", "]", "=", "$", "message", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "errors", "[", "$", "attribute", "]", "[", "'value'", "]", ")", ")", "{", "$", "this", "->", "errors", "[", "$", "attribute", "]", "[", "'value'", "]", "=", "$", "this", "->", "getValue", "(", "$", "attribute", ")", ";", "}", "}" ]
Add an error message to the validator's collection of errors. @param string $attribute @param string $rule @return void
[ "Add", "an", "error", "message", "to", "the", "validator", "s", "collection", "of", "errors", "." ]
cbc137d02625cd05f4cc96414d6f70e451cb821f
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Services/Validator.php#L96-L105
24,998
pryley/castor-framework
src/Services/Validator.php
Validator.normalizeData
protected function normalizeData( $data ) { // If an object was provided, get its public properties if( is_object( $data )) { $this->data = get_object_vars( $data ); } else { $this->data = $data; } return $this; }
php
protected function normalizeData( $data ) { // If an object was provided, get its public properties if( is_object( $data )) { $this->data = get_object_vars( $data ); } else { $this->data = $data; } return $this; }
[ "protected", "function", "normalizeData", "(", "$", "data", ")", "{", "// If an object was provided, get its public properties", "if", "(", "is_object", "(", "$", "data", ")", ")", "{", "$", "this", "->", "data", "=", "get_object_vars", "(", "$", "data", ")", ";", "}", "else", "{", "$", "this", "->", "data", "=", "$", "data", ";", "}", "return", "$", "this", ";", "}" ]
Normalize the provided data to an array. @param mixed $data @return $this
[ "Normalize", "the", "provided", "data", "to", "an", "array", "." ]
cbc137d02625cd05f4cc96414d6f70e451cb821f
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Services/Validator.php#L251-L262
24,999
pryley/castor-framework
src/Services/Validator.php
Validator.translator
protected function translator( $key, $rule, $attribute, array $parameters ) { $strings = [];//glsr_resolve( 'Strings' )->validation(); $message = isset( $strings[$key] ) ? $strings[$key] : false; if( !$message )return; $message = str_replace( ':attribute', $attribute, $message ); if( method_exists( $this, $replacer = "replace{$rule}" )) { $message = $this->$replacer( $message, $parameters ); } return $message; }
php
protected function translator( $key, $rule, $attribute, array $parameters ) { $strings = [];//glsr_resolve( 'Strings' )->validation(); $message = isset( $strings[$key] ) ? $strings[$key] : false; if( !$message )return; $message = str_replace( ':attribute', $attribute, $message ); if( method_exists( $this, $replacer = "replace{$rule}" )) { $message = $this->$replacer( $message, $parameters ); } return $message; }
[ "protected", "function", "translator", "(", "$", "key", ",", "$", "rule", ",", "$", "attribute", ",", "array", "$", "parameters", ")", "{", "$", "strings", "=", "[", "]", ";", "//glsr_resolve( 'Strings' )->validation();", "$", "message", "=", "isset", "(", "$", "strings", "[", "$", "key", "]", ")", "?", "$", "strings", "[", "$", "key", "]", ":", "false", ";", "if", "(", "!", "$", "message", ")", "return", ";", "$", "message", "=", "str_replace", "(", "':attribute'", ",", "$", "attribute", ",", "$", "message", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "replacer", "=", "\"replace{$rule}\"", ")", ")", "{", "$", "message", "=", "$", "this", "->", "$", "replacer", "(", "$", "message", ",", "$", "parameters", ")", ";", "}", "return", "$", "message", ";", "}" ]
Returns a translated message for the attribute @param string $key @param string $rule @param string $attribute @return string|null
[ "Returns", "a", "translated", "message", "for", "the", "attribute" ]
cbc137d02625cd05f4cc96414d6f70e451cb821f
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Services/Validator.php#L415-L432