id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
3,300
itephp/twig-bridge
src/TwigPresenter.php
TwigPresenter.displaySuccess
private function displaySuccess(Request $request,Response $response){ $data=$response->getContent(); if($data==null){ $data=array(); } $controllerName=str_replace('\\', '/', $request->getConfig()->getValue('class')); $methodName=$request->getConfig()->getValue('method'); echo $this->twig->render($controllerName.'/'.$methodName.'.twig', $data); }
php
private function displaySuccess(Request $request,Response $response){ $data=$response->getContent(); if($data==null){ $data=array(); } $controllerName=str_replace('\\', '/', $request->getConfig()->getValue('class')); $methodName=$request->getConfig()->getValue('method'); echo $this->twig->render($controllerName.'/'.$methodName.'.twig', $data); }
[ "private", "function", "displaySuccess", "(", "Request", "$", "request", ",", "Response", "$", "response", ")", "{", "$", "data", "=", "$", "response", "->", "getContent", "(", ")", ";", "if", "(", "$", "data", "==", "null", ")", "{", "$", "data", "=", "array", "(", ")", ";", "}", "$", "controllerName", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "request", "->", "getConfig", "(", ")", "->", "getValue", "(", "'class'", ")", ")", ";", "$", "methodName", "=", "$", "request", "->", "getConfig", "(", ")", "->", "getValue", "(", "'method'", ")", ";", "echo", "$", "this", "->", "twig", "->", "render", "(", "$", "controllerName", ".", "'/'", ".", "$", "methodName", ".", "'.twig'", ",", "$", "data", ")", ";", "}" ]
Support status code 2XX. @param Request $request @param Response $response
[ "Support", "status", "code", "2XX", "." ]
0a0193baa9689977a97c48eee7750a8982692475
https://github.com/itephp/twig-bridge/blob/0a0193baa9689977a97c48eee7750a8982692475/src/TwigPresenter.php#L95-L103
3,301
itephp/twig-bridge
src/TwigPresenter.php
TwigPresenter.displayError
private function displayError(Request $request,Response $response){ $exception=$response->getContent(); $data=array( 'statusCode'=>$response->getStatusCode() ,'message'=>$exception->getMessage() ,'exception'=>get_class($exception) ,'file'=>$exception->getFile() ,'line'=>$exception->getLine() ); if($this->environment->isDebug()){ echo $this->twig->render('error.twig', $data); } else{ echo $this->twig->render($response->getStatusCode().'.twig'); } }
php
private function displayError(Request $request,Response $response){ $exception=$response->getContent(); $data=array( 'statusCode'=>$response->getStatusCode() ,'message'=>$exception->getMessage() ,'exception'=>get_class($exception) ,'file'=>$exception->getFile() ,'line'=>$exception->getLine() ); if($this->environment->isDebug()){ echo $this->twig->render('error.twig', $data); } else{ echo $this->twig->render($response->getStatusCode().'.twig'); } }
[ "private", "function", "displayError", "(", "Request", "$", "request", ",", "Response", "$", "response", ")", "{", "$", "exception", "=", "$", "response", "->", "getContent", "(", ")", ";", "$", "data", "=", "array", "(", "'statusCode'", "=>", "$", "response", "->", "getStatusCode", "(", ")", ",", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", ",", "'exception'", "=>", "get_class", "(", "$", "exception", ")", ",", "'file'", "=>", "$", "exception", "->", "getFile", "(", ")", ",", "'line'", "=>", "$", "exception", "->", "getLine", "(", ")", ")", ";", "if", "(", "$", "this", "->", "environment", "->", "isDebug", "(", ")", ")", "{", "echo", "$", "this", "->", "twig", "->", "render", "(", "'error.twig'", ",", "$", "data", ")", ";", "}", "else", "{", "echo", "$", "this", "->", "twig", "->", "render", "(", "$", "response", "->", "getStatusCode", "(", ")", ".", "'.twig'", ")", ";", "}", "}" ]
Support status code 4XX-5XX. @param Request $request @param Response $response
[ "Support", "status", "code", "4XX", "-", "5XX", "." ]
0a0193baa9689977a97c48eee7750a8982692475
https://github.com/itephp/twig-bridge/blob/0a0193baa9689977a97c48eee7750a8982692475/src/TwigPresenter.php#L111-L128
3,302
ricardoh/wurfl-php-api
WURFL/Handlers/CatchAllHandler.php
WURFL_Handlers_CatchAllHandler.applyConclusiveMatch
public function applyConclusiveMatch($userAgent) { $deviceId = WURFL_Constants::GENERIC; if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'Mozilla')) { $deviceId = $this->applyMozillaConclusiveMatch($userAgent); } else { $tolerance = WURFL_Handlers_Utils::firstSlash($userAgent); $deviceId = $this->getDeviceIDFromRIS($userAgent, $tolerance); } return $deviceId; }
php
public function applyConclusiveMatch($userAgent) { $deviceId = WURFL_Constants::GENERIC; if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'Mozilla')) { $deviceId = $this->applyMozillaConclusiveMatch($userAgent); } else { $tolerance = WURFL_Handlers_Utils::firstSlash($userAgent); $deviceId = $this->getDeviceIDFromRIS($userAgent, $tolerance); } return $deviceId; }
[ "public", "function", "applyConclusiveMatch", "(", "$", "userAgent", ")", "{", "$", "deviceId", "=", "WURFL_Constants", "::", "GENERIC", ";", "if", "(", "WURFL_Handlers_Utils", "::", "checkIfStartsWith", "(", "$", "userAgent", ",", "'Mozilla'", ")", ")", "{", "$", "deviceId", "=", "$", "this", "->", "applyMozillaConclusiveMatch", "(", "$", "userAgent", ")", ";", "}", "else", "{", "$", "tolerance", "=", "WURFL_Handlers_Utils", "::", "firstSlash", "(", "$", "userAgent", ")", ";", "$", "deviceId", "=", "$", "this", "->", "getDeviceIDFromRIS", "(", "$", "userAgent", ",", "$", "tolerance", ")", ";", "}", "return", "$", "deviceId", ";", "}" ]
If UA starts with Mozilla, apply LD with tollerance 5. If UA does not start with Mozilla, apply RIS on FS @param string $userAgent @return string
[ "If", "UA", "starts", "with", "Mozilla", "apply", "LD", "with", "tollerance", "5", ".", "If", "UA", "does", "not", "start", "with", "Mozilla", "apply", "RIS", "on", "FS" ]
1aa6c8af5b4c34ce3b37407c5eeb6fb41e5f3546
https://github.com/ricardoh/wurfl-php-api/blob/1aa6c8af5b4c34ce3b37407c5eeb6fb41e5f3546/WURFL/Handlers/CatchAllHandler.php#L59-L69
3,303
codebobbly/dvoconnector
Classes/Service/PluginConfigurationService.php
PluginConfigurationService.user_templateLayout
public function user_templateLayout(array &$config) { $pageId = 0; $currentColPos = $config['flexParentDatabaseRow']['colPos']; $pageId = $this->getPageId($config['flexParentDatabaseRow']['pid']); if ($pageId > 0) { $templateLayouts = $this->templateLayoutsUtility->getAvailableTemplateLayouts($pageId); $templateLayouts = $this->reduceTemplateLayouts($templateLayouts, $currentColPos); foreach ($templateLayouts as $layout) { $additionalLayout = [ htmlspecialchars($this->getLanguageService()->sL($layout[0])), $layout[1] ]; array_push($config['items'], $additionalLayout); } } }
php
public function user_templateLayout(array &$config) { $pageId = 0; $currentColPos = $config['flexParentDatabaseRow']['colPos']; $pageId = $this->getPageId($config['flexParentDatabaseRow']['pid']); if ($pageId > 0) { $templateLayouts = $this->templateLayoutsUtility->getAvailableTemplateLayouts($pageId); $templateLayouts = $this->reduceTemplateLayouts($templateLayouts, $currentColPos); foreach ($templateLayouts as $layout) { $additionalLayout = [ htmlspecialchars($this->getLanguageService()->sL($layout[0])), $layout[1] ]; array_push($config['items'], $additionalLayout); } } }
[ "public", "function", "user_templateLayout", "(", "array", "&", "$", "config", ")", "{", "$", "pageId", "=", "0", ";", "$", "currentColPos", "=", "$", "config", "[", "'flexParentDatabaseRow'", "]", "[", "'colPos'", "]", ";", "$", "pageId", "=", "$", "this", "->", "getPageId", "(", "$", "config", "[", "'flexParentDatabaseRow'", "]", "[", "'pid'", "]", ")", ";", "if", "(", "$", "pageId", ">", "0", ")", "{", "$", "templateLayouts", "=", "$", "this", "->", "templateLayoutsUtility", "->", "getAvailableTemplateLayouts", "(", "$", "pageId", ")", ";", "$", "templateLayouts", "=", "$", "this", "->", "reduceTemplateLayouts", "(", "$", "templateLayouts", ",", "$", "currentColPos", ")", ";", "foreach", "(", "$", "templateLayouts", "as", "$", "layout", ")", "{", "$", "additionalLayout", "=", "[", "htmlspecialchars", "(", "$", "this", "->", "getLanguageService", "(", ")", "->", "sL", "(", "$", "layout", "[", "0", "]", ")", ")", ",", "$", "layout", "[", "1", "]", "]", ";", "array_push", "(", "$", "config", "[", "'items'", "]", ",", "$", "additionalLayout", ")", ";", "}", "}", "}" ]
Itemsproc function to extend the selection of templateLayouts in the plugin @param array &$config configuration array
[ "Itemsproc", "function", "to", "extend", "the", "selection", "of", "templateLayouts", "in", "the", "plugin" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/PluginConfigurationService.php#L145-L161
3,304
codebobbly/dvoconnector
Classes/Service/PluginConfigurationService.php
PluginConfigurationService.reduceTemplateLayouts
protected function reduceTemplateLayouts($templateLayouts, $currentColPos) { $currentColPos = (int)$currentColPos; $restrictions = []; $allLayouts = []; foreach ($templateLayouts as $key => $layout) { if (is_array($layout[0])) { if (isset($layout[0]['allowedColPos']) && StringUtility::endsWith($layout[1], '.')) { $layoutKey = substr($layout[1], 0, -1); $restrictions[$layoutKey] = GeneralUtility::intExplode(',', $layout[0]['allowedColPos'], true); } } else { $allLayouts[$key] = $layout; } } if (!empty($restrictions)) { foreach ($restrictions as $restrictedIdentifier => $restrictedColPosList) { if (!in_array($currentColPos, $restrictedColPosList, true)) { unset($allLayouts[$restrictedIdentifier]); } } } return $allLayouts; }
php
protected function reduceTemplateLayouts($templateLayouts, $currentColPos) { $currentColPos = (int)$currentColPos; $restrictions = []; $allLayouts = []; foreach ($templateLayouts as $key => $layout) { if (is_array($layout[0])) { if (isset($layout[0]['allowedColPos']) && StringUtility::endsWith($layout[1], '.')) { $layoutKey = substr($layout[1], 0, -1); $restrictions[$layoutKey] = GeneralUtility::intExplode(',', $layout[0]['allowedColPos'], true); } } else { $allLayouts[$key] = $layout; } } if (!empty($restrictions)) { foreach ($restrictions as $restrictedIdentifier => $restrictedColPosList) { if (!in_array($currentColPos, $restrictedColPosList, true)) { unset($allLayouts[$restrictedIdentifier]); } } } return $allLayouts; }
[ "protected", "function", "reduceTemplateLayouts", "(", "$", "templateLayouts", ",", "$", "currentColPos", ")", "{", "$", "currentColPos", "=", "(", "int", ")", "$", "currentColPos", ";", "$", "restrictions", "=", "[", "]", ";", "$", "allLayouts", "=", "[", "]", ";", "foreach", "(", "$", "templateLayouts", "as", "$", "key", "=>", "$", "layout", ")", "{", "if", "(", "is_array", "(", "$", "layout", "[", "0", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "layout", "[", "0", "]", "[", "'allowedColPos'", "]", ")", "&&", "StringUtility", "::", "endsWith", "(", "$", "layout", "[", "1", "]", ",", "'.'", ")", ")", "{", "$", "layoutKey", "=", "substr", "(", "$", "layout", "[", "1", "]", ",", "0", ",", "-", "1", ")", ";", "$", "restrictions", "[", "$", "layoutKey", "]", "=", "GeneralUtility", "::", "intExplode", "(", "','", ",", "$", "layout", "[", "0", "]", "[", "'allowedColPos'", "]", ",", "true", ")", ";", "}", "}", "else", "{", "$", "allLayouts", "[", "$", "key", "]", "=", "$", "layout", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "restrictions", ")", ")", "{", "foreach", "(", "$", "restrictions", "as", "$", "restrictedIdentifier", "=>", "$", "restrictedColPosList", ")", "{", "if", "(", "!", "in_array", "(", "$", "currentColPos", ",", "$", "restrictedColPosList", ",", "true", ")", ")", "{", "unset", "(", "$", "allLayouts", "[", "$", "restrictedIdentifier", "]", ")", ";", "}", "}", "}", "return", "$", "allLayouts", ";", "}" ]
Reduce the template layouts by the ones that are not allowed in given colPos @param array $templateLayouts @param int $currentColPos @return array
[ "Reduce", "the", "template", "layouts", "by", "the", "ones", "that", "are", "not", "allowed", "in", "given", "colPos" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/PluginConfigurationService.php#L170-L193
3,305
codebobbly/dvoconnector
Classes/Service/PluginConfigurationService.php
PluginConfigurationService.getPageId
protected function getPageId($pid) { $pid = (int)$pid; if ($pid > 0) { return $pid; } $row = BackendUtilityCore::getRecord('tt_content', abs($pid), 'uid,pid'); return $row['pid']; }
php
protected function getPageId($pid) { $pid = (int)$pid; if ($pid > 0) { return $pid; } $row = BackendUtilityCore::getRecord('tt_content', abs($pid), 'uid,pid'); return $row['pid']; }
[ "protected", "function", "getPageId", "(", "$", "pid", ")", "{", "$", "pid", "=", "(", "int", ")", "$", "pid", ";", "if", "(", "$", "pid", ">", "0", ")", "{", "return", "$", "pid", ";", "}", "$", "row", "=", "BackendUtilityCore", "::", "getRecord", "(", "'tt_content'", ",", "abs", "(", "$", "pid", ")", ",", "'uid,pid'", ")", ";", "return", "$", "row", "[", "'pid'", "]", ";", "}" ]
Get page id, if negative, then it is a "after record" @param int $pid @return int
[ "Get", "page", "id", "if", "negative", "then", "it", "is", "a", "after", "record" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/PluginConfigurationService.php#L201-L209
3,306
routegroup/file-factory
src/Image.php
Image.resolution
public function resolution($width = null, $height = null) { return [ 'width' => $width ?: $this->widths[array_rand($this->widths)], 'height' => $height ?: $this->heights[array_rand($this->heights)] ]; }
php
public function resolution($width = null, $height = null) { return [ 'width' => $width ?: $this->widths[array_rand($this->widths)], 'height' => $height ?: $this->heights[array_rand($this->heights)] ]; }
[ "public", "function", "resolution", "(", "$", "width", "=", "null", ",", "$", "height", "=", "null", ")", "{", "return", "[", "'width'", "=>", "$", "width", "?", ":", "$", "this", "->", "widths", "[", "array_rand", "(", "$", "this", "->", "widths", ")", "]", ",", "'height'", "=>", "$", "height", "?", ":", "$", "this", "->", "heights", "[", "array_rand", "(", "$", "this", "->", "heights", ")", "]", "]", ";", "}" ]
Resolve resolution. @param integer|null $width @param integer|null $height @return array
[ "Resolve", "resolution", "." ]
09c7e45b6f070a7e9492b7a6185caa7aef20b5e3
https://github.com/routegroup/file-factory/blob/09c7e45b6f070a7e9492b7a6185caa7aef20b5e3/src/Image.php#L77-L83
3,307
themichaelhall/bluemvc-core
src/Response.php
Response.output
public function output(): void { header('HTTP/1.1 ' . $this->getStatusCode()); // Output headers. foreach ($this->getHeaders() as $headerName => $headerValue) { header($headerName . ': ' . $headerValue); } // Set cookies. foreach ($this->getCookies() as $cookieName => $cookie) { /** @var ResponseCookieInterface $cookie */ setcookie( $cookieName, $cookie->getValue(), $cookie->getExpiry() !== null ? $cookie->getExpiry()->getTimestamp() : 0, $cookie->getPath() !== null ? $cookie->getPath()->__toString() : '', $cookie->getDomain() !== null ? $cookie->getDomain()->__toString() : '', $cookie->isSecure(), $cookie->isHttpOnly() ); } // Output content. echo $this->getContent(); }
php
public function output(): void { header('HTTP/1.1 ' . $this->getStatusCode()); // Output headers. foreach ($this->getHeaders() as $headerName => $headerValue) { header($headerName . ': ' . $headerValue); } // Set cookies. foreach ($this->getCookies() as $cookieName => $cookie) { /** @var ResponseCookieInterface $cookie */ setcookie( $cookieName, $cookie->getValue(), $cookie->getExpiry() !== null ? $cookie->getExpiry()->getTimestamp() : 0, $cookie->getPath() !== null ? $cookie->getPath()->__toString() : '', $cookie->getDomain() !== null ? $cookie->getDomain()->__toString() : '', $cookie->isSecure(), $cookie->isHttpOnly() ); } // Output content. echo $this->getContent(); }
[ "public", "function", "output", "(", ")", ":", "void", "{", "header", "(", "'HTTP/1.1 '", ".", "$", "this", "->", "getStatusCode", "(", ")", ")", ";", "// Output headers.", "foreach", "(", "$", "this", "->", "getHeaders", "(", ")", "as", "$", "headerName", "=>", "$", "headerValue", ")", "{", "header", "(", "$", "headerName", ".", "': '", ".", "$", "headerValue", ")", ";", "}", "// Set cookies.", "foreach", "(", "$", "this", "->", "getCookies", "(", ")", "as", "$", "cookieName", "=>", "$", "cookie", ")", "{", "/** @var ResponseCookieInterface $cookie */", "setcookie", "(", "$", "cookieName", ",", "$", "cookie", "->", "getValue", "(", ")", ",", "$", "cookie", "->", "getExpiry", "(", ")", "!==", "null", "?", "$", "cookie", "->", "getExpiry", "(", ")", "->", "getTimestamp", "(", ")", ":", "0", ",", "$", "cookie", "->", "getPath", "(", ")", "!==", "null", "?", "$", "cookie", "->", "getPath", "(", ")", "->", "__toString", "(", ")", ":", "''", ",", "$", "cookie", "->", "getDomain", "(", ")", "!==", "null", "?", "$", "cookie", "->", "getDomain", "(", ")", "->", "__toString", "(", ")", ":", "''", ",", "$", "cookie", "->", "isSecure", "(", ")", ",", "$", "cookie", "->", "isHttpOnly", "(", ")", ")", ";", "}", "// Output content.", "echo", "$", "this", "->", "getContent", "(", ")", ";", "}" ]
Outputs the content. @since 1.0.0
[ "Outputs", "the", "content", "." ]
cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680
https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Response.php#L36-L61
3,308
cundd/test-flight
src/Definition/AbstractCodeDefinition.php
AbstractCodeDefinition.getPreProcessedCode
public function getPreProcessedCode(): string { $code = $this->getCode(); $filePath = $this->getFilePath(); $code = str_replace( '__FILE__', "'" . $filePath . "'", $code ); $code = str_replace( '__DIR__', "'" . dirname($filePath) . "'", $code ); $code = preg_replace( '/([^\w:])(__CLASS__)\(/', '$1' . $this->getClassName() . '(', $code ); $code = str_replace( '__CLASS__', "'" . $this->getClassName() . "'", $code ); $code = preg_replace( '/^(assert)\(/', 'test_flight_assert(', $code ); $code = preg_replace( '/([^\w:])(assert)\(/', '$1test_flight_assert(', $code ); return $code; }
php
public function getPreProcessedCode(): string { $code = $this->getCode(); $filePath = $this->getFilePath(); $code = str_replace( '__FILE__', "'" . $filePath . "'", $code ); $code = str_replace( '__DIR__', "'" . dirname($filePath) . "'", $code ); $code = preg_replace( '/([^\w:])(__CLASS__)\(/', '$1' . $this->getClassName() . '(', $code ); $code = str_replace( '__CLASS__', "'" . $this->getClassName() . "'", $code ); $code = preg_replace( '/^(assert)\(/', 'test_flight_assert(', $code ); $code = preg_replace( '/([^\w:])(assert)\(/', '$1test_flight_assert(', $code ); return $code; }
[ "public", "function", "getPreProcessedCode", "(", ")", ":", "string", "{", "$", "code", "=", "$", "this", "->", "getCode", "(", ")", ";", "$", "filePath", "=", "$", "this", "->", "getFilePath", "(", ")", ";", "$", "code", "=", "str_replace", "(", "'__FILE__'", ",", "\"'\"", ".", "$", "filePath", ".", "\"'\"", ",", "$", "code", ")", ";", "$", "code", "=", "str_replace", "(", "'__DIR__'", ",", "\"'\"", ".", "dirname", "(", "$", "filePath", ")", ".", "\"'\"", ",", "$", "code", ")", ";", "$", "code", "=", "preg_replace", "(", "'/([^\\w:])(__CLASS__)\\(/'", ",", "'$1'", ".", "$", "this", "->", "getClassName", "(", ")", ".", "'('", ",", "$", "code", ")", ";", "$", "code", "=", "str_replace", "(", "'__CLASS__'", ",", "\"'\"", ".", "$", "this", "->", "getClassName", "(", ")", ".", "\"'\"", ",", "$", "code", ")", ";", "$", "code", "=", "preg_replace", "(", "'/^(assert)\\(/'", ",", "'test_flight_assert('", ",", "$", "code", ")", ";", "$", "code", "=", "preg_replace", "(", "'/([^\\w:])(assert)\\(/'", ",", "'$1test_flight_assert('", ",", "$", "code", ")", ";", "return", "$", "code", ";", "}" ]
Returns the pre-processed code @return string
[ "Returns", "the", "pre", "-", "processed", "code" ]
9d8424dfb586f823f9dad2dcb81ff3986e255d56
https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/Definition/AbstractCodeDefinition.php#L54-L91
3,309
PublisherHub/Publisher
src/Publisher/Helper/Validator.php
Validator.checkRequiredParametersAreSet
static function checkRequiredParametersAreSet(array $given, array $required) { foreach ($required as $key) { if (empty($given[$key])) { throw new MissingRequiredParameterException( "Missing required parameter '$key'" ); } } }
php
static function checkRequiredParametersAreSet(array $given, array $required) { foreach ($required as $key) { if (empty($given[$key])) { throw new MissingRequiredParameterException( "Missing required parameter '$key'" ); } } }
[ "static", "function", "checkRequiredParametersAreSet", "(", "array", "$", "given", ",", "array", "$", "required", ")", "{", "foreach", "(", "$", "required", "as", "$", "key", ")", "{", "if", "(", "empty", "(", "$", "given", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "MissingRequiredParameterException", "(", "\"Missing required parameter '$key'\"", ")", ";", "}", "}", "}" ]
Validates if all required parameters are set. @param array $given @param array $required contains required keys
[ "Validates", "if", "all", "required", "parameters", "are", "set", "." ]
954e05118be9956e0c8631e44958af4ba42606b3
https://github.com/PublisherHub/Publisher/blob/954e05118be9956e0c8631e44958af4ba42606b3/src/Publisher/Helper/Validator.php#L38-L47
3,310
PublisherHub/Publisher
src/Publisher/Helper/Validator.php
Validator.checkAnyRequiredParameter
static function checkAnyRequiredParameter(array $given, array $required) { try { foreach ($required as $key) { if (!empty($given[$key])) { throw new RequiredParameterFound(); } } $parameters = implode(', ', $required); throw new MissingRequiredParameterException( "At least one parameter required: $parameters" ); } catch (RequiredParameterFound $ex) { // we have one required parameter, thats all we need } }
php
static function checkAnyRequiredParameter(array $given, array $required) { try { foreach ($required as $key) { if (!empty($given[$key])) { throw new RequiredParameterFound(); } } $parameters = implode(', ', $required); throw new MissingRequiredParameterException( "At least one parameter required: $parameters" ); } catch (RequiredParameterFound $ex) { // we have one required parameter, thats all we need } }
[ "static", "function", "checkAnyRequiredParameter", "(", "array", "$", "given", ",", "array", "$", "required", ")", "{", "try", "{", "foreach", "(", "$", "required", "as", "$", "key", ")", "{", "if", "(", "!", "empty", "(", "$", "given", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "RequiredParameterFound", "(", ")", ";", "}", "}", "$", "parameters", "=", "implode", "(", "', '", ",", "$", "required", ")", ";", "throw", "new", "MissingRequiredParameterException", "(", "\"At least one parameter required: $parameters\"", ")", ";", "}", "catch", "(", "RequiredParameterFound", "$", "ex", ")", "{", "// we have one required parameter, thats all we need\r", "}", "}" ]
Validates if any required parameters are set and not empty. @param array $given @param array $required contains required keys
[ "Validates", "if", "any", "required", "parameters", "are", "set", "and", "not", "empty", "." ]
954e05118be9956e0c8631e44958af4ba42606b3
https://github.com/PublisherHub/Publisher/blob/954e05118be9956e0c8631e44958af4ba42606b3/src/Publisher/Helper/Validator.php#L55-L73
3,311
PublisherHub/Publisher
src/Publisher/Helper/Validator.php
Validator.checkRequiredParameters
static function checkRequiredParameters(array $given, array $required) { foreach ($required as $key) { if (!array_key_exists($key, $given)) { throw new MissingRequiredParameterException( "Missing required parameter '$key'" ); } } }
php
static function checkRequiredParameters(array $given, array $required) { foreach ($required as $key) { if (!array_key_exists($key, $given)) { throw new MissingRequiredParameterException( "Missing required parameter '$key'" ); } } }
[ "static", "function", "checkRequiredParameters", "(", "array", "$", "given", ",", "array", "$", "required", ")", "{", "foreach", "(", "$", "required", "as", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "given", ")", ")", "{", "throw", "new", "MissingRequiredParameterException", "(", "\"Missing required parameter '$key'\"", ")", ";", "}", "}", "}" ]
Validates if all required parameters are present. @param array $given @param array $required contains required keys @throws MissingRequiredParameterException @return void
[ "Validates", "if", "all", "required", "parameters", "are", "present", "." ]
954e05118be9956e0c8631e44958af4ba42606b3
https://github.com/PublisherHub/Publisher/blob/954e05118be9956e0c8631e44958af4ba42606b3/src/Publisher/Helper/Validator.php#L85-L94
3,312
freialib/fenrir.tools
src/Dispatcher/Http.php
HttpDispatcher.get
function get($route, callable $controller) { if ($this->request->requestMethod() == 'get') { $this->any($route, $controller); } }
php
function get($route, callable $controller) { if ($this->request->requestMethod() == 'get') { $this->any($route, $controller); } }
[ "function", "get", "(", "$", "route", ",", "callable", "$", "controller", ")", "{", "if", "(", "$", "this", "->", "request", "->", "requestMethod", "(", ")", "==", "'get'", ")", "{", "$", "this", "->", "any", "(", "$", "route", ",", "$", "controller", ")", ";", "}", "}" ]
HTTP 1.1 GET method
[ "HTTP", "1", ".", "1", "GET", "method" ]
3e6359103a640bd2fcb9708d6874fb0aeebbf7c5
https://github.com/freialib/fenrir.tools/blob/3e6359103a640bd2fcb9708d6874fb0aeebbf7c5/src/Dispatcher/Http.php#L77-L81
3,313
freialib/fenrir.tools
src/Dispatcher/Http.php
HttpDispatcher.post
function post($route, callable $controller) { if ($this->request->requestMethod() == 'post') { $this->any($route, $controller); } }
php
function post($route, callable $controller) { if ($this->request->requestMethod() == 'post') { $this->any($route, $controller); } }
[ "function", "post", "(", "$", "route", ",", "callable", "$", "controller", ")", "{", "if", "(", "$", "this", "->", "request", "->", "requestMethod", "(", ")", "==", "'post'", ")", "{", "$", "this", "->", "any", "(", "$", "route", ",", "$", "controller", ")", ";", "}", "}" ]
HTTP 1.1 POST method
[ "HTTP", "1", ".", "1", "POST", "method" ]
3e6359103a640bd2fcb9708d6874fb0aeebbf7c5
https://github.com/freialib/fenrir.tools/blob/3e6359103a640bd2fcb9708d6874fb0aeebbf7c5/src/Dispatcher/Http.php#L86-L90
3,314
oal/babble
src/Models/Record.php
Record.save
public function save(array $data) { if (!$this->getModel()->isSingle()) { $id = $data['id'] ?? $this->id; $this->id = $id; } $columns = $this->data; foreach ($columns as $key => $column) { if (array_key_exists($key, $data)) { $column->setValue($data[$key]); } else { $column->setValue(null); } } $yaml = Yaml::dump($this->getData(), 5, 4, YAML::DUMP_MULTI_LINE_LITERAL_BLOCK | YAML::DUMP_OBJECT_AS_MAP); $fs = new Filesystem(); $fs->dumpFile($this->getContentFilePath(), $yaml); }
php
public function save(array $data) { if (!$this->getModel()->isSingle()) { $id = $data['id'] ?? $this->id; $this->id = $id; } $columns = $this->data; foreach ($columns as $key => $column) { if (array_key_exists($key, $data)) { $column->setValue($data[$key]); } else { $column->setValue(null); } } $yaml = Yaml::dump($this->getData(), 5, 4, YAML::DUMP_MULTI_LINE_LITERAL_BLOCK | YAML::DUMP_OBJECT_AS_MAP); $fs = new Filesystem(); $fs->dumpFile($this->getContentFilePath(), $yaml); }
[ "public", "function", "save", "(", "array", "$", "data", ")", "{", "if", "(", "!", "$", "this", "->", "getModel", "(", ")", "->", "isSingle", "(", ")", ")", "{", "$", "id", "=", "$", "data", "[", "'id'", "]", "??", "$", "this", "->", "id", ";", "$", "this", "->", "id", "=", "$", "id", ";", "}", "$", "columns", "=", "$", "this", "->", "data", ";", "foreach", "(", "$", "columns", "as", "$", "key", "=>", "$", "column", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "data", ")", ")", "{", "$", "column", "->", "setValue", "(", "$", "data", "[", "$", "key", "]", ")", ";", "}", "else", "{", "$", "column", "->", "setValue", "(", "null", ")", ";", "}", "}", "$", "yaml", "=", "Yaml", "::", "dump", "(", "$", "this", "->", "getData", "(", ")", ",", "5", ",", "4", ",", "YAML", "::", "DUMP_MULTI_LINE_LITERAL_BLOCK", "|", "YAML", "::", "DUMP_OBJECT_AS_MAP", ")", ";", "$", "fs", "=", "new", "Filesystem", "(", ")", ";", "$", "fs", "->", "dumpFile", "(", "$", "this", "->", "getContentFilePath", "(", ")", ",", "$", "yaml", ")", ";", "}" ]
Validates and saves record to disk. @param array $data
[ "Validates", "and", "saves", "record", "to", "disk", "." ]
5a352d12ead6341294747831b0dfce097a0215e7
https://github.com/oal/babble/blob/5a352d12ead6341294747831b0dfce097a0215e7/src/Models/Record.php#L39-L59
3,315
oal/babble
src/Models/Record.php
Record.getValue
public function getValue(string $column) { if ($column === 'id') return $this->id; return $this->data[$column]->getValue(); }
php
public function getValue(string $column) { if ($column === 'id') return $this->id; return $this->data[$column]->getValue(); }
[ "public", "function", "getValue", "(", "string", "$", "column", ")", "{", "if", "(", "$", "column", "===", "'id'", ")", "return", "$", "this", "->", "id", ";", "return", "$", "this", "->", "data", "[", "$", "column", "]", "->", "getValue", "(", ")", ";", "}" ]
Returns the value of a column. @param string $column @return mixed
[ "Returns", "the", "value", "of", "a", "column", "." ]
5a352d12ead6341294747831b0dfce097a0215e7
https://github.com/oal/babble/blob/5a352d12ead6341294747831b0dfce097a0215e7/src/Models/Record.php#L88-L92
3,316
YiMAproject/yima-base
src/yimaBase/Mvc/Listener/DispatchListener.php
DispatchListener.complete
protected function complete($return, MvcEvent $event) { if (!is_object($return)) { if (ArrayUtils::hasStringKeys($return)) { $return = new ArrayObject($return, ArrayObject::ARRAY_AS_PROPS); } } $event->setResult($return); return $return; }
php
protected function complete($return, MvcEvent $event) { if (!is_object($return)) { if (ArrayUtils::hasStringKeys($return)) { $return = new ArrayObject($return, ArrayObject::ARRAY_AS_PROPS); } } $event->setResult($return); return $return; }
[ "protected", "function", "complete", "(", "$", "return", ",", "MvcEvent", "$", "event", ")", "{", "if", "(", "!", "is_object", "(", "$", "return", ")", ")", "{", "if", "(", "ArrayUtils", "::", "hasStringKeys", "(", "$", "return", ")", ")", "{", "$", "return", "=", "new", "ArrayObject", "(", "$", "return", ",", "ArrayObject", "::", "ARRAY_AS_PROPS", ")", ";", "}", "}", "$", "event", "->", "setResult", "(", "$", "return", ")", ";", "return", "$", "return", ";", "}" ]
Complete the dispatch @param mixed $return @param MvcEvent $event @return mixed
[ "Complete", "the", "dispatch" ]
1dc91a3b5f0794e586f43808f52ae8d8cfa2633f
https://github.com/YiMAproject/yima-base/blob/1dc91a3b5f0794e586f43808f52ae8d8cfa2633f/src/yimaBase/Mvc/Listener/DispatchListener.php#L110-L120
3,317
CodeCollab/I18n
src/FileTranslator.php
FileTranslator.translate
public function translate(string $key, array $data = []): string { if (!array_key_exists($key, $this->texts)) { return '{{' . $key . '}}'; } if (empty($data)) { return $this->texts[$key]; } return call_user_func_array('sprintf', array_merge([$this->texts[$key]], $data)); }
php
public function translate(string $key, array $data = []): string { if (!array_key_exists($key, $this->texts)) { return '{{' . $key . '}}'; } if (empty($data)) { return $this->texts[$key]; } return call_user_func_array('sprintf', array_merge([$this->texts[$key]], $data)); }
[ "public", "function", "translate", "(", "string", "$", "key", ",", "array", "$", "data", "=", "[", "]", ")", ":", "string", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "texts", ")", ")", "{", "return", "'{{'", ".", "$", "key", ".", "'}}'", ";", "}", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "$", "this", "->", "texts", "[", "$", "key", "]", ";", "}", "return", "call_user_func_array", "(", "'sprintf'", ",", "array_merge", "(", "[", "$", "this", "->", "texts", "[", "$", "key", "]", "]", ",", "$", "data", ")", ")", ";", "}" ]
Gets the translation by key if any or a placeholder otherwise @param string $key The translation key for which to find the translation @param array $data Extra data to use in the translated string as variables @return string The translation or a placeholder when no translation is available
[ "Gets", "the", "translation", "by", "key", "if", "any", "or", "a", "placeholder", "otherwise" ]
04bd46bab83f42fadab53ff0d043365cc6c80301
https://github.com/CodeCollab/I18n/blob/04bd46bab83f42fadab53ff0d043365cc6c80301/src/FileTranslator.php#L68-L79
3,318
crisu83/yii-caviar
src/components/File.php
File.save
public function save() { $dir = dirname($this->path); if (!is_dir($dir)) { $mask = @umask(0); $result = @mkdir($dir, $this->dirMode, true); @umask($mask); if (!$result) { throw new Exception("Unable to create the directory '$dir'."); } } if (@file_put_contents($this->path, $this->content) === false) { throw new Exception("Unable to write the file '{$this->path}'."); } $mask = @umask(0); @chmod($this->path, $this->mode); @umask($mask); return true; }
php
public function save() { $dir = dirname($this->path); if (!is_dir($dir)) { $mask = @umask(0); $result = @mkdir($dir, $this->dirMode, true); @umask($mask); if (!$result) { throw new Exception("Unable to create the directory '$dir'."); } } if (@file_put_contents($this->path, $this->content) === false) { throw new Exception("Unable to write the file '{$this->path}'."); } $mask = @umask(0); @chmod($this->path, $this->mode); @umask($mask); return true; }
[ "public", "function", "save", "(", ")", "{", "$", "dir", "=", "dirname", "(", "$", "this", "->", "path", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "$", "mask", "=", "@", "umask", "(", "0", ")", ";", "$", "result", "=", "@", "mkdir", "(", "$", "dir", ",", "$", "this", "->", "dirMode", ",", "true", ")", ";", "@", "umask", "(", "$", "mask", ")", ";", "if", "(", "!", "$", "result", ")", "{", "throw", "new", "Exception", "(", "\"Unable to create the directory '$dir'.\"", ")", ";", "}", "}", "if", "(", "@", "file_put_contents", "(", "$", "this", "->", "path", ",", "$", "this", "->", "content", ")", "===", "false", ")", "{", "throw", "new", "Exception", "(", "\"Unable to write the file '{$this->path}'.\"", ")", ";", "}", "$", "mask", "=", "@", "umask", "(", "0", ")", ";", "@", "chmod", "(", "$", "this", "->", "path", ",", "$", "this", "->", "mode", ")", ";", "@", "umask", "(", "$", "mask", ")", ";", "return", "true", ";", "}" ]
Saves this file. @return boolean whether the file was saved successfully. @throws \crisu83\yii_caviar\Exception if the file or the directory cannot be created.
[ "Saves", "this", "file", "." ]
c85286b88e68558224e7f2ea7fff8f6975e46283
https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/components/File.php#L59-L82
3,319
crisu83/yii-caviar
src/components/File.php
File.resolveExtension
public function resolveExtension() { if (($pos = strrpos($this->path, '.')) !== false) { return substr($this->path, $pos + 1); } return ''; }
php
public function resolveExtension() { if (($pos = strrpos($this->path, '.')) !== false) { return substr($this->path, $pos + 1); } return ''; }
[ "public", "function", "resolveExtension", "(", ")", "{", "if", "(", "(", "$", "pos", "=", "strrpos", "(", "$", "this", "->", "path", ",", "'.'", ")", ")", "!==", "false", ")", "{", "return", "substr", "(", "$", "this", "->", "path", ",", "$", "pos", "+", "1", ")", ";", "}", "return", "''", ";", "}" ]
Returns the extension for this file. @return string extension.
[ "Returns", "the", "extension", "for", "this", "file", "." ]
c85286b88e68558224e7f2ea7fff8f6975e46283
https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/components/File.php#L89-L96
3,320
twister-php/twister
src/DatePeriod.php
DatePeriod.setStartTimezone
public function setStartTimezone($timezone = 'UTC') { $this->start->setTimezone(is_string($timezone) ? new \DateTimeZone($timezone) : $timezone); return $this; }
php
public function setStartTimezone($timezone = 'UTC') { $this->start->setTimezone(is_string($timezone) ? new \DateTimeZone($timezone) : $timezone); return $this; }
[ "public", "function", "setStartTimezone", "(", "$", "timezone", "=", "'UTC'", ")", "{", "$", "this", "->", "start", "->", "setTimezone", "(", "is_string", "(", "$", "timezone", ")", "?", "new", "\\", "DateTimeZone", "(", "$", "timezone", ")", ":", "$", "timezone", ")", ";", "return", "$", "this", ";", "}" ]
Sets the start date timezone @link http://php.net/manual/en/datetime.settimezone.php @param string|DateTimeZone $timezone @return $this
[ "Sets", "the", "start", "date", "timezone" ]
c06ea2650331faf11590c017c850dc5f0bbc5c13
https://github.com/twister-php/twister/blob/c06ea2650331faf11590c017c850dc5f0bbc5c13/src/DatePeriod.php#L836-L840
3,321
twister-php/twister
src/DatePeriod.php
DatePeriod.setEndTimezone
public function setEndTimezone($timezone = 'UTC') { $this->end->setTimezone(is_string($timezone) ? new \DateTimeZone($timezone) : $timezone); return $this; }
php
public function setEndTimezone($timezone = 'UTC') { $this->end->setTimezone(is_string($timezone) ? new \DateTimeZone($timezone) : $timezone); return $this; }
[ "public", "function", "setEndTimezone", "(", "$", "timezone", "=", "'UTC'", ")", "{", "$", "this", "->", "end", "->", "setTimezone", "(", "is_string", "(", "$", "timezone", ")", "?", "new", "\\", "DateTimeZone", "(", "$", "timezone", ")", ":", "$", "timezone", ")", ";", "return", "$", "this", ";", "}" ]
Sets the end date timezone @link http://php.net/manual/en/datetime.settimezone.php @param string|DateTimeZone $timezone @return $this
[ "Sets", "the", "end", "date", "timezone" ]
c06ea2650331faf11590c017c850dc5f0bbc5c13
https://github.com/twister-php/twister/blob/c06ea2650331faf11590c017c850dc5f0bbc5c13/src/DatePeriod.php#L850-L854
3,322
zepi/turbo-base
Zepi/Core/AccessControl/src/Manager/EventAccessManager.php
EventAccessManager.loadItems
protected function loadItems() { $items = $this->eventAccessObjectBackend->loadObject(); if (!is_array($items)) { $items = array(); } $this->items = $items; }
php
protected function loadItems() { $items = $this->eventAccessObjectBackend->loadObject(); if (!is_array($items)) { $items = array(); } $this->items = $items; }
[ "protected", "function", "loadItems", "(", ")", "{", "$", "items", "=", "$", "this", "->", "eventAccessObjectBackend", "->", "loadObject", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "items", ")", ")", "{", "$", "items", "=", "array", "(", ")", ";", "}", "$", "this", "->", "items", "=", "$", "items", ";", "}" ]
Loads the items from the object backend @access public
[ "Loads", "the", "items", "from", "the", "object", "backend" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/Manager/EventAccessManager.php#L85-L93
3,323
zepi/turbo-base
Zepi/Core/AccessControl/src/Manager/EventAccessManager.php
EventAccessManager.addItem
public function addItem($eventName, $accessLevel) { if (!isset($this->items[$eventName])) { $this->items[$eventName] = array(); } if (in_array($accessLevel, $this->items[$eventName])) { return; } // Add the definition $this->items[$eventName][] = $accessLevel; // Save the items $this->saveItems(); }
php
public function addItem($eventName, $accessLevel) { if (!isset($this->items[$eventName])) { $this->items[$eventName] = array(); } if (in_array($accessLevel, $this->items[$eventName])) { return; } // Add the definition $this->items[$eventName][] = $accessLevel; // Save the items $this->saveItems(); }
[ "public", "function", "addItem", "(", "$", "eventName", ",", "$", "accessLevel", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "items", "[", "$", "eventName", "]", ")", ")", "{", "$", "this", "->", "items", "[", "$", "eventName", "]", "=", "array", "(", ")", ";", "}", "if", "(", "in_array", "(", "$", "accessLevel", ",", "$", "this", "->", "items", "[", "$", "eventName", "]", ")", ")", "{", "return", ";", "}", "// Add the definition", "$", "this", "->", "items", "[", "$", "eventName", "]", "[", "]", "=", "$", "accessLevel", ";", "// Save the items", "$", "this", "->", "saveItems", "(", ")", ";", "}" ]
Adds the access levels for the event name @access public @param string $eventName @param string $accessLevel
[ "Adds", "the", "access", "levels", "for", "the", "event", "name" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/Manager/EventAccessManager.php#L112-L127
3,324
zepi/turbo-base
Zepi/Core/AccessControl/src/Manager/EventAccessManager.php
EventAccessManager.removeItems
public function removeItems($eventName) { if (!isset($this->items[$eventName])) { return false; } // Remove the event unset($this->items[$eventName]); // Save the items $this->saveItems(); }
php
public function removeItems($eventName) { if (!isset($this->items[$eventName])) { return false; } // Remove the event unset($this->items[$eventName]); // Save the items $this->saveItems(); }
[ "public", "function", "removeItems", "(", "$", "eventName", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "items", "[", "$", "eventName", "]", ")", ")", "{", "return", "false", ";", "}", "// Remove the event", "unset", "(", "$", "this", "->", "items", "[", "$", "eventName", "]", ")", ";", "// Save the items", "$", "this", "->", "saveItems", "(", ")", ";", "}" ]
Removes all access levels for the given event name. @access public @param string $eventName @return false|void
[ "Removes", "all", "access", "levels", "for", "the", "given", "event", "name", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/Manager/EventAccessManager.php#L136-L147
3,325
zepi/turbo-base
Zepi/Core/AccessControl/src/Manager/EventAccessManager.php
EventAccessManager.getAccessLevelsForEvent
public function getAccessLevelsForEvent($eventName) { if (!isset($this->items[$eventName])) { return false; } return $this->items[$eventName]; }
php
public function getAccessLevelsForEvent($eventName) { if (!isset($this->items[$eventName])) { return false; } return $this->items[$eventName]; }
[ "public", "function", "getAccessLevelsForEvent", "(", "$", "eventName", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "items", "[", "$", "eventName", "]", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "items", "[", "$", "eventName", "]", ";", "}" ]
Returns the access levels for the given event name or false if the event name is not set. @param string $eventName @return false|array
[ "Returns", "the", "access", "levels", "for", "the", "given", "event", "name", "or", "false", "if", "the", "event", "name", "is", "not", "set", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/Manager/EventAccessManager.php#L167-L174
3,326
RodinVasily/core
src/Core/Collection/AbstractNamedCollection.php
AbstractNamedCollection.getByName
public function getByName($name, $throwException = true) { foreach ($this as $element) { if (!$element instanceof Element\NamedElement) { throw new Exception\CollectionException(); } if ($element->getName() === $name) { return $element; } } if ($throwException) { throw new Exception\NotFoundException(); } return null; }
php
public function getByName($name, $throwException = true) { foreach ($this as $element) { if (!$element instanceof Element\NamedElement) { throw new Exception\CollectionException(); } if ($element->getName() === $name) { return $element; } } if ($throwException) { throw new Exception\NotFoundException(); } return null; }
[ "public", "function", "getByName", "(", "$", "name", ",", "$", "throwException", "=", "true", ")", "{", "foreach", "(", "$", "this", "as", "$", "element", ")", "{", "if", "(", "!", "$", "element", "instanceof", "Element", "\\", "NamedElement", ")", "{", "throw", "new", "Exception", "\\", "CollectionException", "(", ")", ";", "}", "if", "(", "$", "element", "->", "getName", "(", ")", "===", "$", "name", ")", "{", "return", "$", "element", ";", "}", "}", "if", "(", "$", "throwException", ")", "{", "throw", "new", "Exception", "\\", "NotFoundException", "(", ")", ";", "}", "return", "null", ";", "}" ]
Get element by name @param string $name @param bool $throwException @throws Exception\CollectionException @throws Exception\NotFoundException @return Element\NamedElement|null
[ "Get", "element", "by", "name" ]
1c0d5d7a55a1076409035df1d3b0c8bb11b137db
https://github.com/RodinVasily/core/blob/1c0d5d7a55a1076409035df1d3b0c8bb11b137db/src/Core/Collection/AbstractNamedCollection.php#L45-L63
3,327
marando/phpSOFA
src/Marando/IAU/iauApio13.php
iauApio13.Apio13
public static function Apio13($utc1, $utc2, $dut1, $elong, $phi, $hm, $xp, $yp, $phpa, $tc, $rh, $wl, iauASTROM &$astrom) { $j; $tai1; $tai2; $tt1; $tt2; $ut11; $ut12; $sp; $theta; $refa; $refb; /* UTC to other time scales. */ $j = IAU::Utctai($utc1, $utc2, $tai1, $tai2); if ($j < 0) return -1; $j = IAU::Taitt($tai1, $tai2, $tt1, $tt2); $j = IAU::Utcut1($utc1, $utc2, $dut1, $ut11, $ut12); if ($j < 0) return -1; /* TIO locator s'. */ $sp = IAU::Sp00($tt1, $tt2); /* Earth rotation angle. */ $theta = IAU::Era00($ut11, $ut12); /* Refraction constants A and B. */ IAU::Refco($phpa, $tc, $rh, $wl, $refa, $refb); /* CIRS <-> observed astrometry parameters. */ IAU::Apio($sp, $theta, $elong, $phi, $hm, $xp, $yp, $refa, $refb, $astrom); /* Return any warning status. */ return $j; /* Finished. */ }
php
public static function Apio13($utc1, $utc2, $dut1, $elong, $phi, $hm, $xp, $yp, $phpa, $tc, $rh, $wl, iauASTROM &$astrom) { $j; $tai1; $tai2; $tt1; $tt2; $ut11; $ut12; $sp; $theta; $refa; $refb; /* UTC to other time scales. */ $j = IAU::Utctai($utc1, $utc2, $tai1, $tai2); if ($j < 0) return -1; $j = IAU::Taitt($tai1, $tai2, $tt1, $tt2); $j = IAU::Utcut1($utc1, $utc2, $dut1, $ut11, $ut12); if ($j < 0) return -1; /* TIO locator s'. */ $sp = IAU::Sp00($tt1, $tt2); /* Earth rotation angle. */ $theta = IAU::Era00($ut11, $ut12); /* Refraction constants A and B. */ IAU::Refco($phpa, $tc, $rh, $wl, $refa, $refb); /* CIRS <-> observed astrometry parameters. */ IAU::Apio($sp, $theta, $elong, $phi, $hm, $xp, $yp, $refa, $refb, $astrom); /* Return any warning status. */ return $j; /* Finished. */ }
[ "public", "static", "function", "Apio13", "(", "$", "utc1", ",", "$", "utc2", ",", "$", "dut1", ",", "$", "elong", ",", "$", "phi", ",", "$", "hm", ",", "$", "xp", ",", "$", "yp", ",", "$", "phpa", ",", "$", "tc", ",", "$", "rh", ",", "$", "wl", ",", "iauASTROM", "&", "$", "astrom", ")", "{", "$", "j", ";", "$", "tai1", ";", "$", "tai2", ";", "$", "tt1", ";", "$", "tt2", ";", "$", "ut11", ";", "$", "ut12", ";", "$", "sp", ";", "$", "theta", ";", "$", "refa", ";", "$", "refb", ";", "/* UTC to other time scales. */", "$", "j", "=", "IAU", "::", "Utctai", "(", "$", "utc1", ",", "$", "utc2", ",", "$", "tai1", ",", "$", "tai2", ")", ";", "if", "(", "$", "j", "<", "0", ")", "return", "-", "1", ";", "$", "j", "=", "IAU", "::", "Taitt", "(", "$", "tai1", ",", "$", "tai2", ",", "$", "tt1", ",", "$", "tt2", ")", ";", "$", "j", "=", "IAU", "::", "Utcut1", "(", "$", "utc1", ",", "$", "utc2", ",", "$", "dut1", ",", "$", "ut11", ",", "$", "ut12", ")", ";", "if", "(", "$", "j", "<", "0", ")", "return", "-", "1", ";", "/* TIO locator s'. */", "$", "sp", "=", "IAU", "::", "Sp00", "(", "$", "tt1", ",", "$", "tt2", ")", ";", "/* Earth rotation angle. */", "$", "theta", "=", "IAU", "::", "Era00", "(", "$", "ut11", ",", "$", "ut12", ")", ";", "/* Refraction constants A and B. */", "IAU", "::", "Refco", "(", "$", "phpa", ",", "$", "tc", ",", "$", "rh", ",", "$", "wl", ",", "$", "refa", ",", "$", "refb", ")", ";", "/* CIRS <-> observed astrometry parameters. */", "IAU", "::", "Apio", "(", "$", "sp", ",", "$", "theta", ",", "$", "elong", ",", "$", "phi", ",", "$", "hm", ",", "$", "xp", ",", "$", "yp", ",", "$", "refa", ",", "$", "refb", ",", "$", "astrom", ")", ";", "/* Return any warning status. */", "return", "$", "j", ";", "/* Finished. */", "}" ]
- - - - - - - - - - i a u A p i o 1 3 - - - - - - - - - - For a terrestrial observer, prepare star-independent astrometry parameters for transformations between CIRS and observed coordinates. The caller supplies UTC, site coordinates, ambient air conditions and observing wavelength. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: utc1 double UTC as a 2-part... utc2 double ...quasi Julian Date (Notes 1,2) dut1 double UT1-UTC (seconds) elong double longitude (radians, east +ve, Note 3) phi double geodetic latitude (radians, Note 3) hm double height above ellipsoid (m, geodetic Notes 4,6) xp,yp double polar motion coordinates (radians, Note 5) phpa double pressure at the observer (hPa = mB, Note 6) tc double ambient temperature at the observer (deg C) rh double relative humidity at the observer (range 0-1) wl double wavelength (micrometers, Note 7) Returned: astrom iauASTROM* star-independent astrometry parameters: pmt double unchanged eb double[3] unchanged eh double[3] unchanged em double unchanged v double[3] unchanged bm1 double unchanged bpn double[3][3] unchanged along double longitude + s' (radians) xpl double polar motion xp wrt local meridian (radians) ypl double polar motion yp wrt local meridian (radians) sphi double sine of geodetic latitude cphi double cosine of geodetic latitude diurab double magnitude of diurnal aberration vector eral double "local" Earth rotation angle (radians) refa double refraction constant A (radians) refb double refraction constant B (radians) Returned (function value): int status: +1 = dubious year (Note 2) 0 = OK -1 = unacceptable date Notes: 1) utc1+utc2 is quasi Julian Date (see Note 2), apportioned in any convenient way between the two arguments, for example where utc1 is the Julian Day Number and utc2 is the fraction of a day. However, JD cannot unambiguously represent UTC during a leap second unless special measures are taken. The convention in the present function is that the JD day represents UTC days whether the length is 86399, 86400 or 86401 SI seconds. Applications should use the function iauDtf2d to convert from calendar date and time of day into 2-part quasi Julian Date, as it implements the leap-second-ambiguity convention just described. 2) The warning status "dubious year" flags UTCs that predate the introduction of the time scale or that are too far in the future to be trusted. See iauDat for further details. 3) UT1-UTC is tabulated in IERS bulletins. It increases by exactly one second at the end of each positive UTC leap second, introduced in order to keep UT1-UTC within +/- 0.9s. n.b. This practice is under review, and in the future UT1-UTC may grow essentially without limit. 4) The geographical coordinates are with respect to the WGS84 reference ellipsoid. TAKE CARE WITH THE LONGITUDE SIGN: the longitude required by the present function is east-positive (i.e. right-handed), in accordance with geographical convention. 5) The polar motion xp,yp can be obtained from IERS bulletins. The values are the coordinates (in radians) of the Celestial Intermediate Pole with respect to the International Terrestrial Reference System (see IERS Conventions 2003), measured along the meridians 0 and 90 deg west respectively. For many applications, xp and yp can be set to zero. Internally, the polar motion is stored in a form rotated onto the local meridian. 6) If hm, the height above the ellipsoid of the observing station in meters, is not known but phpa, the pressure in hPa (=mB), is available, an adequate estimate of hm can be obtained from the expression hm = -29.3 * tsl * log ( phpa / 1013.25 ); where tsl is the approximate sea-level air temperature in K (See Astrophysical Quantities, C.W.Allen, 3rd edition, section 52). Similarly, if the pressure phpa is not known, it can be estimated from the height of the observing station, hm, as follows: phpa = 1013.25 * exp ( -hm / ( 29.3 * tsl ) ); Note, however, that the refraction is nearly proportional to the pressure and that an accurate phpa value is important for precise work. 7) The argument wl specifies the observing wavelength in micrometers. The transition from optical to radio is assumed to occur at 100 micrometers (about 3000 GHz). 8) It is advisable to take great care with units, as even unlikely values of the input parameters are accepted and processed in accordance with the models used. 9) In cases where the caller wishes to supply his own Earth rotation information and refraction constants, the function iauApc can be used instead of the present function. 10) This is one of several functions that inserts into the astrom structure star-independent parameters needed for the chain of astrometric transformations ICRS <-> GCRS <-> CIRS <-> observed. The various functions support different classes of observer and portions of the transformation chain: functions observer transformation iauApcg iauApcg13 geocentric ICRS <-> GCRS iauApci iauApci13 terrestrial ICRS <-> CIRS iauApco iauApco13 terrestrial ICRS <-> observed iauApcs iauApcs13 space ICRS <-> GCRS iauAper iauAper13 terrestrial update Earth rotation iauApio iauApio13 terrestrial CIRS <-> observed Those with names ending in "13" use contemporary SOFA models to compute the various ephemerides. The others accept ephemerides supplied by the caller. The transformation from ICRS to GCRS covers space motion, parallax, light deflection, and aberration. From GCRS to CIRS comprises frame bias and precession-nutation. From CIRS to observed takes account of Earth rotation, polar motion, diurnal aberration and parallax (unless subsumed into the ICRS <-> GCRS transformation), and atmospheric refraction. 11) The context structure astrom produced by this function is used by iauAtioq and iauAtoiq. Called: iauUtctai UTC to TAI iauTaitt TAI to TT iauUtcut1 UTC to UT1 iauSp00 the TIO locator s', IERS 2000 iauEra00 Earth rotation angle, IAU 2000 iauRefco refraction constants for given ambient conditions iauApio astrometry parameters, CIRS-observed This revision: 2013 October 9 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "A", "p", "i", "o", "1", "3", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauApio13.php#L176-L216
3,328
indigophp-archive/fuel-core
lib/Fuel/Orm/Observer/UpdatedBy.php
UpdatedBy.before_update
public function before_update(Orm\Model $obj) { // If there are any relations loop through and check if any of them have been changed $relation_changed = false; foreach ($this->_relations as $relation) { if ($this->relation_changed($obj, $relation)) { $relation_changed = true; break; } } if (($obj->is_changed() or $relation_changed) and $user_id = \Auth::get_user_id()) { $obj->{$this->_property} = $user_id[1]; } }
php
public function before_update(Orm\Model $obj) { // If there are any relations loop through and check if any of them have been changed $relation_changed = false; foreach ($this->_relations as $relation) { if ($this->relation_changed($obj, $relation)) { $relation_changed = true; break; } } if (($obj->is_changed() or $relation_changed) and $user_id = \Auth::get_user_id()) { $obj->{$this->_property} = $user_id[1]; } }
[ "public", "function", "before_update", "(", "Orm", "\\", "Model", "$", "obj", ")", "{", "// If there are any relations loop through and check if any of them have been changed", "$", "relation_changed", "=", "false", ";", "foreach", "(", "$", "this", "->", "_relations", "as", "$", "relation", ")", "{", "if", "(", "$", "this", "->", "relation_changed", "(", "$", "obj", ",", "$", "relation", ")", ")", "{", "$", "relation_changed", "=", "true", ";", "break", ";", "}", "}", "if", "(", "(", "$", "obj", "->", "is_changed", "(", ")", "or", "$", "relation_changed", ")", "and", "$", "user_id", "=", "\\", "Auth", "::", "get_user_id", "(", ")", ")", "{", "$", "obj", "->", "{", "$", "this", "->", "_property", "}", "=", "$", "user_id", "[", "1", "]", ";", "}", "}" ]
Sets the UpdatedBy property to the current user id @param Model Model object subject of this observer method
[ "Sets", "the", "UpdatedBy", "property", "to", "the", "current", "user", "id" ]
275462154fb7937f8e1c2c541b31d8e7c5760e39
https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/lib/Fuel/Orm/Observer/UpdatedBy.php#L75-L93
3,329
JumpGateio/ViewResolution
src/JumpGate/ViewResolution/Traits/AutoResolvesViews.php
AutoResolvesViews.view
public function view($view = null, $layout = null) { $layoutOptions = $this->getLayoutOptions($layout); // Set up the default view resolution viewResolver()->setUp($layoutOptions, $view); $this->setupLayout(); }
php
public function view($view = null, $layout = null) { $layoutOptions = $this->getLayoutOptions($layout); // Set up the default view resolution viewResolver()->setUp($layoutOptions, $view); $this->setupLayout(); }
[ "public", "function", "view", "(", "$", "view", "=", "null", ",", "$", "layout", "=", "null", ")", "{", "$", "layoutOptions", "=", "$", "this", "->", "getLayoutOptions", "(", "$", "layout", ")", ";", "// Set up the default view resolution", "viewResolver", "(", ")", "->", "setUp", "(", "$", "layoutOptions", ",", "$", "view", ")", ";", "$", "this", "->", "setupLayout", "(", ")", ";", "}" ]
Find the view for the called method. @param null|string $view @param null|string $layout @return $this
[ "Find", "the", "view", "for", "the", "called", "method", "." ]
49339e160db55876ca2a8fbe15bb3e26148b33f2
https://github.com/JumpGateio/ViewResolution/blob/49339e160db55876ca2a8fbe15bb3e26148b33f2/src/JumpGate/ViewResolution/Traits/AutoResolvesViews.php#L20-L27
3,330
JumpGateio/ViewResolution
src/JumpGate/ViewResolution/Traits/AutoResolvesViews.php
AutoResolvesViews.getLayoutOptions
protected function getLayoutOptions($layout) { // If passed a layout, use that for any request. if (! is_null($layout)) { return [ 'default' => $layout, 'ajax' => $layout, ]; } // If a set of layout options is defined, use those. if (isset($this->layoutOptions)) { return $this->layoutOptions; } // Use nothing. return null; }
php
protected function getLayoutOptions($layout) { // If passed a layout, use that for any request. if (! is_null($layout)) { return [ 'default' => $layout, 'ajax' => $layout, ]; } // If a set of layout options is defined, use those. if (isset($this->layoutOptions)) { return $this->layoutOptions; } // Use nothing. return null; }
[ "protected", "function", "getLayoutOptions", "(", "$", "layout", ")", "{", "// If passed a layout, use that for any request.", "if", "(", "!", "is_null", "(", "$", "layout", ")", ")", "{", "return", "[", "'default'", "=>", "$", "layout", ",", "'ajax'", "=>", "$", "layout", ",", "]", ";", "}", "// If a set of layout options is defined, use those.", "if", "(", "isset", "(", "$", "this", "->", "layoutOptions", ")", ")", "{", "return", "$", "this", "->", "layoutOptions", ";", "}", "// Use nothing.", "return", "null", ";", "}" ]
Get an array of layout options if available. @param null|string $layout @return array|null
[ "Get", "an", "array", "of", "layout", "options", "if", "available", "." ]
49339e160db55876ca2a8fbe15bb3e26148b33f2
https://github.com/JumpGateio/ViewResolution/blob/49339e160db55876ca2a8fbe15bb3e26148b33f2/src/JumpGate/ViewResolution/Traits/AutoResolvesViews.php#L36-L53
3,331
AnonymPHP/Anonym-Library
src/Anonym/Console/Application.php
Application.getProviders
public function getProviders() { $providers = Arr::get($this->getGeneral(), 'providers', []); $routeId = array_search(RouteProvider::class, $providers); unset($providers[$routeId]); return array_merge($this->constructors, $providers); }
php
public function getProviders() { $providers = Arr::get($this->getGeneral(), 'providers', []); $routeId = array_search(RouteProvider::class, $providers); unset($providers[$routeId]); return array_merge($this->constructors, $providers); }
[ "public", "function", "getProviders", "(", ")", "{", "$", "providers", "=", "Arr", "::", "get", "(", "$", "this", "->", "getGeneral", "(", ")", ",", "'providers'", ",", "[", "]", ")", ";", "$", "routeId", "=", "array_search", "(", "RouteProvider", "::", "class", ",", "$", "providers", ")", ";", "unset", "(", "$", "providers", "[", "$", "routeId", "]", ")", ";", "return", "array_merge", "(", "$", "this", "->", "constructors", ",", "$", "providers", ")", ";", "}" ]
Return the providers without routing @return array
[ "Return", "the", "providers", "without", "routing" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Console/Application.php#L38-L45
3,332
webforge-labs/webforge-utils
src/php/Webforge/Common/DateTime/Time.php
Time.formatSpan
public static function formatSpan($timespan, $format = '%Y years %M Months %D days %I Minutes %S seconds %H hours %n milliseconds') { $dv = Time::getDateInterval($timespan); return $dv->format($format); }
php
public static function formatSpan($timespan, $format = '%Y years %M Months %D days %I Minutes %S seconds %H hours %n milliseconds') { $dv = Time::getDateInterval($timespan); return $dv->format($format); }
[ "public", "static", "function", "formatSpan", "(", "$", "timespan", ",", "$", "format", "=", "'%Y years %M Months %D days %I Minutes %S seconds %H hours %n milliseconds'", ")", "{", "$", "dv", "=", "Time", "::", "getDateInterval", "(", "$", "timespan", ")", ";", "return", "$", "dv", "->", "format", "(", "$", "format", ")", ";", "}" ]
Formatiert eine Zeitspanne in Sekunden in einen String @param float $timespan in Sekunden @param string $format http://de2.php.net/manual/de/dateinterval.format.php @return string
[ "Formatiert", "eine", "Zeitspanne", "in", "Sekunden", "in", "einen", "String" ]
a476eeec046c22ad91794b0ab9fe15a1d3f92bfc
https://github.com/webforge-labs/webforge-utils/blob/a476eeec046c22ad91794b0ab9fe15a1d3f92bfc/src/php/Webforge/Common/DateTime/Time.php#L14-L18
3,333
ekyna/Characteristics
Doctrine/Listener/AbstractMapsSubscriber.php
AbstractMapsSubscriber.loadClassMetadata
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $metadata = $eventArgs->getClassMetadata(); if ($metadata->getName() === self::ROOT_CHARACTERISTICS_CLASS) { $metadata->setDiscriminatorMap($this->characteristicsClassesMap); } }
php
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { $metadata = $eventArgs->getClassMetadata(); if ($metadata->getName() === self::ROOT_CHARACTERISTICS_CLASS) { $metadata->setDiscriminatorMap($this->characteristicsClassesMap); } }
[ "public", "function", "loadClassMetadata", "(", "LoadClassMetadataEventArgs", "$", "eventArgs", ")", "{", "$", "metadata", "=", "$", "eventArgs", "->", "getClassMetadata", "(", ")", ";", "if", "(", "$", "metadata", "->", "getName", "(", ")", "===", "self", "::", "ROOT_CHARACTERISTICS_CLASS", ")", "{", "$", "metadata", "->", "setDiscriminatorMap", "(", "$", "this", "->", "characteristicsClassesMap", ")", ";", "}", "}" ]
Sets the discriminator maps on AbstractCharacteristics entity mappings. @param LoadClassMetadataEventArgs $eventArgs
[ "Sets", "the", "discriminator", "maps", "on", "AbstractCharacteristics", "entity", "mappings", "." ]
118a349fd98a7c28721d3cbaba67ce79d1cffada
https://github.com/ekyna/Characteristics/blob/118a349fd98a7c28721d3cbaba67ce79d1cffada/Doctrine/Listener/AbstractMapsSubscriber.php#L39-L46
3,334
silverstripe-modular-project/silverstripe-links
code/models/Link.php
Link.getLinkType
public function getLinkType() { $types = $this->config()->get('types'); return isset($types[$this->Type]) ? _t('Links.TYPE'.strtoupper($this->Type), $types[$this->Type]) : null; }
php
public function getLinkType() { $types = $this->config()->get('types'); return isset($types[$this->Type]) ? _t('Links.TYPE'.strtoupper($this->Type), $types[$this->Type]) : null; }
[ "public", "function", "getLinkType", "(", ")", "{", "$", "types", "=", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'types'", ")", ";", "return", "isset", "(", "$", "types", "[", "$", "this", "->", "Type", "]", ")", "?", "_t", "(", "'Links.TYPE'", ".", "strtoupper", "(", "$", "this", "->", "Type", ")", ",", "$", "types", "[", "$", "this", "->", "Type", "]", ")", ":", "null", ";", "}" ]
Gets the description label of this links type @return string
[ "Gets", "the", "description", "label", "of", "this", "links", "type" ]
a52c9768197cc5dce68a402badaa05cc96aff691
https://github.com/silverstripe-modular-project/silverstripe-links/blob/a52c9768197cc5dce68a402badaa05cc96aff691/code/models/Link.php#L412-L416
3,335
diatem-net/jin-filesystem
src/FileSystem/IniFile.php
IniFile.get
public function get($cle, $errorIfNotExists = false) { if (is_null($this->values)) { return null; } else if (array_key_exists($cle, $this->values)) { return $this->values[$cle]; } else { if ($errorIfNotExists){ throw new \Exception('La clé '.$cle.' n\'existe pas dans le fichier '.$this->path); } else { return null; } } }
php
public function get($cle, $errorIfNotExists = false) { if (is_null($this->values)) { return null; } else if (array_key_exists($cle, $this->values)) { return $this->values[$cle]; } else { if ($errorIfNotExists){ throw new \Exception('La clé '.$cle.' n\'existe pas dans le fichier '.$this->path); } else { return null; } } }
[ "public", "function", "get", "(", "$", "cle", ",", "$", "errorIfNotExists", "=", "false", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "values", ")", ")", "{", "return", "null", ";", "}", "else", "if", "(", "array_key_exists", "(", "$", "cle", ",", "$", "this", "->", "values", ")", ")", "{", "return", "$", "this", "->", "values", "[", "$", "cle", "]", ";", "}", "else", "{", "if", "(", "$", "errorIfNotExists", ")", "{", "throw", "new", "\\", "Exception", "(", "'La clé '.", "$", "c", "le.", "'", " n\\'existe pas dans le fichier '.", "$", "t", "his-", ">p", "ath)", ";", "\r", "}", "else", "{", "return", "null", ";", "}", "}", "}" ]
Lit une valeur @param string $cle Clé @param boolean $errorIfNotExists (optional) Génère une exception si la clé n'existe pas @return null
[ "Lit", "une", "valeur" ]
0a97844284ca48cb47e28ef2834f20b8a42ef798
https://github.com/diatem-net/jin-filesystem/blob/0a97844284ca48cb47e28ef2834f20b8a42ef798/src/FileSystem/IniFile.php#L67-L80
3,336
nattreid/security
src/User.php
User.setNamespace
public function setNamespace(string $namespace): void { $storage = $this->getStorage(); if ($storage instanceof UserStorage) { $storage->setNamespace($namespace); } $this->initIdentity(); }
php
public function setNamespace(string $namespace): void { $storage = $this->getStorage(); if ($storage instanceof UserStorage) { $storage->setNamespace($namespace); } $this->initIdentity(); }
[ "public", "function", "setNamespace", "(", "string", "$", "namespace", ")", ":", "void", "{", "$", "storage", "=", "$", "this", "->", "getStorage", "(", ")", ";", "if", "(", "$", "storage", "instanceof", "UserStorage", ")", "{", "$", "storage", "->", "setNamespace", "(", "$", "namespace", ")", ";", "}", "$", "this", "->", "initIdentity", "(", ")", ";", "}" ]
Nastavi namespace pro autentizaci @param string $namespace
[ "Nastavi", "namespace", "pro", "autentizaci" ]
ed649e5bdf453cea2d5352e643dbf201193de01d
https://github.com/nattreid/security/blob/ed649e5bdf453cea2d5352e643dbf201193de01d/src/User.php#L111-L118
3,337
nattreid/security
src/User.php
User.isMobile
public function isMobile(bool $tablet = true): bool { $session = $this->session->getSection('user'); if ($tablet) { return $session->isMobile; } else { return $session->isMobile && !$session->isTablet; } }
php
public function isMobile(bool $tablet = true): bool { $session = $this->session->getSection('user'); if ($tablet) { return $session->isMobile; } else { return $session->isMobile && !$session->isTablet; } }
[ "public", "function", "isMobile", "(", "bool", "$", "tablet", "=", "true", ")", ":", "bool", "{", "$", "session", "=", "$", "this", "->", "session", "->", "getSection", "(", "'user'", ")", ";", "if", "(", "$", "tablet", ")", "{", "return", "$", "session", "->", "isMobile", ";", "}", "else", "{", "return", "$", "session", "->", "isMobile", "&&", "!", "$", "session", "->", "isTablet", ";", "}", "}" ]
Je klientsky prohlizec mobilni verze? @param bool $tablet patri do skupiny i tablety @return bool
[ "Je", "klientsky", "prohlizec", "mobilni", "verze?" ]
ed649e5bdf453cea2d5352e643dbf201193de01d
https://github.com/nattreid/security/blob/ed649e5bdf453cea2d5352e643dbf201193de01d/src/User.php#L169-L178
3,338
nattreid/security
src/User.php
User.getUid
public function getUid(): string { $uid = $this->request->getCookie(self::TRACKING_COOKIE); if (empty($uid)) { $charList = 'a-f0-9'; $uid = Random::generate(8, $charList); $uid .= "-" . Random::generate(4, $charList); $uid .= "-5" . Random::generate(3, $charList); $uid .= "-" . Random::generate(4, $charList); $uid .= "-" . Random::generate(12, $charList); $this->response->setCookie(self::TRACKING_COOKIE, $uid, self::TRACKING_EXPIRE); } return $uid; }
php
public function getUid(): string { $uid = $this->request->getCookie(self::TRACKING_COOKIE); if (empty($uid)) { $charList = 'a-f0-9'; $uid = Random::generate(8, $charList); $uid .= "-" . Random::generate(4, $charList); $uid .= "-5" . Random::generate(3, $charList); $uid .= "-" . Random::generate(4, $charList); $uid .= "-" . Random::generate(12, $charList); $this->response->setCookie(self::TRACKING_COOKIE, $uid, self::TRACKING_EXPIRE); } return $uid; }
[ "public", "function", "getUid", "(", ")", ":", "string", "{", "$", "uid", "=", "$", "this", "->", "request", "->", "getCookie", "(", "self", "::", "TRACKING_COOKIE", ")", ";", "if", "(", "empty", "(", "$", "uid", ")", ")", "{", "$", "charList", "=", "'a-f0-9'", ";", "$", "uid", "=", "Random", "::", "generate", "(", "8", ",", "$", "charList", ")", ";", "$", "uid", ".=", "\"-\"", ".", "Random", "::", "generate", "(", "4", ",", "$", "charList", ")", ";", "$", "uid", ".=", "\"-5\"", ".", "Random", "::", "generate", "(", "3", ",", "$", "charList", ")", ";", "$", "uid", ".=", "\"-\"", ".", "Random", "::", "generate", "(", "4", ",", "$", "charList", ")", ";", "$", "uid", ".=", "\"-\"", ".", "Random", "::", "generate", "(", "12", ",", "$", "charList", ")", ";", "$", "this", "->", "response", "->", "setCookie", "(", "self", "::", "TRACKING_COOKIE", ",", "$", "uid", ",", "self", "::", "TRACKING_EXPIRE", ")", ";", "}", "return", "$", "uid", ";", "}" ]
Vrati uzivatelske uid @return string
[ "Vrati", "uzivatelske", "uid" ]
ed649e5bdf453cea2d5352e643dbf201193de01d
https://github.com/nattreid/security/blob/ed649e5bdf453cea2d5352e643dbf201193de01d/src/User.php#L184-L198
3,339
Hexmedia/Content-Bundle
Entity/Gallery.php
Gallery.addMedia
public function addMedia(Media $media) { $this->media[] = $media; $media->addGallery($this); return $this; }
php
public function addMedia(Media $media) { $this->media[] = $media; $media->addGallery($this); return $this; }
[ "public", "function", "addMedia", "(", "Media", "$", "media", ")", "{", "$", "this", "->", "media", "[", "]", "=", "$", "media", ";", "$", "media", "->", "addGallery", "(", "$", "this", ")", ";", "return", "$", "this", ";", "}" ]
Add media to gallery @param Media $media @return Gallery
[ "Add", "media", "to", "gallery" ]
04d2d61bec0051e8553b4abc7299d9f7e10aae82
https://github.com/Hexmedia/Content-Bundle/blob/04d2d61bec0051e8553b4abc7299d9f7e10aae82/Entity/Gallery.php#L201-L207
3,340
puli/asset-plugin
src/Api/Installer/InstallerDescriptor.php
InstallerDescriptor.match
public function match(Expression $expr) { return $expr->evaluate(array( self::NAME => $this->name, self::CLASS_NAME => $this->className, self::DESCRIPTION => $this->description, )); }
php
public function match(Expression $expr) { return $expr->evaluate(array( self::NAME => $this->name, self::CLASS_NAME => $this->className, self::DESCRIPTION => $this->description, )); }
[ "public", "function", "match", "(", "Expression", "$", "expr", ")", "{", "return", "$", "expr", "->", "evaluate", "(", "array", "(", "self", "::", "NAME", "=>", "$", "this", "->", "name", ",", "self", "::", "CLASS_NAME", "=>", "$", "this", "->", "className", ",", "self", "::", "DESCRIPTION", "=>", "$", "this", "->", "description", ",", ")", ")", ";", "}" ]
Returns whether the installer matches the given expression. @param Expression $expr The search criteria. You can use the fields {@link NAME}, {@link CLASS_NAME} and {@link DESCRIPTION} in the expression. @return bool Returns `true` if the installer matches the expression and `false` otherwise.
[ "Returns", "whether", "the", "installer", "matches", "the", "given", "expression", "." ]
f36c4a403a2173aced54376690a399884cde2627
https://github.com/puli/asset-plugin/blob/f36c4a403a2173aced54376690a399884cde2627/src/Api/Installer/InstallerDescriptor.php#L271-L278
3,341
flavorzyb/simple
src/Database/Db.php
Db.createPdo
protected function createPdo(array $config) { $dsn = $this->getHostDsn($config); $userName = (isset($config['username']) ? $config['username'] : null); $password = (isset($config['password']) ? $config['password'] : null); $options = $this->getPdoOptions($config); return new PDO($dsn, $userName, $password, $options); }
php
protected function createPdo(array $config) { $dsn = $this->getHostDsn($config); $userName = (isset($config['username']) ? $config['username'] : null); $password = (isset($config['password']) ? $config['password'] : null); $options = $this->getPdoOptions($config); return new PDO($dsn, $userName, $password, $options); }
[ "protected", "function", "createPdo", "(", "array", "$", "config", ")", "{", "$", "dsn", "=", "$", "this", "->", "getHostDsn", "(", "$", "config", ")", ";", "$", "userName", "=", "(", "isset", "(", "$", "config", "[", "'username'", "]", ")", "?", "$", "config", "[", "'username'", "]", ":", "null", ")", ";", "$", "password", "=", "(", "isset", "(", "$", "config", "[", "'password'", "]", ")", "?", "$", "config", "[", "'password'", "]", ":", "null", ")", ";", "$", "options", "=", "$", "this", "->", "getPdoOptions", "(", "$", "config", ")", ";", "return", "new", "PDO", "(", "$", "dsn", ",", "$", "userName", ",", "$", "password", ",", "$", "options", ")", ";", "}" ]
create a pdo instance @param array $config @return PDO @throws \PDOException
[ "create", "a", "pdo", "instance" ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Database/Db.php#L169-L177
3,342
flavorzyb/simple
src/Database/Db.php
Db.initOptions
protected function initOptions(PDO $pdo) { // set time zone if (isset($this->config['timezone'])) { $pdo->prepare('set time_zone="' . $this->config['timezone'] . '"')->execute(); } //set charset if (isset($this->config['charset'])) { $pdo->prepare('set names "' . $this->config['charset'] . '"')->execute(); } // set strict mode if (isset($this->config['strict']) && $this->config['strict']) { $pdo->prepare("set session sql_mode='STRICT_ALL_TABLES'")->execute(); } return $pdo; }
php
protected function initOptions(PDO $pdo) { // set time zone if (isset($this->config['timezone'])) { $pdo->prepare('set time_zone="' . $this->config['timezone'] . '"')->execute(); } //set charset if (isset($this->config['charset'])) { $pdo->prepare('set names "' . $this->config['charset'] . '"')->execute(); } // set strict mode if (isset($this->config['strict']) && $this->config['strict']) { $pdo->prepare("set session sql_mode='STRICT_ALL_TABLES'")->execute(); } return $pdo; }
[ "protected", "function", "initOptions", "(", "PDO", "$", "pdo", ")", "{", "// set time zone", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'timezone'", "]", ")", ")", "{", "$", "pdo", "->", "prepare", "(", "'set time_zone=\"'", ".", "$", "this", "->", "config", "[", "'timezone'", "]", ".", "'\"'", ")", "->", "execute", "(", ")", ";", "}", "//set charset", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'charset'", "]", ")", ")", "{", "$", "pdo", "->", "prepare", "(", "'set names \"'", ".", "$", "this", "->", "config", "[", "'charset'", "]", ".", "'\"'", ")", "->", "execute", "(", ")", ";", "}", "// set strict mode", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'strict'", "]", ")", "&&", "$", "this", "->", "config", "[", "'strict'", "]", ")", "{", "$", "pdo", "->", "prepare", "(", "\"set session sql_mode='STRICT_ALL_TABLES'\"", ")", "->", "execute", "(", ")", ";", "}", "return", "$", "pdo", ";", "}" ]
init pdo connection options after instance @param PDO $pdo @return PDO
[ "init", "pdo", "connection", "options", "after", "instance" ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Database/Db.php#L184-L205
3,343
flavorzyb/simple
src/Database/Db.php
Db.getPdo
public function getPdo($name) { if (!isset($this->connections[$name])) { $name = $this->defaultPdoName; } if (isset($this->pdoArray[$name])) { return $this->pdoArray[$name]; } $pdo = $this->createPdo($this->connections[$name]); $this->pdoArray[$name] = $this->initOptions($pdo); return $this->pdoArray[$name]; }
php
public function getPdo($name) { if (!isset($this->connections[$name])) { $name = $this->defaultPdoName; } if (isset($this->pdoArray[$name])) { return $this->pdoArray[$name]; } $pdo = $this->createPdo($this->connections[$name]); $this->pdoArray[$name] = $this->initOptions($pdo); return $this->pdoArray[$name]; }
[ "public", "function", "getPdo", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "connections", "[", "$", "name", "]", ")", ")", "{", "$", "name", "=", "$", "this", "->", "defaultPdoName", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "pdoArray", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "pdoArray", "[", "$", "name", "]", ";", "}", "$", "pdo", "=", "$", "this", "->", "createPdo", "(", "$", "this", "->", "connections", "[", "$", "name", "]", ")", ";", "$", "this", "->", "pdoArray", "[", "$", "name", "]", "=", "$", "this", "->", "initOptions", "(", "$", "pdo", ")", ";", "return", "$", "this", "->", "pdoArray", "[", "$", "name", "]", ";", "}" ]
get pdo connection by name @param string $name @return PDO @throws DbException
[ "get", "pdo", "connection", "by", "name" ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Database/Db.php#L214-L227
3,344
flavorzyb/simple
src/Database/Db.php
Db.usePdo
public function usePdo($name) { if (!isset($this->connections[$name])) { $name = $this->defaultPdoName; } $pdo = $this->getPdo($name); $this->setActivePdo($pdo); }
php
public function usePdo($name) { if (!isset($this->connections[$name])) { $name = $this->defaultPdoName; } $pdo = $this->getPdo($name); $this->setActivePdo($pdo); }
[ "public", "function", "usePdo", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "connections", "[", "$", "name", "]", ")", ")", "{", "$", "name", "=", "$", "this", "->", "defaultPdoName", ";", "}", "$", "pdo", "=", "$", "this", "->", "getPdo", "(", "$", "name", ")", ";", "$", "this", "->", "setActivePdo", "(", "$", "pdo", ")", ";", "}" ]
use pdo connection by name @param string $name @throws DbException
[ "use", "pdo", "connection", "by", "name" ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Database/Db.php#L265-L273
3,345
flavorzyb/simple
src/Database/Db.php
Db.disconnect
public function disconnect($name) { if (isset($this->pdoArray[$name])) { $pdo = $this->pdoArray[$name]; if ($this->activePdo == $pdo) { $this->activePdo = null; } unset($this->pdoArray[$name]); } }
php
public function disconnect($name) { if (isset($this->pdoArray[$name])) { $pdo = $this->pdoArray[$name]; if ($this->activePdo == $pdo) { $this->activePdo = null; } unset($this->pdoArray[$name]); } }
[ "public", "function", "disconnect", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "pdoArray", "[", "$", "name", "]", ")", ")", "{", "$", "pdo", "=", "$", "this", "->", "pdoArray", "[", "$", "name", "]", ";", "if", "(", "$", "this", "->", "activePdo", "==", "$", "pdo", ")", "{", "$", "this", "->", "activePdo", "=", "null", ";", "}", "unset", "(", "$", "this", "->", "pdoArray", "[", "$", "name", "]", ")", ";", "}", "}" ]
disconnect pdo by name @param string $name @throws DbException
[ "disconnect", "pdo", "by", "name" ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Database/Db.php#L290-L300
3,346
flavorzyb/simple
src/Database/Db.php
Db.reconnect
public function reconnect($name) { if (isset($this->connections[$name])) { $this->disconnect($name); $this->usePdo($name); } }
php
public function reconnect($name) { if (isset($this->connections[$name])) { $this->disconnect($name); $this->usePdo($name); } }
[ "public", "function", "reconnect", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "connections", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "disconnect", "(", "$", "name", ")", ";", "$", "this", "->", "usePdo", "(", "$", "name", ")", ";", "}", "}" ]
reconnect pdo by name @param string $name @throws DbException
[ "reconnect", "pdo", "by", "name" ]
8c4c539ae2057217b2637fc72c2a90ba266e8e6c
https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Database/Db.php#L308-L314
3,347
PSchwisow/phergie-irc-plugin-react-altnick
src/Plugin.php
Plugin.handleEvent
public function handleEvent(Event $event, Queue $queue) { $iterator = $this->getIterator($event->getConnection()); if (!$iterator->valid()) { $queue->ircQuit('All specified alternate nicks are in use'); return; } if ($this->recovery && $this->primaryNick === null) { $params = $event->getParams(); $primaryNick = $params[1]; $this->logger->debug("[AltNick] Saving '$primaryNick' as primary nick"); $this->primaryNick = $primaryNick; } $nick = $iterator->current(); $iterator->next(); $this->logger->debug("[AltNick] Switching nick to '$nick'"); $queue->ircNick($nick); }
php
public function handleEvent(Event $event, Queue $queue) { $iterator = $this->getIterator($event->getConnection()); if (!$iterator->valid()) { $queue->ircQuit('All specified alternate nicks are in use'); return; } if ($this->recovery && $this->primaryNick === null) { $params = $event->getParams(); $primaryNick = $params[1]; $this->logger->debug("[AltNick] Saving '$primaryNick' as primary nick"); $this->primaryNick = $primaryNick; } $nick = $iterator->current(); $iterator->next(); $this->logger->debug("[AltNick] Switching nick to '$nick'"); $queue->ircNick($nick); }
[ "public", "function", "handleEvent", "(", "Event", "$", "event", ",", "Queue", "$", "queue", ")", "{", "$", "iterator", "=", "$", "this", "->", "getIterator", "(", "$", "event", "->", "getConnection", "(", ")", ")", ";", "if", "(", "!", "$", "iterator", "->", "valid", "(", ")", ")", "{", "$", "queue", "->", "ircQuit", "(", "'All specified alternate nicks are in use'", ")", ";", "return", ";", "}", "if", "(", "$", "this", "->", "recovery", "&&", "$", "this", "->", "primaryNick", "===", "null", ")", "{", "$", "params", "=", "$", "event", "->", "getParams", "(", ")", ";", "$", "primaryNick", "=", "$", "params", "[", "1", "]", ";", "$", "this", "->", "logger", "->", "debug", "(", "\"[AltNick] Saving '$primaryNick' as primary nick\"", ")", ";", "$", "this", "->", "primaryNick", "=", "$", "primaryNick", ";", "}", "$", "nick", "=", "$", "iterator", "->", "current", "(", ")", ";", "$", "iterator", "->", "next", "(", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "\"[AltNick] Switching nick to '$nick'\"", ")", ";", "$", "queue", "->", "ircNick", "(", "$", "nick", ")", ";", "}" ]
Nick is in use, pick another. @param \Phergie\Irc\Event\EventInterface $event @param \Phergie\Irc\Bot\React\EventQueueInterface $queue
[ "Nick", "is", "in", "use", "pick", "another", "." ]
112b692cbbf9242450cc8caf073f6c021db29fba
https://github.com/PSchwisow/phergie-irc-plugin-react-altnick/blob/112b692cbbf9242450cc8caf073f6c021db29fba/src/Plugin.php#L134-L155
3,348
PSchwisow/phergie-irc-plugin-react-altnick
src/Plugin.php
Plugin.handleQuit
public function handleQuit(UserEvent $event, Queue $queue) { $nick = $event->getNick(); if ($this->primaryNick !== null && $nick == $this->primaryNick) { $this->logger->debug("[AltNick] '$nick' disconnected, switching to primary nick"); $queue->ircNick($this->primaryNick); $this->primaryNick = null; } }
php
public function handleQuit(UserEvent $event, Queue $queue) { $nick = $event->getNick(); if ($this->primaryNick !== null && $nick == $this->primaryNick) { $this->logger->debug("[AltNick] '$nick' disconnected, switching to primary nick"); $queue->ircNick($this->primaryNick); $this->primaryNick = null; } }
[ "public", "function", "handleQuit", "(", "UserEvent", "$", "event", ",", "Queue", "$", "queue", ")", "{", "$", "nick", "=", "$", "event", "->", "getNick", "(", ")", ";", "if", "(", "$", "this", "->", "primaryNick", "!==", "null", "&&", "$", "nick", "==", "$", "this", "->", "primaryNick", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "\"[AltNick] '$nick' disconnected, switching to primary nick\"", ")", ";", "$", "queue", "->", "ircNick", "(", "$", "this", "->", "primaryNick", ")", ";", "$", "this", "->", "primaryNick", "=", "null", ";", "}", "}" ]
Handle primary nick recovery. @param \Phergie\Irc\Event\UserEventInterface $event @param \Phergie\Irc\Bot\React\EventQueueInterface $queue
[ "Handle", "primary", "nick", "recovery", "." ]
112b692cbbf9242450cc8caf073f6c021db29fba
https://github.com/PSchwisow/phergie-irc-plugin-react-altnick/blob/112b692cbbf9242450cc8caf073f6c021db29fba/src/Plugin.php#L163-L171
3,349
Kylob/Pagination
src/Component.php
Component.set
public function set($page = 'page', $limit = 10, $url = null) { if (is_null($url)) { $url = $this->page->url(); } $params = $this->page->url('params', $url); $this->get = $page; $this->url = $url; $this->offset = 0; $this->limit = $limit; $this->total = 1; $this->current = 1; if (isset($params[$page])) { $page = array_map('intval', explode('of', $params[$page])); if (($current = array_shift($page)) && $current > 1) { // not the first page $this->current = $current; $this->offset = ($current - 1) * $this->limit; if (($total = array_shift($page)) && $current < $total) { // and not the last page $this->total = $total; return true; } } } return false; }
php
public function set($page = 'page', $limit = 10, $url = null) { if (is_null($url)) { $url = $this->page->url(); } $params = $this->page->url('params', $url); $this->get = $page; $this->url = $url; $this->offset = 0; $this->limit = $limit; $this->total = 1; $this->current = 1; if (isset($params[$page])) { $page = array_map('intval', explode('of', $params[$page])); if (($current = array_shift($page)) && $current > 1) { // not the first page $this->current = $current; $this->offset = ($current - 1) * $this->limit; if (($total = array_shift($page)) && $current < $total) { // and not the last page $this->total = $total; return true; } } } return false; }
[ "public", "function", "set", "(", "$", "page", "=", "'page'", ",", "$", "limit", "=", "10", ",", "$", "url", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "url", ")", ")", "{", "$", "url", "=", "$", "this", "->", "page", "->", "url", "(", ")", ";", "}", "$", "params", "=", "$", "this", "->", "page", "->", "url", "(", "'params'", ",", "$", "url", ")", ";", "$", "this", "->", "get", "=", "$", "page", ";", "$", "this", "->", "url", "=", "$", "url", ";", "$", "this", "->", "offset", "=", "0", ";", "$", "this", "->", "limit", "=", "$", "limit", ";", "$", "this", "->", "total", "=", "1", ";", "$", "this", "->", "current", "=", "1", ";", "if", "(", "isset", "(", "$", "params", "[", "$", "page", "]", ")", ")", "{", "$", "page", "=", "array_map", "(", "'intval'", ",", "explode", "(", "'of'", ",", "$", "params", "[", "$", "page", "]", ")", ")", ";", "if", "(", "(", "$", "current", "=", "array_shift", "(", "$", "page", ")", ")", "&&", "$", "current", ">", "1", ")", "{", "// not the first page", "$", "this", "->", "current", "=", "$", "current", ";", "$", "this", "->", "offset", "=", "(", "$", "current", "-", "1", ")", "*", "$", "this", "->", "limit", ";", "if", "(", "(", "$", "total", "=", "array_shift", "(", "$", "page", ")", ")", "&&", "$", "current", "<", "$", "total", ")", "{", "// and not the last page", "$", "this", "->", "total", "=", "$", "total", ";", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Check if we need a total count. There's no sense in querying the database if you don't have to. Plus, you have to call this anyways to set things up. @param string $page The url query parameter that pertains these records. @param int $limit How many records to return at a time. @param string $url The url to use. The default is the current url. @return bool @example ```php if (!$pagination->set()) { $pagination->total(100); } ```
[ "Check", "if", "we", "need", "a", "total", "count", ".", "There", "s", "no", "sense", "in", "querying", "the", "database", "if", "you", "don", "t", "have", "to", ".", "Plus", "you", "have", "to", "call", "this", "anyways", "to", "set", "things", "up", "." ]
83b89566e36d3cf147518e93615ffefa17c7e30e
https://github.com/Kylob/Pagination/blob/83b89566e36d3cf147518e93615ffefa17c7e30e/src/Component.php#L147-L173
3,350
Kylob/Pagination
src/Component.php
Component.html
public function html($type = 'bootstrap', array $options = array()) { if ($type == 'links' && !empty($this->links)) { $this->links = array_merge($this->links, $options); } elseif ($type == 'pager' && !empty($this->pager)) { $this->pager = array_merge($this->pager, $options); } else { // http://getbootstrap.com/components/#pagination $this->links = array( 'wrapper' => '<ul class="pagination">{{ value }}</ul>', 'link' => '<li><a href="{{ url }}">{{ value }}</a></li>', 'active' => '<li class="active"><span>{{ value }}</span></li>', 'disabled' => '<li class="disabled"><span>{{ value }}</span></li>', 'previous' => '&laquo;', 'next' => '&raquo;', 'dots' => '&hellip;', ); $this->pager = array( 'wrapper' => '<ul class="pager">{{ value }}</ul>', 'previous' => '<li class="previous"><a href="{{ url }}">&laquo; {{ value }}</a></li>', 'next' => '<li class="next"><a href="{{ url }}">{{ value }} &raquo;</a></li>', ); switch ($type) { case 'zurb_foundation': // http://foundation.zurb.com/docs/components/pagination.html $this->html('links', array( 'active' => '<li class="current"><a href="">{{ value }}</a></li>', 'disabled' => '<li class="unavailable"><a href="">{{ value }}</a></li>', )); break; case 'semantic_ui': // http://semantic-ui.com/collections/menu.html#pagination $this->html('links', array( 'wrapper' => '<div class="ui pagination menu">{{ value }}</div>', 'link' => '<a class="item" href="{{ url }}">{{ value }}</a>', 'active' => '<div class="active item">{{ value }}</div>', 'disabled' => '<div class="disabled item">{{ value }}</div>', 'previous' => '<i class="left arrow icon"></i>', 'next' => '<i class="right arrow icon"></i>', )); break; case 'materialize': // http://materializecss.com/pagination.html $this->html('links', array( 'link' => '<li class="waves-effect"><a href="{{ url }}">{{ value }}</a></li>', 'active' => '<li class="active"><a href="#!">{{ value }}</a></li>', 'disabled' => '<li class="disabled"><a href="#!">{{ value }}</a></li>', 'previous' => '<i class="material-icons">keyboard_arrow_left</i>', 'next' => '<i class="material-icons">keyboard_arrow_right</i>', )); break; case 'uikit': // http://getuikit.com/docs/pagination.html $this->html('links', array( 'wrapper' => '<ul class="uk-pagination">{{ value }}</ul>', 'active' => '<li class="uk-active"><span>{{ value }}</span></li>', 'disabled' => '<li class="uk-disabled"><span>{{ value }}</span></li>', 'previous' => '<i class="uk-icon-angle-double-left"></i>', 'next' => '<i class="uk-icon-angle-double-right"></i>', )); $this->html('pager', array( 'wrapper' => '<ul class="uk-pagination">{{ value }}</ul>', 'previous' => '<li class="uk-pagination-previous"><a href="{{ url }}"><i class="uk-icon-angle-double-left"></i> {{ value }}</a></li>', 'next' => '<li class="uk-pagination-next"><a href="{{ url }}">{{ value }} <i class="uk-icon-angle-double-right"></i></a></li>', )); break; } } }
php
public function html($type = 'bootstrap', array $options = array()) { if ($type == 'links' && !empty($this->links)) { $this->links = array_merge($this->links, $options); } elseif ($type == 'pager' && !empty($this->pager)) { $this->pager = array_merge($this->pager, $options); } else { // http://getbootstrap.com/components/#pagination $this->links = array( 'wrapper' => '<ul class="pagination">{{ value }}</ul>', 'link' => '<li><a href="{{ url }}">{{ value }}</a></li>', 'active' => '<li class="active"><span>{{ value }}</span></li>', 'disabled' => '<li class="disabled"><span>{{ value }}</span></li>', 'previous' => '&laquo;', 'next' => '&raquo;', 'dots' => '&hellip;', ); $this->pager = array( 'wrapper' => '<ul class="pager">{{ value }}</ul>', 'previous' => '<li class="previous"><a href="{{ url }}">&laquo; {{ value }}</a></li>', 'next' => '<li class="next"><a href="{{ url }}">{{ value }} &raquo;</a></li>', ); switch ($type) { case 'zurb_foundation': // http://foundation.zurb.com/docs/components/pagination.html $this->html('links', array( 'active' => '<li class="current"><a href="">{{ value }}</a></li>', 'disabled' => '<li class="unavailable"><a href="">{{ value }}</a></li>', )); break; case 'semantic_ui': // http://semantic-ui.com/collections/menu.html#pagination $this->html('links', array( 'wrapper' => '<div class="ui pagination menu">{{ value }}</div>', 'link' => '<a class="item" href="{{ url }}">{{ value }}</a>', 'active' => '<div class="active item">{{ value }}</div>', 'disabled' => '<div class="disabled item">{{ value }}</div>', 'previous' => '<i class="left arrow icon"></i>', 'next' => '<i class="right arrow icon"></i>', )); break; case 'materialize': // http://materializecss.com/pagination.html $this->html('links', array( 'link' => '<li class="waves-effect"><a href="{{ url }}">{{ value }}</a></li>', 'active' => '<li class="active"><a href="#!">{{ value }}</a></li>', 'disabled' => '<li class="disabled"><a href="#!">{{ value }}</a></li>', 'previous' => '<i class="material-icons">keyboard_arrow_left</i>', 'next' => '<i class="material-icons">keyboard_arrow_right</i>', )); break; case 'uikit': // http://getuikit.com/docs/pagination.html $this->html('links', array( 'wrapper' => '<ul class="uk-pagination">{{ value }}</ul>', 'active' => '<li class="uk-active"><span>{{ value }}</span></li>', 'disabled' => '<li class="uk-disabled"><span>{{ value }}</span></li>', 'previous' => '<i class="uk-icon-angle-double-left"></i>', 'next' => '<i class="uk-icon-angle-double-right"></i>', )); $this->html('pager', array( 'wrapper' => '<ul class="uk-pagination">{{ value }}</ul>', 'previous' => '<li class="uk-pagination-previous"><a href="{{ url }}"><i class="uk-icon-angle-double-left"></i> {{ value }}</a></li>', 'next' => '<li class="uk-pagination-next"><a href="{{ url }}">{{ value }} <i class="uk-icon-angle-double-right"></i></a></li>', )); break; } } }
[ "public", "function", "html", "(", "$", "type", "=", "'bootstrap'", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "type", "==", "'links'", "&&", "!", "empty", "(", "$", "this", "->", "links", ")", ")", "{", "$", "this", "->", "links", "=", "array_merge", "(", "$", "this", "->", "links", ",", "$", "options", ")", ";", "}", "elseif", "(", "$", "type", "==", "'pager'", "&&", "!", "empty", "(", "$", "this", "->", "pager", ")", ")", "{", "$", "this", "->", "pager", "=", "array_merge", "(", "$", "this", "->", "pager", ",", "$", "options", ")", ";", "}", "else", "{", "// http://getbootstrap.com/components/#pagination", "$", "this", "->", "links", "=", "array", "(", "'wrapper'", "=>", "'<ul class=\"pagination\">{{ value }}</ul>'", ",", "'link'", "=>", "'<li><a href=\"{{ url }}\">{{ value }}</a></li>'", ",", "'active'", "=>", "'<li class=\"active\"><span>{{ value }}</span></li>'", ",", "'disabled'", "=>", "'<li class=\"disabled\"><span>{{ value }}</span></li>'", ",", "'previous'", "=>", "'&laquo;'", ",", "'next'", "=>", "'&raquo;'", ",", "'dots'", "=>", "'&hellip;'", ",", ")", ";", "$", "this", "->", "pager", "=", "array", "(", "'wrapper'", "=>", "'<ul class=\"pager\">{{ value }}</ul>'", ",", "'previous'", "=>", "'<li class=\"previous\"><a href=\"{{ url }}\">&laquo; {{ value }}</a></li>'", ",", "'next'", "=>", "'<li class=\"next\"><a href=\"{{ url }}\">{{ value }} &raquo;</a></li>'", ",", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'zurb_foundation'", ":", "// http://foundation.zurb.com/docs/components/pagination.html", "$", "this", "->", "html", "(", "'links'", ",", "array", "(", "'active'", "=>", "'<li class=\"current\"><a href=\"\">{{ value }}</a></li>'", ",", "'disabled'", "=>", "'<li class=\"unavailable\"><a href=\"\">{{ value }}</a></li>'", ",", ")", ")", ";", "break", ";", "case", "'semantic_ui'", ":", "// http://semantic-ui.com/collections/menu.html#pagination", "$", "this", "->", "html", "(", "'links'", ",", "array", "(", "'wrapper'", "=>", "'<div class=\"ui pagination menu\">{{ value }}</div>'", ",", "'link'", "=>", "'<a class=\"item\" href=\"{{ url }}\">{{ value }}</a>'", ",", "'active'", "=>", "'<div class=\"active item\">{{ value }}</div>'", ",", "'disabled'", "=>", "'<div class=\"disabled item\">{{ value }}</div>'", ",", "'previous'", "=>", "'<i class=\"left arrow icon\"></i>'", ",", "'next'", "=>", "'<i class=\"right arrow icon\"></i>'", ",", ")", ")", ";", "break", ";", "case", "'materialize'", ":", "// http://materializecss.com/pagination.html", "$", "this", "->", "html", "(", "'links'", ",", "array", "(", "'link'", "=>", "'<li class=\"waves-effect\"><a href=\"{{ url }}\">{{ value }}</a></li>'", ",", "'active'", "=>", "'<li class=\"active\"><a href=\"#!\">{{ value }}</a></li>'", ",", "'disabled'", "=>", "'<li class=\"disabled\"><a href=\"#!\">{{ value }}</a></li>'", ",", "'previous'", "=>", "'<i class=\"material-icons\">keyboard_arrow_left</i>'", ",", "'next'", "=>", "'<i class=\"material-icons\">keyboard_arrow_right</i>'", ",", ")", ")", ";", "break", ";", "case", "'uikit'", ":", "// http://getuikit.com/docs/pagination.html", "$", "this", "->", "html", "(", "'links'", ",", "array", "(", "'wrapper'", "=>", "'<ul class=\"uk-pagination\">{{ value }}</ul>'", ",", "'active'", "=>", "'<li class=\"uk-active\"><span>{{ value }}</span></li>'", ",", "'disabled'", "=>", "'<li class=\"uk-disabled\"><span>{{ value }}</span></li>'", ",", "'previous'", "=>", "'<i class=\"uk-icon-angle-double-left\"></i>'", ",", "'next'", "=>", "'<i class=\"uk-icon-angle-double-right\"></i>'", ",", ")", ")", ";", "$", "this", "->", "html", "(", "'pager'", ",", "array", "(", "'wrapper'", "=>", "'<ul class=\"uk-pagination\">{{ value }}</ul>'", ",", "'previous'", "=>", "'<li class=\"uk-pagination-previous\"><a href=\"{{ url }}\"><i class=\"uk-icon-angle-double-left\"></i> {{ value }}</a></li>'", ",", "'next'", "=>", "'<li class=\"uk-pagination-next\"><a href=\"{{ url }}\">{{ value }} <i class=\"uk-icon-angle-double-right\"></i></a></li>'", ",", ")", ")", ";", "break", ";", "}", "}", "}" ]
Customize the pagination and pager links. @param string $type Either the CSS framework you want to use ('[**bootstrap**](http://getbootstrap.com/components/#pagination)', '[**zurb_foundation**](http://foundation.zurb.com/docs/components/pagination.html)', '[**semantic_ui**](http://semantic-ui.com/collections/menu.html#pagination)', '[**materialize**](http://materializecss.com/pagination.html)', '[**uikit**](http://getuikit.com/docs/pagination.html)'), or what you want to override (the pagination '**links**', or '**pager**' html). @param array $options The values you want to override. The default (bootstrap) values are: - If ``$type == 'links'`` - '**wrapper**' => ``'<ul class="pagination">{{ value }}</ul>'``, - '**link**' => ``'<li><a href="{{ url }}">{{ value }}</a></li>'``, - '**active**' => ``'<li class="active"><span>{{ value }}</span></li>'``, - '**disabled**' => ``'<li class="disabled"><span>{{ value }}</span></li>'``, - '**previous**' => ``'&laquo;'``, // Setting to ``null`` will remove this entirely - '**next**' => ``'&raquo;'``, // Setting to ``null`` will remove this entirely - '**dots**' => ``'&hellip;'``, // Setting to ``null`` will remove this entirely - If ``$type == 'pager'`` - '**wrapper**' => ``'<ul class="pager">{{ value }}</ul>'``, - '**previous**' => ``'<li class="previous"><a href="{{ url }}">&laquo; {{ value }}</a></li>'``, - '**next**' => ``'<li class="next"><a href="{{ url }}">{{ value }} &raquo;</a></li>'``, Put '**{{ value }}**' and '**{{ url }}**' where you want those to go. If you set anything to ``null``, then only the '**{{ value }}**' will be returned. @example ```php $pagination->html('links', array( 'wrapper' => '<ul class="pagination pagination-sm">{{ value }}</ul>', )); ```
[ "Customize", "the", "pagination", "and", "pager", "links", "." ]
83b89566e36d3cf147518e93615ffefa17c7e30e
https://github.com/Kylob/Pagination/blob/83b89566e36d3cf147518e93615ffefa17c7e30e/src/Component.php#L216-L280
3,351
tekreme73/FrametekLight
src/Http/Cookie.php
Cookie.setWithExpire
public function setWithExpire($key, $value, $expire) { if (setcookie($key, $value, time() + $expire, '/', '', false, true)) { return true; } return false; }
php
public function setWithExpire($key, $value, $expire) { if (setcookie($key, $value, time() + $expire, '/', '', false, true)) { return true; } return false; }
[ "public", "function", "setWithExpire", "(", "$", "key", ",", "$", "value", ",", "$", "expire", ")", "{", "if", "(", "setcookie", "(", "$", "key", ",", "$", "value", ",", "time", "(", ")", "+", "$", "expire", ",", "'/'", ",", "''", ",", "false", ",", "true", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Set cookie item with expire @param string $key The cookie key @param mixed $value The cookie value @param integer $expire The cookie $expire @return boolean Fail if an output has be done before this method call
[ "Set", "cookie", "item", "with", "expire" ]
7a40e8dd14490488d80741d6a6fe5d9c2bcc7bd5
https://github.com/tekreme73/FrametekLight/blob/7a40e8dd14490488d80741d6a6fe5d9c2bcc7bd5/src/Http/Cookie.php#L57-L63
3,352
helthe/Segmentio
Templating/Helper.php
Helper.init
public function init() { $render = $this->asyncScript(); $render .= $this->load($this->client->getWriteKey()); return $render; }
php
public function init() { $render = $this->asyncScript(); $render .= $this->load($this->client->getWriteKey()); return $render; }
[ "public", "function", "init", "(", ")", "{", "$", "render", "=", "$", "this", "->", "asyncScript", "(", ")", ";", "$", "render", ".=", "$", "this", "->", "load", "(", "$", "this", "->", "client", "->", "getWriteKey", "(", ")", ")", ";", "return", "$", "render", ";", "}" ]
Renders all the code necessary for initializing analytics.js. @return string
[ "Renders", "all", "the", "code", "necessary", "for", "initializing", "analytics", ".", "js", "." ]
40a97cf9780404bf0a48ad4621cc994ca66e9128
https://github.com/helthe/Segmentio/blob/40a97cf9780404bf0a48ad4621cc994ca66e9128/Templating/Helper.php#L90-L96
3,353
helthe/Segmentio
Templating/Helper.php
Helper.page
public function page($name = null, $category = null, array $properties = array()) { return $this->renderer->renderPage($name, $category, $properties); }
php
public function page($name = null, $category = null, array $properties = array()) { return $this->renderer->renderPage($name, $category, $properties); }
[ "public", "function", "page", "(", "$", "name", "=", "null", ",", "$", "category", "=", "null", ",", "array", "$", "properties", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "renderer", "->", "renderPage", "(", "$", "name", ",", "$", "category", ",", "$", "properties", ")", ";", "}" ]
Renders the page method. @param string $name @param string $category @param array $properties @return string
[ "Renders", "the", "page", "method", "." ]
40a97cf9780404bf0a48ad4621cc994ca66e9128
https://github.com/helthe/Segmentio/blob/40a97cf9780404bf0a48ad4621cc994ca66e9128/Templating/Helper.php#L119-L122
3,354
xinc-develop/xinc-getopt
src/CommandLineParser.php
CommandLineParser.addOption
private function addOption($string, $value) { foreach ($this->optionList as $option) { if ($option->matches($string)) { if ($option->mode() == Getopt::IS_FLAG) { if (is_null($value)) { $value = isset($this->options[$string]) ? !$this->options[$string]->getValue() : ($option->getArgument()->hasDefaultValue() ? !$option->getArgument()->getDefaultValue() : true); } } else { if ($option->mode() == Getopt::REQUIRED_ARGUMENT && !mb_strlen($value)) { throw new \UnexpectedValueException("Option '$string' must have a value"); } if ($option->getArgument()->hasValidation()) { if ((mb_strlen($value) > 0) && !$option->getArgument()->validates($value)) { throw new \UnexpectedValueException("Option '$string' has an invalid value"); } } // for no-argument options, check if they are duplicate if ($option->mode() == Getopt::NO_ARGUMENT) { $oldValue = isset($this->options[$string]) ? $this->options[$string]->getValue() : null; $value = is_null($oldValue) ? 1 : $oldValue + 1; } // for optional-argument options, set value to 1 if none was given $value = (mb_strlen($value) > 0) ? $value : 1; } // add both long and short names (if they exist) to the option array to facilitate lookup if ($option->short()) { $this->options[$option->short()] = new Value($value); } if ($option->long()) { $this->options[$option->long()] = new Value($value); } return; } } throw new \UnexpectedValueException("Option '$string' is unknown"); }
php
private function addOption($string, $value) { foreach ($this->optionList as $option) { if ($option->matches($string)) { if ($option->mode() == Getopt::IS_FLAG) { if (is_null($value)) { $value = isset($this->options[$string]) ? !$this->options[$string]->getValue() : ($option->getArgument()->hasDefaultValue() ? !$option->getArgument()->getDefaultValue() : true); } } else { if ($option->mode() == Getopt::REQUIRED_ARGUMENT && !mb_strlen($value)) { throw new \UnexpectedValueException("Option '$string' must have a value"); } if ($option->getArgument()->hasValidation()) { if ((mb_strlen($value) > 0) && !$option->getArgument()->validates($value)) { throw new \UnexpectedValueException("Option '$string' has an invalid value"); } } // for no-argument options, check if they are duplicate if ($option->mode() == Getopt::NO_ARGUMENT) { $oldValue = isset($this->options[$string]) ? $this->options[$string]->getValue() : null; $value = is_null($oldValue) ? 1 : $oldValue + 1; } // for optional-argument options, set value to 1 if none was given $value = (mb_strlen($value) > 0) ? $value : 1; } // add both long and short names (if they exist) to the option array to facilitate lookup if ($option->short()) { $this->options[$option->short()] = new Value($value); } if ($option->long()) { $this->options[$option->long()] = new Value($value); } return; } } throw new \UnexpectedValueException("Option '$string' is unknown"); }
[ "private", "function", "addOption", "(", "$", "string", ",", "$", "value", ")", "{", "foreach", "(", "$", "this", "->", "optionList", "as", "$", "option", ")", "{", "if", "(", "$", "option", "->", "matches", "(", "$", "string", ")", ")", "{", "if", "(", "$", "option", "->", "mode", "(", ")", "==", "Getopt", "::", "IS_FLAG", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "value", "=", "isset", "(", "$", "this", "->", "options", "[", "$", "string", "]", ")", "?", "!", "$", "this", "->", "options", "[", "$", "string", "]", "->", "getValue", "(", ")", ":", "(", "$", "option", "->", "getArgument", "(", ")", "->", "hasDefaultValue", "(", ")", "?", "!", "$", "option", "->", "getArgument", "(", ")", "->", "getDefaultValue", "(", ")", ":", "true", ")", ";", "}", "}", "else", "{", "if", "(", "$", "option", "->", "mode", "(", ")", "==", "Getopt", "::", "REQUIRED_ARGUMENT", "&&", "!", "mb_strlen", "(", "$", "value", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Option '$string' must have a value\"", ")", ";", "}", "if", "(", "$", "option", "->", "getArgument", "(", ")", "->", "hasValidation", "(", ")", ")", "{", "if", "(", "(", "mb_strlen", "(", "$", "value", ")", ">", "0", ")", "&&", "!", "$", "option", "->", "getArgument", "(", ")", "->", "validates", "(", "$", "value", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Option '$string' has an invalid value\"", ")", ";", "}", "}", "// for no-argument options, check if they are duplicate", "if", "(", "$", "option", "->", "mode", "(", ")", "==", "Getopt", "::", "NO_ARGUMENT", ")", "{", "$", "oldValue", "=", "isset", "(", "$", "this", "->", "options", "[", "$", "string", "]", ")", "?", "$", "this", "->", "options", "[", "$", "string", "]", "->", "getValue", "(", ")", ":", "null", ";", "$", "value", "=", "is_null", "(", "$", "oldValue", ")", "?", "1", ":", "$", "oldValue", "+", "1", ";", "}", "// for optional-argument options, set value to 1 if none was given", "$", "value", "=", "(", "mb_strlen", "(", "$", "value", ")", ">", "0", ")", "?", "$", "value", ":", "1", ";", "}", "// add both long and short names (if they exist) to the option array to facilitate lookup", "if", "(", "$", "option", "->", "short", "(", ")", ")", "{", "$", "this", "->", "options", "[", "$", "option", "->", "short", "(", ")", "]", "=", "new", "Value", "(", "$", "value", ")", ";", "}", "if", "(", "$", "option", "->", "long", "(", ")", ")", "{", "$", "this", "->", "options", "[", "$", "option", "->", "long", "(", ")", "]", "=", "new", "Value", "(", "$", "value", ")", ";", "}", "return", ";", "}", "}", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Option '$string' is unknown\"", ")", ";", "}" ]
Add an option to the list of known options. @param string $string the option's name @param string $value the option's value (or null) @throws \UnexpectedValueException
[ "Add", "an", "option", "to", "the", "list", "of", "known", "options", "." ]
f6ba394d83a020e76187d08184849bd930b04a4e
https://github.com/xinc-develop/xinc-getopt/blob/f6ba394d83a020e76187d08184849bd930b04a4e/src/CommandLineParser.php#L175-L216
3,355
xinc-develop/xinc-getopt
src/CommandLineParser.php
CommandLineParser.addDefaultValues
private function addDefaultValues() { foreach ($this->optionList as $option) { if ($option->getArgument()->hasDefaultValue() && !isset($this->options[$option->short()]) && !isset($this->options[$option->long()]) ) { if ($option->short()) { $this->options[$option->short()] = new Value( $option->getArgument()->getDefaultValue(),true); } if ($option->long()) { $this->options[$option->long()] = new Value( $option->getArgument()->getDefaultValue(),true); } /* if ($option->short()) { $this->addOption($option->short(), $option->getArgument()->getDefaultValue()); } if ($option->long()) { $this->addOption($option->long(), $option->getArgument()->getDefaultValue()); } */ } } }
php
private function addDefaultValues() { foreach ($this->optionList as $option) { if ($option->getArgument()->hasDefaultValue() && !isset($this->options[$option->short()]) && !isset($this->options[$option->long()]) ) { if ($option->short()) { $this->options[$option->short()] = new Value( $option->getArgument()->getDefaultValue(),true); } if ($option->long()) { $this->options[$option->long()] = new Value( $option->getArgument()->getDefaultValue(),true); } /* if ($option->short()) { $this->addOption($option->short(), $option->getArgument()->getDefaultValue()); } if ($option->long()) { $this->addOption($option->long(), $option->getArgument()->getDefaultValue()); } */ } } }
[ "private", "function", "addDefaultValues", "(", ")", "{", "foreach", "(", "$", "this", "->", "optionList", "as", "$", "option", ")", "{", "if", "(", "$", "option", "->", "getArgument", "(", ")", "->", "hasDefaultValue", "(", ")", "&&", "!", "isset", "(", "$", "this", "->", "options", "[", "$", "option", "->", "short", "(", ")", "]", ")", "&&", "!", "isset", "(", "$", "this", "->", "options", "[", "$", "option", "->", "long", "(", ")", "]", ")", ")", "{", "if", "(", "$", "option", "->", "short", "(", ")", ")", "{", "$", "this", "->", "options", "[", "$", "option", "->", "short", "(", ")", "]", "=", "new", "Value", "(", "$", "option", "->", "getArgument", "(", ")", "->", "getDefaultValue", "(", ")", ",", "true", ")", ";", "}", "if", "(", "$", "option", "->", "long", "(", ")", ")", "{", "$", "this", "->", "options", "[", "$", "option", "->", "long", "(", ")", "]", "=", "new", "Value", "(", "$", "option", "->", "getArgument", "(", ")", "->", "getDefaultValue", "(", ")", ",", "true", ")", ";", "}", "/*\n if ($option->short()) {\n $this->addOption($option->short(), $option->getArgument()->getDefaultValue());\n }\n if ($option->long()) {\n $this->addOption($option->long(), $option->getArgument()->getDefaultValue());\n }\n*/", "}", "}", "}" ]
If there are options with default values that were not overridden by the parsed option string, add them to the list of known options.
[ "If", "there", "are", "options", "with", "default", "values", "that", "were", "not", "overridden", "by", "the", "parsed", "option", "string", "add", "them", "to", "the", "list", "of", "known", "options", "." ]
f6ba394d83a020e76187d08184849bd930b04a4e
https://github.com/xinc-develop/xinc-getopt/blob/f6ba394d83a020e76187d08184849bd930b04a4e/src/CommandLineParser.php#L222-L247
3,356
phPoirot/Module-Authorization
src/Authorization/Actions/AuthenticatorAction.php
AuthenticatorAction.authenticator
function authenticator($authenticatorName = self::AUTHENTICATOR_DEFAULT) { if (!$this->authenticators->has($authenticatorName)) throw new \Exception(sprintf('Authenticator (%s) Not Registered.', $authenticatorName)); $authenticator = $this->authenticators->get($authenticatorName); return $authenticator; }
php
function authenticator($authenticatorName = self::AUTHENTICATOR_DEFAULT) { if (!$this->authenticators->has($authenticatorName)) throw new \Exception(sprintf('Authenticator (%s) Not Registered.', $authenticatorName)); $authenticator = $this->authenticators->get($authenticatorName); return $authenticator; }
[ "function", "authenticator", "(", "$", "authenticatorName", "=", "self", "::", "AUTHENTICATOR_DEFAULT", ")", "{", "if", "(", "!", "$", "this", "->", "authenticators", "->", "has", "(", "$", "authenticatorName", ")", ")", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Authenticator (%s) Not Registered.'", ",", "$", "authenticatorName", ")", ")", ";", "$", "authenticator", "=", "$", "this", "->", "authenticators", "->", "get", "(", "$", "authenticatorName", ")", ";", "return", "$", "authenticator", ";", "}" ]
Retrieve Registered Authenticator Service By Name @param string $authenticatorName @return iAuthenticator|Authenticator @throws \Exception
[ "Retrieve", "Registered", "Authenticator", "Service", "By", "Name" ]
1adcb85d01bb7cfaa6cc6b0cbcb9907ef4778e06
https://github.com/phPoirot/Module-Authorization/blob/1adcb85d01bb7cfaa6cc6b0cbcb9907ef4778e06/src/Authorization/Actions/AuthenticatorAction.php#L60-L67
3,357
phPoirot/Module-Authorization
src/Authorization/Actions/AuthenticatorAction.php
AuthenticatorAction.guard
function guard($authorizeOfGuardName) { if (! $this->guards->has($authorizeOfGuardName) ) throw new \Exception(sprintf('Guard Authorization (%s) Not Registered.', $authorizeOfGuardName)); $guard = $this->guards->get($authorizeOfGuardName); return $guard; }
php
function guard($authorizeOfGuardName) { if (! $this->guards->has($authorizeOfGuardName) ) throw new \Exception(sprintf('Guard Authorization (%s) Not Registered.', $authorizeOfGuardName)); $guard = $this->guards->get($authorizeOfGuardName); return $guard; }
[ "function", "guard", "(", "$", "authorizeOfGuardName", ")", "{", "if", "(", "!", "$", "this", "->", "guards", "->", "has", "(", "$", "authorizeOfGuardName", ")", ")", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Guard Authorization (%s) Not Registered.'", ",", "$", "authorizeOfGuardName", ")", ")", ";", "$", "guard", "=", "$", "this", "->", "guards", "->", "get", "(", "$", "authorizeOfGuardName", ")", ";", "return", "$", "guard", ";", "}" ]
Retrieve Authorization Guard @param string $authorizeOfGuardName @return iGuard @throws \Exception
[ "Retrieve", "Authorization", "Guard" ]
1adcb85d01bb7cfaa6cc6b0cbcb9907ef4778e06
https://github.com/phPoirot/Module-Authorization/blob/1adcb85d01bb7cfaa6cc6b0cbcb9907ef4778e06/src/Authorization/Actions/AuthenticatorAction.php#L87-L94
3,358
roygoldman/composer-installers-discovery
src/Installer.php
Installer.templatePath
protected function templatePath($path, array $path_vars = []) { if (strpos($path, '{') !== false) { extract($path_vars); preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches); if (!empty($matches[1])) { foreach ($matches[1] as $var) { $path = str_replace('{$' . $var . '}', $$var, $path); } } } return $path; }
php
protected function templatePath($path, array $path_vars = []) { if (strpos($path, '{') !== false) { extract($path_vars); preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches); if (!empty($matches[1])) { foreach ($matches[1] as $var) { $path = str_replace('{$' . $var . '}', $$var, $path); } } } return $path; }
[ "protected", "function", "templatePath", "(", "$", "path", ",", "array", "$", "path_vars", "=", "[", "]", ")", "{", "if", "(", "strpos", "(", "$", "path", ",", "'{'", ")", "!==", "false", ")", "{", "extract", "(", "$", "path_vars", ")", ";", "preg_match_all", "(", "'@\\{\\$([A-Za-z0-9_]*)\\}@i'", ",", "$", "path", ",", "$", "matches", ")", ";", "if", "(", "!", "empty", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "foreach", "(", "$", "matches", "[", "1", "]", "as", "$", "var", ")", "{", "$", "path", "=", "str_replace", "(", "'{$'", ".", "$", "var", ".", "'}'", ",", "$", "$", "var", ",", "$", "path", ")", ";", "}", "}", "}", "return", "$", "path", ";", "}" ]
Replace variables in a path @param string $path @param array $path_vars @return string
[ "Replace", "variables", "in", "a", "path" ]
c5cd1acf067ae0843a511fd9af114b837f9784af
https://github.com/roygoldman/composer-installers-discovery/blob/c5cd1acf067ae0843a511fd9af114b837f9784af/src/Installer.php#L87-L99
3,359
roygoldman/composer-installers-discovery
src/Installer.php
Installer.discoverInstallers
protected function discoverInstallers() { $repo_manager = $this->composer->getRepositoryManager(); $package = $this->composer->getPackage(); return $this->discoverPackageInstallers($package, $repo_manager); }
php
protected function discoverInstallers() { $repo_manager = $this->composer->getRepositoryManager(); $package = $this->composer->getPackage(); return $this->discoverPackageInstallers($package, $repo_manager); }
[ "protected", "function", "discoverInstallers", "(", ")", "{", "$", "repo_manager", "=", "$", "this", "->", "composer", "->", "getRepositoryManager", "(", ")", ";", "$", "package", "=", "$", "this", "->", "composer", "->", "getPackage", "(", ")", ";", "return", "$", "this", "->", "discoverPackageInstallers", "(", "$", "package", ",", "$", "repo_manager", ")", ";", "}" ]
Helper function to scan for installer definitions in dependencies. @param string $dir Installation directory of the project's composer.json. @return array Installer mappings keyed by type, with paths as values.
[ "Helper", "function", "to", "scan", "for", "installer", "definitions", "in", "dependencies", "." ]
c5cd1acf067ae0843a511fd9af114b837f9784af
https://github.com/roygoldman/composer-installers-discovery/blob/c5cd1acf067ae0843a511fd9af114b837f9784af/src/Installer.php#L131-L137
3,360
roygoldman/composer-installers-discovery
src/Installer.php
Installer.discoverPackageInstallers
protected function discoverPackageInstallers(PackageInterface $package, RepositoryManager $repo_manager) { $package_name = $package->getName(); if (!isset($this->packageInstallers[$package_name])) { // Initialize the package cache entry to prevent loops. $this->packageInstallers[$package_name] = []; $installer_paths = &$this->packageInstallers[$package_name]; // Calculate the installer paths for this package. $package_extra = $package->getExtra(); if (isset($package_extra) && isset($package_extra['installer-paths'])) { foreach ($package_extra['installer-paths'] as $path => $values) { foreach ($values as $value) { $type = explode(':', $value, 2); if (count($type) >= 2 && $type[0] === 'type') { $installer_paths[$type[1]] = $path; } } } } $requires = $package->getRequires(); foreach ($requires as $requirement) { if (static::isSystemRequirement($requirement)) { continue; } $required_package = $repo_manager->findPackage($requirement->getTarget(), $requirement->getConstraint()); if ($required_package) { $installer_paths += $this->discoverPackageInstallers($required_package, $repo_manager); } } } return $this->packageInstallers[$package_name]; }
php
protected function discoverPackageInstallers(PackageInterface $package, RepositoryManager $repo_manager) { $package_name = $package->getName(); if (!isset($this->packageInstallers[$package_name])) { // Initialize the package cache entry to prevent loops. $this->packageInstallers[$package_name] = []; $installer_paths = &$this->packageInstallers[$package_name]; // Calculate the installer paths for this package. $package_extra = $package->getExtra(); if (isset($package_extra) && isset($package_extra['installer-paths'])) { foreach ($package_extra['installer-paths'] as $path => $values) { foreach ($values as $value) { $type = explode(':', $value, 2); if (count($type) >= 2 && $type[0] === 'type') { $installer_paths[$type[1]] = $path; } } } } $requires = $package->getRequires(); foreach ($requires as $requirement) { if (static::isSystemRequirement($requirement)) { continue; } $required_package = $repo_manager->findPackage($requirement->getTarget(), $requirement->getConstraint()); if ($required_package) { $installer_paths += $this->discoverPackageInstallers($required_package, $repo_manager); } } } return $this->packageInstallers[$package_name]; }
[ "protected", "function", "discoverPackageInstallers", "(", "PackageInterface", "$", "package", ",", "RepositoryManager", "$", "repo_manager", ")", "{", "$", "package_name", "=", "$", "package", "->", "getName", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "packageInstallers", "[", "$", "package_name", "]", ")", ")", "{", "// Initialize the package cache entry to prevent loops.", "$", "this", "->", "packageInstallers", "[", "$", "package_name", "]", "=", "[", "]", ";", "$", "installer_paths", "=", "&", "$", "this", "->", "packageInstallers", "[", "$", "package_name", "]", ";", "// Calculate the installer paths for this package.", "$", "package_extra", "=", "$", "package", "->", "getExtra", "(", ")", ";", "if", "(", "isset", "(", "$", "package_extra", ")", "&&", "isset", "(", "$", "package_extra", "[", "'installer-paths'", "]", ")", ")", "{", "foreach", "(", "$", "package_extra", "[", "'installer-paths'", "]", "as", "$", "path", "=>", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "type", "=", "explode", "(", "':'", ",", "$", "value", ",", "2", ")", ";", "if", "(", "count", "(", "$", "type", ")", ">=", "2", "&&", "$", "type", "[", "0", "]", "===", "'type'", ")", "{", "$", "installer_paths", "[", "$", "type", "[", "1", "]", "]", "=", "$", "path", ";", "}", "}", "}", "}", "$", "requires", "=", "$", "package", "->", "getRequires", "(", ")", ";", "foreach", "(", "$", "requires", "as", "$", "requirement", ")", "{", "if", "(", "static", "::", "isSystemRequirement", "(", "$", "requirement", ")", ")", "{", "continue", ";", "}", "$", "required_package", "=", "$", "repo_manager", "->", "findPackage", "(", "$", "requirement", "->", "getTarget", "(", ")", ",", "$", "requirement", "->", "getConstraint", "(", ")", ")", ";", "if", "(", "$", "required_package", ")", "{", "$", "installer_paths", "+=", "$", "this", "->", "discoverPackageInstallers", "(", "$", "required_package", ",", "$", "repo_manager", ")", ";", "}", "}", "}", "return", "$", "this", "->", "packageInstallers", "[", "$", "package_name", "]", ";", "}" ]
Recursively discover available installer paths in installers. @param \Composer\Package\PackageInterface $package Package to discover tree starting from. @param \Composer\Repository\RepositoryManager $repo_manager Local Package repository. @return array Installer mappings keyed by type, with paths as values.
[ "Recursively", "discover", "available", "installer", "paths", "in", "installers", "." ]
c5cd1acf067ae0843a511fd9af114b837f9784af
https://github.com/roygoldman/composer-installers-discovery/blob/c5cd1acf067ae0843a511fd9af114b837f9784af/src/Installer.php#L150-L184
3,361
roygoldman/composer-installers-discovery
src/Installer.php
Installer.isSystemRequirement
public static function isSystemRequirement(Link $requirement) { $package_name = $requirement->getTarget(); if (strpos($package_name, '/') === FALSE) { return TRUE; } return FALSE; }
php
public static function isSystemRequirement(Link $requirement) { $package_name = $requirement->getTarget(); if (strpos($package_name, '/') === FALSE) { return TRUE; } return FALSE; }
[ "public", "static", "function", "isSystemRequirement", "(", "Link", "$", "requirement", ")", "{", "$", "package_name", "=", "$", "requirement", "->", "getTarget", "(", ")", ";", "if", "(", "strpos", "(", "$", "package_name", ",", "'/'", ")", "===", "FALSE", ")", "{", "return", "TRUE", ";", "}", "return", "FALSE", ";", "}" ]
Checks if the required package doesn't have a vendor. Packages without vendor definitions should only ever be php or a php extension. @param \Composer\Package\Link $requirement Required package reference. @return bool True if the package is a php or an extension. False otherwise.
[ "Checks", "if", "the", "required", "package", "doesn", "t", "have", "a", "vendor", "." ]
c5cd1acf067ae0843a511fd9af114b837f9784af
https://github.com/roygoldman/composer-installers-discovery/blob/c5cd1acf067ae0843a511fd9af114b837f9784af/src/Installer.php#L198-L205
3,362
gibboncms/gibbon
src/Filesystems/FlyFilesystem.php
FlyFilesystem.listFiles
public function listFiles($directory = null, $recursive = false) { return $this->flysystem->listFiles($directory, $recursive); }
php
public function listFiles($directory = null, $recursive = false) { return $this->flysystem->listFiles($directory, $recursive); }
[ "public", "function", "listFiles", "(", "$", "directory", "=", "null", ",", "$", "recursive", "=", "false", ")", "{", "return", "$", "this", "->", "flysystem", "->", "listFiles", "(", "$", "directory", ",", "$", "recursive", ")", ";", "}" ]
List all the files from a directory @param string $directory @param bool $recursive @return array
[ "List", "all", "the", "files", "from", "a", "directory" ]
2905e90b2902149b3358b385264e98b97cf4fc00
https://github.com/gibboncms/gibbon/blob/2905e90b2902149b3358b385264e98b97cf4fc00/src/Filesystems/FlyFilesystem.php#L23-L26
3,363
hschulz/php-http
src/HeaderCollection.php
HeaderCollection.addHeader
public function addHeader(string $name, string $value): bool { /* Initialize the return value */ $isSet = false; /* If the given parameters aren't empty */ if (!empty($name) && !empty($value)) { /* Assign the values */ $this->offsetSet($name, $value); $isSet = true; } return $isSet; }
php
public function addHeader(string $name, string $value): bool { /* Initialize the return value */ $isSet = false; /* If the given parameters aren't empty */ if (!empty($name) && !empty($value)) { /* Assign the values */ $this->offsetSet($name, $value); $isSet = true; } return $isSet; }
[ "public", "function", "addHeader", "(", "string", "$", "name", ",", "string", "$", "value", ")", ":", "bool", "{", "/* Initialize the return value */", "$", "isSet", "=", "false", ";", "/* If the given parameters aren't empty */", "if", "(", "!", "empty", "(", "$", "name", ")", "&&", "!", "empty", "(", "$", "value", ")", ")", "{", "/* Assign the values */", "$", "this", "->", "offsetSet", "(", "$", "name", ",", "$", "value", ")", ";", "$", "isSet", "=", "true", ";", "}", "return", "$", "isSet", ";", "}" ]
Adds a new Header. If the header already exists it is overwritten. @param string $name @param string $value @return bool
[ "Adds", "a", "new", "Header", ".", "If", "the", "header", "already", "exists", "it", "is", "overwritten", "." ]
12ae2e60eadd5088700954aa088d72a9725d502c
https://github.com/hschulz/php-http/blob/12ae2e60eadd5088700954aa088d72a9725d502c/src/HeaderCollection.php#L41-L56
3,364
zugoripls/laravel-framework
src/Illuminate/Routing/ControllerDispatcher.php
ControllerDispatcher.methodExcludedByOptions
public function methodExcludedByOptions($method, array $options) { return ( ! empty($options['only']) && ! in_array($method, (array) $options['only'])) || ( ! empty($options['except']) && in_array($method, (array) $options['except'])); }
php
public function methodExcludedByOptions($method, array $options) { return ( ! empty($options['only']) && ! in_array($method, (array) $options['only'])) || ( ! empty($options['except']) && in_array($method, (array) $options['except'])); }
[ "public", "function", "methodExcludedByOptions", "(", "$", "method", ",", "array", "$", "options", ")", "{", "return", "(", "!", "empty", "(", "$", "options", "[", "'only'", "]", ")", "&&", "!", "in_array", "(", "$", "method", ",", "(", "array", ")", "$", "options", "[", "'only'", "]", ")", ")", "||", "(", "!", "empty", "(", "$", "options", "[", "'except'", "]", ")", "&&", "in_array", "(", "$", "method", ",", "(", "array", ")", "$", "options", "[", "'except'", "]", ")", ")", ";", "}" ]
Determine if the given options exclude a particular method. @param string $method @param array $options @return bool
[ "Determine", "if", "the", "given", "options", "exclude", "a", "particular", "method", "." ]
90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655
https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Routing/ControllerDispatcher.php#L142-L146
3,365
zugoripls/laravel-framework
src/Illuminate/Routing/ControllerDispatcher.php
ControllerDispatcher.filterFailsOn
protected function filterFailsOn($filter, $request, $method) { $on = array_get($filter, 'options.on'); if (is_null($on)) return false; // If the "on" is a string, we will explode it on the pipe so you can set any // amount of methods on the filter constraints and it will still work like // you specified an array. Then we will check if the method is in array. if (is_string($on)) $on = explode('|', $on); return ! in_array(strtolower($request->getMethod()), $on); }
php
protected function filterFailsOn($filter, $request, $method) { $on = array_get($filter, 'options.on'); if (is_null($on)) return false; // If the "on" is a string, we will explode it on the pipe so you can set any // amount of methods on the filter constraints and it will still work like // you specified an array. Then we will check if the method is in array. if (is_string($on)) $on = explode('|', $on); return ! in_array(strtolower($request->getMethod()), $on); }
[ "protected", "function", "filterFailsOn", "(", "$", "filter", ",", "$", "request", ",", "$", "method", ")", "{", "$", "on", "=", "array_get", "(", "$", "filter", ",", "'options.on'", ")", ";", "if", "(", "is_null", "(", "$", "on", ")", ")", "return", "false", ";", "// If the \"on\" is a string, we will explode it on the pipe so you can set any", "// amount of methods on the filter constraints and it will still work like", "// you specified an array. Then we will check if the method is in array.", "if", "(", "is_string", "(", "$", "on", ")", ")", "$", "on", "=", "explode", "(", "'|'", ",", "$", "on", ")", ";", "return", "!", "in_array", "(", "strtolower", "(", "$", "request", "->", "getMethod", "(", ")", ")", ",", "$", "on", ")", ";", "}" ]
Determine if the filter fails the "on" constraint. @param array $filter @param \Illuminate\Http\Request $request @param string $method @return bool
[ "Determine", "if", "the", "filter", "fails", "the", "on", "constraint", "." ]
90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655
https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Routing/ControllerDispatcher.php#L268-L280
3,366
ghiencode/util
Text.php
Text.uniqueId
public static function uniqueId(): string { $rand = random_bytes(16); $rand[6] = chr(ord($rand[6]) & 0x0f | 0x40); $rand[8] = chr(ord($rand[8]) & 0x3f | 0x80); $rand = str_split(bin2hex($rand), 4); return vsprintf('%s%s%s%s%s', array_map(function ($hex) { return base_convert($hex, 16, 32); }, [$rand[0] . $rand[1], $rand[2], $rand[3], $rand[4], $rand[5] . $rand[6] . $rand[7]])); }
php
public static function uniqueId(): string { $rand = random_bytes(16); $rand[6] = chr(ord($rand[6]) & 0x0f | 0x40); $rand[8] = chr(ord($rand[8]) & 0x3f | 0x80); $rand = str_split(bin2hex($rand), 4); return vsprintf('%s%s%s%s%s', array_map(function ($hex) { return base_convert($hex, 16, 32); }, [$rand[0] . $rand[1], $rand[2], $rand[3], $rand[4], $rand[5] . $rand[6] . $rand[7]])); }
[ "public", "static", "function", "uniqueId", "(", ")", ":", "string", "{", "$", "rand", "=", "random_bytes", "(", "16", ")", ";", "$", "rand", "[", "6", "]", "=", "chr", "(", "ord", "(", "$", "rand", "[", "6", "]", ")", "&", "0x0f", "|", "0x40", ")", ";", "$", "rand", "[", "8", "]", "=", "chr", "(", "ord", "(", "$", "rand", "[", "8", "]", ")", "&", "0x3f", "|", "0x80", ")", ";", "$", "rand", "=", "str_split", "(", "bin2hex", "(", "$", "rand", ")", ",", "4", ")", ";", "return", "vsprintf", "(", "'%s%s%s%s%s'", ",", "array_map", "(", "function", "(", "$", "hex", ")", "{", "return", "base_convert", "(", "$", "hex", ",", "16", ",", "32", ")", ";", "}", ",", "[", "$", "rand", "[", "0", "]", ".", "$", "rand", "[", "1", "]", ",", "$", "rand", "[", "2", "]", ",", "$", "rand", "[", "3", "]", ",", "$", "rand", "[", "4", "]", ",", "$", "rand", "[", "5", "]", ".", "$", "rand", "[", "6", "]", ".", "$", "rand", "[", "7", "]", "]", ")", ")", ";", "}" ]
Follow uuid v4 generation standard but remove dash and encode in base 32 Guarantee 128 bits of entropy but use ~ 20% less space compare to base 16 @see https://stackoverflow.com/a/15875555 @see https://connect2id.com/blog/how-to-generate-human-friendly-identifiers
[ "Follow", "uuid", "v4", "generation", "standard", "but", "remove", "dash", "and", "encode", "in", "base", "32", "Guarantee", "128", "bits", "of", "entropy", "but", "use", "~", "20%", "less", "space", "compare", "to", "base", "16" ]
c27ead3cde04cc682055318a0836862aa7cd9d35
https://github.com/ghiencode/util/blob/c27ead3cde04cc682055318a0836862aa7cd9d35/Text.php#L87-L97
3,367
traceguide/api-php
lib/Traceguide.php
Traceguide.initialize
public static function initialize($group_name, $access_token, $opts = null) { if (!is_string($group_name) || strlen($group_name) == 0) { throw new Exception("Invalid group_name"); } if (!is_string($access_token) || strlen($access_token) == 0) { throw new Exception("Invalid access_token"); } // If the singleton has already been created, treat the initialization // as an options() call instead. if (isset(self::$_singleton)) { if (!isset($opts)) { $opts = array(); } self::$_singleton->options(array_merge($opts, array( 'group_name' => $group_name, 'access_token' => $access_token, ))); } else { self::$_singleton = self::newRuntime($group_name, $access_token, $opts); } return self::$_singleton; }
php
public static function initialize($group_name, $access_token, $opts = null) { if (!is_string($group_name) || strlen($group_name) == 0) { throw new Exception("Invalid group_name"); } if (!is_string($access_token) || strlen($access_token) == 0) { throw new Exception("Invalid access_token"); } // If the singleton has already been created, treat the initialization // as an options() call instead. if (isset(self::$_singleton)) { if (!isset($opts)) { $opts = array(); } self::$_singleton->options(array_merge($opts, array( 'group_name' => $group_name, 'access_token' => $access_token, ))); } else { self::$_singleton = self::newRuntime($group_name, $access_token, $opts); } return self::$_singleton; }
[ "public", "static", "function", "initialize", "(", "$", "group_name", ",", "$", "access_token", ",", "$", "opts", "=", "null", ")", "{", "if", "(", "!", "is_string", "(", "$", "group_name", ")", "||", "strlen", "(", "$", "group_name", ")", "==", "0", ")", "{", "throw", "new", "Exception", "(", "\"Invalid group_name\"", ")", ";", "}", "if", "(", "!", "is_string", "(", "$", "access_token", ")", "||", "strlen", "(", "$", "access_token", ")", "==", "0", ")", "{", "throw", "new", "Exception", "(", "\"Invalid access_token\"", ")", ";", "}", "// If the singleton has already been created, treat the initialization", "// as an options() call instead.", "if", "(", "isset", "(", "self", "::", "$", "_singleton", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "opts", ")", ")", "{", "$", "opts", "=", "array", "(", ")", ";", "}", "self", "::", "$", "_singleton", "->", "options", "(", "array_merge", "(", "$", "opts", ",", "array", "(", "'group_name'", "=>", "$", "group_name", ",", "'access_token'", "=>", "$", "access_token", ",", ")", ")", ")", ";", "}", "else", "{", "self", "::", "$", "_singleton", "=", "self", "::", "newRuntime", "(", "$", "group_name", ",", "$", "access_token", ",", "$", "opts", ")", ";", "}", "return", "self", "::", "$", "_singleton", ";", "}" ]
Initializes and returns the singleton instance of the Runtime. For convenience, multiple calls to initialize are allowed. For example, in library code with more than possible first entry-point, this may be helpful. @return \TraceguideBase\Runtime @throws Exception if the group name or access token is not a valid string @throws Exception if the runtime singleton has already been initialized
[ "Initializes", "and", "returns", "the", "singleton", "instance", "of", "the", "Runtime", "." ]
05d7958732b0e82a7b33bf55db4ef1b1fc6a9136
https://github.com/traceguide/api-php/blob/05d7958732b0e82a7b33bf55db4ef1b1fc6a9136/lib/Traceguide.php#L25-L48
3,368
traceguide/api-php
lib/Traceguide.php
Traceguide.getInstance
public static function getInstance($group_name = NULL, $access_token = NULL, $opts = NULL) { if (!isset(self::$_singleton)) { self::$_singleton = self::newRuntime($group_name, $access_token, $opts); } return self::$_singleton; }
php
public static function getInstance($group_name = NULL, $access_token = NULL, $opts = NULL) { if (!isset(self::$_singleton)) { self::$_singleton = self::newRuntime($group_name, $access_token, $opts); } return self::$_singleton; }
[ "public", "static", "function", "getInstance", "(", "$", "group_name", "=", "NULL", ",", "$", "access_token", "=", "NULL", ",", "$", "opts", "=", "NULL", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "_singleton", ")", ")", "{", "self", "::", "$", "_singleton", "=", "self", "::", "newRuntime", "(", "$", "group_name", ",", "$", "access_token", ",", "$", "opts", ")", ";", "}", "return", "self", "::", "$", "_singleton", ";", "}" ]
Returns the singleton instance of the Runtime. For convenience, this function can be passed the $group_name and $access_token parameters to also initialize the runtime singleton. These values will be ignored on any calls after the first to getInstance(). @param $group_name Group name to use for the runtime @param $access_token The project access token @return \TraceguideBase\Runtime @throws Exception if the group name or access token is not a valid string
[ "Returns", "the", "singleton", "instance", "of", "the", "Runtime", "." ]
05d7958732b0e82a7b33bf55db4ef1b1fc6a9136
https://github.com/traceguide/api-php/blob/05d7958732b0e82a7b33bf55db4ef1b1fc6a9136/lib/Traceguide.php#L62-L67
3,369
traceguide/api-php
lib/Traceguide.php
Traceguide.newRuntime
public static function newRuntime ($group_name, $access_token, $opts = NULL) { if (is_null($opts)) { $opts = array(); } // It is valid to create and use the runtime before it is fully configured. // The only constraint is that it will not be able to flush data until the // configuration is complete. if ($group_name != NULL) { $opts['group_name'] = $group_name; } if ($group_name != NULL) { $opts['access_token'] = $access_token; } return new TraceguideBase\Client\ClientRuntime($opts); }
php
public static function newRuntime ($group_name, $access_token, $opts = NULL) { if (is_null($opts)) { $opts = array(); } // It is valid to create and use the runtime before it is fully configured. // The only constraint is that it will not be able to flush data until the // configuration is complete. if ($group_name != NULL) { $opts['group_name'] = $group_name; } if ($group_name != NULL) { $opts['access_token'] = $access_token; } return new TraceguideBase\Client\ClientRuntime($opts); }
[ "public", "static", "function", "newRuntime", "(", "$", "group_name", ",", "$", "access_token", ",", "$", "opts", "=", "NULL", ")", "{", "if", "(", "is_null", "(", "$", "opts", ")", ")", "{", "$", "opts", "=", "array", "(", ")", ";", "}", "// It is valid to create and use the runtime before it is fully configured.", "// The only constraint is that it will not be able to flush data until the", "// configuration is complete.", "if", "(", "$", "group_name", "!=", "NULL", ")", "{", "$", "opts", "[", "'group_name'", "]", "=", "$", "group_name", ";", "}", "if", "(", "$", "group_name", "!=", "NULL", ")", "{", "$", "opts", "[", "'access_token'", "]", "=", "$", "access_token", ";", "}", "return", "new", "TraceguideBase", "\\", "Client", "\\", "ClientRuntime", "(", "$", "opts", ")", ";", "}" ]
Creates a new runtime instance. @param $group_name Group name to use for the runtime @param $access_token The project access token @return \TraceguideBase\Runtime @throws Exception if the group name or access token is not a valid string.
[ "Creates", "a", "new", "runtime", "instance", "." ]
05d7958732b0e82a7b33bf55db4ef1b1fc6a9136
https://github.com/traceguide/api-php/blob/05d7958732b0e82a7b33bf55db4ef1b1fc6a9136/lib/Traceguide.php#L78-L93
3,370
hiqdev/composer-asset-plugin
src/Constraint.php
Constraint.merge
public static function merge($a, $b) { $acon = static::parse($a); $bcon = static::parse($b); if ($acon instanceof EmptyConstraint) { return $b; } elseif ($bcon instanceof EmptyConstraint) { return $a; } elseif ($acon->matches($bcon) || $bcon->matches($acon)) { return strlen($a) > strlen($b) ? $b : $a; } else { return $a . ' ' . $b; } }
php
public static function merge($a, $b) { $acon = static::parse($a); $bcon = static::parse($b); if ($acon instanceof EmptyConstraint) { return $b; } elseif ($bcon instanceof EmptyConstraint) { return $a; } elseif ($acon->matches($bcon) || $bcon->matches($acon)) { return strlen($a) > strlen($b) ? $b : $a; } else { return $a . ' ' . $b; } }
[ "public", "static", "function", "merge", "(", "$", "a", ",", "$", "b", ")", "{", "$", "acon", "=", "static", "::", "parse", "(", "$", "a", ")", ";", "$", "bcon", "=", "static", "::", "parse", "(", "$", "b", ")", ";", "if", "(", "$", "acon", "instanceof", "EmptyConstraint", ")", "{", "return", "$", "b", ";", "}", "elseif", "(", "$", "bcon", "instanceof", "EmptyConstraint", ")", "{", "return", "$", "a", ";", "}", "elseif", "(", "$", "acon", "->", "matches", "(", "$", "bcon", ")", "||", "$", "bcon", "->", "matches", "(", "$", "acon", ")", ")", "{", "return", "strlen", "(", "$", "a", ")", ">", "strlen", "(", "$", "b", ")", "?", "$", "b", ":", "$", "a", ";", "}", "else", "{", "return", "$", "a", ".", "' '", ".", "$", "b", ";", "}", "}" ]
Merges two constraints. Doesn't resolve version conflicts. @param string $a @param string $b @return string
[ "Merges", "two", "constraints", ".", "Doesn", "t", "resolve", "version", "conflicts", "." ]
cdc55b07612334705e802197a39f41a0adca204c
https://github.com/hiqdev/composer-asset-plugin/blob/cdc55b07612334705e802197a39f41a0adca204c/src/Constraint.php#L48-L62
3,371
edunola13/utils
helper/ApiRestHelper/JsonHelper.php
JsonHelper.array_fields
public function array_fields($array, array $fields){ $newArray= array(); foreach ($array as $value) { $newValue= array(); foreach ($fields as $key) { if(array_key_exists($key, $value)){ $newValue[$key]= $value[$key]; } } $newArray[]= $newValue; } return $newArray; }
php
public function array_fields($array, array $fields){ $newArray= array(); foreach ($array as $value) { $newValue= array(); foreach ($fields as $key) { if(array_key_exists($key, $value)){ $newValue[$key]= $value[$key]; } } $newArray[]= $newValue; } return $newArray; }
[ "public", "function", "array_fields", "(", "$", "array", ",", "array", "$", "fields", ")", "{", "$", "newArray", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "value", ")", "{", "$", "newValue", "=", "array", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "value", ")", ")", "{", "$", "newValue", "[", "$", "key", "]", "=", "$", "value", "[", "$", "key", "]", ";", "}", "}", "$", "newArray", "[", "]", "=", "$", "newValue", ";", "}", "return", "$", "newArray", ";", "}" ]
Retorna un array con los campos indicados @param array $array @param array $fields @return array
[ "Retorna", "un", "array", "con", "los", "campos", "indicados" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/helper/ApiRestHelper/JsonHelper.php#L18-L30
3,372
edunola13/utils
helper/ApiRestHelper/JsonHelper.php
JsonHelper.json_encode_data
public function json_encode_data($object, array $fields, $options = 0){ $array= $this->object_to_array($object, $fields); return json_encode($array, $options); }
php
public function json_encode_data($object, array $fields, $options = 0){ $array= $this->object_to_array($object, $fields); return json_encode($array, $options); }
[ "public", "function", "json_encode_data", "(", "$", "object", ",", "array", "$", "fields", ",", "$", "options", "=", "0", ")", "{", "$", "array", "=", "$", "this", "->", "object_to_array", "(", "$", "object", ",", "$", "fields", ")", ";", "return", "json_encode", "(", "$", "array", ",", "$", "options", ")", ";", "}" ]
Este realiza el pasaje de un objeto a json asegurando que el mismo no entre en loop. Para esto primero pasa el objeto a array en base a los campos que quiere mapear y despues lo pasa a json @param Object $object @param mixed $fields @param int $options @return string
[ "Este", "realiza", "el", "pasaje", "de", "un", "objeto", "a", "json", "asegurando", "que", "el", "mismo", "no", "entre", "en", "loop", ".", "Para", "esto", "primero", "pasa", "el", "objeto", "a", "array", "en", "base", "a", "los", "campos", "que", "quiere", "mapear", "y", "despues", "lo", "pasa", "a", "json" ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/helper/ApiRestHelper/JsonHelper.php#L82-L85
3,373
edunola13/utils
helper/ApiRestHelper/JsonHelper.php
JsonHelper.json_encode_recursion
public function json_encode_recursion($object, $recursionLevel = 1, $options = 0){ $objects= array(); $ocurrencias= array(); $array= array(); if(is_array($object)){ $array= $object; foreach ($array as &$var) { $var= $this->json_encode_recursion_internal($var, $recursionLevel, $options, $objects, $ocurrencias); } }else{ $array= $this->json_encode_recursion_internal($object, $recursionLevel, $options, $objects, $ocurrencias); } return json_encode($array, $options); }
php
public function json_encode_recursion($object, $recursionLevel = 1, $options = 0){ $objects= array(); $ocurrencias= array(); $array= array(); if(is_array($object)){ $array= $object; foreach ($array as &$var) { $var= $this->json_encode_recursion_internal($var, $recursionLevel, $options, $objects, $ocurrencias); } }else{ $array= $this->json_encode_recursion_internal($object, $recursionLevel, $options, $objects, $ocurrencias); } return json_encode($array, $options); }
[ "public", "function", "json_encode_recursion", "(", "$", "object", ",", "$", "recursionLevel", "=", "1", ",", "$", "options", "=", "0", ")", "{", "$", "objects", "=", "array", "(", ")", ";", "$", "ocurrencias", "=", "array", "(", ")", ";", "$", "array", "=", "array", "(", ")", ";", "if", "(", "is_array", "(", "$", "object", ")", ")", "{", "$", "array", "=", "$", "object", ";", "foreach", "(", "$", "array", "as", "&", "$", "var", ")", "{", "$", "var", "=", "$", "this", "->", "json_encode_recursion_internal", "(", "$", "var", ",", "$", "recursionLevel", ",", "$", "options", ",", "$", "objects", ",", "$", "ocurrencias", ")", ";", "}", "}", "else", "{", "$", "array", "=", "$", "this", "->", "json_encode_recursion_internal", "(", "$", "object", ",", "$", "recursionLevel", ",", "$", "options", ",", "$", "objects", ",", "$", "ocurrencias", ")", ";", "}", "return", "json_encode", "(", "$", "array", ",", "$", "options", ")", ";", "}" ]
Este metodo realiza el pasaje de un objeto Doctrine a json. Para esto indicamos el nivel de profundidad que se va a ingresar en el objeto y los objetos no cargados hasta el momento solo se mapearan su id. @param Object $object @param int $recursionLevel @param int $options @return strong
[ "Este", "metodo", "realiza", "el", "pasaje", "de", "un", "objeto", "Doctrine", "a", "json", ".", "Para", "esto", "indicamos", "el", "nivel", "de", "profundidad", "que", "se", "va", "a", "ingresar", "en", "el", "objeto", "y", "los", "objetos", "no", "cargados", "hasta", "el", "momento", "solo", "se", "mapearan", "su", "id", "." ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/helper/ApiRestHelper/JsonHelper.php#L95-L108
3,374
edunola13/utils
helper/ApiRestHelper/JsonHelper.php
JsonHelper.json_encode_recursion_internal
protected function json_encode_recursion_internal($object, $recursionLevel = 1, $options = 0, $objects, $ocurrencias){ $pos= array_search($object, $objects); $repeticiones= 1; if($pos !== FALSE){ $ocurrencias[$pos]++; $repeticiones= $ocurrencias[$pos]; }else{ $objects[]= $object; $ocurrencias[]= 1; } if($repeticiones > $recursionLevel){ return FALSE; }else{ if(method_exists($object, 'jsonSerialize')){ $vars= $object->jsonSerialize(); foreach ($vars as $key => &$var) { if(is_object($var)){ $rta= $this->json_encode_recursion_internal($var, $recursionLevel, $options, $objects, $ocurrencias); if($rta !== FALSE){ $var= $rta; }else{ unset($var); unset($vars[$key]); } }else if(is_array($var) || $var instanceof \Traversable){ foreach ($var as &$item) { $item= $this->json_encode_recursion_internal($item, $recursionLevel, $options, $objects, $ocurrencias); } //$var= json_encode_recursion_internal($var, $recursionLevel, $options, $objects, $ocurrencias); } } return $vars; }else{ return $object; } } }
php
protected function json_encode_recursion_internal($object, $recursionLevel = 1, $options = 0, $objects, $ocurrencias){ $pos= array_search($object, $objects); $repeticiones= 1; if($pos !== FALSE){ $ocurrencias[$pos]++; $repeticiones= $ocurrencias[$pos]; }else{ $objects[]= $object; $ocurrencias[]= 1; } if($repeticiones > $recursionLevel){ return FALSE; }else{ if(method_exists($object, 'jsonSerialize')){ $vars= $object->jsonSerialize(); foreach ($vars as $key => &$var) { if(is_object($var)){ $rta= $this->json_encode_recursion_internal($var, $recursionLevel, $options, $objects, $ocurrencias); if($rta !== FALSE){ $var= $rta; }else{ unset($var); unset($vars[$key]); } }else if(is_array($var) || $var instanceof \Traversable){ foreach ($var as &$item) { $item= $this->json_encode_recursion_internal($item, $recursionLevel, $options, $objects, $ocurrencias); } //$var= json_encode_recursion_internal($var, $recursionLevel, $options, $objects, $ocurrencias); } } return $vars; }else{ return $object; } } }
[ "protected", "function", "json_encode_recursion_internal", "(", "$", "object", ",", "$", "recursionLevel", "=", "1", ",", "$", "options", "=", "0", ",", "$", "objects", ",", "$", "ocurrencias", ")", "{", "$", "pos", "=", "array_search", "(", "$", "object", ",", "$", "objects", ")", ";", "$", "repeticiones", "=", "1", ";", "if", "(", "$", "pos", "!==", "FALSE", ")", "{", "$", "ocurrencias", "[", "$", "pos", "]", "++", ";", "$", "repeticiones", "=", "$", "ocurrencias", "[", "$", "pos", "]", ";", "}", "else", "{", "$", "objects", "[", "]", "=", "$", "object", ";", "$", "ocurrencias", "[", "]", "=", "1", ";", "}", "if", "(", "$", "repeticiones", ">", "$", "recursionLevel", ")", "{", "return", "FALSE", ";", "}", "else", "{", "if", "(", "method_exists", "(", "$", "object", ",", "'jsonSerialize'", ")", ")", "{", "$", "vars", "=", "$", "object", "->", "jsonSerialize", "(", ")", ";", "foreach", "(", "$", "vars", "as", "$", "key", "=>", "&", "$", "var", ")", "{", "if", "(", "is_object", "(", "$", "var", ")", ")", "{", "$", "rta", "=", "$", "this", "->", "json_encode_recursion_internal", "(", "$", "var", ",", "$", "recursionLevel", ",", "$", "options", ",", "$", "objects", ",", "$", "ocurrencias", ")", ";", "if", "(", "$", "rta", "!==", "FALSE", ")", "{", "$", "var", "=", "$", "rta", ";", "}", "else", "{", "unset", "(", "$", "var", ")", ";", "unset", "(", "$", "vars", "[", "$", "key", "]", ")", ";", "}", "}", "else", "if", "(", "is_array", "(", "$", "var", ")", "||", "$", "var", "instanceof", "\\", "Traversable", ")", "{", "foreach", "(", "$", "var", "as", "&", "$", "item", ")", "{", "$", "item", "=", "$", "this", "->", "json_encode_recursion_internal", "(", "$", "item", ",", "$", "recursionLevel", ",", "$", "options", ",", "$", "objects", ",", "$", "ocurrencias", ")", ";", "}", "//$var= json_encode_recursion_internal($var, $recursionLevel, $options, $objects, $ocurrencias);", "}", "}", "return", "$", "vars", ";", "}", "else", "{", "return", "$", "object", ";", "}", "}", "}" ]
Este metodo es privado y realiza el pasaje de un objeto Doctrine a json. Para esto indicamos el nivel de profundidad que se va a ingresar en el objeto y los objetos no cargados hasta el momento solo se mapearan su id. @param Object $object @param int $recursionLevel @param int $options @param mixed $objects @param int $ocurrencias @return mixed
[ "Este", "metodo", "es", "privado", "y", "realiza", "el", "pasaje", "de", "un", "objeto", "Doctrine", "a", "json", ".", "Para", "esto", "indicamos", "el", "nivel", "de", "profundidad", "que", "se", "va", "a", "ingresar", "en", "el", "objeto", "y", "los", "objetos", "no", "cargados", "hasta", "el", "momento", "solo", "se", "mapearan", "su", "id", "." ]
6c637731cf805dba465658bbaf5cd8aefa6f8f22
https://github.com/edunola13/utils/blob/6c637731cf805dba465658bbaf5cd8aefa6f8f22/helper/ApiRestHelper/JsonHelper.php#L120-L156
3,375
liip/LiipDrupalRegistryModule
src/Liip/Drupal/Modules/Registry/Dispatcher.php
Dispatcher.attach
public function attach(Registry $registry, $id = '') { if (!empty($id) || 0 === $id) { if (!empty($this->registries[$id])) { throw new RegistryException( RegistryException::DUPLICATE_REGISTRATION_ATTEMPT_TEXT, RegistryException::DUPLICATE_REGISTRATION_ATTEMPT_CODE ); } $this->registries[$id] = $registry; } else { $this->registries[] = $registry; } }
php
public function attach(Registry $registry, $id = '') { if (!empty($id) || 0 === $id) { if (!empty($this->registries[$id])) { throw new RegistryException( RegistryException::DUPLICATE_REGISTRATION_ATTEMPT_TEXT, RegistryException::DUPLICATE_REGISTRATION_ATTEMPT_CODE ); } $this->registries[$id] = $registry; } else { $this->registries[] = $registry; } }
[ "public", "function", "attach", "(", "Registry", "$", "registry", ",", "$", "id", "=", "''", ")", "{", "if", "(", "!", "empty", "(", "$", "id", ")", "||", "0", "===", "$", "id", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "registries", "[", "$", "id", "]", ")", ")", "{", "throw", "new", "RegistryException", "(", "RegistryException", "::", "DUPLICATE_REGISTRATION_ATTEMPT_TEXT", ",", "RegistryException", "::", "DUPLICATE_REGISTRATION_ATTEMPT_CODE", ")", ";", "}", "$", "this", "->", "registries", "[", "$", "id", "]", "=", "$", "registry", ";", "}", "else", "{", "$", "this", "->", "registries", "[", "]", "=", "$", "registry", ";", "}", "}" ]
Adds the provided registry to the dispatcher queue. @param Registry $registry @param string $id @throws RegistryException
[ "Adds", "the", "provided", "registry", "to", "the", "dispatcher", "queue", "." ]
2d860c1f88ef91d9af91909d8711ffbb6e2a1eab
https://github.com/liip/LiipDrupalRegistryModule/blob/2d860c1f88ef91d9af91909d8711ffbb6e2a1eab/src/Liip/Drupal/Modules/Registry/Dispatcher.php#L34-L52
3,376
liip/LiipDrupalRegistryModule
src/Liip/Drupal/Modules/Registry/Dispatcher.php
Dispatcher.detach
public function detach($id) { if (empty($this->registries[$id])) { throw new RegistryException( RegistryException::MODIFICATION_ATTEMPT_FAILED_TEXT, RegistryException::MODIFICATION_ATTEMPT_FAILED_CODE ); } unset($this->registries[$id]); }
php
public function detach($id) { if (empty($this->registries[$id])) { throw new RegistryException( RegistryException::MODIFICATION_ATTEMPT_FAILED_TEXT, RegistryException::MODIFICATION_ATTEMPT_FAILED_CODE ); } unset($this->registries[$id]); }
[ "public", "function", "detach", "(", "$", "id", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "registries", "[", "$", "id", "]", ")", ")", "{", "throw", "new", "RegistryException", "(", "RegistryException", "::", "MODIFICATION_ATTEMPT_FAILED_TEXT", ",", "RegistryException", "::", "MODIFICATION_ATTEMPT_FAILED_CODE", ")", ";", "}", "unset", "(", "$", "this", "->", "registries", "[", "$", "id", "]", ")", ";", "}" ]
Removes the a registry from dispatcher. @param string $id @throws RegistryException
[ "Removes", "the", "a", "registry", "from", "dispatcher", "." ]
2d860c1f88ef91d9af91909d8711ffbb6e2a1eab
https://github.com/liip/LiipDrupalRegistryModule/blob/2d860c1f88ef91d9af91909d8711ffbb6e2a1eab/src/Liip/Drupal/Modules/Registry/Dispatcher.php#L61-L71
3,377
liip/LiipDrupalRegistryModule
src/Liip/Drupal/Modules/Registry/Dispatcher.php
Dispatcher.processRegistry
protected function processRegistry($action, Registry $registry, $id, array $output, array $args = array()) { try { $output[$id] = call_user_func_array(array($registry, $action), $args); } catch (RegistryException $e) { $this->errors[$id] = $e; } return $output; }
php
protected function processRegistry($action, Registry $registry, $id, array $output, array $args = array()) { try { $output[$id] = call_user_func_array(array($registry, $action), $args); } catch (RegistryException $e) { $this->errors[$id] = $e; } return $output; }
[ "protected", "function", "processRegistry", "(", "$", "action", ",", "Registry", "$", "registry", ",", "$", "id", ",", "array", "$", "output", ",", "array", "$", "args", "=", "array", "(", ")", ")", "{", "try", "{", "$", "output", "[", "$", "id", "]", "=", "call_user_func_array", "(", "array", "(", "$", "registry", ",", "$", "action", ")", ",", "$", "args", ")", ";", "}", "catch", "(", "RegistryException", "$", "e", ")", "{", "$", "this", "->", "errors", "[", "$", "id", "]", "=", "$", "e", ";", "}", "return", "$", "output", ";", "}" ]
Invokes the defined callback on the given registry. @param string $action @param Registry $registry @param string $id @param array $output @param array $args @return array
[ "Invokes", "the", "defined", "callback", "on", "the", "given", "registry", "." ]
2d860c1f88ef91d9af91909d8711ffbb6e2a1eab
https://github.com/liip/LiipDrupalRegistryModule/blob/2d860c1f88ef91d9af91909d8711ffbb6e2a1eab/src/Liip/Drupal/Modules/Registry/Dispatcher.php#L118-L130
3,378
liip/LiipDrupalRegistryModule
src/Liip/Drupal/Modules/Registry/Dispatcher.php
Dispatcher.getLastErrorMessages
public function getLastErrorMessages() { $message = ''; if ($this->hasError()) { foreach ($this->errors as $exception) { $message .= $exception->getMessage() . ',' . PHP_EOL; } } return $message; }
php
public function getLastErrorMessages() { $message = ''; if ($this->hasError()) { foreach ($this->errors as $exception) { $message .= $exception->getMessage() . ',' . PHP_EOL; } } return $message; }
[ "public", "function", "getLastErrorMessages", "(", ")", "{", "$", "message", "=", "''", ";", "if", "(", "$", "this", "->", "hasError", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "errors", "as", "$", "exception", ")", "{", "$", "message", ".=", "$", "exception", "->", "getMessage", "(", ")", ".", "','", ".", "PHP_EOL", ";", "}", "}", "return", "$", "message", ";", "}" ]
Provides the messages generated by the last occurred errors. @return string
[ "Provides", "the", "messages", "generated", "by", "the", "last", "occurred", "errors", "." ]
2d860c1f88ef91d9af91909d8711ffbb6e2a1eab
https://github.com/liip/LiipDrupalRegistryModule/blob/2d860c1f88ef91d9af91909d8711ffbb6e2a1eab/src/Liip/Drupal/Modules/Registry/Dispatcher.php#L145-L157
3,379
XTAIN/JoomlaBundle
Library/Joomla/Database/Driver/AbstractDoctrineDriver.php
AbstractDoctrineDriver.fetchArray
protected function fetchArray($cursor = null) { if (!empty($cursor) && $cursor instanceof Statement) { return $cursor->fetch(\PDO::FETCH_NUM); } if ($this->prepared instanceof Statement) { return $this->prepared->fetch(\PDO::FETCH_NUM); } }
php
protected function fetchArray($cursor = null) { if (!empty($cursor) && $cursor instanceof Statement) { return $cursor->fetch(\PDO::FETCH_NUM); } if ($this->prepared instanceof Statement) { return $this->prepared->fetch(\PDO::FETCH_NUM); } }
[ "protected", "function", "fetchArray", "(", "$", "cursor", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "cursor", ")", "&&", "$", "cursor", "instanceof", "Statement", ")", "{", "return", "$", "cursor", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_NUM", ")", ";", "}", "if", "(", "$", "this", "->", "prepared", "instanceof", "Statement", ")", "{", "return", "$", "this", "->", "prepared", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_NUM", ")", ";", "}", "}" ]
Method to fetch a row from the result set cursor as an array. @param mixed $cursor The optional result set cursor from which to fetch the row. @return mixed Either the next row from the result set or false if there are no more rows. @author Maximiian Ruta <[email protected]>
[ "Method", "to", "fetch", "a", "row", "from", "the", "result", "set", "cursor", "as", "an", "array", "." ]
3d39e1278deba77c5a2197ad91973964ed2a38bd
https://github.com/XTAIN/JoomlaBundle/blob/3d39e1278deba77c5a2197ad91973964ed2a38bd/Library/Joomla/Database/Driver/AbstractDoctrineDriver.php#L451-L460
3,380
XTAIN/JoomlaBundle
Library/Joomla/Database/Driver/AbstractDoctrineDriver.php
AbstractDoctrineDriver.fetchAssoc
protected function fetchAssoc($cursor = null) { if (!empty($cursor) && $cursor instanceof Statement) { return $cursor->fetch(\PDO::FETCH_ASSOC); } if ($this->prepared instanceof Statement) { return $this->prepared->fetch(\PDO::FETCH_ASSOC); } return null; }
php
protected function fetchAssoc($cursor = null) { if (!empty($cursor) && $cursor instanceof Statement) { return $cursor->fetch(\PDO::FETCH_ASSOC); } if ($this->prepared instanceof Statement) { return $this->prepared->fetch(\PDO::FETCH_ASSOC); } return null; }
[ "protected", "function", "fetchAssoc", "(", "$", "cursor", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "cursor", ")", "&&", "$", "cursor", "instanceof", "Statement", ")", "{", "return", "$", "cursor", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "}", "if", "(", "$", "this", "->", "prepared", "instanceof", "Statement", ")", "{", "return", "$", "this", "->", "prepared", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "}", "return", "null", ";", "}" ]
Method to fetch a row from the result set cursor as an associative array. @param mixed $cursor The optional result set cursor from which to fetch the row. @return mixed Either the next row from the result set or false if there are no more rows. @author Maximiian Ruta <[email protected]>
[ "Method", "to", "fetch", "a", "row", "from", "the", "result", "set", "cursor", "as", "an", "associative", "array", "." ]
3d39e1278deba77c5a2197ad91973964ed2a38bd
https://github.com/XTAIN/JoomlaBundle/blob/3d39e1278deba77c5a2197ad91973964ed2a38bd/Library/Joomla/Database/Driver/AbstractDoctrineDriver.php#L470-L481
3,381
XTAIN/JoomlaBundle
Library/Joomla/Database/Driver/AbstractDoctrineDriver.php
AbstractDoctrineDriver.loadNextObject
public function loadNextObject($class = 'stdClass') { $this->connect(); // Execute the query and get the result set cursor. if (!$this->executed) { if (!($this->execute())) { return $this->errorNum ? null : false; } } // Get the next row from the result set as an object of type $class. if ($row = $this->fetchObject(null, $class)) { return $row; } // Free up system resources and return. $this->freeResult(); return false; }
php
public function loadNextObject($class = 'stdClass') { $this->connect(); // Execute the query and get the result set cursor. if (!$this->executed) { if (!($this->execute())) { return $this->errorNum ? null : false; } } // Get the next row from the result set as an object of type $class. if ($row = $this->fetchObject(null, $class)) { return $row; } // Free up system resources and return. $this->freeResult(); return false; }
[ "public", "function", "loadNextObject", "(", "$", "class", "=", "'stdClass'", ")", "{", "$", "this", "->", "connect", "(", ")", ";", "// Execute the query and get the result set cursor.", "if", "(", "!", "$", "this", "->", "executed", ")", "{", "if", "(", "!", "(", "$", "this", "->", "execute", "(", ")", ")", ")", "{", "return", "$", "this", "->", "errorNum", "?", "null", ":", "false", ";", "}", "}", "// Get the next row from the result set as an object of type $class.", "if", "(", "$", "row", "=", "$", "this", "->", "fetchObject", "(", "null", ",", "$", "class", ")", ")", "{", "return", "$", "row", ";", "}", "// Free up system resources and return.", "$", "this", "->", "freeResult", "(", ")", ";", "return", "false", ";", "}" ]
Method to get the next row in the result set from the database query as an object. @param string $class The class name to use for the returned row object. @return mixed The result of the query as an array, false if there are no more rows. @throws RuntimeException @author Maximiian Ruta <[email protected]>
[ "Method", "to", "get", "the", "next", "row", "in", "the", "result", "set", "from", "the", "database", "query", "as", "an", "object", "." ]
3d39e1278deba77c5a2197ad91973964ed2a38bd
https://github.com/XTAIN/JoomlaBundle/blob/3d39e1278deba77c5a2197ad91973964ed2a38bd/Library/Joomla/Database/Driver/AbstractDoctrineDriver.php#L549-L569
3,382
XTAIN/JoomlaBundle
Library/Joomla/Database/Driver/AbstractDoctrineDriver.php
AbstractDoctrineDriver.escape
public function escape($text, $extra = false) { if (is_int($text) || is_float($text)) { return $text; } $result = substr($this->connection->quote($text), 1, -1); if ($extra) { $result = addcslashes($result, '%_'); } return $result; }
php
public function escape($text, $extra = false) { if (is_int($text) || is_float($text)) { return $text; } $result = substr($this->connection->quote($text), 1, -1); if ($extra) { $result = addcslashes($result, '%_'); } return $result; }
[ "public", "function", "escape", "(", "$", "text", ",", "$", "extra", "=", "false", ")", "{", "if", "(", "is_int", "(", "$", "text", ")", "||", "is_float", "(", "$", "text", ")", ")", "{", "return", "$", "text", ";", "}", "$", "result", "=", "substr", "(", "$", "this", "->", "connection", "->", "quote", "(", "$", "text", ")", ",", "1", ",", "-", "1", ")", ";", "if", "(", "$", "extra", ")", "{", "$", "result", "=", "addcslashes", "(", "$", "result", ",", "'%_'", ")", ";", "}", "return", "$", "result", ";", "}" ]
Escapes a string for usage in an SQL statement. @param string $text The string to be escaped. @param bool $extra Optional parameter to provide extra escaping. @return string The escaped string. @author Maximiian Ruta <[email protected]>
[ "Escapes", "a", "string", "for", "usage", "in", "an", "SQL", "statement", "." ]
3d39e1278deba77c5a2197ad91973964ed2a38bd
https://github.com/XTAIN/JoomlaBundle/blob/3d39e1278deba77c5a2197ad91973964ed2a38bd/Library/Joomla/Database/Driver/AbstractDoctrineDriver.php#L638-L651
3,383
znframework/package-security
Script.php
Script.encode
public static function encode(String $str) : String { return preg_replace ( array_keys(self::$scriptTagChars), array_values(self::$scriptTagChars), $str ); }
php
public static function encode(String $str) : String { return preg_replace ( array_keys(self::$scriptTagChars), array_values(self::$scriptTagChars), $str ); }
[ "public", "static", "function", "encode", "(", "String", "$", "str", ")", ":", "String", "{", "return", "preg_replace", "(", "array_keys", "(", "self", "::", "$", "scriptTagChars", ")", ",", "array_values", "(", "self", "::", "$", "scriptTagChars", ")", ",", "$", "str", ")", ";", "}" ]
Encode Script Tags @param string $str @return string
[ "Encode", "Script", "Tags" ]
dfced60e243ab9f52a1b5bbdb695bfc39b26cac0
https://github.com/znframework/package-security/blob/dfced60e243ab9f52a1b5bbdb695bfc39b26cac0/Script.php#L43-L51
3,384
znframework/package-security
Script.php
Script.decode
public static function decode(String $str) : String { return preg_replace ( array_keys(self::$scriptTagCharsDecode), array_values(self::$scriptTagCharsDecode), $str ); }
php
public static function decode(String $str) : String { return preg_replace ( array_keys(self::$scriptTagCharsDecode), array_values(self::$scriptTagCharsDecode), $str ); }
[ "public", "static", "function", "decode", "(", "String", "$", "str", ")", ":", "String", "{", "return", "preg_replace", "(", "array_keys", "(", "self", "::", "$", "scriptTagCharsDecode", ")", ",", "array_values", "(", "self", "::", "$", "scriptTagCharsDecode", ")", ",", "$", "str", ")", ";", "}" ]
Decode Script Tags @param string $str @return string
[ "Decode", "Script", "Tags" ]
dfced60e243ab9f52a1b5bbdb695bfc39b26cac0
https://github.com/znframework/package-security/blob/dfced60e243ab9f52a1b5bbdb695bfc39b26cac0/Script.php#L60-L68
3,385
phPoirot/Http
HttpMessage/Request/Plugin/ParseRequestData.php
ParseRequestData.parseBody
function parseBody() { $request = $this->getMessageObject(); $reqID = spl_object_hash($request); if ( isset(self::$_parsed[$reqID]) ) // parse from cached return self::$_parsed[$reqID]; if ($request->headers()->has('content-type')) { $contentType = \Poirot\Http\Header\renderHeaderValue($request, 'content-type'); $contentType = strtolower($contentType); } else { // No Any Data Sent ..... return array(); } // Content-Type May be in form of: // application/x-www-form-urlencoded; charset=utf-8 // when we call from jquery/ajax in exm. if ( false !== $pos = strpos($contentType, ';') ) $contentType = substr($contentType, 0, $pos); switch ( $contentType ) { case 'application/json': $parsedData = $this->_parseJsonDataFromRequest($request); break; case 'application/x-www-form-urlencoded': $parsedData = $this->_parseUrlEncodeDataFromRequest($request); break; case strpos($contentType, 'multipart') !== false: $parsedData = $this->_parseMultipartDataFromRequest($request); break; default: throw new \Exception(sprintf( 'Request Body Contains No Data or Unknown Content-Type (%s).' , $contentType )); } return self::$_parsed[$reqID] = $parsedData; }
php
function parseBody() { $request = $this->getMessageObject(); $reqID = spl_object_hash($request); if ( isset(self::$_parsed[$reqID]) ) // parse from cached return self::$_parsed[$reqID]; if ($request->headers()->has('content-type')) { $contentType = \Poirot\Http\Header\renderHeaderValue($request, 'content-type'); $contentType = strtolower($contentType); } else { // No Any Data Sent ..... return array(); } // Content-Type May be in form of: // application/x-www-form-urlencoded; charset=utf-8 // when we call from jquery/ajax in exm. if ( false !== $pos = strpos($contentType, ';') ) $contentType = substr($contentType, 0, $pos); switch ( $contentType ) { case 'application/json': $parsedData = $this->_parseJsonDataFromRequest($request); break; case 'application/x-www-form-urlencoded': $parsedData = $this->_parseUrlEncodeDataFromRequest($request); break; case strpos($contentType, 'multipart') !== false: $parsedData = $this->_parseMultipartDataFromRequest($request); break; default: throw new \Exception(sprintf( 'Request Body Contains No Data or Unknown Content-Type (%s).' , $contentType )); } return self::$_parsed[$reqID] = $parsedData; }
[ "function", "parseBody", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getMessageObject", "(", ")", ";", "$", "reqID", "=", "spl_object_hash", "(", "$", "request", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "_parsed", "[", "$", "reqID", "]", ")", ")", "// parse from cached", "return", "self", "::", "$", "_parsed", "[", "$", "reqID", "]", ";", "if", "(", "$", "request", "->", "headers", "(", ")", "->", "has", "(", "'content-type'", ")", ")", "{", "$", "contentType", "=", "\\", "Poirot", "\\", "Http", "\\", "Header", "\\", "renderHeaderValue", "(", "$", "request", ",", "'content-type'", ")", ";", "$", "contentType", "=", "strtolower", "(", "$", "contentType", ")", ";", "}", "else", "{", "// No Any Data Sent .....", "return", "array", "(", ")", ";", "}", "// Content-Type May be in form of:", "// application/x-www-form-urlencoded; charset=utf-8", "// when we call from jquery/ajax in exm.", "if", "(", "false", "!==", "$", "pos", "=", "strpos", "(", "$", "contentType", ",", "';'", ")", ")", "$", "contentType", "=", "substr", "(", "$", "contentType", ",", "0", ",", "$", "pos", ")", ";", "switch", "(", "$", "contentType", ")", "{", "case", "'application/json'", ":", "$", "parsedData", "=", "$", "this", "->", "_parseJsonDataFromRequest", "(", "$", "request", ")", ";", "break", ";", "case", "'application/x-www-form-urlencoded'", ":", "$", "parsedData", "=", "$", "this", "->", "_parseUrlEncodeDataFromRequest", "(", "$", "request", ")", ";", "break", ";", "case", "strpos", "(", "$", "contentType", ",", "'multipart'", ")", "!==", "false", ":", "$", "parsedData", "=", "$", "this", "->", "_parseMultipartDataFromRequest", "(", "$", "request", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Request Body Contains No Data or Unknown Content-Type (%s).'", ",", "$", "contentType", ")", ")", ";", "}", "return", "self", "::", "$", "_parsed", "[", "$", "reqID", "]", "=", "$", "parsedData", ";", "}" ]
Parse Request Body Data @return array @throws \Exception
[ "Parse", "Request", "Body", "Data" ]
3230b3555abf0e74c3d593fc49c8978758969736
https://github.com/phPoirot/Http/blob/3230b3555abf0e74c3d593fc49c8978758969736/HttpMessage/Request/Plugin/ParseRequestData.php#L23-L71
3,386
phPoirot/Http
HttpMessage/Request/Plugin/ParseRequestData.php
ParseRequestData.parseQueryParams
function parseQueryParams() { $request = $this->getMessageObject(); $data = array(); $url = $request->getTarget(); if ($p = parse_url($url, PHP_URL_QUERY)) parse_str($p, $data); return $data; }
php
function parseQueryParams() { $request = $this->getMessageObject(); $data = array(); $url = $request->getTarget(); if ($p = parse_url($url, PHP_URL_QUERY)) parse_str($p, $data); return $data; }
[ "function", "parseQueryParams", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getMessageObject", "(", ")", ";", "$", "data", "=", "array", "(", ")", ";", "$", "url", "=", "$", "request", "->", "getTarget", "(", ")", ";", "if", "(", "$", "p", "=", "parse_url", "(", "$", "url", ",", "PHP_URL_QUERY", ")", ")", "parse_str", "(", "$", "p", ",", "$", "data", ")", ";", "return", "$", "data", ";", "}" ]
Parse Request Query Params @return array
[ "Parse", "Request", "Query", "Params" ]
3230b3555abf0e74c3d593fc49c8978758969736
https://github.com/phPoirot/Http/blob/3230b3555abf0e74c3d593fc49c8978758969736/HttpMessage/Request/Plugin/ParseRequestData.php#L78-L88
3,387
routegroup/native-media
src/Concerns/Paths.php
Paths.getUrlAttribute
public function getUrlAttribute() { if ($this->disk == 'public') { return url($this->storage->url($this->path)); } return config('media.download', false) ? url(str_finish(config('media.download'), '/') . $this->id) : null; }
php
public function getUrlAttribute() { if ($this->disk == 'public') { return url($this->storage->url($this->path)); } return config('media.download', false) ? url(str_finish(config('media.download'), '/') . $this->id) : null; }
[ "public", "function", "getUrlAttribute", "(", ")", "{", "if", "(", "$", "this", "->", "disk", "==", "'public'", ")", "{", "return", "url", "(", "$", "this", "->", "storage", "->", "url", "(", "$", "this", "->", "path", ")", ")", ";", "}", "return", "config", "(", "'media.download'", ",", "false", ")", "?", "url", "(", "str_finish", "(", "config", "(", "'media.download'", ")", ",", "'/'", ")", ".", "$", "this", "->", "id", ")", ":", "null", ";", "}" ]
Url to file. @return string|null
[ "Url", "to", "file", "." ]
5ea35c46c2ac1019e277ec4fe698f17581524631
https://github.com/routegroup/native-media/blob/5ea35c46c2ac1019e277ec4fe698f17581524631/src/Concerns/Paths.php#L56-L63
3,388
aedart/model
src/Traits/Strings/FirstNameTrait.php
FirstNameTrait.getFirstName
public function getFirstName() : ?string { if ( ! $this->hasFirstName()) { $this->setFirstName($this->getDefaultFirstName()); } return $this->firstName; }
php
public function getFirstName() : ?string { if ( ! $this->hasFirstName()) { $this->setFirstName($this->getDefaultFirstName()); } return $this->firstName; }
[ "public", "function", "getFirstName", "(", ")", ":", "?", "string", "{", "if", "(", "!", "$", "this", "->", "hasFirstName", "(", ")", ")", "{", "$", "this", "->", "setFirstName", "(", "$", "this", "->", "getDefaultFirstName", "(", ")", ")", ";", "}", "return", "$", "this", "->", "firstName", ";", "}" ]
Get first name If no "first name" value has been set, this method will set and return a default "first name" value, if any such value is available @see getDefaultFirstName() @return string|null first name or null if no first name has been set
[ "Get", "first", "name" ]
9a562c1c53a276d01ace0ab71f5305458bea542f
https://github.com/aedart/model/blob/9a562c1c53a276d01ace0ab71f5305458bea542f/src/Traits/Strings/FirstNameTrait.php#L48-L54
3,389
circle314/type
src/TypeTrait/DateTimeTypeTrait.php
DateTimeTypeTrait.isUnixTimestamp
private function isUnixTimestamp($value): bool { return (string)(float)$value == (string)$value && ((float)$value <= PHP_INT_MAX) && ((float)$value >= ~PHP_INT_MAX) ; }
php
private function isUnixTimestamp($value): bool { return (string)(float)$value == (string)$value && ((float)$value <= PHP_INT_MAX) && ((float)$value >= ~PHP_INT_MAX) ; }
[ "private", "function", "isUnixTimestamp", "(", "$", "value", ")", ":", "bool", "{", "return", "(", "string", ")", "(", "float", ")", "$", "value", "==", "(", "string", ")", "$", "value", "&&", "(", "(", "float", ")", "$", "value", "<=", "PHP_INT_MAX", ")", "&&", "(", "(", "float", ")", "$", "value", ">=", "~", "PHP_INT_MAX", ")", ";", "}" ]
Checks whether a value is a valid UNIX timestamp @param $value @return bool
[ "Checks", "whether", "a", "value", "is", "a", "valid", "UNIX", "timestamp" ]
4048d57efad65f043b549c3c4b48b1d0e6c09a3f
https://github.com/circle314/type/blob/4048d57efad65f043b549c3c4b48b1d0e6c09a3f/src/TypeTrait/DateTimeTypeTrait.php#L27-L34
3,390
circle314/type
src/TypeTrait/DateTimeTypeTrait.php
DateTimeTypeTrait.validateDateTime
private function validateDateTime($value): void { try { if( is_a($value, DateTime::class) || is_null($value) || $value === 'now' ) { // Expected and valid values, no need to attempt conversion } else { if($this->isUnixTimestamp($value)) { // Try making a DateTime with a UNIX Timestamp from a string DateTime::createFromFormat("U.u", $this->unixTimestampAsUuFormat($value)); } else { // Try making a DateTime with whatever remains new DateTime($value); } } } catch (Exception $e) { throw new TypeValidationException('Attempted to pass non-date[time] value to date[time] type'); } }
php
private function validateDateTime($value): void { try { if( is_a($value, DateTime::class) || is_null($value) || $value === 'now' ) { // Expected and valid values, no need to attempt conversion } else { if($this->isUnixTimestamp($value)) { // Try making a DateTime with a UNIX Timestamp from a string DateTime::createFromFormat("U.u", $this->unixTimestampAsUuFormat($value)); } else { // Try making a DateTime with whatever remains new DateTime($value); } } } catch (Exception $e) { throw new TypeValidationException('Attempted to pass non-date[time] value to date[time] type'); } }
[ "private", "function", "validateDateTime", "(", "$", "value", ")", ":", "void", "{", "try", "{", "if", "(", "is_a", "(", "$", "value", ",", "DateTime", "::", "class", ")", "||", "is_null", "(", "$", "value", ")", "||", "$", "value", "===", "'now'", ")", "{", "// Expected and valid values, no need to attempt conversion", "}", "else", "{", "if", "(", "$", "this", "->", "isUnixTimestamp", "(", "$", "value", ")", ")", "{", "// Try making a DateTime with a UNIX Timestamp from a string", "DateTime", "::", "createFromFormat", "(", "\"U.u\"", ",", "$", "this", "->", "unixTimestampAsUuFormat", "(", "$", "value", ")", ")", ";", "}", "else", "{", "// Try making a DateTime with whatever remains", "new", "DateTime", "(", "$", "value", ")", ";", "}", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "TypeValidationException", "(", "'Attempted to pass non-date[time] value to date[time] type'", ")", ";", "}", "}" ]
Validates a value as a nullable value that can be cast to DateTime @param $value @throws TypeValidationException
[ "Validates", "a", "value", "as", "a", "nullable", "value", "that", "can", "be", "cast", "to", "DateTime" ]
4048d57efad65f043b549c3c4b48b1d0e6c09a3f
https://github.com/circle314/type/blob/4048d57efad65f043b549c3c4b48b1d0e6c09a3f/src/TypeTrait/DateTimeTypeTrait.php#L53-L74
3,391
Fenzland/Htsl.php
libs/ReadingBuffer/StringBuffer.php
StringBuffer.goSide
public function goSide( $fileName ):parent { $filePath= $this->htsl->getFilePath($fileName,dirname($this->filePath)); $content= $this->htsl->getFileContent($filePath); return new static($this->htsl,$content,$filePath); }
php
public function goSide( $fileName ):parent { $filePath= $this->htsl->getFilePath($fileName,dirname($this->filePath)); $content= $this->htsl->getFileContent($filePath); return new static($this->htsl,$content,$filePath); }
[ "public", "function", "goSide", "(", "$", "fileName", ")", ":", "parent", "{", "$", "filePath", "=", "$", "this", "->", "htsl", "->", "getFilePath", "(", "$", "fileName", ",", "dirname", "(", "$", "this", "->", "filePath", ")", ")", ";", "$", "content", "=", "$", "this", "->", "htsl", "->", "getFileContent", "(", "$", "filePath", ")", ";", "return", "new", "static", "(", "$", "this", "->", "htsl", ",", "$", "content", ",", "$", "filePath", ")", ";", "}" ]
Getting another file reference fake file of this buffer. @access public @param string $fileName @return \Htsl\ReadingBuffer\Contracts\ABuffer
[ "Getting", "another", "file", "reference", "fake", "file", "of", "this", "buffer", "." ]
28ecc4afd1a5bdb29dea3589c8132adba87f3947
https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/ReadingBuffer/StringBuffer.php#L64-L70
3,392
heennkkee/rss
src/rss/Crss.php
Crss.connect
private function connect() { try { $this->db = new \PDO( $this->dbOptions['dsn'], $this->dbOptions['username'], $this->dbOptions['password'], $this->dbOptions['driver_options'] ); } catch (\Exception $e) { //Change to true to debug database connection if ($this->dbOptions['debug']) { // For debug purpose, shows all connection details throw $e; } else { // Hide connection details. throw new \PDOException("Could not connect to database, hiding connection details."); } } $this->db->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_OBJ); }
php
private function connect() { try { $this->db = new \PDO( $this->dbOptions['dsn'], $this->dbOptions['username'], $this->dbOptions['password'], $this->dbOptions['driver_options'] ); } catch (\Exception $e) { //Change to true to debug database connection if ($this->dbOptions['debug']) { // For debug purpose, shows all connection details throw $e; } else { // Hide connection details. throw new \PDOException("Could not connect to database, hiding connection details."); } } $this->db->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_OBJ); }
[ "private", "function", "connect", "(", ")", "{", "try", "{", "$", "this", "->", "db", "=", "new", "\\", "PDO", "(", "$", "this", "->", "dbOptions", "[", "'dsn'", "]", ",", "$", "this", "->", "dbOptions", "[", "'username'", "]", ",", "$", "this", "->", "dbOptions", "[", "'password'", "]", ",", "$", "this", "->", "dbOptions", "[", "'driver_options'", "]", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "//Change to true to debug database connection", "if", "(", "$", "this", "->", "dbOptions", "[", "'debug'", "]", ")", "{", "// For debug purpose, shows all connection details", "throw", "$", "e", ";", "}", "else", "{", "// Hide connection details.", "throw", "new", "\\", "PDOException", "(", "\"Could not connect to database, hiding connection details.\"", ")", ";", "}", "}", "$", "this", "->", "db", "->", "setAttribute", "(", "\\", "PDO", "::", "ATTR_DEFAULT_FETCH_MODE", ",", "\\", "PDO", "::", "FETCH_OBJ", ")", ";", "}" ]
Internal function for connecting to the database @return void
[ "Internal", "function", "for", "connecting", "to", "the", "database" ]
3c990af5dc9d41edd2c6ca85232a0e2cbb1ef533
https://github.com/heennkkee/rss/blob/3c990af5dc9d41edd2c6ca85232a0e2cbb1ef533/src/rss/Crss.php#L89-L110
3,393
heennkkee/rss
src/rss/Crss.php
Crss.checkValidity
private function checkValidity() { if (!is_writable($this->rssFile)) { $this->valid = false; return; } $stmt = $this->db->prepare('SELECT CREATED FROM ' . $this->table . ' ORDER BY CREATED DESC LIMIT 1'); $stmt->execute(); $res = $stmt->fetchAll(); if (count($res) == 0) { $this->valid = false; return; } $latestInput = strtotime($res[0]->CREATED); $rssCreated = filemtime($this->rssFile); if ($latestInput > $rssCreated) { $this->valid = false; } else { $this->valid = true; } }
php
private function checkValidity() { if (!is_writable($this->rssFile)) { $this->valid = false; return; } $stmt = $this->db->prepare('SELECT CREATED FROM ' . $this->table . ' ORDER BY CREATED DESC LIMIT 1'); $stmt->execute(); $res = $stmt->fetchAll(); if (count($res) == 0) { $this->valid = false; return; } $latestInput = strtotime($res[0]->CREATED); $rssCreated = filemtime($this->rssFile); if ($latestInput > $rssCreated) { $this->valid = false; } else { $this->valid = true; } }
[ "private", "function", "checkValidity", "(", ")", "{", "if", "(", "!", "is_writable", "(", "$", "this", "->", "rssFile", ")", ")", "{", "$", "this", "->", "valid", "=", "false", ";", "return", ";", "}", "$", "stmt", "=", "$", "this", "->", "db", "->", "prepare", "(", "'SELECT CREATED FROM '", ".", "$", "this", "->", "table", ".", "' ORDER BY CREATED DESC LIMIT 1'", ")", ";", "$", "stmt", "->", "execute", "(", ")", ";", "$", "res", "=", "$", "stmt", "->", "fetchAll", "(", ")", ";", "if", "(", "count", "(", "$", "res", ")", "==", "0", ")", "{", "$", "this", "->", "valid", "=", "false", ";", "return", ";", "}", "$", "latestInput", "=", "strtotime", "(", "$", "res", "[", "0", "]", "->", "CREATED", ")", ";", "$", "rssCreated", "=", "filemtime", "(", "$", "this", "->", "rssFile", ")", ";", "if", "(", "$", "latestInput", ">", "$", "rssCreated", ")", "{", "$", "this", "->", "valid", "=", "false", ";", "}", "else", "{", "$", "this", "->", "valid", "=", "true", ";", "}", "}" ]
Compares RSS file created timestamp and database timestamp to judge if new RSS file is needed Sets internal variable $this->valid to true/false depending if new file needs to be generate @return void
[ "Compares", "RSS", "file", "created", "timestamp", "and", "database", "timestamp", "to", "judge", "if", "new", "RSS", "file", "is", "needed" ]
3c990af5dc9d41edd2c6ca85232a0e2cbb1ef533
https://github.com/heennkkee/rss/blob/3c990af5dc9d41edd2c6ca85232a0e2cbb1ef533/src/rss/Crss.php#L124-L150
3,394
heennkkee/rss
src/rss/Crss.php
Crss.createRSS
private function createRSS() { $file = fopen($this->rssFile, "w+"); $stmt = $this->db->prepare('SELECT * FROM ' . $this->table . ' ORDER BY CREATED DESC LIMIT ?'); $stmt->execute([$this->newsCount]); $res = $stmt->fetchAll(); $xmlVersion = '<?xml version="1.0" encoding="UTF-8" ?>'; $startString = <<<EOD {$xmlVersion} <rss version="2.0"> <channel> <title>{$this->feedDescription['title']}</title> <link>{$this->feedDescription['link']}</link> <description>{$this->feedDescription['description']}</description> EOD; fwrite($file, $startString); foreach ($res as $post) { $date = date("D, d M y H:i:s O", strtotime($post->CREATED)); $string = <<<EOD <item> <title>{$post->TITLE}</title> <link>{$post->LINK}</link> <description>{$post->DESCRIPTION}</description> <pubDate>{$date}</pubDate> </item> EOD; fwrite($file, $string); } fwrite($file, ' </channel> </rss>'); }
php
private function createRSS() { $file = fopen($this->rssFile, "w+"); $stmt = $this->db->prepare('SELECT * FROM ' . $this->table . ' ORDER BY CREATED DESC LIMIT ?'); $stmt->execute([$this->newsCount]); $res = $stmt->fetchAll(); $xmlVersion = '<?xml version="1.0" encoding="UTF-8" ?>'; $startString = <<<EOD {$xmlVersion} <rss version="2.0"> <channel> <title>{$this->feedDescription['title']}</title> <link>{$this->feedDescription['link']}</link> <description>{$this->feedDescription['description']}</description> EOD; fwrite($file, $startString); foreach ($res as $post) { $date = date("D, d M y H:i:s O", strtotime($post->CREATED)); $string = <<<EOD <item> <title>{$post->TITLE}</title> <link>{$post->LINK}</link> <description>{$post->DESCRIPTION}</description> <pubDate>{$date}</pubDate> </item> EOD; fwrite($file, $string); } fwrite($file, ' </channel> </rss>'); }
[ "private", "function", "createRSS", "(", ")", "{", "$", "file", "=", "fopen", "(", "$", "this", "->", "rssFile", ",", "\"w+\"", ")", ";", "$", "stmt", "=", "$", "this", "->", "db", "->", "prepare", "(", "'SELECT * FROM '", ".", "$", "this", "->", "table", ".", "' ORDER BY CREATED DESC LIMIT ?'", ")", ";", "$", "stmt", "->", "execute", "(", "[", "$", "this", "->", "newsCount", "]", ")", ";", "$", "res", "=", "$", "stmt", "->", "fetchAll", "(", ")", ";", "$", "xmlVersion", "=", "'<?xml version=\"1.0\" encoding=\"UTF-8\" ?>'", ";", "$", "startString", "=", " <<<EOD\n{$xmlVersion}\n<rss version=\"2.0\">\n<channel>\n <title>{$this->feedDescription['title']}</title>\n <link>{$this->feedDescription['link']}</link>\n <description>{$this->feedDescription['description']}</description>\nEOD", ";", "fwrite", "(", "$", "file", ",", "$", "startString", ")", ";", "foreach", "(", "$", "res", "as", "$", "post", ")", "{", "$", "date", "=", "date", "(", "\"D, d M y H:i:s O\"", ",", "strtotime", "(", "$", "post", "->", "CREATED", ")", ")", ";", "$", "string", "=", " <<<EOD\n\n <item>\n <title>{$post->TITLE}</title>\n <link>{$post->LINK}</link>\n <description>{$post->DESCRIPTION}</description>\n <pubDate>{$date}</pubDate>\n </item>\nEOD", ";", "fwrite", "(", "$", "file", ",", "$", "string", ")", ";", "}", "fwrite", "(", "$", "file", ",", "'\n</channel>\n</rss>'", ")", ";", "}" ]
Creates a new RSS File with information from the database. Max amount of news is configured in the initiation. @return void
[ "Creates", "a", "new", "RSS", "File", "with", "information", "from", "the", "database", ".", "Max", "amount", "of", "news", "is", "configured", "in", "the", "initiation", "." ]
3c990af5dc9d41edd2c6ca85232a0e2cbb1ef533
https://github.com/heennkkee/rss/blob/3c990af5dc9d41edd2c6ca85232a0e2cbb1ef533/src/rss/Crss.php#L157-L194
3,395
heennkkee/rss
src/rss/Crss.php
Crss.getRSS
public function getRSS() { $this->checkValidity(); if (!$this->valid) { $this->createRSS(); } if ($this->sendHeader) { header('Content-type: application/rss+xml; charset=UTF-8'); } readfile($this->rssFile); }
php
public function getRSS() { $this->checkValidity(); if (!$this->valid) { $this->createRSS(); } if ($this->sendHeader) { header('Content-type: application/rss+xml; charset=UTF-8'); } readfile($this->rssFile); }
[ "public", "function", "getRSS", "(", ")", "{", "$", "this", "->", "checkValidity", "(", ")", ";", "if", "(", "!", "$", "this", "->", "valid", ")", "{", "$", "this", "->", "createRSS", "(", ")", ";", "}", "if", "(", "$", "this", "->", "sendHeader", ")", "{", "header", "(", "'Content-type: application/rss+xml; charset=UTF-8'", ")", ";", "}", "readfile", "(", "$", "this", "->", "rssFile", ")", ";", "}" ]
Function that should be called to receive the RSS feed. Checks if the latest RSS File is up to date, if not, generates a new one. @return void
[ "Function", "that", "should", "be", "called", "to", "receive", "the", "RSS", "feed", ".", "Checks", "if", "the", "latest", "RSS", "File", "is", "up", "to", "date", "if", "not", "generates", "a", "new", "one", "." ]
3c990af5dc9d41edd2c6ca85232a0e2cbb1ef533
https://github.com/heennkkee/rss/blob/3c990af5dc9d41edd2c6ca85232a0e2cbb1ef533/src/rss/Crss.php#L201-L214
3,396
axypro/creator
helpers/Validator.php
Validator.validate
public static function validate($result, array $context) { if (!empty($context['parent'])) { if (!($result instanceof $context['parent'])) { throw new InvalidPointer('Object must be an instance of '.$context['parent']); } } if (!empty($context['validator'])) { if (!Callback::call($context['validator'], [$result])) { throw new InvalidPointer('Object is not valid'); } } return true; }
php
public static function validate($result, array $context) { if (!empty($context['parent'])) { if (!($result instanceof $context['parent'])) { throw new InvalidPointer('Object must be an instance of '.$context['parent']); } } if (!empty($context['validator'])) { if (!Callback::call($context['validator'], [$result])) { throw new InvalidPointer('Object is not valid'); } } return true; }
[ "public", "static", "function", "validate", "(", "$", "result", ",", "array", "$", "context", ")", "{", "if", "(", "!", "empty", "(", "$", "context", "[", "'parent'", "]", ")", ")", "{", "if", "(", "!", "(", "$", "result", "instanceof", "$", "context", "[", "'parent'", "]", ")", ")", "{", "throw", "new", "InvalidPointer", "(", "'Object must be an instance of '", ".", "$", "context", "[", "'parent'", "]", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "context", "[", "'validator'", "]", ")", ")", "{", "if", "(", "!", "Callback", "::", "call", "(", "$", "context", "[", "'validator'", "]", ",", "[", "$", "result", "]", ")", ")", "{", "throw", "new", "InvalidPointer", "(", "'Object is not valid'", ")", ";", "}", "}", "return", "true", ";", "}" ]
Checks a result @param mixed $result the result of creating @param array $context the context of the creator @return boolean @throws \axy\creator\errors\InvalidPointer
[ "Checks", "a", "result" ]
3d74e2201cdb93912d32b1d80d1fdc44018f132a
https://github.com/axypro/creator/blob/3d74e2201cdb93912d32b1d80d1fdc44018f132a/helpers/Validator.php#L27-L40
3,397
phossa2/libs
src/Phossa2/Logger/Traits/ExtendedLoggerTrait.php
ExtendedLoggerTrait.removeFromQueue
protected function removeFromQueue( PriorityQueueInterface $queue, $callabOrClassname ) { if (is_object($callabOrClassname)) { $queue->remove($callabOrClassname); } else { foreach ($queue as $data) { if (is_a($data['data'], $callabOrClassname)) { $queue->remove($data['data']); } } } }
php
protected function removeFromQueue( PriorityQueueInterface $queue, $callabOrClassname ) { if (is_object($callabOrClassname)) { $queue->remove($callabOrClassname); } else { foreach ($queue as $data) { if (is_a($data['data'], $callabOrClassname)) { $queue->remove($data['data']); } } } }
[ "protected", "function", "removeFromQueue", "(", "PriorityQueueInterface", "$", "queue", ",", "$", "callabOrClassname", ")", "{", "if", "(", "is_object", "(", "$", "callabOrClassname", ")", ")", "{", "$", "queue", "->", "remove", "(", "$", "callabOrClassname", ")", ";", "}", "else", "{", "foreach", "(", "$", "queue", "as", "$", "data", ")", "{", "if", "(", "is_a", "(", "$", "data", "[", "'data'", "]", ",", "$", "callabOrClassname", ")", ")", "{", "$", "queue", "->", "remove", "(", "$", "data", "[", "'data'", "]", ")", ";", "}", "}", "}", "}" ]
Remove callable or matching classname object from the queue @param PriorityQueueInterface $queue @param callable|string $callabOrClassname @access protected
[ "Remove", "callable", "or", "matching", "classname", "object", "from", "the", "queue" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Logger/Traits/ExtendedLoggerTrait.php#L147-L160
3,398
phossa2/libs
src/Phossa2/Logger/Traits/ExtendedLoggerTrait.php
ExtendedLoggerTrait.runProcessors
protected function runProcessors(LogEntryInterface $logEntry) { // get related processors $queue = $this->getCallables('processors', $logEntry->getChannel()); // loop thru these processors foreach ($queue as $data) { call_user_func($data['data'], $logEntry); } return $this; }
php
protected function runProcessors(LogEntryInterface $logEntry) { // get related processors $queue = $this->getCallables('processors', $logEntry->getChannel()); // loop thru these processors foreach ($queue as $data) { call_user_func($data['data'], $logEntry); } return $this; }
[ "protected", "function", "runProcessors", "(", "LogEntryInterface", "$", "logEntry", ")", "{", "// get related processors", "$", "queue", "=", "$", "this", "->", "getCallables", "(", "'processors'", ",", "$", "logEntry", "->", "getChannel", "(", ")", ")", ";", "// loop thru these processors", "foreach", "(", "$", "queue", "as", "$", "data", ")", "{", "call_user_func", "(", "$", "data", "[", "'data'", "]", ",", "$", "logEntry", ")", ";", "}", "return", "$", "this", ";", "}" ]
Execute related processors on the log entry @param LogEntryInterface $logEntry @return $this @access protected
[ "Execute", "related", "processors", "on", "the", "log", "entry" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Logger/Traits/ExtendedLoggerTrait.php#L181-L192
3,399
phossa2/libs
src/Phossa2/Logger/Traits/ExtendedLoggerTrait.php
ExtendedLoggerTrait.runHandlers
protected function runHandlers(LogEntryInterface $logEntry) { // get related handlers $queue = $this->getCallables('handlers', $logEntry->getChannel()); // loop thru these handlers foreach ($queue as $data) { // stopped ? if ($logEntry->isPropagationStopped()) { break; } // run handler only if level allowed if (LogLevel::$levels[$logEntry->getLevel()] >= LogLevel::$levels[$data['extra']]) { call_user_func($data['data'], $logEntry); } } return $this; }
php
protected function runHandlers(LogEntryInterface $logEntry) { // get related handlers $queue = $this->getCallables('handlers', $logEntry->getChannel()); // loop thru these handlers foreach ($queue as $data) { // stopped ? if ($logEntry->isPropagationStopped()) { break; } // run handler only if level allowed if (LogLevel::$levels[$logEntry->getLevel()] >= LogLevel::$levels[$data['extra']]) { call_user_func($data['data'], $logEntry); } } return $this; }
[ "protected", "function", "runHandlers", "(", "LogEntryInterface", "$", "logEntry", ")", "{", "// get related handlers", "$", "queue", "=", "$", "this", "->", "getCallables", "(", "'handlers'", ",", "$", "logEntry", "->", "getChannel", "(", ")", ")", ";", "// loop thru these handlers", "foreach", "(", "$", "queue", "as", "$", "data", ")", "{", "// stopped ?", "if", "(", "$", "logEntry", "->", "isPropagationStopped", "(", ")", ")", "{", "break", ";", "}", "// run handler only if level allowed", "if", "(", "LogLevel", "::", "$", "levels", "[", "$", "logEntry", "->", "getLevel", "(", ")", "]", ">=", "LogLevel", "::", "$", "levels", "[", "$", "data", "[", "'extra'", "]", "]", ")", "{", "call_user_func", "(", "$", "data", "[", "'data'", "]", ",", "$", "logEntry", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Execute related handlers on the log entry @param LogEntryInterface $logEntry @return $this @access protected @since 2.0.1 added level checking here
[ "Execute", "related", "handlers", "on", "the", "log", "entry" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Logger/Traits/ExtendedLoggerTrait.php#L202-L222