repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
encorephp/view-controller
src/View/Style/StyleCollection.php
StyleCollection.addByElement
public function addByElement($element, array $styles) { $this->elements[$element] = array_merge_recursive($this->getByElement($element), $styles); }
php
public function addByElement($element, array $styles) { $this->elements[$element] = array_merge_recursive($this->getByElement($element), $styles); }
[ "public", "function", "addByElement", "(", "$", "element", ",", "array", "$", "styles", ")", "{", "$", "this", "->", "elements", "[", "$", "element", "]", "=", "array_merge_recursive", "(", "$", "this", "->", "getByElement", "(", "$", "element", ")", ","...
Add style by element name @param string $element @param array $styles
[ "Add", "style", "by", "element", "name" ]
38335ee5c175364ea49bc378c141aabfe9fa3def
https://github.com/encorephp/view-controller/blob/38335ee5c175364ea49bc378c141aabfe9fa3def/src/View/Style/StyleCollection.php#L64-L67
train
znframework/package-console
Upgrade.php
Upgrade.fe
protected static function fe() { if( ! empty(ZN::upgrade()) ) { $status = self::$lang['upgradeSuccess']; } else { $status = self::$lang['alreadyVersion']; if( $upgradeError = ZN::upgradeError() ) { $status = $upgradeError; } } return $status; }
php
protected static function fe() { if( ! empty(ZN::upgrade()) ) { $status = self::$lang['upgradeSuccess']; } else { $status = self::$lang['alreadyVersion']; if( $upgradeError = ZN::upgradeError() ) { $status = $upgradeError; } } return $status; }
[ "protected", "static", "function", "fe", "(", ")", "{", "if", "(", "!", "empty", "(", "ZN", "::", "upgrade", "(", ")", ")", ")", "{", "$", "status", "=", "self", "::", "$", "lang", "[", "'upgradeSuccess'", "]", ";", "}", "else", "{", "$", "status...
Protected upgrade FE
[ "Protected", "upgrade", "FE" ]
fde428da8b9d926ea4256c235f542e6225c5d788
https://github.com/znframework/package-console/blob/fde428da8b9d926ea4256c235f542e6225c5d788/Upgrade.php#L59-L76
train
znframework/package-console
Upgrade.php
Upgrade.eip
protected static function eip($tag = 'znframework') { if( $return = Restful::useragent(true)->get('https://api.github.com/repos/znframework/'.$tag.'/tags') ) { if( ! isset($return->message) ) { usort($return, function($data1, $data2){ return strcmp($data1->name, $data2->name); }); rsort($return); $lastest = $return[0]; $lastVersionData = $lastest->name ?? ZN_VERSION; $open = popen('composer update 2>&1', 'r'); $result = fread($open, 2048); pclose($open); if( empty($result) ) { $status = self::$lang['composerUpdate']; } else { if( ZN_VERSION !== $lastVersionData ) { File::replace(DIRECTORY_INDEX, ZN_VERSION, $lastVersionData); $status = self::$lang['upgradeSuccess']; } else { $status = self::$lang['alreadyVersion']; } } } else { $status = $return->message; } return $status; } }
php
protected static function eip($tag = 'znframework') { if( $return = Restful::useragent(true)->get('https://api.github.com/repos/znframework/'.$tag.'/tags') ) { if( ! isset($return->message) ) { usort($return, function($data1, $data2){ return strcmp($data1->name, $data2->name); }); rsort($return); $lastest = $return[0]; $lastVersionData = $lastest->name ?? ZN_VERSION; $open = popen('composer update 2>&1', 'r'); $result = fread($open, 2048); pclose($open); if( empty($result) ) { $status = self::$lang['composerUpdate']; } else { if( ZN_VERSION !== $lastVersionData ) { File::replace(DIRECTORY_INDEX, ZN_VERSION, $lastVersionData); $status = self::$lang['upgradeSuccess']; } else { $status = self::$lang['alreadyVersion']; } } } else { $status = $return->message; } return $status; } }
[ "protected", "static", "function", "eip", "(", "$", "tag", "=", "'znframework'", ")", "{", "if", "(", "$", "return", "=", "Restful", "::", "useragent", "(", "true", ")", "->", "get", "(", "'https://api.github.com/repos/znframework/'", ".", "$", "tag", ".", ...
Proteted upgrade EIP
[ "Proteted", "upgrade", "EIP" ]
fde428da8b9d926ea4256c235f542e6225c5d788
https://github.com/znframework/package-console/blob/fde428da8b9d926ea4256c235f542e6225c5d788/Upgrade.php#L81-L124
train
jivoo/http
src/Message/Response.php
Response.cached
public function cached($public = true, $expires = '+1 year') { if (!is_int($expires)) { $expires = strtotime($expires); } $maxAge = $expires - time(); $pragma = $public ? 'public' : 'private'; $cache = $pragma . ', max-age=' . $maxAge; $response = clone $this; $response->setHeader('Expires', Message::date($expires)); $response->setHeader('Pragma', $pragma); $response->setHeader('Cache-Control', $cache); return $response; }
php
public function cached($public = true, $expires = '+1 year') { if (!is_int($expires)) { $expires = strtotime($expires); } $maxAge = $expires - time(); $pragma = $public ? 'public' : 'private'; $cache = $pragma . ', max-age=' . $maxAge; $response = clone $this; $response->setHeader('Expires', Message::date($expires)); $response->setHeader('Pragma', $pragma); $response->setHeader('Cache-Control', $cache); return $response; }
[ "public", "function", "cached", "(", "$", "public", "=", "true", ",", "$", "expires", "=", "'+1 year'", ")", "{", "if", "(", "!", "is_int", "(", "$", "expires", ")", ")", "{", "$", "expires", "=", "strtotime", "(", "$", "expires", ")", ";", "}", ...
Set cache settings. @param string $public Public or private. @param int|string $expires Time on which cache expires. Can be a UNIX timestamp or a string used with {@see strtotime()}.
[ "Set", "cache", "settings", "." ]
3c1d8dba66978bc91fc2b324dd941e5da3b253bc
https://github.com/jivoo/http/blob/3c1d8dba66978bc91fc2b324dd941e5da3b253bc/src/Message/Response.php#L77-L90
train
jivoo/http
src/Message/Response.php
Response.file
public static function file($path, $type = null) { $response = new self( Status::OK, new PhpStream($path, 'rb') ); if (isset($type)) { $response->setHeader('Content-Type', $type); } return $response; }
php
public static function file($path, $type = null) { $response = new self( Status::OK, new PhpStream($path, 'rb') ); if (isset($type)) { $response->setHeader('Content-Type', $type); } return $response; }
[ "public", "static", "function", "file", "(", "$", "path", ",", "$", "type", "=", "null", ")", "{", "$", "response", "=", "new", "self", "(", "Status", "::", "OK", ",", "new", "PhpStream", "(", "$", "path", ",", "'rb'", ")", ")", ";", "if", "(", ...
Create a file response. @param string $path Path to file. @param string|null $type Optional MIME type. @return self The response.
[ "Create", "a", "file", "response", "." ]
3c1d8dba66978bc91fc2b324dd941e5da3b253bc
https://github.com/jivoo/http/blob/3c1d8dba66978bc91fc2b324dd941e5da3b253bc/src/Message/Response.php#L116-L126
train
nonetallt/jinitialize-core
src/JinitializeApplication.php
JinitializeApplication.registerPlugin
public function registerPlugin(array $plugin) { /* Dont't process nameless plugins */ if(! isset($plugin['name'])) return; /* Create a container for the plugin */ $this->getContainer()->addPlugin($plugin['name']); /* Commands are registered first so they can be found be porcedures */ if(isset($plugin['commands'])) { $this->registerCommands($plugin['name'], $plugin['commands']); } if(isset($plugin['procedures'])) { /* The path info is appended by ComposerScripts */ $this->registerProcedures($plugin['name'], $plugin['procedures'], $plugin['path']); } if(isset($plugin['settings'])) { $this->registerSettings($plugin['name'], $plugin[ 'settings' ]); } }
php
public function registerPlugin(array $plugin) { /* Dont't process nameless plugins */ if(! isset($plugin['name'])) return; /* Create a container for the plugin */ $this->getContainer()->addPlugin($plugin['name']); /* Commands are registered first so they can be found be porcedures */ if(isset($plugin['commands'])) { $this->registerCommands($plugin['name'], $plugin['commands']); } if(isset($plugin['procedures'])) { /* The path info is appended by ComposerScripts */ $this->registerProcedures($plugin['name'], $plugin['procedures'], $plugin['path']); } if(isset($plugin['settings'])) { $this->registerSettings($plugin['name'], $plugin[ 'settings' ]); } }
[ "public", "function", "registerPlugin", "(", "array", "$", "plugin", ")", "{", "/* Dont't process nameless plugins */", "if", "(", "!", "isset", "(", "$", "plugin", "[", "'name'", "]", ")", ")", "return", ";", "/* Create a container for the plugin */", "$", "this"...
Register a plugin found in manifest file @param array $plugin @return null
[ "Register", "a", "plugin", "found", "in", "manifest", "file" ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/JinitializeApplication.php#L61-L82
train
nonetallt/jinitialize-core
src/JinitializeApplication.php
JinitializeApplication.registerProcedures
public function registerProcedures(string $plugin, array $procedures, string $path) { /* Append the installation path before the files */ array_walk($procedures, function(&$procedure) use ($path){ $procedure = "$path/$procedure"; }); /* Create a factory from list of paths defined by plugin */ $factory = new ProcedureFactory($this, $procedures); /* Get a list of all procedure names contained in file paths */ foreach($factory->getNames() as $name) { /* Use the factory to create and register each procedure */ $procedure = $factory->create($name); $this->add($procedure); } }
php
public function registerProcedures(string $plugin, array $procedures, string $path) { /* Append the installation path before the files */ array_walk($procedures, function(&$procedure) use ($path){ $procedure = "$path/$procedure"; }); /* Create a factory from list of paths defined by plugin */ $factory = new ProcedureFactory($this, $procedures); /* Get a list of all procedure names contained in file paths */ foreach($factory->getNames() as $name) { /* Use the factory to create and register each procedure */ $procedure = $factory->create($name); $this->add($procedure); } }
[ "public", "function", "registerProcedures", "(", "string", "$", "plugin", ",", "array", "$", "procedures", ",", "string", "$", "path", ")", "{", "/* Append the installation path before the files */", "array_walk", "(", "$", "procedures", ",", "function", "(", "&", ...
Register all procedures for a given plugin
[ "Register", "all", "procedures", "for", "a", "given", "plugin" ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/JinitializeApplication.php#L87-L103
train
nonetallt/jinitialize-core
src/JinitializeApplication.php
JinitializeApplication.registerCommands
public function registerCommands(string $plugin, array $commands) { $newCommands = []; foreach($commands as $commandClass) { $command = new $commandClass($plugin); $command = CommandFactory::setNamespace($command); $this->add($command); $newCommands[] = $command; } return $newCommands; }
php
public function registerCommands(string $plugin, array $commands) { $newCommands = []; foreach($commands as $commandClass) { $command = new $commandClass($plugin); $command = CommandFactory::setNamespace($command); $this->add($command); $newCommands[] = $command; } return $newCommands; }
[ "public", "function", "registerCommands", "(", "string", "$", "plugin", ",", "array", "$", "commands", ")", "{", "$", "newCommands", "=", "[", "]", ";", "foreach", "(", "$", "commands", "as", "$", "commandClass", ")", "{", "$", "command", "=", "new", "...
Register all commands for a given plugin @param string $plugin The plugin these commands will be registered for @param array $commands array containing the classnames of the commands @return array $newCommands array containing JinitializeCommand objects
[ "Register", "all", "commands", "for", "a", "given", "plugin" ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/JinitializeApplication.php#L114-L125
train
nonetallt/jinitialize-core
src/JinitializeApplication.php
JinitializeApplication.missingSettings
public function missingSettings() { $missing = []; foreach($this->recommendedSettings() as $plugin => $settings) { foreach($settings as $setting) { /* Get value for the setting */ $value = $_ENV[$setting] ?? null; if(is_null($value)) $missing[$plugin][] = $setting; } } return $missing; }
php
public function missingSettings() { $missing = []; foreach($this->recommendedSettings() as $plugin => $settings) { foreach($settings as $setting) { /* Get value for the setting */ $value = $_ENV[$setting] ?? null; if(is_null($value)) $missing[$plugin][] = $setting; } } return $missing; }
[ "public", "function", "missingSettings", "(", ")", "{", "$", "missing", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "recommendedSettings", "(", ")", "as", "$", "plugin", "=>", "$", "settings", ")", "{", "foreach", "(", "$", "settings", "as",...
Get an array of plugins and their settings that are not defined in env
[ "Get", "an", "array", "of", "plugins", "and", "their", "settings", "that", "are", "not", "defined", "in", "env" ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/JinitializeApplication.php#L150-L162
train
weew/console
src/Weew/Console/Output.php
Output.flushBuffer
public function flushBuffer() { $content = $this->format($this->buffer->flush()); if ( ! $this->is(OutputVerbosity::SILENT)) { fwrite($this->getOutputStream(), $content); } }
php
public function flushBuffer() { $content = $this->format($this->buffer->flush()); if ( ! $this->is(OutputVerbosity::SILENT)) { fwrite($this->getOutputStream(), $content); } }
[ "public", "function", "flushBuffer", "(", ")", "{", "$", "content", "=", "$", "this", "->", "format", "(", "$", "this", "->", "buffer", "->", "flush", "(", ")", ")", ";", "if", "(", "!", "$", "this", "->", "is", "(", "OutputVerbosity", "::", "SILEN...
Manually flush buffered output.
[ "Manually", "flush", "buffered", "output", "." ]
083703f21fdeff3cfe6036ebd21ab9cb84ca74c7
https://github.com/weew/console/blob/083703f21fdeff3cfe6036ebd21ab9cb84ca74c7/src/Weew/Console/Output.php#L219-L225
train
ntentan/ajumamoro
src/Queue.php
Queue.add
public function add(Job $job) { $jobClass = new \ReflectionClass($job); $name = $jobClass->getName(); $object = serialize($job); $jobId = $this->broker->put(['object' => $object, 'class' => $name]); $this->broker->setStatus($jobId, ['status' => Job::STATUS_QUEUED, 'queued'=> date(DATE_RFC3339_EXTENDED)] ); return $jobId; }
php
public function add(Job $job) { $jobClass = new \ReflectionClass($job); $name = $jobClass->getName(); $object = serialize($job); $jobId = $this->broker->put(['object' => $object, 'class' => $name]); $this->broker->setStatus($jobId, ['status' => Job::STATUS_QUEUED, 'queued'=> date(DATE_RFC3339_EXTENDED)] ); return $jobId; }
[ "public", "function", "add", "(", "Job", "$", "job", ")", "{", "$", "jobClass", "=", "new", "\\", "ReflectionClass", "(", "$", "job", ")", ";", "$", "name", "=", "$", "jobClass", "->", "getName", "(", ")", ";", "$", "object", "=", "serialize", "(",...
Add a job to the job queue. @param Job $job @return string
[ "Add", "a", "job", "to", "the", "job", "queue", "." ]
160c772c02e40e9656ab03acd1e9387aebce7219
https://github.com/ntentan/ajumamoro/blob/160c772c02e40e9656ab03acd1e9387aebce7219/src/Queue.php#L27-L37
train
robotdance/php-console
src/Console.php
Console.indent
public static function indent($str, $spaces = 4, $level = 1){ return str_repeat(" ", $spaces * $level) . str_replace("\n", "\n" . str_repeat(" ", $spaces * $level), $str); }
php
public static function indent($str, $spaces = 4, $level = 1){ return str_repeat(" ", $spaces * $level) . str_replace("\n", "\n" . str_repeat(" ", $spaces * $level), $str); }
[ "public", "static", "function", "indent", "(", "$", "str", ",", "$", "spaces", "=", "4", ",", "$", "level", "=", "1", ")", "{", "return", "str_repeat", "(", "\" \"", ",", "$", "spaces", "*", "$", "level", ")", ".", "str_replace", "(", "\"\\n\"", ",...
Inserts N spaces to the left of a string @param $str String @param $spaces Number of spaces to insert @param $level Indentation level (1, 2, 3, ...) @return String with N spaces inserted
[ "Inserts", "N", "spaces", "to", "the", "left", "of", "a", "string" ]
1bac28ed8868e5247040dec96e8b8df162fdaa07
https://github.com/robotdance/php-console/blob/1bac28ed8868e5247040dec96e8b8df162fdaa07/src/Console.php#L165-L168
train
robotdance/php-console
src/Console.php
Console.moveCursorRel
public function moveCursorRel($x, $y) { $yChar = ($y < 0) ? "A" : "B"; // up / down $xChar = ($x < 0) ? "D" : "C"; // left / right fwrite(STDOUT, "\e[" . abs($x) . $xChar); fwrite(STDOUT, "\e[" . abs($y) . $yChar); }
php
public function moveCursorRel($x, $y) { $yChar = ($y < 0) ? "A" : "B"; // up / down $xChar = ($x < 0) ? "D" : "C"; // left / right fwrite(STDOUT, "\e[" . abs($x) . $xChar); fwrite(STDOUT, "\e[" . abs($y) . $yChar); }
[ "public", "function", "moveCursorRel", "(", "$", "x", ",", "$", "y", ")", "{", "$", "yChar", "=", "(", "$", "y", "<", "0", ")", "?", "\"A\"", ":", "\"B\"", ";", "// up / down", "$", "xChar", "=", "(", "$", "x", "<", "0", ")", "?", "\"D\"", ":...
Moves cursor relatively to its current position @param $x Positive value move to right, left otherwise @param $y Positive value move to down, up otherwise
[ "Moves", "cursor", "relatively", "to", "its", "current", "position" ]
1bac28ed8868e5247040dec96e8b8df162fdaa07
https://github.com/robotdance/php-console/blob/1bac28ed8868e5247040dec96e8b8df162fdaa07/src/Console.php#L184-L190
train
CampaignChain/channel-mailchimp
REST/MailChimpOAuth.php
Hybrid_Providers_MailChimp.getEndpoint
function getEndpoint() { $this->api->curl_header = array( 'Authorization: OAuth '.$this->api->access_token, ); $data = $this->api->get( $this->metadata_url ); if ( ! isset( $data->api_endpoint ) ){ throw new Exception( "Endpoint request failed! {$this->providerId} returned an invalid response.", 6 ); } return $data->api_endpoint; }
php
function getEndpoint() { $this->api->curl_header = array( 'Authorization: OAuth '.$this->api->access_token, ); $data = $this->api->get( $this->metadata_url ); if ( ! isset( $data->api_endpoint ) ){ throw new Exception( "Endpoint request failed! {$this->providerId} returned an invalid response.", 6 ); } return $data->api_endpoint; }
[ "function", "getEndpoint", "(", ")", "{", "$", "this", "->", "api", "->", "curl_header", "=", "array", "(", "'Authorization: OAuth '", ".", "$", "this", "->", "api", "->", "access_token", ",", ")", ";", "$", "data", "=", "$", "this", "->", "api", "->",...
Load the metadata, which includes the URL of the API endpoint.
[ "Load", "the", "metadata", "which", "includes", "the", "URL", "of", "the", "API", "endpoint", "." ]
c68035c8140aa05db5cf8556e68f5d4eaae8e2fa
https://github.com/CampaignChain/channel-mailchimp/blob/c68035c8140aa05db5cf8556e68f5d4eaae8e2fa/REST/MailChimpOAuth.php#L74-L86
train
nattreid/app-manager
src/Helpers/Info.php
Info.getPhpInfo
protected function getPhpInfo(): string { ob_start(); phpinfo(); $result = ob_get_contents(); ob_end_clean(); $result = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $result); $result = preg_replace('/,\s*/', ', ', $result); return $result; }
php
protected function getPhpInfo(): string { ob_start(); phpinfo(); $result = ob_get_contents(); ob_end_clean(); $result = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $result); $result = preg_replace('/,\s*/', ', ', $result); return $result; }
[ "protected", "function", "getPhpInfo", "(", ")", ":", "string", "{", "ob_start", "(", ")", ";", "phpinfo", "(", ")", ";", "$", "result", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "$", "result", "=", "preg_replace", "(", "'%^...
Vrati vypis PHP info @return string
[ "Vrati", "vypis", "PHP", "info" ]
7821d09a0b3e58ba9c6eb81d44e35aacce55de75
https://github.com/nattreid/app-manager/blob/7821d09a0b3e58ba9c6eb81d44e35aacce55de75/src/Helpers/Info.php#L34-L44
train
nattreid/app-manager
src/Helpers/Info.php
Info.getSystem
protected function getSystem(): Obj { $system = new Obj; $system->hostname = $this->readFile('/etc/hostname'); $system->ip = $this->getIp(); $system->distribution = Strings::replace($this->readCommand('lsb_release -d'), '/Description:\s/'); $system->kernel = $this->readCommand('uname -r') . ' ' . $this->readCommand('uname -i'); $uptime = $this->readFileAsArray('/proc/uptime', ' '); if ($uptime) { $system->uptime = new Obj; $system->uptime->days = (int) gmdate("d", (int) $uptime[0]) - 1; $system->uptime->hours = (int) gmdate("H", (int) $uptime[0]); $system->uptime->minutes = (int) gmdate("i", (int) $uptime[0]); } $system->users = $this->readCommandAsArray('users', ' '); $system->load = $this->getLoad(); $system->processes = new Obj; $system->processes->total = $this->readCommand('ps axo state | wc -l'); $system->processes->running = $this->readCommand('ps axo state | grep "R" | wc -l'); $system->processes->sleeping = $system->processes->total - $system->processes->running; return $system; }
php
protected function getSystem(): Obj { $system = new Obj; $system->hostname = $this->readFile('/etc/hostname'); $system->ip = $this->getIp(); $system->distribution = Strings::replace($this->readCommand('lsb_release -d'), '/Description:\s/'); $system->kernel = $this->readCommand('uname -r') . ' ' . $this->readCommand('uname -i'); $uptime = $this->readFileAsArray('/proc/uptime', ' '); if ($uptime) { $system->uptime = new Obj; $system->uptime->days = (int) gmdate("d", (int) $uptime[0]) - 1; $system->uptime->hours = (int) gmdate("H", (int) $uptime[0]); $system->uptime->minutes = (int) gmdate("i", (int) $uptime[0]); } $system->users = $this->readCommandAsArray('users', ' '); $system->load = $this->getLoad(); $system->processes = new Obj; $system->processes->total = $this->readCommand('ps axo state | wc -l'); $system->processes->running = $this->readCommand('ps axo state | grep "R" | wc -l'); $system->processes->sleeping = $system->processes->total - $system->processes->running; return $system; }
[ "protected", "function", "getSystem", "(", ")", ":", "Obj", "{", "$", "system", "=", "new", "Obj", ";", "$", "system", "->", "hostname", "=", "$", "this", "->", "readFile", "(", "'/etc/hostname'", ")", ";", "$", "system", "->", "ip", "=", "$", "this"...
Vrati informace o systemu @return Obj
[ "Vrati", "informace", "o", "systemu" ]
7821d09a0b3e58ba9c6eb81d44e35aacce55de75
https://github.com/nattreid/app-manager/blob/7821d09a0b3e58ba9c6eb81d44e35aacce55de75/src/Helpers/Info.php#L86-L113
train
nattreid/app-manager
src/Helpers/Info.php
Info.getLoad
protected function getLoad(): ?string { $load = $this->readFileAsArray('/proc/loadavg', ' '); if ($load) { unset($load[3], $load[4]); return implode(' ', $load); } return null; }
php
protected function getLoad(): ?string { $load = $this->readFileAsArray('/proc/loadavg', ' '); if ($load) { unset($load[3], $load[4]); return implode(' ', $load); } return null; }
[ "protected", "function", "getLoad", "(", ")", ":", "?", "string", "{", "$", "load", "=", "$", "this", "->", "readFileAsArray", "(", "'/proc/loadavg'", ",", "' '", ")", ";", "if", "(", "$", "load", ")", "{", "unset", "(", "$", "load", "[", "3", "]",...
Vrati vytizeni serveru @return string|null
[ "Vrati", "vytizeni", "serveru" ]
7821d09a0b3e58ba9c6eb81d44e35aacce55de75
https://github.com/nattreid/app-manager/blob/7821d09a0b3e58ba9c6eb81d44e35aacce55de75/src/Helpers/Info.php#L128-L136
train
nattreid/app-manager
src/Helpers/Info.php
Info.getHardware
protected function getHardware(): Obj { $hardware = new Obj; $product = $this->readFile('/sys/devices/virtual/dmi/id/product_name'); $board = $this->readFile('/sys/devices/virtual/dmi/id/board_name'); $bios = $this->readFile('/sys/devices/virtual/dmi/id/bios_version'); $biosDate = $this->readFile('/sys/devices/virtual/dmi/id/bios_date'); $hardware->server = $product . ($board ? '/' . $board : null) . ($bios ? ', BIOS ' . $bios : null) . ($biosDate ? ' ' . $biosDate : null); $hardware->cpu = $this->getCpu(); $hardware->scsi = $this->getScsi(); $hardware->data = !empty($hardware->server) || !empty($hardware->cpu) || !empty($hardware->scsi); return $hardware; }
php
protected function getHardware(): Obj { $hardware = new Obj; $product = $this->readFile('/sys/devices/virtual/dmi/id/product_name'); $board = $this->readFile('/sys/devices/virtual/dmi/id/board_name'); $bios = $this->readFile('/sys/devices/virtual/dmi/id/bios_version'); $biosDate = $this->readFile('/sys/devices/virtual/dmi/id/bios_date'); $hardware->server = $product . ($board ? '/' . $board : null) . ($bios ? ', BIOS ' . $bios : null) . ($biosDate ? ' ' . $biosDate : null); $hardware->cpu = $this->getCpu(); $hardware->scsi = $this->getScsi(); $hardware->data = !empty($hardware->server) || !empty($hardware->cpu) || !empty($hardware->scsi); return $hardware; }
[ "protected", "function", "getHardware", "(", ")", ":", "Obj", "{", "$", "hardware", "=", "new", "Obj", ";", "$", "product", "=", "$", "this", "->", "readFile", "(", "'/sys/devices/virtual/dmi/id/product_name'", ")", ";", "$", "board", "=", "$", "this", "->...
Vrati informace o hardware @return Obj
[ "Vrati", "informace", "o", "hardware" ]
7821d09a0b3e58ba9c6eb81d44e35aacce55de75
https://github.com/nattreid/app-manager/blob/7821d09a0b3e58ba9c6eb81d44e35aacce55de75/src/Helpers/Info.php#L142-L161
train
nattreid/app-manager
src/Helpers/Info.php
Info.getScsi
private function getScsi(): array { $get_type = false; $device = null; $scsi = []; $data = $this->readFile('/proc/scsi/scsi'); if ($data !== null) { $bufe = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); foreach ($bufe as $buf) { if (preg_match('/Vendor: (.*) Model: (.*) Rev: (.*)/i', $buf, $devices)) { $get_type = true; $device = $devices; continue; } if ($get_type) { preg_match('/Type:\s+(\S+)/i', $buf, $dev_type); $dev = new Obj; $dev->name = trim($device[1]) . ' ' . trim($device[2]); $dev->type = trim($dev_type[1]); $scsi[] = $dev; $get_type = false; } } } return $scsi; }
php
private function getScsi(): array { $get_type = false; $device = null; $scsi = []; $data = $this->readFile('/proc/scsi/scsi'); if ($data !== null) { $bufe = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); foreach ($bufe as $buf) { if (preg_match('/Vendor: (.*) Model: (.*) Rev: (.*)/i', $buf, $devices)) { $get_type = true; $device = $devices; continue; } if ($get_type) { preg_match('/Type:\s+(\S+)/i', $buf, $dev_type); $dev = new Obj; $dev->name = trim($device[1]) . ' ' . trim($device[2]); $dev->type = trim($dev_type[1]); $scsi[] = $dev; $get_type = false; } } } return $scsi; }
[ "private", "function", "getScsi", "(", ")", ":", "array", "{", "$", "get_type", "=", "false", ";", "$", "device", "=", "null", ";", "$", "scsi", "=", "[", "]", ";", "$", "data", "=", "$", "this", "->", "readFile", "(", "'/proc/scsi/scsi'", ")", ";"...
Vrati informace o scsi @return Obj[]
[ "Vrati", "informace", "o", "scsi" ]
7821d09a0b3e58ba9c6eb81d44e35aacce55de75
https://github.com/nattreid/app-manager/blob/7821d09a0b3e58ba9c6eb81d44e35aacce55de75/src/Helpers/Info.php#L311-L337
train
nattreid/app-manager
src/Helpers/Info.php
Info.getMemory
protected function getMemory(): ?Obj { $memory = null; $meminfo = $this->readFile('/proc/meminfo'); if ($meminfo) { $bufer = preg_split("/\n/", $meminfo, -1, PREG_SPLIT_NO_EMPTY); $memory = new Obj; foreach ($bufer as $buf) { if (preg_match('/^MemTotal:\s+(.*)\s*kB/i', $buf, $ar_buf)) { $memory->total = ((float) $ar_buf[1]) * 1024; } elseif (preg_match('/^MemFree:\s+(.*)\s*kB/i', $buf, $ar_buf)) { $memory->free = ((float) $ar_buf[1]) * 1024; } elseif (preg_match('/^Cached:\s+(.*)\s*kB/i', $buf, $ar_buf)) { $memory->cache = ((float) $ar_buf[1]) * 1024; } elseif (preg_match('/^Buffers:\s+(.*)\s*kB/i', $buf, $ar_buf)) { $memory->buffer = ((float) $ar_buf[1]) * 1024; } } $memory->used = $memory->total - $memory->free; if ($memory->cache !== null && $memory->buffer !== null) { $memory->application = $memory->used - $memory->cache - $memory->buffer; } $memory->swap = []; $swaps = preg_split("/\n/", $this->readFile('/proc/swaps'), -1, PREG_SPLIT_NO_EMPTY); unset($swaps[0]); foreach ($swaps as $swap) { $ar_buf = preg_split('/\s+/', $swap, PREG_BAD_UTF8_OFFSET_ERROR); $swap = new Obj; $swap->mount = $ar_buf[0]; $swap->name = 'SWAP'; $swap->total = $ar_buf[2] * 1024; $swap->used = $ar_buf[3] * 1024; $swap->free = $swap->total - $swap->used; $memory->swap[] = $swap; } } return $memory; }
php
protected function getMemory(): ?Obj { $memory = null; $meminfo = $this->readFile('/proc/meminfo'); if ($meminfo) { $bufer = preg_split("/\n/", $meminfo, -1, PREG_SPLIT_NO_EMPTY); $memory = new Obj; foreach ($bufer as $buf) { if (preg_match('/^MemTotal:\s+(.*)\s*kB/i', $buf, $ar_buf)) { $memory->total = ((float) $ar_buf[1]) * 1024; } elseif (preg_match('/^MemFree:\s+(.*)\s*kB/i', $buf, $ar_buf)) { $memory->free = ((float) $ar_buf[1]) * 1024; } elseif (preg_match('/^Cached:\s+(.*)\s*kB/i', $buf, $ar_buf)) { $memory->cache = ((float) $ar_buf[1]) * 1024; } elseif (preg_match('/^Buffers:\s+(.*)\s*kB/i', $buf, $ar_buf)) { $memory->buffer = ((float) $ar_buf[1]) * 1024; } } $memory->used = $memory->total - $memory->free; if ($memory->cache !== null && $memory->buffer !== null) { $memory->application = $memory->used - $memory->cache - $memory->buffer; } $memory->swap = []; $swaps = preg_split("/\n/", $this->readFile('/proc/swaps'), -1, PREG_SPLIT_NO_EMPTY); unset($swaps[0]); foreach ($swaps as $swap) { $ar_buf = preg_split('/\s+/', $swap, PREG_BAD_UTF8_OFFSET_ERROR); $swap = new Obj; $swap->mount = $ar_buf[0]; $swap->name = 'SWAP'; $swap->total = $ar_buf[2] * 1024; $swap->used = $ar_buf[3] * 1024; $swap->free = $swap->total - $swap->used; $memory->swap[] = $swap; } } return $memory; }
[ "protected", "function", "getMemory", "(", ")", ":", "?", "Obj", "{", "$", "memory", "=", "null", ";", "$", "meminfo", "=", "$", "this", "->", "readFile", "(", "'/proc/meminfo'", ")", ";", "if", "(", "$", "meminfo", ")", "{", "$", "bufer", "=", "pr...
Vrati informace o pameti @return Obj|null
[ "Vrati", "informace", "o", "pameti" ]
7821d09a0b3e58ba9c6eb81d44e35aacce55de75
https://github.com/nattreid/app-manager/blob/7821d09a0b3e58ba9c6eb81d44e35aacce55de75/src/Helpers/Info.php#L343-L383
train
nattreid/app-manager
src/Helpers/Info.php
Info.getFileSystem
protected function getFileSystem(): array { $fileSystem = []; $command = $this->readCommand('df -T'); if ($command) { $bufe = preg_split("/\n/", $command, -1, PREG_SPLIT_NO_EMPTY); unset($bufe[0]); foreach ($bufe as $buf) { $data = preg_split('/\s+/', $buf); $mounted = new Obj; $mounted->partition = $data[0]; $mounted->type = $data[1]; $mounted->size = $data[2] * 1024; $mounted->used = $data[3] * 1024; $mounted->free = $data[4] * 1024; $mounted->usage = $data[5]; $mounted->mountPoint = $data[6]; $fileSystem[] = $mounted; } } return $fileSystem; }
php
protected function getFileSystem(): array { $fileSystem = []; $command = $this->readCommand('df -T'); if ($command) { $bufe = preg_split("/\n/", $command, -1, PREG_SPLIT_NO_EMPTY); unset($bufe[0]); foreach ($bufe as $buf) { $data = preg_split('/\s+/', $buf); $mounted = new Obj; $mounted->partition = $data[0]; $mounted->type = $data[1]; $mounted->size = $data[2] * 1024; $mounted->used = $data[3] * 1024; $mounted->free = $data[4] * 1024; $mounted->usage = $data[5]; $mounted->mountPoint = $data[6]; $fileSystem[] = $mounted; } } return $fileSystem; }
[ "protected", "function", "getFileSystem", "(", ")", ":", "array", "{", "$", "fileSystem", "=", "[", "]", ";", "$", "command", "=", "$", "this", "->", "readCommand", "(", "'df -T'", ")", ";", "if", "(", "$", "command", ")", "{", "$", "bufe", "=", "p...
Vrati informace o souborovem system @return Obj[]
[ "Vrati", "informace", "o", "souborovem", "system" ]
7821d09a0b3e58ba9c6eb81d44e35aacce55de75
https://github.com/nattreid/app-manager/blob/7821d09a0b3e58ba9c6eb81d44e35aacce55de75/src/Helpers/Info.php#L389-L414
train
nattreid/app-manager
src/Helpers/Info.php
Info.getNetwork
protected function getNetwork(): array { $network = []; $data = $this->readFile('/proc/net/dev'); if ($data !== null) { $bufe = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); unset($bufe[0], $bufe[1]); foreach ($bufe as $buf) { list($dev_name, $stats_list) = preg_split('/:/', $buf, 2); $stats = preg_split('/\s+/', trim($stats_list)); $dev = new Obj; $dev->name = trim($dev_name); $dev->recieve = (int) $stats[0]; $dev->sent = (int) $stats[8]; $dev->error = (int) $stats[2] + (int) $stats[10]; $dev->drop = (int) $stats[3] + (int) $stats[11]; $ipBuff = preg_split("/\n/", $this->readCommand('ip addr show ' . $dev->name), -1, PREG_SPLIT_NO_EMPTY); foreach ($ipBuff as $line) { if (preg_match('/^\s*link\/ether\s+(.*)\s+brd.*/i', $line, $ar_buf)) { $dev->mac = $ar_buf[1]; } elseif (preg_match('/^\s*inet6\s+(.*)\/.*/i', $line, $ar_buf)) { $dev->ip6 = $ar_buf[1]; } elseif (preg_match('/^\s*inet\s+(.*)\/.*/i', $line, $ar_buf)) { $dev->ip = $ar_buf[1]; } } $network[] = $dev; } } return $network; }
php
protected function getNetwork(): array { $network = []; $data = $this->readFile('/proc/net/dev'); if ($data !== null) { $bufe = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); unset($bufe[0], $bufe[1]); foreach ($bufe as $buf) { list($dev_name, $stats_list) = preg_split('/:/', $buf, 2); $stats = preg_split('/\s+/', trim($stats_list)); $dev = new Obj; $dev->name = trim($dev_name); $dev->recieve = (int) $stats[0]; $dev->sent = (int) $stats[8]; $dev->error = (int) $stats[2] + (int) $stats[10]; $dev->drop = (int) $stats[3] + (int) $stats[11]; $ipBuff = preg_split("/\n/", $this->readCommand('ip addr show ' . $dev->name), -1, PREG_SPLIT_NO_EMPTY); foreach ($ipBuff as $line) { if (preg_match('/^\s*link\/ether\s+(.*)\s+brd.*/i', $line, $ar_buf)) { $dev->mac = $ar_buf[1]; } elseif (preg_match('/^\s*inet6\s+(.*)\/.*/i', $line, $ar_buf)) { $dev->ip6 = $ar_buf[1]; } elseif (preg_match('/^\s*inet\s+(.*)\/.*/i', $line, $ar_buf)) { $dev->ip = $ar_buf[1]; } } $network[] = $dev; } } return $network; }
[ "protected", "function", "getNetwork", "(", ")", ":", "array", "{", "$", "network", "=", "[", "]", ";", "$", "data", "=", "$", "this", "->", "readFile", "(", "'/proc/net/dev'", ")", ";", "if", "(", "$", "data", "!==", "null", ")", "{", "$", "bufe",...
Vrati informace o siti @return Obj[]
[ "Vrati", "informace", "o", "siti" ]
7821d09a0b3e58ba9c6eb81d44e35aacce55de75
https://github.com/nattreid/app-manager/blob/7821d09a0b3e58ba9c6eb81d44e35aacce55de75/src/Helpers/Info.php#L420-L453
train
yujin1st/yii2-user
models/User.php
User.attemptConfirmation
public function attemptConfirmation($code) { $token = Token::find()->where([ 'userId' => $this->id, 'code' => $code, 'type' => Token::TYPE_CONFIRMATION, ])->one(); if ($token instanceof Token && !$token->isExpired) { $token->delete(); if (($success = $this->confirm())) { Yii::$app->user->login($this, $this->module->rememberFor); $message = Yii::t('users', 'Thank you, registration is now complete.'); } else { $message = Yii::t('users', 'Something went wrong and your account has not been confirmed.'); } } else { $success = false; $message = Yii::t('users', 'The confirmation link is invalid or expired. Please try requesting a new one.'); } Yii::$app->session->setFlash($success ? 'success' : 'danger', $message); return $success; }
php
public function attemptConfirmation($code) { $token = Token::find()->where([ 'userId' => $this->id, 'code' => $code, 'type' => Token::TYPE_CONFIRMATION, ])->one(); if ($token instanceof Token && !$token->isExpired) { $token->delete(); if (($success = $this->confirm())) { Yii::$app->user->login($this, $this->module->rememberFor); $message = Yii::t('users', 'Thank you, registration is now complete.'); } else { $message = Yii::t('users', 'Something went wrong and your account has not been confirmed.'); } } else { $success = false; $message = Yii::t('users', 'The confirmation link is invalid or expired. Please try requesting a new one.'); } Yii::$app->session->setFlash($success ? 'success' : 'danger', $message); return $success; }
[ "public", "function", "attemptConfirmation", "(", "$", "code", ")", "{", "$", "token", "=", "Token", "::", "find", "(", ")", "->", "where", "(", "[", "'userId'", "=>", "$", "this", "->", "id", ",", "'code'", "=>", "$", "code", ",", "'type'", "=>", ...
Attempts user confirmation. @param string $code Confirmation code. @return boolean
[ "Attempts", "user", "confirmation", "." ]
b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f
https://github.com/yujin1st/yii2-user/blob/b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f/models/User.php#L316-L339
train
yujin1st/yii2-user
models/User.php
User.assignRoles
public function assignRoles() { $auth = Yii::$app->authManager; $auth->assign($auth->getRole(Access::ROLE_USER), $this->id); }
php
public function assignRoles() { $auth = Yii::$app->authManager; $auth->assign($auth->getRole(Access::ROLE_USER), $this->id); }
[ "public", "function", "assignRoles", "(", ")", "{", "$", "auth", "=", "Yii", "::", "$", "app", "->", "authManager", ";", "$", "auth", "->", "assign", "(", "$", "auth", "->", "getRole", "(", "Access", "::", "ROLE_USER", ")", ",", "$", "this", "->", ...
Assign roles to new user Overwrite this method for own purposes
[ "Assign", "roles", "to", "new", "user", "Overwrite", "this", "method", "for", "own", "purposes" ]
b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f
https://github.com/yujin1st/yii2-user/blob/b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f/models/User.php#L471-L474
train
jitesoft/php-math
src/VectorMath.php
VectorMath.mul
public static function mul(Vector $vector, $value) : Vector { $type = get_class($vector); $out = new $type(); $count = count($out); if ($value instanceof Vector === false) { $value = new $type(...array_fill(0, $count , $value)); } for ($i=$count;$i-->0;) { $out[$i] = $vector[$i] * $value[$i]; } return $out; }
php
public static function mul(Vector $vector, $value) : Vector { $type = get_class($vector); $out = new $type(); $count = count($out); if ($value instanceof Vector === false) { $value = new $type(...array_fill(0, $count , $value)); } for ($i=$count;$i-->0;) { $out[$i] = $vector[$i] * $value[$i]; } return $out; }
[ "public", "static", "function", "mul", "(", "Vector", "$", "vector", ",", "$", "value", ")", ":", "Vector", "{", "$", "type", "=", "get_class", "(", "$", "vector", ")", ";", "$", "out", "=", "new", "$", "type", "(", ")", ";", "$", "count", "=", ...
Vector multiplication. @param Vector $vector @param Vector|float $value @return Vector
[ "Vector", "multiplication", "." ]
1775055e5a14ef30c7df0deeb1fe1ff0775bb581
https://github.com/jitesoft/php-math/blob/1775055e5a14ef30c7df0deeb1fe1ff0775bb581/src/VectorMath.php#L18-L32
train
jitesoft/php-math
src/VectorMath.php
VectorMath.cross
public static function cross(Vector3D $value1, Vector3D $value2) : Vector3D { return new Vector3D( ($value1->getY() * $value2->getZ()) - ($value1->getZ() * $value2->getY()), -(($value1->getX() * $value2->getZ()) - ($value1->getZ() * $value2->getX())), ($value1->getX() * $value2->getY()) - ($value1->getY() * $value2->getX()) ); }
php
public static function cross(Vector3D $value1, Vector3D $value2) : Vector3D { return new Vector3D( ($value1->getY() * $value2->getZ()) - ($value1->getZ() * $value2->getY()), -(($value1->getX() * $value2->getZ()) - ($value1->getZ() * $value2->getX())), ($value1->getX() * $value2->getY()) - ($value1->getY() * $value2->getX()) ); }
[ "public", "static", "function", "cross", "(", "Vector3D", "$", "value1", ",", "Vector3D", "$", "value2", ")", ":", "Vector3D", "{", "return", "new", "Vector3D", "(", "(", "$", "value1", "->", "getY", "(", ")", "*", "$", "value2", "->", "getZ", "(", "...
Cross product of two vectors. @param Vector3D $value1 @param Vector3D $value2 @return Vector3D
[ "Cross", "product", "of", "two", "vectors", "." ]
1775055e5a14ef30c7df0deeb1fe1ff0775bb581
https://github.com/jitesoft/php-math/blob/1775055e5a14ef30c7df0deeb1fe1ff0775bb581/src/VectorMath.php#L125-L131
train
droid-php/droid-model
src/Model/Inventory/Remote/SynchroniserComposer.php
SynchroniserComposer.executeComposerInstall
private function executeComposerInstall($host) { $ssh = $host->getSshClient(); $ssh->exec(array( sprintf('cd %s;', $host->getWorkingDirectory()), 'stat composer.phar' )); if ($ssh->getExitCode()) { $this->installComposer($host); } $ssh = $host->getSshClient(); $ssh->exec( array( sprintf('cd %s;', $host->getWorkingDirectory()), 'php composer.phar install --no-dev' ), null, self::TIMEOUT_MAX_RUNTIME_COMPOSER_INSTALL ); if ($ssh->getExitCode()) { throw new SynchronisationException($host->getName(), sprintf( 'Unable to execute composer install: "%s".', $ssh->getErrorOutput() )); } }
php
private function executeComposerInstall($host) { $ssh = $host->getSshClient(); $ssh->exec(array( sprintf('cd %s;', $host->getWorkingDirectory()), 'stat composer.phar' )); if ($ssh->getExitCode()) { $this->installComposer($host); } $ssh = $host->getSshClient(); $ssh->exec( array( sprintf('cd %s;', $host->getWorkingDirectory()), 'php composer.phar install --no-dev' ), null, self::TIMEOUT_MAX_RUNTIME_COMPOSER_INSTALL ); if ($ssh->getExitCode()) { throw new SynchronisationException($host->getName(), sprintf( 'Unable to execute composer install: "%s".', $ssh->getErrorOutput() )); } }
[ "private", "function", "executeComposerInstall", "(", "$", "host", ")", "{", "$", "ssh", "=", "$", "host", "->", "getSshClient", "(", ")", ";", "$", "ssh", "->", "exec", "(", "array", "(", "sprintf", "(", "'cd %s;'", ",", "$", "host", "->", "getWorking...
Execute composer install from the host's working directory. Install composer to the working directory if it isn't already installed there.
[ "Execute", "composer", "install", "from", "the", "host", "s", "working", "directory", ".", "Install", "composer", "to", "the", "working", "directory", "if", "it", "isn", "t", "already", "installed", "there", "." ]
5dee2a4a6a7a77512747ac5ddf2f4b8f7018ce5a
https://github.com/droid-php/droid-model/blob/5dee2a4a6a7a77512747ac5ddf2f4b8f7018ce5a/src/Model/Inventory/Remote/SynchroniserComposer.php#L76-L101
train
weew/router-routes-invoker-container-aware
src/Weew/Router/Invoker/ContainerAware/RoutesInvoker.php
RoutesInvoker.invoke
public function invoke($route) { if ($route instanceof IRoute) { return $this->invokeRoute($route); } return new HttpResponse(HttpStatusCode::NOT_FOUND); }
php
public function invoke($route) { if ($route instanceof IRoute) { return $this->invokeRoute($route); } return new HttpResponse(HttpStatusCode::NOT_FOUND); }
[ "public", "function", "invoke", "(", "$", "route", ")", "{", "if", "(", "$", "route", "instanceof", "IRoute", ")", "{", "return", "$", "this", "->", "invokeRoute", "(", "$", "route", ")", ";", "}", "return", "new", "HttpResponse", "(", "HttpStatusCode", ...
Invoke given route. If the route is null, returns a 404 response. @param IRoute $route @return IHttpResponse @throws InvalidRouteValue
[ "Invoke", "given", "route", ".", "If", "the", "route", "is", "null", "returns", "a", "404", "response", "." ]
96bc23f67081223031218274b7a51fff196e6039
https://github.com/weew/router-routes-invoker-container-aware/blob/96bc23f67081223031218274b7a51fff196e6039/src/Weew/Router/Invoker/ContainerAware/RoutesInvoker.php#L45-L51
train
zepi/turbo-base
Zepi/Api/Rest/src/Helper/RestHelper.php
RestHelper.sendRequest
public function sendRequest(ApiKey $apiKey, RestRequest $request) { $hmac = $this->generateHmac($apiKey->getPrivateKey(), $request->getEndpoint(), array_merge($request->getQueryData(), $request->getPostData())); $client = new Client([ 'base_uri' => $request->getHost() ]); $args = [ 'auth' => [$apiKey->getPublicKey(), $hmac], 'headers' => [ 'Accept' => 'application/json' ] ]; if ($request->getRequestMethod() === 'POST') { $args['form_params'] = $request->getPostData(); } else { $args['query'] = $request->getQueryData(); } try { $responseRaw = $client->request($request->getRequestMethod(), $request->getEndpoint(), $args); } catch (RequestException $e) { if (!$e->hasResponse()) { throw new Exception('Cannot send REST request.', 0, $e); } $responseRaw = $e->getResponse(); } return $this->prepareResponse($responseRaw, $request); }
php
public function sendRequest(ApiKey $apiKey, RestRequest $request) { $hmac = $this->generateHmac($apiKey->getPrivateKey(), $request->getEndpoint(), array_merge($request->getQueryData(), $request->getPostData())); $client = new Client([ 'base_uri' => $request->getHost() ]); $args = [ 'auth' => [$apiKey->getPublicKey(), $hmac], 'headers' => [ 'Accept' => 'application/json' ] ]; if ($request->getRequestMethod() === 'POST') { $args['form_params'] = $request->getPostData(); } else { $args['query'] = $request->getQueryData(); } try { $responseRaw = $client->request($request->getRequestMethod(), $request->getEndpoint(), $args); } catch (RequestException $e) { if (!$e->hasResponse()) { throw new Exception('Cannot send REST request.', 0, $e); } $responseRaw = $e->getResponse(); } return $this->prepareResponse($responseRaw, $request); }
[ "public", "function", "sendRequest", "(", "ApiKey", "$", "apiKey", ",", "RestRequest", "$", "request", ")", "{", "$", "hmac", "=", "$", "this", "->", "generateHmac", "(", "$", "apiKey", "->", "getPrivateKey", "(", ")", ",", "$", "request", "->", "getEndp...
Sends the RestRequest to the endpoint @access public @param \Zepi\Api\AccessControl\Entity\ApiKey $apiKey @param \Zepi\Api\Rest\Entity\Request $request @return \Zepi\Api\Rest\Entity\Response @throws \Zepi\Api\Rest\Exception Cannot send REST request.
[ "Sends", "the", "RestRequest", "to", "the", "endpoint" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Api/Rest/src/Helper/RestHelper.php#L85-L117
train
zepi/turbo-base
Zepi/Api/Rest/src/Helper/RestHelper.php
RestHelper.prepareResponse
protected function prepareResponse($responseRaw, RestRequest $request) { $body = (string) $responseRaw->getBody(); $parsedResult = json_decode($body); if ($parsedResult == false) { $parsedResult = new \stdClass(); } $response = new RestResponse($responseRaw->getStatusCode(), $body, $parsedResult, $request); return $response; }
php
protected function prepareResponse($responseRaw, RestRequest $request) { $body = (string) $responseRaw->getBody(); $parsedResult = json_decode($body); if ($parsedResult == false) { $parsedResult = new \stdClass(); } $response = new RestResponse($responseRaw->getStatusCode(), $body, $parsedResult, $request); return $response; }
[ "protected", "function", "prepareResponse", "(", "$", "responseRaw", ",", "RestRequest", "$", "request", ")", "{", "$", "body", "=", "(", "string", ")", "$", "responseRaw", "->", "getBody", "(", ")", ";", "$", "parsedResult", "=", "json_decode", "(", "$", ...
Prepares the response object for the given raw response object @param mixed $responseRaw @param \Zepi\Api\Rest\Entity\Request @return \Zepi\Api\Rest\Entity\Response
[ "Prepares", "the", "response", "object", "for", "the", "given", "raw", "response", "object" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Api/Rest/src/Helper/RestHelper.php#L126-L138
train
zepi/turbo-base
Zepi/Api/Rest/src/Helper/RestHelper.php
RestHelper.fillXml
protected function fillXml(\SimpleXMLElement $element, $data) { foreach ($data as $key => $value) { if (is_array($value) || is_object($value)) { if (!is_numeric($key)) { $child = $element->addChild($key); } else { $child = $element; } $this->fillXml($child, $value); } else { $element->addChild($key, $value); } } }
php
protected function fillXml(\SimpleXMLElement $element, $data) { foreach ($data as $key => $value) { if (is_array($value) || is_object($value)) { if (!is_numeric($key)) { $child = $element->addChild($key); } else { $child = $element; } $this->fillXml($child, $value); } else { $element->addChild($key, $value); } } }
[ "protected", "function", "fillXml", "(", "\\", "SimpleXMLElement", "$", "element", ",", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "||", "is_objec...
Builds a xml string out of the given array @access public @param \SimpleXMLElement $element @param array|object $data
[ "Builds", "a", "xml", "string", "out", "of", "the", "given", "array" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Api/Rest/src/Helper/RestHelper.php#L181-L196
train
zepi/turbo-base
Zepi/Api/Rest/src/Helper/RestHelper.php
RestHelper.generateHmac
protected function generateHmac($privateKey, $requestedRoute, $data) { $completeString = $requestedRoute . json_encode($data); return hash_hmac('sha256', $completeString, $privateKey); }
php
protected function generateHmac($privateKey, $requestedRoute, $data) { $completeString = $requestedRoute . json_encode($data); return hash_hmac('sha256', $completeString, $privateKey); }
[ "protected", "function", "generateHmac", "(", "$", "privateKey", ",", "$", "requestedRoute", ",", "$", "data", ")", "{", "$", "completeString", "=", "$", "requestedRoute", ".", "json_encode", "(", "$", "data", ")", ";", "return", "hash_hmac", "(", "'sha256'"...
Generates the hmac for the given data @access protected @param string $privateKey @param string $requestedRoute @param array $data @return string
[ "Generates", "the", "hmac", "for", "the", "given", "data" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Api/Rest/src/Helper/RestHelper.php#L231-L236
train
Dhii/data-state-base
src/CreateTransitionerExceptionCapableTrait.php
CreateTransitionerExceptionCapableTrait._createTransitionerException
protected function _createTransitionerException( $message = null, $code = null, RootException $previous = null, $transitioner = null ) { return new TransitionerException($message, $code, $previous, $transitioner); }
php
protected function _createTransitionerException( $message = null, $code = null, RootException $previous = null, $transitioner = null ) { return new TransitionerException($message, $code, $previous, $transitioner); }
[ "protected", "function", "_createTransitionerException", "(", "$", "message", "=", "null", ",", "$", "code", "=", "null", ",", "RootException", "$", "previous", "=", "null", ",", "$", "transitioner", "=", "null", ")", "{", "return", "new", "TransitionerExcepti...
Creates a new transitioner exception. @since [*next-version*] @param string|Stringable|null $message The error message, if any. @param int|null $code The error code, if any. @param RootException|null $previous The previous exception for chaining, if any. @param TransitionerInterface|null $transitioner The transitioner that erred, if any. @return TransitionerException The created transitioner exception.
[ "Creates", "a", "new", "transitioner", "exception", "." ]
762866374fc8c7cc482fd8a5d37520b14873be06
https://github.com/Dhii/data-state-base/blob/762866374fc8c7cc482fd8a5d37520b14873be06/src/CreateTransitionerExceptionCapableTrait.php#L28-L35
train
budkit/budkit-framework
src/Budkit/Filesystem/Directory.php
Directory.chmodR
public function chmodR($path, $filemode) { if (!$this->isFolder($path)) { return $this->chmod($path, $filemode); } $dirh = @opendir($path); while ($file = readdir($dirh)) { if ($file != '.' && $file != '..') { $fullpath = $path . '/' . $file; if (!$this->isFolder($fullpath)) { if (!$this->chmod($fullpath, $filemode)) { return false; } } else { if (!$this->chmodR($fullpath, $filemode)) { return false; } } } } closedir($dirh); if ($this->chmod($path, $filemode)) { return true; } else { return false; } }
php
public function chmodR($path, $filemode) { if (!$this->isFolder($path)) { return $this->chmod($path, $filemode); } $dirh = @opendir($path); while ($file = readdir($dirh)) { if ($file != '.' && $file != '..') { $fullpath = $path . '/' . $file; if (!$this->isFolder($fullpath)) { if (!$this->chmod($fullpath, $filemode)) { return false; } } else { if (!$this->chmodR($fullpath, $filemode)) { return false; } } } } closedir($dirh); if ($this->chmod($path, $filemode)) { return true; } else { return false; } }
[ "public", "function", "chmodR", "(", "$", "path", ",", "$", "filemode", ")", "{", "if", "(", "!", "$", "this", "->", "isFolder", "(", "$", "path", ")", ")", "{", "return", "$", "this", "->", "chmod", "(", "$", "path", ",", "$", "filemode", ")", ...
Recursively sets permissions for all files in a folder @param type $path @param type $permission
[ "Recursively", "sets", "permissions", "for", "all", "files", "in", "a", "folder" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Filesystem/Directory.php#L31-L61
train
budkit/budkit-framework
src/Budkit/Filesystem/Directory.php
Directory.ls
final public function ls($path, $exclude = array(".DS_Store", ".git", ".svn", ".CVS"), $recursive = FALSE, $recursivelimit = 0, $showfiles = FALSE, $sort = TRUE, $long = FALSE) { //1. Search $name as a folder or as a file if (!$this->is($path)) { //if in path is a directory return array(); } $dirh = @opendir($path); //directory handler //$recursion = 0; $found = []; if ($dirh) { while (false !== ($file = readdir($dirh))) { // remove '.' and '..' if ($file == '.' || $file == '..' || in_array($file, $exclude)) { continue; } $recursion = 0; $newPath = $path . $file; if ($this->isFolder($newPath) && $recursive && ($recursion < $recursiveLimit)) { //echo $this->is($newPath)."<br />"; //echo $newPath."<br />"; $newRecursiveLimit = ((int)$recursiveLimit > 0) ? ((int)$recursiveLimit - 1) : 0; $items = $this->list($newPath, $exclude, $recursive, $newRecursiveLimit); $found = array_merge($items, $found); } $found[] = $newPath; } closedir($dirh); } //@TODO if long, get additional info for each path; return $found; }
php
final public function ls($path, $exclude = array(".DS_Store", ".git", ".svn", ".CVS"), $recursive = FALSE, $recursivelimit = 0, $showfiles = FALSE, $sort = TRUE, $long = FALSE) { //1. Search $name as a folder or as a file if (!$this->is($path)) { //if in path is a directory return array(); } $dirh = @opendir($path); //directory handler //$recursion = 0; $found = []; if ($dirh) { while (false !== ($file = readdir($dirh))) { // remove '.' and '..' if ($file == '.' || $file == '..' || in_array($file, $exclude)) { continue; } $recursion = 0; $newPath = $path . $file; if ($this->isFolder($newPath) && $recursive && ($recursion < $recursiveLimit)) { //echo $this->is($newPath)."<br />"; //echo $newPath."<br />"; $newRecursiveLimit = ((int)$recursiveLimit > 0) ? ((int)$recursiveLimit - 1) : 0; $items = $this->list($newPath, $exclude, $recursive, $newRecursiveLimit); $found = array_merge($items, $found); } $found[] = $newPath; } closedir($dirh); } //@TODO if long, get additional info for each path; return $found; }
[ "final", "public", "function", "ls", "(", "$", "path", ",", "$", "exclude", "=", "array", "(", "\".DS_Store\"", ",", "\".git\"", ",", "\".svn\"", ",", "\".CVS\"", ")", ",", "$", "recursive", "=", "FALSE", ",", "$", "recursivelimit", "=", "0", ",", "$",...
Lists all the files in a directory @param string $path the compound path being searched and listed @param array $exclude a list of folders, files or fileTypes to exclude from the list @param boolean $recursive Determines whether to search subdirectories if found @param interger $recursivelimit The number of deep subfolder levels to search @param boolean $showfiles Include Files contained in each folder to the array @param boolean $sort Sort folder/files in alphabetical order @param boolean $long returns size, permission, datemodified in list if true, Slow!! @return array $list = array( "path/to/folder" => array( "name" => '', "parent" => '', //only in long "size" => '', //only in long "modified" => '', //only in long "permission" => '', "files" => array( "path/to/file" => array( "name" => '', "size" => '', //only in long "modified" => '', //only in long "permission" => '', "extension" => '', "mimetype" => ''//only in long ) ), "children" => array()
[ "Lists", "all", "the", "files", "in", "a", "directory" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Filesystem/Directory.php#L102-L140
train
budkit/budkit-framework
src/Budkit/Filesystem/Directory.php
Directory.deleteContents
final public function deleteContents($folderpath, $filterByExtension = [], $filterByName = [], $filterExcludeMode = true, $recursive = true) { //1. Search $name as a folder or as a file if (!$this->is($folderpath)) { //if in path is a directory return false; } $dirh = @opendir($folderpath); //directory handler if ($dirh) { while (false !== ($file = readdir($dirh))) { // remove '.' and '..' if ($filterExcludeMode) { //Excluding by name as in "file.ext" if ($file == '.' || $file == '..' || in_array($file, $filterByName)) { continue; } //Excluding extension if (!empty($filterByExtension)) { $fhandler = $this->getFile(); $extension = $fhandler->getExtension($file); if (in_array($extension, $filterByExtension)) { continue; } } } //The new path $newPath = $folderpath . DS . $file; //echo $newPath; //If newpath is a folder and we are deleting recursively if ($this->isFolder($newPath) && $recursive) { $this->deleteContents($newPath, $filterByExtension, $filterByName, $filterExcludeMode, $recursive); } //Now unlink the file if (!static::delete($newPath)) { static::setError("Could not delete {$newPath}"); return false; } } closedir($dirh); } //@TODO if long, get additional info for each path; return true; }
php
final public function deleteContents($folderpath, $filterByExtension = [], $filterByName = [], $filterExcludeMode = true, $recursive = true) { //1. Search $name as a folder or as a file if (!$this->is($folderpath)) { //if in path is a directory return false; } $dirh = @opendir($folderpath); //directory handler if ($dirh) { while (false !== ($file = readdir($dirh))) { // remove '.' and '..' if ($filterExcludeMode) { //Excluding by name as in "file.ext" if ($file == '.' || $file == '..' || in_array($file, $filterByName)) { continue; } //Excluding extension if (!empty($filterByExtension)) { $fhandler = $this->getFile(); $extension = $fhandler->getExtension($file); if (in_array($extension, $filterByExtension)) { continue; } } } //The new path $newPath = $folderpath . DS . $file; //echo $newPath; //If newpath is a folder and we are deleting recursively if ($this->isFolder($newPath) && $recursive) { $this->deleteContents($newPath, $filterByExtension, $filterByName, $filterExcludeMode, $recursive); } //Now unlink the file if (!static::delete($newPath)) { static::setError("Could not delete {$newPath}"); return false; } } closedir($dirh); } //@TODO if long, get additional info for each path; return true; }
[ "final", "public", "function", "deleteContents", "(", "$", "folderpath", ",", "$", "filterByExtension", "=", "[", "]", ",", "$", "filterByName", "=", "[", "]", ",", "$", "filterExcludeMode", "=", "true", ",", "$", "recursive", "=", "true", ")", "{", "//1...
Method to delete the contents of a folder @param type $folderpath @param type $filterByType @param type $filterByName @param type $filterExcludeMode
[ "Method", "to", "delete", "the", "contents", "of", "a", "folder" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Filesystem/Directory.php#L208-L258
train
Puzzlout/FrameworkMvcLegacy
src/Core/Page.php
Page.GetOutput
public function GetOutput() { $numberOfVarsExtracted = extract($this->variablesList); if (count($this->variablesList) !== $numberOfVarsExtracted) { $errMsg = "Number of variables extracted different from the $vars array"; throw new \Exception($errMsg, Codes\LogicErrors::UNEXPECTED_VALUE, null); } ob_start(); include_once $this->contentFile; $content = ob_get_clean(); ob_start(); include_once "APP_ROOT_DIR" . \Puzzlout\Framework\Enums\FrameworkFolderName::ViewsFolderName . \Puzzlout\Framework\Enums\FileNameConst::LayoutTemplate; return ob_get_clean(); }
php
public function GetOutput() { $numberOfVarsExtracted = extract($this->variablesList); if (count($this->variablesList) !== $numberOfVarsExtracted) { $errMsg = "Number of variables extracted different from the $vars array"; throw new \Exception($errMsg, Codes\LogicErrors::UNEXPECTED_VALUE, null); } ob_start(); include_once $this->contentFile; $content = ob_get_clean(); ob_start(); include_once "APP_ROOT_DIR" . \Puzzlout\Framework\Enums\FrameworkFolderName::ViewsFolderName . \Puzzlout\Framework\Enums\FileNameConst::LayoutTemplate; return ob_get_clean(); }
[ "public", "function", "GetOutput", "(", ")", "{", "$", "numberOfVarsExtracted", "=", "extract", "(", "$", "this", "->", "variablesList", ")", ";", "if", "(", "count", "(", "$", "this", "->", "variablesList", ")", "!==", "$", "numberOfVarsExtracted", ")", "...
Computes the html output of send to the client. It extracts the variables first, @return string The output generated. @throws \Exception Throws if the number of variables extracted if different to the number of variables given to extract.
[ "Computes", "the", "html", "output", "of", "send", "to", "the", "client", ".", "It", "extracts", "the", "variables", "first" ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Core/Page.php#L67-L79
train
nishimura/laiz-db
src/Laiz/Db/Driver/Pgsql.php
Pgsql.getMetaTables
public function getMetaTables(){ $stmt = $this->query(self::META_TABLES_SQL); if ($stmt === false){ return array(); } $rows = array(); foreach ($stmt as $row){ $rows[] = $row[0]; } return $rows; }
php
public function getMetaTables(){ $stmt = $this->query(self::META_TABLES_SQL); if ($stmt === false){ return array(); } $rows = array(); foreach ($stmt as $row){ $rows[] = $row[0]; } return $rows; }
[ "public", "function", "getMetaTables", "(", ")", "{", "$", "stmt", "=", "$", "this", "->", "query", "(", "self", "::", "META_TABLES_SQL", ")", ";", "if", "(", "$", "stmt", "===", "false", ")", "{", "return", "array", "(", ")", ";", "}", "$", "rows"...
Return tables information. @return array @access public
[ "Return", "tables", "information", "." ]
9d14c99711cd2081d2f658c5253f72721a2c7337
https://github.com/nishimura/laiz-db/blob/9d14c99711cd2081d2f658c5253f72721a2c7337/src/Laiz/Db/Driver/Pgsql.php#L66-L78
train
nishimura/laiz-db
src/Laiz/Db/Driver/Pgsql.php
Pgsql.getMetaColumns
public function getMetaColumns($tableName){ $stmt = $this->query(self::META_COLUMNS_SQL, array($tableName)); if ($stmt === false){ return array(); } $rows = array(); foreach ($stmt as $row){ switch($row[1]){ case 'float8': case 'numeric': $type = PDO::PARAM_STR; // Not exists PARAM_FLOAT by current version. break; case 'int4': case 'int8': $type = PDO::PARAM_INT; break; case 'bool': $type = PDO::PARAM_BOOL; break; default: $type = PDO::PARAM_STR; break; } $rows[$row[0]] = $type; } return $rows; }
php
public function getMetaColumns($tableName){ $stmt = $this->query(self::META_COLUMNS_SQL, array($tableName)); if ($stmt === false){ return array(); } $rows = array(); foreach ($stmt as $row){ switch($row[1]){ case 'float8': case 'numeric': $type = PDO::PARAM_STR; // Not exists PARAM_FLOAT by current version. break; case 'int4': case 'int8': $type = PDO::PARAM_INT; break; case 'bool': $type = PDO::PARAM_BOOL; break; default: $type = PDO::PARAM_STR; break; } $rows[$row[0]] = $type; } return $rows; }
[ "public", "function", "getMetaColumns", "(", "$", "tableName", ")", "{", "$", "stmt", "=", "$", "this", "->", "query", "(", "self", "::", "META_COLUMNS_SQL", ",", "array", "(", "$", "tableName", ")", ")", ";", "if", "(", "$", "stmt", "===", "false", ...
Return columns information. @return array @access public
[ "Return", "columns", "information", "." ]
9d14c99711cd2081d2f658c5253f72721a2c7337
https://github.com/nishimura/laiz-db/blob/9d14c99711cd2081d2f658c5253f72721a2c7337/src/Laiz/Db/Driver/Pgsql.php#L86-L118
train
nishimura/laiz-db
src/Laiz/Db/Driver/Pgsql.php
Pgsql.currval
public function currval($table, $pkey){ $stmt = $this->query("SELECT currval('{$table}_{$pkey}_seq')"); if (!$stmt) return false; $ret = $stmt->fetch(PDO::FETCH_NUM); if (!$ret){ $stmt = null; return false; } $stmt = null; return $ret[0]; }
php
public function currval($table, $pkey){ $stmt = $this->query("SELECT currval('{$table}_{$pkey}_seq')"); if (!$stmt) return false; $ret = $stmt->fetch(PDO::FETCH_NUM); if (!$ret){ $stmt = null; return false; } $stmt = null; return $ret[0]; }
[ "public", "function", "currval", "(", "$", "table", ",", "$", "pkey", ")", "{", "$", "stmt", "=", "$", "this", "->", "query", "(", "\"SELECT currval('{$table}_{$pkey}_seq')\"", ")", ";", "if", "(", "!", "$", "stmt", ")", "return", "false", ";", "$", "r...
Return current sequence. @param string $table
[ "Return", "current", "sequence", "." ]
9d14c99711cd2081d2f658c5253f72721a2c7337
https://github.com/nishimura/laiz-db/blob/9d14c99711cd2081d2f658c5253f72721a2c7337/src/Laiz/Db/Driver/Pgsql.php#L177-L191
train
emmanix2002/dorcas-sdk-php
src/Sdk.php
Sdk.checkCredentials
private function checkCredentials(array $args = []): bool { if (empty($args['credentials'])) { throw new DorcasException('You did not provide the Dorcas client credentials in the configuration.', $args); } $id = data_get($args, 'credentials.id', null); $secret = data_get($args, 'credentials.secret', null); if (empty($id)) { throw new DorcasException('The client "id" key is absent in the credentials configuration.', $args); } if (empty($secret)) { throw new DorcasException('The client "secret" key is absent in the credentials configuration.', $args); } return true; }
php
private function checkCredentials(array $args = []): bool { if (empty($args['credentials'])) { throw new DorcasException('You did not provide the Dorcas client credentials in the configuration.', $args); } $id = data_get($args, 'credentials.id', null); $secret = data_get($args, 'credentials.secret', null); if (empty($id)) { throw new DorcasException('The client "id" key is absent in the credentials configuration.', $args); } if (empty($secret)) { throw new DorcasException('The client "secret" key is absent in the credentials configuration.', $args); } return true; }
[ "private", "function", "checkCredentials", "(", "array", "$", "args", "=", "[", "]", ")", ":", "bool", "{", "if", "(", "empty", "(", "$", "args", "[", "'credentials'", "]", ")", ")", "{", "throw", "new", "DorcasException", "(", "'You did not provide the Do...
Checks the credentials configuration to make sure it is valid. @param array $args @return bool @throws DorcasException
[ "Checks", "the", "credentials", "configuration", "to", "make", "sure", "it", "is", "valid", "." ]
1b68df62da1ed5f993f9e2687633402b96ab7f64
https://github.com/emmanix2002/dorcas-sdk-php/blob/1b68df62da1ed5f993f9e2687633402b96ab7f64/src/Sdk.php#L188-L202
train
emmanix2002/dorcas-sdk-php
src/Sdk.php
Sdk.createResourceClient
protected function createResourceClient(string $name, array $options = []): ResourceInterface { $entry = $this->manifest->getResource($name); # we check for the manifest entry if (empty($entry)) { throw new ResourceNotFoundException('Could not find the client for the requested resource '.$name); } $resource = $entry['namespace'] . '\\' . $entry['client']; return new $resource($this, ...$options); }
php
protected function createResourceClient(string $name, array $options = []): ResourceInterface { $entry = $this->manifest->getResource($name); # we check for the manifest entry if (empty($entry)) { throw new ResourceNotFoundException('Could not find the client for the requested resource '.$name); } $resource = $entry['namespace'] . '\\' . $entry['client']; return new $resource($this, ...$options); }
[ "protected", "function", "createResourceClient", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ResourceInterface", "{", "$", "entry", "=", "$", "this", "->", "manifest", "->", "getResource", "(", "$", "name", ")", ";...
Creates a new resource client with the provided options. @param string $name @param array $options @return ResourceInterface
[ "Creates", "a", "new", "resource", "client", "with", "the", "provided", "options", "." ]
1b68df62da1ed5f993f9e2687633402b96ab7f64
https://github.com/emmanix2002/dorcas-sdk-php/blob/1b68df62da1ed5f993f9e2687633402b96ab7f64/src/Sdk.php#L212-L222
train
emmanix2002/dorcas-sdk-php
src/Sdk.php
Sdk.createServiceClient
protected function createServiceClient(string $name, array $options = []): ServiceInterface { $entry = $this->manifest->getService($name); # we check for the manifest entry if (empty($entry)) { throw new ResourceNotFoundException('Could not find the client for the requested service '.$name); } $service = $entry['namespace'] . '\\' . $entry['client']; return new $service($this, $options); }
php
protected function createServiceClient(string $name, array $options = []): ServiceInterface { $entry = $this->manifest->getService($name); # we check for the manifest entry if (empty($entry)) { throw new ResourceNotFoundException('Could not find the client for the requested service '.$name); } $service = $entry['namespace'] . '\\' . $entry['client']; return new $service($this, $options); }
[ "protected", "function", "createServiceClient", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "ServiceInterface", "{", "$", "entry", "=", "$", "this", "->", "manifest", "->", "getService", "(", "$", "name", ")", ";", ...
Creates a new service client with the provided options. @param string $name @param array $options @return ServiceInterface
[ "Creates", "a", "new", "service", "client", "with", "the", "provided", "options", "." ]
1b68df62da1ed5f993f9e2687633402b96ab7f64
https://github.com/emmanix2002/dorcas-sdk-php/blob/1b68df62da1ed5f993f9e2687633402b96ab7f64/src/Sdk.php#L232-L241
train
as3io/modlr-api-jsonapiorg
src/Normalizer.php
Normalizer.extractAttributes
protected function extractAttributes(array $data, EntityMetadata $metadata) { $flattened = []; if (!isset($data['attributes']) || !is_array($data['attributes'])) { return $data['attributes'] = []; } $keyMap = array_flip(array_keys($data['attributes'])); foreach ($metadata->getProperties() as $key => $propMeta) { if (!isset($keyMap[$key])) { continue; } if (true === $metadata->hasAttribute($key) || true === $metadata->hasEmbed($key)) { $flattened[$key] = $data['attributes'][$key]; } } return $flattened; }
php
protected function extractAttributes(array $data, EntityMetadata $metadata) { $flattened = []; if (!isset($data['attributes']) || !is_array($data['attributes'])) { return $data['attributes'] = []; } $keyMap = array_flip(array_keys($data['attributes'])); foreach ($metadata->getProperties() as $key => $propMeta) { if (!isset($keyMap[$key])) { continue; } if (true === $metadata->hasAttribute($key) || true === $metadata->hasEmbed($key)) { $flattened[$key] = $data['attributes'][$key]; } } return $flattened; }
[ "protected", "function", "extractAttributes", "(", "array", "$", "data", ",", "EntityMetadata", "$", "metadata", ")", "{", "$", "flattened", "=", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "'attributes'", "]", ")", "||", "!", "is_ar...
Extracts the model's attributes, per JSON API spec. @param array $data @param EntityMetadata $metadata @return array
[ "Extracts", "the", "model", "s", "attributes", "per", "JSON", "API", "spec", "." ]
f53163c315a6a7be09e514a4c81af24aa665634b
https://github.com/as3io/modlr-api-jsonapiorg/blob/f53163c315a6a7be09e514a4c81af24aa665634b/src/Normalizer.php#L57-L74
train
as3io/modlr-api-jsonapiorg
src/Normalizer.php
Normalizer.extractRelationships
protected function extractRelationships(array $data, EntityMetadata $metadata) { $flattened = []; if (!isset($data['relationships']) || !is_array($data['relationships'])) { return $flattened; } foreach ($metadata->getRelationships() as $key => $relMeta) { if (!isset($data['relationships'][$key])) { continue; } $rel = $data['relationships'][$key]; // Need to use array_key_exists over isset because 'null' is valid. Creating a key map for each relationship is too costly since every relationship needs the data check. if (false === array_key_exists('data', $rel)) { throw NormalizerException::badRequest(sprintf('The "data" member was missing from the payload for relationship "%s"', $key)); } if (empty($rel['data'])) { $flattened[$key] = $relMeta->isOne() ? null : []; continue; } if (!is_array($rel['data'])) { throw NormalizerException::badRequest(sprintf('The "data" member is not valid in the payload for relationship "%s"', $key)); } if (true === $relMeta->isOne() && true === $this->isSequentialArray($rel['data'])) { throw NormalizerException::badRequest(sprintf('The data payload for relationship "%s" is malformed. Data types of "one" must be an associative array, sequential found.', $key)); } if (true === $relMeta->isMany() && false === $this->isSequentialArray($rel['data'])) { throw NormalizerException::badRequest(sprintf('The data payload for relationship "%s" is malformed. Data types of "many" must be a sequential array, associative found.', $key)); } $flattened[$key] = $rel['data']; } return $flattened; }
php
protected function extractRelationships(array $data, EntityMetadata $metadata) { $flattened = []; if (!isset($data['relationships']) || !is_array($data['relationships'])) { return $flattened; } foreach ($metadata->getRelationships() as $key => $relMeta) { if (!isset($data['relationships'][$key])) { continue; } $rel = $data['relationships'][$key]; // Need to use array_key_exists over isset because 'null' is valid. Creating a key map for each relationship is too costly since every relationship needs the data check. if (false === array_key_exists('data', $rel)) { throw NormalizerException::badRequest(sprintf('The "data" member was missing from the payload for relationship "%s"', $key)); } if (empty($rel['data'])) { $flattened[$key] = $relMeta->isOne() ? null : []; continue; } if (!is_array($rel['data'])) { throw NormalizerException::badRequest(sprintf('The "data" member is not valid in the payload for relationship "%s"', $key)); } if (true === $relMeta->isOne() && true === $this->isSequentialArray($rel['data'])) { throw NormalizerException::badRequest(sprintf('The data payload for relationship "%s" is malformed. Data types of "one" must be an associative array, sequential found.', $key)); } if (true === $relMeta->isMany() && false === $this->isSequentialArray($rel['data'])) { throw NormalizerException::badRequest(sprintf('The data payload for relationship "%s" is malformed. Data types of "many" must be a sequential array, associative found.', $key)); } $flattened[$key] = $rel['data']; } return $flattened; }
[ "protected", "function", "extractRelationships", "(", "array", "$", "data", ",", "EntityMetadata", "$", "metadata", ")", "{", "$", "flattened", "=", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "'relationships'", "]", ")", "||", "!", ...
Extracts the model's relationships, per JSON API spec. @param array $data @param EntityMetadata $metadata @return array
[ "Extracts", "the", "model", "s", "relationships", "per", "JSON", "API", "spec", "." ]
f53163c315a6a7be09e514a4c81af24aa665634b
https://github.com/as3io/modlr-api-jsonapiorg/blob/f53163c315a6a7be09e514a4c81af24aa665634b/src/Normalizer.php#L83-L118
train
tasoftch/skyline-translation
src/TranslationManager.php
TranslationManager.setClientLocales
public function setClientLocales($clientLocales): void { if(!$this->clientLocales) $this->clientLocales = new LocaleCollection(); $this->clientLocales->removeAllLocales(); foreach ($clientLocales as $locale) { if(is_string($locale)) { $locale = new Locale($locale); } if($locale instanceof Locale) { $this->clientLocales->addLocale($locale); } } }
php
public function setClientLocales($clientLocales): void { if(!$this->clientLocales) $this->clientLocales = new LocaleCollection(); $this->clientLocales->removeAllLocales(); foreach ($clientLocales as $locale) { if(is_string($locale)) { $locale = new Locale($locale); } if($locale instanceof Locale) { $this->clientLocales->addLocale($locale); } } }
[ "public", "function", "setClientLocales", "(", "$", "clientLocales", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "clientLocales", ")", "$", "this", "->", "clientLocales", "=", "new", "LocaleCollection", "(", ")", ";", "$", "this", "->", "cl...
Sets the client locales. You may pass Locale objects or string values. @param \Traversable|array $clientLocales @throws BadLocaleException
[ "Sets", "the", "client", "locales", ".", "You", "may", "pass", "Locale", "objects", "or", "string", "values", "." ]
fce37d7298f8bd880d11c73e7ecf145600668bc5
https://github.com/tasoftch/skyline-translation/blob/fce37d7298f8bd880d11c73e7ecf145600668bc5/src/TranslationManager.php#L93-L109
train
tasoftch/skyline-translation
src/TranslationManager.php
TranslationManager.readClientLocalesFromRequest
public function readClientLocalesFromRequest(Request $request) { $locales = []; foreach($request->getLanguages() as $client) { try { $locale = new Locale($client); $locales[] = $locale; } catch(\Exception $e) { trigger_error($e->getMessage(), E_USER_NOTICE); } } $this->setClientLocales($locales); }
php
public function readClientLocalesFromRequest(Request $request) { $locales = []; foreach($request->getLanguages() as $client) { try { $locale = new Locale($client); $locales[] = $locale; } catch(\Exception $e) { trigger_error($e->getMessage(), E_USER_NOTICE); } } $this->setClientLocales($locales); }
[ "public", "function", "readClientLocalesFromRequest", "(", "Request", "$", "request", ")", "{", "$", "locales", "=", "[", "]", ";", "foreach", "(", "$", "request", "->", "getLanguages", "(", ")", "as", "$", "client", ")", "{", "try", "{", "$", "locale", ...
Reads the client locales from the request @param Request $request @throws BadLocaleException
[ "Reads", "the", "client", "locales", "from", "the", "request" ]
fce37d7298f8bd880d11c73e7ecf145600668bc5
https://github.com/tasoftch/skyline-translation/blob/fce37d7298f8bd880d11c73e7ecf145600668bc5/src/TranslationManager.php#L116-L129
train
tasoftch/skyline-translation
src/TranslationManager.php
TranslationManager.getServerLocales
public function getServerLocales() { if(!isset($this->serverLocales)) { $this->serverLocales = new LocaleCollection(); foreach($this->supportedLocaleStrings as $server) { try { $locale = new Locale($server); $this->serverLocales->addLocale( $locale ); } catch(\Exception $e) { trigger_error($e->getMessage(), E_USER_NOTICE); } } } return $this->serverLocales->getLocales(); }
php
public function getServerLocales() { if(!isset($this->serverLocales)) { $this->serverLocales = new LocaleCollection(); foreach($this->supportedLocaleStrings as $server) { try { $locale = new Locale($server); $this->serverLocales->addLocale( $locale ); } catch(\Exception $e) { trigger_error($e->getMessage(), E_USER_NOTICE); } } } return $this->serverLocales->getLocales(); }
[ "public", "function", "getServerLocales", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "serverLocales", ")", ")", "{", "$", "this", "->", "serverLocales", "=", "new", "LocaleCollection", "(", ")", ";", "foreach", "(", "$", "this", "-...
Returns all possible locales the server can deliver the render result @return array
[ "Returns", "all", "possible", "locales", "the", "server", "can", "deliver", "the", "render", "result" ]
fce37d7298f8bd880d11c73e7ecf145600668bc5
https://github.com/tasoftch/skyline-translation/blob/fce37d7298f8bd880d11c73e7ecf145600668bc5/src/TranslationManager.php#L135-L148
train
tasoftch/skyline-translation
src/TranslationManager.php
TranslationManager.getBestRenderLocales
public function getBestRenderLocales($ordered = self::ORDER_LANG) { $locales = []; $this->getServerLocales(); foreach($this->getClientLocales() as $locale) { /** @var Locale $locale */ $loc = $this->serverLocales->getBestMatchingLocaleForLocale($locale); if($loc && !in_array($loc, $locales)) { $locales[] = $loc; } } if(count($locales) == 0) { if($this->defaultLocale) $locales[] = $this->defaultLocale; else { $locales[] = $this->getServerLocales()[0] ?? NULL; } } if($ordered & self::ORDER_STRUCT) { $locs = []; foreach($locales as $loc) { /** @var Locale $loc */ $lang = $loc->getLanguage(); $locs[$lang][] = $loc; } if($ordered & self::ORDER_LANG) { foreach($locs as &$ll) usort($ll, LocaleCollection::LANG_SORT_CALLBACK); } elseif($ordered & self::ORDER_REG) { foreach($locs as &$ll) usort($ll, LocaleCollection::REG_SORT_CALLBACK); } return $locs; } return $locales; }
php
public function getBestRenderLocales($ordered = self::ORDER_LANG) { $locales = []; $this->getServerLocales(); foreach($this->getClientLocales() as $locale) { /** @var Locale $locale */ $loc = $this->serverLocales->getBestMatchingLocaleForLocale($locale); if($loc && !in_array($loc, $locales)) { $locales[] = $loc; } } if(count($locales) == 0) { if($this->defaultLocale) $locales[] = $this->defaultLocale; else { $locales[] = $this->getServerLocales()[0] ?? NULL; } } if($ordered & self::ORDER_STRUCT) { $locs = []; foreach($locales as $loc) { /** @var Locale $loc */ $lang = $loc->getLanguage(); $locs[$lang][] = $loc; } if($ordered & self::ORDER_LANG) { foreach($locs as &$ll) usort($ll, LocaleCollection::LANG_SORT_CALLBACK); } elseif($ordered & self::ORDER_REG) { foreach($locs as &$ll) usort($ll, LocaleCollection::REG_SORT_CALLBACK); } return $locs; } return $locales; }
[ "public", "function", "getBestRenderLocales", "(", "$", "ordered", "=", "self", "::", "ORDER_LANG", ")", "{", "$", "locales", "=", "[", "]", ";", "$", "this", "->", "getServerLocales", "(", ")", ";", "foreach", "(", "$", "this", "->", "getClientLocales", ...
Tries to figure out which locales matching the desired language and the provided language. If no matches can be found, the default CMS language will be served. @param int $ordered @return array
[ "Tries", "to", "figure", "out", "which", "locales", "matching", "the", "desired", "language", "and", "the", "provided", "language", ".", "If", "no", "matches", "can", "be", "found", "the", "default", "CMS", "language", "will", "be", "served", "." ]
fce37d7298f8bd880d11c73e7ecf145600668bc5
https://github.com/tasoftch/skyline-translation/blob/fce37d7298f8bd880d11c73e7ecf145600668bc5/src/TranslationManager.php#L156-L197
train
avoo/FrameworkInstallerBundle
Composer/ScriptHandler.php
ScriptHandler.installAvooDemoBundle
public static function installAvooDemoBundle(InputInterface $input, OutputInterface $output, QuestionHelper $helper) { $rootDir = getcwd(); if (file_exists($rootDir.'/src/Avoo/DemoBundle')) { return; } if (!getenv('AVOO_DEMO')) { $question = new ConfirmationQuestion('Would you like to install Avoo Demo bundle? [y/n] ', true); if (!$helper->ask($input, $output, $question)) { return; } } $output->writeln('<info>Installing the Avoo Demo bundle.</info>'); $output->writeln(''); $kernelFile = $rootDir . '/app/AppKernel.php'; $configFile = $rootDir . '/app/config/config_dev.yml'; $fileSystem = new Filesystem(); $fileSystem->mirror(__DIR__.'/../Resources/skeleton/avoo-demo-bundle', $rootDir . '/src', null, array('override' => true)); $ref = '$bundles[] = new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();'; $bundleDeclaration = "\$bundles[] = new \\Avoo\\DemoBundle\\AvooDemoBundle();"; $content = file_get_contents($kernelFile); if (false === strpos($content, $bundleDeclaration)) { $updatedContent = str_replace($ref, $bundleDeclaration."\n ".$ref, $content); if ($content === $updatedContent) { throw new \RuntimeException('Unable to patch %s.', $kernelFile); } $fileSystem->dumpFile($kernelFile, $updatedContent); } $ref = '- { resource: config.yml }'; $configDeclaration = '- { resource: @AvooDemoBundle/Resources/config/config.yml }'; $content = file_get_contents($configFile); if (false === strpos($content, $bundleDeclaration)) { $updatedContent = str_replace($ref, $ref . "\n " . $configDeclaration, $content); if ($content === $updatedContent) { throw new \RuntimeException('Unable to patch %s.', $kernelFile); } $fileSystem->dumpFile($configFile, $updatedContent); } self::patchAvooDemoBundleConfiguration($rootDir, $fileSystem); }
php
public static function installAvooDemoBundle(InputInterface $input, OutputInterface $output, QuestionHelper $helper) { $rootDir = getcwd(); if (file_exists($rootDir.'/src/Avoo/DemoBundle')) { return; } if (!getenv('AVOO_DEMO')) { $question = new ConfirmationQuestion('Would you like to install Avoo Demo bundle? [y/n] ', true); if (!$helper->ask($input, $output, $question)) { return; } } $output->writeln('<info>Installing the Avoo Demo bundle.</info>'); $output->writeln(''); $kernelFile = $rootDir . '/app/AppKernel.php'; $configFile = $rootDir . '/app/config/config_dev.yml'; $fileSystem = new Filesystem(); $fileSystem->mirror(__DIR__.'/../Resources/skeleton/avoo-demo-bundle', $rootDir . '/src', null, array('override' => true)); $ref = '$bundles[] = new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();'; $bundleDeclaration = "\$bundles[] = new \\Avoo\\DemoBundle\\AvooDemoBundle();"; $content = file_get_contents($kernelFile); if (false === strpos($content, $bundleDeclaration)) { $updatedContent = str_replace($ref, $bundleDeclaration."\n ".$ref, $content); if ($content === $updatedContent) { throw new \RuntimeException('Unable to patch %s.', $kernelFile); } $fileSystem->dumpFile($kernelFile, $updatedContent); } $ref = '- { resource: config.yml }'; $configDeclaration = '- { resource: @AvooDemoBundle/Resources/config/config.yml }'; $content = file_get_contents($configFile); if (false === strpos($content, $bundleDeclaration)) { $updatedContent = str_replace($ref, $ref . "\n " . $configDeclaration, $content); if ($content === $updatedContent) { throw new \RuntimeException('Unable to patch %s.', $kernelFile); } $fileSystem->dumpFile($configFile, $updatedContent); } self::patchAvooDemoBundleConfiguration($rootDir, $fileSystem); }
[ "public", "static", "function", "installAvooDemoBundle", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ",", "QuestionHelper", "$", "helper", ")", "{", "$", "rootDir", "=", "getcwd", "(", ")", ";", "if", "(", "file_exists", "(", ...
Avoo demo bundle install @param InputInterface $input @param OutputInterface $output @param QuestionHelper $helper
[ "Avoo", "demo", "bundle", "install" ]
402032e01467359b176de19731ebbff744cc52f5
https://github.com/avoo/FrameworkInstallerBundle/blob/402032e01467359b176de19731ebbff744cc52f5/Composer/ScriptHandler.php#L28-L78
train
avoo/FrameworkInstallerBundle
Composer/ScriptHandler.php
ScriptHandler.getApplicationName
private static function getApplicationName(InputInterface $input, OutputInterface $output, QuestionHelper $helper) { $question = new Question('Choose your application name: '); $question->setValidator(function($answer) { if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $answer)) { throw new \InvalidArgumentException('The application name contains invalid characters.'); } return ucfirst(strtolower($answer)); }); return $helper->ask($input, $output, $question); }
php
private static function getApplicationName(InputInterface $input, OutputInterface $output, QuestionHelper $helper) { $question = new Question('Choose your application name: '); $question->setValidator(function($answer) { if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $answer)) { throw new \InvalidArgumentException('The application name contains invalid characters.'); } return ucfirst(strtolower($answer)); }); return $helper->ask($input, $output, $question); }
[ "private", "static", "function", "getApplicationName", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ",", "QuestionHelper", "$", "helper", ")", "{", "$", "question", "=", "new", "Question", "(", "'Choose your application name: '", ")", ...
Get application name @param InputInterface $input @param OutputInterface $output @param QuestionHelper $helper @return string
[ "Get", "application", "name" ]
402032e01467359b176de19731ebbff744cc52f5
https://github.com/avoo/FrameworkInstallerBundle/blob/402032e01467359b176de19731ebbff744cc52f5/Composer/ScriptHandler.php#L248-L260
train
avoo/FrameworkInstallerBundle
Composer/ScriptHandler.php
ScriptHandler.buildCoreFiles
private static function buildCoreFiles($bundleDir, $applicationName, Filesystem $filesystem) { $filesystem->setParameters(array( 'namespace' => $applicationName . '\\Bundle\\CoreBundle', 'applicationName' => $applicationName, 'rename' => array( 'Bundle.php.twig' => $applicationName . 'CoreBundle.php', 'Extension.php.twig' => $applicationName . 'CoreExtension.php', 'app.yml.twig' => strtolower($applicationName) . '.yml', ) )); $filesystem->mirror(__DIR__.'/../Resources/skeleton/avoo-core-bundle', $bundleDir, null, array('override' => true)); }
php
private static function buildCoreFiles($bundleDir, $applicationName, Filesystem $filesystem) { $filesystem->setParameters(array( 'namespace' => $applicationName . '\\Bundle\\CoreBundle', 'applicationName' => $applicationName, 'rename' => array( 'Bundle.php.twig' => $applicationName . 'CoreBundle.php', 'Extension.php.twig' => $applicationName . 'CoreExtension.php', 'app.yml.twig' => strtolower($applicationName) . '.yml', ) )); $filesystem->mirror(__DIR__.'/../Resources/skeleton/avoo-core-bundle', $bundleDir, null, array('override' => true)); }
[ "private", "static", "function", "buildCoreFiles", "(", "$", "bundleDir", ",", "$", "applicationName", ",", "Filesystem", "$", "filesystem", ")", "{", "$", "filesystem", "->", "setParameters", "(", "array", "(", "'namespace'", "=>", "$", "applicationName", ".", ...
Build core files @param string $bundleDir @param string $applicationName @param Filesystem $filesystem
[ "Build", "core", "files" ]
402032e01467359b176de19731ebbff744cc52f5
https://github.com/avoo/FrameworkInstallerBundle/blob/402032e01467359b176de19731ebbff744cc52f5/Composer/ScriptHandler.php#L269-L282
train
avoo/FrameworkInstallerBundle
Composer/ScriptHandler.php
ScriptHandler.buildComponentFiles
private static function buildComponentFiles($bundleDir, $applicationName, Filesystem $filesystem) { $filesystem->setParameters(array( 'namespace' => $applicationName, 'applicationName' => $applicationName, )); $filesystem->mirror(__DIR__.'/../Resources/skeleton/avoo-component', $bundleDir, null, array('override' => true)); }
php
private static function buildComponentFiles($bundleDir, $applicationName, Filesystem $filesystem) { $filesystem->setParameters(array( 'namespace' => $applicationName, 'applicationName' => $applicationName, )); $filesystem->mirror(__DIR__.'/../Resources/skeleton/avoo-component', $bundleDir, null, array('override' => true)); }
[ "private", "static", "function", "buildComponentFiles", "(", "$", "bundleDir", ",", "$", "applicationName", ",", "Filesystem", "$", "filesystem", ")", "{", "$", "filesystem", "->", "setParameters", "(", "array", "(", "'namespace'", "=>", "$", "applicationName", ...
Build component files @param string $bundleDir @param string $applicationName @param Filesystem $filesystem
[ "Build", "component", "files" ]
402032e01467359b176de19731ebbff744cc52f5
https://github.com/avoo/FrameworkInstallerBundle/blob/402032e01467359b176de19731ebbff744cc52f5/Composer/ScriptHandler.php#L334-L342
train
binsoul/net-http-message-message
src/Request.php
Request.buildHost
private function buildHost(UriInterface $uri): string { return $uri->getHost().($uri->getPort() !== null ? ':'.$uri->getPort() : ''); }
php
private function buildHost(UriInterface $uri): string { return $uri->getHost().($uri->getPort() !== null ? ':'.$uri->getPort() : ''); }
[ "private", "function", "buildHost", "(", "UriInterface", "$", "uri", ")", ":", "string", "{", "return", "$", "uri", "->", "getHost", "(", ")", ".", "(", "$", "uri", "->", "getPort", "(", ")", "!==", "null", "?", "':'", ".", "$", "uri", "->", "getPo...
Returns the host header. @param UriInterface $uri @return string
[ "Returns", "the", "host", "header", "." ]
b367ecdfda28570f849fc7e0723125a951d915a7
https://github.com/binsoul/net-http-message-message/blob/b367ecdfda28570f849fc7e0723125a951d915a7/src/Request.php#L121-L124
train
getconnect/connect-php
src/Security.php
Security.generateFilteredKey
public static function generateFilteredKey($definition, $masterKey) { $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); $ivSize = mcrypt_enc_get_iv_size($cipher); $iv = mcrypt_create_iv($ivSize, MCRYPT_RAND); $definitionWithPading = self::_pad(json_encode($definition),16); if (mcrypt_generic_init($cipher, $masterKey, $iv) != -1) { $cipherText = mcrypt_generic($cipher,$definitionWithPading); mcrypt_generic_deinit($cipher); $encrypted = sprintf("%s-%s",bin2hex($iv),bin2hex($cipherText)); return $encrypted; } }
php
public static function generateFilteredKey($definition, $masterKey) { $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); $ivSize = mcrypt_enc_get_iv_size($cipher); $iv = mcrypt_create_iv($ivSize, MCRYPT_RAND); $definitionWithPading = self::_pad(json_encode($definition),16); if (mcrypt_generic_init($cipher, $masterKey, $iv) != -1) { $cipherText = mcrypt_generic($cipher,$definitionWithPading); mcrypt_generic_deinit($cipher); $encrypted = sprintf("%s-%s",bin2hex($iv),bin2hex($cipherText)); return $encrypted; } }
[ "public", "static", "function", "generateFilteredKey", "(", "$", "definition", ",", "$", "masterKey", ")", "{", "$", "cipher", "=", "mcrypt_module_open", "(", "MCRYPT_RIJNDAEL_128", ",", "''", ",", "MCRYPT_MODE_CBC", ",", "''", ")", ";", "$", "ivSize", "=", ...
Encrypt filtered key for use with the Connect API @param array $definition The filtered key definition @param string $masterKey The master key for the Connect project @return String
[ "Encrypt", "filtered", "key", "for", "use", "with", "the", "Connect", "API" ]
cbce3daae58eca16450df811ac6f1280fc1ef6b1
https://github.com/getconnect/connect-php/blob/cbce3daae58eca16450df811ac6f1280fc1ef6b1/src/Security.php#L15-L29
train
getconnect/connect-php
src/Security.php
Security.decryptFilteredKey
public static function decryptFilteredKey($encryptedKey, $masterKey){ $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); $ivAndFilter = explode('-',$encryptedKey); $iv = hex2bin($ivAndFilter[0]); $filter = hex2bin($ivAndFilter[1]); if (mcrypt_generic_init($cipher, $masterKey, $iv) != -1) { $decrypted = mdecrypt_generic($cipher, $filter); mcrypt_generic_deinit($cipher); mcrypt_module_close($cipher); $decryptedNoPadding = self::_unpad($decrypted,16); return $decryptedNoPadding; } }
php
public static function decryptFilteredKey($encryptedKey, $masterKey){ $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, ''); $ivAndFilter = explode('-',$encryptedKey); $iv = hex2bin($ivAndFilter[0]); $filter = hex2bin($ivAndFilter[1]); if (mcrypt_generic_init($cipher, $masterKey, $iv) != -1) { $decrypted = mdecrypt_generic($cipher, $filter); mcrypt_generic_deinit($cipher); mcrypt_module_close($cipher); $decryptedNoPadding = self::_unpad($decrypted,16); return $decryptedNoPadding; } }
[ "public", "static", "function", "decryptFilteredKey", "(", "$", "encryptedKey", ",", "$", "masterKey", ")", "{", "$", "cipher", "=", "mcrypt_module_open", "(", "MCRYPT_RIJNDAEL_128", ",", "''", ",", "MCRYPT_MODE_CBC", ",", "''", ")", ";", "$", "ivAndFilter", "...
Decrypt filtered key generated via the encryptFukteredKey function @param array $definition The filtered key definition @param string $masterKey The master key for the Connect project @return String
[ "Decrypt", "filtered", "key", "generated", "via", "the", "encryptFukteredKey", "function" ]
cbce3daae58eca16450df811ac6f1280fc1ef6b1
https://github.com/getconnect/connect-php/blob/cbce3daae58eca16450df811ac6f1280fc1ef6b1/src/Security.php#L37-L52
train
getconnect/connect-php
src/Security.php
Security._pad
private static function _pad($text, $blocksize) { $pad = $blocksize - (strlen($text) % $blocksize); $textWithPadding = $text . str_repeat(chr($pad), $pad); return $textWithPadding; }
php
private static function _pad($text, $blocksize) { $pad = $blocksize - (strlen($text) % $blocksize); $textWithPadding = $text . str_repeat(chr($pad), $pad); return $textWithPadding; }
[ "private", "static", "function", "_pad", "(", "$", "text", ",", "$", "blocksize", ")", "{", "$", "pad", "=", "$", "blocksize", "-", "(", "strlen", "(", "$", "text", ")", "%", "$", "blocksize", ")", ";", "$", "textWithPadding", "=", "$", "text", "."...
Pad an input string for encryption @text string the string to add padding to @blocksize int
[ "Pad", "an", "input", "string", "for", "encryption" ]
cbce3daae58eca16450df811ac6f1280fc1ef6b1
https://github.com/getconnect/connect-php/blob/cbce3daae58eca16450df811ac6f1280fc1ef6b1/src/Security.php#L59-L63
train
getconnect/connect-php
src/Security.php
Security._unpad
private static function _unpad($text, $blocksize) { if (empty($text)) { return ''; } if (strlen($text) % $blocksize !== 0) { return false; } $pad = ord($text{strlen($text)-1}); if ($pad > $blocksize || $pad > strlen($text) || $pad === 0) { return false; } if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) { return false; } $textNoPadding = substr($text, 0, - $pad); return $textNoPadding; }
php
private static function _unpad($text, $blocksize) { if (empty($text)) { return ''; } if (strlen($text) % $blocksize !== 0) { return false; } $pad = ord($text{strlen($text)-1}); if ($pad > $blocksize || $pad > strlen($text) || $pad === 0) { return false; } if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) { return false; } $textNoPadding = substr($text, 0, - $pad); return $textNoPadding; }
[ "private", "static", "function", "_unpad", "(", "$", "text", ",", "$", "blocksize", ")", "{", "if", "(", "empty", "(", "$", "text", ")", ")", "{", "return", "''", ";", "}", "if", "(", "strlen", "(", "$", "text", ")", "%", "$", "blocksize", "!==",...
Unpad an input string @text string the string to add padding to @blocksize int
[ "Unpad", "an", "input", "string" ]
cbce3daae58eca16450df811ac6f1280fc1ef6b1
https://github.com/getconnect/connect-php/blob/cbce3daae58eca16450df811ac6f1280fc1ef6b1/src/Security.php#L70-L86
train
interactivesolutions/honeycomb-acl
src/app/http/controllers/UserActivation.php
UserActivation.sendActivationMail
public function sendActivationMail($user) { if( ! $this->shouldSend($user) ) { return trans('HCACL::users.activation.check_email'); } \DB::beginTransaction(); try { $token = $this->createActivation($user); $user->sendActivationLinkNotification($token); } catch ( \Exception $e ) { \DB::rollback(); throw new \Exception('Activation code or mail sending failed'); } \DB::commit(); return trans('HCACL::users.activation.resent_activation'); }
php
public function sendActivationMail($user) { if( ! $this->shouldSend($user) ) { return trans('HCACL::users.activation.check_email'); } \DB::beginTransaction(); try { $token = $this->createActivation($user); $user->sendActivationLinkNotification($token); } catch ( \Exception $e ) { \DB::rollback(); throw new \Exception('Activation code or mail sending failed'); } \DB::commit(); return trans('HCACL::users.activation.resent_activation'); }
[ "public", "function", "sendActivationMail", "(", "$", "user", ")", "{", "if", "(", "!", "$", "this", "->", "shouldSend", "(", "$", "user", ")", ")", "{", "return", "trans", "(", "'HCACL::users.activation.check_email'", ")", ";", "}", "\\", "DB", "::", "b...
Send activation mail @param $user @return array @throws \Exception
[ "Send", "activation", "mail" ]
6c73d7d1c5d17ef730593e03386236a746bab12c
https://github.com/interactivesolutions/honeycomb-acl/blob/6c73d7d1c5d17ef730593e03386236a746bab12c/src/app/http/controllers/UserActivation.php#L40-L61
train
interactivesolutions/honeycomb-acl
src/app/http/controllers/UserActivation.php
UserActivation.shouldSend
protected function shouldSend($user) { $activation = $this->getActivation($user); return $activation === null || strtotime($activation->created_at) + 60 * 60 * $this->resendAfter < time(); }
php
protected function shouldSend($user) { $activation = $this->getActivation($user); return $activation === null || strtotime($activation->created_at) + 60 * 60 * $this->resendAfter < time(); }
[ "protected", "function", "shouldSend", "(", "$", "user", ")", "{", "$", "activation", "=", "$", "this", "->", "getActivation", "(", "$", "user", ")", ";", "return", "$", "activation", "===", "null", "||", "strtotime", "(", "$", "activation", "->", "creat...
Check if activation mail should be resent @param $user @return bool
[ "Check", "if", "activation", "mail", "should", "be", "resent" ]
6c73d7d1c5d17ef730593e03386236a746bab12c
https://github.com/interactivesolutions/honeycomb-acl/blob/6c73d7d1c5d17ef730593e03386236a746bab12c/src/app/http/controllers/UserActivation.php#L99-L104
train
jmpantoja/planb-utils
src/Beautifier/Parser/AttributeList.php
AttributeList.parseValue
private function parseValue(string $key, $value): string { if (is_array($value)) { return $this->parseArray($key, $value); } return $this->parseScalar($key, $value); }
php
private function parseValue(string $key, $value): string { if (is_array($value)) { return $this->parseArray($key, $value); } return $this->parseScalar($key, $value); }
[ "private", "function", "parseValue", "(", "string", "$", "key", ",", "$", "value", ")", ":", "string", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "$", "this", "->", "parseArray", "(", "$", "key", ",", "$", "value", ")",...
Parsea un valor @param string $key @param mixed $value @return string
[ "Parsea", "un", "valor" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Parser/AttributeList.php#L121-L129
train
rafflesargentina/l5-action-based-form-request
src/Traits/WorksWithFormRequests.php
WorksWithFormRequests.getRules
public function getRules() { $action = $this->getActionReplaced(); if (method_exists($this->formRequest, $action)) { return call_user_func([$this->formRequest, $action]); } if (method_exists($this->formRequest, 'rules')) { return call_user_func([$this->formRequest, 'rules']); } return []; }
php
public function getRules() { $action = $this->getActionReplaced(); if (method_exists($this->formRequest, $action)) { return call_user_func([$this->formRequest, $action]); } if (method_exists($this->formRequest, 'rules')) { return call_user_func([$this->formRequest, 'rules']); } return []; }
[ "public", "function", "getRules", "(", ")", "{", "$", "action", "=", "$", "this", "->", "getActionReplaced", "(", ")", ";", "if", "(", "method_exists", "(", "$", "this", "->", "formRequest", ",", "$", "action", ")", ")", "{", "return", "call_user_func", ...
Get rules from ActionBasedFormRequest or FormRequest instance. @return array
[ "Get", "rules", "from", "ActionBasedFormRequest", "or", "FormRequest", "instance", "." ]
dc39cc93d506763fa9714754c9700862bfeca5a7
https://github.com/rafflesargentina/l5-action-based-form-request/blob/dc39cc93d506763fa9714754c9700862bfeca5a7/src/Traits/WorksWithFormRequests.php#L15-L27
train
rafflesargentina/l5-action-based-form-request
src/Traits/WorksWithFormRequests.php
WorksWithFormRequests.getRequiredFields
public function getRequiredFields() { $rules = $this->getRules(); $requiredFields = array_where( $rules, function ($value, $key) { if (is_array($value)) { $value = implode('|', $value); } return str_contains($value, ['required', 'sometimes']); } ); return $requiredFields; }
php
public function getRequiredFields() { $rules = $this->getRules(); $requiredFields = array_where( $rules, function ($value, $key) { if (is_array($value)) { $value = implode('|', $value); } return str_contains($value, ['required', 'sometimes']); } ); return $requiredFields; }
[ "public", "function", "getRequiredFields", "(", ")", "{", "$", "rules", "=", "$", "this", "->", "getRules", "(", ")", ";", "$", "requiredFields", "=", "array_where", "(", "$", "rules", ",", "function", "(", "$", "value", ",", "$", "key", ")", "{", "i...
Get required fields. @return array
[ "Get", "required", "fields", "." ]
dc39cc93d506763fa9714754c9700862bfeca5a7
https://github.com/rafflesargentina/l5-action-based-form-request/blob/dc39cc93d506763fa9714754c9700862bfeca5a7/src/Traits/WorksWithFormRequests.php#L44-L59
train
e-commerce-passaro/produto
src/Produto/Repository.php
Repository.getTableGateway
private function getTableGateway() { return new TableGateway($this->tableName, $this->dbAdapter, null, new HydratingResultSet($this->hydrator, $this->prototipo)); }
php
private function getTableGateway() { return new TableGateway($this->tableName, $this->dbAdapter, null, new HydratingResultSet($this->hydrator, $this->prototipo)); }
[ "private", "function", "getTableGateway", "(", ")", "{", "return", "new", "TableGateway", "(", "$", "this", "->", "tableName", ",", "$", "this", "->", "dbAdapter", ",", "null", ",", "new", "HydratingResultSet", "(", "$", "this", "->", "hydrator", ",", "$",...
Obtem o TableGatwey @return \Zend\Db\TableGateway\TableGateway
[ "Obtem", "o", "TableGatwey" ]
31cb790173485c37db8de9a2cc5cfaeb827250aa
https://github.com/e-commerce-passaro/produto/blob/31cb790173485c37db8de9a2cc5cfaeb827250aa/src/Produto/Repository.php#L37-L40
train
johanderuijter/mailer-swift-mailer-bridge
src/SwiftMailer.php
SwiftMailer.sendEmail
public function sendEmail(EmailType $type) { $builder = $this->builder; $type->buildEmail($builder); $email = $builder->build(new SwiftEmail()); $this->mailer->send($email->getMessage()); }
php
public function sendEmail(EmailType $type) { $builder = $this->builder; $type->buildEmail($builder); $email = $builder->build(new SwiftEmail()); $this->mailer->send($email->getMessage()); }
[ "public", "function", "sendEmail", "(", "EmailType", "$", "type", ")", "{", "$", "builder", "=", "$", "this", "->", "builder", ";", "$", "type", "->", "buildEmail", "(", "$", "builder", ")", ";", "$", "email", "=", "$", "builder", "->", "build", "(",...
Build and send a given type of email. @param EmailType $type
[ "Build", "and", "send", "a", "given", "type", "of", "email", "." ]
be7acf4b6f3f2e448546835038f98fdef9fc2889
https://github.com/johanderuijter/mailer-swift-mailer-bridge/blob/be7acf4b6f3f2e448546835038f98fdef9fc2889/src/SwiftMailer.php#L40-L47
train
DavidFricker/DataAbstracter
src/Adapter/MySQLDatabaseWrapper.php
MySQLDatabaseWrapper.run
public function run ($query, $bind=[]) { try { $this->handle = $this->prepare($query); $this->handle->execute($bind); // check what the query begins with if (preg_match('/^(select|describe|pragma)/i', $query)) { // return a result set return $this->handle->fetchAll(); } if (preg_match('/^(delete|insert|update)/i', $query)) { // return the affected row count return $this->rowCount(); } // default to simply indicating success return true; } catch (\PDOException $e) { $this->error = $e->getMessage(); return false; } }
php
public function run ($query, $bind=[]) { try { $this->handle = $this->prepare($query); $this->handle->execute($bind); // check what the query begins with if (preg_match('/^(select|describe|pragma)/i', $query)) { // return a result set return $this->handle->fetchAll(); } if (preg_match('/^(delete|insert|update)/i', $query)) { // return the affected row count return $this->rowCount(); } // default to simply indicating success return true; } catch (\PDOException $e) { $this->error = $e->getMessage(); return false; } }
[ "public", "function", "run", "(", "$", "query", ",", "$", "bind", "=", "[", "]", ")", "{", "try", "{", "$", "this", "->", "handle", "=", "$", "this", "->", "prepare", "(", "$", "query", ")", ";", "$", "this", "->", "handle", "->", "execute", "(...
Execute any SQL query To ensure your query is safe from first order SQL injection attacks pass all values via the $bind array @param string $query MySQL query @param array $bind key:value pairs where the key is a bind identifier and value is to be inserted at that location @return mixed see example @example depending on the type of input query the returned result can be an affected row count or a result set, the type of which is specified in the options passed to the constructor, defaulting to an assoc array @example $query = 'SELECT * FROM table_name WHERE col_id = :BindColID'; $bind = [':BindColID' => 12];
[ "Execute", "any", "SQL", "query" ]
d612910cb114ddceb9f4ab1d152d5eb8019e5342
https://github.com/DavidFricker/DataAbstracter/blob/d612910cb114ddceb9f4ab1d152d5eb8019e5342/src/Adapter/MySQLDatabaseWrapper.php#L167-L189
train
padosoft/laravel-request
src/RequestHelper.php
RequestHelper.requestHasFiles
public static function requestHasFiles(Request $request) : bool { return ($request && $request->allFiles() && count($request->allFiles()) > 0); }
php
public static function requestHasFiles(Request $request) : bool { return ($request && $request->allFiles() && count($request->allFiles()) > 0); }
[ "public", "static", "function", "requestHasFiles", "(", "Request", "$", "request", ")", ":", "bool", "{", "return", "(", "$", "request", "&&", "$", "request", "->", "allFiles", "(", ")", "&&", "count", "(", "$", "request", "->", "allFiles", "(", ")", "...
Check if the passed request has at least one file @param Request $request @return bool
[ "Check", "if", "the", "passed", "request", "has", "at", "least", "one", "file" ]
8c4ea439db6ad2e7d28402b0f1e358d4df9c7768
https://github.com/padosoft/laravel-request/blob/8c4ea439db6ad2e7d28402b0f1e358d4df9c7768/src/RequestHelper.php#L28-L31
train
padosoft/laravel-request
src/RequestHelper.php
RequestHelper.isValidCurrentRequestUploadFile
public static function isValidCurrentRequestUploadFile(string $uploadField, array $arrMimeType = array()) : bool { return self::isValidUploadFile($uploadField, $arrMimeType, request()); }
php
public static function isValidCurrentRequestUploadFile(string $uploadField, array $arrMimeType = array()) : bool { return self::isValidUploadFile($uploadField, $arrMimeType, request()); }
[ "public", "static", "function", "isValidCurrentRequestUploadFile", "(", "string", "$", "uploadField", ",", "array", "$", "arrMimeType", "=", "array", "(", ")", ")", ":", "bool", "{", "return", "self", "::", "isValidUploadFile", "(", "$", "uploadField", ",", "$...
Check if uploaded File in current request is valid and has a valid Mime Type. Return true is all ok, otherwise return false. @param string $uploadField @param array $arrMimeType @return bool
[ "Check", "if", "uploaded", "File", "in", "current", "request", "is", "valid", "and", "has", "a", "valid", "Mime", "Type", ".", "Return", "true", "is", "all", "ok", "otherwise", "return", "false", "." ]
8c4ea439db6ad2e7d28402b0f1e358d4df9c7768
https://github.com/padosoft/laravel-request/blob/8c4ea439db6ad2e7d28402b0f1e358d4df9c7768/src/RequestHelper.php#L40-L43
train
padosoft/laravel-request
src/RequestHelper.php
RequestHelper.isValidUploadFile
public static function isValidUploadFile(string $uploadField, array $arrMimeType = array(), Request $request) : bool { $uploadedFile = self::getFileSafe($uploadField, $request); if (!is_a($uploadedFile, UploadedFile::class)) { return false; } return UploadedFileHelper::isValidUploadFile($uploadedFile, $arrMimeType); }
php
public static function isValidUploadFile(string $uploadField, array $arrMimeType = array(), Request $request) : bool { $uploadedFile = self::getFileSafe($uploadField, $request); if (!is_a($uploadedFile, UploadedFile::class)) { return false; } return UploadedFileHelper::isValidUploadFile($uploadedFile, $arrMimeType); }
[ "public", "static", "function", "isValidUploadFile", "(", "string", "$", "uploadField", ",", "array", "$", "arrMimeType", "=", "array", "(", ")", ",", "Request", "$", "request", ")", ":", "bool", "{", "$", "uploadedFile", "=", "self", "::", "getFileSafe", ...
Check if uploaded File is valid and has a valid Mime Type. Return true is all ok, otherwise return false. @param string $uploadField @param array $arrMimeType @param Request $request @return bool
[ "Check", "if", "uploaded", "File", "is", "valid", "and", "has", "a", "valid", "Mime", "Type", ".", "Return", "true", "is", "all", "ok", "otherwise", "return", "false", "." ]
8c4ea439db6ad2e7d28402b0f1e358d4df9c7768
https://github.com/padosoft/laravel-request/blob/8c4ea439db6ad2e7d28402b0f1e358d4df9c7768/src/RequestHelper.php#L53-L62
train
padosoft/laravel-request
src/RequestHelper.php
RequestHelper.getFileSafe
public static function getFileSafe( string $uploadField, Request $request ) { if (!$request) { return null; } $uploadedFile = $request->file($uploadField); //check type because request file method, may returns UploadedFile, array or null if (!is_a($uploadedFile, UploadedFile::class)) { return null; } return $uploadedFile; }
php
public static function getFileSafe( string $uploadField, Request $request ) { if (!$request) { return null; } $uploadedFile = $request->file($uploadField); //check type because request file method, may returns UploadedFile, array or null if (!is_a($uploadedFile, UploadedFile::class)) { return null; } return $uploadedFile; }
[ "public", "static", "function", "getFileSafe", "(", "string", "$", "uploadField", ",", "Request", "$", "request", ")", "{", "if", "(", "!", "$", "request", ")", "{", "return", "null", ";", "}", "$", "uploadedFile", "=", "$", "request", "->", "file", "(...
Return File in passed request if ok, otherwise return null @param string $uploadField @param Request $request @return null|UploadedFile
[ "Return", "File", "in", "passed", "request", "if", "ok", "otherwise", "return", "null" ]
8c4ea439db6ad2e7d28402b0f1e358d4df9c7768
https://github.com/padosoft/laravel-request/blob/8c4ea439db6ad2e7d28402b0f1e358d4df9c7768/src/RequestHelper.php#L80-L96
train
lucifurious/kisma
src/Kisma/Core/Utility/Log.php
Log.error
public static function error( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::ERROR, $context, $extra ); }
php
public static function error( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::ERROR, $context, $extra ); }
[ "public", "static", "function", "error", "(", "$", "message", ",", "$", "context", "=", "array", "(", ")", ",", "$", "extra", "=", "null", ")", "{", "return", "static", "::", "log", "(", "$", "message", ",", "LoggingLevels", "::", "ERROR", ",", "$", ...
Creates an 'error' log entry @param string $message The message to send to the log @param array $context @param mixed $extra @return bool
[ "Creates", "an", "error", "log", "entry" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Log.php#L206-L209
train
lucifurious/kisma
src/Kisma/Core/Utility/Log.php
Log.warning
public static function warning( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::WARNING, $context, $extra ); }
php
public static function warning( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::WARNING, $context, $extra ); }
[ "public", "static", "function", "warning", "(", "$", "message", ",", "$", "context", "=", "array", "(", ")", ",", "$", "extra", "=", "null", ")", "{", "return", "static", "::", "log", "(", "$", "message", ",", "LoggingLevels", "::", "WARNING", ",", "...
Creates a 'warning' log entry @param string $message The message to send to the log @param array $context @param mixed $extra @return bool
[ "Creates", "a", "warning", "log", "entry" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Log.php#L220-L223
train
lucifurious/kisma
src/Kisma/Core/Utility/Log.php
Log.notice
public static function notice( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::NOTICE, $context, $extra ); }
php
public static function notice( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::NOTICE, $context, $extra ); }
[ "public", "static", "function", "notice", "(", "$", "message", ",", "$", "context", "=", "array", "(", ")", ",", "$", "extra", "=", "null", ")", "{", "return", "static", "::", "log", "(", "$", "message", ",", "LoggingLevels", "::", "NOTICE", ",", "$"...
Creates a 'notice' log entry @param string $message The message to send to the log @param array $context @param mixed $extra @return bool
[ "Creates", "a", "notice", "log", "entry" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Log.php#L234-L237
train
lucifurious/kisma
src/Kisma/Core/Utility/Log.php
Log.info
public static function info( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::INFO, $context, $extra ); }
php
public static function info( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::INFO, $context, $extra ); }
[ "public", "static", "function", "info", "(", "$", "message", ",", "$", "context", "=", "array", "(", ")", ",", "$", "extra", "=", "null", ")", "{", "return", "static", "::", "log", "(", "$", "message", ",", "LoggingLevels", "::", "INFO", ",", "$", ...
Creates an 'info' log entry @param string $message The message to send to the log @param array $context @param mixed $extra @return bool
[ "Creates", "an", "info", "log", "entry" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Log.php#L248-L251
train
lucifurious/kisma
src/Kisma/Core/Utility/Log.php
Log.debug
public static function debug( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::DEBUG, $context, $extra ); }
php
public static function debug( $message, $context = array(), $extra = null ) { return static::log( $message, LoggingLevels::DEBUG, $context, $extra ); }
[ "public", "static", "function", "debug", "(", "$", "message", ",", "$", "context", "=", "array", "(", ")", ",", "$", "extra", "=", "null", ")", "{", "return", "static", "::", "log", "(", "$", "message", ",", "LoggingLevels", "::", "DEBUG", ",", "$", ...
Creates a 'debug' log entry @param string $message The message to send to the log @param array $context @param mixed $extra @return bool
[ "Creates", "a", "debug", "log", "entry" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Log.php#L262-L265
train
lucifurious/kisma
src/Kisma/Core/Utility/Log.php
Log._processMessage
protected static function _processMessage( &$message ) { $_newIndent = 0; foreach ( static::$_indentTokens as $_key => $_token ) { if ( $_token == substr( $message, 0, $_length = strlen( $_token ) ) ) { $_newIndent = ( false === $_key ? -1 : 1 ); $message = substr( $message, $_length ); } } return $_newIndent; }
php
protected static function _processMessage( &$message ) { $_newIndent = 0; foreach ( static::$_indentTokens as $_key => $_token ) { if ( $_token == substr( $message, 0, $_length = strlen( $_token ) ) ) { $_newIndent = ( false === $_key ? -1 : 1 ); $message = substr( $message, $_length ); } } return $_newIndent; }
[ "protected", "static", "function", "_processMessage", "(", "&", "$", "message", ")", "{", "$", "_newIndent", "=", "0", ";", "foreach", "(", "static", "::", "$", "_indentTokens", "as", "$", "_key", "=>", "$", "_token", ")", "{", "if", "(", "$", "_token"...
Processes the indent level for the messages @param string $message @return integer The indent difference AFTER this message
[ "Processes", "the", "indent", "level", "for", "the", "messages" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Log.php#L307-L321
train
lucifurious/kisma
src/Kisma/Core/Utility/Log.php
Log._getCallingMethod
protected static function _getCallingMethod() { $_backTrace = debug_backtrace(); $_thisClass = get_called_class(); $_type = $_class = $_method = null; for ( $_i = 0, $_size = sizeof( $_backTrace ); $_i < $_size; $_i++ ) { if ( isset( $_backTrace[$_i]['class'] ) ) { $_class = $_backTrace[$_i]['class']; } if ( $_class == $_thisClass ) { continue; } if ( isset( $_backTrace[$_i]['method'] ) ) { $_method = $_backTrace[$_i]['method']; } else if ( isset( $_backTrace[$_i]['function'] ) ) { $_method = $_backTrace[$_i]['function']; } else { $_method = 'Unknown'; } $_type = $_backTrace[$_i]['type']; break; } if ( $_i >= 0 ) { return str_ireplace( 'Kisma\\Core\\', 'Core\\', $_class ) . $_type . $_method; } return 'Unknown'; }
php
protected static function _getCallingMethod() { $_backTrace = debug_backtrace(); $_thisClass = get_called_class(); $_type = $_class = $_method = null; for ( $_i = 0, $_size = sizeof( $_backTrace ); $_i < $_size; $_i++ ) { if ( isset( $_backTrace[$_i]['class'] ) ) { $_class = $_backTrace[$_i]['class']; } if ( $_class == $_thisClass ) { continue; } if ( isset( $_backTrace[$_i]['method'] ) ) { $_method = $_backTrace[$_i]['method']; } else if ( isset( $_backTrace[$_i]['function'] ) ) { $_method = $_backTrace[$_i]['function']; } else { $_method = 'Unknown'; } $_type = $_backTrace[$_i]['type']; break; } if ( $_i >= 0 ) { return str_ireplace( 'Kisma\\Core\\', 'Core\\', $_class ) . $_type . $_method; } return 'Unknown'; }
[ "protected", "static", "function", "_getCallingMethod", "(", ")", "{", "$", "_backTrace", "=", "debug_backtrace", "(", ")", ";", "$", "_thisClass", "=", "get_called_class", "(", ")", ";", "$", "_type", "=", "$", "_class", "=", "$", "_method", "=", "null", ...
Returns the name of the method that made the call @return string @deprecated in v0.2.20. To be removed in v0.3.0. Replaced by Monolog
[ "Returns", "the", "name", "of", "the", "method", "that", "made", "the", "call" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Log.php#L497-L539
train
lucifurious/kisma
src/Kisma/Core/Utility/Log.php
Log.formatLogEntry
public static function formatLogEntry( array $entry, $newline = true ) { $_level = Option::get( $entry, 'level' ); $_levelName = static::_getLogLevel( $_level ); $_timestamp = Option::get( $entry, 'timestamp' ); $_message = preg_replace( '/\033\[[\d;]+m/', null, Option::get( $entry, 'message' ) ); $_context = Option::get( $entry, 'context' ); $_extra = Option::get( $entry, 'extra' ); $_blob = new \stdClass(); if ( static::$_includeProcessInfo ) { $_blob->pid = getmypid(); $_blob->uid = getmyuid(); $_blob->hostname = gethostname(); } if ( !empty( $_context ) ) { $_blob->context = $_context; } if ( !empty( $_extra ) ) { $_context->extra = $_extra; } $_blob = json_encode( $_blob ); if ( false === $_blob || '{}' == $_blob ) { $_blob = null; } $_replacements = array( 0 => $_levelName, 1 => date( 'M d', $_timestamp ), 2 => date( 'H:i:s', $_timestamp ), 3 => $_message, 4 => $_blob, ); return str_ireplace( array( '%%level%%', '%%date%%', '%%time%%', '%%message%%', '%%extra%%', ), $_replacements, static::$_logFormat ) . ( $newline ? PHP_EOL : null ); }
php
public static function formatLogEntry( array $entry, $newline = true ) { $_level = Option::get( $entry, 'level' ); $_levelName = static::_getLogLevel( $_level ); $_timestamp = Option::get( $entry, 'timestamp' ); $_message = preg_replace( '/\033\[[\d;]+m/', null, Option::get( $entry, 'message' ) ); $_context = Option::get( $entry, 'context' ); $_extra = Option::get( $entry, 'extra' ); $_blob = new \stdClass(); if ( static::$_includeProcessInfo ) { $_blob->pid = getmypid(); $_blob->uid = getmyuid(); $_blob->hostname = gethostname(); } if ( !empty( $_context ) ) { $_blob->context = $_context; } if ( !empty( $_extra ) ) { $_context->extra = $_extra; } $_blob = json_encode( $_blob ); if ( false === $_blob || '{}' == $_blob ) { $_blob = null; } $_replacements = array( 0 => $_levelName, 1 => date( 'M d', $_timestamp ), 2 => date( 'H:i:s', $_timestamp ), 3 => $_message, 4 => $_blob, ); return str_ireplace( array( '%%level%%', '%%date%%', '%%time%%', '%%message%%', '%%extra%%', ), $_replacements, static::$_logFormat ) . ( $newline ? PHP_EOL : null ); }
[ "public", "static", "function", "formatLogEntry", "(", "array", "$", "entry", ",", "$", "newline", "=", "true", ")", "{", "$", "_level", "=", "Option", "::", "get", "(", "$", "entry", ",", "'level'", ")", ";", "$", "_levelName", "=", "static", "::", ...
Formats the log entry. You can override this method to provide you own formatting. It will strip out any console escape sequences as well @param array $entry Read the code, data in the array @param bool $newline @return string @deprecated in v0.2.20. To be removed in v0.3.0. Replaced by Monolog formatter
[ "Formats", "the", "log", "entry", ".", "You", "can", "override", "this", "method", "to", "provide", "you", "own", "formatting", ".", "It", "will", "strip", "out", "any", "console", "escape", "sequences", "as", "well" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Log.php#L551-L605
train
lucifurious/kisma
src/Kisma/Core/Utility/Log.php
Log._checkLogFile
protected static function _checkLogFile() { if ( null !== static::$_logger ) { return static::$_logFileValid = true; } if ( empty( static::$_logFilePath ) ) { // Try and figure out a good place to log... static::$_logFilePath = ( \Kisma::get( 'app.log_path', \Kisma::get( 'app.base_path' ) ) ?: dirname( getcwd() ) ) . '/log'; } if ( !is_dir( static::$_logFilePath ) ) { if ( false === @mkdir( static::$_logFilePath, 0777, true ) ) { error_log( 'Unable to create default log directory: ' . static::$_logFilePath ); return static::$_logFileValid = false; } } if ( empty( static::$_logFileName ) ) { \Kisma::set( 'app.log_file_name', static::$_logFileName = static::DEFAULT_LOG_FILE_NAME ); } static::$_defaultLog = static::$_logFilePath . '/' . trim( static::$_logFileName, '/' ); static::$_logger = static::createLogger( static::DEFAULT_CHANNEL_NAME ); // If we're in debug mode and these haven't been disabled, enable... if ( \Kisma::get( CoreSettings::DEBUG ) ) { static::$_enableChromePhp = static::$_enableChromePhp ?: true; static::$_enableFirePhp = static::$_enableFirePhp ?: true; } // Enable conditional handlers if ( static::$_enableFirePhp ) { static::$_logger->pushHandler( new FirePHPHandler() ); } if ( static::$_enableChromePhp ) { static::$_logger->pushHandler( new ChromePHPHandler() ); } return static::$_logFileValid = true; }
php
protected static function _checkLogFile() { if ( null !== static::$_logger ) { return static::$_logFileValid = true; } if ( empty( static::$_logFilePath ) ) { // Try and figure out a good place to log... static::$_logFilePath = ( \Kisma::get( 'app.log_path', \Kisma::get( 'app.base_path' ) ) ?: dirname( getcwd() ) ) . '/log'; } if ( !is_dir( static::$_logFilePath ) ) { if ( false === @mkdir( static::$_logFilePath, 0777, true ) ) { error_log( 'Unable to create default log directory: ' . static::$_logFilePath ); return static::$_logFileValid = false; } } if ( empty( static::$_logFileName ) ) { \Kisma::set( 'app.log_file_name', static::$_logFileName = static::DEFAULT_LOG_FILE_NAME ); } static::$_defaultLog = static::$_logFilePath . '/' . trim( static::$_logFileName, '/' ); static::$_logger = static::createLogger( static::DEFAULT_CHANNEL_NAME ); // If we're in debug mode and these haven't been disabled, enable... if ( \Kisma::get( CoreSettings::DEBUG ) ) { static::$_enableChromePhp = static::$_enableChromePhp ?: true; static::$_enableFirePhp = static::$_enableFirePhp ?: true; } // Enable conditional handlers if ( static::$_enableFirePhp ) { static::$_logger->pushHandler( new FirePHPHandler() ); } if ( static::$_enableChromePhp ) { static::$_logger->pushHandler( new ChromePHPHandler() ); } return static::$_logFileValid = true; }
[ "protected", "static", "function", "_checkLogFile", "(", ")", "{", "if", "(", "null", "!==", "static", "::", "$", "_logger", ")", "{", "return", "static", "::", "$", "_logFileValid", "=", "true", ";", "}", "if", "(", "empty", "(", "static", "::", "$", ...
Makes sure we have a log file name and path @deprecated in v0.2.20. To be removed in v0.3.0. Replaced by Monolog
[ "Makes", "sure", "we", "have", "a", "log", "file", "name", "and", "path" ]
4cc9954249da4e535b52f154e728935f07e648ae
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/Log.php#L612-L663
train
ekyna/Characteristics
Entity/NumberCharacteristic.php
NumberCharacteristic.setNumber
public function setNumber($number = null) { $this->number = null !== $number ? floatval($number) : null; return $this; }
php
public function setNumber($number = null) { $this->number = null !== $number ? floatval($number) : null; return $this; }
[ "public", "function", "setNumber", "(", "$", "number", "=", "null", ")", "{", "$", "this", "->", "number", "=", "null", "!==", "$", "number", "?", "floatval", "(", "$", "number", ")", ":", "null", ";", "return", "$", "this", ";", "}" ]
Sets the number. @param float $number @return NumberCharacteristic
[ "Sets", "the", "number", "." ]
118a349fd98a7c28721d3cbaba67ce79d1cffada
https://github.com/ekyna/Characteristics/blob/118a349fd98a7c28721d3cbaba67ce79d1cffada/Entity/NumberCharacteristic.php#L26-L31
train
MASNathan/Curl
src/MASNathan/Curl/Ch.php
Ch.curl
static private function curl($method, $url, $data, $special_options = null) { $curl = \curl_init(); if ($method == 'GET') { if (!empty($data)) { $url .= '?' . \http_build_query($data); } } elseif (!is_null($special_options)) { \curl_setopt_array($curl, $special_options); \curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); \curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } else { \curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); \curl_setopt($curl, CURLOPT_POSTFIELDS, \http_build_query($data)); } \curl_setopt($curl, CURLOPT_URL, $url); \curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); \curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); \curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); \curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $content = \curl_exec($curl); \curl_close($curl); return $content; }
php
static private function curl($method, $url, $data, $special_options = null) { $curl = \curl_init(); if ($method == 'GET') { if (!empty($data)) { $url .= '?' . \http_build_query($data); } } elseif (!is_null($special_options)) { \curl_setopt_array($curl, $special_options); \curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); \curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } else { \curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); \curl_setopt($curl, CURLOPT_POSTFIELDS, \http_build_query($data)); } \curl_setopt($curl, CURLOPT_URL, $url); \curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); \curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); \curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); \curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $content = \curl_exec($curl); \curl_close($curl); return $content; }
[ "static", "private", "function", "curl", "(", "$", "method", ",", "$", "url", ",", "$", "data", ",", "$", "special_options", "=", "null", ")", "{", "$", "curl", "=", "\\", "curl_init", "(", ")", ";", "if", "(", "$", "method", "==", "'GET'", ")", ...
Requests a specified url using the specified method @param string $methof @param string $url @param array $data @param array $special_options Adicional CURL options @return string
[ "Requests", "a", "specified", "url", "using", "the", "specified", "method" ]
f03d33d45d583723dcfde8005c13ae3dd16d4d97
https://github.com/MASNathan/Curl/blob/f03d33d45d583723dcfde8005c13ae3dd16d4d97/src/MASNathan/Curl/Ch.php#L145-L173
train
MASNathan/Curl
src/MASNathan/Curl/Ch.php
Ch.call
public static function call($method, $args, $content_type = null) { if (count($args) == 0) { throw new Exception\InvalidArgsException("You need specify at least the URL to call"); } $method = strtoupper($method); $url = null; $params = null; $callback = null; $data_type = ''; if (!is_string($args[0]) || !filter_var($args[0], FILTER_VALIDATE_URL)) { throw new Exception\InvalidArgsException("The URL you specified is not valid."); } else { $url = \array_shift($args); } //Is there any parameters to add? if (count($args) > 0 && is_array($args[0])) { $params = \array_shift($args); } //Is there any callback function to call? if (count($args) > 0 && is_callable($args[0])) { $callback = \array_shift($args); } //Is there any data type? if (count($args) > 0 && is_string($args[0])) { $data_type = \array_shift($args); } //END of arguments treatment if ($method == 'POST' && $content_type == 'json') { $data = self::curl($method, $url, \reset($params), array( CURLOPT_HTTPHEADER => array('Content-Type: application/json'), CURLOPT_POSTFIELDS => $params, )); } else if ($method == 'POST' && $content_type == 'xml') { $data = self::curl($method, $url, \reset($params), array( CURLOPT_HTTPHEADER => array('Content-Type: text/xml'), CURLOPT_POSTFIELDS => $params, )); } else { $data = self::curl($method, $url, $params); } $data = StringParser::parse($data, $data_type); if (!is_null($callback)) { $data = $callback($data); } return $data; }
php
public static function call($method, $args, $content_type = null) { if (count($args) == 0) { throw new Exception\InvalidArgsException("You need specify at least the URL to call"); } $method = strtoupper($method); $url = null; $params = null; $callback = null; $data_type = ''; if (!is_string($args[0]) || !filter_var($args[0], FILTER_VALIDATE_URL)) { throw new Exception\InvalidArgsException("The URL you specified is not valid."); } else { $url = \array_shift($args); } //Is there any parameters to add? if (count($args) > 0 && is_array($args[0])) { $params = \array_shift($args); } //Is there any callback function to call? if (count($args) > 0 && is_callable($args[0])) { $callback = \array_shift($args); } //Is there any data type? if (count($args) > 0 && is_string($args[0])) { $data_type = \array_shift($args); } //END of arguments treatment if ($method == 'POST' && $content_type == 'json') { $data = self::curl($method, $url, \reset($params), array( CURLOPT_HTTPHEADER => array('Content-Type: application/json'), CURLOPT_POSTFIELDS => $params, )); } else if ($method == 'POST' && $content_type == 'xml') { $data = self::curl($method, $url, \reset($params), array( CURLOPT_HTTPHEADER => array('Content-Type: text/xml'), CURLOPT_POSTFIELDS => $params, )); } else { $data = self::curl($method, $url, $params); } $data = StringParser::parse($data, $data_type); if (!is_null($callback)) { $data = $callback($data); } return $data; }
[ "public", "static", "function", "call", "(", "$", "method", ",", "$", "args", ",", "$", "content_type", "=", "null", ")", "{", "if", "(", "count", "(", "$", "args", ")", "==", "0", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgsException", ...
Deals with the arguments "detection" and sets the rigth configs for the method you specify @param string $method You can use the following: GET, POST, PUT, DELETE @param array $args @param string $content_type Should be json or xml, if not, just leave it empty @return string|array
[ "Deals", "with", "the", "arguments", "detection", "and", "sets", "the", "rigth", "configs", "for", "the", "method", "you", "specify" ]
f03d33d45d583723dcfde8005c13ae3dd16d4d97
https://github.com/MASNathan/Curl/blob/f03d33d45d583723dcfde8005c13ae3dd16d4d97/src/MASNathan/Curl/Ch.php#L182-L239
train
minecraftphp/rcon
src/ConnectionFactory.php
ConnectionFactory.createConnection
public function createConnection($host, $port, $password = null) { $socket = $this->socketFactory->createClient(sprintf('%s:%s', $host, $port)); $conn = new Connection($socket); if (!empty($password)) { $conn->authenticate($password); } return $conn; }
php
public function createConnection($host, $port, $password = null) { $socket = $this->socketFactory->createClient(sprintf('%s:%s', $host, $port)); $conn = new Connection($socket); if (!empty($password)) { $conn->authenticate($password); } return $conn; }
[ "public", "function", "createConnection", "(", "$", "host", ",", "$", "port", ",", "$", "password", "=", "null", ")", "{", "$", "socket", "=", "$", "this", "->", "socketFactory", "->", "createClient", "(", "sprintf", "(", "'%s:%s'", ",", "$", "host", "...
Creates a new Connection @param string $host @param integer $port @param string|null $password @return Connection
[ "Creates", "a", "new", "Connection" ]
15c2a523b58f4326633192717800db62da2bbde3
https://github.com/minecraftphp/rcon/blob/15c2a523b58f4326633192717800db62da2bbde3/src/ConnectionFactory.php#L43-L54
train
indigophp/fuelphp-dbal
src/Providers/FuelServiceProvider.php
FuelServiceProvider.parseFuelConfig
public function parseFuelConfig(array $config) { $params = array(); $params['driver'] = $config['type']; if ($params['driver'] === 'pdo') { list($type, $dsn) = explode(':', $config['connection']['dsn'], 2); $params['driver'] .= '_' . $type; $dsn = explode(';', $dsn); foreach ($dsn as $d) { list($k, $v) = explode('=', $d); $params[$k] = $v; } } else { $params['dbname'] = $config['connection']['database']; $params['host'] = $config['connection']['hostname']; $params['port'] = Arr::get($config, 'connection.port'); } $params['user'] = Arr::get($config, 'connection.username'); $params['password'] = Arr::get($config, 'connection.password'); $params['charset'] = Arr::get($config, 'charset'); return $params; }
php
public function parseFuelConfig(array $config) { $params = array(); $params['driver'] = $config['type']; if ($params['driver'] === 'pdo') { list($type, $dsn) = explode(':', $config['connection']['dsn'], 2); $params['driver'] .= '_' . $type; $dsn = explode(';', $dsn); foreach ($dsn as $d) { list($k, $v) = explode('=', $d); $params[$k] = $v; } } else { $params['dbname'] = $config['connection']['database']; $params['host'] = $config['connection']['hostname']; $params['port'] = Arr::get($config, 'connection.port'); } $params['user'] = Arr::get($config, 'connection.username'); $params['password'] = Arr::get($config, 'connection.password'); $params['charset'] = Arr::get($config, 'charset'); return $params; }
[ "public", "function", "parseFuelConfig", "(", "array", "$", "config", ")", "{", "$", "params", "=", "array", "(", ")", ";", "$", "params", "[", "'driver'", "]", "=", "$", "config", "[", "'type'", "]", ";", "if", "(", "$", "params", "[", "'driver'", ...
Parses Fuel db config to DBAL compatible configuration @param array $config @return array
[ "Parses", "Fuel", "db", "config", "to", "DBAL", "compatible", "configuration" ]
2c98a3ea8bf4b1dab1bb6b578bb2af3a7ad1ee49
https://github.com/indigophp/fuelphp-dbal/blob/2c98a3ea8bf4b1dab1bb6b578bb2af3a7ad1ee49/src/Providers/FuelServiceProvider.php#L114-L147
train
indigophp/fuelphp-dbal
src/Providers/FuelServiceProvider.php
FuelServiceProvider.getApp
private function getApp() { $stack = $this->resolve('requeststack'); if ($request = $stack->top()) { $app = $request->getApplication(); } else { $app = $this->resolve('application::__main'); } return $app; }
php
private function getApp() { $stack = $this->resolve('requeststack'); if ($request = $stack->top()) { $app = $request->getApplication(); } else { $app = $this->resolve('application::__main'); } return $app; }
[ "private", "function", "getApp", "(", ")", "{", "$", "stack", "=", "$", "this", "->", "resolve", "(", "'requeststack'", ")", ";", "if", "(", "$", "request", "=", "$", "stack", "->", "top", "(", ")", ")", "{", "$", "app", "=", "$", "request", "->"...
Returns the current application @return \Fuel\Foundation\Application
[ "Returns", "the", "current", "application" ]
2c98a3ea8bf4b1dab1bb6b578bb2af3a7ad1ee49
https://github.com/indigophp/fuelphp-dbal/blob/2c98a3ea8bf4b1dab1bb6b578bb2af3a7ad1ee49/src/Providers/FuelServiceProvider.php#L154-L168
train
EarthlingInteractive/PHPProjectUtils
lib/EarthIT/ProjectUtil/DB/DatabaseUpgrader.php
EarthIT_ProjectUtil_DB_DatabaseUpgrader.semicolonTerminate
protected static function semicolonTerminate( $sql ) { $lines = explode("\n", $sql); $lastLineK = null; foreach( $lines as $k=>$line ) { $line = trim($line); if( !preg_match('/^$|^--$|^--\s+/', $line) ) $lastLineK = $k; } if( $lastLineK !== null and !preg_match('/;$/', $lines[$lastLineK]) ) { $lines[$lastLineK] .= ";"; return implode("\n", $lines); } else { return $sql; } }
php
protected static function semicolonTerminate( $sql ) { $lines = explode("\n", $sql); $lastLineK = null; foreach( $lines as $k=>$line ) { $line = trim($line); if( !preg_match('/^$|^--$|^--\s+/', $line) ) $lastLineK = $k; } if( $lastLineK !== null and !preg_match('/;$/', $lines[$lastLineK]) ) { $lines[$lastLineK] .= ";"; return implode("\n", $lines); } else { return $sql; } }
[ "protected", "static", "function", "semicolonTerminate", "(", "$", "sql", ")", "{", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "sql", ")", ";", "$", "lastLineK", "=", "null", ";", "foreach", "(", "$", "lines", "as", "$", "k", "=>", "$", ...
Make sure the last non-comment line ends with a semicolon.
[ "Make", "sure", "the", "last", "non", "-", "comment", "line", "ends", "with", "a", "semicolon", "." ]
1a1cb341b877130604650b4e5b19e4bc78f0cfca
https://github.com/EarthlingInteractive/PHPProjectUtils/blob/1a1cb341b877130604650b4e5b19e4bc78f0cfca/lib/EarthIT/ProjectUtil/DB/DatabaseUpgrader.php#L145-L158
train
EarthlingInteractive/PHPProjectUtils
lib/EarthIT/ProjectUtil/DB/DatabaseUpgrader.php
EarthIT_ProjectUtil_DB_DatabaseUpgrader.isEntirelyCommented
protected function isEntirelyCommented( $sql ) { $lines = explode("\n", $sql); foreach( $lines as $line ) { if( preg_match(self::COMMENT_LINE_REGEX,$line) ) continue; // Otherwise this line's not a comment! return false; } // If we get here, there were no non-comment, non-blank lines, so yes. return true; }
php
protected function isEntirelyCommented( $sql ) { $lines = explode("\n", $sql); foreach( $lines as $line ) { if( preg_match(self::COMMENT_LINE_REGEX,$line) ) continue; // Otherwise this line's not a comment! return false; } // If we get here, there were no non-comment, non-blank lines, so yes. return true; }
[ "protected", "function", "isEntirelyCommented", "(", "$", "sql", ")", "{", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "sql", ")", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "if", "(", "preg_match", "(", "self", "::",...
Commented or empty
[ "Commented", "or", "empty" ]
1a1cb341b877130604650b4e5b19e4bc78f0cfca
https://github.com/EarthlingInteractive/PHPProjectUtils/blob/1a1cb341b877130604650b4e5b19e4bc78f0cfca/lib/EarthIT/ProjectUtil/DB/DatabaseUpgrader.php#L162-L172
train
EarthlingInteractive/PHPProjectUtils
lib/EarthIT/ProjectUtil/DB/DatabaseUpgrader.php
EarthIT_ProjectUtil_DB_DatabaseUpgrader.getUpgradeLogColumnNames
protected function getUpgradeLogColumnNames() { $colNames = array(); foreach( array('time','script filename','script file hash') as $attrib ) { $colNames[self::toLowerCamelCase($attrib)] = $this->toDbObjectName($attrib); } return $colNames; }
php
protected function getUpgradeLogColumnNames() { $colNames = array(); foreach( array('time','script filename','script file hash') as $attrib ) { $colNames[self::toLowerCamelCase($attrib)] = $this->toDbObjectName($attrib); } return $colNames; }
[ "protected", "function", "getUpgradeLogColumnNames", "(", ")", "{", "$", "colNames", "=", "array", "(", ")", ";", "foreach", "(", "array", "(", "'time'", ",", "'script filename'", ",", "'script file hash'", ")", "as", "$", "attrib", ")", "{", "$", "colNames"...
Returns a map of camelCase => however the column is spelled in the database of our upgrade table columns
[ "Returns", "a", "map", "of", "camelCase", "=", ">", "however", "the", "column", "is", "spelled", "in", "the", "database", "of", "our", "upgrade", "table", "columns" ]
1a1cb341b877130604650b4e5b19e4bc78f0cfca
https://github.com/EarthlingInteractive/PHPProjectUtils/blob/1a1cb341b877130604650b4e5b19e4bc78f0cfca/lib/EarthIT/ProjectUtil/DB/DatabaseUpgrader.php#L270-L276
train
bishopb/vanilla
applications/dashboard/models/class.activitymodel.php
ActivityModel.ActivityQuery
public function ActivityQuery($Join = TRUE) { $this->SQL ->Select('a.*') ->Select('t.FullHeadline, t.ProfileHeadline, t.AllowComments, t.ShowIcon, t.RouteCode') ->Select('t.Name', '', 'ActivityType') ->From('Activity a') ->Join('ActivityType t', 'a.ActivityTypeID = t.ActivityTypeID'); if ($Join) { $this->SQL ->Select('au.Name', '', 'ActivityName') ->Select('au.Gender', '', 'ActivityGender') ->Select('au.Photo', '', 'ActivityPhoto') ->Select('au.Email', '', 'ActivityEmail') ->Select('ru.Name', '', 'RegardingName') ->Select('ru.Gender', '', 'RegardingGender') ->Select('ru.Email', '', 'RegardingEmail') ->Select('ru.Photo', '', 'RegardingPhoto') ->Join('User au', 'a.ActivityUserID = au.UserID') ->Join('User ru', 'a.RegardingUserID = ru.UserID', 'left'); } $this->FireEvent('AfterActivityQuery'); }
php
public function ActivityQuery($Join = TRUE) { $this->SQL ->Select('a.*') ->Select('t.FullHeadline, t.ProfileHeadline, t.AllowComments, t.ShowIcon, t.RouteCode') ->Select('t.Name', '', 'ActivityType') ->From('Activity a') ->Join('ActivityType t', 'a.ActivityTypeID = t.ActivityTypeID'); if ($Join) { $this->SQL ->Select('au.Name', '', 'ActivityName') ->Select('au.Gender', '', 'ActivityGender') ->Select('au.Photo', '', 'ActivityPhoto') ->Select('au.Email', '', 'ActivityEmail') ->Select('ru.Name', '', 'RegardingName') ->Select('ru.Gender', '', 'RegardingGender') ->Select('ru.Email', '', 'RegardingEmail') ->Select('ru.Photo', '', 'RegardingPhoto') ->Join('User au', 'a.ActivityUserID = au.UserID') ->Join('User ru', 'a.RegardingUserID = ru.UserID', 'left'); } $this->FireEvent('AfterActivityQuery'); }
[ "public", "function", "ActivityQuery", "(", "$", "Join", "=", "TRUE", ")", "{", "$", "this", "->", "SQL", "->", "Select", "(", "'a.*'", ")", "->", "Select", "(", "'t.FullHeadline, t.ProfileHeadline, t.AllowComments, t.ShowIcon, t.RouteCode'", ")", "->", "Select", ...
Build basis of common activity SQL query. @since 2.0.0 @access public
[ "Build", "basis", "of", "common", "activity", "SQL", "query", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L50-L73
train
bishopb/vanilla
applications/dashboard/models/class.activitymodel.php
ActivityModel.Delete
public function Delete($ActivityID, $Options = array()) { // Get the activity first. $Activity = $this->GetID($ActivityID); if ($Activity) { // Log the deletion. $Log = GetValue('Log', $Options); if ($Log) { LogModel::Insert($Log, 'Activity', $Activity); } // Delete comments on the activity item $this->SQL->Delete('ActivityComment', array('ActivityID' => $ActivityID)); // Delete the activity item parent::Delete(array('ActivityID' => $ActivityID)); } }
php
public function Delete($ActivityID, $Options = array()) { // Get the activity first. $Activity = $this->GetID($ActivityID); if ($Activity) { // Log the deletion. $Log = GetValue('Log', $Options); if ($Log) { LogModel::Insert($Log, 'Activity', $Activity); } // Delete comments on the activity item $this->SQL->Delete('ActivityComment', array('ActivityID' => $ActivityID)); // Delete the activity item parent::Delete(array('ActivityID' => $ActivityID)); } }
[ "public", "function", "Delete", "(", "$", "ActivityID", ",", "$", "Options", "=", "array", "(", ")", ")", "{", "// Get the activity first.", "$", "Activity", "=", "$", "this", "->", "GetID", "(", "$", "ActivityID", ")", ";", "if", "(", "$", "Activity", ...
Delete a particular activity item. @since 2.0.0 @access public @param int $ActivityID Unique ID of acitivity to be deleted.
[ "Delete", "a", "particular", "activity", "item", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L139-L155
train
bishopb/vanilla
applications/dashboard/models/class.activitymodel.php
ActivityModel.GetWhere
public function GetWhere($Where, $Offset = 0, $Limit = 30) { if (is_string($Where)) { $Where = array($Where => $Offset); $Offset = 0; } // Add the basic activity query. $this->SQL ->Select('a2.*') ->Select('t.FullHeadline, t.ProfileHeadline, t.AllowComments, t.ShowIcon, t.RouteCode') ->Select('t.Name', '', 'ActivityType') ->From('Activity a') ->Join('Activity a2', 'a.ActivityID = a2.ActivityID') // self-join for index speed. ->Join('ActivityType t', 'a2.ActivityTypeID = t.ActivityTypeID'); // Add prefixes to the where. foreach ($Where as $Key => $Value) { if (strpos($Key, '.') === FALSE) { $Where['a.'.$Key] = $Value; unset($Where[$Key]); } } $Result = $this->SQL ->Where($Where) ->OrderBy('a.DateUpdated', 'desc') ->Limit($Limit, $Offset) ->Get(); self::GetUsers($Result->ResultArray()); Gdn::UserModel()->JoinUsers($Result->ResultArray(), array('ActivityUserID', 'RegardingUserID'), array('Join' => array('Name', 'Email', 'Gender', 'Photo'))); $this->CalculateData($Result->ResultArray()); $this->EventArguments['Data'] =& $Result; $this->FireEvent('AfterGet'); return $Result; }
php
public function GetWhere($Where, $Offset = 0, $Limit = 30) { if (is_string($Where)) { $Where = array($Where => $Offset); $Offset = 0; } // Add the basic activity query. $this->SQL ->Select('a2.*') ->Select('t.FullHeadline, t.ProfileHeadline, t.AllowComments, t.ShowIcon, t.RouteCode') ->Select('t.Name', '', 'ActivityType') ->From('Activity a') ->Join('Activity a2', 'a.ActivityID = a2.ActivityID') // self-join for index speed. ->Join('ActivityType t', 'a2.ActivityTypeID = t.ActivityTypeID'); // Add prefixes to the where. foreach ($Where as $Key => $Value) { if (strpos($Key, '.') === FALSE) { $Where['a.'.$Key] = $Value; unset($Where[$Key]); } } $Result = $this->SQL ->Where($Where) ->OrderBy('a.DateUpdated', 'desc') ->Limit($Limit, $Offset) ->Get(); self::GetUsers($Result->ResultArray()); Gdn::UserModel()->JoinUsers($Result->ResultArray(), array('ActivityUserID', 'RegardingUserID'), array('Join' => array('Name', 'Email', 'Gender', 'Photo'))); $this->CalculateData($Result->ResultArray()); $this->EventArguments['Data'] =& $Result; $this->FireEvent('AfterGet'); return $Result; }
[ "public", "function", "GetWhere", "(", "$", "Where", ",", "$", "Offset", "=", "0", ",", "$", "Limit", "=", "30", ")", "{", "if", "(", "is_string", "(", "$", "Where", ")", ")", "{", "$", "Where", "=", "array", "(", "$", "Where", "=>", "$", "Offs...
Modifies standard Gdn_Model->GetWhere to use AcitivityQuery. Events: AfterGet. @since 2.0.0 @access public @param array $Where The where condition. @param int $Offset The offset of the query. @param int $Limit the limit of the query. @return DataSet SQL results.
[ "Modifies", "standard", "Gdn_Model", "-", ">", "GetWhere", "to", "use", "AcitivityQuery", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L178-L215
train
bishopb/vanilla
applications/dashboard/models/class.activitymodel.php
ActivityModel.Get
public function Get($NotifyUserID = FALSE, $Offset = 0, $Limit = 30) { $Offset = is_numeric($Offset) ? $Offset : 0; if ($Offset < 0) $Offset = 0; $Limit = is_numeric($Limit) ? $Limit : 0; if ($Limit < 0) $Limit = 30; $this->ActivityQuery(FALSE); if (!$NotifyUserID) { $NotifyUserID = self::NOTIFY_PUBLIC; } $this->SQL->WhereIn('NotifyUserID', (array)$NotifyUserID); $this->FireEvent('BeforeGet'); $Result = $this->SQL ->OrderBy('a.ActivityID', 'desc') ->Limit($Limit, $Offset) ->Get(); Gdn::UserModel()->JoinUsers($Result, array('ActivityUserID', 'RegardingUserID'), array('Join' => array('Name', 'Photo', 'Email', 'Gender'))); $this->EventArguments['Data'] =& $Result; $this->FireEvent('AfterGet'); return $Result; }
php
public function Get($NotifyUserID = FALSE, $Offset = 0, $Limit = 30) { $Offset = is_numeric($Offset) ? $Offset : 0; if ($Offset < 0) $Offset = 0; $Limit = is_numeric($Limit) ? $Limit : 0; if ($Limit < 0) $Limit = 30; $this->ActivityQuery(FALSE); if (!$NotifyUserID) { $NotifyUserID = self::NOTIFY_PUBLIC; } $this->SQL->WhereIn('NotifyUserID', (array)$NotifyUserID); $this->FireEvent('BeforeGet'); $Result = $this->SQL ->OrderBy('a.ActivityID', 'desc') ->Limit($Limit, $Offset) ->Get(); Gdn::UserModel()->JoinUsers($Result, array('ActivityUserID', 'RegardingUserID'), array('Join' => array('Name', 'Photo', 'Email', 'Gender'))); $this->EventArguments['Data'] =& $Result; $this->FireEvent('AfterGet'); return $Result; }
[ "public", "function", "Get", "(", "$", "NotifyUserID", "=", "FALSE", ",", "$", "Offset", "=", "0", ",", "$", "Limit", "=", "30", ")", "{", "$", "Offset", "=", "is_numeric", "(", "$", "Offset", ")", "?", "$", "Offset", ":", "0", ";", "if", "(", ...
Modifies standard Gdn_Model->Get to use AcitivityQuery. Events: BeforeGet, AfterGet. @since 2.0.0 @access public @param int $NotifyUserID Unique ID of user to gather activity for or one of the NOTIFY_* constants in this class. @param int $Offset Number to skip. @param int $Limit How many to return. @return DataSet SQL results.
[ "Modifies", "standard", "Gdn_Model", "-", ">", "Get", "to", "use", "AcitivityQuery", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L261-L289
train
bishopb/vanilla
applications/dashboard/models/class.activitymodel.php
ActivityModel.GetCount
public function GetCount($UserID = '') { $this->SQL ->Select('a.ActivityID', 'count', 'ActivityCount') ->From('Activity a') ->Join('ActivityType t', 'a.ActivityTypeID = t.ActivityTypeID'); if ($UserID != '') { $this->SQL ->BeginWhereGroup() ->Where('a.ActivityUserID', $UserID) ->OrWhere('a.RegardingUserID', $UserID) ->EndWhereGroup(); } $Session = Gdn::Session(); if (!$Session->IsValid() || $Session->UserID != $UserID) $this->SQL->Where('t.Public', '1'); $this->FireEvent('BeforeGetCount'); return $this->SQL ->Get() ->FirstRow() ->ActivityCount; }
php
public function GetCount($UserID = '') { $this->SQL ->Select('a.ActivityID', 'count', 'ActivityCount') ->From('Activity a') ->Join('ActivityType t', 'a.ActivityTypeID = t.ActivityTypeID'); if ($UserID != '') { $this->SQL ->BeginWhereGroup() ->Where('a.ActivityUserID', $UserID) ->OrWhere('a.RegardingUserID', $UserID) ->EndWhereGroup(); } $Session = Gdn::Session(); if (!$Session->IsValid() || $Session->UserID != $UserID) $this->SQL->Where('t.Public', '1'); $this->FireEvent('BeforeGetCount'); return $this->SQL ->Get() ->FirstRow() ->ActivityCount; }
[ "public", "function", "GetCount", "(", "$", "UserID", "=", "''", ")", "{", "$", "this", "->", "SQL", "->", "Select", "(", "'a.ActivityID'", ",", "'count'", ",", "'ActivityCount'", ")", "->", "From", "(", "'Activity a'", ")", "->", "Join", "(", "'Activity...
Get number of activity related to a user. Events: BeforeGetCount. @since 2.0.0 @access public @param string $UserID Unique ID of user. @return int Number of activity items found.
[ "Get", "number", "of", "activity", "related", "to", "a", "user", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L340-L363
train
bishopb/vanilla
applications/dashboard/models/class.activitymodel.php
ActivityModel.GetForRole
public function GetForRole($RoleID = '', $Offset = '0', $Limit = '50') { if (!is_array($RoleID)) $RoleID = array($RoleID); $Offset = is_numeric($Offset) ? $Offset : 0; if ($Offset < 0) $Offset = 0; $Limit = is_numeric($Limit) ? $Limit : 0; if ($Limit < 0) $Limit = 0; $this->ActivityQuery(); $Result = $this->SQL ->Join('UserRole ur', 'a.ActivityUserID = ur.UserID') ->WhereIn('ur.RoleID', $RoleID) ->Where('t.Public', '1') ->OrderBy('a.DateInserted', 'desc') ->Limit($Limit, $Offset) ->Get(); $this->EventArguments['Data'] =& $Result; $this->FireEvent('AfterGet'); return $Result; }
php
public function GetForRole($RoleID = '', $Offset = '0', $Limit = '50') { if (!is_array($RoleID)) $RoleID = array($RoleID); $Offset = is_numeric($Offset) ? $Offset : 0; if ($Offset < 0) $Offset = 0; $Limit = is_numeric($Limit) ? $Limit : 0; if ($Limit < 0) $Limit = 0; $this->ActivityQuery(); $Result = $this->SQL ->Join('UserRole ur', 'a.ActivityUserID = ur.UserID') ->WhereIn('ur.RoleID', $RoleID) ->Where('t.Public', '1') ->OrderBy('a.DateInserted', 'desc') ->Limit($Limit, $Offset) ->Get(); $this->EventArguments['Data'] =& $Result; $this->FireEvent('AfterGet'); return $Result; }
[ "public", "function", "GetForRole", "(", "$", "RoleID", "=", "''", ",", "$", "Offset", "=", "'0'", ",", "$", "Limit", "=", "'50'", ")", "{", "if", "(", "!", "is_array", "(", "$", "RoleID", ")", ")", "$", "RoleID", "=", "array", "(", "$", "RoleID"...
Get activity related to a particular role. Events: AfterGet. @since 2.0.18 @access public @param string $RoleID Unique ID of role. @param int $Offset Number to skip. @param int $Limit Max number to return. @return DataSet SQL results.
[ "Get", "activity", "related", "to", "a", "particular", "role", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L377-L402
train
bishopb/vanilla
applications/dashboard/models/class.activitymodel.php
ActivityModel.GetCountForRole
public function GetCountForRole($RoleID = '') { if (!is_array($RoleID)) $RoleID = array($RoleID); return $this->SQL ->Select('a.ActivityID', 'count', 'ActivityCount') ->From('Activity a') ->Join('ActivityType t', 'a.ActivityTypeID = t.ActivityTypeID') ->Join('UserRole ur', 'a.ActivityUserID = ur.UserID') ->WhereIn('ur.RoleID', $RoleID) ->Where('t.Public', '1') ->Get() ->FirstRow() ->ActivityCount; }
php
public function GetCountForRole($RoleID = '') { if (!is_array($RoleID)) $RoleID = array($RoleID); return $this->SQL ->Select('a.ActivityID', 'count', 'ActivityCount') ->From('Activity a') ->Join('ActivityType t', 'a.ActivityTypeID = t.ActivityTypeID') ->Join('UserRole ur', 'a.ActivityUserID = ur.UserID') ->WhereIn('ur.RoleID', $RoleID) ->Where('t.Public', '1') ->Get() ->FirstRow() ->ActivityCount; }
[ "public", "function", "GetCountForRole", "(", "$", "RoleID", "=", "''", ")", "{", "if", "(", "!", "is_array", "(", "$", "RoleID", ")", ")", "$", "RoleID", "=", "array", "(", "$", "RoleID", ")", ";", "return", "$", "this", "->", "SQL", "->", "Select...
Get number of activity related to a particular role. @since 2.0.18 @access public @param int $RoleID Unique ID of role. @return int Number of activity items.
[ "Get", "number", "of", "activity", "related", "to", "a", "particular", "role", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L412-L426
train
bishopb/vanilla
applications/dashboard/models/class.activitymodel.php
ActivityModel.GetID
public function GetID($ActivityID, $DataType = FALSE) { $Activity = parent::GetID($ActivityID, $DataType); if ($Activity) { $this->CalculateRow($Activity); $Activities = array($Activity); self::JoinUsers($Activities); $Activity = array_pop($Activities); } return $Activity; }
php
public function GetID($ActivityID, $DataType = FALSE) { $Activity = parent::GetID($ActivityID, $DataType); if ($Activity) { $this->CalculateRow($Activity); $Activities = array($Activity); self::JoinUsers($Activities); $Activity = array_pop($Activities); } return $Activity; }
[ "public", "function", "GetID", "(", "$", "ActivityID", ",", "$", "DataType", "=", "FALSE", ")", "{", "$", "Activity", "=", "parent", "::", "GetID", "(", "$", "ActivityID", ",", "$", "DataType", ")", ";", "if", "(", "$", "Activity", ")", "{", "$", "...
Get a particular activity record. @since 2.0.0 @access public @param int $ActivityID Unique ID of activity item. @return array|object A single SQL result.
[ "Get", "a", "particular", "activity", "record", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L436-L446
train
bishopb/vanilla
applications/dashboard/models/class.activitymodel.php
ActivityModel.GetNotifications
public function GetNotifications($NotifyUserID, $Offset = '0', $Limit = '30') { $this->ActivityQuery(FALSE); $this->FireEvent('BeforeGetNotifications'); $Result = $this->SQL ->Where('NotifyUserID', $NotifyUserID) ->Limit($Limit, $Offset) ->OrderBy('a.ActivityID', 'desc') ->Get(); $Result->DatasetType(DATASET_TYPE_ARRAY); self::GetUsers($Result->ResultArray()); Gdn::UserModel()->JoinUsers($Result->ResultArray(), array('ActivityUserID', 'RegardingUserID'), array('Join' => array('Name', 'Photo', 'Email', 'Gender'))); $this->CalculateData($Result->ResultArray()); return $Result; }
php
public function GetNotifications($NotifyUserID, $Offset = '0', $Limit = '30') { $this->ActivityQuery(FALSE); $this->FireEvent('BeforeGetNotifications'); $Result = $this->SQL ->Where('NotifyUserID', $NotifyUserID) ->Limit($Limit, $Offset) ->OrderBy('a.ActivityID', 'desc') ->Get(); $Result->DatasetType(DATASET_TYPE_ARRAY); self::GetUsers($Result->ResultArray()); Gdn::UserModel()->JoinUsers($Result->ResultArray(), array('ActivityUserID', 'RegardingUserID'), array('Join' => array('Name', 'Photo', 'Email', 'Gender'))); $this->CalculateData($Result->ResultArray()); return $Result; }
[ "public", "function", "GetNotifications", "(", "$", "NotifyUserID", ",", "$", "Offset", "=", "'0'", ",", "$", "Limit", "=", "'30'", ")", "{", "$", "this", "->", "ActivityQuery", "(", "FALSE", ")", ";", "$", "this", "->", "FireEvent", "(", "'BeforeGetNoti...
Get notifications for a user. Events: BeforeGetNotifications. @since 2.0.0 @access public @param int $NotifyUserID Unique ID of user. @param int $Offset Number to skip. @param int $Limit Max number to return. @return DataSet SQL results.
[ "Get", "notifications", "for", "a", "user", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L460-L475
train
bishopb/vanilla
applications/dashboard/models/class.activitymodel.php
ActivityModel.GetNotificationsSince
public function GetNotificationsSince($UserID, $LastActivityID, $FilterToActivityTypeIDs = '', $Limit = '5') { $this->ActivityQuery(); $this->FireEvent('BeforeGetNotificationsSince'); if (is_array($FilterToActivityTypeIDs)) $this->SQL->WhereIn('a.ActivityTypeID', $FilterToActivityTypeIDs); else $this->SQL->Where('t.Notify', '1'); $Result = $this->SQL ->Where('RegardingUserID', $UserID) ->Where('a.ActivityID >', $LastActivityID) ->Limit($Limit, 0) ->OrderBy('a.ActivityID', 'desc') ->Get(); return $Result; }
php
public function GetNotificationsSince($UserID, $LastActivityID, $FilterToActivityTypeIDs = '', $Limit = '5') { $this->ActivityQuery(); $this->FireEvent('BeforeGetNotificationsSince'); if (is_array($FilterToActivityTypeIDs)) $this->SQL->WhereIn('a.ActivityTypeID', $FilterToActivityTypeIDs); else $this->SQL->Where('t.Notify', '1'); $Result = $this->SQL ->Where('RegardingUserID', $UserID) ->Where('a.ActivityID >', $LastActivityID) ->Limit($Limit, 0) ->OrderBy('a.ActivityID', 'desc') ->Get(); return $Result; }
[ "public", "function", "GetNotificationsSince", "(", "$", "UserID", ",", "$", "LastActivityID", ",", "$", "FilterToActivityTypeIDs", "=", "''", ",", "$", "Limit", "=", "'5'", ")", "{", "$", "this", "->", "ActivityQuery", "(", ")", ";", "$", "this", "->", ...
Get notifications for a user since designated ActivityID. Events: BeforeGetNotificationsSince. @since 2.0.18 @access public @param int $UserID Unique ID of user. @param int $LastActivityID ID of activity to start at. @param array $FilterToActivityTypeIDs Limits returned activity to particular types. @param int $Limit Max number to return. @return DataSet SQL results.
[ "Get", "notifications", "for", "a", "user", "since", "designated", "ActivityID", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L490-L506
train
bishopb/vanilla
applications/dashboard/models/class.activitymodel.php
ActivityModel.GetComments
public function GetComments($ActivityIDs) { $Result = $this->SQL ->Select('c.*') ->From('ActivityComment c') ->WhereIn('c.ActivityID', $ActivityIDs) ->OrderBy('c.ActivityID, c.DateInserted') ->Get()->ResultArray(); Gdn::UserModel()->JoinUsers($Result, array('InsertUserID'), array('Join' => array('Name', 'Photo', 'Email'))); return $Result; }
php
public function GetComments($ActivityIDs) { $Result = $this->SQL ->Select('c.*') ->From('ActivityComment c') ->WhereIn('c.ActivityID', $ActivityIDs) ->OrderBy('c.ActivityID, c.DateInserted') ->Get()->ResultArray(); Gdn::UserModel()->JoinUsers($Result, array('InsertUserID'), array('Join' => array('Name', 'Photo', 'Email'))); return $Result; }
[ "public", "function", "GetComments", "(", "$", "ActivityIDs", ")", "{", "$", "Result", "=", "$", "this", "->", "SQL", "->", "Select", "(", "'c.*'", ")", "->", "From", "(", "'ActivityComment c'", ")", "->", "WhereIn", "(", "'c.ActivityID'", ",", "$", "Act...
Get comments related to designated activity items. Events: BeforeGetComments. @since 2.0.0 @access public @param array $ActivityIDs IDs of activity items. @return DataSet SQL results.
[ "Get", "comments", "related", "to", "designated", "activity", "items", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L552-L561
train
bishopb/vanilla
applications/dashboard/models/class.activitymodel.php
ActivityModel.Add
public function Add($ActivityUserID, $ActivityType, $Story = NULL, $RegardingUserID = NULL, $CommentActivityID = NULL, $Route = NULL, $SendEmail = '') { static $ActivityTypes = array(); // Get the ActivityTypeID & see if this is a notification. $ActivityTypeRow = self::GetActivityType($ActivityType); if ($ActivityTypeRow !== FALSE) { $ActivityTypeID = $ActivityTypeRow['ActivityTypeID']; $Notify = (bool)$ActivityTypeRow['Notify']; } else { trigger_error(ErrorMessage(sprintf('Activity type could not be found: %s', $ActivityType), 'ActivityModel', 'Add'), E_USER_ERROR); } $Activity = array( 'ActivityUserID' => $ActivityUserID, 'ActivityType' => $ActivityType, 'Story' => $Story, 'RegardingUserID' => $RegardingUserID, 'Route' => $Route ); // Massage $SendEmail to allow for only sending an email. $QueueEmail = FALSE; if ($SendEmail === 'Only') { $SendEmail = ''; $AddActivity = FALSE; } else if ($SendEmail === 'QueueOnly') { $SendEmail = ''; $QueueEmail = TRUE; $AddActivity = TRUE; $Notify = TRUE; } else { $AddActivity = TRUE; } // If $SendEmail was FALSE or TRUE, let it override the $Notify setting. if ($SendEmail === FALSE || $SendEmail === TRUE) $Notify = $SendEmail; $Preference = FALSE; if (($ActivityTypeRow['Notify'] || !$ActivityTypeRow['Public']) && $RegardingUserID) { $Activity['NotifyUserID'] = $Activity['RegardingUserID']; $Preference = $ActivityType; } else { $Activity['NotifyUserID'] = self::NOTIFY_PUBLIC; } // Otherwise let the decision to email lie with the $Notify setting. if ($SendEmail == 'Force' || $Notify) { $Activity['Emailed'] = self::SENT_PENDING; } elseif ($Notify) { $Activity['Emailed'] = self::SENT_PENDING; } elseif ($SendEmail === FALSE) { $Activity['Emailed'] = self::SENT_ARCHIVE; } $Activity = $this->Save($Activity, $Preference); return GetValue('ActivityID', $Activity); }
php
public function Add($ActivityUserID, $ActivityType, $Story = NULL, $RegardingUserID = NULL, $CommentActivityID = NULL, $Route = NULL, $SendEmail = '') { static $ActivityTypes = array(); // Get the ActivityTypeID & see if this is a notification. $ActivityTypeRow = self::GetActivityType($ActivityType); if ($ActivityTypeRow !== FALSE) { $ActivityTypeID = $ActivityTypeRow['ActivityTypeID']; $Notify = (bool)$ActivityTypeRow['Notify']; } else { trigger_error(ErrorMessage(sprintf('Activity type could not be found: %s', $ActivityType), 'ActivityModel', 'Add'), E_USER_ERROR); } $Activity = array( 'ActivityUserID' => $ActivityUserID, 'ActivityType' => $ActivityType, 'Story' => $Story, 'RegardingUserID' => $RegardingUserID, 'Route' => $Route ); // Massage $SendEmail to allow for only sending an email. $QueueEmail = FALSE; if ($SendEmail === 'Only') { $SendEmail = ''; $AddActivity = FALSE; } else if ($SendEmail === 'QueueOnly') { $SendEmail = ''; $QueueEmail = TRUE; $AddActivity = TRUE; $Notify = TRUE; } else { $AddActivity = TRUE; } // If $SendEmail was FALSE or TRUE, let it override the $Notify setting. if ($SendEmail === FALSE || $SendEmail === TRUE) $Notify = $SendEmail; $Preference = FALSE; if (($ActivityTypeRow['Notify'] || !$ActivityTypeRow['Public']) && $RegardingUserID) { $Activity['NotifyUserID'] = $Activity['RegardingUserID']; $Preference = $ActivityType; } else { $Activity['NotifyUserID'] = self::NOTIFY_PUBLIC; } // Otherwise let the decision to email lie with the $Notify setting. if ($SendEmail == 'Force' || $Notify) { $Activity['Emailed'] = self::SENT_PENDING; } elseif ($Notify) { $Activity['Emailed'] = self::SENT_PENDING; } elseif ($SendEmail === FALSE) { $Activity['Emailed'] = self::SENT_ARCHIVE; } $Activity = $this->Save($Activity, $Preference); return GetValue('ActivityID', $Activity); }
[ "public", "function", "Add", "(", "$", "ActivityUserID", ",", "$", "ActivityType", ",", "$", "Story", "=", "NULL", ",", "$", "RegardingUserID", "=", "NULL", ",", "$", "CommentActivityID", "=", "NULL", ",", "$", "Route", "=", "NULL", ",", "$", "SendEmail"...
Add a new activity item. Getting reworked for 2.1 so I'm cheating and skipping params for now. -mlr @since 2.0.0 @access public @param int $ActivityUserID @param string $ActivityType @param string $Story @param int $RegardingUserID @param int $CommentActivityID @param string $Route @param mixed $SendEmail @return int ActivityID of item created.
[ "Add", "a", "new", "activity", "item", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.activitymodel.php#L579-L639
train