id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
19,900
steeffeen/FancyManiaLinks
FML/Script/Features/ControlScript.php
ControlScript.updateScriptEvents
protected function updateScriptEvents() { if (!$this->control || !ScriptLabel::isEventLabel($this->labelName)) { return $this; } if ($this->control instanceof Scriptable) { $this->control->setScriptEvents(true); } return $this; }
php
protected function updateScriptEvents() { if (!$this->control || !ScriptLabel::isEventLabel($this->labelName)) { return $this; } if ($this->control instanceof Scriptable) { $this->control->setScriptEvents(true); } return $this; }
[ "protected", "function", "updateScriptEvents", "(", ")", "{", "if", "(", "!", "$", "this", "->", "control", "||", "!", "ScriptLabel", "::", "isEventLabel", "(", "$", "this", "->", "labelName", ")", ")", "{", "return", "$", "this", ";", "}", "if", "(", "$", "this", "->", "control", "instanceof", "Scriptable", ")", "{", "$", "this", "->", "control", "->", "setScriptEvents", "(", "true", ")", ";", "}", "return", "$", "this", ";", "}" ]
Enable Script Events on the Control if needed @return static
[ "Enable", "Script", "Events", "on", "the", "Control", "if", "needed" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/ControlScript.php#L152-L161
19,901
steeffeen/FancyManiaLinks
FML/Script/Features/ControlScript.php
ControlScript.buildScriptText
protected function buildScriptText() { $controlId = Builder::escapeText($this->control->getId()); $scriptText = ''; $closeBlock = false; if (ScriptLabel::isEventLabel($this->labelName)) { $scriptText .= " if (Event.ControlId == {$controlId}) { declare Control <=> Event.Control;"; $closeBlock = true; } else { $scriptText .= " declare Control <=> Page.GetFirstChild({$controlId});"; } $class = $this->control->getManiaScriptClass(); $name = preg_replace('/^CMl/', '', $class, 1); $scriptText .= " declare {$name} <=> (Control as {$class}); "; $scriptText .= $this->scriptText . " "; if ($closeBlock) { $scriptText .= "}"; } return $scriptText; }
php
protected function buildScriptText() { $controlId = Builder::escapeText($this->control->getId()); $scriptText = ''; $closeBlock = false; if (ScriptLabel::isEventLabel($this->labelName)) { $scriptText .= " if (Event.ControlId == {$controlId}) { declare Control <=> Event.Control;"; $closeBlock = true; } else { $scriptText .= " declare Control <=> Page.GetFirstChild({$controlId});"; } $class = $this->control->getManiaScriptClass(); $name = preg_replace('/^CMl/', '', $class, 1); $scriptText .= " declare {$name} <=> (Control as {$class}); "; $scriptText .= $this->scriptText . " "; if ($closeBlock) { $scriptText .= "}"; } return $scriptText; }
[ "protected", "function", "buildScriptText", "(", ")", "{", "$", "controlId", "=", "Builder", "::", "escapeText", "(", "$", "this", "->", "control", "->", "getId", "(", ")", ")", ";", "$", "scriptText", "=", "''", ";", "$", "closeBlock", "=", "false", ";", "if", "(", "ScriptLabel", "::", "isEventLabel", "(", "$", "this", "->", "labelName", ")", ")", "{", "$", "scriptText", ".=", "\"\nif (Event.ControlId == {$controlId}) {\ndeclare Control <=> Event.Control;\"", ";", "$", "closeBlock", "=", "true", ";", "}", "else", "{", "$", "scriptText", ".=", "\"\ndeclare Control <=> Page.GetFirstChild({$controlId});\"", ";", "}", "$", "class", "=", "$", "this", "->", "control", "->", "getManiaScriptClass", "(", ")", ";", "$", "name", "=", "preg_replace", "(", "'/^CMl/'", ",", "''", ",", "$", "class", ",", "1", ")", ";", "$", "scriptText", ".=", "\"\ndeclare {$name} <=> (Control as {$class});\n\"", ";", "$", "scriptText", ".=", "$", "this", "->", "scriptText", ".", "\"\n\"", ";", "if", "(", "$", "closeBlock", ")", "{", "$", "scriptText", ".=", "\"}\"", ";", "}", "return", "$", "scriptText", ";", "}" ]
Build the script text for the Control @return string
[ "Build", "the", "script", "text", "for", "the", "Control" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/ControlScript.php#L178-L203
19,902
yuncms/framework
src/services/Path.php
Path.getCachePath
public function getCachePath(): string { $path = $this->getRuntimePath() . DIRECTORY_SEPARATOR . 'cache'; FileHelper::createDirectory($path); return $path; }
php
public function getCachePath(): string { $path = $this->getRuntimePath() . DIRECTORY_SEPARATOR . 'cache'; FileHelper::createDirectory($path); return $path; }
[ "public", "function", "getCachePath", "(", ")", ":", "string", "{", "$", "path", "=", "$", "this", "->", "getRuntimePath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "'cache'", ";", "FileHelper", "::", "createDirectory", "(", "$", "path", ")", ";", "return", "$", "path", ";", "}" ]
Returns the path to the file cache directory. This will be located at `@runtime/cache/` by default, but that can be overridden with the 'cachePath'. @return string @throws Exception
[ "Returns", "the", "path", "to", "the", "file", "cache", "directory", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/services/Path.php#L120-L125
19,903
digitalkaoz/versioneye-php
src/Client.php
Client.api
public function api($name) { $this->initializeClient($this->url, $this->client); $class = 'Rs\\VersionEye\\Api\\' . ucfirst($name); if (class_exists($class)) { return new $class($this->client); } else { throw new \InvalidArgumentException('unknown api "' . $name . '" requested'); } }
php
public function api($name) { $this->initializeClient($this->url, $this->client); $class = 'Rs\\VersionEye\\Api\\' . ucfirst($name); if (class_exists($class)) { return new $class($this->client); } else { throw new \InvalidArgumentException('unknown api "' . $name . '" requested'); } }
[ "public", "function", "api", "(", "$", "name", ")", "{", "$", "this", "->", "initializeClient", "(", "$", "this", "->", "url", ",", "$", "this", "->", "client", ")", ";", "$", "class", "=", "'Rs\\\\VersionEye\\\\Api\\\\'", ".", "ucfirst", "(", "$", "name", ")", ";", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "return", "new", "$", "class", "(", "$", "this", "->", "client", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'unknown api \"'", ".", "$", "name", ".", "'\" requested'", ")", ";", "}", "}" ]
returns an api. @param string $name @throws \InvalidArgumentException @return Api
[ "returns", "an", "api", "." ]
7b8eb9cdc83e01138dda0e709c07e3beb6aad136
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Client.php#L46-L57
19,904
digitalkaoz/versioneye-php
src/Client.php
Client.initializeClient
private function initializeClient($url, HttpClient $client = null) { if ($client) { return $this->client = $client; } return $this->client = $this->createDefaultHttpClient($url); }
php
private function initializeClient($url, HttpClient $client = null) { if ($client) { return $this->client = $client; } return $this->client = $this->createDefaultHttpClient($url); }
[ "private", "function", "initializeClient", "(", "$", "url", ",", "HttpClient", "$", "client", "=", "null", ")", "{", "if", "(", "$", "client", ")", "{", "return", "$", "this", "->", "client", "=", "$", "client", ";", "}", "return", "$", "this", "->", "client", "=", "$", "this", "->", "createDefaultHttpClient", "(", "$", "url", ")", ";", "}" ]
initializes the http client. @param string $url @param HttpClient $client @return HttpClient
[ "initializes", "the", "http", "client", "." ]
7b8eb9cdc83e01138dda0e709c07e3beb6aad136
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Client.php#L77-L84
19,905
Lansoweb/LosBase
src/LosBase/Service/Uuid.php
Uuid.generateVersion
private static function generateVersion($namespace, $name, $version) { if (!self::isValid($namespace)) { return false; } $nhex = str_replace(array('-', '{', '}'), '', $namespace); $nstr = ''; $len = strlen($nhex); for ($i = 0; $i < $len; $i += 2) { $nstr .= chr(hexdec($nhex[$i].$nhex[$i + 1])); } if ($version == 3) { $hash = md5($nstr.$name); $digit = 0x3000; } else { $hash = sha1($nstr.$name); $digit = 0x5000; } return sprintf('%08s-%04s-%04x-%04x-%12s', substr($hash, 0, 8), substr($hash, 8, 4), (hexdec(substr($hash, 12, 4)) & 0x0fff) | $digit, (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000, substr($hash, 20, 12) ); }
php
private static function generateVersion($namespace, $name, $version) { if (!self::isValid($namespace)) { return false; } $nhex = str_replace(array('-', '{', '}'), '', $namespace); $nstr = ''; $len = strlen($nhex); for ($i = 0; $i < $len; $i += 2) { $nstr .= chr(hexdec($nhex[$i].$nhex[$i + 1])); } if ($version == 3) { $hash = md5($nstr.$name); $digit = 0x3000; } else { $hash = sha1($nstr.$name); $digit = 0x5000; } return sprintf('%08s-%04s-%04x-%04x-%12s', substr($hash, 0, 8), substr($hash, 8, 4), (hexdec(substr($hash, 12, 4)) & 0x0fff) | $digit, (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000, substr($hash, 20, 12) ); }
[ "private", "static", "function", "generateVersion", "(", "$", "namespace", ",", "$", "name", ",", "$", "version", ")", "{", "if", "(", "!", "self", "::", "isValid", "(", "$", "namespace", ")", ")", "{", "return", "false", ";", "}", "$", "nhex", "=", "str_replace", "(", "array", "(", "'-'", ",", "'{'", ",", "'}'", ")", ",", "''", ",", "$", "namespace", ")", ";", "$", "nstr", "=", "''", ";", "$", "len", "=", "strlen", "(", "$", "nhex", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "len", ";", "$", "i", "+=", "2", ")", "{", "$", "nstr", ".=", "chr", "(", "hexdec", "(", "$", "nhex", "[", "$", "i", "]", ".", "$", "nhex", "[", "$", "i", "+", "1", "]", ")", ")", ";", "}", "if", "(", "$", "version", "==", "3", ")", "{", "$", "hash", "=", "md5", "(", "$", "nstr", ".", "$", "name", ")", ";", "$", "digit", "=", "0x3000", ";", "}", "else", "{", "$", "hash", "=", "sha1", "(", "$", "nstr", ".", "$", "name", ")", ";", "$", "digit", "=", "0x5000", ";", "}", "return", "sprintf", "(", "'%08s-%04s-%04x-%04x-%12s'", ",", "substr", "(", "$", "hash", ",", "0", ",", "8", ")", ",", "substr", "(", "$", "hash", ",", "8", ",", "4", ")", ",", "(", "hexdec", "(", "substr", "(", "$", "hash", ",", "12", ",", "4", ")", ")", "&", "0x0fff", ")", "|", "$", "digit", ",", "(", "hexdec", "(", "substr", "(", "$", "hash", ",", "16", ",", "4", ")", ")", "&", "0x3fff", ")", "|", "0x8000", ",", "substr", "(", "$", "hash", ",", "20", ",", "12", ")", ")", ";", "}" ]
Generates v3 or v5 UUIDs. @param string $namespace @param string $name @param int $version @return bool|string
[ "Generates", "v3", "or", "v5", "UUIDs", "." ]
90e18a53d29c1bd841c149dca43aa365eecc656d
https://github.com/Lansoweb/LosBase/blob/90e18a53d29c1bd841c149dca43aa365eecc656d/src/LosBase/Service/Uuid.php#L30-L59
19,906
nyeholt/silverstripe-external-content
thirdparty/Zend/Validate/File/Exists.php
Zend_Validate_File_Exists.addDirectory
public function addDirectory($directory) { $directories = $this->getDirectory(true); if (is_string($directory)) { $directory = explode(',', $directory); } else if (!is_array($directory)) { require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } foreach ($directory as $content) { if (empty($content) || !is_string($content)) { continue; } $directories[] = trim($content); } $directories = array_unique($directories); // Sanity check to ensure no empty values foreach ($directories as $key => $dir) { if (empty($dir)) { unset($directories[$key]); } } $this->_directory = implode(',', $directories); return $this; }
php
public function addDirectory($directory) { $directories = $this->getDirectory(true); if (is_string($directory)) { $directory = explode(',', $directory); } else if (!is_array($directory)) { require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } foreach ($directory as $content) { if (empty($content) || !is_string($content)) { continue; } $directories[] = trim($content); } $directories = array_unique($directories); // Sanity check to ensure no empty values foreach ($directories as $key => $dir) { if (empty($dir)) { unset($directories[$key]); } } $this->_directory = implode(',', $directories); return $this; }
[ "public", "function", "addDirectory", "(", "$", "directory", ")", "{", "$", "directories", "=", "$", "this", "->", "getDirectory", "(", "true", ")", ";", "if", "(", "is_string", "(", "$", "directory", ")", ")", "{", "$", "directory", "=", "explode", "(", "','", ",", "$", "directory", ")", ";", "}", "else", "if", "(", "!", "is_array", "(", "$", "directory", ")", ")", "{", "require_once", "'Zend/Validate/Exception.php'", ";", "throw", "new", "Zend_Validate_Exception", "(", "'Invalid options to validator provided'", ")", ";", "}", "foreach", "(", "$", "directory", "as", "$", "content", ")", "{", "if", "(", "empty", "(", "$", "content", ")", "||", "!", "is_string", "(", "$", "content", ")", ")", "{", "continue", ";", "}", "$", "directories", "[", "]", "=", "trim", "(", "$", "content", ")", ";", "}", "$", "directories", "=", "array_unique", "(", "$", "directories", ")", ";", "// Sanity check to ensure no empty values", "foreach", "(", "$", "directories", "as", "$", "key", "=>", "$", "dir", ")", "{", "if", "(", "empty", "(", "$", "dir", ")", ")", "{", "unset", "(", "$", "directories", "[", "$", "key", "]", ")", ";", "}", "}", "$", "this", "->", "_directory", "=", "implode", "(", "','", ",", "$", "directories", ")", ";", "return", "$", "this", ";", "}" ]
Adds the file directory which will be checked @param string|array $directory The directory to add for validation @return Zend_Validate_File_Extension Provides a fluent interface
[ "Adds", "the", "file", "directory", "which", "will", "be", "checked" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/File/Exists.php#L118-L148
19,907
limenet/deploy
src/limenet/Deploy/Deploy.php
Deploy.updateCode
protected function updateCode() : array { $output = []; $returnValue = 0; $updateMaster = 'ls'; // dummy if ($this->getBranch() !== 'master') { $updateMaster = ' git checkout master && git pull && git checkout '.$this->getBranch().' '; } $commands = [ 'git reset --hard HEAD', 'git pull', $updateMaster, 'composer install --no-dev', 'yarn install --production', ]; foreach ($commands as $command) { exec('cd '.$this->getBasepath().' && '.$command, $output, $returnValue); } return [ 'output' => $output, 'returnValue' => $returnValue, ]; }
php
protected function updateCode() : array { $output = []; $returnValue = 0; $updateMaster = 'ls'; // dummy if ($this->getBranch() !== 'master') { $updateMaster = ' git checkout master && git pull && git checkout '.$this->getBranch().' '; } $commands = [ 'git reset --hard HEAD', 'git pull', $updateMaster, 'composer install --no-dev', 'yarn install --production', ]; foreach ($commands as $command) { exec('cd '.$this->getBasepath().' && '.$command, $output, $returnValue); } return [ 'output' => $output, 'returnValue' => $returnValue, ]; }
[ "protected", "function", "updateCode", "(", ")", ":", "array", "{", "$", "output", "=", "[", "]", ";", "$", "returnValue", "=", "0", ";", "$", "updateMaster", "=", "'ls'", ";", "// dummy", "if", "(", "$", "this", "->", "getBranch", "(", ")", "!==", "'master'", ")", "{", "$", "updateMaster", "=", "' git checkout master && git pull && git checkout '", ".", "$", "this", "->", "getBranch", "(", ")", ".", "' '", ";", "}", "$", "commands", "=", "[", "'git reset --hard HEAD'", ",", "'git pull'", ",", "$", "updateMaster", ",", "'composer install --no-dev'", ",", "'yarn install --production'", ",", "]", ";", "foreach", "(", "$", "commands", "as", "$", "command", ")", "{", "exec", "(", "'cd '", ".", "$", "this", "->", "getBasepath", "(", ")", ".", "' && '", ".", "$", "command", ",", "$", "output", ",", "$", "returnValue", ")", ";", "}", "return", "[", "'output'", "=>", "$", "output", ",", "'returnValue'", "=>", "$", "returnValue", ",", "]", ";", "}" ]
Executes the actual deployment commands. @return array
[ "Executes", "the", "actual", "deployment", "commands", "." ]
7c403b69f3221fd159c528f7a6a59f481765a2da
https://github.com/limenet/deploy/blob/7c403b69f3221fd159c528f7a6a59f481765a2da/src/limenet/Deploy/Deploy.php#L178-L205
19,908
periaptio/empress-generator
src/Syntax/AddForeignKeysToTable.php
AddForeignKeysToTable.getItem
protected function getItem($foreignKey) { $value = $foreignKey['field']; if (! empty($foreignKey['name'])) { $value .= "', '". $foreignKey['name']; } $output = sprintf( "\$table->foreign('%s')->references('%s')->on('%s')", $value, $foreignKey['references'], $foreignKey['on'] ); if ($foreignKey['onUpdate']) { $output .= sprintf("->onUpdate('%s')", $foreignKey['onUpdate']); } if ($foreignKey['onDelete']) { $output .= sprintf("->onDelete('%s')", $foreignKey['onDelete']); } if (isset($foreignKey['decorators'])) { $output .= $this->addDecorators($foreignKey['decorators']); } return $output . ';'; }
php
protected function getItem($foreignKey) { $value = $foreignKey['field']; if (! empty($foreignKey['name'])) { $value .= "', '". $foreignKey['name']; } $output = sprintf( "\$table->foreign('%s')->references('%s')->on('%s')", $value, $foreignKey['references'], $foreignKey['on'] ); if ($foreignKey['onUpdate']) { $output .= sprintf("->onUpdate('%s')", $foreignKey['onUpdate']); } if ($foreignKey['onDelete']) { $output .= sprintf("->onDelete('%s')", $foreignKey['onDelete']); } if (isset($foreignKey['decorators'])) { $output .= $this->addDecorators($foreignKey['decorators']); } return $output . ';'; }
[ "protected", "function", "getItem", "(", "$", "foreignKey", ")", "{", "$", "value", "=", "$", "foreignKey", "[", "'field'", "]", ";", "if", "(", "!", "empty", "(", "$", "foreignKey", "[", "'name'", "]", ")", ")", "{", "$", "value", ".=", "\"', '\"", ".", "$", "foreignKey", "[", "'name'", "]", ";", "}", "$", "output", "=", "sprintf", "(", "\"\\$table->foreign('%s')->references('%s')->on('%s')\"", ",", "$", "value", ",", "$", "foreignKey", "[", "'references'", "]", ",", "$", "foreignKey", "[", "'on'", "]", ")", ";", "if", "(", "$", "foreignKey", "[", "'onUpdate'", "]", ")", "{", "$", "output", ".=", "sprintf", "(", "\"->onUpdate('%s')\"", ",", "$", "foreignKey", "[", "'onUpdate'", "]", ")", ";", "}", "if", "(", "$", "foreignKey", "[", "'onDelete'", "]", ")", "{", "$", "output", ".=", "sprintf", "(", "\"->onDelete('%s')\"", ",", "$", "foreignKey", "[", "'onDelete'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "foreignKey", "[", "'decorators'", "]", ")", ")", "{", "$", "output", ".=", "$", "this", "->", "addDecorators", "(", "$", "foreignKey", "[", "'decorators'", "]", ")", ";", "}", "return", "$", "output", ".", "';'", ";", "}" ]
Return string for adding a foreign key @param array $foreignKey @return string
[ "Return", "string", "for", "adding", "a", "foreign", "key" ]
749fb4b12755819e9c97377ebfb446ee0822168a
https://github.com/periaptio/empress-generator/blob/749fb4b12755819e9c97377ebfb446ee0822168a/src/Syntax/AddForeignKeysToTable.php#L16-L38
19,909
jinexus-framework/jinexus-mvc
src/Application/AbstractApplication.php
AbstractApplication.error
public static function error($number, $string, $file, $line) { throw new \ErrorException($string, 0, $number, $file, $line); }
php
public static function error($number, $string, $file, $line) { throw new \ErrorException($string, 0, $number, $file, $line); }
[ "public", "static", "function", "error", "(", "$", "number", ",", "$", "string", ",", "$", "file", ",", "$", "line", ")", "{", "throw", "new", "\\", "ErrorException", "(", "$", "string", ",", "0", ",", "$", "number", ",", "$", "file", ",", "$", "line", ")", ";", "}" ]
Convert errors to \ErrorException instances @param int $number @param string $string @param string $file @param int $line @throws \ErrorException
[ "Convert", "errors", "to", "\\", "ErrorException", "instances" ]
63937fecea4bc927b1ac9669fee5cf50278d28d3
https://github.com/jinexus-framework/jinexus-mvc/blob/63937fecea4bc927b1ac9669fee5cf50278d28d3/src/Application/AbstractApplication.php#L156-L159
19,910
ClanCats/Core
src/classes/CCTheme.php
CCTheme.create
public static function create( $file = null, $data = null, $encode = false ) { $view = parent::create( static::view_namespace().'::'.$file, $data, $encode ); // set the asset holder path \CCAsset::holder( 'theme' )->path = static::public_namespace(); // set the vendor path \CCAsset::holder( 'vendor' )->path = 'assets/vendor/'; // you may ask why not just return the parent::create(bla bla.. directly? // i actually wanted to do something with that var view. So if you'r still // able to read this i completly forgot it. return $view; }
php
public static function create( $file = null, $data = null, $encode = false ) { $view = parent::create( static::view_namespace().'::'.$file, $data, $encode ); // set the asset holder path \CCAsset::holder( 'theme' )->path = static::public_namespace(); // set the vendor path \CCAsset::holder( 'vendor' )->path = 'assets/vendor/'; // you may ask why not just return the parent::create(bla bla.. directly? // i actually wanted to do something with that var view. So if you'r still // able to read this i completly forgot it. return $view; }
[ "public", "static", "function", "create", "(", "$", "file", "=", "null", ",", "$", "data", "=", "null", ",", "$", "encode", "=", "false", ")", "{", "$", "view", "=", "parent", "::", "create", "(", "static", "::", "view_namespace", "(", ")", ".", "'::'", ".", "$", "file", ",", "$", "data", ",", "$", "encode", ")", ";", "// set the asset holder path", "\\", "CCAsset", "::", "holder", "(", "'theme'", ")", "->", "path", "=", "static", "::", "public_namespace", "(", ")", ";", "// set the vendor path", "\\", "CCAsset", "::", "holder", "(", "'vendor'", ")", "->", "path", "=", "'assets/vendor/'", ";", "// you may ask why not just return the parent::create(bla bla.. directly?", "// i actually wanted to do something with that var view. So if you'r still", "// able to read this i completly forgot it.", "return", "$", "view", ";", "}" ]
theme creator returns a new view instance @param string $file @param array $data @param bool $encode @return CCView
[ "theme", "creator", "returns", "a", "new", "view", "instance" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCTheme.php#L47-L61
19,911
simple-php-mvc/simple-php-mvc
src/MVC/Server/Response.php
Response._parse
protected function _parse($response) { $defaults = array( 'body' => '', 'headers' => array('Content-Type: text/html; charset=utf-8'), 'status' => 200 ); if ( is_array($response) ) { $response += $defaults; } elseif ( is_string($response) ) { $defaults['body'] = $response; $response = $defaults; } else { throw new \LogicException('Response can\'t be NULL.'); } return $response; }
php
protected function _parse($response) { $defaults = array( 'body' => '', 'headers' => array('Content-Type: text/html; charset=utf-8'), 'status' => 200 ); if ( is_array($response) ) { $response += $defaults; } elseif ( is_string($response) ) { $defaults['body'] = $response; $response = $defaults; } else { throw new \LogicException('Response can\'t be NULL.'); } return $response; }
[ "protected", "function", "_parse", "(", "$", "response", ")", "{", "$", "defaults", "=", "array", "(", "'body'", "=>", "''", ",", "'headers'", "=>", "array", "(", "'Content-Type: text/html; charset=utf-8'", ")", ",", "'status'", "=>", "200", ")", ";", "if", "(", "is_array", "(", "$", "response", ")", ")", "{", "$", "response", "+=", "$", "defaults", ";", "}", "elseif", "(", "is_string", "(", "$", "response", ")", ")", "{", "$", "defaults", "[", "'body'", "]", "=", "$", "response", ";", "$", "response", "=", "$", "defaults", ";", "}", "else", "{", "throw", "new", "\\", "LogicException", "(", "'Response can\\'t be NULL.'", ")", ";", "}", "return", "$", "response", ";", "}" ]
Parses a response. @access protected @param mixed $response The response to be parsed. Can be an array containing 'body', 'headers', and/or 'status' keys, or a string which will be used as the body of the response. Note that the headers must be well-formed HTTP headers, and the status must be an integer (i.e., the one associated with the HTTP status code). @return array
[ "Parses", "a", "response", "." ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Server/Response.php#L107-L123
19,912
gerritdrost/phenum
src/GerritDrost/Lib/Enum/Enum.php
Enum.byName
public static final function byName($enumName) { $instances = self::getInstances(get_called_class()); return isset($instances[$enumName]) ? $instances[$enumName] : null; }
php
public static final function byName($enumName) { $instances = self::getInstances(get_called_class()); return isset($instances[$enumName]) ? $instances[$enumName] : null; }
[ "public", "static", "final", "function", "byName", "(", "$", "enumName", ")", "{", "$", "instances", "=", "self", "::", "getInstances", "(", "get_called_class", "(", ")", ")", ";", "return", "isset", "(", "$", "instances", "[", "$", "enumName", "]", ")", "?", "$", "instances", "[", "$", "enumName", "]", ":", "null", ";", "}" ]
Returns the enum value instance representing the provided const name or null when the const name is not present in the enum. @param string $enumName @return Enum
[ "Returns", "the", "enum", "value", "instance", "representing", "the", "provided", "const", "name", "or", "null", "when", "the", "const", "name", "is", "not", "present", "in", "the", "enum", "." ]
935ba4911d0591dea9a2c94a1c1ab5babeec92cb
https://github.com/gerritdrost/phenum/blob/935ba4911d0591dea9a2c94a1c1ab5babeec92cb/src/GerritDrost/Lib/Enum/Enum.php#L79-L86
19,913
gerritdrost/phenum
src/GerritDrost/Lib/Enum/Enum.php
Enum.&
private final static function &getInstances($fqcn) { if (!isset(self::$instances[$fqcn])) { self::loadClass($fqcn); } return self::$instances[$fqcn]; }
php
private final static function &getInstances($fqcn) { if (!isset(self::$instances[$fqcn])) { self::loadClass($fqcn); } return self::$instances[$fqcn]; }
[ "private", "final", "static", "function", "&", "getInstances", "(", "$", "fqcn", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instances", "[", "$", "fqcn", "]", ")", ")", "{", "self", "::", "loadClass", "(", "$", "fqcn", ")", ";", "}", "return", "self", "::", "$", "instances", "[", "$", "fqcn", "]", ";", "}" ]
Returns the array of all value singletons of one Enum class @param string $fqcn FQCN of the enum @return Enum[]
[ "Returns", "the", "array", "of", "all", "value", "singletons", "of", "one", "Enum", "class" ]
935ba4911d0591dea9a2c94a1c1ab5babeec92cb
https://github.com/gerritdrost/phenum/blob/935ba4911d0591dea9a2c94a1c1ab5babeec92cb/src/GerritDrost/Lib/Enum/Enum.php#L141-L148
19,914
gerritdrost/phenum
src/GerritDrost/Lib/Enum/Enum.php
Enum.loadClass
private final static function loadClass($fqcn) { $reflectionClass = new ReflectionClass($fqcn); $constants = $reflectionClass->getConstants(); foreach ($constants as $name => $value) { $instance = new $fqcn($fqcn, $name, $value); /* @var $instance Enum */ if (is_callable([$instance, '__initEnum'])) { $instance->__initEnum(); } $instanceConstructorName = '__' . $name; if (is_callable([$instance, $instanceConstructorName])) { $instance->$instanceConstructorName(); } if (!isset(self::$instances[$fqcn])) { self::$instances[$fqcn] = []; } self::$instances[$fqcn][$name] = $instance; } }
php
private final static function loadClass($fqcn) { $reflectionClass = new ReflectionClass($fqcn); $constants = $reflectionClass->getConstants(); foreach ($constants as $name => $value) { $instance = new $fqcn($fqcn, $name, $value); /* @var $instance Enum */ if (is_callable([$instance, '__initEnum'])) { $instance->__initEnum(); } $instanceConstructorName = '__' . $name; if (is_callable([$instance, $instanceConstructorName])) { $instance->$instanceConstructorName(); } if (!isset(self::$instances[$fqcn])) { self::$instances[$fqcn] = []; } self::$instances[$fqcn][$name] = $instance; } }
[ "private", "final", "static", "function", "loadClass", "(", "$", "fqcn", ")", "{", "$", "reflectionClass", "=", "new", "ReflectionClass", "(", "$", "fqcn", ")", ";", "$", "constants", "=", "$", "reflectionClass", "->", "getConstants", "(", ")", ";", "foreach", "(", "$", "constants", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "instance", "=", "new", "$", "fqcn", "(", "$", "fqcn", ",", "$", "name", ",", "$", "value", ")", ";", "/* @var $instance Enum */", "if", "(", "is_callable", "(", "[", "$", "instance", ",", "'__initEnum'", "]", ")", ")", "{", "$", "instance", "->", "__initEnum", "(", ")", ";", "}", "$", "instanceConstructorName", "=", "'__'", ".", "$", "name", ";", "if", "(", "is_callable", "(", "[", "$", "instance", ",", "$", "instanceConstructorName", "]", ")", ")", "{", "$", "instance", "->", "$", "instanceConstructorName", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "self", "::", "$", "instances", "[", "$", "fqcn", "]", ")", ")", "{", "self", "::", "$", "instances", "[", "$", "fqcn", "]", "=", "[", "]", ";", "}", "self", "::", "$", "instances", "[", "$", "fqcn", "]", "[", "$", "name", "]", "=", "$", "instance", ";", "}", "}" ]
Uses reflection to load and cache all value singletons of the class represented by the fqcn. @param string $fqcn FQCN of the enum
[ "Uses", "reflection", "to", "load", "and", "cache", "all", "value", "singletons", "of", "the", "class", "represented", "by", "the", "fqcn", "." ]
935ba4911d0591dea9a2c94a1c1ab5babeec92cb
https://github.com/gerritdrost/phenum/blob/935ba4911d0591dea9a2c94a1c1ab5babeec92cb/src/GerritDrost/Lib/Enum/Enum.php#L155-L179
19,915
redaigbaria/oauth2
src/Grant/AbstractGrant.php
AbstractGrant.validateScopes
public function validateScopes($scopeParam = '', ClientEntity $client, $redirectUri = null) { $scopesList = explode($this->server->getScopeDelimiter(), $scopeParam); for ($i = 0; $i < count($scopesList); $i++) { $scopesList[$i] = trim($scopesList[$i]); if ($scopesList[$i] === '') { unset($scopesList[$i]); // Remove any junk scopes } } if ( $this->server->scopeParamRequired() === true && $this->server->getDefaultScope() === null && count($scopesList) === 0 ) { throw new Exception\InvalidRequestException('scope'); } elseif (count($scopesList) === 0 && $this->server->getDefaultScope() !== null) { if (is_array($this->server->getDefaultScope())) { $scopesList = $this->server->getDefaultScope(); } else { $scopesList = [0 => $this->server->getDefaultScope()]; } } $scopes = []; foreach ($scopesList as $scopeItem) { $scope = $this->server->getScopeStorage()->get( $scopeItem, $this->getIdentifier(), $client->getId() ); if (($scope instanceof ScopeEntity) === false) { throw new Exception\InvalidScopeException($scopeItem, $redirectUri); } $scopes[$scope->getId()] = $scope; } return $scopes; }
php
public function validateScopes($scopeParam = '', ClientEntity $client, $redirectUri = null) { $scopesList = explode($this->server->getScopeDelimiter(), $scopeParam); for ($i = 0; $i < count($scopesList); $i++) { $scopesList[$i] = trim($scopesList[$i]); if ($scopesList[$i] === '') { unset($scopesList[$i]); // Remove any junk scopes } } if ( $this->server->scopeParamRequired() === true && $this->server->getDefaultScope() === null && count($scopesList) === 0 ) { throw new Exception\InvalidRequestException('scope'); } elseif (count($scopesList) === 0 && $this->server->getDefaultScope() !== null) { if (is_array($this->server->getDefaultScope())) { $scopesList = $this->server->getDefaultScope(); } else { $scopesList = [0 => $this->server->getDefaultScope()]; } } $scopes = []; foreach ($scopesList as $scopeItem) { $scope = $this->server->getScopeStorage()->get( $scopeItem, $this->getIdentifier(), $client->getId() ); if (($scope instanceof ScopeEntity) === false) { throw new Exception\InvalidScopeException($scopeItem, $redirectUri); } $scopes[$scope->getId()] = $scope; } return $scopes; }
[ "public", "function", "validateScopes", "(", "$", "scopeParam", "=", "''", ",", "ClientEntity", "$", "client", ",", "$", "redirectUri", "=", "null", ")", "{", "$", "scopesList", "=", "explode", "(", "$", "this", "->", "server", "->", "getScopeDelimiter", "(", ")", ",", "$", "scopeParam", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "scopesList", ")", ";", "$", "i", "++", ")", "{", "$", "scopesList", "[", "$", "i", "]", "=", "trim", "(", "$", "scopesList", "[", "$", "i", "]", ")", ";", "if", "(", "$", "scopesList", "[", "$", "i", "]", "===", "''", ")", "{", "unset", "(", "$", "scopesList", "[", "$", "i", "]", ")", ";", "// Remove any junk scopes", "}", "}", "if", "(", "$", "this", "->", "server", "->", "scopeParamRequired", "(", ")", "===", "true", "&&", "$", "this", "->", "server", "->", "getDefaultScope", "(", ")", "===", "null", "&&", "count", "(", "$", "scopesList", ")", "===", "0", ")", "{", "throw", "new", "Exception", "\\", "InvalidRequestException", "(", "'scope'", ")", ";", "}", "elseif", "(", "count", "(", "$", "scopesList", ")", "===", "0", "&&", "$", "this", "->", "server", "->", "getDefaultScope", "(", ")", "!==", "null", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "server", "->", "getDefaultScope", "(", ")", ")", ")", "{", "$", "scopesList", "=", "$", "this", "->", "server", "->", "getDefaultScope", "(", ")", ";", "}", "else", "{", "$", "scopesList", "=", "[", "0", "=>", "$", "this", "->", "server", "->", "getDefaultScope", "(", ")", "]", ";", "}", "}", "$", "scopes", "=", "[", "]", ";", "foreach", "(", "$", "scopesList", "as", "$", "scopeItem", ")", "{", "$", "scope", "=", "$", "this", "->", "server", "->", "getScopeStorage", "(", ")", "->", "get", "(", "$", "scopeItem", ",", "$", "this", "->", "getIdentifier", "(", ")", ",", "$", "client", "->", "getId", "(", ")", ")", ";", "if", "(", "(", "$", "scope", "instanceof", "ScopeEntity", ")", "===", "false", ")", "{", "throw", "new", "Exception", "\\", "InvalidScopeException", "(", "$", "scopeItem", ",", "$", "redirectUri", ")", ";", "}", "$", "scopes", "[", "$", "scope", "->", "getId", "(", ")", "]", "=", "$", "scope", ";", "}", "return", "$", "scopes", ";", "}" ]
Given a list of scopes, validate them and return an array of Scope entities @param string $scopeParam A string of scopes (e.g. "profile email birthday") @param \League\OAuth2\Server\Entity\ClientEntity $client Client entity @param string|null $redirectUri The redirect URI to return the user to @return \League\OAuth2\Server\Entity\ScopeEntity[] @throws \League\OAuth2\Server\Exception\InvalidScopeException If scope is invalid, or no scopes passed when required @throws
[ "Given", "a", "list", "of", "scopes", "validate", "them", "and", "return", "an", "array", "of", "Scope", "entities" ]
54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Grant/AbstractGrant.php#L135-L177
19,916
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsQuery.php
BaseSystemSettingsQuery.create
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof SystemSettingsQuery) { return $criteria; } $query = new SystemSettingsQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
php
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof SystemSettingsQuery) { return $criteria; } $query = new SystemSettingsQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
[ "public", "static", "function", "create", "(", "$", "modelAlias", "=", "null", ",", "$", "criteria", "=", "null", ")", "{", "if", "(", "$", "criteria", "instanceof", "SystemSettingsQuery", ")", "{", "return", "$", "criteria", ";", "}", "$", "query", "=", "new", "SystemSettingsQuery", "(", "null", ",", "null", ",", "$", "modelAlias", ")", ";", "if", "(", "$", "criteria", "instanceof", "Criteria", ")", "{", "$", "query", "->", "mergeWith", "(", "$", "criteria", ")", ";", "}", "return", "$", "query", ";", "}" ]
Returns a new SystemSettingsQuery object. @param string $modelAlias The alias of a model in the query @param SystemSettingsQuery|Criteria $criteria Optional Criteria to build the query from @return SystemSettingsQuery
[ "Returns", "a", "new", "SystemSettingsQuery", "object", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsQuery.php#L68-L80
19,917
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsQuery.php
BaseSystemSettingsQuery.filterByKey
public function filterByKey($key = null, $comparison = null) { if (null === $comparison) { if (is_array($key)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $key)) { $key = str_replace('*', '%', $key); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(SystemSettingsPeer::KEY, $key, $comparison); }
php
public function filterByKey($key = null, $comparison = null) { if (null === $comparison) { if (is_array($key)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $key)) { $key = str_replace('*', '%', $key); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(SystemSettingsPeer::KEY, $key, $comparison); }
[ "public", "function", "filterByKey", "(", "$", "key", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "key", ")", ")", "{", "$", "key", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "key", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "SystemSettingsPeer", "::", "KEY", ",", "$", "key", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the key column Example usage: <code> $query->filterByKey('fooValue'); // WHERE key = 'fooValue' $query->filterByKey('%fooValue%'); // WHERE key LIKE '%fooValue%' </code> @param string $key The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return SystemSettingsQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "key", "column" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsQuery.php#L290-L302
19,918
monthly-cloud/monthly-sdk-php
src/Builder.php
Builder.buildUrl
public function buildUrl() { $url = $this->getApiUrl(); if ($endpoint = $this->getEndpoint()) { $url .= $endpoint; } if ($id = $this->getId()) { $url .= '/'.$id; } $parameters = []; if ($include = $this->getInclude()) { if (is_array($include)) { $include = implode(',', $include); } $parameters['include'] = $include; } if ($filters = $this->getFilters()) { if (!empty($filters)) { $parameters['filter'] = $filters; } } if ($pageSize = $this->getPageSize()) { if (!empty($pageSize)) { $parameters['page'] = ['size' => $pageSize]; } } if ($sort = $this->getSort()) { if (!empty($sort)) { $parameters['sort'] = $sort; } } if ($parameters) { $url .= '?'.http_build_query($parameters); } return $url; }
php
public function buildUrl() { $url = $this->getApiUrl(); if ($endpoint = $this->getEndpoint()) { $url .= $endpoint; } if ($id = $this->getId()) { $url .= '/'.$id; } $parameters = []; if ($include = $this->getInclude()) { if (is_array($include)) { $include = implode(',', $include); } $parameters['include'] = $include; } if ($filters = $this->getFilters()) { if (!empty($filters)) { $parameters['filter'] = $filters; } } if ($pageSize = $this->getPageSize()) { if (!empty($pageSize)) { $parameters['page'] = ['size' => $pageSize]; } } if ($sort = $this->getSort()) { if (!empty($sort)) { $parameters['sort'] = $sort; } } if ($parameters) { $url .= '?'.http_build_query($parameters); } return $url; }
[ "public", "function", "buildUrl", "(", ")", "{", "$", "url", "=", "$", "this", "->", "getApiUrl", "(", ")", ";", "if", "(", "$", "endpoint", "=", "$", "this", "->", "getEndpoint", "(", ")", ")", "{", "$", "url", ".=", "$", "endpoint", ";", "}", "if", "(", "$", "id", "=", "$", "this", "->", "getId", "(", ")", ")", "{", "$", "url", ".=", "'/'", ".", "$", "id", ";", "}", "$", "parameters", "=", "[", "]", ";", "if", "(", "$", "include", "=", "$", "this", "->", "getInclude", "(", ")", ")", "{", "if", "(", "is_array", "(", "$", "include", ")", ")", "{", "$", "include", "=", "implode", "(", "','", ",", "$", "include", ")", ";", "}", "$", "parameters", "[", "'include'", "]", "=", "$", "include", ";", "}", "if", "(", "$", "filters", "=", "$", "this", "->", "getFilters", "(", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "filters", ")", ")", "{", "$", "parameters", "[", "'filter'", "]", "=", "$", "filters", ";", "}", "}", "if", "(", "$", "pageSize", "=", "$", "this", "->", "getPageSize", "(", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "pageSize", ")", ")", "{", "$", "parameters", "[", "'page'", "]", "=", "[", "'size'", "=>", "$", "pageSize", "]", ";", "}", "}", "if", "(", "$", "sort", "=", "$", "this", "->", "getSort", "(", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "sort", ")", ")", "{", "$", "parameters", "[", "'sort'", "]", "=", "$", "sort", ";", "}", "}", "if", "(", "$", "parameters", ")", "{", "$", "url", ".=", "'?'", ".", "http_build_query", "(", "$", "parameters", ")", ";", "}", "return", "$", "url", ";", "}" ]
Build api call url. @return string
[ "Build", "api", "call", "url", "." ]
88b9d2bb346344495346a42043108627f648a793
https://github.com/monthly-cloud/monthly-sdk-php/blob/88b9d2bb346344495346a42043108627f648a793/src/Builder.php#L207-L242
19,919
monthly-cloud/monthly-sdk-php
src/Builder.php
Builder.httpGetRequest
public function httpGetRequest($url) { // Check for cache hit. if ($this->useCache()) { $cache = $this->getCache(); if ($response = $cache->get($url)) { return $response; } } if (empty($this->client)) { $this->client = new Client(['verify' => false]); } $this->response = $this->client->request( 'GET', $url, ['headers' => $this->getHeaders()] ); $response = json_decode($this->response->getBody()); if (!empty($cache)) { $cache->put($url, $response, $this->getCacheTtl()); } return $response; }
php
public function httpGetRequest($url) { // Check for cache hit. if ($this->useCache()) { $cache = $this->getCache(); if ($response = $cache->get($url)) { return $response; } } if (empty($this->client)) { $this->client = new Client(['verify' => false]); } $this->response = $this->client->request( 'GET', $url, ['headers' => $this->getHeaders()] ); $response = json_decode($this->response->getBody()); if (!empty($cache)) { $cache->put($url, $response, $this->getCacheTtl()); } return $response; }
[ "public", "function", "httpGetRequest", "(", "$", "url", ")", "{", "// Check for cache hit.", "if", "(", "$", "this", "->", "useCache", "(", ")", ")", "{", "$", "cache", "=", "$", "this", "->", "getCache", "(", ")", ";", "if", "(", "$", "response", "=", "$", "cache", "->", "get", "(", "$", "url", ")", ")", "{", "return", "$", "response", ";", "}", "}", "if", "(", "empty", "(", "$", "this", "->", "client", ")", ")", "{", "$", "this", "->", "client", "=", "new", "Client", "(", "[", "'verify'", "=>", "false", "]", ")", ";", "}", "$", "this", "->", "response", "=", "$", "this", "->", "client", "->", "request", "(", "'GET'", ",", "$", "url", ",", "[", "'headers'", "=>", "$", "this", "->", "getHeaders", "(", ")", "]", ")", ";", "$", "response", "=", "json_decode", "(", "$", "this", "->", "response", "->", "getBody", "(", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "cache", ")", ")", "{", "$", "cache", "->", "put", "(", "$", "url", ",", "$", "response", ",", "$", "this", "->", "getCacheTtl", "(", ")", ")", ";", "}", "return", "$", "response", ";", "}" ]
Make a GET request and respond with json decoded to array. @param string $url @return array
[ "Make", "a", "GET", "request", "and", "respond", "with", "json", "decoded", "to", "array", "." ]
88b9d2bb346344495346a42043108627f648a793
https://github.com/monthly-cloud/monthly-sdk-php/blob/88b9d2bb346344495346a42043108627f648a793/src/Builder.php#L265-L292
19,920
monthly-cloud/monthly-sdk-php
src/Builder.php
Builder.httpPostRequest
public function httpPostRequest($url, $parameters) { if (empty($this->client)) { $this->client = new Client(['verify' => false]); } $this->response = $this->client->request( 'POST', $url, [ 'headers' => $this->getHeaders(), 'json' => $parameters ] ); $response = json_decode($this->response->getBody()); return $response; }
php
public function httpPostRequest($url, $parameters) { if (empty($this->client)) { $this->client = new Client(['verify' => false]); } $this->response = $this->client->request( 'POST', $url, [ 'headers' => $this->getHeaders(), 'json' => $parameters ] ); $response = json_decode($this->response->getBody()); return $response; }
[ "public", "function", "httpPostRequest", "(", "$", "url", ",", "$", "parameters", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "client", ")", ")", "{", "$", "this", "->", "client", "=", "new", "Client", "(", "[", "'verify'", "=>", "false", "]", ")", ";", "}", "$", "this", "->", "response", "=", "$", "this", "->", "client", "->", "request", "(", "'POST'", ",", "$", "url", ",", "[", "'headers'", "=>", "$", "this", "->", "getHeaders", "(", ")", ",", "'json'", "=>", "$", "parameters", "]", ")", ";", "$", "response", "=", "json_decode", "(", "$", "this", "->", "response", "->", "getBody", "(", ")", ")", ";", "return", "$", "response", ";", "}" ]
Make a POST request and respond with json decoded to array. @param string $url @param array $url @return array
[ "Make", "a", "POST", "request", "and", "respond", "with", "json", "decoded", "to", "array", "." ]
88b9d2bb346344495346a42043108627f648a793
https://github.com/monthly-cloud/monthly-sdk-php/blob/88b9d2bb346344495346a42043108627f648a793/src/Builder.php#L301-L318
19,921
monthly-cloud/monthly-sdk-php
src/Builder.php
Builder.get
public function get($fields = null) { if (!empty($fields)) { $this->fields($fields); } return $this->httpGetRequest($this->buildUrl()); }
php
public function get($fields = null) { if (!empty($fields)) { $this->fields($fields); } return $this->httpGetRequest($this->buildUrl()); }
[ "public", "function", "get", "(", "$", "fields", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "fields", ")", ")", "{", "$", "this", "->", "fields", "(", "$", "fields", ")", ";", "}", "return", "$", "this", "->", "httpGetRequest", "(", "$", "this", "->", "buildUrl", "(", ")", ")", ";", "}" ]
Call get request. @param array|null $fields @return object
[ "Call", "get", "request", "." ]
88b9d2bb346344495346a42043108627f648a793
https://github.com/monthly-cloud/monthly-sdk-php/blob/88b9d2bb346344495346a42043108627f648a793/src/Builder.php#L350-L357
19,922
monthly-cloud/monthly-sdk-php
src/Builder.php
Builder.first
public function first() { $response = $this->httpGetRequest($this->buildUrl()); if (empty($response->data[0])) { return false; } return $response->data[0]; }
php
public function first() { $response = $this->httpGetRequest($this->buildUrl()); if (empty($response->data[0])) { return false; } return $response->data[0]; }
[ "public", "function", "first", "(", ")", "{", "$", "response", "=", "$", "this", "->", "httpGetRequest", "(", "$", "this", "->", "buildUrl", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "response", "->", "data", "[", "0", "]", ")", ")", "{", "return", "false", ";", "}", "return", "$", "response", "->", "data", "[", "0", "]", ";", "}" ]
Get first item from get response. @return stdClass|false
[ "Get", "first", "item", "from", "get", "response", "." ]
88b9d2bb346344495346a42043108627f648a793
https://github.com/monthly-cloud/monthly-sdk-php/blob/88b9d2bb346344495346a42043108627f648a793/src/Builder.php#L364-L373
19,923
monthly-cloud/monthly-sdk-php
src/Builder.php
Builder.flush
public function flush() { $this->filters = []; $this->include = null; $this->id = null; $this->endpoint = null; $this->sort = null; $this->fields = null; $this->pageSize = null; $this->response = null; }
php
public function flush() { $this->filters = []; $this->include = null; $this->id = null; $this->endpoint = null; $this->sort = null; $this->fields = null; $this->pageSize = null; $this->response = null; }
[ "public", "function", "flush", "(", ")", "{", "$", "this", "->", "filters", "=", "[", "]", ";", "$", "this", "->", "include", "=", "null", ";", "$", "this", "->", "id", "=", "null", ";", "$", "this", "->", "endpoint", "=", "null", ";", "$", "this", "->", "sort", "=", "null", ";", "$", "this", "->", "fields", "=", "null", ";", "$", "this", "->", "pageSize", "=", "null", ";", "$", "this", "->", "response", "=", "null", ";", "}" ]
Unset all call parameters. @return void
[ "Unset", "all", "call", "parameters", "." ]
88b9d2bb346344495346a42043108627f648a793
https://github.com/monthly-cloud/monthly-sdk-php/blob/88b9d2bb346344495346a42043108627f648a793/src/Builder.php#L522-L532
19,924
monthly-cloud/monthly-sdk-php
src/Builder.php
Builder.useCache
public function useCache($caching = null) { if (is_null($caching)) { return ($this->useCache && $this->getCache()); } $this->useCache = (bool) $caching; return $this; }
php
public function useCache($caching = null) { if (is_null($caching)) { return ($this->useCache && $this->getCache()); } $this->useCache = (bool) $caching; return $this; }
[ "public", "function", "useCache", "(", "$", "caching", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "caching", ")", ")", "{", "return", "(", "$", "this", "->", "useCache", "&&", "$", "this", "->", "getCache", "(", ")", ")", ";", "}", "$", "this", "->", "useCache", "=", "(", "bool", ")", "$", "caching", ";", "return", "$", "this", ";", "}" ]
Check if cache can be used in this request, or set caching for request. Apply only to get requests. @param bool|null $caching @return self|bool
[ "Check", "if", "cache", "can", "be", "used", "in", "this", "request", "or", "set", "caching", "for", "request", "." ]
88b9d2bb346344495346a42043108627f648a793
https://github.com/monthly-cloud/monthly-sdk-php/blob/88b9d2bb346344495346a42043108627f648a793/src/Builder.php#L542-L551
19,925
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/Base/BaseCoverFishOutput.php
BaseCoverFishOutput.resetJsonResult
protected function resetJsonResult() { $this->jsonResult['skipped'] = false; $this->jsonResult['pass'] = false; $this->jsonResult['failure'] = false; $this->jsonResult['error'] = false; $this->jsonResult['unknown'] = false; }
php
protected function resetJsonResult() { $this->jsonResult['skipped'] = false; $this->jsonResult['pass'] = false; $this->jsonResult['failure'] = false; $this->jsonResult['error'] = false; $this->jsonResult['unknown'] = false; }
[ "protected", "function", "resetJsonResult", "(", ")", "{", "$", "this", "->", "jsonResult", "[", "'skipped'", "]", "=", "false", ";", "$", "this", "->", "jsonResult", "[", "'pass'", "]", "=", "false", ";", "$", "this", "->", "jsonResult", "[", "'failure'", "]", "=", "false", ";", "$", "this", "->", "jsonResult", "[", "'error'", "]", "=", "false", ";", "$", "this", "->", "jsonResult", "[", "'unknown'", "]", "=", "false", ";", "}" ]
initializer for json result set in write progress method
[ "initializer", "for", "json", "result", "set", "in", "write", "progress", "method" ]
779bd399ec8f4cadb3b7854200695c5eb3f5a8ad
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/Base/BaseCoverFishOutput.php#L139-L146
19,926
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/Base/BaseCoverFishOutput.php
BaseCoverFishOutput.writeScanPassStatistic
protected function writeScanPassStatistic(CoverFishResult $coverFishResult) { $passStatistic = '%s file(s) and %s method(s) scanned, scan succeeded, no problems found.%s'; $passStatistic = sprintf($passStatistic, $coverFishResult->getFileCount(), $coverFishResult->getTestCount(), PHP_EOL ); $scanResultMacro = '%s%s%s'; $scanResult = sprintf($scanResultMacro, ($this->outputLevel === 0) ? PHP_EOL : null, PHP_EOL, (false === $this->preventAnsiColors) ? Color::tplGreenColor($passStatistic) : $passStatistic ); $this->write($scanResult); }
php
protected function writeScanPassStatistic(CoverFishResult $coverFishResult) { $passStatistic = '%s file(s) and %s method(s) scanned, scan succeeded, no problems found.%s'; $passStatistic = sprintf($passStatistic, $coverFishResult->getFileCount(), $coverFishResult->getTestCount(), PHP_EOL ); $scanResultMacro = '%s%s%s'; $scanResult = sprintf($scanResultMacro, ($this->outputLevel === 0) ? PHP_EOL : null, PHP_EOL, (false === $this->preventAnsiColors) ? Color::tplGreenColor($passStatistic) : $passStatistic ); $this->write($scanResult); }
[ "protected", "function", "writeScanPassStatistic", "(", "CoverFishResult", "$", "coverFishResult", ")", "{", "$", "passStatistic", "=", "'%s file(s) and %s method(s) scanned, scan succeeded, no problems found.%s'", ";", "$", "passStatistic", "=", "sprintf", "(", "$", "passStatistic", ",", "$", "coverFishResult", "->", "getFileCount", "(", ")", ",", "$", "coverFishResult", "->", "getTestCount", "(", ")", ",", "PHP_EOL", ")", ";", "$", "scanResultMacro", "=", "'%s%s%s'", ";", "$", "scanResult", "=", "sprintf", "(", "$", "scanResultMacro", ",", "(", "$", "this", "->", "outputLevel", "===", "0", ")", "?", "PHP_EOL", ":", "null", ",", "PHP_EOL", ",", "(", "false", "===", "$", "this", "->", "preventAnsiColors", ")", "?", "Color", "::", "tplGreenColor", "(", "$", "passStatistic", ")", ":", "$", "passStatistic", ")", ";", "$", "this", "->", "write", "(", "$", "scanResult", ")", ";", "}" ]
write scan pass results @param CoverFishResult $coverFishResult
[ "write", "scan", "pass", "results" ]
779bd399ec8f4cadb3b7854200695c5eb3f5a8ad
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/Base/BaseCoverFishOutput.php#L358-L379
19,927
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/Base/BaseCoverFishOutput.php
BaseCoverFishOutput.writeScanFailStatistic
protected function writeScanFailStatistic(CoverFishResult $coverFishResult) { $errorStatistic = '%s file(s) and %s method(s) scanned, coverage failed: %s cover annotation problem(s) found!%s'; $errorStatistic = sprintf($errorStatistic, $coverFishResult->getFileCount(), $coverFishResult->getTestCount(), $coverFishResult->getFailureCount(), PHP_EOL ); $scanResultMacro = '%s%s%s%s'; $scanResult = sprintf($scanResultMacro, ($this->outputLevel === 0) ? PHP_EOL : null, PHP_EOL, (false === $this->preventAnsiColors) ? Color::tplRedColor($errorStatistic) : $errorStatistic, $this->getScanFailPassStatistic($coverFishResult) ); $this->write($scanResult); throw new CoverFishFailExit(); }
php
protected function writeScanFailStatistic(CoverFishResult $coverFishResult) { $errorStatistic = '%s file(s) and %s method(s) scanned, coverage failed: %s cover annotation problem(s) found!%s'; $errorStatistic = sprintf($errorStatistic, $coverFishResult->getFileCount(), $coverFishResult->getTestCount(), $coverFishResult->getFailureCount(), PHP_EOL ); $scanResultMacro = '%s%s%s%s'; $scanResult = sprintf($scanResultMacro, ($this->outputLevel === 0) ? PHP_EOL : null, PHP_EOL, (false === $this->preventAnsiColors) ? Color::tplRedColor($errorStatistic) : $errorStatistic, $this->getScanFailPassStatistic($coverFishResult) ); $this->write($scanResult); throw new CoverFishFailExit(); }
[ "protected", "function", "writeScanFailStatistic", "(", "CoverFishResult", "$", "coverFishResult", ")", "{", "$", "errorStatistic", "=", "'%s file(s) and %s method(s) scanned, coverage failed: %s cover annotation problem(s) found!%s'", ";", "$", "errorStatistic", "=", "sprintf", "(", "$", "errorStatistic", ",", "$", "coverFishResult", "->", "getFileCount", "(", ")", ",", "$", "coverFishResult", "->", "getTestCount", "(", ")", ",", "$", "coverFishResult", "->", "getFailureCount", "(", ")", ",", "PHP_EOL", ")", ";", "$", "scanResultMacro", "=", "'%s%s%s%s'", ";", "$", "scanResult", "=", "sprintf", "(", "$", "scanResultMacro", ",", "(", "$", "this", "->", "outputLevel", "===", "0", ")", "?", "PHP_EOL", ":", "null", ",", "PHP_EOL", ",", "(", "false", "===", "$", "this", "->", "preventAnsiColors", ")", "?", "Color", "::", "tplRedColor", "(", "$", "errorStatistic", ")", ":", "$", "errorStatistic", ",", "$", "this", "->", "getScanFailPassStatistic", "(", "$", "coverFishResult", ")", ")", ";", "$", "this", "->", "write", "(", "$", "scanResult", ")", ";", "throw", "new", "CoverFishFailExit", "(", ")", ";", "}" ]
write scan fail result @param CoverFishResult $coverFishResult @throws CoverFishFailExit
[ "write", "scan", "fail", "result" ]
779bd399ec8f4cadb3b7854200695c5eb3f5a8ad
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/Base/BaseCoverFishOutput.php#L388-L413
19,928
joseph-walker/vector
src/Lib/Arrays.php
Arrays.__zipWith
protected static function __zipWith(callable $f, array $a, array $b) : array { $result = []; while (($ai = array_shift($a)) !== null && ($bi = array_shift($b)) !== null) { $result[] = $f($ai, $bi); } return $result; }
php
protected static function __zipWith(callable $f, array $a, array $b) : array { $result = []; while (($ai = array_shift($a)) !== null && ($bi = array_shift($b)) !== null) { $result[] = $f($ai, $bi); } return $result; }
[ "protected", "static", "function", "__zipWith", "(", "callable", "$", "f", ",", "array", "$", "a", ",", "array", "$", "b", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "while", "(", "(", "$", "ai", "=", "array_shift", "(", "$", "a", ")", ")", "!==", "null", "&&", "(", "$", "bi", "=", "array_shift", "(", "$", "b", ")", ")", "!==", "null", ")", "{", "$", "result", "[", "]", "=", "$", "f", "(", "$", "ai", ",", "$", "bi", ")", ";", "}", "return", "$", "result", ";", "}" ]
Custom Array Zip Given two arrays a and b, and some combinator f, combine the arrays using the combinator f(ai, bi) into a new array c. If a and b are not the same length, the resultant array will always be the same length as the shorter array, i.e. the zip stops when it runs out of pairs. @example $combinator = function($a, $b) { return $a + $b; }; Arrays::zipWith($combinator, [1, 2, 3], [0, 8, -1]); // [1, 10, 2] @example $combinator = function($a, $b) { return $a - $b; }; Arrays::zipWith($combinator, [0], [1, 2, 3]); // [-1] @type (a -> b -> c) -> [a] -> [b] -> [c] @param Callable $f The function used to combine $a and $b @param array $a The first array to use in the combinator @param array $b The second array to use in the combinator @return array The result of calling f with each element of a and b in series
[ "Custom", "Array", "Zip" ]
e349aa2e9e0535b1993f9fffc0476e7fd8e113fc
https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Arrays.php#L522-L531
19,929
joseph-walker/vector
src/Lib/Arrays.php
Arrays.__dropWhile
protected static function __dropWhile(callable $predicate, array $list) : array { foreach ($list as $item) { if ($predicate($item)) { array_shift($list); } else { break; } } return $list; }
php
protected static function __dropWhile(callable $predicate, array $list) : array { foreach ($list as $item) { if ($predicate($item)) { array_shift($list); } else { break; } } return $list; }
[ "protected", "static", "function", "__dropWhile", "(", "callable", "$", "predicate", ",", "array", "$", "list", ")", ":", "array", "{", "foreach", "(", "$", "list", "as", "$", "item", ")", "{", "if", "(", "$", "predicate", "(", "$", "item", ")", ")", "{", "array_shift", "(", "$", "list", ")", ";", "}", "else", "{", "break", ";", "}", "}", "return", "$", "list", ";", "}" ]
Drop Elements with Predicate Given some function that returns true or false, drop elements from an array starting at the front, testing each element along the way, until that function returns false. Return the array without all of those elements. @example $greaterThanOne = function($n) { return $n > 1; }; Arrays::dropWhile($greaterThanOne, [2, 4, 6, 1, 2, 3]); // [1, 2, 3] @type (a -> Bool) -> [a] -> [a] @param callable $predicate Function to use for testing @param array $list List to drop from @return array List with elements removed from the front
[ "Drop", "Elements", "with", "Predicate" ]
e349aa2e9e0535b1993f9fffc0476e7fd8e113fc
https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Arrays.php#L632-L643
19,930
joseph-walker/vector
src/Lib/Arrays.php
Arrays.__takeWhile
protected static function __takeWhile(callable $predicate, array $list) : array { $result = []; foreach ($list as $item) { if ($predicate($item)) { $result[] = $item; } else { break; } } return $result; }
php
protected static function __takeWhile(callable $predicate, array $list) : array { $result = []; foreach ($list as $item) { if ($predicate($item)) { $result[] = $item; } else { break; } } return $result; }
[ "protected", "static", "function", "__takeWhile", "(", "callable", "$", "predicate", ",", "array", "$", "list", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "list", "as", "$", "item", ")", "{", "if", "(", "$", "predicate", "(", "$", "item", ")", ")", "{", "$", "result", "[", "]", "=", "$", "item", ";", "}", "else", "{", "break", ";", "}", "}", "return", "$", "result", ";", "}" ]
Take Elements with Predicate Given some function that returns true or false, return the first elements of the array that all pass the test, until the test fails. @example $greaterThanOne = function($n) { return $n > 1; }; Arrays::takeWhile($greaterThanOne, [5, 5, 5, 1, 5, 5]); // [5, 5, 5] @type (a -> Bool) -> [a] -> [a] @param callable $predicate Function to use for testing each element @param array $list List to take elements from @return array First elements of list that all pass the $predicate
[ "Take", "Elements", "with", "Predicate" ]
e349aa2e9e0535b1993f9fffc0476e7fd8e113fc
https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Arrays.php#L681-L694
19,931
2amigos/yiifoundation
helpers/Html.php
Html.thumb
public static function thumb($src, $url = '#', $htmlOptions = array()) { static::addCssClass($htmlOptions, 'th'); return \CHtml::link(\CHtml::image($src), $url, $htmlOptions); }
php
public static function thumb($src, $url = '#', $htmlOptions = array()) { static::addCssClass($htmlOptions, 'th'); return \CHtml::link(\CHtml::image($src), $url, $htmlOptions); }
[ "public", "static", "function", "thumb", "(", "$", "src", ",", "$", "url", "=", "'#'", ",", "$", "htmlOptions", "=", "array", "(", ")", ")", "{", "static", "::", "addCssClass", "(", "$", "htmlOptions", ",", "'th'", ")", ";", "return", "\\", "CHtml", "::", "link", "(", "\\", "CHtml", "::", "image", "(", "$", "src", ")", ",", "$", "url", ",", "$", "htmlOptions", ")", ";", "}" ]
Renders a Foundation thumbnail @param $src @param string $url @param array $htmlOptions @return string
[ "Renders", "a", "Foundation", "thumbnail" ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Html.php#L161-L165
19,932
2amigos/yiifoundation
helpers/Html.php
Html.addCssClass
public static function addCssClass(&$options, $class) { if (isset($options['class'])) { $classes = ' ' . $options['class'] . ' '; if (($pos = strpos($classes, ' ' . $class . ' ')) === false) { $options['class'] .= ' ' . $class; } } else { $options['class'] = $class; } }
php
public static function addCssClass(&$options, $class) { if (isset($options['class'])) { $classes = ' ' . $options['class'] . ' '; if (($pos = strpos($classes, ' ' . $class . ' ')) === false) { $options['class'] .= ' ' . $class; } } else { $options['class'] = $class; } }
[ "public", "static", "function", "addCssClass", "(", "&", "$", "options", ",", "$", "class", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'class'", "]", ")", ")", "{", "$", "classes", "=", "' '", ".", "$", "options", "[", "'class'", "]", ".", "' '", ";", "if", "(", "(", "$", "pos", "=", "strpos", "(", "$", "classes", ",", "' '", ".", "$", "class", ".", "' '", ")", ")", "===", "false", ")", "{", "$", "options", "[", "'class'", "]", ".=", "' '", ".", "$", "class", ";", "}", "}", "else", "{", "$", "options", "[", "'class'", "]", "=", "$", "class", ";", "}", "}" ]
Adds a CSS class to the specified options. If the CSS class is already in the options, it will not be added again. @param array $options the options to be modified. @param string $class the CSS class to be added
[ "Adds", "a", "CSS", "class", "to", "the", "specified", "options", ".", "If", "the", "CSS", "class", "is", "already", "in", "the", "options", "it", "will", "not", "be", "added", "again", "." ]
49bed0d3ca1a9bac9299000e48a2661bdc8f9a29
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Html.php#L173-L183
19,933
nyeholt/silverstripe-external-content
remoteclients/WebApiClient.php
WebApiClient.callUrl
public function callUrl($url, $args = array(), $returnType = 'raw', $requestType = 'GET', $cache = 300, $enctype = Zend_Http_Client::ENC_URLENCODED) { $body = null; // use the method params to try caching the results // need to add in the baseUrl we're connecting to, and any global params // because the cache might be connecting via different users, and the // different users will have different sessions. This might need to be // tweaked to handle separate user logins at a later point in time $cacheKey = md5($url . $requestType . var_export($args, true) . var_export($this->globalParams, true)); $requestType = isset($methodDetails['method']) ? $methodDetails['method'] : 'GET'; if (mb_strtolower($requestType) == 'get' && $cache) { $body = CacheService::inst()->get($cacheKey); } if (!$body) { $uri = $url; $client = $this->getClient($uri); $client->setMethod($requestType); // set the encoding type $client->setEncType($enctype); $paramMethod = 'setParameter'.$requestType; // make sure to add the alfTicket parameter if ($this->globalParams) { foreach ($this->globalParams as $key => $value) { $client->$paramMethod($key, $value); } } foreach ($args as $index => $pname) { $client->$paramMethod($index, $pname); } // request away $response = $client->request(); if ($response->isSuccessful()) { $body = $response->getBody(); if ($cache) { CacheService::inst()->store($cacheKey, $body, $cache); } } else { if ($response->getStatus() == 500) { error_log("Failure: ".$response->getBody()); error_log(var_export($client, true)); } throw new FailedRequestException("Failed executing $url: ".$response->getMessage()." for request to $uri (".$client->getUri(true).')', $response->getBody()); } } // see what we need to do with it if (isset($this->returnHandlers[$returnType])) { $handler = $this->returnHandlers[$returnType]; return $handler->handleReturn($body); } else { return $body; } }
php
public function callUrl($url, $args = array(), $returnType = 'raw', $requestType = 'GET', $cache = 300, $enctype = Zend_Http_Client::ENC_URLENCODED) { $body = null; // use the method params to try caching the results // need to add in the baseUrl we're connecting to, and any global params // because the cache might be connecting via different users, and the // different users will have different sessions. This might need to be // tweaked to handle separate user logins at a later point in time $cacheKey = md5($url . $requestType . var_export($args, true) . var_export($this->globalParams, true)); $requestType = isset($methodDetails['method']) ? $methodDetails['method'] : 'GET'; if (mb_strtolower($requestType) == 'get' && $cache) { $body = CacheService::inst()->get($cacheKey); } if (!$body) { $uri = $url; $client = $this->getClient($uri); $client->setMethod($requestType); // set the encoding type $client->setEncType($enctype); $paramMethod = 'setParameter'.$requestType; // make sure to add the alfTicket parameter if ($this->globalParams) { foreach ($this->globalParams as $key => $value) { $client->$paramMethod($key, $value); } } foreach ($args as $index => $pname) { $client->$paramMethod($index, $pname); } // request away $response = $client->request(); if ($response->isSuccessful()) { $body = $response->getBody(); if ($cache) { CacheService::inst()->store($cacheKey, $body, $cache); } } else { if ($response->getStatus() == 500) { error_log("Failure: ".$response->getBody()); error_log(var_export($client, true)); } throw new FailedRequestException("Failed executing $url: ".$response->getMessage()." for request to $uri (".$client->getUri(true).')', $response->getBody()); } } // see what we need to do with it if (isset($this->returnHandlers[$returnType])) { $handler = $this->returnHandlers[$returnType]; return $handler->handleReturn($body); } else { return $body; } }
[ "public", "function", "callUrl", "(", "$", "url", ",", "$", "args", "=", "array", "(", ")", ",", "$", "returnType", "=", "'raw'", ",", "$", "requestType", "=", "'GET'", ",", "$", "cache", "=", "300", ",", "$", "enctype", "=", "Zend_Http_Client", "::", "ENC_URLENCODED", ")", "{", "$", "body", "=", "null", ";", "// use the method params to try caching the results", "// need to add in the baseUrl we're connecting to, and any global params", "// because the cache might be connecting via different users, and the", "// different users will have different sessions. This might need to be", "// tweaked to handle separate user logins at a later point in time", "$", "cacheKey", "=", "md5", "(", "$", "url", ".", "$", "requestType", ".", "var_export", "(", "$", "args", ",", "true", ")", ".", "var_export", "(", "$", "this", "->", "globalParams", ",", "true", ")", ")", ";", "$", "requestType", "=", "isset", "(", "$", "methodDetails", "[", "'method'", "]", ")", "?", "$", "methodDetails", "[", "'method'", "]", ":", "'GET'", ";", "if", "(", "mb_strtolower", "(", "$", "requestType", ")", "==", "'get'", "&&", "$", "cache", ")", "{", "$", "body", "=", "CacheService", "::", "inst", "(", ")", "->", "get", "(", "$", "cacheKey", ")", ";", "}", "if", "(", "!", "$", "body", ")", "{", "$", "uri", "=", "$", "url", ";", "$", "client", "=", "$", "this", "->", "getClient", "(", "$", "uri", ")", ";", "$", "client", "->", "setMethod", "(", "$", "requestType", ")", ";", "// set the encoding type", "$", "client", "->", "setEncType", "(", "$", "enctype", ")", ";", "$", "paramMethod", "=", "'setParameter'", ".", "$", "requestType", ";", "// make sure to add the alfTicket parameter", "if", "(", "$", "this", "->", "globalParams", ")", "{", "foreach", "(", "$", "this", "->", "globalParams", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "client", "->", "$", "paramMethod", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "foreach", "(", "$", "args", "as", "$", "index", "=>", "$", "pname", ")", "{", "$", "client", "->", "$", "paramMethod", "(", "$", "index", ",", "$", "pname", ")", ";", "}", "// request away", "$", "response", "=", "$", "client", "->", "request", "(", ")", ";", "if", "(", "$", "response", "->", "isSuccessful", "(", ")", ")", "{", "$", "body", "=", "$", "response", "->", "getBody", "(", ")", ";", "if", "(", "$", "cache", ")", "{", "CacheService", "::", "inst", "(", ")", "->", "store", "(", "$", "cacheKey", ",", "$", "body", ",", "$", "cache", ")", ";", "}", "}", "else", "{", "if", "(", "$", "response", "->", "getStatus", "(", ")", "==", "500", ")", "{", "error_log", "(", "\"Failure: \"", ".", "$", "response", "->", "getBody", "(", ")", ")", ";", "error_log", "(", "var_export", "(", "$", "client", ",", "true", ")", ")", ";", "}", "throw", "new", "FailedRequestException", "(", "\"Failed executing $url: \"", ".", "$", "response", "->", "getMessage", "(", ")", ".", "\" for request to $uri (\"", ".", "$", "client", "->", "getUri", "(", "true", ")", ".", "')'", ",", "$", "response", "->", "getBody", "(", ")", ")", ";", "}", "}", "// see what we need to do with it", "if", "(", "isset", "(", "$", "this", "->", "returnHandlers", "[", "$", "returnType", "]", ")", ")", "{", "$", "handler", "=", "$", "this", "->", "returnHandlers", "[", "$", "returnType", "]", ";", "return", "$", "handler", "->", "handleReturn", "(", "$", "body", ")", ";", "}", "else", "{", "return", "$", "body", ";", "}", "}" ]
Call a URL directly, without it being mapped to a configured web method. This differs from the above in that the caller already knows what URL is trying to be called, so we can bypass the business of mapping arguments all over the place. We still maintain the globalParams for this client though @param $url The URL to call @param $args Parameters to be passed on the call @return mixed
[ "Call", "a", "URL", "directly", "without", "it", "being", "mapped", "to", "a", "configured", "web", "method", "." ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/remoteclients/WebApiClient.php#L316-L374
19,934
nyeholt/silverstripe-external-content
remoteclients/WebApiClient.php
WebApiClient.getClient
protected function getClient($uri) { // TODO For some reason the Alfresco client goes into an infinite loop when returning // the children of an item (when you call getChildren on the company home) // it returns itself as its own child, unless you recreate the client. It seems // to maintain all the request body... or something weird. if (!$this->httpClient || !$this->maintainSession) { $this->httpClient = new Zend_Http_Client($uri, array( 'maxredirects' => 0, 'timeout' => 10 ) ); if ($this->useCookies) { $this->httpClient->setCookieJar(); } } else { $this->httpClient->setUri($uri); } // clear it out if ($this->maintainSession) { $this->httpClient->resetParameters(); } if ($this->authInfo) { $this->httpClient->setAuth($this->authInfo['user'], $this->authInfo['pass']); } return $this->httpClient; }
php
protected function getClient($uri) { // TODO For some reason the Alfresco client goes into an infinite loop when returning // the children of an item (when you call getChildren on the company home) // it returns itself as its own child, unless you recreate the client. It seems // to maintain all the request body... or something weird. if (!$this->httpClient || !$this->maintainSession) { $this->httpClient = new Zend_Http_Client($uri, array( 'maxredirects' => 0, 'timeout' => 10 ) ); if ($this->useCookies) { $this->httpClient->setCookieJar(); } } else { $this->httpClient->setUri($uri); } // clear it out if ($this->maintainSession) { $this->httpClient->resetParameters(); } if ($this->authInfo) { $this->httpClient->setAuth($this->authInfo['user'], $this->authInfo['pass']); } return $this->httpClient; }
[ "protected", "function", "getClient", "(", "$", "uri", ")", "{", "// TODO For some reason the Alfresco client goes into an infinite loop when returning", "// the children of an item (when you call getChildren on the company home)", "// it returns itself as its own child, unless you recreate the client. It seems", "// to maintain all the request body... or something weird.", "if", "(", "!", "$", "this", "->", "httpClient", "||", "!", "$", "this", "->", "maintainSession", ")", "{", "$", "this", "->", "httpClient", "=", "new", "Zend_Http_Client", "(", "$", "uri", ",", "array", "(", "'maxredirects'", "=>", "0", ",", "'timeout'", "=>", "10", ")", ")", ";", "if", "(", "$", "this", "->", "useCookies", ")", "{", "$", "this", "->", "httpClient", "->", "setCookieJar", "(", ")", ";", "}", "}", "else", "{", "$", "this", "->", "httpClient", "->", "setUri", "(", "$", "uri", ")", ";", "}", "// clear it out", "if", "(", "$", "this", "->", "maintainSession", ")", "{", "$", "this", "->", "httpClient", "->", "resetParameters", "(", ")", ";", "}", "if", "(", "$", "this", "->", "authInfo", ")", "{", "$", "this", "->", "httpClient", "->", "setAuth", "(", "$", "this", "->", "authInfo", "[", "'user'", "]", ",", "$", "this", "->", "authInfo", "[", "'pass'", "]", ")", ";", "}", "return", "$", "this", "->", "httpClient", ";", "}" ]
Create and return the http client, defined in a separate method for testing purposes @return Zend_Http_Client
[ "Create", "and", "return", "the", "http", "client", "defined", "in", "a", "separate", "method", "for", "testing", "purposes" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/remoteclients/WebApiClient.php#L389-L419
19,935
zircote/AMQP
library/AMQP/Connection.php
Connection.waitFrame
protected function waitFrame() { $frameType = $this->input->readOctet(); $channel = $this->input->readShort(); $size = $this->input->readLong(); $payload = $this->input->read($size); $ch = $this->input->readOctet(); if ($ch != 0xCE) { throw new \Exception( sprintf( 'Framing error, unexpected byte: %x', $ch ) ); } return array($frameType, $channel, $payload); }
php
protected function waitFrame() { $frameType = $this->input->readOctet(); $channel = $this->input->readShort(); $size = $this->input->readLong(); $payload = $this->input->read($size); $ch = $this->input->readOctet(); if ($ch != 0xCE) { throw new \Exception( sprintf( 'Framing error, unexpected byte: %x', $ch ) ); } return array($frameType, $channel, $payload); }
[ "protected", "function", "waitFrame", "(", ")", "{", "$", "frameType", "=", "$", "this", "->", "input", "->", "readOctet", "(", ")", ";", "$", "channel", "=", "$", "this", "->", "input", "->", "readShort", "(", ")", ";", "$", "size", "=", "$", "this", "->", "input", "->", "readLong", "(", ")", ";", "$", "payload", "=", "$", "this", "->", "input", "->", "read", "(", "$", "size", ")", ";", "$", "ch", "=", "$", "this", "->", "input", "->", "readOctet", "(", ")", ";", "if", "(", "$", "ch", "!=", "0xCE", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Framing error, unexpected byte: %x'", ",", "$", "ch", ")", ")", ";", "}", "return", "array", "(", "$", "frameType", ",", "$", "channel", ",", "$", "payload", ")", ";", "}" ]
Wait for a frame from the server @return array @throws \Exception
[ "Wait", "for", "a", "frame", "from", "the", "server" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L513-L530
19,936
zircote/AMQP
library/AMQP/Connection.php
Connection.waitChannel
public function waitChannel($channelId) { while (true) { list($frameType, $frameChannel, $payload) = $this->waitFrame(); if ($frameChannel == $channelId) { return array($frameType, $payload); } /** * Not the channel we were looking for. Queue this frame * for later, when the other channel is looking for frames. */ array_push( $this->channels[$frameChannel]->frame_queue, array($frameType, $payload) ); /** * If we just queued up a method for channel 0 (the Connection * itself) it's probably a close method in reaction to some * error, so deal with it right away. */ if (($frameType == 1) && ($frameChannel == 0)) { $this->wait(); } } return array(); }
php
public function waitChannel($channelId) { while (true) { list($frameType, $frameChannel, $payload) = $this->waitFrame(); if ($frameChannel == $channelId) { return array($frameType, $payload); } /** * Not the channel we were looking for. Queue this frame * for later, when the other channel is looking for frames. */ array_push( $this->channels[$frameChannel]->frame_queue, array($frameType, $payload) ); /** * If we just queued up a method for channel 0 (the Connection * itself) it's probably a close method in reaction to some * error, so deal with it right away. */ if (($frameType == 1) && ($frameChannel == 0)) { $this->wait(); } } return array(); }
[ "public", "function", "waitChannel", "(", "$", "channelId", ")", "{", "while", "(", "true", ")", "{", "list", "(", "$", "frameType", ",", "$", "frameChannel", ",", "$", "payload", ")", "=", "$", "this", "->", "waitFrame", "(", ")", ";", "if", "(", "$", "frameChannel", "==", "$", "channelId", ")", "{", "return", "array", "(", "$", "frameType", ",", "$", "payload", ")", ";", "}", "/**\n * Not the channel we were looking for. Queue this frame\n * for later, when the other channel is looking for frames.\n */", "array_push", "(", "$", "this", "->", "channels", "[", "$", "frameChannel", "]", "->", "frame_queue", ",", "array", "(", "$", "frameType", ",", "$", "payload", ")", ")", ";", "/**\n * If we just queued up a method for channel 0 (the Connection\n * itself) it's probably a close method in reaction to some\n * error, so deal with it right away.\n */", "if", "(", "(", "$", "frameType", "==", "1", ")", "&&", "(", "$", "frameChannel", "==", "0", ")", ")", "{", "$", "this", "->", "wait", "(", ")", ";", "}", "}", "return", "array", "(", ")", ";", "}" ]
Wait for a frame from the server destined for a particular channel. @param $channelId @return array
[ "Wait", "for", "a", "frame", "from", "the", "server", "destined", "for", "a", "particular", "channel", "." ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L539-L565
19,937
zircote/AMQP
library/AMQP/Connection.php
Connection.channel
public function channel($channelId = null) { if (isset($this->channels[$channelId])) { return $this->channels[$channelId]; } else { $channelId = $channelId ? : $this->getFreeChannelId(); $ch = new Channel($this->connection, $channelId); return $this->channels[$channelId] = $ch; } }
php
public function channel($channelId = null) { if (isset($this->channels[$channelId])) { return $this->channels[$channelId]; } else { $channelId = $channelId ? : $this->getFreeChannelId(); $ch = new Channel($this->connection, $channelId); return $this->channels[$channelId] = $ch; } }
[ "public", "function", "channel", "(", "$", "channelId", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "channels", "[", "$", "channelId", "]", ")", ")", "{", "return", "$", "this", "->", "channels", "[", "$", "channelId", "]", ";", "}", "else", "{", "$", "channelId", "=", "$", "channelId", "?", ":", "$", "this", "->", "getFreeChannelId", "(", ")", ";", "$", "ch", "=", "new", "Channel", "(", "$", "this", "->", "connection", ",", "$", "channelId", ")", ";", "return", "$", "this", "->", "channels", "[", "$", "channelId", "]", "=", "$", "ch", ";", "}", "}" ]
Fetch a Channel object identified by the numeric channel_id, or create that object if it doesn't already exist. @param string|null $channelId @return \AMQP\Channel
[ "Fetch", "a", "Channel", "object", "identified", "by", "the", "numeric", "channel_id", "or", "create", "that", "object", "if", "it", "doesn", "t", "already", "exist", "." ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L575-L584
19,938
zircote/AMQP
library/AMQP/Connection.php
Connection.close
public function close($replyCode = 0, $replyText = '', $methodSig = array(0, 0)) { $args = new Writer(); $args->writeShort($replyCode); $args->writeShortStr($replyText); $args->writeShort($methodSig[0]); // class_id $args->writeShort($methodSig[1]); // method_id $this->sendMethodFrame(array(10, 60), $args); return $this->wait( array( "10,61", // Connection.close_ok ) ); }
php
public function close($replyCode = 0, $replyText = '', $methodSig = array(0, 0)) { $args = new Writer(); $args->writeShort($replyCode); $args->writeShortStr($replyText); $args->writeShort($methodSig[0]); // class_id $args->writeShort($methodSig[1]); // method_id $this->sendMethodFrame(array(10, 60), $args); return $this->wait( array( "10,61", // Connection.close_ok ) ); }
[ "public", "function", "close", "(", "$", "replyCode", "=", "0", ",", "$", "replyText", "=", "''", ",", "$", "methodSig", "=", "array", "(", "0", ",", "0", ")", ")", "{", "$", "args", "=", "new", "Writer", "(", ")", ";", "$", "args", "->", "writeShort", "(", "$", "replyCode", ")", ";", "$", "args", "->", "writeShortStr", "(", "$", "replyText", ")", ";", "$", "args", "->", "writeShort", "(", "$", "methodSig", "[", "0", "]", ")", ";", "// class_id", "$", "args", "->", "writeShort", "(", "$", "methodSig", "[", "1", "]", ")", ";", "// method_id", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "10", ",", "60", ")", ",", "$", "args", ")", ";", "return", "$", "this", "->", "wait", "(", "array", "(", "\"10,61\"", ",", "// Connection.close_ok", ")", ")", ";", "}" ]
request a connection close @param int $replyCode @param string $replyText @param array $methodSig @return mixed|null
[ "request", "a", "connection", "close" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L595-L608
19,939
zircote/AMQP
library/AMQP/Connection.php
Connection.openOk
protected function openOk(Reader $args) { $this->knownHosts = $args->readShortstr(); if ($this->debug) { Helper::debugMsg("Open OK! known_hosts: " . $this->knownHosts); } return null; }
php
protected function openOk(Reader $args) { $this->knownHosts = $args->readShortstr(); if ($this->debug) { Helper::debugMsg("Open OK! known_hosts: " . $this->knownHosts); } return null; }
[ "protected", "function", "openOk", "(", "Reader", "$", "args", ")", "{", "$", "this", "->", "knownHosts", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "Helper", "::", "debugMsg", "(", "\"Open OK! known_hosts: \"", ".", "$", "this", "->", "knownHosts", ")", ";", "}", "return", "null", ";", "}" ]
signal that the connection is ready
[ "signal", "that", "the", "connection", "is", "ready" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L675-L683
19,940
zircote/AMQP
library/AMQP/Connection.php
Connection.redirect
protected function redirect(Reader $args) { $host = $args->readShortstr(); $this->knownHosts = $args->readShortstr(); if ($this->debug) { Helper::debugMsg( sprintf( 'Redirected to [%s], known_hosts [%s]', $host, $this->knownHosts ) ); } return $host; }
php
protected function redirect(Reader $args) { $host = $args->readShortstr(); $this->knownHosts = $args->readShortstr(); if ($this->debug) { Helper::debugMsg( sprintf( 'Redirected to [%s], known_hosts [%s]', $host, $this->knownHosts ) ); } return $host; }
[ "protected", "function", "redirect", "(", "Reader", "$", "args", ")", "{", "$", "host", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "this", "->", "knownHosts", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "Helper", "::", "debugMsg", "(", "sprintf", "(", "'Redirected to [%s], known_hosts [%s]'", ",", "$", "host", ",", "$", "this", "->", "knownHosts", ")", ")", ";", "}", "return", "$", "host", ";", "}" ]
asks the client to use a different server @param \AMQP\Wire\Reader $args @return string
[ "asks", "the", "client", "to", "use", "a", "different", "server" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L692-L705
19,941
zircote/AMQP
library/AMQP/Connection.php
Connection._xSecureOk
protected function _xSecureOk($response) { $args = new Writer(); $args->writeLongStr($response); $this->sendMethodFrame(array(10, 21), $args); }
php
protected function _xSecureOk($response) { $args = new Writer(); $args->writeLongStr($response); $this->sendMethodFrame(array(10, 21), $args); }
[ "protected", "function", "_xSecureOk", "(", "$", "response", ")", "{", "$", "args", "=", "new", "Writer", "(", ")", ";", "$", "args", "->", "writeLongStr", "(", "$", "response", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "10", ",", "21", ")", ",", "$", "args", ")", ";", "}" ]
security mechanism response @param string $response
[ "security", "mechanism", "response" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L722-L727
19,942
zircote/AMQP
library/AMQP/Connection.php
Connection.start
protected function start(Reader $args) { $this->versionMajor = $args->readOctet(); $this->versionMinor = $args->readOctet(); $this->serverProperties = $args->readTable(); $this->mechanisms = explode(" ", $args->readLongstr()); $this->locales = explode(" ", $args->readLongstr()); if ($this->debug) { Helper::debugMsg( sprintf( 'Start from server, version: %d.%d, properties: %s, ' . 'mechanisms: %s, locales: %s', $this->versionMajor, $this->versionMinor, self::dumpTable($this->serverProperties), implode(', ', $this->mechanisms), implode(', ', $this->locales) ) ); } }
php
protected function start(Reader $args) { $this->versionMajor = $args->readOctet(); $this->versionMinor = $args->readOctet(); $this->serverProperties = $args->readTable(); $this->mechanisms = explode(" ", $args->readLongstr()); $this->locales = explode(" ", $args->readLongstr()); if ($this->debug) { Helper::debugMsg( sprintf( 'Start from server, version: %d.%d, properties: %s, ' . 'mechanisms: %s, locales: %s', $this->versionMajor, $this->versionMinor, self::dumpTable($this->serverProperties), implode(', ', $this->mechanisms), implode(', ', $this->locales) ) ); } }
[ "protected", "function", "start", "(", "Reader", "$", "args", ")", "{", "$", "this", "->", "versionMajor", "=", "$", "args", "->", "readOctet", "(", ")", ";", "$", "this", "->", "versionMinor", "=", "$", "args", "->", "readOctet", "(", ")", ";", "$", "this", "->", "serverProperties", "=", "$", "args", "->", "readTable", "(", ")", ";", "$", "this", "->", "mechanisms", "=", "explode", "(", "\" \"", ",", "$", "args", "->", "readLongstr", "(", ")", ")", ";", "$", "this", "->", "locales", "=", "explode", "(", "\" \"", ",", "$", "args", "->", "readLongstr", "(", ")", ")", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "Helper", "::", "debugMsg", "(", "sprintf", "(", "'Start from server, version: %d.%d, properties: %s, '", ".", "'mechanisms: %s, locales: %s'", ",", "$", "this", "->", "versionMajor", ",", "$", "this", "->", "versionMinor", ",", "self", "::", "dumpTable", "(", "$", "this", "->", "serverProperties", ")", ",", "implode", "(", "', '", ",", "$", "this", "->", "mechanisms", ")", ",", "implode", "(", "', '", ",", "$", "this", "->", "locales", ")", ")", ")", ";", "}", "}" ]
start connection negotiation
[ "start", "connection", "negotiation" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L732-L753
19,943
zircote/AMQP
library/AMQP/Connection.php
Connection.tune
protected function tune(Reader $args) { $v = $args->readShort(); if ($v) { $this->channelMax = $v; } $v = $args->readLong(); if ($v) { $this->frameMax = $v; } $this->heartbeat = $args->readShort(); $this->xTuneOk($this->channelMax, $this->frameMax, 0); }
php
protected function tune(Reader $args) { $v = $args->readShort(); if ($v) { $this->channelMax = $v; } $v = $args->readLong(); if ($v) { $this->frameMax = $v; } $this->heartbeat = $args->readShort(); $this->xTuneOk($this->channelMax, $this->frameMax, 0); }
[ "protected", "function", "tune", "(", "Reader", "$", "args", ")", "{", "$", "v", "=", "$", "args", "->", "readShort", "(", ")", ";", "if", "(", "$", "v", ")", "{", "$", "this", "->", "channelMax", "=", "$", "v", ";", "}", "$", "v", "=", "$", "args", "->", "readLong", "(", ")", ";", "if", "(", "$", "v", ")", "{", "$", "this", "->", "frameMax", "=", "$", "v", ";", "}", "$", "this", "->", "heartbeat", "=", "$", "args", "->", "readShort", "(", ")", ";", "$", "this", "->", "xTuneOk", "(", "$", "this", "->", "channelMax", ",", "$", "this", "->", "frameMax", ",", "0", ")", ";", "}" ]
propose connection tuning parameters @param \AMQP\Wire\Reader $args
[ "propose", "connection", "tuning", "parameters" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L776-L792
19,944
zircote/AMQP
library/AMQP/Connection.php
Connection.xTuneOk
protected function xTuneOk($channelMax, $frameMax, $heartbeat) { $args = new Writer(); $args->writeShort($channelMax); $args->writeLong($frameMax); $args->writeShort($heartbeat); $this->sendMethodFrame(array(10, 31), $args); $this->waitTuneOk = False; }
php
protected function xTuneOk($channelMax, $frameMax, $heartbeat) { $args = new Writer(); $args->writeShort($channelMax); $args->writeLong($frameMax); $args->writeShort($heartbeat); $this->sendMethodFrame(array(10, 31), $args); $this->waitTuneOk = False; }
[ "protected", "function", "xTuneOk", "(", "$", "channelMax", ",", "$", "frameMax", ",", "$", "heartbeat", ")", "{", "$", "args", "=", "new", "Writer", "(", ")", ";", "$", "args", "->", "writeShort", "(", "$", "channelMax", ")", ";", "$", "args", "->", "writeLong", "(", "$", "frameMax", ")", ";", "$", "args", "->", "writeShort", "(", "$", "heartbeat", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "10", ",", "31", ")", ",", "$", "args", ")", ";", "$", "this", "->", "waitTuneOk", "=", "False", ";", "}" ]
negotiate connection tuning parameters @param $channelMax @param $frameMax @param $heartbeat
[ "negotiate", "connection", "tuning", "parameters" ]
b96777b372f556797db4fd0ba02edb18d4bf4a1e
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L801-L809
19,945
freearhey/sparql
src/QueryBuilder.php
QueryBuilder.service
public function service( $service, $subject, $predicate = null, $object = null ) { $this->graphBuilder->service( $service, $subject, $predicate, $object ); return $this; }
php
public function service( $service, $subject, $predicate = null, $object = null ) { $this->graphBuilder->service( $service, $subject, $predicate, $object ); return $this; }
[ "public", "function", "service", "(", "$", "service", ",", "$", "subject", ",", "$", "predicate", "=", "null", ",", "$", "object", "=", "null", ")", "{", "$", "this", "->", "graphBuilder", "->", "service", "(", "$", "service", ",", "$", "subject", ",", "$", "predicate", ",", "$", "object", ")", ";", "return", "$", "this", ";", "}" ]
Adds the given graph or triple as an service condition. @param string|GraphBuilder $subject @param string|null $predicate @param string|null $object @return self @throws InvalidArgumentException
[ "Adds", "the", "given", "graph", "or", "triple", "as", "an", "service", "condition", "." ]
622a8ea661dc5939122b0e8b430a6a94b3bc49c7
https://github.com/freearhey/sparql/blob/622a8ea661dc5939122b0e8b430a6a94b3bc49c7/src/QueryBuilder.php#L257-L260
19,946
gries/rcon
src/Message.php
Message.convertToRconData
public function convertToRconData($id) { $idAndTypePacked = pack('VV', $id, $this->type); $endOfMessage = chr(0) . chr(0); $message = $idAndTypePacked . $this->body . $endOfMessage; $data = pack("V", strlen($message)) . $message; return $data; }
php
public function convertToRconData($id) { $idAndTypePacked = pack('VV', $id, $this->type); $endOfMessage = chr(0) . chr(0); $message = $idAndTypePacked . $this->body . $endOfMessage; $data = pack("V", strlen($message)) . $message; return $data; }
[ "public", "function", "convertToRconData", "(", "$", "id", ")", "{", "$", "idAndTypePacked", "=", "pack", "(", "'VV'", ",", "$", "id", ",", "$", "this", "->", "type", ")", ";", "$", "endOfMessage", "=", "chr", "(", "0", ")", ".", "chr", "(", "0", ")", ";", "$", "message", "=", "$", "idAndTypePacked", ".", "$", "this", "->", "body", ".", "$", "endOfMessage", ";", "$", "data", "=", "pack", "(", "\"V\"", ",", "strlen", "(", "$", "message", ")", ")", ".", "$", "message", ";", "return", "$", "data", ";", "}" ]
The message id used for this message. This will be encoded in the RconData. @param int $id @return string
[ "The", "message", "id", "used", "for", "this", "message", ".", "This", "will", "be", "encoded", "in", "the", "RconData", "." ]
7fada05b329d89542692af00ab80db02ad59d45d
https://github.com/gries/rcon/blob/7fada05b329d89542692af00ab80db02ad59d45d/src/Message.php#L82-L92
19,947
inc2734/wp-seo
src/App/Controller/Posts.php
Posts._add_meta_boxes
public function _add_meta_boxes( $post_type, $post ) { $post_type_object = get_post_type_object( $post_type ); if ( empty( $post_type_object ) || empty( $post_type_object->public ) ) { return; } add_meta_box( 'wp-seo', __( 'SEO', 'inc2734-wp-seo' ), array( $this, '_wp_seo_meta_box' ), $post_type, 'normal' ); }
php
public function _add_meta_boxes( $post_type, $post ) { $post_type_object = get_post_type_object( $post_type ); if ( empty( $post_type_object ) || empty( $post_type_object->public ) ) { return; } add_meta_box( 'wp-seo', __( 'SEO', 'inc2734-wp-seo' ), array( $this, '_wp_seo_meta_box' ), $post_type, 'normal' ); }
[ "public", "function", "_add_meta_boxes", "(", "$", "post_type", ",", "$", "post", ")", "{", "$", "post_type_object", "=", "get_post_type_object", "(", "$", "post_type", ")", ";", "if", "(", "empty", "(", "$", "post_type_object", ")", "||", "empty", "(", "$", "post_type_object", "->", "public", ")", ")", "{", "return", ";", "}", "add_meta_box", "(", "'wp-seo'", ",", "__", "(", "'SEO'", ",", "'inc2734-wp-seo'", ")", ",", "array", "(", "$", "this", ",", "'_wp_seo_meta_box'", ")", ",", "$", "post_type", ",", "'normal'", ")", ";", "}" ]
Add meta box in pages of public post type @param [string] $post_type @param [WP_Post] $post @return void
[ "Add", "meta", "box", "in", "pages", "of", "public", "post", "type" ]
d08f3fad346751232859c335d289237a82f9eef3
https://github.com/inc2734/wp-seo/blob/d08f3fad346751232859c335d289237a82f9eef3/src/App/Controller/Posts.php#L25-L38
19,948
inc2734/wp-seo
src/App/Controller/Posts.php
Posts._wp_seo_meta_box
public function _wp_seo_meta_box( $post ) { ?> <?php wp_nonce_field( 'wp-seo-meta-box-action', 'wp-seo-meta-box-nonce' ); ?> <p> <label for="wp-seo-meta-description"> <b><?php esc_html_e( 'Meta description', 'inc2734-wp-seo' ); ?></b> </label><br /> <input type="text" name="wp-seo-meta-description" class="widefat" id="wp-seo-meta-description" value="<?php echo esc_attr( get_post_meta( $post->ID, 'wp-seo-meta-description', true ) ); ?>" /> </p> <p> <b><?php esc_html_e( 'Meta robots', 'inc2734-wp-seo' ); ?></b><br /> <?php $robots = (array) get_post_meta( $post->ID, 'wp-seo-meta-robots', true ); $robots_choices = [ 'noindex', 'nofollow', ] ?> <?php foreach ( $robots_choices as $robot ) : ?> <label for="wp-seo-meta-robots-<?php echo esc_attr( $robot ); ?>" style="margin-right: 1em;"> <input type="checkbox" name="wp-seo-meta-robots[]" id="wp-seo-meta-robots-<?php echo esc_attr( $robot ); ?>" value="<?php echo esc_attr( $robot ); ?>" <?php checked( in_array( $robot, $robots ) ); ?> /> <?php echo esc_html( $robot ); ?> </label> <?php endforeach; ?> </p> <?php }
php
public function _wp_seo_meta_box( $post ) { ?> <?php wp_nonce_field( 'wp-seo-meta-box-action', 'wp-seo-meta-box-nonce' ); ?> <p> <label for="wp-seo-meta-description"> <b><?php esc_html_e( 'Meta description', 'inc2734-wp-seo' ); ?></b> </label><br /> <input type="text" name="wp-seo-meta-description" class="widefat" id="wp-seo-meta-description" value="<?php echo esc_attr( get_post_meta( $post->ID, 'wp-seo-meta-description', true ) ); ?>" /> </p> <p> <b><?php esc_html_e( 'Meta robots', 'inc2734-wp-seo' ); ?></b><br /> <?php $robots = (array) get_post_meta( $post->ID, 'wp-seo-meta-robots', true ); $robots_choices = [ 'noindex', 'nofollow', ] ?> <?php foreach ( $robots_choices as $robot ) : ?> <label for="wp-seo-meta-robots-<?php echo esc_attr( $robot ); ?>" style="margin-right: 1em;"> <input type="checkbox" name="wp-seo-meta-robots[]" id="wp-seo-meta-robots-<?php echo esc_attr( $robot ); ?>" value="<?php echo esc_attr( $robot ); ?>" <?php checked( in_array( $robot, $robots ) ); ?> /> <?php echo esc_html( $robot ); ?> </label> <?php endforeach; ?> </p> <?php }
[ "public", "function", "_wp_seo_meta_box", "(", "$", "post", ")", "{", "?>\n\t\t<?php", "wp_nonce_field", "(", "'wp-seo-meta-box-action'", ",", "'wp-seo-meta-box-nonce'", ")", ";", "?>\n\t\t<p>\n\t\t\t<label for=\"wp-seo-meta-description\">\n\t\t\t\t<b><?php", "esc_html_e", "(", "'Meta description'", ",", "'inc2734-wp-seo'", ")", ";", "?></b>\n\t\t\t</label><br />\n\t\t\t<input\n\t\t\t\ttype=\"text\"\n\t\t\t\tname=\"wp-seo-meta-description\"\n\t\t\t\tclass=\"widefat\"\n\t\t\t\tid=\"wp-seo-meta-description\"\n\t\t\t\tvalue=\"<?php", "echo", "esc_attr", "(", "get_post_meta", "(", "$", "post", "->", "ID", ",", "'wp-seo-meta-description'", ",", "true", ")", ")", ";", "?>\"\n\t\t\t/>\n\t\t</p>\n\t\t<p>\n\t\t\t<b><?php", "esc_html_e", "(", "'Meta robots'", ",", "'inc2734-wp-seo'", ")", ";", "?></b><br />\n\t\t\t<?php", "$", "robots", "=", "(", "array", ")", "get_post_meta", "(", "$", "post", "->", "ID", ",", "'wp-seo-meta-robots'", ",", "true", ")", ";", "$", "robots_choices", "=", "[", "'noindex'", ",", "'nofollow'", ",", "]", "?>\n\t\t\t<?php", "foreach", "(", "$", "robots_choices", "as", "$", "robot", ")", ":", "?>\n\t\t\t\t<label for=\"wp-seo-meta-robots-<?php", "echo", "esc_attr", "(", "$", "robot", ")", ";", "?>\" style=\"margin-right: 1em;\">\n\t\t\t\t\t<input\n\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\tname=\"wp-seo-meta-robots[]\"\n\t\t\t\t\t\tid=\"wp-seo-meta-robots-<?php", "echo", "esc_attr", "(", "$", "robot", ")", ";", "?>\"\n\t\t\t\t\t\tvalue=\"<?php", "echo", "esc_attr", "(", "$", "robot", ")", ";", "?>\"\n\t\t\t\t\t\t<?php", "checked", "(", "in_array", "(", "$", "robot", ",", "$", "robots", ")", ")", ";", "?>\n\t\t\t\t\t/>\n\t\t\t\t\t<?php", "echo", "esc_html", "(", "$", "robot", ")", ";", "?>\n\t\t\t\t</label>\n\t\t\t<?php", "endforeach", ";", "?>\n\t\t</p>\n\t\t<?php", "}" ]
Display meta box @param [WP_Post] $post @return void
[ "Display", "meta", "box" ]
d08f3fad346751232859c335d289237a82f9eef3
https://github.com/inc2734/wp-seo/blob/d08f3fad346751232859c335d289237a82f9eef3/src/App/Controller/Posts.php#L46-L84
19,949
inc2734/wp-seo
src/App/Controller/Posts.php
Posts._save_meta_description
public function _save_meta_description( $post_id ) { if ( empty( $_POST['wp-seo-meta-box-nonce'] ) ) { return; } if ( ! wp_verify_nonce( wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-box-nonce' ) ), 'wp-seo-meta-box-action' ) ) { return; } if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } if ( ! isset( $_POST['wp-seo-meta-description'] ) ) { return; } if ( is_array( $_POST['wp-seo-meta-description'] ) ) { return; } $meta_description = wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-description' ) ); update_post_meta( $post_id, 'wp-seo-meta-description', $meta_description ); }
php
public function _save_meta_description( $post_id ) { if ( empty( $_POST['wp-seo-meta-box-nonce'] ) ) { return; } if ( ! wp_verify_nonce( wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-box-nonce' ) ), 'wp-seo-meta-box-action' ) ) { return; } if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } if ( ! isset( $_POST['wp-seo-meta-description'] ) ) { return; } if ( is_array( $_POST['wp-seo-meta-description'] ) ) { return; } $meta_description = wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-description' ) ); update_post_meta( $post_id, 'wp-seo-meta-description', $meta_description ); }
[ "public", "function", "_save_meta_description", "(", "$", "post_id", ")", "{", "if", "(", "empty", "(", "$", "_POST", "[", "'wp-seo-meta-box-nonce'", "]", ")", ")", "{", "return", ";", "}", "if", "(", "!", "wp_verify_nonce", "(", "wp_unslash", "(", "filter_input", "(", "INPUT_POST", ",", "'wp-seo-meta-box-nonce'", ")", ")", ",", "'wp-seo-meta-box-action'", ")", ")", "{", "return", ";", "}", "if", "(", "defined", "(", "'DOING_AUTOSAVE'", ")", "&&", "DOING_AUTOSAVE", ")", "{", "return", ";", "}", "if", "(", "!", "current_user_can", "(", "'edit_post'", ",", "$", "post_id", ")", ")", "{", "return", ";", "}", "if", "(", "!", "isset", "(", "$", "_POST", "[", "'wp-seo-meta-description'", "]", ")", ")", "{", "return", ";", "}", "if", "(", "is_array", "(", "$", "_POST", "[", "'wp-seo-meta-description'", "]", ")", ")", "{", "return", ";", "}", "$", "meta_description", "=", "wp_unslash", "(", "filter_input", "(", "INPUT_POST", ",", "'wp-seo-meta-description'", ")", ")", ";", "update_post_meta", "(", "$", "post_id", ",", "'wp-seo-meta-description'", ",", "$", "meta_description", ")", ";", "}" ]
Save meta description @param [int] $post_id @return void
[ "Save", "meta", "description" ]
d08f3fad346751232859c335d289237a82f9eef3
https://github.com/inc2734/wp-seo/blob/d08f3fad346751232859c335d289237a82f9eef3/src/App/Controller/Posts.php#L92-L119
19,950
inc2734/wp-seo
src/App/Controller/Posts.php
Posts._save_meta_robots
public function _save_meta_robots( $post_id ) { if ( empty( $_POST['wp-seo-meta-box-nonce'] ) ) { return; } if ( ! wp_verify_nonce( wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-box-nonce' ) ), 'wp-seo-meta-box-action' ) ) { return; } if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } if ( ! isset( $_POST['wp-seo-meta-robots'] ) || ! is_array( $_POST['wp-seo-meta-robots'] ) ) { update_post_meta( $post_id, 'wp-seo-meta-robots', [] ); return; } $meta_robots = filter_input( INPUT_POST, 'wp-seo-meta-robots', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); update_post_meta( $post_id, 'wp-seo-meta-robots', $meta_robots ); }
php
public function _save_meta_robots( $post_id ) { if ( empty( $_POST['wp-seo-meta-box-nonce'] ) ) { return; } if ( ! wp_verify_nonce( wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-box-nonce' ) ), 'wp-seo-meta-box-action' ) ) { return; } if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } if ( ! isset( $_POST['wp-seo-meta-robots'] ) || ! is_array( $_POST['wp-seo-meta-robots'] ) ) { update_post_meta( $post_id, 'wp-seo-meta-robots', [] ); return; } $meta_robots = filter_input( INPUT_POST, 'wp-seo-meta-robots', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); update_post_meta( $post_id, 'wp-seo-meta-robots', $meta_robots ); }
[ "public", "function", "_save_meta_robots", "(", "$", "post_id", ")", "{", "if", "(", "empty", "(", "$", "_POST", "[", "'wp-seo-meta-box-nonce'", "]", ")", ")", "{", "return", ";", "}", "if", "(", "!", "wp_verify_nonce", "(", "wp_unslash", "(", "filter_input", "(", "INPUT_POST", ",", "'wp-seo-meta-box-nonce'", ")", ")", ",", "'wp-seo-meta-box-action'", ")", ")", "{", "return", ";", "}", "if", "(", "defined", "(", "'DOING_AUTOSAVE'", ")", "&&", "DOING_AUTOSAVE", ")", "{", "return", ";", "}", "if", "(", "!", "current_user_can", "(", "'edit_post'", ",", "$", "post_id", ")", ")", "{", "return", ";", "}", "if", "(", "!", "isset", "(", "$", "_POST", "[", "'wp-seo-meta-robots'", "]", ")", "||", "!", "is_array", "(", "$", "_POST", "[", "'wp-seo-meta-robots'", "]", ")", ")", "{", "update_post_meta", "(", "$", "post_id", ",", "'wp-seo-meta-robots'", ",", "[", "]", ")", ";", "return", ";", "}", "$", "meta_robots", "=", "filter_input", "(", "INPUT_POST", ",", "'wp-seo-meta-robots'", ",", "FILTER_DEFAULT", ",", "FILTER_REQUIRE_ARRAY", ")", ";", "update_post_meta", "(", "$", "post_id", ",", "'wp-seo-meta-robots'", ",", "$", "meta_robots", ")", ";", "}" ]
Save meta robots @param [int] $post_id @return void
[ "Save", "meta", "robots" ]
d08f3fad346751232859c335d289237a82f9eef3
https://github.com/inc2734/wp-seo/blob/d08f3fad346751232859c335d289237a82f9eef3/src/App/Controller/Posts.php#L127-L151
19,951
jfusion/org.jfusion.framework
src/Api/Platform.php
Platform.getTypeInstance
public static function getTypeInstance($type) { $type = ucfirst(strtolower($type)); if (!isset(self::$instances[$type])) { $class = 'JFusion\\Api\\Platform\\' . $type; self::$instances[$type] = new $class(); } return self::$instances[$type]; }
php
public static function getTypeInstance($type) { $type = ucfirst(strtolower($type)); if (!isset(self::$instances[$type])) { $class = 'JFusion\\Api\\Platform\\' . $type; self::$instances[$type] = new $class(); } return self::$instances[$type]; }
[ "public", "static", "function", "getTypeInstance", "(", "$", "type", ")", "{", "$", "type", "=", "ucfirst", "(", "strtolower", "(", "$", "type", ")", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "instances", "[", "$", "type", "]", ")", ")", "{", "$", "class", "=", "'JFusion\\\\Api\\\\Platform\\\\'", ".", "$", "type", ";", "self", "::", "$", "instances", "[", "$", "type", "]", "=", "new", "$", "class", "(", ")", ";", "}", "return", "self", "::", "$", "instances", "[", "$", "type", "]", ";", "}" ]
Get a platform type object. @param string $type @return Platform
[ "Get", "a", "platform", "type", "object", "." ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Platform.php#L43-L51
19,952
lode/fem
src/text.php
text.generate_token
public static function generate_token($length) { $byte_length = ($length / 2); $new_token = bin2hex(openssl_random_pseudo_bytes($byte_length, $strong_enough)); if ($strong_enough == false || empty($new_token)) { $exception = bootstrap::get_library('exception'); throw new $exception('can not generate cryptographically strong enough token'); } return $new_token; }
php
public static function generate_token($length) { $byte_length = ($length / 2); $new_token = bin2hex(openssl_random_pseudo_bytes($byte_length, $strong_enough)); if ($strong_enough == false || empty($new_token)) { $exception = bootstrap::get_library('exception'); throw new $exception('can not generate cryptographically strong enough token'); } return $new_token; }
[ "public", "static", "function", "generate_token", "(", "$", "length", ")", "{", "$", "byte_length", "=", "(", "$", "length", "/", "2", ")", ";", "$", "new_token", "=", "bin2hex", "(", "openssl_random_pseudo_bytes", "(", "$", "byte_length", ",", "$", "strong_enough", ")", ")", ";", "if", "(", "$", "strong_enough", "==", "false", "||", "empty", "(", "$", "new_token", ")", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "throw", "new", "$", "exception", "(", "'can not generate cryptographically strong enough token'", ")", ";", "}", "return", "$", "new_token", ";", "}" ]
generates cryptographically strong tokens @param int $length of the returned string @return string
[ "generates", "cryptographically", "strong", "tokens" ]
c1c466c1a904d99452b341c5ae7cbc3e22b106e1
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/text.php#L13-L22
19,953
factorio-item-browser/export-data
src/Entity/Icon.php
Icon.setLayers
public function setLayers(array $layers) { $this->layers = array_values(array_filter($layers, function ($layer): bool { return $layer instanceof Layer; })); return $this; }
php
public function setLayers(array $layers) { $this->layers = array_values(array_filter($layers, function ($layer): bool { return $layer instanceof Layer; })); return $this; }
[ "public", "function", "setLayers", "(", "array", "$", "layers", ")", "{", "$", "this", "->", "layers", "=", "array_values", "(", "array_filter", "(", "$", "layers", ",", "function", "(", "$", "layer", ")", ":", "bool", "{", "return", "$", "layer", "instanceof", "Layer", ";", "}", ")", ")", ";", "return", "$", "this", ";", "}" ]
Sets the layers of the icon. @param array|Layer[] $layers @return $this Implementing fluent interface.
[ "Sets", "the", "layers", "of", "the", "icon", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon.php#L98-L104
19,954
askupasoftware/amarkal
Loaders/AssetLoader.php
AssetLoader.register_asset
public function register_asset( \Amarkal\Assets\AbstractAsset $new_asset ) { if( NULL == $this->assets ) { $this->assets = array(); $this->assets[] = $new_asset; } else { foreach( $this->assets as $asset ) { if( $asset->handle == $new_asset->handle && get_class($asset) == get_class($new_asset) ) { throw new DuplicateAssetException("An asset with the handle {$new_asset->handle} already exists"); } } $this->assets[] = $new_asset; } }
php
public function register_asset( \Amarkal\Assets\AbstractAsset $new_asset ) { if( NULL == $this->assets ) { $this->assets = array(); $this->assets[] = $new_asset; } else { foreach( $this->assets as $asset ) { if( $asset->handle == $new_asset->handle && get_class($asset) == get_class($new_asset) ) { throw new DuplicateAssetException("An asset with the handle {$new_asset->handle} already exists"); } } $this->assets[] = $new_asset; } }
[ "public", "function", "register_asset", "(", "\\", "Amarkal", "\\", "Assets", "\\", "AbstractAsset", "$", "new_asset", ")", "{", "if", "(", "NULL", "==", "$", "this", "->", "assets", ")", "{", "$", "this", "->", "assets", "=", "array", "(", ")", ";", "$", "this", "->", "assets", "[", "]", "=", "$", "new_asset", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "assets", "as", "$", "asset", ")", "{", "if", "(", "$", "asset", "->", "handle", "==", "$", "new_asset", "->", "handle", "&&", "get_class", "(", "$", "asset", ")", "==", "get_class", "(", "$", "new_asset", ")", ")", "{", "throw", "new", "DuplicateAssetException", "(", "\"An asset with the handle {$new_asset->handle} already exists\"", ")", ";", "}", "}", "$", "this", "->", "assets", "[", "]", "=", "$", "new_asset", ";", "}", "}" ]
Register a single asset @param \Amarkal\Assets\AbstractAsset $new_asset The asset to enqueue @throws DuplicateAssetException If the a duplicated asset handle exists
[ "Register", "a", "single", "asset" ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Loaders/AssetLoader.php#L79-L93
19,955
webforge-labs/psc-cms
lib/Psc/Code/Code.php
Code.expandNamespace
public static function expandNamespace($classOrClassName, $expandNamespace) { if (mb_strpos($classOrClassName, '\\') !== 0 && self::getNamespace($classOrClassName) === NULL) { return $expandNamespace.'\\'.ltrim($classOrClassName,'\\'); } return $classOrClassName; }
php
public static function expandNamespace($classOrClassName, $expandNamespace) { if (mb_strpos($classOrClassName, '\\') !== 0 && self::getNamespace($classOrClassName) === NULL) { return $expandNamespace.'\\'.ltrim($classOrClassName,'\\'); } return $classOrClassName; }
[ "public", "static", "function", "expandNamespace", "(", "$", "classOrClassName", ",", "$", "expandNamespace", ")", "{", "if", "(", "mb_strpos", "(", "$", "classOrClassName", ",", "'\\\\'", ")", "!==", "0", "&&", "self", "::", "getNamespace", "(", "$", "classOrClassName", ")", "===", "NULL", ")", "{", "return", "$", "expandNamespace", ".", "'\\\\'", ".", "ltrim", "(", "$", "classOrClassName", ",", "'\\\\'", ")", ";", "}", "return", "$", "classOrClassName", ";", "}" ]
Erweitert einen nicht qualifzierten Klassenamen mit einem Namespace nicht qualifizierte Klassenamen sind diese ohne \ am Anfang und ohne self::getNamespace() wird root als leer übergeben, ist nicht gewährleistet, dass für alle parameter ein \ vor der Klasse steht: z. B. (blubb\className) wird nicht \blubb\className da blubb der namespace der klasse ist und somit nicht expanded wird @param $expandNamespace ohne \ am Ende (für "root" also NULL übergeben)
[ "Erweitert", "einen", "nicht", "qualifzierten", "Klassenamen", "mit", "einem", "Namespace" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Code.php#L223-L229
19,956
Chill-project/Main
Security/Authorization/AuthorizationHelper.php
AuthorizationHelper.userCanReachCenter
public function userCanReachCenter(User $user, Center $center) { foreach ($user->getGroupCenters() as $groupCenter) { if ($center->getId() === $groupCenter->getCenter()->getId()) { return true; } } return false; }
php
public function userCanReachCenter(User $user, Center $center) { foreach ($user->getGroupCenters() as $groupCenter) { if ($center->getId() === $groupCenter->getCenter()->getId()) { return true; } } return false; }
[ "public", "function", "userCanReachCenter", "(", "User", "$", "user", ",", "Center", "$", "center", ")", "{", "foreach", "(", "$", "user", "->", "getGroupCenters", "(", ")", "as", "$", "groupCenter", ")", "{", "if", "(", "$", "center", "->", "getId", "(", ")", "===", "$", "groupCenter", "->", "getCenter", "(", ")", "->", "getId", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Determines if a user is active on this center @param User $user @param Center $center @return bool
[ "Determines", "if", "a", "user", "is", "active", "on", "this", "center" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Security/Authorization/AuthorizationHelper.php#L60-L70
19,957
Chill-project/Main
Security/Authorization/AuthorizationHelper.php
AuthorizationHelper.getReachableCenters
public function getReachableCenters(User $user, Role $role, Scope $scope = null) { $centers = array(); foreach ($user->getGroupCenters() as $groupCenter){ $permissionGroup = $groupCenter->getPermissionsGroup(); //iterate on roleScopes foreach($permissionGroup->getRoleScopes() as $roleScope) { //check that the role is in the reachable roles if ($this->isRoleReached($role, new Role($roleScope->getRole()))) { if ($scope === null) { $centers[] = $groupCenter->getCenter(); break 1; } else { if ($scope->getId() == $roleScope->getScope()->getId()){ $centers[] = $groupCenter->getCenter(); break 1; } } } } } return $centers; }
php
public function getReachableCenters(User $user, Role $role, Scope $scope = null) { $centers = array(); foreach ($user->getGroupCenters() as $groupCenter){ $permissionGroup = $groupCenter->getPermissionsGroup(); //iterate on roleScopes foreach($permissionGroup->getRoleScopes() as $roleScope) { //check that the role is in the reachable roles if ($this->isRoleReached($role, new Role($roleScope->getRole()))) { if ($scope === null) { $centers[] = $groupCenter->getCenter(); break 1; } else { if ($scope->getId() == $roleScope->getScope()->getId()){ $centers[] = $groupCenter->getCenter(); break 1; } } } } } return $centers; }
[ "public", "function", "getReachableCenters", "(", "User", "$", "user", ",", "Role", "$", "role", ",", "Scope", "$", "scope", "=", "null", ")", "{", "$", "centers", "=", "array", "(", ")", ";", "foreach", "(", "$", "user", "->", "getGroupCenters", "(", ")", "as", "$", "groupCenter", ")", "{", "$", "permissionGroup", "=", "$", "groupCenter", "->", "getPermissionsGroup", "(", ")", ";", "//iterate on roleScopes", "foreach", "(", "$", "permissionGroup", "->", "getRoleScopes", "(", ")", "as", "$", "roleScope", ")", "{", "//check that the role is in the reachable roles", "if", "(", "$", "this", "->", "isRoleReached", "(", "$", "role", ",", "new", "Role", "(", "$", "roleScope", "->", "getRole", "(", ")", ")", ")", ")", "{", "if", "(", "$", "scope", "===", "null", ")", "{", "$", "centers", "[", "]", "=", "$", "groupCenter", "->", "getCenter", "(", ")", ";", "break", "1", ";", "}", "else", "{", "if", "(", "$", "scope", "->", "getId", "(", ")", "==", "$", "roleScope", "->", "getScope", "(", ")", "->", "getId", "(", ")", ")", "{", "$", "centers", "[", "]", "=", "$", "groupCenter", "->", "getCenter", "(", ")", ";", "break", "1", ";", "}", "}", "}", "}", "}", "return", "$", "centers", ";", "}" ]
Get reachable Centers for the given user, role, and optionnaly Scope @param User $user @param Role $role @param null|Scope $scope @return Center[]
[ "Get", "reachable", "Centers", "for", "the", "given", "user", "role", "and", "optionnaly", "Scope" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Security/Authorization/AuthorizationHelper.php#L136-L162
19,958
Chill-project/Main
Security/Authorization/AuthorizationHelper.php
AuthorizationHelper.getReachableScopes
public function getReachableScopes(User $user, Role $role, Center $center) { return $this->getReachableCircles($user, $role, $center); }
php
public function getReachableScopes(User $user, Role $role, Center $center) { return $this->getReachableCircles($user, $role, $center); }
[ "public", "function", "getReachableScopes", "(", "User", "$", "user", ",", "Role", "$", "role", ",", "Center", "$", "center", ")", "{", "return", "$", "this", "->", "getReachableCircles", "(", "$", "user", ",", "$", "role", ",", "$", "center", ")", ";", "}" ]
Return all reachable scope for a given user, center and role @deprecated Use getReachableCircles @param User $user @param Role $role @param Center $center @return Scope[]
[ "Return", "all", "reachable", "scope", "for", "a", "given", "user", "center", "and", "role" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Security/Authorization/AuthorizationHelper.php#L174-L177
19,959
Chill-project/Main
Security/Authorization/AuthorizationHelper.php
AuthorizationHelper.getReachableCircles
public function getReachableCircles(User $user, Role $role, Center $center) { $scopes = array(); foreach ($user->getGroupCenters() as $groupCenter){ if ($center->getId() === $groupCenter->getCenter()->getId()) { //iterate on permissionGroup $permissionGroup = $groupCenter->getPermissionsGroup(); //iterate on roleScopes foreach($permissionGroup->getRoleScopes() as $roleScope) { //check that the role is in the reachable roles if ($this->isRoleReached($role, new Role($roleScope->getRole()))) { $scopes[] = $roleScope->getScope(); } } } } return $scopes; }
php
public function getReachableCircles(User $user, Role $role, Center $center) { $scopes = array(); foreach ($user->getGroupCenters() as $groupCenter){ if ($center->getId() === $groupCenter->getCenter()->getId()) { //iterate on permissionGroup $permissionGroup = $groupCenter->getPermissionsGroup(); //iterate on roleScopes foreach($permissionGroup->getRoleScopes() as $roleScope) { //check that the role is in the reachable roles if ($this->isRoleReached($role, new Role($roleScope->getRole()))) { $scopes[] = $roleScope->getScope(); } } } } return $scopes; }
[ "public", "function", "getReachableCircles", "(", "User", "$", "user", ",", "Role", "$", "role", ",", "Center", "$", "center", ")", "{", "$", "scopes", "=", "array", "(", ")", ";", "foreach", "(", "$", "user", "->", "getGroupCenters", "(", ")", "as", "$", "groupCenter", ")", "{", "if", "(", "$", "center", "->", "getId", "(", ")", "===", "$", "groupCenter", "->", "getCenter", "(", ")", "->", "getId", "(", ")", ")", "{", "//iterate on permissionGroup", "$", "permissionGroup", "=", "$", "groupCenter", "->", "getPermissionsGroup", "(", ")", ";", "//iterate on roleScopes", "foreach", "(", "$", "permissionGroup", "->", "getRoleScopes", "(", ")", "as", "$", "roleScope", ")", "{", "//check that the role is in the reachable roles", "if", "(", "$", "this", "->", "isRoleReached", "(", "$", "role", ",", "new", "Role", "(", "$", "roleScope", "->", "getRole", "(", ")", ")", ")", ")", "{", "$", "scopes", "[", "]", "=", "$", "roleScope", "->", "getScope", "(", ")", ";", "}", "}", "}", "}", "return", "$", "scopes", ";", "}" ]
Return all reachable circle for a given user, center and role @param User $user @param Role $role @param Center $center @return Scope[]
[ "Return", "all", "reachable", "circle", "for", "a", "given", "user", "center", "and", "role" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Security/Authorization/AuthorizationHelper.php#L187-L208
19,960
Chill-project/Main
Security/Authorization/AuthorizationHelper.php
AuthorizationHelper.isRoleReached
protected function isRoleReached(Role $childRole, Role $parentRole) { $reachableRoles = $this->roleHierarchy ->getReachableRoles([$parentRole]); return in_array($childRole, $reachableRoles); }
php
protected function isRoleReached(Role $childRole, Role $parentRole) { $reachableRoles = $this->roleHierarchy ->getReachableRoles([$parentRole]); return in_array($childRole, $reachableRoles); }
[ "protected", "function", "isRoleReached", "(", "Role", "$", "childRole", ",", "Role", "$", "parentRole", ")", "{", "$", "reachableRoles", "=", "$", "this", "->", "roleHierarchy", "->", "getReachableRoles", "(", "[", "$", "parentRole", "]", ")", ";", "return", "in_array", "(", "$", "childRole", ",", "$", "reachableRoles", ")", ";", "}" ]
Test if a parent role may give access to a given child role @param Role $childRole The role we want to test if he is reachable @param Role $parentRole The role which should give access to $childRole @return boolean true if the child role is granted by parent role
[ "Test", "if", "a", "parent", "role", "may", "give", "access", "to", "a", "given", "child", "role" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Security/Authorization/AuthorizationHelper.php#L219-L225
19,961
aedart/laravel-helpers
src/Traits/Cache/CacheStoreTrait.php
CacheStoreTrait.getCacheStore
public function getCacheStore(): ?Store { if (!$this->hasCacheStore()) { $this->setCacheStore($this->getDefaultCacheStore()); } return $this->cacheStore; }
php
public function getCacheStore(): ?Store { if (!$this->hasCacheStore()) { $this->setCacheStore($this->getDefaultCacheStore()); } return $this->cacheStore; }
[ "public", "function", "getCacheStore", "(", ")", ":", "?", "Store", "{", "if", "(", "!", "$", "this", "->", "hasCacheStore", "(", ")", ")", "{", "$", "this", "->", "setCacheStore", "(", "$", "this", "->", "getDefaultCacheStore", "(", ")", ")", ";", "}", "return", "$", "this", "->", "cacheStore", ";", "}" ]
Get cache store If no cache store has been set, this method will set and return a default cache store, if any such value is available @see getDefaultCacheStore() @return Store|null cache store or null if none cache store has been set
[ "Get", "cache", "store" ]
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Cache/CacheStoreTrait.php#L54-L60
19,962
aedart/laravel-helpers
src/Traits/Cache/CacheStoreTrait.php
CacheStoreTrait.getDefaultCacheStore
public function getDefaultCacheStore(): ?Store { // We do not know what store is desired. Therefore, // the safest bet is to obtain the default $manager = Cache::getFacadeRoot(); if (isset($manager)) { /** @var Repository $repository */ $repository = $manager->store(); return $repository->getStore(); } return $manager; }
php
public function getDefaultCacheStore(): ?Store { // We do not know what store is desired. Therefore, // the safest bet is to obtain the default $manager = Cache::getFacadeRoot(); if (isset($manager)) { /** @var Repository $repository */ $repository = $manager->store(); return $repository->getStore(); } return $manager; }
[ "public", "function", "getDefaultCacheStore", "(", ")", ":", "?", "Store", "{", "// We do not know what store is desired. Therefore,", "// the safest bet is to obtain the default", "$", "manager", "=", "Cache", "::", "getFacadeRoot", "(", ")", ";", "if", "(", "isset", "(", "$", "manager", ")", ")", "{", "/** @var Repository $repository */", "$", "repository", "=", "$", "manager", "->", "store", "(", ")", ";", "return", "$", "repository", "->", "getStore", "(", ")", ";", "}", "return", "$", "manager", ";", "}" ]
Get a default cache store value, if any is available @return Store|null A default cache store value or Null if no default value is available
[ "Get", "a", "default", "cache", "store", "value", "if", "any", "is", "available" ]
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Cache/CacheStoreTrait.php#L77-L88
19,963
prolic/Concurrent-PHP-Utils
src/ConcurrentPhpUtils/CasThreadedMemberTrait.php
CasThreadedMemberTrait.casMember
public function casMember($member, $oldValue, $newValue) { $set = false; $this->lock(); if ($this[$member] == $oldValue) { $this[$member] = $newValue; $set = true; } $this->unlock(); return $set; }
php
public function casMember($member, $oldValue, $newValue) { $set = false; $this->lock(); if ($this[$member] == $oldValue) { $this[$member] = $newValue; $set = true; } $this->unlock(); return $set; }
[ "public", "function", "casMember", "(", "$", "member", ",", "$", "oldValue", ",", "$", "newValue", ")", "{", "$", "set", "=", "false", ";", "$", "this", "->", "lock", "(", ")", ";", "if", "(", "$", "this", "[", "$", "member", "]", "==", "$", "oldValue", ")", "{", "$", "this", "[", "$", "member", "]", "=", "$", "newValue", ";", "$", "set", "=", "true", ";", "}", "$", "this", "->", "unlock", "(", ")", ";", "return", "$", "set", ";", "}" ]
Performs a compare and swap operation on a class member @param string $member @param mixed $oldValue @param mixed $newValue @return bool
[ "Performs", "a", "compare", "and", "swap", "operation", "on", "a", "class", "member" ]
771b55b3ef79d9a7443c4f6d95373f41b9f34c4a
https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/CasThreadedMemberTrait.php#L20-L33
19,964
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/NotificationCenterController.php
NotificationCenterController.indexAction
public function indexAction() { $id = $this->getUser()->getId(); /** @var User $oUser */ $oUser = UserQuery::create()->findOneById($id); $form = $this->createFormBuilder($oUser) ->setAction($this->generateUrl("notification_center_update")) ->add('notification_change', 'checkbox') ->add('notification_error', 'checkbox') ->add('save', 'submit', array('label' => $this->get('translator')->trans('notificationcenter.form.save'))) ->getForm(); return $this->render('SlashworksAppBundle:NotificationCenter:index.html.twig', array( 'user' => $oUser, 'form' => $form->createView() )); }
php
public function indexAction() { $id = $this->getUser()->getId(); /** @var User $oUser */ $oUser = UserQuery::create()->findOneById($id); $form = $this->createFormBuilder($oUser) ->setAction($this->generateUrl("notification_center_update")) ->add('notification_change', 'checkbox') ->add('notification_error', 'checkbox') ->add('save', 'submit', array('label' => $this->get('translator')->trans('notificationcenter.form.save'))) ->getForm(); return $this->render('SlashworksAppBundle:NotificationCenter:index.html.twig', array( 'user' => $oUser, 'form' => $form->createView() )); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "id", "=", "$", "this", "->", "getUser", "(", ")", "->", "getId", "(", ")", ";", "/** @var User $oUser */", "$", "oUser", "=", "UserQuery", "::", "create", "(", ")", "->", "findOneById", "(", "$", "id", ")", ";", "$", "form", "=", "$", "this", "->", "createFormBuilder", "(", "$", "oUser", ")", "->", "setAction", "(", "$", "this", "->", "generateUrl", "(", "\"notification_center_update\"", ")", ")", "->", "add", "(", "'notification_change'", ",", "'checkbox'", ")", "->", "add", "(", "'notification_error'", ",", "'checkbox'", ")", "->", "add", "(", "'save'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'notificationcenter.form.save'", ")", ")", ")", "->", "getForm", "(", ")", ";", "return", "$", "this", "->", "render", "(", "'SlashworksAppBundle:NotificationCenter:index.html.twig'", ",", "array", "(", "'user'", "=>", "$", "oUser", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ")", ")", ";", "}" ]
Display form for notification settings @return \Symfony\Component\HttpFoundation\Response
[ "Display", "form", "for", "notification", "settings" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/NotificationCenterController.php#L41-L61
19,965
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/NotificationCenterController.php
NotificationCenterController.updateAction
public function updateAction(Request $request) { try { $id = $this->getUser()->getId(); /** @var User $oUser */ $oUser = UserQuery::create()->findOneById($id); if ($oUser === null) { throw $this->createNotFoundException('Unable to find User entity.'); } $aPost = $request->request->get("form"); $nbUpdatedRows = UserQuery::create() ->filterById($id) ->update(array('NotificationError' => isset($aPost['notification_error']), 'NotificationChange' => isset($aPost['notification_change']))); $aResult = array( "success" => true, "message" => $this->get("translator")->trans("notificationcenter.save.successful") ); } catch (\Exception $e) { $aResult = array( "success" => false, "message" => $this->get("translator")->trans("notificationcenter.save.failed") . ":<br>" . $e->getMessage() ); } $sResult = json_encode($aResult); $response = new Response($sResult); $response->headers->set('Content-Type', 'application/json'); return $response; }
php
public function updateAction(Request $request) { try { $id = $this->getUser()->getId(); /** @var User $oUser */ $oUser = UserQuery::create()->findOneById($id); if ($oUser === null) { throw $this->createNotFoundException('Unable to find User entity.'); } $aPost = $request->request->get("form"); $nbUpdatedRows = UserQuery::create() ->filterById($id) ->update(array('NotificationError' => isset($aPost['notification_error']), 'NotificationChange' => isset($aPost['notification_change']))); $aResult = array( "success" => true, "message" => $this->get("translator")->trans("notificationcenter.save.successful") ); } catch (\Exception $e) { $aResult = array( "success" => false, "message" => $this->get("translator")->trans("notificationcenter.save.failed") . ":<br>" . $e->getMessage() ); } $sResult = json_encode($aResult); $response = new Response($sResult); $response->headers->set('Content-Type', 'application/json'); return $response; }
[ "public", "function", "updateAction", "(", "Request", "$", "request", ")", "{", "try", "{", "$", "id", "=", "$", "this", "->", "getUser", "(", ")", "->", "getId", "(", ")", ";", "/** @var User $oUser */", "$", "oUser", "=", "UserQuery", "::", "create", "(", ")", "->", "findOneById", "(", "$", "id", ")", ";", "if", "(", "$", "oUser", "===", "null", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find User entity.'", ")", ";", "}", "$", "aPost", "=", "$", "request", "->", "request", "->", "get", "(", "\"form\"", ")", ";", "$", "nbUpdatedRows", "=", "UserQuery", "::", "create", "(", ")", "->", "filterById", "(", "$", "id", ")", "->", "update", "(", "array", "(", "'NotificationError'", "=>", "isset", "(", "$", "aPost", "[", "'notification_error'", "]", ")", ",", "'NotificationChange'", "=>", "isset", "(", "$", "aPost", "[", "'notification_change'", "]", ")", ")", ")", ";", "$", "aResult", "=", "array", "(", "\"success\"", "=>", "true", ",", "\"message\"", "=>", "$", "this", "->", "get", "(", "\"translator\"", ")", "->", "trans", "(", "\"notificationcenter.save.successful\"", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "aResult", "=", "array", "(", "\"success\"", "=>", "false", ",", "\"message\"", "=>", "$", "this", "->", "get", "(", "\"translator\"", ")", "->", "trans", "(", "\"notificationcenter.save.failed\"", ")", ".", "\":<br>\"", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "sResult", "=", "json_encode", "(", "$", "aResult", ")", ";", "$", "response", "=", "new", "Response", "(", "$", "sResult", ")", ";", "$", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "return", "$", "response", ";", "}" ]
Update notification settings @param \Symfony\Component\HttpFoundation\Request $request @return \Symfony\Component\HttpFoundation\Response
[ "Update", "notification", "settings" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/NotificationCenterController.php#L71-L110
19,966
CakeCMS/Core
src/Event/CoreEventHandler.php
CoreEventHandler.onControllerSetup
public function onControllerSetup(Event $event) { /** @var AppController $controller */ $controller = $event->getSubject(); $isAdmin = ($controller->request->getParam('prefix') === 'admin'); $plugins = Plugin::loaded(); foreach ($plugins as $plugin) { $path = Plugin::path($plugin); $menuFile = ($isAdmin) ? 'admin_menu' : 'menu'; $navConf = $path . 'config/' . $menuFile . '.php'; if (FS::isFile($navConf)) { /** @noinspection PhpIncludeInspection */ require_once $navConf; } } }
php
public function onControllerSetup(Event $event) { /** @var AppController $controller */ $controller = $event->getSubject(); $isAdmin = ($controller->request->getParam('prefix') === 'admin'); $plugins = Plugin::loaded(); foreach ($plugins as $plugin) { $path = Plugin::path($plugin); $menuFile = ($isAdmin) ? 'admin_menu' : 'menu'; $navConf = $path . 'config/' . $menuFile . '.php'; if (FS::isFile($navConf)) { /** @noinspection PhpIncludeInspection */ require_once $navConf; } } }
[ "public", "function", "onControllerSetup", "(", "Event", "$", "event", ")", "{", "/** @var AppController $controller */", "$", "controller", "=", "$", "event", "->", "getSubject", "(", ")", ";", "$", "isAdmin", "=", "(", "$", "controller", "->", "request", "->", "getParam", "(", "'prefix'", ")", "===", "'admin'", ")", ";", "$", "plugins", "=", "Plugin", "::", "loaded", "(", ")", ";", "foreach", "(", "$", "plugins", "as", "$", "plugin", ")", "{", "$", "path", "=", "Plugin", "::", "path", "(", "$", "plugin", ")", ";", "$", "menuFile", "=", "(", "$", "isAdmin", ")", "?", "'admin_menu'", ":", "'menu'", ";", "$", "navConf", "=", "$", "path", ".", "'config/'", ".", "$", "menuFile", ".", "'.php'", ";", "if", "(", "FS", "::", "isFile", "(", "$", "navConf", ")", ")", "{", "/** @noinspection PhpIncludeInspection */", "require_once", "$", "navConf", ";", "}", "}", "}" ]
On controller setup. @param Event $event @return void
[ "On", "controller", "setup", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Event/CoreEventHandler.php#L50-L67
19,967
webforge-labs/psc-cms
lib/Psc/CMS/EntityMeta.php
EntityMeta.getNewFormRequestMeta
public function getNewFormRequestMeta($clone = TRUE) { if (!isset($this->newFormRequestMeta)) { $this->newFormRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::GET, $this->constructUrl(array($this->getEntityNamePlural(), 'form')) ); } if ($clone) { return clone $this->newFormRequestMeta; } else { return $this->newFormRequestMeta; } }
php
public function getNewFormRequestMeta($clone = TRUE) { if (!isset($this->newFormRequestMeta)) { $this->newFormRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::GET, $this->constructUrl(array($this->getEntityNamePlural(), 'form')) ); } if ($clone) { return clone $this->newFormRequestMeta; } else { return $this->newFormRequestMeta; } }
[ "public", "function", "getNewFormRequestMeta", "(", "$", "clone", "=", "TRUE", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "newFormRequestMeta", ")", ")", "{", "$", "this", "->", "newFormRequestMeta", "=", "new", "RequestMeta", "(", "\\", "Psc", "\\", "Net", "\\", "HTTP", "\\", "Request", "::", "GET", ",", "$", "this", "->", "constructUrl", "(", "array", "(", "$", "this", "->", "getEntityNamePlural", "(", ")", ",", "'form'", ")", ")", ")", ";", "}", "if", "(", "$", "clone", ")", "{", "return", "clone", "$", "this", "->", "newFormRequestMeta", ";", "}", "else", "{", "return", "$", "this", "->", "newFormRequestMeta", ";", "}", "}" ]
Zeigt das "Entity erstellen" Formular an @return Psc\CMS\RequestMeta
[ "Zeigt", "das", "Entity", "erstellen", "Formular", "an" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/EntityMeta.php#L614-L626
19,968
webforge-labs/psc-cms
lib/Psc/CMS/EntityMeta.php
EntityMeta.getSearchRequestMeta
public function getSearchRequestMeta(Array $query = NULL) { if (!isset($this->searchRequestMeta)) { $this->searchRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::GET, $this->constructUrl(array($this->getEntityNamePlural(), '%s')), array(RequestMeta::QUERY) ); } if (isset($query)) { $meta = clone $this->searchRequestMeta; return $meta->setInput($query); } return $this->searchRequestMeta; }
php
public function getSearchRequestMeta(Array $query = NULL) { if (!isset($this->searchRequestMeta)) { $this->searchRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::GET, $this->constructUrl(array($this->getEntityNamePlural(), '%s')), array(RequestMeta::QUERY) ); } if (isset($query)) { $meta = clone $this->searchRequestMeta; return $meta->setInput($query); } return $this->searchRequestMeta; }
[ "public", "function", "getSearchRequestMeta", "(", "Array", "$", "query", "=", "NULL", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "searchRequestMeta", ")", ")", "{", "$", "this", "->", "searchRequestMeta", "=", "new", "RequestMeta", "(", "\\", "Psc", "\\", "Net", "\\", "HTTP", "\\", "Request", "::", "GET", ",", "$", "this", "->", "constructUrl", "(", "array", "(", "$", "this", "->", "getEntityNamePlural", "(", ")", ",", "'%s'", ")", ")", ",", "array", "(", "RequestMeta", "::", "QUERY", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "query", ")", ")", "{", "$", "meta", "=", "clone", "$", "this", "->", "searchRequestMeta", ";", "return", "$", "meta", "->", "setInput", "(", "$", "query", ")", ";", "}", "return", "$", "this", "->", "searchRequestMeta", ";", "}" ]
Request zum Suchen von Entities und zur LowLevel Ausgabe @return Psc\CMS\RequestMeta
[ "Request", "zum", "Suchen", "von", "Entities", "und", "zur", "LowLevel", "Ausgabe" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/EntityMeta.php#L633-L646
19,969
webforge-labs/psc-cms
lib/Psc/CMS/Controller/GPCController.php
GPCController.initTodo
public function initTodo() { $todo = $this->getVar(array('todo'),'GP'); $this->assertTodo($todo); $this->setTodo($todo); if (!isset($this->todo)) $this->todo = $this->defaultTodo; }
php
public function initTodo() { $todo = $this->getVar(array('todo'),'GP'); $this->assertTodo($todo); $this->setTodo($todo); if (!isset($this->todo)) $this->todo = $this->defaultTodo; }
[ "public", "function", "initTodo", "(", ")", "{", "$", "todo", "=", "$", "this", "->", "getVar", "(", "array", "(", "'todo'", ")", ",", "'GP'", ")", ";", "$", "this", "->", "assertTodo", "(", "$", "todo", ")", ";", "$", "this", "->", "setTodo", "(", "$", "todo", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "todo", ")", ")", "$", "this", "->", "todo", "=", "$", "this", "->", "defaultTodo", ";", "}" ]
Initialisiert das Todo des Controllers der Schlüssel 'todo' muss in $this->vars gesetzt sein, damit ein todo aus der Map genommen wird ist der Schlüssel gesetzt, aber der Wert nicht in der todoMap wird eine Exception geworfen ist der Schlüssel nicht gesetzt, wird $this->todo auf $this->defaultTodo gessetzt $_POST['todo'] hat Vorrang vor $_GET['todo'] Es wird immer setTodo() mit dem gefundenen Wert aufgerufen @uses validateTodo(), setTodo()
[ "Initialisiert", "das", "Todo", "des", "Controllers" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Controller/GPCController.php#L52-L59
19,970
webforge-labs/psc-cms
lib/Psc/CMS/Service/MetadataGenerator.php
MetadataGenerator.entity
public function entity(Entity $entity, Array $linkRelations = array()) { if (!isset($this->meta['links'])) $this->meta['links'] = array(); foreach ($linkRelations as $linkRelation) { $this->meta['links'][] = (object) array( 'rel'=>$linkRelation->getName(), 'href'=>$linkRelation->getHref() ); } return $this; }
php
public function entity(Entity $entity, Array $linkRelations = array()) { if (!isset($this->meta['links'])) $this->meta['links'] = array(); foreach ($linkRelations as $linkRelation) { $this->meta['links'][] = (object) array( 'rel'=>$linkRelation->getName(), 'href'=>$linkRelation->getHref() ); } return $this; }
[ "public", "function", "entity", "(", "Entity", "$", "entity", ",", "Array", "$", "linkRelations", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "meta", "[", "'links'", "]", ")", ")", "$", "this", "->", "meta", "[", "'links'", "]", "=", "array", "(", ")", ";", "foreach", "(", "$", "linkRelations", "as", "$", "linkRelation", ")", "{", "$", "this", "->", "meta", "[", "'links'", "]", "[", "]", "=", "(", "object", ")", "array", "(", "'rel'", "=>", "$", "linkRelation", "->", "getName", "(", ")", ",", "'href'", "=>", "$", "linkRelation", "->", "getHref", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds metadata for the reponse from an Entity @param Psc\Net\Service\LinkRelation[] $linkRelations
[ "Adds", "metadata", "for", "the", "reponse", "from", "an", "Entity" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Service/MetadataGenerator.php#L47-L59
19,971
hametuha/gapiwp
src/Hametuha/GapiWP/Service/Analytics.php
Analytics.get_accounts
public function get_accounts(){ static $ga_accounts = null; if( !is_null($ga_accounts) ){ return $ga_accounts; } $ga_accounts = array(); if( $this->ga ){ try{ $accounts = $this->ga->management_accounts->listManagementAccounts(); if( count($accounts->getItems()) > 0 ){ $ga_accounts = $accounts; } }catch (\Exception $e){ // Do nothing. error_log($e->getMessage(), $e->getCode()); } } return $ga_accounts; }
php
public function get_accounts(){ static $ga_accounts = null; if( !is_null($ga_accounts) ){ return $ga_accounts; } $ga_accounts = array(); if( $this->ga ){ try{ $accounts = $this->ga->management_accounts->listManagementAccounts(); if( count($accounts->getItems()) > 0 ){ $ga_accounts = $accounts; } }catch (\Exception $e){ // Do nothing. error_log($e->getMessage(), $e->getCode()); } } return $ga_accounts; }
[ "public", "function", "get_accounts", "(", ")", "{", "static", "$", "ga_accounts", "=", "null", ";", "if", "(", "!", "is_null", "(", "$", "ga_accounts", ")", ")", "{", "return", "$", "ga_accounts", ";", "}", "$", "ga_accounts", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "ga", ")", "{", "try", "{", "$", "accounts", "=", "$", "this", "->", "ga", "->", "management_accounts", "->", "listManagementAccounts", "(", ")", ";", "if", "(", "count", "(", "$", "accounts", "->", "getItems", "(", ")", ")", ">", "0", ")", "{", "$", "ga_accounts", "=", "$", "accounts", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// Do nothing.", "error_log", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ")", ";", "}", "}", "return", "$", "ga_accounts", ";", "}" ]
Get account list @return array|\Google_Service_Analytics_Accounts
[ "Get", "account", "list" ]
7b9716d0ebd54c4ab79cca94a4c5aef099a54266
https://github.com/hametuha/gapiwp/blob/7b9716d0ebd54c4ab79cca94a4c5aef099a54266/src/Hametuha/GapiWP/Service/Analytics.php#L127-L145
19,972
hametuha/gapiwp
src/Hametuha/GapiWP/Service/Analytics.php
Analytics.get_properties
public function get_properties($account_id) { $result = array(); try { if ( $this->ga ) { $properties = $this->ga ->management_webproperties ->listManagementWebproperties( $account_id ); $result = $properties->getItems(); } } catch ( \Exception $e ) { // Do nothing. error_log($e->getMessage(), $e->getCode()); } return $result; }
php
public function get_properties($account_id) { $result = array(); try { if ( $this->ga ) { $properties = $this->ga ->management_webproperties ->listManagementWebproperties( $account_id ); $result = $properties->getItems(); } } catch ( \Exception $e ) { // Do nothing. error_log($e->getMessage(), $e->getCode()); } return $result; }
[ "public", "function", "get_properties", "(", "$", "account_id", ")", "{", "$", "result", "=", "array", "(", ")", ";", "try", "{", "if", "(", "$", "this", "->", "ga", ")", "{", "$", "properties", "=", "$", "this", "->", "ga", "->", "management_webproperties", "->", "listManagementWebproperties", "(", "$", "account_id", ")", ";", "$", "result", "=", "$", "properties", "->", "getItems", "(", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// Do nothing.", "error_log", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get Web Properties @param $account_id @return array
[ "Get", "Web", "Properties" ]
7b9716d0ebd54c4ab79cca94a4c5aef099a54266
https://github.com/hametuha/gapiwp/blob/7b9716d0ebd54c4ab79cca94a4c5aef099a54266/src/Hametuha/GapiWP/Service/Analytics.php#L153-L167
19,973
redaigbaria/oauth2
src/Entity/AccessTokenEntity.php
AccessTokenEntity.getScopes
public function getScopes() { if ($this->scopes === null) { $this->scopes = $this->formatScopes( $this->server->getAccessTokenStorage()->getScopes($this) ); } return $this->scopes; }
php
public function getScopes() { if ($this->scopes === null) { $this->scopes = $this->formatScopes( $this->server->getAccessTokenStorage()->getScopes($this) ); } return $this->scopes; }
[ "public", "function", "getScopes", "(", ")", "{", "if", "(", "$", "this", "->", "scopes", "===", "null", ")", "{", "$", "this", "->", "scopes", "=", "$", "this", "->", "formatScopes", "(", "$", "this", "->", "server", "->", "getAccessTokenStorage", "(", ")", "->", "getScopes", "(", "$", "this", ")", ")", ";", "}", "return", "$", "this", "->", "scopes", ";", "}" ]
Return all scopes associated with the access token @return \League\OAuth2\Server\Entity\ScopeEntity[]
[ "Return", "all", "scopes", "associated", "with", "the", "access", "token" ]
54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Entity/AccessTokenEntity.php#L56-L65
19,974
CakeCMS/Core
src/View/Helper/NavHelper.php
NavHelper.render
public function render($key, array $items = [], array $options = [], $level = 1) { $i = 0; $output = []; $options = Hash::merge($this->_default, $options); $sorted = Hash::sort($items, '{s}.weight', 'ASC'); $itemCount = count($sorted); foreach ($sorted as $item) { $i++; $item = $this->_setFirstLast($i, $itemCount, $item); $children = false; if (count($item['children']) > 0) { $children = $this->render($key, $item['children'], $options, $level + 1); } $itemParams = [ 'options' => $options, 'item' => $item, 'count' => $i, 'children' => $children, 'level' => $level, ]; $this->_setItemParams($itemParams); if (isset($item['callable']) && is_callable($item['callable'])) { $output[] = call_user_func_array($item['callable'], array_merge(['view' => $this->_View], $itemParams)); } else { $output[] = $this->_View->element($options['itemElement'], $itemParams); } } $element = $this->_getCurrentMenuElement($options, $level); return $this->_View->element($element, [ 'content' => $output, 'options' => $options, ]); }
php
public function render($key, array $items = [], array $options = [], $level = 1) { $i = 0; $output = []; $options = Hash::merge($this->_default, $options); $sorted = Hash::sort($items, '{s}.weight', 'ASC'); $itemCount = count($sorted); foreach ($sorted as $item) { $i++; $item = $this->_setFirstLast($i, $itemCount, $item); $children = false; if (count($item['children']) > 0) { $children = $this->render($key, $item['children'], $options, $level + 1); } $itemParams = [ 'options' => $options, 'item' => $item, 'count' => $i, 'children' => $children, 'level' => $level, ]; $this->_setItemParams($itemParams); if (isset($item['callable']) && is_callable($item['callable'])) { $output[] = call_user_func_array($item['callable'], array_merge(['view' => $this->_View], $itemParams)); } else { $output[] = $this->_View->element($options['itemElement'], $itemParams); } } $element = $this->_getCurrentMenuElement($options, $level); return $this->_View->element($element, [ 'content' => $output, 'options' => $options, ]); }
[ "public", "function", "render", "(", "$", "key", ",", "array", "$", "items", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ",", "$", "level", "=", "1", ")", "{", "$", "i", "=", "0", ";", "$", "output", "=", "[", "]", ";", "$", "options", "=", "Hash", "::", "merge", "(", "$", "this", "->", "_default", ",", "$", "options", ")", ";", "$", "sorted", "=", "Hash", "::", "sort", "(", "$", "items", ",", "'{s}.weight'", ",", "'ASC'", ")", ";", "$", "itemCount", "=", "count", "(", "$", "sorted", ")", ";", "foreach", "(", "$", "sorted", "as", "$", "item", ")", "{", "$", "i", "++", ";", "$", "item", "=", "$", "this", "->", "_setFirstLast", "(", "$", "i", ",", "$", "itemCount", ",", "$", "item", ")", ";", "$", "children", "=", "false", ";", "if", "(", "count", "(", "$", "item", "[", "'children'", "]", ")", ">", "0", ")", "{", "$", "children", "=", "$", "this", "->", "render", "(", "$", "key", ",", "$", "item", "[", "'children'", "]", ",", "$", "options", ",", "$", "level", "+", "1", ")", ";", "}", "$", "itemParams", "=", "[", "'options'", "=>", "$", "options", ",", "'item'", "=>", "$", "item", ",", "'count'", "=>", "$", "i", ",", "'children'", "=>", "$", "children", ",", "'level'", "=>", "$", "level", ",", "]", ";", "$", "this", "->", "_setItemParams", "(", "$", "itemParams", ")", ";", "if", "(", "isset", "(", "$", "item", "[", "'callable'", "]", ")", "&&", "is_callable", "(", "$", "item", "[", "'callable'", "]", ")", ")", "{", "$", "output", "[", "]", "=", "call_user_func_array", "(", "$", "item", "[", "'callable'", "]", ",", "array_merge", "(", "[", "'view'", "=>", "$", "this", "->", "_View", "]", ",", "$", "itemParams", ")", ")", ";", "}", "else", "{", "$", "output", "[", "]", "=", "$", "this", "->", "_View", "->", "element", "(", "$", "options", "[", "'itemElement'", "]", ",", "$", "itemParams", ")", ";", "}", "}", "$", "element", "=", "$", "this", "->", "_getCurrentMenuElement", "(", "$", "options", ",", "$", "level", ")", ";", "return", "$", "this", "->", "_View", "->", "element", "(", "$", "element", ",", "[", "'content'", "=>", "$", "output", ",", "'options'", "=>", "$", "options", ",", "]", ")", ";", "}" ]
Render menu. @param string $key @param array $items @param array $options @param int $level @return string @SuppressWarnings(PHPMD.ShortVariable)
[ "Render", "menu", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/NavHelper.php#L73-L113
19,975
CakeCMS/Core
src/View/Helper/NavHelper.php
NavHelper._getCurrentMenuElement
protected function _getCurrentMenuElement(array $options = [], $level = 1) { if ($level > 1) { $levelElement = $this->_getLevelElement($options, $level); if ($this->_View->elementExists($levelElement)) { return $levelElement; } return $options['childMenuAttr']['element']; } return $options['menuAttr']['element']; }
php
protected function _getCurrentMenuElement(array $options = [], $level = 1) { if ($level > 1) { $levelElement = $this->_getLevelElement($options, $level); if ($this->_View->elementExists($levelElement)) { return $levelElement; } return $options['childMenuAttr']['element']; } return $options['menuAttr']['element']; }
[ "protected", "function", "_getCurrentMenuElement", "(", "array", "$", "options", "=", "[", "]", ",", "$", "level", "=", "1", ")", "{", "if", "(", "$", "level", ">", "1", ")", "{", "$", "levelElement", "=", "$", "this", "->", "_getLevelElement", "(", "$", "options", ",", "$", "level", ")", ";", "if", "(", "$", "this", "->", "_View", "->", "elementExists", "(", "$", "levelElement", ")", ")", "{", "return", "$", "levelElement", ";", "}", "return", "$", "options", "[", "'childMenuAttr'", "]", "[", "'element'", "]", ";", "}", "return", "$", "options", "[", "'menuAttr'", "]", "[", "'element'", "]", ";", "}" ]
Get current menu element. @param array $options @param int $level @return string
[ "Get", "current", "menu", "element", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/NavHelper.php#L122-L134
19,976
CakeCMS/Core
src/View/Helper/NavHelper.php
NavHelper._getLevelElement
protected function _getLevelElement(array $options, $level) { $levelElement = 'menu_child_' . $level; $element = $options['childMenuAttr']['element']; list($plugin, $path) = $this->_View->pluginSplit($element); $path = FS::clean($path, '/'); $details = explode('/', $path); array_pop($details); $path = implode('/', $details); return $plugin . '.' . $path . '/' . $levelElement; }
php
protected function _getLevelElement(array $options, $level) { $levelElement = 'menu_child_' . $level; $element = $options['childMenuAttr']['element']; list($plugin, $path) = $this->_View->pluginSplit($element); $path = FS::clean($path, '/'); $details = explode('/', $path); array_pop($details); $path = implode('/', $details); return $plugin . '.' . $path . '/' . $levelElement; }
[ "protected", "function", "_getLevelElement", "(", "array", "$", "options", ",", "$", "level", ")", "{", "$", "levelElement", "=", "'menu_child_'", ".", "$", "level", ";", "$", "element", "=", "$", "options", "[", "'childMenuAttr'", "]", "[", "'element'", "]", ";", "list", "(", "$", "plugin", ",", "$", "path", ")", "=", "$", "this", "->", "_View", "->", "pluginSplit", "(", "$", "element", ")", ";", "$", "path", "=", "FS", "::", "clean", "(", "$", "path", ",", "'/'", ")", ";", "$", "details", "=", "explode", "(", "'/'", ",", "$", "path", ")", ";", "array_pop", "(", "$", "details", ")", ";", "$", "path", "=", "implode", "(", "'/'", ",", "$", "details", ")", ";", "return", "$", "plugin", ".", "'.'", ".", "$", "path", ".", "'/'", ".", "$", "levelElement", ";", "}" ]
Get current menu level element. @param array $options @param int $level @return string
[ "Get", "current", "menu", "level", "element", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/NavHelper.php#L143-L156
19,977
CakeCMS/Core
src/View/Helper/NavHelper.php
NavHelper._setFirstLast
protected function _setFirstLast($i, $itemCount, array $item = []) { $item = array_merge(['last' => false, 'first' => false], $item); if ($i == 1) { $item['first'] = true; } if ($i == $itemCount) { $item['last'] = true; } return $item; }
php
protected function _setFirstLast($i, $itemCount, array $item = []) { $item = array_merge(['last' => false, 'first' => false], $item); if ($i == 1) { $item['first'] = true; } if ($i == $itemCount) { $item['last'] = true; } return $item; }
[ "protected", "function", "_setFirstLast", "(", "$", "i", ",", "$", "itemCount", ",", "array", "$", "item", "=", "[", "]", ")", "{", "$", "item", "=", "array_merge", "(", "[", "'last'", "=>", "false", ",", "'first'", "=>", "false", "]", ",", "$", "item", ")", ";", "if", "(", "$", "i", "==", "1", ")", "{", "$", "item", "[", "'first'", "]", "=", "true", ";", "}", "if", "(", "$", "i", "==", "$", "itemCount", ")", "{", "$", "item", "[", "'last'", "]", "=", "true", ";", "}", "return", "$", "item", ";", "}" ]
Setup first last item params. @param int $i @param int $itemCount @param array $item @return array @SuppressWarnings(PHPMD.ShortVariable)
[ "Setup", "first", "last", "item", "params", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/NavHelper.php#L167-L179
19,978
CakeCMS/Core
src/View/Helper/NavHelper.php
NavHelper.getLiAttr
public function getLiAttr() { $params = self::$_itemParams; $attr = ['class' => 'li-item']; if (isset($params['item']['liClass'])) { $attr = $this->addClass($attr, $params['item']['liClass']); } if ($params['item']['last']) { $attr = $this->addClass($attr, 'last'); } if ($params['item']['first']) { $attr = $this->addClass($attr, 'first'); } return $this->_setActive($attr); }
php
public function getLiAttr() { $params = self::$_itemParams; $attr = ['class' => 'li-item']; if (isset($params['item']['liClass'])) { $attr = $this->addClass($attr, $params['item']['liClass']); } if ($params['item']['last']) { $attr = $this->addClass($attr, 'last'); } if ($params['item']['first']) { $attr = $this->addClass($attr, 'first'); } return $this->_setActive($attr); }
[ "public", "function", "getLiAttr", "(", ")", "{", "$", "params", "=", "self", "::", "$", "_itemParams", ";", "$", "attr", "=", "[", "'class'", "=>", "'li-item'", "]", ";", "if", "(", "isset", "(", "$", "params", "[", "'item'", "]", "[", "'liClass'", "]", ")", ")", "{", "$", "attr", "=", "$", "this", "->", "addClass", "(", "$", "attr", ",", "$", "params", "[", "'item'", "]", "[", "'liClass'", "]", ")", ";", "}", "if", "(", "$", "params", "[", "'item'", "]", "[", "'last'", "]", ")", "{", "$", "attr", "=", "$", "this", "->", "addClass", "(", "$", "attr", ",", "'last'", ")", ";", "}", "if", "(", "$", "params", "[", "'item'", "]", "[", "'first'", "]", ")", "{", "$", "attr", "=", "$", "this", "->", "addClass", "(", "$", "attr", ",", "'first'", ")", ";", "}", "return", "$", "this", "->", "_setActive", "(", "$", "attr", ")", ";", "}" ]
Get default li attributes. @return array
[ "Get", "default", "li", "attributes", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/NavHelper.php#L186-L204
19,979
CakeCMS/Core
src/View/Helper/NavHelper.php
NavHelper._setActive
protected function _setActive(array $attr = []) { if ($this->Url->build(self::$_itemParams['item']['url']) == env('REQUEST_URI')) { $attr = $this->addClass($attr, 'active'); } return $attr; }
php
protected function _setActive(array $attr = []) { if ($this->Url->build(self::$_itemParams['item']['url']) == env('REQUEST_URI')) { $attr = $this->addClass($attr, 'active'); } return $attr; }
[ "protected", "function", "_setActive", "(", "array", "$", "attr", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "Url", "->", "build", "(", "self", "::", "$", "_itemParams", "[", "'item'", "]", "[", "'url'", "]", ")", "==", "env", "(", "'REQUEST_URI'", ")", ")", "{", "$", "attr", "=", "$", "this", "->", "addClass", "(", "$", "attr", ",", "'active'", ")", ";", "}", "return", "$", "attr", ";", "}" ]
Set active item link. @param array $attr @return array
[ "Set", "active", "item", "link", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/NavHelper.php#L212-L219
19,980
yuncms/framework
src/behaviors/PolymorphicRelation.php
PolymorphicRelation.getPolymorphicRelation
public function getPolymorphicRelation() { if ($this->_cached !== null) { return $this->_cached; } $className = $this->owner->getAttribute($this->classAttribute); if ($className == "") { return null; } if (!class_exists($className)) { Yii::error("Underlying object class " . $className . " not found!"); return null; } $tableName = $className::tableName(); $object = $className::find()->where([$tableName . '.id' => $this->owner->getAttribute($this->pkAttribute)])->one(); if ($object !== null && $this->validateUnderlyingObjectType($object)) { $this->_cached = $object; return $object; } return null; }
php
public function getPolymorphicRelation() { if ($this->_cached !== null) { return $this->_cached; } $className = $this->owner->getAttribute($this->classAttribute); if ($className == "") { return null; } if (!class_exists($className)) { Yii::error("Underlying object class " . $className . " not found!"); return null; } $tableName = $className::tableName(); $object = $className::find()->where([$tableName . '.id' => $this->owner->getAttribute($this->pkAttribute)])->one(); if ($object !== null && $this->validateUnderlyingObjectType($object)) { $this->_cached = $object; return $object; } return null; }
[ "public", "function", "getPolymorphicRelation", "(", ")", "{", "if", "(", "$", "this", "->", "_cached", "!==", "null", ")", "{", "return", "$", "this", "->", "_cached", ";", "}", "$", "className", "=", "$", "this", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "classAttribute", ")", ";", "if", "(", "$", "className", "==", "\"\"", ")", "{", "return", "null", ";", "}", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{", "Yii", "::", "error", "(", "\"Underlying object class \"", ".", "$", "className", ".", "\" not found!\"", ")", ";", "return", "null", ";", "}", "$", "tableName", "=", "$", "className", "::", "tableName", "(", ")", ";", "$", "object", "=", "$", "className", "::", "find", "(", ")", "->", "where", "(", "[", "$", "tableName", ".", "'.id'", "=>", "$", "this", "->", "owner", "->", "getAttribute", "(", "$", "this", "->", "pkAttribute", ")", "]", ")", "->", "one", "(", ")", ";", "if", "(", "$", "object", "!==", "null", "&&", "$", "this", "->", "validateUnderlyingObjectType", "(", "$", "object", ")", ")", "{", "$", "this", "->", "_cached", "=", "$", "object", ";", "return", "$", "object", ";", "}", "return", "null", ";", "}" ]
Returns the Underlying Object @return mixed
[ "Returns", "the", "Underlying", "Object" ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/behaviors/PolymorphicRelation.php#L50-L70
19,981
yuncms/framework
src/behaviors/PolymorphicRelation.php
PolymorphicRelation.validateUnderlyingObjectType
private function validateUnderlyingObjectType($object) { if (count($this->mustBeInstanceOf) == 0) { return true; } foreach ($this->mustBeInstanceOf as $instance) { if ($object instanceof $instance) { //|| $object->asa($instance) !== null return true; } } Yii::error('Got invalid underlying object type! (' . $object->className() . ')'); return false; }
php
private function validateUnderlyingObjectType($object) { if (count($this->mustBeInstanceOf) == 0) { return true; } foreach ($this->mustBeInstanceOf as $instance) { if ($object instanceof $instance) { //|| $object->asa($instance) !== null return true; } } Yii::error('Got invalid underlying object type! (' . $object->className() . ')'); return false; }
[ "private", "function", "validateUnderlyingObjectType", "(", "$", "object", ")", "{", "if", "(", "count", "(", "$", "this", "->", "mustBeInstanceOf", ")", "==", "0", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "this", "->", "mustBeInstanceOf", "as", "$", "instance", ")", "{", "if", "(", "$", "object", "instanceof", "$", "instance", ")", "{", "//|| $object->asa($instance) !== null", "return", "true", ";", "}", "}", "Yii", "::", "error", "(", "'Got invalid underlying object type! ('", ".", "$", "object", "->", "className", "(", ")", ".", "')'", ")", ";", "return", "false", ";", "}" ]
Validates if given object is of allowed type @param mixed $object @return boolean
[ "Validates", "if", "given", "object", "is", "of", "allowed", "type" ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/behaviors/PolymorphicRelation.php#L98-L110
19,982
webforge-labs/psc-cms
lib/PHPWord/PHPWord/Shared/String.php
PHPWord_Shared_String.ConvertEncoding
public static function ConvertEncoding($value, $to, $from) { if (self::getIsMbstringEnabled()) { $value = mb_convert_encoding($value, $to, $from); return $value; } if (self::getIsIconvEnabled()) { $value = iconv($from, $to, $value); return $value; } // else, no conversion return $value; }
php
public static function ConvertEncoding($value, $to, $from) { if (self::getIsMbstringEnabled()) { $value = mb_convert_encoding($value, $to, $from); return $value; } if (self::getIsIconvEnabled()) { $value = iconv($from, $to, $value); return $value; } // else, no conversion return $value; }
[ "public", "static", "function", "ConvertEncoding", "(", "$", "value", ",", "$", "to", ",", "$", "from", ")", "{", "if", "(", "self", "::", "getIsMbstringEnabled", "(", ")", ")", "{", "$", "value", "=", "mb_convert_encoding", "(", "$", "value", ",", "$", "to", ",", "$", "from", ")", ";", "return", "$", "value", ";", "}", "if", "(", "self", "::", "getIsIconvEnabled", "(", ")", ")", "{", "$", "value", "=", "iconv", "(", "$", "from", ",", "$", "to", ",", "$", "value", ")", ";", "return", "$", "value", ";", "}", "// else, no conversion", "return", "$", "value", ";", "}" ]
Convert string from one encoding to another. First try mbstring, then iconv, or no convertion @param string $value @param string $to Encoding to convert to, e.g. 'UTF-8' @param string $from Encoding to convert from, e.g. 'UTF-16LE' @return string
[ "Convert", "string", "from", "one", "encoding", "to", "another", ".", "First", "try", "mbstring", "then", "iconv", "or", "no", "convertion" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Shared/String.php#L223-L237
19,983
webforge-labs/psc-cms
lib/PHPWord/PHPWord/Shared/String.php
PHPWord_Shared_String.CountCharacters
public static function CountCharacters($value, $enc = 'UTF-8') { if (self::getIsMbstringEnabled()) { $count = mb_strlen($value, $enc); return $count; } if (self::getIsIconvEnabled()) { $count = iconv_strlen($value, $enc); return $count; } // else strlen $count = strlen($value); return $count; }
php
public static function CountCharacters($value, $enc = 'UTF-8') { if (self::getIsMbstringEnabled()) { $count = mb_strlen($value, $enc); return $count; } if (self::getIsIconvEnabled()) { $count = iconv_strlen($value, $enc); return $count; } // else strlen $count = strlen($value); return $count; }
[ "public", "static", "function", "CountCharacters", "(", "$", "value", ",", "$", "enc", "=", "'UTF-8'", ")", "{", "if", "(", "self", "::", "getIsMbstringEnabled", "(", ")", ")", "{", "$", "count", "=", "mb_strlen", "(", "$", "value", ",", "$", "enc", ")", ";", "return", "$", "count", ";", "}", "if", "(", "self", "::", "getIsIconvEnabled", "(", ")", ")", "{", "$", "count", "=", "iconv_strlen", "(", "$", "value", ",", "$", "enc", ")", ";", "return", "$", "count", ";", "}", "// else strlen", "$", "count", "=", "strlen", "(", "$", "value", ")", ";", "return", "$", "count", ";", "}" ]
Get character count. First try mbstring, then iconv, finally strlen @param string $value @param string $enc Encoding @return int Character count
[ "Get", "character", "count", ".", "First", "try", "mbstring", "then", "iconv", "finally", "strlen" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Shared/String.php#L246-L261
19,984
Craftsware/scissor
src/Lib/Database.php
Database.max
public function max($table, $inc = null) { return $this->select($table, ['MAX(id)'])[0]['MAX(id)'] + (isset($inc) ? $inc : 0); }
php
public function max($table, $inc = null) { return $this->select($table, ['MAX(id)'])[0]['MAX(id)'] + (isset($inc) ? $inc : 0); }
[ "public", "function", "max", "(", "$", "table", ",", "$", "inc", "=", "null", ")", "{", "return", "$", "this", "->", "select", "(", "$", "table", ",", "[", "'MAX(id)'", "]", ")", "[", "0", "]", "[", "'MAX(id)'", "]", "+", "(", "isset", "(", "$", "inc", ")", "?", "$", "inc", ":", "0", ")", ";", "}" ]
Get Maximum ID of a table @param $table String @param $add Int
[ "Get", "Maximum", "ID", "of", "a", "table" ]
644e4a8ea9859fc30fee36705e54784acd8d43e2
https://github.com/Craftsware/scissor/blob/644e4a8ea9859fc30fee36705e54784acd8d43e2/src/Lib/Database.php#L53-L56
19,985
Craftsware/scissor
src/Lib/Database.php
Database.fetch
public function fetch($query) { $db = $this->connection(); if(method_exists($result = $db->query(rtrim(preg_replace('/\s\s/', ' ', $query), ' ')), 'rowCount')) { if($result->rowCount() && $result->setFetchMode($db::FETCH_ASSOC)) { return $result->fetchAll(); } return false; } }
php
public function fetch($query) { $db = $this->connection(); if(method_exists($result = $db->query(rtrim(preg_replace('/\s\s/', ' ', $query), ' ')), 'rowCount')) { if($result->rowCount() && $result->setFetchMode($db::FETCH_ASSOC)) { return $result->fetchAll(); } return false; } }
[ "public", "function", "fetch", "(", "$", "query", ")", "{", "$", "db", "=", "$", "this", "->", "connection", "(", ")", ";", "if", "(", "method_exists", "(", "$", "result", "=", "$", "db", "->", "query", "(", "rtrim", "(", "preg_replace", "(", "'/\\s\\s/'", ",", "' '", ",", "$", "query", ")", ",", "' '", ")", ")", ",", "'rowCount'", ")", ")", "{", "if", "(", "$", "result", "->", "rowCount", "(", ")", "&&", "$", "result", "->", "setFetchMode", "(", "$", "db", "::", "FETCH_ASSOC", ")", ")", "{", "return", "$", "result", "->", "fetchAll", "(", ")", ";", "}", "return", "false", ";", "}", "}" ]
Get Data from the table @param $query String
[ "Get", "Data", "from", "the", "table" ]
644e4a8ea9859fc30fee36705e54784acd8d43e2
https://github.com/Craftsware/scissor/blob/644e4a8ea9859fc30fee36705e54784acd8d43e2/src/Lib/Database.php#L78-L91
19,986
ClanCats/Core
src/classes/CCError/Trace.php
CCError_Trace.file
public function file( $cut = true ) { if ( empty( $this->file ) ) { return null; } if ( $cut ) { return str_replace( CCROOT, '', $this->file ); } return $this->file; }
php
public function file( $cut = true ) { if ( empty( $this->file ) ) { return null; } if ( $cut ) { return str_replace( CCROOT, '', $this->file ); } return $this->file; }
[ "public", "function", "file", "(", "$", "cut", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "file", ")", ")", "{", "return", "null", ";", "}", "if", "(", "$", "cut", ")", "{", "return", "str_replace", "(", "CCROOT", ",", "''", ",", "$", "this", "->", "file", ")", ";", "}", "return", "$", "this", "->", "file", ";", "}" ]
get file path @param bool $cut Cut @return string
[ "get", "file", "path" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCError/Trace.php#L90-L103
19,987
ClanCats/Core
src/classes/CCError/Trace.php
CCError_Trace.args_string
public function args_string() { if ( !isset( $this->args ) || !is_array( $this->args ) ) { return null; } $args = $this->args; foreach( $args as $key => $arg ) { if ( is_array( $arg ) ) { $args[$key] = 'Array'; } else { $args[$key] = var_export( $arg, true ); } } return implode( ', ', $args ); }
php
public function args_string() { if ( !isset( $this->args ) || !is_array( $this->args ) ) { return null; } $args = $this->args; foreach( $args as $key => $arg ) { if ( is_array( $arg ) ) { $args[$key] = 'Array'; } else { $args[$key] = var_export( $arg, true ); } } return implode( ', ', $args ); }
[ "public", "function", "args_string", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "args", ")", "||", "!", "is_array", "(", "$", "this", "->", "args", ")", ")", "{", "return", "null", ";", "}", "$", "args", "=", "$", "this", "->", "args", ";", "foreach", "(", "$", "args", "as", "$", "key", "=>", "$", "arg", ")", "{", "if", "(", "is_array", "(", "$", "arg", ")", ")", "{", "$", "args", "[", "$", "key", "]", "=", "'Array'", ";", "}", "else", "{", "$", "args", "[", "$", "key", "]", "=", "var_export", "(", "$", "arg", ",", "true", ")", ";", "}", "}", "return", "implode", "(", "', '", ",", "$", "args", ")", ";", "}" ]
create an argument string @return string
[ "create", "an", "argument", "string" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCError/Trace.php#L160-L182
19,988
ClanCats/Core
src/classes/CCError/Trace.php
CCError_Trace.parse_source
private function parse_source() { if ( !$this->file() ) { return null; } // get the file $lines = file( $this->file ); /* * parse the relevant source */ $size = 10; $start = $this->line - ( $size / 2 ); $end = $this->line + ( $size / 2 ); // check if start is in the middle of a comment while( $start > 0 && substr( trim( $lines[$start-1] ), 0, 1 ) === '*' ) { $start--; } $source = array(); for ( $i=$start-1; $i<$end; $i++ ) { if ( array_key_exists( $i, $lines ) ) { $source[$i] = str_replace( "\t", ' ', $lines[$i] ); } } $this->source = $source; }
php
private function parse_source() { if ( !$this->file() ) { return null; } // get the file $lines = file( $this->file ); /* * parse the relevant source */ $size = 10; $start = $this->line - ( $size / 2 ); $end = $this->line + ( $size / 2 ); // check if start is in the middle of a comment while( $start > 0 && substr( trim( $lines[$start-1] ), 0, 1 ) === '*' ) { $start--; } $source = array(); for ( $i=$start-1; $i<$end; $i++ ) { if ( array_key_exists( $i, $lines ) ) { $source[$i] = str_replace( "\t", ' ', $lines[$i] ); } } $this->source = $source; }
[ "private", "function", "parse_source", "(", ")", "{", "if", "(", "!", "$", "this", "->", "file", "(", ")", ")", "{", "return", "null", ";", "}", "// get the file", "$", "lines", "=", "file", "(", "$", "this", "->", "file", ")", ";", "/*\n\t\t * parse the relevant source\n\t\t */", "$", "size", "=", "10", ";", "$", "start", "=", "$", "this", "->", "line", "-", "(", "$", "size", "/", "2", ")", ";", "$", "end", "=", "$", "this", "->", "line", "+", "(", "$", "size", "/", "2", ")", ";", "// check if start is in the middle of a comment", "while", "(", "$", "start", ">", "0", "&&", "substr", "(", "trim", "(", "$", "lines", "[", "$", "start", "-", "1", "]", ")", ",", "0", ",", "1", ")", "===", "'*'", ")", "{", "$", "start", "--", ";", "}", "$", "source", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "$", "start", "-", "1", ";", "$", "i", "<", "$", "end", ";", "$", "i", "++", ")", "{", "if", "(", "array_key_exists", "(", "$", "i", ",", "$", "lines", ")", ")", "{", "$", "source", "[", "$", "i", "]", "=", "str_replace", "(", "\"\\t\"", ",", "' '", ",", "$", "lines", "[", "$", "i", "]", ")", ";", "}", "}", "$", "this", "->", "source", "=", "$", "source", ";", "}" ]
parse the source file @return void
[ "parse", "the", "source", "file" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCError/Trace.php#L189-L224
19,989
ClanCats/Core
src/classes/CCError/Trace.php
CCError_Trace.reflection_file
public function reflection_file() { if ( is_null( $this->reflection_file ) ) { if ( is_null( $reflection = $this->reflection() ) ) { return null; } $this->reflection_file = file( $reflection->getFileName() ); } return $this->reflection_file; }
php
public function reflection_file() { if ( is_null( $this->reflection_file ) ) { if ( is_null( $reflection = $this->reflection() ) ) { return null; } $this->reflection_file = file( $reflection->getFileName() ); } return $this->reflection_file; }
[ "public", "function", "reflection_file", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "reflection_file", ")", ")", "{", "if", "(", "is_null", "(", "$", "reflection", "=", "$", "this", "->", "reflection", "(", ")", ")", ")", "{", "return", "null", ";", "}", "$", "this", "->", "reflection_file", "=", "file", "(", "$", "reflection", "->", "getFileName", "(", ")", ")", ";", "}", "return", "$", "this", "->", "reflection_file", ";", "}" ]
get the source code of the reflected file @return string
[ "get", "the", "source", "code", "of", "the", "reflected", "file" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCError/Trace.php#L261-L274
19,990
ClanCats/Core
src/classes/CCError/Trace.php
CCError_Trace.reflection_function_info
public function reflection_function_info( $function = null ) { if ( is_null( $lines = $this->reflection_file() ) ) { return null; } if ( is_null( $function ) ) { if ( is_null( $function = $this->function_name() ) ) { return null; } } $info = array( 'message' => '', ); foreach( $lines as $index => $line ) { // is this the function define if ( strpos( $line, 'function '.$function ) !== false ) { // do we have a comment on top if ( substr( trim( $lines[$index-1] ), 0, 1 ) === '*' ) { $start = $index-1; $comment = array(); // parse the comment while( $start > 0 && substr( trim( $lines[$start-1] ), 0, 1 ) === '*' ) { $start--; array_unshift( $comment, substr( trim( trim( $lines[$start] ), "*" ), 1 ) ); } // parse quotse $in_quote = false; // we got a comment foreach( $comment as $line ) { // add param if ( strpos( $line, '@' ) !== false ) { // replace double tabs $line = preg_replace( "!\t+!", "\t", $line ); // make tabs to spaces $line = str_replace( "\t", ' ', $line ); $info[trim(substr( $line, 1, strpos( $line, ' ' ) ))][] = trim( substr( $line, strpos( $line, ' ' ) ) ); } // add message else { $line = str_replace( "\t", ' ', $line ); if ( substr( $line, 0, 4 ) == ' ' && !$in_quote ) { $info['message'] .= "<pre>"; $in_quote = true; } elseif ( substr( $line, 0, 4 ) != ' ' && $in_quote ) { $info['message'] .= "</pre>"; $in_quote = false; } if ( $in_quote ) { $line = substr( $line, 4 ); } $info['message'] .= $line."\n"; } } // final trim $info['message'] = trim( $info['message'], "\n\r\t" ); // done; return $info; } continue; } } }
php
public function reflection_function_info( $function = null ) { if ( is_null( $lines = $this->reflection_file() ) ) { return null; } if ( is_null( $function ) ) { if ( is_null( $function = $this->function_name() ) ) { return null; } } $info = array( 'message' => '', ); foreach( $lines as $index => $line ) { // is this the function define if ( strpos( $line, 'function '.$function ) !== false ) { // do we have a comment on top if ( substr( trim( $lines[$index-1] ), 0, 1 ) === '*' ) { $start = $index-1; $comment = array(); // parse the comment while( $start > 0 && substr( trim( $lines[$start-1] ), 0, 1 ) === '*' ) { $start--; array_unshift( $comment, substr( trim( trim( $lines[$start] ), "*" ), 1 ) ); } // parse quotse $in_quote = false; // we got a comment foreach( $comment as $line ) { // add param if ( strpos( $line, '@' ) !== false ) { // replace double tabs $line = preg_replace( "!\t+!", "\t", $line ); // make tabs to spaces $line = str_replace( "\t", ' ', $line ); $info[trim(substr( $line, 1, strpos( $line, ' ' ) ))][] = trim( substr( $line, strpos( $line, ' ' ) ) ); } // add message else { $line = str_replace( "\t", ' ', $line ); if ( substr( $line, 0, 4 ) == ' ' && !$in_quote ) { $info['message'] .= "<pre>"; $in_quote = true; } elseif ( substr( $line, 0, 4 ) != ' ' && $in_quote ) { $info['message'] .= "</pre>"; $in_quote = false; } if ( $in_quote ) { $line = substr( $line, 4 ); } $info['message'] .= $line."\n"; } } // final trim $info['message'] = trim( $info['message'], "\n\r\t" ); // done; return $info; } continue; } } }
[ "public", "function", "reflection_function_info", "(", "$", "function", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "lines", "=", "$", "this", "->", "reflection_file", "(", ")", ")", ")", "{", "return", "null", ";", "}", "if", "(", "is_null", "(", "$", "function", ")", ")", "{", "if", "(", "is_null", "(", "$", "function", "=", "$", "this", "->", "function_name", "(", ")", ")", ")", "{", "return", "null", ";", "}", "}", "$", "info", "=", "array", "(", "'message'", "=>", "''", ",", ")", ";", "foreach", "(", "$", "lines", "as", "$", "index", "=>", "$", "line", ")", "{", "// is this the function define", "if", "(", "strpos", "(", "$", "line", ",", "'function '", ".", "$", "function", ")", "!==", "false", ")", "{", "// do we have a comment on top", "if", "(", "substr", "(", "trim", "(", "$", "lines", "[", "$", "index", "-", "1", "]", ")", ",", "0", ",", "1", ")", "===", "'*'", ")", "{", "$", "start", "=", "$", "index", "-", "1", ";", "$", "comment", "=", "array", "(", ")", ";", "// parse the comment", "while", "(", "$", "start", ">", "0", "&&", "substr", "(", "trim", "(", "$", "lines", "[", "$", "start", "-", "1", "]", ")", ",", "0", ",", "1", ")", "===", "'*'", ")", "{", "$", "start", "--", ";", "array_unshift", "(", "$", "comment", ",", "substr", "(", "trim", "(", "trim", "(", "$", "lines", "[", "$", "start", "]", ")", ",", "\"*\"", ")", ",", "1", ")", ")", ";", "}", "// parse quotse", "$", "in_quote", "=", "false", ";", "// we got a comment", "foreach", "(", "$", "comment", "as", "$", "line", ")", "{", "// add param", "if", "(", "strpos", "(", "$", "line", ",", "'@'", ")", "!==", "false", ")", "{", "// replace double tabs", "$", "line", "=", "preg_replace", "(", "\"!\\t+!\"", ",", "\"\\t\"", ",", "$", "line", ")", ";", "// make tabs to spaces", "$", "line", "=", "str_replace", "(", "\"\\t\"", ",", "' '", ",", "$", "line", ")", ";", "$", "info", "[", "trim", "(", "substr", "(", "$", "line", ",", "1", ",", "strpos", "(", "$", "line", ",", "' '", ")", ")", ")", "]", "[", "]", "=", "trim", "(", "substr", "(", "$", "line", ",", "strpos", "(", "$", "line", ",", "' '", ")", ")", ")", ";", "}", "// add message", "else", "{", "$", "line", "=", "str_replace", "(", "\"\\t\"", ",", "' '", ",", "$", "line", ")", ";", "if", "(", "substr", "(", "$", "line", ",", "0", ",", "4", ")", "==", "' '", "&&", "!", "$", "in_quote", ")", "{", "$", "info", "[", "'message'", "]", ".=", "\"<pre>\"", ";", "$", "in_quote", "=", "true", ";", "}", "elseif", "(", "substr", "(", "$", "line", ",", "0", ",", "4", ")", "!=", "' '", "&&", "$", "in_quote", ")", "{", "$", "info", "[", "'message'", "]", ".=", "\"</pre>\"", ";", "$", "in_quote", "=", "false", ";", "}", "if", "(", "$", "in_quote", ")", "{", "$", "line", "=", "substr", "(", "$", "line", ",", "4", ")", ";", "}", "$", "info", "[", "'message'", "]", ".=", "$", "line", ".", "\"\\n\"", ";", "}", "}", "// final trim", "$", "info", "[", "'message'", "]", "=", "trim", "(", "$", "info", "[", "'message'", "]", ",", "\"\\n\\r\\t\"", ")", ";", "// done;", "return", "$", "info", ";", "}", "continue", ";", "}", "}", "}" ]
get the source code where the trace happend @return string
[ "get", "the", "source", "code", "where", "the", "trace", "happend" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCError/Trace.php#L281-L367
19,991
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Header.php
Zend_Feed_Builder_Header.setEmail
public function setEmail($email) { /** * @see Zend_Validate_EmailAddress */ require_once 'Zend/Validate/EmailAddress.php'; $validate = new Zend_Validate_EmailAddress(); if (!$validate->isValid($email)) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the email property"); } $this->offsetSet('email', $email); return $this; }
php
public function setEmail($email) { /** * @see Zend_Validate_EmailAddress */ require_once 'Zend/Validate/EmailAddress.php'; $validate = new Zend_Validate_EmailAddress(); if (!$validate->isValid($email)) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the email property"); } $this->offsetSet('email', $email); return $this; }
[ "public", "function", "setEmail", "(", "$", "email", ")", "{", "/**\n * @see Zend_Validate_EmailAddress\n */", "require_once", "'Zend/Validate/EmailAddress.php'", ";", "$", "validate", "=", "new", "Zend_Validate_EmailAddress", "(", ")", ";", "if", "(", "!", "$", "validate", "->", "isValid", "(", "$", "email", ")", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you have to set a valid email address into the email property\"", ")", ";", "}", "$", "this", "->", "offsetSet", "(", "'email'", ",", "$", "email", ")", ";", "return", "$", "this", ";", "}" ]
Sets the author's email @param string $email @return Zend_Feed_Builder_Header @throws Zend_Feed_Builder_Exception
[ "Sets", "the", "author", "s", "email" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Header.php#L170-L186
19,992
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Header.php
Zend_Feed_Builder_Header.setWebmaster
public function setWebmaster($webmaster) { /** * @see Zend_Validate_EmailAddress */ require_once 'Zend/Validate/EmailAddress.php'; $validate = new Zend_Validate_EmailAddress(); if (!$validate->isValid($webmaster)) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the webmaster property"); } $this->offsetSet('webmaster', $webmaster); return $this; }
php
public function setWebmaster($webmaster) { /** * @see Zend_Validate_EmailAddress */ require_once 'Zend/Validate/EmailAddress.php'; $validate = new Zend_Validate_EmailAddress(); if (!$validate->isValid($webmaster)) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the webmaster property"); } $this->offsetSet('webmaster', $webmaster); return $this; }
[ "public", "function", "setWebmaster", "(", "$", "webmaster", ")", "{", "/**\n * @see Zend_Validate_EmailAddress\n */", "require_once", "'Zend/Validate/EmailAddress.php'", ";", "$", "validate", "=", "new", "Zend_Validate_EmailAddress", "(", ")", ";", "if", "(", "!", "$", "validate", "->", "isValid", "(", "$", "webmaster", ")", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you have to set a valid email address into the webmaster property\"", ")", ";", "}", "$", "this", "->", "offsetSet", "(", "'webmaster'", ",", "$", "webmaster", ")", ";", "return", "$", "this", ";", "}" ]
Email address for person responsible for technical issues Ignored if atom is used @param string $webmaster @return Zend_Feed_Builder_Header @throws Zend_Feed_Builder_Exception
[ "Email", "address", "for", "person", "responsible", "for", "technical", "issues", "Ignored", "if", "atom", "is", "used" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Header.php#L244-L260
19,993
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Header.php
Zend_Feed_Builder_Header.setTtl
public function setTtl($ttl) { /** * @see Zend_Validate_Int */ require_once 'Zend/Validate/Int.php'; $validate = new Zend_Validate_Int(); if (!$validate->isValid($ttl)) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set an integer value to the ttl property"); } $this->offsetSet('ttl', $ttl); return $this; }
php
public function setTtl($ttl) { /** * @see Zend_Validate_Int */ require_once 'Zend/Validate/Int.php'; $validate = new Zend_Validate_Int(); if (!$validate->isValid($ttl)) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set an integer value to the ttl property"); } $this->offsetSet('ttl', $ttl); return $this; }
[ "public", "function", "setTtl", "(", "$", "ttl", ")", "{", "/**\n * @see Zend_Validate_Int\n */", "require_once", "'Zend/Validate/Int.php'", ";", "$", "validate", "=", "new", "Zend_Validate_Int", "(", ")", ";", "if", "(", "!", "$", "validate", "->", "isValid", "(", "$", "ttl", ")", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you have to set an integer value to the ttl property\"", ")", ";", "}", "$", "this", "->", "offsetSet", "(", "'ttl'", ",", "$", "ttl", ")", ";", "return", "$", "this", ";", "}" ]
How long in minutes a feed can be cached before refreshing Ignored if atom is used @param int $ttl @return Zend_Feed_Builder_Header @throws Zend_Feed_Builder_Exception
[ "How", "long", "in", "minutes", "a", "feed", "can", "be", "cached", "before", "refreshing", "Ignored", "if", "atom", "is", "used" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Header.php#L270-L286
19,994
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Header.php
Zend_Feed_Builder_Header.setCloud
public function setCloud($uri, $procedure, $protocol) { if (is_string($uri) && Zend_Uri_Http::check($uri)) { $uri = Zend_Uri::factory($uri); } if (!$uri instanceof Zend_Uri_Http) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception('Passed parameter is not a valid HTTP URI'); } if (!$uri->getPort()) { $uri->setPort(80); } $this->offsetSet('cloud', array('uri' => $uri, 'procedure' => $procedure, 'protocol' => $protocol)); return $this; }
php
public function setCloud($uri, $procedure, $protocol) { if (is_string($uri) && Zend_Uri_Http::check($uri)) { $uri = Zend_Uri::factory($uri); } if (!$uri instanceof Zend_Uri_Http) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception('Passed parameter is not a valid HTTP URI'); } if (!$uri->getPort()) { $uri->setPort(80); } $this->offsetSet('cloud', array('uri' => $uri, 'procedure' => $procedure, 'protocol' => $protocol)); return $this; }
[ "public", "function", "setCloud", "(", "$", "uri", ",", "$", "procedure", ",", "$", "protocol", ")", "{", "if", "(", "is_string", "(", "$", "uri", ")", "&&", "Zend_Uri_Http", "::", "check", "(", "$", "uri", ")", ")", "{", "$", "uri", "=", "Zend_Uri", "::", "factory", "(", "$", "uri", ")", ";", "}", "if", "(", "!", "$", "uri", "instanceof", "Zend_Uri_Http", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "'Passed parameter is not a valid HTTP URI'", ")", ";", "}", "if", "(", "!", "$", "uri", "->", "getPort", "(", ")", ")", "{", "$", "uri", "->", "setPort", "(", "80", ")", ";", "}", "$", "this", "->", "offsetSet", "(", "'cloud'", ",", "array", "(", "'uri'", "=>", "$", "uri", ",", "'procedure'", "=>", "$", "procedure", ",", "'protocol'", "=>", "$", "protocol", ")", ")", ";", "return", "$", "this", ";", "}" ]
Cloud to be notified of updates of the feed Ignored if atom is used @param string|Zend_Uri_Http $uri @param string $procedure procedure to call, e.g. myCloud.rssPleaseNotify @param string $protocol protocol to use, e.g. soap or xml-rpc @return Zend_Feed_Builder_Header @throws Zend_Feed_Builder_Exception
[ "Cloud", "to", "be", "notified", "of", "updates", "of", "the", "feed", "Ignored", "if", "atom", "is", "used" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Header.php#L311-L330
19,995
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Header.php
Zend_Feed_Builder_Header.setTextInput
public function setTextInput($title, $description, $name, $link) { $this->offsetSet('textInput', array('title' => $title, 'description' => $description, 'name' => $name, 'link' => $link)); return $this; }
php
public function setTextInput($title, $description, $name, $link) { $this->offsetSet('textInput', array('title' => $title, 'description' => $description, 'name' => $name, 'link' => $link)); return $this; }
[ "public", "function", "setTextInput", "(", "$", "title", ",", "$", "description", ",", "$", "name", ",", "$", "link", ")", "{", "$", "this", "->", "offsetSet", "(", "'textInput'", ",", "array", "(", "'title'", "=>", "$", "title", ",", "'description'", "=>", "$", "description", ",", "'name'", "=>", "$", "name", ",", "'link'", "=>", "$", "link", ")", ")", ";", "return", "$", "this", ";", "}" ]
A text input box that can be displayed with the feed Ignored if atom is used @param string $title the label of the Submit button in the text input area @param string $description explains the text input area @param string $name the name of the text object in the text input area @param string $link the URL of the CGI script that processes text input requests @return Zend_Feed_Builder_Header
[ "A", "text", "input", "box", "that", "can", "be", "displayed", "with", "the", "feed", "Ignored", "if", "atom", "is", "used" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Header.php#L342-L349
19,996
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Header.php
Zend_Feed_Builder_Header.setSkipHours
public function setSkipHours(array $hours) { if (count($hours) > 24) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you can not have more than 24 rows in the skipHours property"); } foreach ($hours as $hour) { if ($hour < 0 || $hour > 23) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("$hour has te be between 0 and 23"); } } $this->offsetSet('skipHours', $hours); return $this; }
php
public function setSkipHours(array $hours) { if (count($hours) > 24) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you can not have more than 24 rows in the skipHours property"); } foreach ($hours as $hour) { if ($hour < 0 || $hour > 23) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("$hour has te be between 0 and 23"); } } $this->offsetSet('skipHours', $hours); return $this; }
[ "public", "function", "setSkipHours", "(", "array", "$", "hours", ")", "{", "if", "(", "count", "(", "$", "hours", ")", ">", "24", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you can not have more than 24 rows in the skipHours property\"", ")", ";", "}", "foreach", "(", "$", "hours", "as", "$", "hour", ")", "{", "if", "(", "$", "hour", "<", "0", "||", "$", "hour", ">", "23", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"$hour has te be between 0 and 23\"", ")", ";", "}", "}", "$", "this", "->", "offsetSet", "(", "'skipHours'", ",", "$", "hours", ")", ";", "return", "$", "this", ";", "}" ]
Hint telling aggregators which hours they can skip Ignored if atom is used @param array $hours list of hours in 24 format @return Zend_Feed_Builder_Header @throws Zend_Feed_Builder_Exception
[ "Hint", "telling", "aggregators", "which", "hours", "they", "can", "skip", "Ignored", "if", "atom", "is", "used" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Header.php#L359-L379
19,997
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Header.php
Zend_Feed_Builder_Header.setSkipDays
public function setSkipDays(array $days) { if (count($days) > 7) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you can not have more than 7 days in the skipDays property"); } $valid = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); foreach ($days as $day) { if (!in_array(strtolower($day), $valid)) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("$day is not a valid day"); } } $this->offsetSet('skipDays', $days); return $this; }
php
public function setSkipDays(array $days) { if (count($days) > 7) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you can not have more than 7 days in the skipDays property"); } $valid = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); foreach ($days as $day) { if (!in_array(strtolower($day), $valid)) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("$day is not a valid day"); } } $this->offsetSet('skipDays', $days); return $this; }
[ "public", "function", "setSkipDays", "(", "array", "$", "days", ")", "{", "if", "(", "count", "(", "$", "days", ")", ">", "7", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you can not have more than 7 days in the skipDays property\"", ")", ";", "}", "$", "valid", "=", "array", "(", "'monday'", ",", "'tuesday'", ",", "'wednesday'", ",", "'thursday'", ",", "'friday'", ",", "'saturday'", ",", "'sunday'", ")", ";", "foreach", "(", "$", "days", "as", "$", "day", ")", "{", "if", "(", "!", "in_array", "(", "strtolower", "(", "$", "day", ")", ",", "$", "valid", ")", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"$day is not a valid day\"", ")", ";", "}", "}", "$", "this", "->", "offsetSet", "(", "'skipDays'", ",", "$", "days", ")", ";", "return", "$", "this", ";", "}" ]
Hint telling aggregators which days they can skip Ignored if atom is used @param array $days list of days to skip, e.g. Monday @return Zend_Feed_Builder_Header @throws Zend_Feed_Builder_Exception
[ "Hint", "telling", "aggregators", "which", "days", "they", "can", "skip", "Ignored", "if", "atom", "is", "used" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Header.php#L389-L410
19,998
nyeholt/silverstripe-external-content
code/cache/CacheService.php
CacheService.store
public function store($key, $value, $expiry=0) { if ($expiry == 0) { $expiry = $this->expiry; } $entry = new CacheItem(); $entry->value = serialize($value); $entry->expireAt = time() + $expiry; $data = serialize($entry); $this->store->store($key, $data); $this->items[$key] = $entry; }
php
public function store($key, $value, $expiry=0) { if ($expiry == 0) { $expiry = $this->expiry; } $entry = new CacheItem(); $entry->value = serialize($value); $entry->expireAt = time() + $expiry; $data = serialize($entry); $this->store->store($key, $data); $this->items[$key] = $entry; }
[ "public", "function", "store", "(", "$", "key", ",", "$", "value", ",", "$", "expiry", "=", "0", ")", "{", "if", "(", "$", "expiry", "==", "0", ")", "{", "$", "expiry", "=", "$", "this", "->", "expiry", ";", "}", "$", "entry", "=", "new", "CacheItem", "(", ")", ";", "$", "entry", "->", "value", "=", "serialize", "(", "$", "value", ")", ";", "$", "entry", "->", "expireAt", "=", "time", "(", ")", "+", "$", "expiry", ";", "$", "data", "=", "serialize", "(", "$", "entry", ")", ";", "$", "this", "->", "store", "->", "store", "(", "$", "key", ",", "$", "data", ")", ";", "$", "this", "->", "items", "[", "$", "key", "]", "=", "$", "entry", ";", "}" ]
Cache an item @param string $key @param mixed $value @param int $expiry How many seconds to cache this object for (no value uses the configured default)
[ "Cache", "an", "item" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/cache/CacheService.php#L67-L80
19,999
nyeholt/silverstripe-external-content
code/cache/CacheService.php
CacheService.get
public function get($key) { $entry = null; if (isset($this->items[$key])) { $entry = $this->items[$key]; } else { $data = $this->store->get($key); if ($data) { $entry = unserialize($data); } } if (!$entry) { return $entry; } // if the expire time is in the future if ($entry->expireAt > time()) { return unserialize($entry->value); } // if we got to here, we need to expire the value $this->expire($key); return null; }
php
public function get($key) { $entry = null; if (isset($this->items[$key])) { $entry = $this->items[$key]; } else { $data = $this->store->get($key); if ($data) { $entry = unserialize($data); } } if (!$entry) { return $entry; } // if the expire time is in the future if ($entry->expireAt > time()) { return unserialize($entry->value); } // if we got to here, we need to expire the value $this->expire($key); return null; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "entry", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "items", "[", "$", "key", "]", ")", ")", "{", "$", "entry", "=", "$", "this", "->", "items", "[", "$", "key", "]", ";", "}", "else", "{", "$", "data", "=", "$", "this", "->", "store", "->", "get", "(", "$", "key", ")", ";", "if", "(", "$", "data", ")", "{", "$", "entry", "=", "unserialize", "(", "$", "data", ")", ";", "}", "}", "if", "(", "!", "$", "entry", ")", "{", "return", "$", "entry", ";", "}", "// if the expire time is in the future", "if", "(", "$", "entry", "->", "expireAt", ">", "time", "(", ")", ")", "{", "return", "unserialize", "(", "$", "entry", "->", "value", ")", ";", "}", "// if we got to here, we need to expire the value", "$", "this", "->", "expire", "(", "$", "key", ")", ";", "return", "null", ";", "}" ]
Gets a cached value for a given key @param String $key The key to retrieve data for
[ "Gets", "a", "cached", "value", "for", "a", "given", "key" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/cache/CacheService.php#L87-L113