repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Upload/Driver/Upyun.php
Upyun.response
private function response($text){ $headers = explode("\r\n", $text); $items = array(); foreach($headers as $header) { $header = trim($header); if(strpos($header, 'x-upyun') !== False){ list($k, $v) = explode(':', $header); $items[trim($k)] = in_array(substr($k,8,5), array('width','heigh','frame')) ? intval($v) : trim($v); } } return $items; }
php
private function response($text){ $headers = explode("\r\n", $text); $items = array(); foreach($headers as $header) { $header = trim($header); if(strpos($header, 'x-upyun') !== False){ list($k, $v) = explode(':', $header); $items[trim($k)] = in_array(substr($k,8,5), array('width','heigh','frame')) ? intval($v) : trim($v); } } return $items; }
[ "private", "function", "response", "(", "$", "text", ")", "{", "$", "headers", "=", "explode", "(", "\"\\r\\n\"", ",", "$", "text", ")", ";", "$", "items", "=", "array", "(", ")", ";", "foreach", "(", "$", "headers", "as", "$", "header", ")", "{", "$", "header", "=", "trim", "(", "$", "header", ")", ";", "if", "(", "strpos", "(", "$", "header", ",", "'x-upyun'", ")", "!==", "False", ")", "{", "list", "(", "$", "k", ",", "$", "v", ")", "=", "explode", "(", "':'", ",", "$", "header", ")", ";", "$", "items", "[", "trim", "(", "$", "k", ")", "]", "=", "in_array", "(", "substr", "(", "$", "k", ",", "8", ",", "5", ")", ",", "array", "(", "'width'", ",", "'heigh'", ",", "'frame'", ")", ")", "?", "intval", "(", "$", "v", ")", ":", "trim", "(", "$", "v", ")", ";", "}", "}", "return", "$", "items", ";", "}" ]
获取响应数据 @param string $text 响应头字符串 @return array 响应数据列表
[ "获取响应数据" ]
train
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Upload/Driver/Upyun.php#L181-L192
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Upload/Driver/Upyun.php
Upyun.sign
private function sign($method, $uri, $date, $length){ $sign = "{$method}&{$uri}&{$date}&{$length}&{$this->config['password']}"; return 'UpYun ' . $this->config['username'] . ':' . md5($sign); }
php
private function sign($method, $uri, $date, $length){ $sign = "{$method}&{$uri}&{$date}&{$length}&{$this->config['password']}"; return 'UpYun ' . $this->config['username'] . ':' . md5($sign); }
[ "private", "function", "sign", "(", "$", "method", ",", "$", "uri", ",", "$", "date", ",", "$", "length", ")", "{", "$", "sign", "=", "\"{$method}&{$uri}&{$date}&{$length}&{$this->config['password']}\"", ";", "return", "'UpYun '", ".", "$", "this", "->", "config", "[", "'username'", "]", ".", "':'", ".", "md5", "(", "$", "sign", ")", ";", "}" ]
生成请求签名 @param string $method 请求方法 @param string $uri 请求URI @param string $date 请求时间 @param integer $length 请求内容大小 @return string 请求签名
[ "生成请求签名" ]
train
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Upload/Driver/Upyun.php#L202-L205
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Upload/Driver/Upyun.php
Upyun.error
private function error($header) { list($status, $stash) = explode("\r\n", $header, 2); list($v, $code, $message) = explode(" ", $status, 3); $message = is_null($message) ? 'File Not Found' : "[{$status}]:{$message}"; $this->error = $message; }
php
private function error($header) { list($status, $stash) = explode("\r\n", $header, 2); list($v, $code, $message) = explode(" ", $status, 3); $message = is_null($message) ? 'File Not Found' : "[{$status}]:{$message}"; $this->error = $message; }
[ "private", "function", "error", "(", "$", "header", ")", "{", "list", "(", "$", "status", ",", "$", "stash", ")", "=", "explode", "(", "\"\\r\\n\"", ",", "$", "header", ",", "2", ")", ";", "list", "(", "$", "v", ",", "$", "code", ",", "$", "message", ")", "=", "explode", "(", "\" \"", ",", "$", "status", ",", "3", ")", ";", "$", "message", "=", "is_null", "(", "$", "message", ")", "?", "'File Not Found'", ":", "\"[{$status}]:{$message}\"", ";", "$", "this", "->", "error", "=", "$", "message", ";", "}" ]
获取请求错误信息 @param string $header 请求返回头信息
[ "获取请求错误信息" ]
train
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Upload/Driver/Upyun.php#L211-L216
AlexyaFramework/Database
Alexya/Database/Connection.php
Connection.connect
public function connect() { try { $this->_connection = new PDO( $this->_type .":host=". $this->_host .";dbname=". $this->_database .";port=". $this->_port, $this->_username, $this->_password ); } catch(PDOException $e) { $code = $e->getCode(); $message = $e->getMessage(); throw new ConnectionFailed($code, $message); } }
php
public function connect() { try { $this->_connection = new PDO( $this->_type .":host=". $this->_host .";dbname=". $this->_database .";port=". $this->_port, $this->_username, $this->_password ); } catch(PDOException $e) { $code = $e->getCode(); $message = $e->getMessage(); throw new ConnectionFailed($code, $message); } }
[ "public", "function", "connect", "(", ")", "{", "try", "{", "$", "this", "->", "_connection", "=", "new", "PDO", "(", "$", "this", "->", "_type", ".", "\":host=\"", ".", "$", "this", "->", "_host", ".", "\";dbname=\"", ".", "$", "this", "->", "_database", ".", "\";port=\"", ".", "$", "this", "->", "_port", ",", "$", "this", "->", "_username", ",", "$", "this", "->", "_password", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "$", "code", "=", "$", "e", "->", "getCode", "(", ")", ";", "$", "message", "=", "$", "e", "->", "getMessage", "(", ")", ";", "throw", "new", "ConnectionFailed", "(", "$", "code", ",", "$", "message", ")", ";", "}", "}" ]
Connects to the server. @throws ConnectionFailed If couldn't connect to host
[ "Connects", "to", "the", "server", "." ]
train
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/Connection.php#L135-L149
AlexyaFramework/Database
Alexya/Database/Connection.php
Connection.execute
public function execute(string $query, bool $fetchAll = true, int $fetch = PDO::FETCH_ASSOC) { $result = $this->_connection->query($query); if($result === false) { throw new QueryFailed($query, $this->_connection->errorInfo()[2]); } $this->lastQuery = $query; if($fetchAll) { return $result->fetchAll($fetch); } return $result->fetch($fetch); }
php
public function execute(string $query, bool $fetchAll = true, int $fetch = PDO::FETCH_ASSOC) { $result = $this->_connection->query($query); if($result === false) { throw new QueryFailed($query, $this->_connection->errorInfo()[2]); } $this->lastQuery = $query; if($fetchAll) { return $result->fetchAll($fetch); } return $result->fetch($fetch); }
[ "public", "function", "execute", "(", "string", "$", "query", ",", "bool", "$", "fetchAll", "=", "true", ",", "int", "$", "fetch", "=", "PDO", "::", "FETCH_ASSOC", ")", "{", "$", "result", "=", "$", "this", "->", "_connection", "->", "query", "(", "$", "query", ")", ";", "if", "(", "$", "result", "===", "false", ")", "{", "throw", "new", "QueryFailed", "(", "$", "query", ",", "$", "this", "->", "_connection", "->", "errorInfo", "(", ")", "[", "2", "]", ")", ";", "}", "$", "this", "->", "lastQuery", "=", "$", "query", ";", "if", "(", "$", "fetchAll", ")", "{", "return", "$", "result", "->", "fetchAll", "(", "$", "fetch", ")", ";", "}", "return", "$", "result", "->", "fetch", "(", "$", "fetch", ")", ";", "}" ]
Executes a query. @param string $query SQL query to execute. @param bool $fetchAll Whether all results should be fetched or not (default = `true`). @param int $fetch How results should be fetched (default = `PDO::FETCH_ASSOC`). @return mixed Query result. @throws QueryFailed If the query failed to execute.
[ "Executes", "a", "query", "." ]
train
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/Connection.php#L192-L207
ekyna/SettingBundle
Transformer/ObjectToIdentifierTransformer.php
ObjectToIdentifierTransformer.reverseTransform
public function reverseTransform($value) { if (empty($value)) { return null; } return $this->repository->findOneBy([$this->identifier => $value]); }
php
public function reverseTransform($value) { if (empty($value)) { return null; } return $this->repository->findOneBy([$this->identifier => $value]); }
[ "public", "function", "reverseTransform", "(", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "repository", "->", "findOneBy", "(", "[", "$", "this", "->", "identifier", "=>", "$", "value", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ekyna/SettingBundle/blob/df58f83eb3a01ef56cd76ea73639322c581e75c1/Transformer/ObjectToIdentifierTransformer.php#L32-L39
dms-org/common.structure
src/DateTime/Persistence/DateTimeRangeMapper.php
DateTimeRangeMapper.define
protected function define(MapperDefinition $map) { $map->type(DateTimeRange::class); $map->embedded(DateTimeRange::START)->using(new DateTimeMapper($this->startColumnName)); $map->embedded(DateTimeRange::END)->using(new DateTimeMapper($this->endColumnName)); }
php
protected function define(MapperDefinition $map) { $map->type(DateTimeRange::class); $map->embedded(DateTimeRange::START)->using(new DateTimeMapper($this->startColumnName)); $map->embedded(DateTimeRange::END)->using(new DateTimeMapper($this->endColumnName)); }
[ "protected", "function", "define", "(", "MapperDefinition", "$", "map", ")", "{", "$", "map", "->", "type", "(", "DateTimeRange", "::", "class", ")", ";", "$", "map", "->", "embedded", "(", "DateTimeRange", "::", "START", ")", "->", "using", "(", "new", "DateTimeMapper", "(", "$", "this", "->", "startColumnName", ")", ")", ";", "$", "map", "->", "embedded", "(", "DateTimeRange", "::", "END", ")", "->", "using", "(", "new", "DateTimeMapper", "(", "$", "this", "->", "endColumnName", ")", ")", ";", "}" ]
Defines the value object mapper @param MapperDefinition $map @return void
[ "Defines", "the", "value", "object", "mapper" ]
train
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/DateTime/Persistence/DateTimeRangeMapper.php#L30-L36
cmsgears/module-sns-connect
common/services/system/LinkedinService.php
LinkedinService.curl
private function curl( $url ) { $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); $data = curl_exec( $ch ); curl_close( $ch ); return $data; }
php
private function curl( $url ) { $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); $data = curl_exec( $ch ); curl_close( $ch ); return $data; }
[ "private", "function", "curl", "(", "$", "url", ")", "{", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "url", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "1", ")", ";", "$", "data", "=", "curl_exec", "(", "$", "ch", ")", ";", "curl_close", "(", "$", "ch", ")", ";", "return", "$", "data", ";", "}" ]
LinkedinService -----------------------
[ "LinkedinService", "-----------------------" ]
train
https://github.com/cmsgears/module-sns-connect/blob/753ee4157d41c81a701689624f4c44760a6cada3/common/services/system/LinkedinService.php#L53-L65
kambalabs/KmbPuppetDb
src/KmbPuppetDb/Service/FactNamesFactory.php
FactNamesFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $service = new Service\FactNames(); $service->setPuppetDbClient($serviceLocator->get('KmbPuppetDb\Client')); return $service; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $service = new Service\FactNames(); $service->setPuppetDbClient($serviceLocator->get('KmbPuppetDb\Client')); return $service; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "service", "=", "new", "Service", "\\", "FactNames", "(", ")", ";", "$", "service", "->", "setPuppetDbClient", "(", "$", "serviceLocator", "->", "get", "(", "'KmbPuppetDb\\Client'", ")", ")", ";", "return", "$", "service", ";", "}" ]
Create service @param ServiceLocatorInterface $serviceLocator @return mixed
[ "Create", "service" ]
train
https://github.com/kambalabs/KmbPuppetDb/blob/df56a275cf00f4402cf121a2e99149168f1f8b2d/src/KmbPuppetDb/Service/FactNamesFactory.php#L35-L40
stubbles/stubbles-image
src/main/php/driver/PngDriver.php
PngDriver.load
public function load(string $fileName) { if (!file_exists($fileName)) { throw new DriverException('The image ' . $fileName . ' could not be found'); } $handle = @imagecreatefrompng($fileName); if (empty($handle)) { throw new DriverException('The image ' . $fileName . ' seems to be broken.'); } return $handle; }
php
public function load(string $fileName) { if (!file_exists($fileName)) { throw new DriverException('The image ' . $fileName . ' could not be found'); } $handle = @imagecreatefrompng($fileName); if (empty($handle)) { throw new DriverException('The image ' . $fileName . ' seems to be broken.'); } return $handle; }
[ "public", "function", "load", "(", "string", "$", "fileName", ")", "{", "if", "(", "!", "file_exists", "(", "$", "fileName", ")", ")", "{", "throw", "new", "DriverException", "(", "'The image '", ".", "$", "fileName", ".", "' could not be found'", ")", ";", "}", "$", "handle", "=", "@", "imagecreatefrompng", "(", "$", "fileName", ")", ";", "if", "(", "empty", "(", "$", "handle", ")", ")", "{", "throw", "new", "DriverException", "(", "'The image '", ".", "$", "fileName", ".", "' seems to be broken.'", ")", ";", "}", "return", "$", "handle", ";", "}" ]
loads given image @param string $fileName @return resource @throws \stubbles\img\driver\DriverException
[ "loads", "given", "image" ]
train
https://github.com/stubbles/stubbles-image/blob/5ae6488a94c7b2eb97e042875a19ba43efc414fa/src/main/php/driver/PngDriver.php#L24-L36
stubbles/stubbles-image
src/main/php/driver/PngDriver.php
PngDriver.store
public function store(string $fileName, $handle): ImageDriver { if (!@imagepng($handle, $fileName)) { throw new DriverException('Could not save image to ' . $fileName); } return $this; }
php
public function store(string $fileName, $handle): ImageDriver { if (!@imagepng($handle, $fileName)) { throw new DriverException('Could not save image to ' . $fileName); } return $this; }
[ "public", "function", "store", "(", "string", "$", "fileName", ",", "$", "handle", ")", ":", "ImageDriver", "{", "if", "(", "!", "@", "imagepng", "(", "$", "handle", ",", "$", "fileName", ")", ")", "{", "throw", "new", "DriverException", "(", "'Could not save image to '", ".", "$", "fileName", ")", ";", "}", "return", "$", "this", ";", "}" ]
stores given image @param string $fileName @param resource $handle @return \stubbles\img\driver\PngDriver @throws \stubbles\img\driver\DriverException
[ "stores", "given", "image" ]
train
https://github.com/stubbles/stubbles-image/blob/5ae6488a94c7b2eb97e042875a19ba43efc414fa/src/main/php/driver/PngDriver.php#L46-L53
formapro/BadaBoom
src/BadaBoom/ChainNode/Filter/ErrorLevelFilter.php
ErrorLevelFilter.shouldContinue
public function shouldContinue(\Exception $exception, DataHolderInterface $data) { if (false == $exception instanceof \ErrorException) { return true; } foreach ($this->denyErrors as $error) { if ($error == $exception->getSeverity()) { return false; } } return true; }
php
public function shouldContinue(\Exception $exception, DataHolderInterface $data) { if (false == $exception instanceof \ErrorException) { return true; } foreach ($this->denyErrors as $error) { if ($error == $exception->getSeverity()) { return false; } } return true; }
[ "public", "function", "shouldContinue", "(", "\\", "Exception", "$", "exception", ",", "DataHolderInterface", "$", "data", ")", "{", "if", "(", "false", "==", "$", "exception", "instanceof", "\\", "ErrorException", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "this", "->", "denyErrors", "as", "$", "error", ")", "{", "if", "(", "$", "error", "==", "$", "exception", "->", "getSeverity", "(", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/formapro/BadaBoom/blob/db42dbc4a43f7070586229c0e6075fe3a781e04e/src/BadaBoom/ChainNode/Filter/ErrorLevelFilter.php#L24-L37
CampaignChain/security-authentication-client-oauth
Entity/Application.php
Application.addToken
public function addToken(\CampaignChain\Security\Authentication\Client\OAuthBundle\Entity\Token $tokens) { $this->tokens[] = $tokens; return $this; }
php
public function addToken(\CampaignChain\Security\Authentication\Client\OAuthBundle\Entity\Token $tokens) { $this->tokens[] = $tokens; return $this; }
[ "public", "function", "addToken", "(", "\\", "CampaignChain", "\\", "Security", "\\", "Authentication", "\\", "Client", "\\", "OAuthBundle", "\\", "Entity", "\\", "Token", "$", "tokens", ")", "{", "$", "this", "->", "tokens", "[", "]", "=", "$", "tokens", ";", "return", "$", "this", ";", "}" ]
Add tokens @param \CampaignChain\Security\Authentication\Client\OAuthBundle\Entity\Token $tokens @return Application
[ "Add", "tokens" ]
train
https://github.com/CampaignChain/security-authentication-client-oauth/blob/06800ccd0ee6b5ca9f53b85146228467ff6a7529/Entity/Application.php#L141-L146
CampaignChain/security-authentication-client-oauth
Entity/Application.php
Application.removeToken
public function removeToken(\CampaignChain\Security\Authentication\Client\OAuthBundle\Entity\Token $tokens) { $this->tokens->removeElement($tokens); }
php
public function removeToken(\CampaignChain\Security\Authentication\Client\OAuthBundle\Entity\Token $tokens) { $this->tokens->removeElement($tokens); }
[ "public", "function", "removeToken", "(", "\\", "CampaignChain", "\\", "Security", "\\", "Authentication", "\\", "Client", "\\", "OAuthBundle", "\\", "Entity", "\\", "Token", "$", "tokens", ")", "{", "$", "this", "->", "tokens", "->", "removeElement", "(", "$", "tokens", ")", ";", "}" ]
Remove tokens @param \CampaignChain\Security\Authentication\Client\OAuthBundle\Entity\Token $tokens
[ "Remove", "tokens" ]
train
https://github.com/CampaignChain/security-authentication-client-oauth/blob/06800ccd0ee6b5ca9f53b85146228467ff6a7529/Entity/Application.php#L153-L156
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.start
public function start() { $modules = ModuleModel::where('module_status', 1)->get(); foreach($modules as $module) { $path = $this->getModuleDirectory($module->module_name); if ($path) { $name = $module->module_name; $this->modules[$name] = new Module($this->app, $module->module_name, $path); } } }
php
public function start() { $modules = ModuleModel::where('module_status', 1)->get(); foreach($modules as $module) { $path = $this->getModuleDirectory($module->module_name); if ($path) { $name = $module->module_name; $this->modules[$name] = new Module($this->app, $module->module_name, $path); } } }
[ "public", "function", "start", "(", ")", "{", "$", "modules", "=", "ModuleModel", "::", "where", "(", "'module_status'", ",", "1", ")", "->", "get", "(", ")", ";", "foreach", "(", "$", "modules", "as", "$", "module", ")", "{", "$", "path", "=", "$", "this", "->", "getModuleDirectory", "(", "$", "module", "->", "module_name", ")", ";", "if", "(", "$", "path", ")", "{", "$", "name", "=", "$", "module", "->", "module_name", ";", "$", "this", "->", "modules", "[", "$", "name", "]", "=", "new", "Module", "(", "$", "this", "->", "app", ",", "$", "module", "->", "module_name", ",", "$", "path", ")", ";", "}", "}", "}" ]
Get all module from database and initialize @return void
[ "Get", "all", "module", "from", "database", "and", "initialize" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L120-L132
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.register
public function register() { foreach ($this->modules as $module) { $module->register(); } $modules = ModuleModel::where('module_status', 1)->get(); foreach ($modules as $module) { if ($module->module_is_installed) { $this->app['events']->fire('modules.install.'.$module->module_name, null); $module->module_is_installed = 0; } if ($module->module_is_updated) { $this->app['events']->fire('modules.update.'.$module->module_name, null); $module->module_is_updated = 0; } if ($module->module_is_enabled) { $this->app['events']->fire('modules.enable.'.$module->module_name, null); $module->module_is_enabled = 0; } $module->save(); } }
php
public function register() { foreach ($this->modules as $module) { $module->register(); } $modules = ModuleModel::where('module_status', 1)->get(); foreach ($modules as $module) { if ($module->module_is_installed) { $this->app['events']->fire('modules.install.'.$module->module_name, null); $module->module_is_installed = 0; } if ($module->module_is_updated) { $this->app['events']->fire('modules.update.'.$module->module_name, null); $module->module_is_updated = 0; } if ($module->module_is_enabled) { $this->app['events']->fire('modules.enable.'.$module->module_name, null); $module->module_is_enabled = 0; } $module->save(); } }
[ "public", "function", "register", "(", ")", "{", "foreach", "(", "$", "this", "->", "modules", "as", "$", "module", ")", "{", "$", "module", "->", "register", "(", ")", ";", "}", "$", "modules", "=", "ModuleModel", "::", "where", "(", "'module_status'", ",", "1", ")", "->", "get", "(", ")", ";", "foreach", "(", "$", "modules", "as", "$", "module", ")", "{", "if", "(", "$", "module", "->", "module_is_installed", ")", "{", "$", "this", "->", "app", "[", "'events'", "]", "->", "fire", "(", "'modules.install.'", ".", "$", "module", "->", "module_name", ",", "null", ")", ";", "$", "module", "->", "module_is_installed", "=", "0", ";", "}", "if", "(", "$", "module", "->", "module_is_updated", ")", "{", "$", "this", "->", "app", "[", "'events'", "]", "->", "fire", "(", "'modules.update.'", ".", "$", "module", "->", "module_name", ",", "null", ")", ";", "$", "module", "->", "module_is_updated", "=", "0", ";", "}", "if", "(", "$", "module", "->", "module_is_enabled", ")", "{", "$", "this", "->", "app", "[", "'events'", "]", "->", "fire", "(", "'modules.enable.'", ".", "$", "module", "->", "module_name", ",", "null", ")", ";", "$", "module", "->", "module_is_enabled", "=", "0", ";", "}", "$", "module", "->", "save", "(", ")", ";", "}", "}" ]
Register modules with Moduel class @return void
[ "Register", "modules", "with", "Moduel", "class" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L139-L166
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.enable
public function enable($moduleName) { $module = $this->findOrFalse('module_name', $moduleName); if ($module) { if(!$module->module_status) { $module->module_status = 1; $module->module_is_enabled = 1; $module->save(); return true; } return false; } return false; }
php
public function enable($moduleName) { $module = $this->findOrFalse('module_name', $moduleName); if ($module) { if(!$module->module_status) { $module->module_status = 1; $module->module_is_enabled = 1; $module->save(); return true; } return false; } return false; }
[ "public", "function", "enable", "(", "$", "moduleName", ")", "{", "$", "module", "=", "$", "this", "->", "findOrFalse", "(", "'module_name'", ",", "$", "moduleName", ")", ";", "if", "(", "$", "module", ")", "{", "if", "(", "!", "$", "module", "->", "module_status", ")", "{", "$", "module", "->", "module_status", "=", "1", ";", "$", "module", "->", "module_is_enabled", "=", "1", ";", "$", "module", "->", "save", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "return", "false", ";", "}" ]
Enable module to load @param string #moduleName @return bool
[ "Enable", "module", "to", "load" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L174-L189
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.disable
public function disable($moduleName) { $module = $this->findOrFalse('module_name', $moduleName); if ($module) { if ($module->module_status) { $module->module_status = 0; $module->save(); $this->app['events']->fire('modules.disable.'.$moduleName, null); return true; } return false; } return false; }
php
public function disable($moduleName) { $module = $this->findOrFalse('module_name', $moduleName); if ($module) { if ($module->module_status) { $module->module_status = 0; $module->save(); $this->app['events']->fire('modules.disable.'.$moduleName, null); return true; } return false; } return false; }
[ "public", "function", "disable", "(", "$", "moduleName", ")", "{", "$", "module", "=", "$", "this", "->", "findOrFalse", "(", "'module_name'", ",", "$", "moduleName", ")", ";", "if", "(", "$", "module", ")", "{", "if", "(", "$", "module", "->", "module_status", ")", "{", "$", "module", "->", "module_status", "=", "0", ";", "$", "module", "->", "save", "(", ")", ";", "$", "this", "->", "app", "[", "'events'", "]", "->", "fire", "(", "'modules.disable.'", ".", "$", "moduleName", ",", "null", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "return", "false", ";", "}" ]
Disable module @param string $moduleName @return bool
[ "Disable", "module" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L198-L213
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.getListModules
protected function getListModules($modulesModel) { $modules = array(); foreach ($modulesModel as $module) { $modules[$module->module_name]['name'] = $this->def($module->module_name, 'name'); $modules[$module->module_name]['icon'] = $this->getConfig('assets').'/'.$module->module_name.'/'.$this->def($module->module_name, 'icon'); $modules[$module->module_name]['description'] = $this->def($module->module_name, 'description'); $modules[$module->module_name]['author'] = $this->def($module->module_name, 'author'); $modules[$module->module_name]['website'] = $this->def($module->module_name, 'website'); $modules[$module->module_name]['version'] = $this->def($module->module_name, 'version'); } return $modules; }
php
protected function getListModules($modulesModel) { $modules = array(); foreach ($modulesModel as $module) { $modules[$module->module_name]['name'] = $this->def($module->module_name, 'name'); $modules[$module->module_name]['icon'] = $this->getConfig('assets').'/'.$module->module_name.'/'.$this->def($module->module_name, 'icon'); $modules[$module->module_name]['description'] = $this->def($module->module_name, 'description'); $modules[$module->module_name]['author'] = $this->def($module->module_name, 'author'); $modules[$module->module_name]['website'] = $this->def($module->module_name, 'website'); $modules[$module->module_name]['version'] = $this->def($module->module_name, 'version'); } return $modules; }
[ "protected", "function", "getListModules", "(", "$", "modulesModel", ")", "{", "$", "modules", "=", "array", "(", ")", ";", "foreach", "(", "$", "modulesModel", "as", "$", "module", ")", "{", "$", "modules", "[", "$", "module", "->", "module_name", "]", "[", "'name'", "]", "=", "$", "this", "->", "def", "(", "$", "module", "->", "module_name", ",", "'name'", ")", ";", "$", "modules", "[", "$", "module", "->", "module_name", "]", "[", "'icon'", "]", "=", "$", "this", "->", "getConfig", "(", "'assets'", ")", ".", "'/'", ".", "$", "module", "->", "module_name", ".", "'/'", ".", "$", "this", "->", "def", "(", "$", "module", "->", "module_name", ",", "'icon'", ")", ";", "$", "modules", "[", "$", "module", "->", "module_name", "]", "[", "'description'", "]", "=", "$", "this", "->", "def", "(", "$", "module", "->", "module_name", ",", "'description'", ")", ";", "$", "modules", "[", "$", "module", "->", "module_name", "]", "[", "'author'", "]", "=", "$", "this", "->", "def", "(", "$", "module", "->", "module_name", ",", "'author'", ")", ";", "$", "modules", "[", "$", "module", "->", "module_name", "]", "[", "'website'", "]", "=", "$", "this", "->", "def", "(", "$", "module", "->", "module_name", ",", "'website'", ")", ";", "$", "modules", "[", "$", "module", "->", "module_name", "]", "[", "'version'", "]", "=", "$", "this", "->", "def", "(", "$", "module", "->", "module_name", ",", "'version'", ")", ";", "}", "return", "$", "modules", ";", "}" ]
Get list modules @param model $modulesModel @return array
[ "Get", "list", "modules" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L254-L267
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.buildAssets
public function buildAssets($moduleName) { $module = $this->getModuleDirectory($moduleName); if ($module) { $module .= '/assets'; if ($this->files->exists($module)) { if (!@$this->files->copyDirectory($module, $this->getAssetDirectory($moduleName))) { $this->errors->add('build_assets', 'Unable to build assets'); return false; } } return true; } return false; }
php
public function buildAssets($moduleName) { $module = $this->getModuleDirectory($moduleName); if ($module) { $module .= '/assets'; if ($this->files->exists($module)) { if (!@$this->files->copyDirectory($module, $this->getAssetDirectory($moduleName))) { $this->errors->add('build_assets', 'Unable to build assets'); return false; } } return true; } return false; }
[ "public", "function", "buildAssets", "(", "$", "moduleName", ")", "{", "$", "module", "=", "$", "this", "->", "getModuleDirectory", "(", "$", "moduleName", ")", ";", "if", "(", "$", "module", ")", "{", "$", "module", ".=", "'/assets'", ";", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "module", ")", ")", "{", "if", "(", "!", "@", "$", "this", "->", "files", "->", "copyDirectory", "(", "$", "module", ",", "$", "this", "->", "getAssetDirectory", "(", "$", "moduleName", ")", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "'build_assets'", ",", "'Unable to build assets'", ")", ";", "return", "false", ";", "}", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Move contents assets module to public directory @param string $moduleName @return bool
[ "Move", "contents", "assets", "module", "to", "public", "directory" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L275-L292
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.removeAssets
public function removeAssets($moduleName) { $assets = $this->getAssetDirectory($moduleName); $this->files->deleteDirectory($assets); if ($this->files->exists($assets)) { $this->errors->add('delete_assets', 'Unable to delete assets in: '.$assets); return false; } return true; }
php
public function removeAssets($moduleName) { $assets = $this->getAssetDirectory($moduleName); $this->files->deleteDirectory($assets); if ($this->files->exists($assets)) { $this->errors->add('delete_assets', 'Unable to delete assets in: '.$assets); return false; } return true; }
[ "public", "function", "removeAssets", "(", "$", "moduleName", ")", "{", "$", "assets", "=", "$", "this", "->", "getAssetDirectory", "(", "$", "moduleName", ")", ";", "$", "this", "->", "files", "->", "deleteDirectory", "(", "$", "assets", ")", ";", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "assets", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "'delete_assets'", ",", "'Unable to delete assets in: '", ".", "$", "assets", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Remove assets of a module @param string $moduleName @return bool
[ "Remove", "assets", "of", "a", "module" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L300-L311
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L319-L328
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L336-L347
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L355-L400
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L420-L442
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L451-L472
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.registerModule
protected function registerModule($moduleName) { $module = new ModuleModel; $module->module_name = $this->def($moduleName, 'name'); $module->module_version = $this->def($moduleName, 'version'); $module->module_status = 0; $module->module_is_enabled = 0; $module->module_is_installed = 1; $module->save(); return true; }
php
protected function registerModule($moduleName) { $module = new ModuleModel; $module->module_name = $this->def($moduleName, 'name'); $module->module_version = $this->def($moduleName, 'version'); $module->module_status = 0; $module->module_is_enabled = 0; $module->module_is_installed = 1; $module->save(); return true; }
[ "protected", "function", "registerModule", "(", "$", "moduleName", ")", "{", "$", "module", "=", "new", "ModuleModel", ";", "$", "module", "->", "module_name", "=", "$", "this", "->", "def", "(", "$", "moduleName", ",", "'name'", ")", ";", "$", "module", "->", "module_version", "=", "$", "this", "->", "def", "(", "$", "moduleName", ",", "'version'", ")", ";", "$", "module", "->", "module_status", "=", "0", ";", "$", "module", "->", "module_is_enabled", "=", "0", ";", "$", "module", "->", "module_is_installed", "=", "1", ";", "$", "module", "->", "save", "(", ")", ";", "return", "true", ";", "}" ]
Register module @param string $moduleName @return bool
[ "Register", "module" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L480-L491
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L499-L505
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L515-L527
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L536-L552
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L560-L601
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.update
protected function update($newModulePath, $moduleName) { $curModulePath = $this->getModuleDirectory($moduleName); $curVersion = $this->def($moduleName, 'version'); $newVersion = $this->def($newModulePath, 'version', true); $curVersion = new Version($curVersion); $newVersion = new Version($newVersion); if (!$newVersion->greaterThan($curVersion)) { $this->errors->add('update_version', 'Current version is greater than or equal uploaded version.'); return false; } if ($this->checkModuleDepends($moduleName, $curVersion, $newVersion)) return false; $moduleDependency = $this->def($newModulePath, 'require', true); if (!$moduleDependency = $this->checkDependency($moduleDependency)) return false; //Move and replace new version if (!$this->removeModuleDirectory($moduleName)) return false; if (!$this->files->copyDirectory($newModulePath, $curModulePath)) { $this->errors->add('move_files', 'Can not move new version files to '.$newModulePath); return false; } $this->removeAssets($moduleName); $this->buildAssets($moduleName); $this->updateRegisteredModule($moduleName); return true; }
php
protected function update($newModulePath, $moduleName) { $curModulePath = $this->getModuleDirectory($moduleName); $curVersion = $this->def($moduleName, 'version'); $newVersion = $this->def($newModulePath, 'version', true); $curVersion = new Version($curVersion); $newVersion = new Version($newVersion); if (!$newVersion->greaterThan($curVersion)) { $this->errors->add('update_version', 'Current version is greater than or equal uploaded version.'); return false; } if ($this->checkModuleDepends($moduleName, $curVersion, $newVersion)) return false; $moduleDependency = $this->def($newModulePath, 'require', true); if (!$moduleDependency = $this->checkDependency($moduleDependency)) return false; //Move and replace new version if (!$this->removeModuleDirectory($moduleName)) return false; if (!$this->files->copyDirectory($newModulePath, $curModulePath)) { $this->errors->add('move_files', 'Can not move new version files to '.$newModulePath); return false; } $this->removeAssets($moduleName); $this->buildAssets($moduleName); $this->updateRegisteredModule($moduleName); return true; }
[ "protected", "function", "update", "(", "$", "newModulePath", ",", "$", "moduleName", ")", "{", "$", "curModulePath", "=", "$", "this", "->", "getModuleDirectory", "(", "$", "moduleName", ")", ";", "$", "curVersion", "=", "$", "this", "->", "def", "(", "$", "moduleName", ",", "'version'", ")", ";", "$", "newVersion", "=", "$", "this", "->", "def", "(", "$", "newModulePath", ",", "'version'", ",", "true", ")", ";", "$", "curVersion", "=", "new", "Version", "(", "$", "curVersion", ")", ";", "$", "newVersion", "=", "new", "Version", "(", "$", "newVersion", ")", ";", "if", "(", "!", "$", "newVersion", "->", "greaterThan", "(", "$", "curVersion", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "'update_version'", ",", "'Current version is greater than or equal uploaded version.'", ")", ";", "return", "false", ";", "}", "if", "(", "$", "this", "->", "checkModuleDepends", "(", "$", "moduleName", ",", "$", "curVersion", ",", "$", "newVersion", ")", ")", "return", "false", ";", "$", "moduleDependency", "=", "$", "this", "->", "def", "(", "$", "newModulePath", ",", "'require'", ",", "true", ")", ";", "if", "(", "!", "$", "moduleDependency", "=", "$", "this", "->", "checkDependency", "(", "$", "moduleDependency", ")", ")", "return", "false", ";", "//Move and replace new version", "if", "(", "!", "$", "this", "->", "removeModuleDirectory", "(", "$", "moduleName", ")", ")", "return", "false", ";", "if", "(", "!", "$", "this", "->", "files", "->", "copyDirectory", "(", "$", "newModulePath", ",", "$", "curModulePath", ")", ")", "{", "$", "this", "->", "errors", "->", "add", "(", "'move_files'", ",", "'Can not move new version files to '", ".", "$", "newModulePath", ")", ";", "return", "false", ";", "}", "$", "this", "->", "removeAssets", "(", "$", "moduleName", ")", ";", "$", "this", "->", "buildAssets", "(", "$", "moduleName", ")", ";", "$", "this", "->", "updateRegisteredModule", "(", "$", "moduleName", ")", ";", "return", "true", ";", "}" ]
Update module @param string $newModulePath path of zip @param string $moduleName @return bool
[ "Update", "module" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L622-L661
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L671-L709
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L719-L738
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L747-L759
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L768-L771
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L779-L786
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" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L794-L800
chee-commerce/CheeModule
src/Chee/Module/CheeModule.php
CheeModule.def
protected function def($moduleName, $key = null, $isAddress = false, $default = null) { if($isAddress) $definition = json_decode($this->app['files']->get($moduleName.$this->configFile), true); else $definition = json_decode($this->app['files']->get($this->getModuleDirectory($moduleName).$this->configFile), true); if ($key) if (isset($definition[$key])) return $definition[$key]; else return $default; else return $definition; }
php
protected function def($moduleName, $key = null, $isAddress = false, $default = null) { if($isAddress) $definition = json_decode($this->app['files']->get($moduleName.$this->configFile), true); else $definition = json_decode($this->app['files']->get($this->getModuleDirectory($moduleName).$this->configFile), true); if ($key) if (isset($definition[$key])) return $definition[$key]; else return $default; else return $definition; }
[ "protected", "function", "def", "(", "$", "moduleName", ",", "$", "key", "=", "null", ",", "$", "isAddress", "=", "false", ",", "$", "default", "=", "null", ")", "{", "if", "(", "$", "isAddress", ")", "$", "definition", "=", "json_decode", "(", "$", "this", "->", "app", "[", "'files'", "]", "->", "get", "(", "$", "moduleName", ".", "$", "this", "->", "configFile", ")", ",", "true", ")", ";", "else", "$", "definition", "=", "json_decode", "(", "$", "this", "->", "app", "[", "'files'", "]", "->", "get", "(", "$", "this", "->", "getModuleDirectory", "(", "$", "moduleName", ")", ".", "$", "this", "->", "configFile", ")", ",", "true", ")", ";", "if", "(", "$", "key", ")", "if", "(", "isset", "(", "$", "definition", "[", "$", "key", "]", ")", ")", "return", "$", "definition", "[", "$", "key", "]", ";", "else", "return", "$", "default", ";", "else", "return", "$", "definition", ";", "}" ]
Get module.json data of module @param string $moduleName name of module or address of @param string $key key of array @param string $isAddress if first parameter is address this parameter should be true @param mixed $default @return array|string|null
[ "Get", "module", ".", "json", "data", "of", "module" ]
train
https://github.com/chee-commerce/CheeModule/blob/ccfff426f4ecf8f13687f5acd49246ba4997deee/src/Chee/Module/CheeModule.php#L811-L825
IgorTimoshenko/IMTDataGrid
src/Filter/Reflection/Doctrine/ORM/FilterReflection.php
FilterReflection.reflect
public function reflect(FilterInterface $filter = null) { $exprParts = array(); /** * @var $rule \IMT\DataGrid\Filter\RuleInterface */ foreach ($filter->getRules() as $rule) { $ruleReflectionClass = sprintf( '%s\Rule\%sRuleReflection', __NAMESPACE__, ucfirst($rule->getOperator()) ); if (!class_exists($ruleReflectionClass)) { throw new ReflectionNotFoundException( sprintf( 'The data grid filter rule reflection class named `%s` ' . 'does not exist.', $ruleReflectionClass ) ); } /** * @var $ruleReflection ReflectionInterface */ $ruleReflection = new $ruleReflectionClass($this->queryBuilder); $exprParts[] = $ruleReflection->reflect($rule); } $exprOperation = mb_strtolower($filter->getOperator()) . 'X'; $expr = call_user_func_array( array($this->queryBuilder->expr(), $exprOperation), $exprParts ); $nestedExprParts = array(); foreach ($filter->getFilters() as $nestedFilter) { $nestedExprParts[] = $this->reflect($nestedFilter); } if (count($nestedExprParts) == 0) { return $expr; } return call_user_func_array( array($this->queryBuilder->expr(), 'andX'), array_merge(array($expr), $nestedExprParts) ); }
php
public function reflect(FilterInterface $filter = null) { $exprParts = array(); /** * @var $rule \IMT\DataGrid\Filter\RuleInterface */ foreach ($filter->getRules() as $rule) { $ruleReflectionClass = sprintf( '%s\Rule\%sRuleReflection', __NAMESPACE__, ucfirst($rule->getOperator()) ); if (!class_exists($ruleReflectionClass)) { throw new ReflectionNotFoundException( sprintf( 'The data grid filter rule reflection class named `%s` ' . 'does not exist.', $ruleReflectionClass ) ); } /** * @var $ruleReflection ReflectionInterface */ $ruleReflection = new $ruleReflectionClass($this->queryBuilder); $exprParts[] = $ruleReflection->reflect($rule); } $exprOperation = mb_strtolower($filter->getOperator()) . 'X'; $expr = call_user_func_array( array($this->queryBuilder->expr(), $exprOperation), $exprParts ); $nestedExprParts = array(); foreach ($filter->getFilters() as $nestedFilter) { $nestedExprParts[] = $this->reflect($nestedFilter); } if (count($nestedExprParts) == 0) { return $expr; } return call_user_func_array( array($this->queryBuilder->expr(), 'andX'), array_merge(array($expr), $nestedExprParts) ); }
[ "public", "function", "reflect", "(", "FilterInterface", "$", "filter", "=", "null", ")", "{", "$", "exprParts", "=", "array", "(", ")", ";", "/**\n * @var $rule \\IMT\\DataGrid\\Filter\\RuleInterface\n */", "foreach", "(", "$", "filter", "->", "getRules", "(", ")", "as", "$", "rule", ")", "{", "$", "ruleReflectionClass", "=", "sprintf", "(", "'%s\\Rule\\%sRuleReflection'", ",", "__NAMESPACE__", ",", "ucfirst", "(", "$", "rule", "->", "getOperator", "(", ")", ")", ")", ";", "if", "(", "!", "class_exists", "(", "$", "ruleReflectionClass", ")", ")", "{", "throw", "new", "ReflectionNotFoundException", "(", "sprintf", "(", "'The data grid filter rule reflection class named `%s` '", ".", "'does not exist.'", ",", "$", "ruleReflectionClass", ")", ")", ";", "}", "/**\n * @var $ruleReflection ReflectionInterface\n */", "$", "ruleReflection", "=", "new", "$", "ruleReflectionClass", "(", "$", "this", "->", "queryBuilder", ")", ";", "$", "exprParts", "[", "]", "=", "$", "ruleReflection", "->", "reflect", "(", "$", "rule", ")", ";", "}", "$", "exprOperation", "=", "mb_strtolower", "(", "$", "filter", "->", "getOperator", "(", ")", ")", ".", "'X'", ";", "$", "expr", "=", "call_user_func_array", "(", "array", "(", "$", "this", "->", "queryBuilder", "->", "expr", "(", ")", ",", "$", "exprOperation", ")", ",", "$", "exprParts", ")", ";", "$", "nestedExprParts", "=", "array", "(", ")", ";", "foreach", "(", "$", "filter", "->", "getFilters", "(", ")", "as", "$", "nestedFilter", ")", "{", "$", "nestedExprParts", "[", "]", "=", "$", "this", "->", "reflect", "(", "$", "nestedFilter", ")", ";", "}", "if", "(", "count", "(", "$", "nestedExprParts", ")", "==", "0", ")", "{", "return", "$", "expr", ";", "}", "return", "call_user_func_array", "(", "array", "(", "$", "this", "->", "queryBuilder", "->", "expr", "(", ")", ",", "'andX'", ")", ",", "array_merge", "(", "array", "(", "$", "expr", ")", ",", "$", "nestedExprParts", ")", ")", ";", "}" ]
{@inheritDoc} @param FilterInterface $filter @return Base @throws ReflectionNotFoundException If the data grid filter rule reflection class does not exist
[ "{" ]
train
https://github.com/IgorTimoshenko/IMTDataGrid/blob/c70c12a250e9b17870c2cd6cc7fa1f35cbf3b9af/src/Filter/Reflection/Doctrine/ORM/FilterReflection.php#L51-L103
WellCommerce/CartBundle
DataSet/Front/CartProductDataSet.php
CartProductDataSet.configureOptions
public function configureOptions(DataSetConfiguratorInterface $configurator) { $configurator->setColumns([ 'id' => 'cart_product.id', 'price' => 'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.sellPrice.grossAmount, product.sellPrice.grossAmount)', 'discountedPrice' => 'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.sellPrice.discountedGrossAmount, product.sellPrice.discountedGrossAmount)', 'currency' => 'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.sellPrice.currency, product.sellPrice.currency)', 'stock' => 'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.stock, product.stock)', 'weight' => 'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.weight, product.weight)', 'quantity' => 'cart_product.quantity', 'variant' => 'IDENTITY(cart_product.variant)', 'options' => 'cart_product.options', 'name' => 'product_translation.name', 'route' => 'IDENTITY(product_translation.route)', 'isDiscountValid' => 'IF_ELSE(:date BETWEEN product.sellPrice.validFrom AND product.sellPrice.validTo, 1, 0)', 'tax' => 'sell_tax.value', 'photo' => 'photos.path' ]); $configurator->setColumnTransformers([ 'route' => $this->getDataSetTransformer('route'), ]); $configurator->setCacheOptions(new CacheOptions(true, 3600, [ Cart::class, CartProduct::class, Product::class, Variant::class, Tax::class ])); }
php
public function configureOptions(DataSetConfiguratorInterface $configurator) { $configurator->setColumns([ 'id' => 'cart_product.id', 'price' => 'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.sellPrice.grossAmount, product.sellPrice.grossAmount)', 'discountedPrice' => 'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.sellPrice.discountedGrossAmount, product.sellPrice.discountedGrossAmount)', 'currency' => 'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.sellPrice.currency, product.sellPrice.currency)', 'stock' => 'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.stock, product.stock)', 'weight' => 'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.weight, product.weight)', 'quantity' => 'cart_product.quantity', 'variant' => 'IDENTITY(cart_product.variant)', 'options' => 'cart_product.options', 'name' => 'product_translation.name', 'route' => 'IDENTITY(product_translation.route)', 'isDiscountValid' => 'IF_ELSE(:date BETWEEN product.sellPrice.validFrom AND product.sellPrice.validTo, 1, 0)', 'tax' => 'sell_tax.value', 'photo' => 'photos.path' ]); $configurator->setColumnTransformers([ 'route' => $this->getDataSetTransformer('route'), ]); $configurator->setCacheOptions(new CacheOptions(true, 3600, [ Cart::class, CartProduct::class, Product::class, Variant::class, Tax::class ])); }
[ "public", "function", "configureOptions", "(", "DataSetConfiguratorInterface", "$", "configurator", ")", "{", "$", "configurator", "->", "setColumns", "(", "[", "'id'", "=>", "'cart_product.id'", ",", "'price'", "=>", "'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.sellPrice.grossAmount, product.sellPrice.grossAmount)'", ",", "'discountedPrice'", "=>", "'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.sellPrice.discountedGrossAmount, product.sellPrice.discountedGrossAmount)'", ",", "'currency'", "=>", "'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.sellPrice.currency, product.sellPrice.currency)'", ",", "'stock'", "=>", "'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.stock, product.stock)'", ",", "'weight'", "=>", "'IF_ELSE(cart_product.variant IS NOT NULL, product_variant.weight, product.weight)'", ",", "'quantity'", "=>", "'cart_product.quantity'", ",", "'variant'", "=>", "'IDENTITY(cart_product.variant)'", ",", "'options'", "=>", "'cart_product.options'", ",", "'name'", "=>", "'product_translation.name'", ",", "'route'", "=>", "'IDENTITY(product_translation.route)'", ",", "'isDiscountValid'", "=>", "'IF_ELSE(:date BETWEEN product.sellPrice.validFrom AND product.sellPrice.validTo, 1, 0)'", ",", "'tax'", "=>", "'sell_tax.value'", ",", "'photo'", "=>", "'photos.path'", "]", ")", ";", "$", "configurator", "->", "setColumnTransformers", "(", "[", "'route'", "=>", "$", "this", "->", "getDataSetTransformer", "(", "'route'", ")", ",", "]", ")", ";", "$", "configurator", "->", "setCacheOptions", "(", "new", "CacheOptions", "(", "true", ",", "3600", ",", "[", "Cart", "::", "class", ",", "CartProduct", "::", "class", ",", "Product", "::", "class", ",", "Variant", "::", "class", ",", "Tax", "::", "class", "]", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/WellCommerce/CartBundle/blob/77c1e12b36bde008dca61260481b21135e339396/DataSet/Front/CartProductDataSet.php#L34-L64
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", "." ]
train
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Http/Message/RequestFactory.php#L176-L179
zapheus/zapheus
src/Http/Message/RequestFactory.php
RequestFactory.server
public function server(array $server) { parent::server($server); $this->server = $server; $this->method = $server['REQUEST_METHOD']; $this->target = $server['REQUEST_URI']; $http = 'https://'; if (! isset($server['HTTPS']) || $server['HTTPS'] === 'off') { $http = 'http://'; } $link = $http . $server['SERVER_NAME']; $port = $server['SERVER_PORT'] . $this->target; $this->uri = new Uri($link . ':' . $port); return $this; }
php
public function server(array $server) { parent::server($server); $this->server = $server; $this->method = $server['REQUEST_METHOD']; $this->target = $server['REQUEST_URI']; $http = 'https://'; if (! isset($server['HTTPS']) || $server['HTTPS'] === 'off') { $http = 'http://'; } $link = $http . $server['SERVER_NAME']; $port = $server['SERVER_PORT'] . $this->target; $this->uri = new Uri($link . ':' . $port); return $this; }
[ "public", "function", "server", "(", "array", "$", "server", ")", "{", "parent", "::", "server", "(", "$", "server", ")", ";", "$", "this", "->", "server", "=", "$", "server", ";", "$", "this", "->", "method", "=", "$", "server", "[", "'REQUEST_METHOD'", "]", ";", "$", "this", "->", "target", "=", "$", "server", "[", "'REQUEST_URI'", "]", ";", "$", "http", "=", "'https://'", ";", "if", "(", "!", "isset", "(", "$", "server", "[", "'HTTPS'", "]", ")", "||", "$", "server", "[", "'HTTPS'", "]", "===", "'off'", ")", "{", "$", "http", "=", "'http://'", ";", "}", "$", "link", "=", "$", "http", ".", "$", "server", "[", "'SERVER_NAME'", "]", ";", "$", "port", "=", "$", "server", "[", "'SERVER_PORT'", "]", ".", "$", "this", "->", "target", ";", "$", "this", "->", "uri", "=", "new", "Uri", "(", "$", "link", ".", "':'", ".", "$", "port", ")", ";", "return", "$", "this", ";", "}" ]
Sets the server parameters ($_SERVER). @param array $server @return self
[ "Sets", "the", "server", "parameters", "(", "$_SERVER", ")", "." ]
train
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Http/Message/RequestFactory.php#L227-L251
thomasez/BisonLabSakonninBundle
Lib/Sakonnin/MailForward.php
MailForward.execute
public function execute($options = array()) { $message = $options['message']; $receivers = isset($options['attributes']) ? $options['attributes'] : array(); $options['provide_link'] = true; foreach ($receivers as $receiver) { $this->sendMail($message, $receiver, $options); } // Message is handled, put in the archive $message->setState('ARCHIVED'); }
php
public function execute($options = array()) { $message = $options['message']; $receivers = isset($options['attributes']) ? $options['attributes'] : array(); $options['provide_link'] = true; foreach ($receivers as $receiver) { $this->sendMail($message, $receiver, $options); } // Message is handled, put in the archive $message->setState('ARCHIVED'); }
[ "public", "function", "execute", "(", "$", "options", "=", "array", "(", ")", ")", "{", "$", "message", "=", "$", "options", "[", "'message'", "]", ";", "$", "receivers", "=", "isset", "(", "$", "options", "[", "'attributes'", "]", ")", "?", "$", "options", "[", "'attributes'", "]", ":", "array", "(", ")", ";", "$", "options", "[", "'provide_link'", "]", "=", "true", ";", "foreach", "(", "$", "receivers", "as", "$", "receiver", ")", "{", "$", "this", "->", "sendMail", "(", "$", "message", ",", "$", "receiver", ",", "$", "options", ")", ";", "}", "// Message is handled, put in the archive", "$", "message", "->", "setState", "(", "'ARCHIVED'", ")", ";", "}" ]
/* You may call this lazyness, jkust having an options array, but it's also more future proof.
[ "/", "*", "You", "may", "call", "this", "lazyness", "jkust", "having", "an", "options", "array", "but", "it", "s", "also", "more", "future", "proof", "." ]
train
https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Lib/Sakonnin/MailForward.php#L14-L25
judus/minimal-provider
src/Exceptions/IocNotResolvableException.php
IocNotResolvableException.prettyMessage
public function prettyMessage($message = null, $data = null) { $this->setMyMessage($message); $this->setMyData($data); return $this->template([ 'title' => $this->getMyTitle(), 'message' => $this->getMyMessage(), 'file' => $this->getMyFile(), 'line' => $this->getMyLine(), 'data' => $this->getMyData(), 'traces' => $this->getMyTraces(), 'footer' => $this->getMyFooter() ]); }
php
public function prettyMessage($message = null, $data = null) { $this->setMyMessage($message); $this->setMyData($data); return $this->template([ 'title' => $this->getMyTitle(), 'message' => $this->getMyMessage(), 'file' => $this->getMyFile(), 'line' => $this->getMyLine(), 'data' => $this->getMyData(), 'traces' => $this->getMyTraces(), 'footer' => $this->getMyFooter() ]); }
[ "public", "function", "prettyMessage", "(", "$", "message", "=", "null", ",", "$", "data", "=", "null", ")", "{", "$", "this", "->", "setMyMessage", "(", "$", "message", ")", ";", "$", "this", "->", "setMyData", "(", "$", "data", ")", ";", "return", "$", "this", "->", "template", "(", "[", "'title'", "=>", "$", "this", "->", "getMyTitle", "(", ")", ",", "'message'", "=>", "$", "this", "->", "getMyMessage", "(", ")", ",", "'file'", "=>", "$", "this", "->", "getMyFile", "(", ")", ",", "'line'", "=>", "$", "this", "->", "getMyLine", "(", ")", ",", "'data'", "=>", "$", "this", "->", "getMyData", "(", ")", ",", "'traces'", "=>", "$", "this", "->", "getMyTraces", "(", ")", ",", "'footer'", "=>", "$", "this", "->", "getMyFooter", "(", ")", "]", ")", ";", "}" ]
@param null $message @param null $data @return mixed|string
[ "@param", "null", "$message", "@param", "null", "$data" ]
train
https://github.com/judus/minimal-provider/blob/1838f86f7c04fcb5f64bd6b6f18cd54f71c2401b/src/Exceptions/IocNotResolvableException.php#L273-L288
bheisig/cli
src/Log.php
Log.event
public function event($level, $value, ...$args) { if ($level & $this->verbosity) { $message = $value; if (count($args) > 0) { $message = call_user_func_array( 'sprintf', array_merge([$value], $args) ); } if ($this->colorize) { switch ($level) { case self::FATAL: $message = "<fatal>$message</fatal>"; break; case self::ERROR: $message = "<error>$message</error>"; break; case self::WARNING: $message = "<warning>$message</warning>"; break; case self::NOTICE: $message = "<notice>$message</notice>"; break; case self::DEBUG: $message = "<debug>$message</debug>"; break; } } $message = $this->formatText($message); $this->flush($message); } return $this; }
php
public function event($level, $value, ...$args) { if ($level & $this->verbosity) { $message = $value; if (count($args) > 0) { $message = call_user_func_array( 'sprintf', array_merge([$value], $args) ); } if ($this->colorize) { switch ($level) { case self::FATAL: $message = "<fatal>$message</fatal>"; break; case self::ERROR: $message = "<error>$message</error>"; break; case self::WARNING: $message = "<warning>$message</warning>"; break; case self::NOTICE: $message = "<notice>$message</notice>"; break; case self::DEBUG: $message = "<debug>$message</debug>"; break; } } $message = $this->formatText($message); $this->flush($message); } return $this; }
[ "public", "function", "event", "(", "$", "level", ",", "$", "value", ",", "...", "$", "args", ")", "{", "if", "(", "$", "level", "&", "$", "this", "->", "verbosity", ")", "{", "$", "message", "=", "$", "value", ";", "if", "(", "count", "(", "$", "args", ")", ">", "0", ")", "{", "$", "message", "=", "call_user_func_array", "(", "'sprintf'", ",", "array_merge", "(", "[", "$", "value", "]", ",", "$", "args", ")", ")", ";", "}", "if", "(", "$", "this", "->", "colorize", ")", "{", "switch", "(", "$", "level", ")", "{", "case", "self", "::", "FATAL", ":", "$", "message", "=", "\"<fatal>$message</fatal>\"", ";", "break", ";", "case", "self", "::", "ERROR", ":", "$", "message", "=", "\"<error>$message</error>\"", ";", "break", ";", "case", "self", "::", "WARNING", ":", "$", "message", "=", "\"<warning>$message</warning>\"", ";", "break", ";", "case", "self", "::", "NOTICE", ":", "$", "message", "=", "\"<notice>$message</notice>\"", ";", "break", ";", "case", "self", "::", "DEBUG", ":", "$", "message", "=", "\"<debug>$message</debug>\"", ";", "break", ";", "}", "}", "$", "message", "=", "$", "this", "->", "formatText", "(", "$", "message", ")", ";", "$", "this", "->", "flush", "(", "$", "message", ")", ";", "}", "return", "$", "this", ";", "}" ]
Log event. It provides the same functionality as sprintf() by passing three or more arguments. @param int $level Event level. One of the following class constants: DEBUG, INFO, NOTICE, WARNING, ERROR or FATAL. @param string $value What to be formatted @param mixed ...$args (Optional) One or more arguments @return self Returns itself @see sprintf()
[ "Log", "event", ".", "It", "provides", "the", "same", "functionality", "as", "sprintf", "()", "by", "passing", "three", "or", "more", "arguments", "." ]
train
https://github.com/bheisig/cli/blob/ee77266e173335950357899cdfe86b43c00a6776/src/Log.php#L212-L249
bheisig/cli
src/Log.php
Log.fatal
public function fatal($value, ...$args) { return call_user_func_array( [__CLASS__, 'event'], array_merge([self::FATAL, $value], $args) ); }
php
public function fatal($value, ...$args) { return call_user_func_array( [__CLASS__, 'event'], array_merge([self::FATAL, $value], $args) ); }
[ "public", "function", "fatal", "(", "$", "value", ",", "...", "$", "args", ")", "{", "return", "call_user_func_array", "(", "[", "__CLASS__", ",", "'event'", "]", ",", "array_merge", "(", "[", "self", "::", "FATAL", ",", "$", "value", "]", ",", "$", "args", ")", ")", ";", "}" ]
Log fatal event. It provides the same functionality as sprintf() by passing two or more arguments. @param string $value What to be formatted @param mixed ...$args (Optional) One or more arguments @return self Returns itself @see sprintf()
[ "Log", "fatal", "event", ".", "It", "provides", "the", "same", "functionality", "as", "sprintf", "()", "by", "passing", "two", "or", "more", "arguments", "." ]
train
https://github.com/bheisig/cli/blob/ee77266e173335950357899cdfe86b43c00a6776/src/Log.php#L261-L266
bheisig/cli
src/Log.php
Log.error
public function error($value, ...$args) { return call_user_func_array( [__CLASS__, 'event'], array_merge([self::ERROR, $value], $args) ); }
php
public function error($value, ...$args) { return call_user_func_array( [__CLASS__, 'event'], array_merge([self::ERROR, $value], $args) ); }
[ "public", "function", "error", "(", "$", "value", ",", "...", "$", "args", ")", "{", "return", "call_user_func_array", "(", "[", "__CLASS__", ",", "'event'", "]", ",", "array_merge", "(", "[", "self", "::", "ERROR", ",", "$", "value", "]", ",", "$", "args", ")", ")", ";", "}" ]
Log error event. It provides the same functionality as sprintf() by passing two or more arguments. @param string $value What to be formatted @param mixed ...$args (Optional) One or more arguments @return self Returns itself @see sprintf()
[ "Log", "error", "event", ".", "It", "provides", "the", "same", "functionality", "as", "sprintf", "()", "by", "passing", "two", "or", "more", "arguments", "." ]
train
https://github.com/bheisig/cli/blob/ee77266e173335950357899cdfe86b43c00a6776/src/Log.php#L278-L283
bheisig/cli
src/Log.php
Log.warning
public function warning($value, ...$args) { return call_user_func_array( [__CLASS__, 'event'], array_merge([self::WARNING, $value], $args) ); }
php
public function warning($value, ...$args) { return call_user_func_array( [__CLASS__, 'event'], array_merge([self::WARNING, $value], $args) ); }
[ "public", "function", "warning", "(", "$", "value", ",", "...", "$", "args", ")", "{", "return", "call_user_func_array", "(", "[", "__CLASS__", ",", "'event'", "]", ",", "array_merge", "(", "[", "self", "::", "WARNING", ",", "$", "value", "]", ",", "$", "args", ")", ")", ";", "}" ]
Log warning event. It provides the same functionality as sprintf() by passing two or more arguments. @param string $value What to be formatted @param mixed ...$args (Optional) One or more arguments @return self Returns itself @see sprintf()
[ "Log", "warning", "event", ".", "It", "provides", "the", "same", "functionality", "as", "sprintf", "()", "by", "passing", "two", "or", "more", "arguments", "." ]
train
https://github.com/bheisig/cli/blob/ee77266e173335950357899cdfe86b43c00a6776/src/Log.php#L295-L300
bheisig/cli
src/Log.php
Log.notice
public function notice($value, ...$args) { return call_user_func_array( [__CLASS__, 'event'], array_merge([self::NOTICE, $value], $args) ); }
php
public function notice($value, ...$args) { return call_user_func_array( [__CLASS__, 'event'], array_merge([self::NOTICE, $value], $args) ); }
[ "public", "function", "notice", "(", "$", "value", ",", "...", "$", "args", ")", "{", "return", "call_user_func_array", "(", "[", "__CLASS__", ",", "'event'", "]", ",", "array_merge", "(", "[", "self", "::", "NOTICE", ",", "$", "value", "]", ",", "$", "args", ")", ")", ";", "}" ]
Log warning event. It provides the same functionality as sprintf() by passing two or more arguments. @param string $value What to be formatted @param mixed ...$args (Optional) One or more arguments @return self Returns itself @see sprintf()
[ "Log", "warning", "event", ".", "It", "provides", "the", "same", "functionality", "as", "sprintf", "()", "by", "passing", "two", "or", "more", "arguments", "." ]
train
https://github.com/bheisig/cli/blob/ee77266e173335950357899cdfe86b43c00a6776/src/Log.php#L312-L317
bheisig/cli
src/Log.php
Log.info
public function info($value, ...$args) { return call_user_func_array( [__CLASS__, 'event'], array_merge([self::INFO, $value], $args) ); }
php
public function info($value, ...$args) { return call_user_func_array( [__CLASS__, 'event'], array_merge([self::INFO, $value], $args) ); }
[ "public", "function", "info", "(", "$", "value", ",", "...", "$", "args", ")", "{", "return", "call_user_func_array", "(", "[", "__CLASS__", ",", "'event'", "]", ",", "array_merge", "(", "[", "self", "::", "INFO", ",", "$", "value", "]", ",", "$", "args", ")", ")", ";", "}" ]
Log info event. It provides the same functionality as sprintf() by passing two or more arguments. @param string $value What to be formatted @param mixed ...$args (Optional) One or more arguments @return self Returns itself @see sprintf()
[ "Log", "info", "event", ".", "It", "provides", "the", "same", "functionality", "as", "sprintf", "()", "by", "passing", "two", "or", "more", "arguments", "." ]
train
https://github.com/bheisig/cli/blob/ee77266e173335950357899cdfe86b43c00a6776/src/Log.php#L329-L334
bheisig/cli
src/Log.php
Log.debug
public function debug($value, ...$args) { return call_user_func_array( [__CLASS__, 'event'], array_merge([self::DEBUG, $value], $args) ); }
php
public function debug($value, ...$args) { return call_user_func_array( [__CLASS__, 'event'], array_merge([self::DEBUG, $value], $args) ); }
[ "public", "function", "debug", "(", "$", "value", ",", "...", "$", "args", ")", "{", "return", "call_user_func_array", "(", "[", "__CLASS__", ",", "'event'", "]", ",", "array_merge", "(", "[", "self", "::", "DEBUG", ",", "$", "value", "]", ",", "$", "args", ")", ")", ";", "}" ]
Log debug event. It provides the same functionality as sprintf() by passing two or more arguments. @param string $value What to be formatted @param mixed ...$args (Optional) One or more arguments @return self Returns itself @see sprintf()
[ "Log", "debug", "event", ".", "It", "provides", "the", "same", "functionality", "as", "sprintf", "()", "by", "passing", "two", "or", "more", "arguments", "." ]
train
https://github.com/bheisig/cli/blob/ee77266e173335950357899cdfe86b43c00a6776/src/Log.php#L346-L351
bheisig/cli
src/Log.php
Log.formatText
protected function formatText($text) { $syntax = [ '/\<strong\>/m' => "\033[1m", '/\<u\>/m' => "\033[4m", '/\<dim\>/m' => "\033[2m", '/\<fatal\>/m' => "\033[" . $this->colors[self::FATAL] . "m", '/\<error\>/m' => "\033[" . $this->colors[self::ERROR] . "m", '/\<warning\>/m' => "\033[" . $this->colors[self::WARNING] . "m", '/\<notice\>/m' => "\033[" . $this->colors[self::NOTICE] . "m", '/\<debug\>/m' => "\033[" . $this->colors[self::DEBUG] . "m", '/\<red\>/m' => "\033[31m", '/\<yellow\>/m' => "\033[33m", '/\<green\>/m' => "\033[32m", '/\<grey\>/m' => "\033[37m", '/\<\/([a-z]+)\>/m' => "\033[0m", ]; $replacements = '$1'; if ($this->colorize) { $replacements = $syntax; } $result = preg_replace( array_keys($syntax), $replacements, $text ); if (!is_string($result)) { throw new RuntimeException('Unable to format text', ExitApp::RUNTIME_ERROR); } return $result; }
php
protected function formatText($text) { $syntax = [ '/\<strong\>/m' => "\033[1m", '/\<u\>/m' => "\033[4m", '/\<dim\>/m' => "\033[2m", '/\<fatal\>/m' => "\033[" . $this->colors[self::FATAL] . "m", '/\<error\>/m' => "\033[" . $this->colors[self::ERROR] . "m", '/\<warning\>/m' => "\033[" . $this->colors[self::WARNING] . "m", '/\<notice\>/m' => "\033[" . $this->colors[self::NOTICE] . "m", '/\<debug\>/m' => "\033[" . $this->colors[self::DEBUG] . "m", '/\<red\>/m' => "\033[31m", '/\<yellow\>/m' => "\033[33m", '/\<green\>/m' => "\033[32m", '/\<grey\>/m' => "\033[37m", '/\<\/([a-z]+)\>/m' => "\033[0m", ]; $replacements = '$1'; if ($this->colorize) { $replacements = $syntax; } $result = preg_replace( array_keys($syntax), $replacements, $text ); if (!is_string($result)) { throw new RuntimeException('Unable to format text', ExitApp::RUNTIME_ERROR); } return $result; }
[ "protected", "function", "formatText", "(", "$", "text", ")", "{", "$", "syntax", "=", "[", "'/\\<strong\\>/m'", "=>", "\"\\033[1m\"", ",", "'/\\<u\\>/m'", "=>", "\"\\033[4m\"", ",", "'/\\<dim\\>/m'", "=>", "\"\\033[2m\"", ",", "'/\\<fatal\\>/m'", "=>", "\"\\033[\"", ".", "$", "this", "->", "colors", "[", "self", "::", "FATAL", "]", ".", "\"m\"", ",", "'/\\<error\\>/m'", "=>", "\"\\033[\"", ".", "$", "this", "->", "colors", "[", "self", "::", "ERROR", "]", ".", "\"m\"", ",", "'/\\<warning\\>/m'", "=>", "\"\\033[\"", ".", "$", "this", "->", "colors", "[", "self", "::", "WARNING", "]", ".", "\"m\"", ",", "'/\\<notice\\>/m'", "=>", "\"\\033[\"", ".", "$", "this", "->", "colors", "[", "self", "::", "NOTICE", "]", ".", "\"m\"", ",", "'/\\<debug\\>/m'", "=>", "\"\\033[\"", ".", "$", "this", "->", "colors", "[", "self", "::", "DEBUG", "]", ".", "\"m\"", ",", "'/\\<red\\>/m'", "=>", "\"\\033[31m\"", ",", "'/\\<yellow\\>/m'", "=>", "\"\\033[33m\"", ",", "'/\\<green\\>/m'", "=>", "\"\\033[32m\"", ",", "'/\\<grey\\>/m'", "=>", "\"\\033[37m\"", ",", "'/\\<\\/([a-z]+)\\>/m'", "=>", "\"\\033[0m\"", ",", "]", ";", "$", "replacements", "=", "'$1'", ";", "if", "(", "$", "this", "->", "colorize", ")", "{", "$", "replacements", "=", "$", "syntax", ";", "}", "$", "result", "=", "preg_replace", "(", "array_keys", "(", "$", "syntax", ")", ",", "$", "replacements", ",", "$", "text", ")", ";", "if", "(", "!", "is_string", "(", "$", "result", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Unable to format text'", ",", "ExitApp", "::", "RUNTIME_ERROR", ")", ";", "}", "return", "$", "result", ";", "}" ]
Format text @param string $text Unformatted text @return string Formatted text @throws RuntimeException on error
[ "Format", "text" ]
train
https://github.com/bheisig/cli/blob/ee77266e173335950357899cdfe86b43c00a6776/src/Log.php#L371-L405
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" ]
train
https://github.com/bheisig/cli/blob/ee77266e173335950357899cdfe86b43c00a6776/src/Log.php#L412-L421
Nicklas766/Comment
src/Comment/Modules/Comment.php
Comment.getComments
public function getComments($sql, $params) { $comments = $this->findAllWhere("$sql", $params); return array_map(function ($comment) { $user = new User($this->db); $comment->img = $user->getGravatar($comment->user); $comment->markdown = $this->getMD($comment->text); // Get votes for Post $vote = new Vote($this->db); $comment->vote = $vote->getVote("parentId = ? AND parentType = ?", [$comment->id, "comment"]); return $comment; }, $comments); }
php
public function getComments($sql, $params) { $comments = $this->findAllWhere("$sql", $params); return array_map(function ($comment) { $user = new User($this->db); $comment->img = $user->getGravatar($comment->user); $comment->markdown = $this->getMD($comment->text); // Get votes for Post $vote = new Vote($this->db); $comment->vote = $vote->getVote("parentId = ? AND parentType = ?", [$comment->id, "comment"]); return $comment; }, $comments); }
[ "public", "function", "getComments", "(", "$", "sql", ",", "$", "params", ")", "{", "$", "comments", "=", "$", "this", "->", "findAllWhere", "(", "\"$sql\"", ",", "$", "params", ")", ";", "return", "array_map", "(", "function", "(", "$", "comment", ")", "{", "$", "user", "=", "new", "User", "(", "$", "this", "->", "db", ")", ";", "$", "comment", "->", "img", "=", "$", "user", "->", "getGravatar", "(", "$", "comment", "->", "user", ")", ";", "$", "comment", "->", "markdown", "=", "$", "this", "->", "getMD", "(", "$", "comment", "->", "text", ")", ";", "// Get votes for Post", "$", "vote", "=", "new", "Vote", "(", "$", "this", "->", "db", ")", ";", "$", "comment", "->", "vote", "=", "$", "vote", "->", "getVote", "(", "\"parentId = ? AND parentType = ?\"", ",", "[", "$", "comment", "->", "id", ",", "\"comment\"", "]", ")", ";", "return", "$", "comment", ";", "}", ",", "$", "comments", ")", ";", "}" ]
Returns post with markdown and gravatar @param string $sql @param array $param @return array
[ "Returns", "post", "with", "markdown", "and", "gravatar", "@param", "string", "$sql", "@param", "array", "$param" ]
train
https://github.com/Nicklas766/Comment/blob/1483eaf1ebb120b8bd6c2a1552c084b3a288ff25/src/Comment/Modules/Comment.php#L36-L51
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" ]
train
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L157-L168
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" ]
train
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L177-L182
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" ]
train
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L244-L252
wb-crowdfusion/crowdfusion
system/core/classes/libraries/database/DTO.php
DTO.getResult
public function getResult($index = 0) { if($index == 0 && count($this->results) > 0) return current($this->results); return isset($this->results[$index]) ? $this->results[$index] : null; }
php
public function getResult($index = 0) { if($index == 0 && count($this->results) > 0) return current($this->results); return isset($this->results[$index]) ? $this->results[$index] : null; }
[ "public", "function", "getResult", "(", "$", "index", "=", "0", ")", "{", "if", "(", "$", "index", "==", "0", "&&", "count", "(", "$", "this", "->", "results", ")", ">", "0", ")", "return", "current", "(", "$", "this", "->", "results", ")", ";", "return", "isset", "(", "$", "this", "->", "results", "[", "$", "index", "]", ")", "?", "$", "this", "->", "results", "[", "$", "index", "]", ":", "null", ";", "}" ]
Returns the result at the specified {@link $index} @param integer $index The index to get @return mixed The result at the specified index or null if it doesn't exist
[ "Returns", "the", "result", "at", "the", "specified", "{", "@link", "$index", "}" ]
train
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L308-L316
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" ]
train
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L369-L379
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" ]
train
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L386-L398
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" ]
train
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L407-L417
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" ]
train
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L450-L458
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" ]
train
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/database/DTO.php#L470-L478
bseddon/XPath20
DOM/XmlSchema.php
XmlSchema.__static
public static function __static() { // XmlTypeCode::getTypeForCode( XmlTypeCode::Boolean ); XmlSchema::$AnySimpleType = DOMSchemaType::GetBuiltInSimpleTypeByQName( new \lyquidity\xml\qname( SCHEMA_PREFIX, XmlReservedNs::xs, "anySimpleType" ) ); XmlSchema::$AnyType = DOMSchemaType::GetBuiltInComplexTypeByQName( new \lyquidity\xml\qname( SCHEMA_PREFIX, XmlReservedNs::xs, "anyType" ) ); XmlSchema::$AnyUri = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::AnyUri ); XmlSchema::$AnyAtomicType = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::AnyAtomicType ); XmlSchema::$UntypedAtomic = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::UntypedAtomic ); XmlSchema::$Boolean = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Boolean ); XmlSchema::$Byte = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Byte ); XmlSchema::$Integer = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Integer ); XmlSchema::$Decimal = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Decimal ); XmlSchema::$Double = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Double ); XmlSchema::$Float = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Float ); XmlSchema::$Long = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Long ); XmlSchema::$Short = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Short ); XmlSchema::$UnsignedLong = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::UnsignedLong ); XmlSchema::$UnsignedInt = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::UnsignedInt ); XmlSchema::$UnsignedShort = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::UnsignedShort ); XmlSchema::$DateTime = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::DateTime ); XmlSchema::$Date = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Date ); XmlSchema::$Time = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Time ); XmlSchema::$Duration = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Duration ); XmlSchema::$YearMonthDuration = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::YearMonthDuration ); XmlSchema::$DayTimeDuration = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::DayTimeDuration ); XmlSchema::$GYearMonth = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::GYearMonth ); XmlSchema::$GYear = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::GYear ); XmlSchema::$GDay = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::GDay ); XmlSchema::$GMonth = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::GMonth ); XmlSchema::$GMonthDay = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::GMonthDay ); XmlSchema::$QName = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::QName ); XmlSchema::$HexBinary = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::HexBinary ); XmlSchema::$Base64Binary = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Base64Binary ); XmlSchema::$NMTOKEN = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::NmToken ); XmlSchema::$IDREF = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Idref ); XmlSchema::$ID = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Id ); XmlSchema::$IDREFS = DOMSchemaType::GetBuiltInSimpleTypeByQName( new \lyquidity\xml\qname( SCHEMA_PREFIX, XmlReservedNs::xs, "IDREFS" ) ); XmlSchema::$NMTOKENS = DOMSchemaType::GetBuiltInSimpleTypeByQName( new \lyquidity\xml\qname( SCHEMA_PREFIX, XmlReservedNs::xs, "NMTOKENS" ) ); XmlSchema::$ENTITY = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Entity ); XmlSchema::$ENTITIES = DOMSchemaType::GetBuiltInSimpleTypeByQName( new \lyquidity\xml\qname( SCHEMA_PREFIX, XmlReservedNs::xs, "ENTITIES" ) ); XmlSchema::$Name = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Name ); XmlSchema::$NCName = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::NCName ); XmlSchema::$String = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::String ); XmlSchema::$Token = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Token ); XmlSchema::$Notation = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Notation ); XmlSchema::$Language = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Language ); XmlSchema::$NormalizedString = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::NormalizedString ); }
php
public static function __static() { // XmlTypeCode::getTypeForCode( XmlTypeCode::Boolean ); XmlSchema::$AnySimpleType = DOMSchemaType::GetBuiltInSimpleTypeByQName( new \lyquidity\xml\qname( SCHEMA_PREFIX, XmlReservedNs::xs, "anySimpleType" ) ); XmlSchema::$AnyType = DOMSchemaType::GetBuiltInComplexTypeByQName( new \lyquidity\xml\qname( SCHEMA_PREFIX, XmlReservedNs::xs, "anyType" ) ); XmlSchema::$AnyUri = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::AnyUri ); XmlSchema::$AnyAtomicType = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::AnyAtomicType ); XmlSchema::$UntypedAtomic = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::UntypedAtomic ); XmlSchema::$Boolean = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Boolean ); XmlSchema::$Byte = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Byte ); XmlSchema::$Integer = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Integer ); XmlSchema::$Decimal = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Decimal ); XmlSchema::$Double = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Double ); XmlSchema::$Float = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Float ); XmlSchema::$Long = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Long ); XmlSchema::$Short = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Short ); XmlSchema::$UnsignedLong = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::UnsignedLong ); XmlSchema::$UnsignedInt = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::UnsignedInt ); XmlSchema::$UnsignedShort = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::UnsignedShort ); XmlSchema::$DateTime = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::DateTime ); XmlSchema::$Date = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Date ); XmlSchema::$Time = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Time ); XmlSchema::$Duration = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Duration ); XmlSchema::$YearMonthDuration = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::YearMonthDuration ); XmlSchema::$DayTimeDuration = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::DayTimeDuration ); XmlSchema::$GYearMonth = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::GYearMonth ); XmlSchema::$GYear = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::GYear ); XmlSchema::$GDay = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::GDay ); XmlSchema::$GMonth = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::GMonth ); XmlSchema::$GMonthDay = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::GMonthDay ); XmlSchema::$QName = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::QName ); XmlSchema::$HexBinary = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::HexBinary ); XmlSchema::$Base64Binary = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Base64Binary ); XmlSchema::$NMTOKEN = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::NmToken ); XmlSchema::$IDREF = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Idref ); XmlSchema::$ID = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Id ); XmlSchema::$IDREFS = DOMSchemaType::GetBuiltInSimpleTypeByQName( new \lyquidity\xml\qname( SCHEMA_PREFIX, XmlReservedNs::xs, "IDREFS" ) ); XmlSchema::$NMTOKENS = DOMSchemaType::GetBuiltInSimpleTypeByQName( new \lyquidity\xml\qname( SCHEMA_PREFIX, XmlReservedNs::xs, "NMTOKENS" ) ); XmlSchema::$ENTITY = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Entity ); XmlSchema::$ENTITIES = DOMSchemaType::GetBuiltInSimpleTypeByQName( new \lyquidity\xml\qname( SCHEMA_PREFIX, XmlReservedNs::xs, "ENTITIES" ) ); XmlSchema::$Name = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Name ); XmlSchema::$NCName = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::NCName ); XmlSchema::$String = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::String ); XmlSchema::$Token = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Token ); XmlSchema::$Notation = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Notation ); XmlSchema::$Language = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::Language ); XmlSchema::$NormalizedString = DOMSchemaType::GetBuiltInSimpleTypeByTypecode( XmlTypeCode::NormalizedString ); }
[ "public", "static", "function", "__static", "(", ")", "{", "// XmlTypeCode::getTypeForCode( XmlTypeCode::Boolean );\r", "XmlSchema", "::", "$", "AnySimpleType", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByQName", "(", "new", "\\", "lyquidity", "\\", "xml", "\\", "qname", "(", "SCHEMA_PREFIX", ",", "XmlReservedNs", "::", "xs", ",", "\"anySimpleType\"", ")", ")", ";", "XmlSchema", "::", "$", "AnyType", "=", "DOMSchemaType", "::", "GetBuiltInComplexTypeByQName", "(", "new", "\\", "lyquidity", "\\", "xml", "\\", "qname", "(", "SCHEMA_PREFIX", ",", "XmlReservedNs", "::", "xs", ",", "\"anyType\"", ")", ")", ";", "XmlSchema", "::", "$", "AnyUri", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "AnyUri", ")", ";", "XmlSchema", "::", "$", "AnyAtomicType", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "AnyAtomicType", ")", ";", "XmlSchema", "::", "$", "UntypedAtomic", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "UntypedAtomic", ")", ";", "XmlSchema", "::", "$", "Boolean", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Boolean", ")", ";", "XmlSchema", "::", "$", "Byte", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Byte", ")", ";", "XmlSchema", "::", "$", "Integer", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Integer", ")", ";", "XmlSchema", "::", "$", "Decimal", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Decimal", ")", ";", "XmlSchema", "::", "$", "Double", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Double", ")", ";", "XmlSchema", "::", "$", "Float", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Float", ")", ";", "XmlSchema", "::", "$", "Long", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Long", ")", ";", "XmlSchema", "::", "$", "Short", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Short", ")", ";", "XmlSchema", "::", "$", "UnsignedLong", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "UnsignedLong", ")", ";", "XmlSchema", "::", "$", "UnsignedInt", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "UnsignedInt", ")", ";", "XmlSchema", "::", "$", "UnsignedShort", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "UnsignedShort", ")", ";", "XmlSchema", "::", "$", "DateTime", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "DateTime", ")", ";", "XmlSchema", "::", "$", "Date", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Date", ")", ";", "XmlSchema", "::", "$", "Time", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Time", ")", ";", "XmlSchema", "::", "$", "Duration", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Duration", ")", ";", "XmlSchema", "::", "$", "YearMonthDuration", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "YearMonthDuration", ")", ";", "XmlSchema", "::", "$", "DayTimeDuration", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "DayTimeDuration", ")", ";", "XmlSchema", "::", "$", "GYearMonth", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "GYearMonth", ")", ";", "XmlSchema", "::", "$", "GYear", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "GYear", ")", ";", "XmlSchema", "::", "$", "GDay", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "GDay", ")", ";", "XmlSchema", "::", "$", "GMonth", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "GMonth", ")", ";", "XmlSchema", "::", "$", "GMonthDay", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "GMonthDay", ")", ";", "XmlSchema", "::", "$", "QName", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "QName", ")", ";", "XmlSchema", "::", "$", "HexBinary", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "HexBinary", ")", ";", "XmlSchema", "::", "$", "Base64Binary", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Base64Binary", ")", ";", "XmlSchema", "::", "$", "NMTOKEN", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "NmToken", ")", ";", "XmlSchema", "::", "$", "IDREF", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Idref", ")", ";", "XmlSchema", "::", "$", "ID", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Id", ")", ";", "XmlSchema", "::", "$", "IDREFS", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByQName", "(", "new", "\\", "lyquidity", "\\", "xml", "\\", "qname", "(", "SCHEMA_PREFIX", ",", "XmlReservedNs", "::", "xs", ",", "\"IDREFS\"", ")", ")", ";", "XmlSchema", "::", "$", "NMTOKENS", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByQName", "(", "new", "\\", "lyquidity", "\\", "xml", "\\", "qname", "(", "SCHEMA_PREFIX", ",", "XmlReservedNs", "::", "xs", ",", "\"NMTOKENS\"", ")", ")", ";", "XmlSchema", "::", "$", "ENTITY", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Entity", ")", ";", "XmlSchema", "::", "$", "ENTITIES", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByQName", "(", "new", "\\", "lyquidity", "\\", "xml", "\\", "qname", "(", "SCHEMA_PREFIX", ",", "XmlReservedNs", "::", "xs", ",", "\"ENTITIES\"", ")", ")", ";", "XmlSchema", "::", "$", "Name", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Name", ")", ";", "XmlSchema", "::", "$", "NCName", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "NCName", ")", ";", "XmlSchema", "::", "$", "String", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "String", ")", ";", "XmlSchema", "::", "$", "Token", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Token", ")", ";", "XmlSchema", "::", "$", "Notation", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Notation", ")", ";", "XmlSchema", "::", "$", "Language", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "Language", ")", ";", "XmlSchema", "::", "$", "NormalizedString", "=", "DOMSchemaType", "::", "GetBuiltInSimpleTypeByTypecode", "(", "XmlTypeCode", "::", "NormalizedString", ")", ";", "}" ]
Static constructor
[ "Static", "constructor" ]
train
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/XmlSchema.php#L336-L383
netbull/CoreBundle
ORM/Types/Point.php
Point.convertToPHPValue
public function convertToPHPValue($value, AbstractPlatform $platform) { list($longitude, $latitude) = sscanf($value, 'POINT(%f %f)'); return new BasePoint($latitude, $longitude); }
php
public function convertToPHPValue($value, AbstractPlatform $platform) { list($longitude, $latitude) = sscanf($value, 'POINT(%f %f)'); return new BasePoint($latitude, $longitude); }
[ "public", "function", "convertToPHPValue", "(", "$", "value", ",", "AbstractPlatform", "$", "platform", ")", "{", "list", "(", "$", "longitude", ",", "$", "latitude", ")", "=", "sscanf", "(", "$", "value", ",", "'POINT(%f %f)'", ")", ";", "return", "new", "BasePoint", "(", "$", "latitude", ",", "$", "longitude", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/netbull/CoreBundle/blob/0bacc1d9e4733b6da613027400c48421e5a14645/ORM/Types/Point.php#L37-L42
netbull/CoreBundle
ORM/Types/Point.php
Point.convertToDatabaseValue
public function convertToDatabaseValue($value, AbstractPlatform $platform) { if ($value instanceof BasePoint) { $value = sprintf('POINT(%F %F)', $value->getLongitude(), $value->getLatitude()); } return $value; }
php
public function convertToDatabaseValue($value, AbstractPlatform $platform) { if ($value instanceof BasePoint) { $value = sprintf('POINT(%F %F)', $value->getLongitude(), $value->getLatitude()); } return $value; }
[ "public", "function", "convertToDatabaseValue", "(", "$", "value", ",", "AbstractPlatform", "$", "platform", ")", "{", "if", "(", "$", "value", "instanceof", "BasePoint", ")", "{", "$", "value", "=", "sprintf", "(", "'POINT(%F %F)'", ",", "$", "value", "->", "getLongitude", "(", ")", ",", "$", "value", "->", "getLatitude", "(", ")", ")", ";", "}", "return", "$", "value", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/netbull/CoreBundle/blob/0bacc1d9e4733b6da613027400c48421e5a14645/ORM/Types/Point.php#L47-L54
zarathustra323/modlr-data
src/Zarathustra/ModlrData/DataTypes/Types/FloatType.php
FloatType.convertToModlrValue
public function convertToModlrValue($value) { if (is_object($value)) { return (Float) (String) $value; } if (null !== $value) { return (Float) $value; } return null; }
php
public function convertToModlrValue($value) { if (is_object($value)) { return (Float) (String) $value; } if (null !== $value) { return (Float) $value; } return null; }
[ "public", "function", "convertToModlrValue", "(", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "return", "(", "Float", ")", "(", "String", ")", "$", "value", ";", "}", "if", "(", "null", "!==", "$", "value", ")", "{", "return", "(", "Float", ")", "$", "value", ";", "}", "return", "null", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/DataTypes/Types/FloatType.php#L15-L24
zarathustra323/modlr-data
src/Zarathustra/ModlrData/DataTypes/Types/FloatType.php
FloatType.convertToPHPValue
public function convertToPHPValue($value) { if (is_object($value)) { return (Float) (String) $value; } if (null !== $value) { return (Float) $value; } return null; }
php
public function convertToPHPValue($value) { if (is_object($value)) { return (Float) (String) $value; } if (null !== $value) { return (Float) $value; } return null; }
[ "public", "function", "convertToPHPValue", "(", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "return", "(", "Float", ")", "(", "String", ")", "$", "value", ";", "}", "if", "(", "null", "!==", "$", "value", ")", "{", "return", "(", "Float", ")", "$", "value", ";", "}", "return", "null", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/DataTypes/Types/FloatType.php#L29-L38
itiqiti/dev-lib
src/Cli.php
Cli.getCommand
public function getCommand($name, Config $config) { if (!$config->hasItem('commands', $name)) { if (!$config->hasItem('commands', '_'.$name)) { $config->checkItem('commands', $name); } $name = '_'.$name; } return $config->getItem('commands', $name); }
php
public function getCommand($name, Config $config) { if (!$config->hasItem('commands', $name)) { if (!$config->hasItem('commands', '_'.$name)) { $config->checkItem('commands', $name); } $name = '_'.$name; } return $config->getItem('commands', $name); }
[ "public", "function", "getCommand", "(", "$", "name", ",", "Config", "$", "config", ")", "{", "if", "(", "!", "$", "config", "->", "hasItem", "(", "'commands'", ",", "$", "name", ")", ")", "{", "if", "(", "!", "$", "config", "->", "hasItem", "(", "'commands'", ",", "'_'", ".", "$", "name", ")", ")", "{", "$", "config", "->", "checkItem", "(", "'commands'", ",", "$", "name", ")", ";", "}", "$", "name", "=", "'_'", ".", "$", "name", ";", "}", "return", "$", "config", "->", "getItem", "(", "'commands'", ",", "$", "name", ")", ";", "}" ]
@param string $name @param Config $config @return CommandInterface|mixed
[ "@param", "string", "$name", "@param", "Config", "$config" ]
train
https://github.com/itiqiti/dev-lib/blob/6f99f9332270095e072e75fd9f3a6c7e1d2cb7d8/src/Cli.php#L57-L67
itiqiti/dev-lib
src/Cli.php
Cli.main
public static function main(array $argv = [], $command = null) { $code = 0; $output = new ConsoleOutput(); $input = new ArgvInput(); try { $c = static::createCli(); array_shift($argv); if (null !== $command) { array_unshift($argv, $command); } $c->run($input, $output, $argv); } catch (\Exception $e) { if ('true' !== getenv('DEV_QUIET')) { $output->writeln(sprintf('<error>Error #%d: %s</error>', $e->getCode(), $e->getMessage())); } $code = ($e->getCode() > 0 && $e->getCode() < 255) ? $e->getCode() : 255; } return $code; }
php
public static function main(array $argv = [], $command = null) { $code = 0; $output = new ConsoleOutput(); $input = new ArgvInput(); try { $c = static::createCli(); array_shift($argv); if (null !== $command) { array_unshift($argv, $command); } $c->run($input, $output, $argv); } catch (\Exception $e) { if ('true' !== getenv('DEV_QUIET')) { $output->writeln(sprintf('<error>Error #%d: %s</error>', $e->getCode(), $e->getMessage())); } $code = ($e->getCode() > 0 && $e->getCode() < 255) ? $e->getCode() : 255; } return $code; }
[ "public", "static", "function", "main", "(", "array", "$", "argv", "=", "[", "]", ",", "$", "command", "=", "null", ")", "{", "$", "code", "=", "0", ";", "$", "output", "=", "new", "ConsoleOutput", "(", ")", ";", "$", "input", "=", "new", "ArgvInput", "(", ")", ";", "try", "{", "$", "c", "=", "static", "::", "createCli", "(", ")", ";", "array_shift", "(", "$", "argv", ")", ";", "if", "(", "null", "!==", "$", "command", ")", "{", "array_unshift", "(", "$", "argv", ",", "$", "command", ")", ";", "}", "$", "c", "->", "run", "(", "$", "input", ",", "$", "output", ",", "$", "argv", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "if", "(", "'true'", "!==", "getenv", "(", "'DEV_QUIET'", ")", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'<error>Error #%d: %s</error>'", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "$", "code", "=", "(", "$", "e", "->", "getCode", "(", ")", ">", "0", "&&", "$", "e", "->", "getCode", "(", ")", "<", "255", ")", "?", "$", "e", "->", "getCode", "(", ")", ":", "255", ";", "}", "return", "$", "code", ";", "}" ]
@param array $argv @param string $command @return int
[ "@param", "array", "$argv", "@param", "string", "$command" ]
train
https://github.com/itiqiti/dev-lib/blob/6f99f9332270095e072e75fd9f3a6c7e1d2cb7d8/src/Cli.php#L98-L124
itiqiti/dev-lib
src/Cli.php
Cli.run
public function run(InputInterface $input, OutputInterface $output, array $args) { $arguments = []; $options = []; foreach ($args as $arg) { $matches = []; if (0 < preg_match('/^\-{1,2}(?<key>[^\=]+)(\=(?<value>.*))?$/', $arg, $matches)) { $options[$matches['key']] = isset($matches['value']) ? $matches['value'] : true; } else { $arguments[] = $arg; } } if (!count($arguments)) { array_unshift($arguments, 'help'); } $config = new Config( [ 'uses' => [ 'core' => null, 'git' => null, 'php' => null, 'composer' => null, 'phpunit' => null, 'phpcs' => null, 'travis' => null, 'npm' => null, 'gulp' => null, 'itiqiti' => null, ], ] ); $el = new ExpressionLanguage(); $expressionService = new ExpressionService($el); $s = new Service\ConfigService($expressionService); $s->load($config); $commandNames = array_shift($arguments); return $this->executeCommandFromName($input, $output, $commandNames, $arguments, $options, $config, $s); }
php
public function run(InputInterface $input, OutputInterface $output, array $args) { $arguments = []; $options = []; foreach ($args as $arg) { $matches = []; if (0 < preg_match('/^\-{1,2}(?<key>[^\=]+)(\=(?<value>.*))?$/', $arg, $matches)) { $options[$matches['key']] = isset($matches['value']) ? $matches['value'] : true; } else { $arguments[] = $arg; } } if (!count($arguments)) { array_unshift($arguments, 'help'); } $config = new Config( [ 'uses' => [ 'core' => null, 'git' => null, 'php' => null, 'composer' => null, 'phpunit' => null, 'phpcs' => null, 'travis' => null, 'npm' => null, 'gulp' => null, 'itiqiti' => null, ], ] ); $el = new ExpressionLanguage(); $expressionService = new ExpressionService($el); $s = new Service\ConfigService($expressionService); $s->load($config); $commandNames = array_shift($arguments); return $this->executeCommandFromName($input, $output, $commandNames, $arguments, $options, $config, $s); }
[ "public", "function", "run", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ",", "array", "$", "args", ")", "{", "$", "arguments", "=", "[", "]", ";", "$", "options", "=", "[", "]", ";", "foreach", "(", "$", "args", "as", "$", "arg", ")", "{", "$", "matches", "=", "[", "]", ";", "if", "(", "0", "<", "preg_match", "(", "'/^\\-{1,2}(?<key>[^\\=]+)(\\=(?<value>.*))?$/'", ",", "$", "arg", ",", "$", "matches", ")", ")", "{", "$", "options", "[", "$", "matches", "[", "'key'", "]", "]", "=", "isset", "(", "$", "matches", "[", "'value'", "]", ")", "?", "$", "matches", "[", "'value'", "]", ":", "true", ";", "}", "else", "{", "$", "arguments", "[", "]", "=", "$", "arg", ";", "}", "}", "if", "(", "!", "count", "(", "$", "arguments", ")", ")", "{", "array_unshift", "(", "$", "arguments", ",", "'help'", ")", ";", "}", "$", "config", "=", "new", "Config", "(", "[", "'uses'", "=>", "[", "'core'", "=>", "null", ",", "'git'", "=>", "null", ",", "'php'", "=>", "null", ",", "'composer'", "=>", "null", ",", "'phpunit'", "=>", "null", ",", "'phpcs'", "=>", "null", ",", "'travis'", "=>", "null", ",", "'npm'", "=>", "null", ",", "'gulp'", "=>", "null", ",", "'itiqiti'", "=>", "null", ",", "]", ",", "]", ")", ";", "$", "el", "=", "new", "ExpressionLanguage", "(", ")", ";", "$", "expressionService", "=", "new", "ExpressionService", "(", "$", "el", ")", ";", "$", "s", "=", "new", "Service", "\\", "ConfigService", "(", "$", "expressionService", ")", ";", "$", "s", "->", "load", "(", "$", "config", ")", ";", "$", "commandNames", "=", "array_shift", "(", "$", "arguments", ")", ";", "return", "$", "this", "->", "executeCommandFromName", "(", "$", "input", ",", "$", "output", ",", "$", "commandNames", ",", "$", "arguments", ",", "$", "options", ",", "$", "config", ",", "$", "s", ")", ";", "}" ]
@param InputInterface $input @param OutputInterface $output @param array $args @return $this
[ "@param", "InputInterface", "$input", "@param", "OutputInterface", "$output", "@param", "array", "$args" ]
train
https://github.com/itiqiti/dev-lib/blob/6f99f9332270095e072e75fd9f3a6c7e1d2cb7d8/src/Cli.php#L139-L184
itiqiti/dev-lib
src/Cli.php
Cli.executecommandFromName
public function executecommandFromName(InputInterface $input, OutputInterface $output, $commandNames, array $arguments, array $options, Config $config, ConfigService $s) { $silent = false; if ('?' === $commandNames{0}) { $silent = true; $commandNames = substr($commandNames, 1); } $this->executeHooks($input, $output, ':before', $config, $s); foreach (explode('+', $commandNames) as $_commandNames) { $exceptions = []; foreach (explode('~', $_commandNames) as $commandName) { $commandName = strtolower($commandName); try { $command = $this->getCommand($commandName, $config); if (method_exists($command, 'setConfigService')) { $command->setConfigService($s); } if (method_exists($command, 'setOutput')) { $command->setOutput($output); } if (method_exists($command, 'setInput')) { $command->setInput($input); } if (method_exists($command, 'setConfig')) { $command->setConfig($config); } $this->executeHooks($input, $output, $commandName.':before', $config, $s); if (method_exists($command, 'execute')) { $command->execute($arguments, $options); } elseif (method_exists($command, '__invoke')) { $command($arguments, $options); } else { $this->executeHooks($input, $output, $commandName.':failure', $config, $s); throw new \RuntimeException(sprintf("Command '%s' is not executable", $commandName), 43); } $this->executeHooks($input, $output, $commandName.':after', $config, $s); } catch (\Exception $e) { $exceptions[] = ['command' => $commandName, 'exception' => $e]; } } if (count($exceptions)) { if ($silent) { return $this; } $this->executeHooks($input, $output, ':failure', $config, $s); throw $exceptions[0]['exception']; } } $this->executeHooks($input, $output, ':after', $config, $s); return $this; }
php
public function executecommandFromName(InputInterface $input, OutputInterface $output, $commandNames, array $arguments, array $options, Config $config, ConfigService $s) { $silent = false; if ('?' === $commandNames{0}) { $silent = true; $commandNames = substr($commandNames, 1); } $this->executeHooks($input, $output, ':before', $config, $s); foreach (explode('+', $commandNames) as $_commandNames) { $exceptions = []; foreach (explode('~', $_commandNames) as $commandName) { $commandName = strtolower($commandName); try { $command = $this->getCommand($commandName, $config); if (method_exists($command, 'setConfigService')) { $command->setConfigService($s); } if (method_exists($command, 'setOutput')) { $command->setOutput($output); } if (method_exists($command, 'setInput')) { $command->setInput($input); } if (method_exists($command, 'setConfig')) { $command->setConfig($config); } $this->executeHooks($input, $output, $commandName.':before', $config, $s); if (method_exists($command, 'execute')) { $command->execute($arguments, $options); } elseif (method_exists($command, '__invoke')) { $command($arguments, $options); } else { $this->executeHooks($input, $output, $commandName.':failure', $config, $s); throw new \RuntimeException(sprintf("Command '%s' is not executable", $commandName), 43); } $this->executeHooks($input, $output, $commandName.':after', $config, $s); } catch (\Exception $e) { $exceptions[] = ['command' => $commandName, 'exception' => $e]; } } if (count($exceptions)) { if ($silent) { return $this; } $this->executeHooks($input, $output, ':failure', $config, $s); throw $exceptions[0]['exception']; } } $this->executeHooks($input, $output, ':after', $config, $s); return $this; }
[ "public", "function", "executecommandFromName", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ",", "$", "commandNames", ",", "array", "$", "arguments", ",", "array", "$", "options", ",", "Config", "$", "config", ",", "ConfigService", "$", "s", ")", "{", "$", "silent", "=", "false", ";", "if", "(", "'?'", "===", "$", "commandNames", "{", "0", "}", ")", "{", "$", "silent", "=", "true", ";", "$", "commandNames", "=", "substr", "(", "$", "commandNames", ",", "1", ")", ";", "}", "$", "this", "->", "executeHooks", "(", "$", "input", ",", "$", "output", ",", "':before'", ",", "$", "config", ",", "$", "s", ")", ";", "foreach", "(", "explode", "(", "'+'", ",", "$", "commandNames", ")", "as", "$", "_commandNames", ")", "{", "$", "exceptions", "=", "[", "]", ";", "foreach", "(", "explode", "(", "'~'", ",", "$", "_commandNames", ")", "as", "$", "commandName", ")", "{", "$", "commandName", "=", "strtolower", "(", "$", "commandName", ")", ";", "try", "{", "$", "command", "=", "$", "this", "->", "getCommand", "(", "$", "commandName", ",", "$", "config", ")", ";", "if", "(", "method_exists", "(", "$", "command", ",", "'setConfigService'", ")", ")", "{", "$", "command", "->", "setConfigService", "(", "$", "s", ")", ";", "}", "if", "(", "method_exists", "(", "$", "command", ",", "'setOutput'", ")", ")", "{", "$", "command", "->", "setOutput", "(", "$", "output", ")", ";", "}", "if", "(", "method_exists", "(", "$", "command", ",", "'setInput'", ")", ")", "{", "$", "command", "->", "setInput", "(", "$", "input", ")", ";", "}", "if", "(", "method_exists", "(", "$", "command", ",", "'setConfig'", ")", ")", "{", "$", "command", "->", "setConfig", "(", "$", "config", ")", ";", "}", "$", "this", "->", "executeHooks", "(", "$", "input", ",", "$", "output", ",", "$", "commandName", ".", "':before'", ",", "$", "config", ",", "$", "s", ")", ";", "if", "(", "method_exists", "(", "$", "command", ",", "'execute'", ")", ")", "{", "$", "command", "->", "execute", "(", "$", "arguments", ",", "$", "options", ")", ";", "}", "elseif", "(", "method_exists", "(", "$", "command", ",", "'__invoke'", ")", ")", "{", "$", "command", "(", "$", "arguments", ",", "$", "options", ")", ";", "}", "else", "{", "$", "this", "->", "executeHooks", "(", "$", "input", ",", "$", "output", ",", "$", "commandName", ".", "':failure'", ",", "$", "config", ",", "$", "s", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "\"Command '%s' is not executable\"", ",", "$", "commandName", ")", ",", "43", ")", ";", "}", "$", "this", "->", "executeHooks", "(", "$", "input", ",", "$", "output", ",", "$", "commandName", ".", "':after'", ",", "$", "config", ",", "$", "s", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "exceptions", "[", "]", "=", "[", "'command'", "=>", "$", "commandName", ",", "'exception'", "=>", "$", "e", "]", ";", "}", "}", "if", "(", "count", "(", "$", "exceptions", ")", ")", "{", "if", "(", "$", "silent", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "executeHooks", "(", "$", "input", ",", "$", "output", ",", "':failure'", ",", "$", "config", ",", "$", "s", ")", ";", "throw", "$", "exceptions", "[", "0", "]", "[", "'exception'", "]", ";", "}", "}", "$", "this", "->", "executeHooks", "(", "$", "input", ",", "$", "output", ",", "':after'", ",", "$", "config", ",", "$", "s", ")", ";", "return", "$", "this", ";", "}" ]
@param InputInterface $input @param OutputInterface $output @param string $commandNames @param array $arguments @param array $options @param Config $config @param ConfigService $s @return $this
[ "@param", "InputInterface", "$input", "@param", "OutputInterface", "$output", "@param", "string", "$commandNames", "@param", "array", "$arguments", "@param", "array", "$options", "@param", "Config", "$config", "@param", "ConfigService", "$s" ]
train
https://github.com/itiqiti/dev-lib/blob/6f99f9332270095e072e75fd9f3a6c7e1d2cb7d8/src/Cli.php#L196-L258
itiqiti/dev-lib
src/Cli.php
Cli.executeHooks
protected function executeHooks(InputInterface $input, OutputInterface $output, $type, Config $config, ConfigService $configService) { if ($config->hasItem('_executed_hooks', $type)) { return $this; } $config->setItem('_executed_hooks', $type, true); /** @var HookInterface[]|\Closure[] $hooks */ $hooks = $config->getItem('hooks', $type, []); if (!is_array($hooks)) { $hooks = []; } foreach ($hooks as $hook) { if (method_exists($hook, 'setConfigService')) { $hook->setConfigService($configService); } if (method_exists($hook, 'setOutput')) { $hook->setOutput($output); } if (method_exists($hook, 'setInput')) { $hook->setInput($input); } if (method_exists($hook, 'setConfig')) { $hook->setConfig($config); } if (method_exists($hook, 'setCli')) { $hook->setCli($this); } if (method_exists($hook, 'execute')) { $hook->execute(); } elseif (method_exists($hook, '__invoke')) { $hook(); } else { throw new \RuntimeException(sprintf("Hook '%s' is not executable", get_class($hook)), 47); } } return $this; }
php
protected function executeHooks(InputInterface $input, OutputInterface $output, $type, Config $config, ConfigService $configService) { if ($config->hasItem('_executed_hooks', $type)) { return $this; } $config->setItem('_executed_hooks', $type, true); /** @var HookInterface[]|\Closure[] $hooks */ $hooks = $config->getItem('hooks', $type, []); if (!is_array($hooks)) { $hooks = []; } foreach ($hooks as $hook) { if (method_exists($hook, 'setConfigService')) { $hook->setConfigService($configService); } if (method_exists($hook, 'setOutput')) { $hook->setOutput($output); } if (method_exists($hook, 'setInput')) { $hook->setInput($input); } if (method_exists($hook, 'setConfig')) { $hook->setConfig($config); } if (method_exists($hook, 'setCli')) { $hook->setCli($this); } if (method_exists($hook, 'execute')) { $hook->execute(); } elseif (method_exists($hook, '__invoke')) { $hook(); } else { throw new \RuntimeException(sprintf("Hook '%s' is not executable", get_class($hook)), 47); } } return $this; }
[ "protected", "function", "executeHooks", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ",", "$", "type", ",", "Config", "$", "config", ",", "ConfigService", "$", "configService", ")", "{", "if", "(", "$", "config", "->", "hasItem", "(", "'_executed_hooks'", ",", "$", "type", ")", ")", "{", "return", "$", "this", ";", "}", "$", "config", "->", "setItem", "(", "'_executed_hooks'", ",", "$", "type", ",", "true", ")", ";", "/** @var HookInterface[]|\\Closure[] $hooks */", "$", "hooks", "=", "$", "config", "->", "getItem", "(", "'hooks'", ",", "$", "type", ",", "[", "]", ")", ";", "if", "(", "!", "is_array", "(", "$", "hooks", ")", ")", "{", "$", "hooks", "=", "[", "]", ";", "}", "foreach", "(", "$", "hooks", "as", "$", "hook", ")", "{", "if", "(", "method_exists", "(", "$", "hook", ",", "'setConfigService'", ")", ")", "{", "$", "hook", "->", "setConfigService", "(", "$", "configService", ")", ";", "}", "if", "(", "method_exists", "(", "$", "hook", ",", "'setOutput'", ")", ")", "{", "$", "hook", "->", "setOutput", "(", "$", "output", ")", ";", "}", "if", "(", "method_exists", "(", "$", "hook", ",", "'setInput'", ")", ")", "{", "$", "hook", "->", "setInput", "(", "$", "input", ")", ";", "}", "if", "(", "method_exists", "(", "$", "hook", ",", "'setConfig'", ")", ")", "{", "$", "hook", "->", "setConfig", "(", "$", "config", ")", ";", "}", "if", "(", "method_exists", "(", "$", "hook", ",", "'setCli'", ")", ")", "{", "$", "hook", "->", "setCli", "(", "$", "this", ")", ";", "}", "if", "(", "method_exists", "(", "$", "hook", ",", "'execute'", ")", ")", "{", "$", "hook", "->", "execute", "(", ")", ";", "}", "elseif", "(", "method_exists", "(", "$", "hook", ",", "'__invoke'", ")", ")", "{", "$", "hook", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "\"Hook '%s' is not executable\"", ",", "get_class", "(", "$", "hook", ")", ")", ",", "47", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
@param InputInterface $input @param OutputInterface $output @param string $type @param Config $config @param ConfigService $configService @return $this
[ "@param", "InputInterface", "$input", "@param", "OutputInterface", "$output", "@param", "string", "$type", "@param", "Config", "$config", "@param", "ConfigService", "$configService" ]
train
https://github.com/itiqiti/dev-lib/blob/6f99f9332270095e072e75fd9f3a6c7e1d2cb7d8/src/Cli.php#L268-L314
siriusSupreme/sirius-broadcast
src/Broadcasters/Broadcaster.php
Broadcaster.verifyUserCanAccessChannel
protected function verifyUserCanAccessChannel($request, $channel) { foreach ($this->channels as $pattern => $callback) { if (! Str::is(preg_replace('/\{(.*?)\}/', '*', $pattern), $channel)) { continue; } $parameters = $this->extractAuthParameters($pattern, $channel, $callback); if ($result = $callback($request->user(), ...$parameters)) { return $this->validAuthenticationResponse($request, $result); } } throw new AccessDeniedHttpException; }
php
protected function verifyUserCanAccessChannel($request, $channel) { foreach ($this->channels as $pattern => $callback) { if (! Str::is(preg_replace('/\{(.*?)\}/', '*', $pattern), $channel)) { continue; } $parameters = $this->extractAuthParameters($pattern, $channel, $callback); if ($result = $callback($request->user(), ...$parameters)) { return $this->validAuthenticationResponse($request, $result); } } throw new AccessDeniedHttpException; }
[ "protected", "function", "verifyUserCanAccessChannel", "(", "$", "request", ",", "$", "channel", ")", "{", "foreach", "(", "$", "this", "->", "channels", "as", "$", "pattern", "=>", "$", "callback", ")", "{", "if", "(", "!", "Str", "::", "is", "(", "preg_replace", "(", "'/\\{(.*?)\\}/'", ",", "'*'", ",", "$", "pattern", ")", ",", "$", "channel", ")", ")", "{", "continue", ";", "}", "$", "parameters", "=", "$", "this", "->", "extractAuthParameters", "(", "$", "pattern", ",", "$", "channel", ",", "$", "callback", ")", ";", "if", "(", "$", "result", "=", "$", "callback", "(", "$", "request", "->", "user", "(", ")", ",", "...", "$", "parameters", ")", ")", "{", "return", "$", "this", "->", "validAuthenticationResponse", "(", "$", "request", ",", "$", "result", ")", ";", "}", "}", "throw", "new", "AccessDeniedHttpException", ";", "}" ]
Authenticate the incoming request for a given channel. @param \Psr\Http\Message\RequestInterface $request @param string $channel @return mixed @throws \Sirius\Broadcast\Exceptions\AccessDeniedHttpException
[ "Authenticate", "the", "incoming", "request", "for", "a", "given", "channel", "." ]
train
https://github.com/siriusSupreme/sirius-broadcast/blob/d98f47973631dbb2da0296fd7066d1a70e9b30f7/src/Broadcasters/Broadcaster.php#L42-L57
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", "." ]
train
https://github.com/siriusSupreme/sirius-broadcast/blob/d98f47973631dbb2da0296fd7066d1a70e9b30f7/src/Broadcasters/Broadcaster.php#L67-L76
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Map/SourceTableMap.php
SourceTableMap.addSelectColumns
public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { $criteria->addSelectColumn(SourceTableMap::COL_ID); $criteria->addSelectColumn(SourceTableMap::COL_TITLE); $criteria->addSelectColumn(SourceTableMap::COL_HOST); $criteria->addSelectColumn(SourceTableMap::COL_ENDPOINT); $criteria->addSelectColumn(SourceTableMap::COL_CREATED_AT); $criteria->addSelectColumn(SourceTableMap::COL_UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.id'); $criteria->addSelectColumn($alias . '.title'); $criteria->addSelectColumn($alias . '.host'); $criteria->addSelectColumn($alias . '.endpoint'); $criteria->addSelectColumn($alias . '.created_at'); $criteria->addSelectColumn($alias . '.updated_at'); } }
php
public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { $criteria->addSelectColumn(SourceTableMap::COL_ID); $criteria->addSelectColumn(SourceTableMap::COL_TITLE); $criteria->addSelectColumn(SourceTableMap::COL_HOST); $criteria->addSelectColumn(SourceTableMap::COL_ENDPOINT); $criteria->addSelectColumn(SourceTableMap::COL_CREATED_AT); $criteria->addSelectColumn(SourceTableMap::COL_UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.id'); $criteria->addSelectColumn($alias . '.title'); $criteria->addSelectColumn($alias . '.host'); $criteria->addSelectColumn($alias . '.endpoint'); $criteria->addSelectColumn($alias . '.created_at'); $criteria->addSelectColumn($alias . '.updated_at'); } }
[ "public", "static", "function", "addSelectColumns", "(", "Criteria", "$", "criteria", ",", "$", "alias", "=", "null", ")", "{", "if", "(", "null", "===", "$", "alias", ")", "{", "$", "criteria", "->", "addSelectColumn", "(", "SourceTableMap", "::", "COL_ID", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "SourceTableMap", "::", "COL_TITLE", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "SourceTableMap", "::", "COL_HOST", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "SourceTableMap", "::", "COL_ENDPOINT", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "SourceTableMap", "::", "COL_CREATED_AT", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "SourceTableMap", "::", "COL_UPDATED_AT", ")", ";", "}", "else", "{", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.id'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.title'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.host'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.endpoint'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.created_at'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.updated_at'", ")", ";", "}", "}" ]
Add all the columns needed to create a new object. Note: any columns that were marked with lazyLoad="true" in the XML schema will not be added to the select list and only loaded on demand. @param Criteria $criteria object containing the columns to add. @param string $alias optional table alias @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Add", "all", "the", "columns", "needed", "to", "create", "a", "new", "object", "." ]
train
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Map/SourceTableMap.php#L341-L358
attogram/shared-media-orm
src/Attogram/SharedMedia/Orm/Map/SourceTableMap.php
SourceTableMap.buildTableMap
public static function buildTableMap() { $dbMap = Propel::getServiceContainer()->getDatabaseMap(SourceTableMap::DATABASE_NAME); if (!$dbMap->hasTable(SourceTableMap::TABLE_NAME)) { $dbMap->addTableObject(new SourceTableMap()); } }
php
public static function buildTableMap() { $dbMap = Propel::getServiceContainer()->getDatabaseMap(SourceTableMap::DATABASE_NAME); if (!$dbMap->hasTable(SourceTableMap::TABLE_NAME)) { $dbMap->addTableObject(new SourceTableMap()); } }
[ "public", "static", "function", "buildTableMap", "(", ")", "{", "$", "dbMap", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getDatabaseMap", "(", "SourceTableMap", "::", "DATABASE_NAME", ")", ";", "if", "(", "!", "$", "dbMap", "->", "hasTable", "(", "SourceTableMap", "::", "TABLE_NAME", ")", ")", "{", "$", "dbMap", "->", "addTableObject", "(", "new", "SourceTableMap", "(", ")", ")", ";", "}", "}" ]
Add a TableMap instance to the database for this tableMap class.
[ "Add", "a", "TableMap", "instance", "to", "the", "database", "for", "this", "tableMap", "class", "." ]
train
https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/Map/SourceTableMap.php#L375-L381
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", "." ]
train
https://github.com/railken/lem/blob/cff1efcd090a9504b2faf5594121885786dea67a/src/Attributes/BaseAttribute.php#L115-L120
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", "." ]
train
https://github.com/railken/lem/blob/cff1efcd090a9504b2faf5594121885786dea67a/src/Attributes/BaseAttribute.php#L130-L139
railken/lem
src/Attributes/BaseAttribute.php
BaseAttribute.authorize
public function authorize(string $action, $value) { $permission = $this->getPermission($action); $result = $this->getManager()->getAgent()->can($permission); if (!$result) { return Collection::make([$this->newException(Tokens::NOT_AUTHORIZED, $permission)]); } return Collection::make(); }
php
public function authorize(string $action, $value) { $permission = $this->getPermission($action); $result = $this->getManager()->getAgent()->can($permission); if (!$result) { return Collection::make([$this->newException(Tokens::NOT_AUTHORIZED, $permission)]); } return Collection::make(); }
[ "public", "function", "authorize", "(", "string", "$", "action", ",", "$", "value", ")", "{", "$", "permission", "=", "$", "this", "->", "getPermission", "(", "$", "action", ")", ";", "$", "result", "=", "$", "this", "->", "getManager", "(", ")", "->", "getAgent", "(", ")", "->", "can", "(", "$", "permission", ")", ";", "if", "(", "!", "$", "result", ")", "{", "return", "Collection", "::", "make", "(", "[", "$", "this", "->", "newException", "(", "Tokens", "::", "NOT_AUTHORIZED", ",", "$", "permission", ")", "]", ")", ";", "}", "return", "Collection", "::", "make", "(", ")", ";", "}" ]
Is a value valid ? @param string $action @param mixed $value @return Collection
[ "Is", "a", "value", "valid", "?" ]
train
https://github.com/railken/lem/blob/cff1efcd090a9504b2faf5594121885786dea67a/src/Attributes/BaseAttribute.php#L158-L169
railken/lem
src/Attributes/BaseAttribute.php
BaseAttribute.authorizeByEntity
public function authorizeByEntity(string $action, EntityContract $entity, $value) { $permission = $this->getPermission($action); $result = $this->getManager()->getAgent()->can($permission); if (!$result) { return Collection::make([$this->newException(Tokens::NOT_AUTHORIZED, $permission)]); } return Collection::make(); }
php
public function authorizeByEntity(string $action, EntityContract $entity, $value) { $permission = $this->getPermission($action); $result = $this->getManager()->getAgent()->can($permission); if (!$result) { return Collection::make([$this->newException(Tokens::NOT_AUTHORIZED, $permission)]); } return Collection::make(); }
[ "public", "function", "authorizeByEntity", "(", "string", "$", "action", ",", "EntityContract", "$", "entity", ",", "$", "value", ")", "{", "$", "permission", "=", "$", "this", "->", "getPermission", "(", "$", "action", ")", ";", "$", "result", "=", "$", "this", "->", "getManager", "(", ")", "->", "getAgent", "(", ")", "->", "can", "(", "$", "permission", ")", ";", "if", "(", "!", "$", "result", ")", "{", "return", "Collection", "::", "make", "(", "[", "$", "this", "->", "newException", "(", "Tokens", "::", "NOT_AUTHORIZED", ",", "$", "permission", ")", "]", ")", ";", "}", "return", "Collection", "::", "make", "(", ")", ";", "}" ]
Is a value valid ? @param string $action @param \Railken\Lem\Contracts\EntityContract $entity @param mixed $value @return Collection
[ "Is", "a", "value", "valid", "?" ]
train
https://github.com/railken/lem/blob/cff1efcd090a9504b2faf5594121885786dea67a/src/Attributes/BaseAttribute.php#L180-L191
railken/lem
src/Attributes/BaseAttribute.php
BaseAttribute.validate
public function validate(EntityContract $entity, Bag $parameters) { $errors = new Collection(); $value = $parameters->get($this->name); if ($this->required && !$entity->exists && !$parameters->exists($this->name)) { $errors->push($this->newException(Tokens::NOT_DEFINED, $value)); } if ($this->unique && $value !== null && $this->isUnique($entity, $value)) { $errors->push($this->newException(Tokens::NOT_UNIQUE, $value)); } if ($parameters->exists($this->name) && ($value !== null || $this->required) && !$this->valid($entity, $value)) { $errors->push($this->newException(Tokens::NOT_VALID, $value)); } return $errors; }
php
public function validate(EntityContract $entity, Bag $parameters) { $errors = new Collection(); $value = $parameters->get($this->name); if ($this->required && !$entity->exists && !$parameters->exists($this->name)) { $errors->push($this->newException(Tokens::NOT_DEFINED, $value)); } if ($this->unique && $value !== null && $this->isUnique($entity, $value)) { $errors->push($this->newException(Tokens::NOT_UNIQUE, $value)); } if ($parameters->exists($this->name) && ($value !== null || $this->required) && !$this->valid($entity, $value)) { $errors->push($this->newException(Tokens::NOT_VALID, $value)); } return $errors; }
[ "public", "function", "validate", "(", "EntityContract", "$", "entity", ",", "Bag", "$", "parameters", ")", "{", "$", "errors", "=", "new", "Collection", "(", ")", ";", "$", "value", "=", "$", "parameters", "->", "get", "(", "$", "this", "->", "name", ")", ";", "if", "(", "$", "this", "->", "required", "&&", "!", "$", "entity", "->", "exists", "&&", "!", "$", "parameters", "->", "exists", "(", "$", "this", "->", "name", ")", ")", "{", "$", "errors", "->", "push", "(", "$", "this", "->", "newException", "(", "Tokens", "::", "NOT_DEFINED", ",", "$", "value", ")", ")", ";", "}", "if", "(", "$", "this", "->", "unique", "&&", "$", "value", "!==", "null", "&&", "$", "this", "->", "isUnique", "(", "$", "entity", ",", "$", "value", ")", ")", "{", "$", "errors", "->", "push", "(", "$", "this", "->", "newException", "(", "Tokens", "::", "NOT_UNIQUE", ",", "$", "value", ")", ")", ";", "}", "if", "(", "$", "parameters", "->", "exists", "(", "$", "this", "->", "name", ")", "&&", "(", "$", "value", "!==", "null", "||", "$", "this", "->", "required", ")", "&&", "!", "$", "this", "->", "valid", "(", "$", "entity", ",", "$", "value", ")", ")", "{", "$", "errors", "->", "push", "(", "$", "this", "->", "newException", "(", "Tokens", "::", "NOT_VALID", ",", "$", "value", ")", ")", ";", "}", "return", "$", "errors", ";", "}" ]
Validate. @param \Railken\Lem\Contracts\EntityContract $entity @param \Railken\Bag $parameters @return Collection
[ "Validate", "." ]
train
https://github.com/railken/lem/blob/cff1efcd090a9504b2faf5594121885786dea67a/src/Attributes/BaseAttribute.php#L201-L220
railken/lem
src/Attributes/BaseAttribute.php
BaseAttribute.update
public function update(EntityContract $entity, Bag $parameters) { $errors = new Collection(); $default = null; if (!$parameters->has($this->name) && !$entity->exists) { $default = $this->getDefault($entity); if ($default !== null) { $parameters->set($this->name, $default); } } // Skip check fillable if has a default value if (!$this->getFillable() && $default === null) { return $errors; } $errors = $errors->merge($this->authorize(Tokens::PERMISSION_FILL, $entity, $parameters)); $errors = $errors->merge($this->validate($entity, $parameters)); $errors = $errors->merge($this->fill($entity, $parameters)); return $errors; }
php
public function update(EntityContract $entity, Bag $parameters) { $errors = new Collection(); $default = null; if (!$parameters->has($this->name) && !$entity->exists) { $default = $this->getDefault($entity); if ($default !== null) { $parameters->set($this->name, $default); } } // Skip check fillable if has a default value if (!$this->getFillable() && $default === null) { return $errors; } $errors = $errors->merge($this->authorize(Tokens::PERMISSION_FILL, $entity, $parameters)); $errors = $errors->merge($this->validate($entity, $parameters)); $errors = $errors->merge($this->fill($entity, $parameters)); return $errors; }
[ "public", "function", "update", "(", "EntityContract", "$", "entity", ",", "Bag", "$", "parameters", ")", "{", "$", "errors", "=", "new", "Collection", "(", ")", ";", "$", "default", "=", "null", ";", "if", "(", "!", "$", "parameters", "->", "has", "(", "$", "this", "->", "name", ")", "&&", "!", "$", "entity", "->", "exists", ")", "{", "$", "default", "=", "$", "this", "->", "getDefault", "(", "$", "entity", ")", ";", "if", "(", "$", "default", "!==", "null", ")", "{", "$", "parameters", "->", "set", "(", "$", "this", "->", "name", ",", "$", "default", ")", ";", "}", "}", "// Skip check fillable if has a default value", "if", "(", "!", "$", "this", "->", "getFillable", "(", ")", "&&", "$", "default", "===", "null", ")", "{", "return", "$", "errors", ";", "}", "$", "errors", "=", "$", "errors", "->", "merge", "(", "$", "this", "->", "authorize", "(", "Tokens", "::", "PERMISSION_FILL", ",", "$", "entity", ",", "$", "parameters", ")", ")", ";", "$", "errors", "=", "$", "errors", "->", "merge", "(", "$", "this", "->", "validate", "(", "$", "entity", ",", "$", "parameters", ")", ")", ";", "$", "errors", "=", "$", "errors", "->", "merge", "(", "$", "this", "->", "fill", "(", "$", "entity", ",", "$", "parameters", ")", ")", ";", "return", "$", "errors", ";", "}" ]
Update entity value. @param \Railken\Lem\Contracts\EntityContract $entity @param \Railken\Bag $parameters @return Collection
[ "Update", "entity", "value", "." ]
train
https://github.com/railken/lem/blob/cff1efcd090a9504b2faf5594121885786dea67a/src/Attributes/BaseAttribute.php#L243-L269
railken/lem
src/Attributes/BaseAttribute.php
BaseAttribute.fill
public function fill(EntityContract $entity, Bag $parameters) { $errors = new Collection(); if ($parameters->exists($this->name)) { $entity->setAttribute($this->name, $this->parse($parameters->get($this->name))); } return $errors; }
php
public function fill(EntityContract $entity, Bag $parameters) { $errors = new Collection(); if ($parameters->exists($this->name)) { $entity->setAttribute($this->name, $this->parse($parameters->get($this->name))); } return $errors; }
[ "public", "function", "fill", "(", "EntityContract", "$", "entity", ",", "Bag", "$", "parameters", ")", "{", "$", "errors", "=", "new", "Collection", "(", ")", ";", "if", "(", "$", "parameters", "->", "exists", "(", "$", "this", "->", "name", ")", ")", "{", "$", "entity", "->", "setAttribute", "(", "$", "this", "->", "name", ",", "$", "this", "->", "parse", "(", "$", "parameters", "->", "get", "(", "$", "this", "->", "name", ")", ")", ")", ";", "}", "return", "$", "errors", ";", "}" ]
Update entity value. @param \Railken\Lem\Contracts\EntityContract $entity @param \Railken\Bag $parameters @return Collection
[ "Update", "entity", "value", "." ]
train
https://github.com/railken/lem/blob/cff1efcd090a9504b2faf5594121885786dea67a/src/Attributes/BaseAttribute.php#L279-L288
railken/lem
src/Attributes/BaseAttribute.php
BaseAttribute.isUnique
public function isUnique(EntityContract $entity, $value) { $q = $this->getManager()->getRepository()->getQuery()->where($this->name, $value); if ($entity->exists) { $q->where('id', '!=', $entity->id); } return $q->count() > 0; }
php
public function isUnique(EntityContract $entity, $value) { $q = $this->getManager()->getRepository()->getQuery()->where($this->name, $value); if ($entity->exists) { $q->where('id', '!=', $entity->id); } return $q->count() > 0; }
[ "public", "function", "isUnique", "(", "EntityContract", "$", "entity", ",", "$", "value", ")", "{", "$", "q", "=", "$", "this", "->", "getManager", "(", ")", "->", "getRepository", "(", ")", "->", "getQuery", "(", ")", "->", "where", "(", "$", "this", "->", "name", ",", "$", "value", ")", ";", "if", "(", "$", "entity", "->", "exists", ")", "{", "$", "q", "->", "where", "(", "'id'", ",", "'!='", ",", "$", "entity", "->", "id", ")", ";", "}", "return", "$", "q", "->", "count", "(", ")", ">", "0", ";", "}" ]
Is a value valid ? @param \Railken\Lem\Contracts\EntityContract $entity @param mixed $value @return bool
[ "Is", "a", "value", "valid", "?" ]
train
https://github.com/railken/lem/blob/cff1efcd090a9504b2faf5594121885786dea67a/src/Attributes/BaseAttribute.php#L298-L307
ekyna/MediaBundle
Install/MediaInstaller.php
MediaInstaller.install
public function install(Command $command, InputInterface $input, OutputInterface $output) { $output->writeln('<info>[Media] Creating root folder:</info>'); $this->createRootFolders($output); $output->writeln(''); }
php
public function install(Command $command, InputInterface $input, OutputInterface $output) { $output->writeln('<info>[Media] Creating root folder:</info>'); $this->createRootFolders($output); $output->writeln(''); }
[ "public", "function", "install", "(", "Command", "$", "command", ",", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "output", "->", "writeln", "(", "'<info>[Media] Creating root folder:</info>'", ")", ";", "$", "this", "->", "createRootFolders", "(", "$", "output", ")", ";", "$", "output", "->", "writeln", "(", "''", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ekyna/MediaBundle/blob/512cf86c801a130a9f17eba8b48d646d23acdbab/Install/MediaInstaller.php#L39-L44
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", "." ]
train
https://github.com/ekyna/MediaBundle/blob/512cf86c801a130a9f17eba8b48d646d23acdbab/Install/MediaInstaller.php#L51-L74
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Point.php
Point.TryParse
public static function TryParse( $value, &$output ) : bool { if ( \is_null( $value ) ) { return false; } if ( $value instanceof Point ) { $output = $value; return true; } if ( $value instanceof Rectangle ) { $output = $value->Point; return true; } if ( \is_string( $value ) ) { $hits = null; if ( \preg_match( '~^x=(\d{1,4});\s*y=(\d{1,4})$~', $value, $hits ) ) { $output = new Point( \intval( $hits[ 1 ] ), \intval( $hits[ 2 ] ) ); return true; } if ( \preg_match( '~^(\d{1,4}),\s*(\d{1,4})$~', $value, $hits ) ) { $output = new Point( \intval( $hits[ 1 ] ), \intval( $hits[ 2 ] ) ); return true; } return false; } if ( \is_array( $value ) ) { if ( isset( $value[ 'x' ] ) && isset( $value[ 'y' ] ) ) { $output = new Point( \intval( $value[ 'x' ] ), \intval( $value[ 'y' ] ) ); return true; } if ( isset( $value[ 'X' ] ) && isset( $value[ 'Y' ] ) ) { $output = new Point( \intval( $value[ 'X' ] ), \intval( $value[ 'Y' ] ) ); return true; } if ( \count( $value ) != 2 ) { return false; } if ( isset( $value[ 0 ] ) && isset( $value[ 1 ] ) ) { $output = new Point( \intval( $value[ 0 ] ), \intval( $value[ 1 ] ) ); return true; } return false; } $type = new Type( $value ); if ( $type->hasAssociatedString() ) { $hits = null; if ( \preg_match( '~^x=(\d{1,4});\s*y=(\d{1,4})$~', $type->getStringValue(), $hits ) ) { $output = new Point( \intval( $hits[ 1 ] ), \intval( $hits[ 2 ] ) ); return true; } if ( \preg_match( '~^(\d{1,4}),\s*(\d{1,4})$~', $type->getStringValue(), $hits ) ) { $output = new Point( \intval( $hits[ 1 ] ), \intval( $hits[ 2 ] ) ); return true; } } return false; }
php
public static function TryParse( $value, &$output ) : bool { if ( \is_null( $value ) ) { return false; } if ( $value instanceof Point ) { $output = $value; return true; } if ( $value instanceof Rectangle ) { $output = $value->Point; return true; } if ( \is_string( $value ) ) { $hits = null; if ( \preg_match( '~^x=(\d{1,4});\s*y=(\d{1,4})$~', $value, $hits ) ) { $output = new Point( \intval( $hits[ 1 ] ), \intval( $hits[ 2 ] ) ); return true; } if ( \preg_match( '~^(\d{1,4}),\s*(\d{1,4})$~', $value, $hits ) ) { $output = new Point( \intval( $hits[ 1 ] ), \intval( $hits[ 2 ] ) ); return true; } return false; } if ( \is_array( $value ) ) { if ( isset( $value[ 'x' ] ) && isset( $value[ 'y' ] ) ) { $output = new Point( \intval( $value[ 'x' ] ), \intval( $value[ 'y' ] ) ); return true; } if ( isset( $value[ 'X' ] ) && isset( $value[ 'Y' ] ) ) { $output = new Point( \intval( $value[ 'X' ] ), \intval( $value[ 'Y' ] ) ); return true; } if ( \count( $value ) != 2 ) { return false; } if ( isset( $value[ 0 ] ) && isset( $value[ 1 ] ) ) { $output = new Point( \intval( $value[ 0 ] ), \intval( $value[ 1 ] ) ); return true; } return false; } $type = new Type( $value ); if ( $type->hasAssociatedString() ) { $hits = null; if ( \preg_match( '~^x=(\d{1,4});\s*y=(\d{1,4})$~', $type->getStringValue(), $hits ) ) { $output = new Point( \intval( $hits[ 1 ] ), \intval( $hits[ 2 ] ) ); return true; } if ( \preg_match( '~^(\d{1,4}),\s*(\d{1,4})$~', $type->getStringValue(), $hits ) ) { $output = new Point( \intval( $hits[ 1 ] ), \intval( $hits[ 2 ] ) ); return true; } } return false; }
[ "public", "static", "function", "TryParse", "(", "$", "value", ",", "&", "$", "output", ")", ":", "bool", "{", "if", "(", "\\", "is_null", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "value", "instanceof", "Point", ")", "{", "$", "output", "=", "$", "value", ";", "return", "true", ";", "}", "if", "(", "$", "value", "instanceof", "Rectangle", ")", "{", "$", "output", "=", "$", "value", "->", "Point", ";", "return", "true", ";", "}", "if", "(", "\\", "is_string", "(", "$", "value", ")", ")", "{", "$", "hits", "=", "null", ";", "if", "(", "\\", "preg_match", "(", "'~^x=(\\d{1,4});\\s*y=(\\d{1,4})$~'", ",", "$", "value", ",", "$", "hits", ")", ")", "{", "$", "output", "=", "new", "Point", "(", "\\", "intval", "(", "$", "hits", "[", "1", "]", ")", ",", "\\", "intval", "(", "$", "hits", "[", "2", "]", ")", ")", ";", "return", "true", ";", "}", "if", "(", "\\", "preg_match", "(", "'~^(\\d{1,4}),\\s*(\\d{1,4})$~'", ",", "$", "value", ",", "$", "hits", ")", ")", "{", "$", "output", "=", "new", "Point", "(", "\\", "intval", "(", "$", "hits", "[", "1", "]", ")", ",", "\\", "intval", "(", "$", "hits", "[", "2", "]", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "if", "(", "\\", "is_array", "(", "$", "value", ")", ")", "{", "if", "(", "isset", "(", "$", "value", "[", "'x'", "]", ")", "&&", "isset", "(", "$", "value", "[", "'y'", "]", ")", ")", "{", "$", "output", "=", "new", "Point", "(", "\\", "intval", "(", "$", "value", "[", "'x'", "]", ")", ",", "\\", "intval", "(", "$", "value", "[", "'y'", "]", ")", ")", ";", "return", "true", ";", "}", "if", "(", "isset", "(", "$", "value", "[", "'X'", "]", ")", "&&", "isset", "(", "$", "value", "[", "'Y'", "]", ")", ")", "{", "$", "output", "=", "new", "Point", "(", "\\", "intval", "(", "$", "value", "[", "'X'", "]", ")", ",", "\\", "intval", "(", "$", "value", "[", "'Y'", "]", ")", ")", ";", "return", "true", ";", "}", "if", "(", "\\", "count", "(", "$", "value", ")", "!=", "2", ")", "{", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "value", "[", "0", "]", ")", "&&", "isset", "(", "$", "value", "[", "1", "]", ")", ")", "{", "$", "output", "=", "new", "Point", "(", "\\", "intval", "(", "$", "value", "[", "0", "]", ")", ",", "\\", "intval", "(", "$", "value", "[", "1", "]", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "$", "type", "=", "new", "Type", "(", "$", "value", ")", ";", "if", "(", "$", "type", "->", "hasAssociatedString", "(", ")", ")", "{", "$", "hits", "=", "null", ";", "if", "(", "\\", "preg_match", "(", "'~^x=(\\d{1,4});\\s*y=(\\d{1,4})$~'", ",", "$", "type", "->", "getStringValue", "(", ")", ",", "$", "hits", ")", ")", "{", "$", "output", "=", "new", "Point", "(", "\\", "intval", "(", "$", "hits", "[", "1", "]", ")", ",", "\\", "intval", "(", "$", "hits", "[", "2", "]", ")", ")", ";", "return", "true", ";", "}", "if", "(", "\\", "preg_match", "(", "'~^(\\d{1,4}),\\s*(\\d{1,4})$~'", ",", "$", "type", "->", "getStringValue", "(", ")", ",", "$", "hits", ")", ")", "{", "$", "output", "=", "new", "Point", "(", "\\", "intval", "(", "$", "hits", "[", "1", "]", ")", ",", "\\", "intval", "(", "$", "hits", "[", "2", "]", ")", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Parse a value to an \Beluga\Drawing\Point instance. If the value uses an invalid format (boolean)FALSE is returned. @param \Beluga\Drawing\Point|\Beluga\Drawing\Rectangle|string|array $value @param \Beluga\Drawing\Point &$output @return boolean
[ "Parse", "a", "value", "to", "an", "\\", "Beluga", "\\", "Drawing", "\\", "Point", "instance", ".", "If", "the", "value", "uses", "an", "invalid", "format", "(", "boolean", ")", "FALSE", "is", "returned", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Point.php#L123-L201
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", "." ]
train
https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/PlantCategory.php#L90-L95
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", "." ]
train
https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/PlantCategory.php#L104-L107
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", "." ]
train
https://github.com/sil-project/VarietyBundle/blob/e9508ce13a4bb277d10bdcd925fdb84bc01f453f/src/Entity/PlantCategory.php#L126-L131
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" ]
train
https://github.com/DzikuVx/phpCache/blob/faf3003795ab21913e7ebb02fb04d6a480b7786c/src/File.php#L101-L132
DzikuVx/phpCache
src/File.php
File.maintenance
private function maintenance(CacheKey $key) { $module = $key->getModule(); if (! isset ( $this->elements [$module] )) { return false; } if (! isset ( $_SESSION [$this->cacheMaintenanceTimeName] [$module] )) { $_SESSION [$this->cacheMaintenanceTimeName] [$module] = time (); } if (time () < $_SESSION [$this->cacheMaintenanceTimeName] [$module]) { return false; } $_SESSION [$this->cacheMaintenanceTimeName] [$module] = time () + $this->timeThreshold; /** @noinspection PhpParamsInspection */ $keys = array_keys($this->elements[$module]); foreach ( $keys as $value ) { /** @noinspection PhpUndefinedMethodInspection */ if ($this->elements[$module][$value]->getTime() > time()) { unset ( $this->elements [$module] [$value] ); $this->changed = true; } } return true; }
php
private function maintenance(CacheKey $key) { $module = $key->getModule(); if (! isset ( $this->elements [$module] )) { return false; } if (! isset ( $_SESSION [$this->cacheMaintenanceTimeName] [$module] )) { $_SESSION [$this->cacheMaintenanceTimeName] [$module] = time (); } if (time () < $_SESSION [$this->cacheMaintenanceTimeName] [$module]) { return false; } $_SESSION [$this->cacheMaintenanceTimeName] [$module] = time () + $this->timeThreshold; /** @noinspection PhpParamsInspection */ $keys = array_keys($this->elements[$module]); foreach ( $keys as $value ) { /** @noinspection PhpUndefinedMethodInspection */ if ($this->elements[$module][$value]->getTime() > time()) { unset ( $this->elements [$module] [$value] ); $this->changed = true; } } return true; }
[ "private", "function", "maintenance", "(", "CacheKey", "$", "key", ")", "{", "$", "module", "=", "$", "key", "->", "getModule", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "elements", "[", "$", "module", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "isset", "(", "$", "_SESSION", "[", "$", "this", "->", "cacheMaintenanceTimeName", "]", "[", "$", "module", "]", ")", ")", "{", "$", "_SESSION", "[", "$", "this", "->", "cacheMaintenanceTimeName", "]", "[", "$", "module", "]", "=", "time", "(", ")", ";", "}", "if", "(", "time", "(", ")", "<", "$", "_SESSION", "[", "$", "this", "->", "cacheMaintenanceTimeName", "]", "[", "$", "module", "]", ")", "{", "return", "false", ";", "}", "$", "_SESSION", "[", "$", "this", "->", "cacheMaintenanceTimeName", "]", "[", "$", "module", "]", "=", "time", "(", ")", "+", "$", "this", "->", "timeThreshold", ";", "/** @noinspection PhpParamsInspection */", "$", "keys", "=", "array_keys", "(", "$", "this", "->", "elements", "[", "$", "module", "]", ")", ";", "foreach", "(", "$", "keys", "as", "$", "value", ")", "{", "/** @noinspection PhpUndefinedMethodInspection */", "if", "(", "$", "this", "->", "elements", "[", "$", "module", "]", "[", "$", "value", "]", "->", "getTime", "(", ")", ">", "time", "(", ")", ")", "{", "unset", "(", "$", "this", "->", "elements", "[", "$", "module", "]", "[", "$", "value", "]", ")", ";", "$", "this", "->", "changed", "=", "true", ";", "}", "}", "return", "true", ";", "}" ]
Cache maintenance, remove old entries @param CacheKey $key @return boolean
[ "Cache", "maintenance", "remove", "old", "entries" ]
train
https://github.com/DzikuVx/phpCache/blob/faf3003795ab21913e7ebb02fb04d6a480b7786c/src/File.php#L139-L169
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" ]
train
https://github.com/DzikuVx/phpCache/blob/faf3003795ab21913e7ebb02fb04d6a480b7786c/src/File.php#L176-L183
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" ]
train
https://github.com/DzikuVx/phpCache/blob/faf3003795ab21913e7ebb02fb04d6a480b7786c/src/File.php#L190-L199
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" ]
train
https://github.com/DzikuVx/phpCache/blob/faf3003795ab21913e7ebb02fb04d6a480b7786c/src/File.php#L205-L210
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" ]
train
https://github.com/DzikuVx/phpCache/blob/faf3003795ab21913e7ebb02fb04d6a480b7786c/src/File.php#L217-L224
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" ]
train
https://github.com/lasallecms/lasallecms-l5-lasallecmsapi-pkg/blob/05083be19645d52be86d8ba4f322773db348a11d/src/FeaturedImageProcessing/FeaturedImageProcessing.php#L69-L140
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" ]
train
https://github.com/lasallecms/lasallecms-l5-lasallecmsapi-pkg/blob/05083be19645d52be86d8ba4f322773db348a11d/src/FeaturedImageProcessing/FeaturedImageProcessing.php#L175-L193