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
7,700
GrupaZero/core
src/Gzero/Core/ViewModels/UserViewModel.php
UserViewModel.displayName
public function displayName() { if (isset($this->data['name']) && config('gzero.use_users_nicks')) { return $this->data['name']; } if (isset($this->data['first_name']) || isset($this->data['last_name'])) { return $this->data['first_name'] . ' ' . $this->data['last_name']; } return trans('gzero-core::common.anonymous'); }
php
public function displayName() { if (isset($this->data['name']) && config('gzero.use_users_nicks')) { return $this->data['name']; } if (isset($this->data['first_name']) || isset($this->data['last_name'])) { return $this->data['first_name'] . ' ' . $this->data['last_name']; } return trans('gzero-core::common.anonymous'); }
[ "public", "function", "displayName", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "'name'", "]", ")", "&&", "config", "(", "'gzero.use_users_nicks'", ")", ")", "{", "return", "$", "this", "->", "data", "[", "'name'", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "'first_name'", "]", ")", "||", "isset", "(", "$", "this", "->", "data", "[", "'last_name'", "]", ")", ")", "{", "return", "$", "this", "->", "data", "[", "'first_name'", "]", ".", "' '", ".", "$", "this", "->", "data", "[", "'last_name'", "]", ";", "}", "return", "trans", "(", "'gzero-core::common.anonymous'", ")", ";", "}" ]
Get display name nick or first and last name @return string
[ "Get", "display", "name", "nick", "or", "first", "and", "last", "name" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/ViewModels/UserViewModel.php#L117-L128
7,701
osflab/test
Runner.php
Runner.assert
protected static function assert($condition, string $errorMessage = '', bool $exitOnError = false): bool { self::$totalCount++; self::$count++; if (!$condition) { $trace = debug_backtrace(); $errorPrefix = (isset($trace[1]['class']) ? ($trace[1]['class'] . (isset($trace[1]['function']) ? '::' . $trace[1]['function'] : '') . (isset($trace[1]['line']) ? ' (' . $trace[1]['line'] . ')' : '') . ' -> ') : '') . $trace[0]['class'] . ' (' . $trace[0]['line'] . ")\n "; self::addError($errorPrefix . $errorMessage); self::$totalCountErrors++; if ($exitOnError) { exit; } } return (bool) $condition; }
php
protected static function assert($condition, string $errorMessage = '', bool $exitOnError = false): bool { self::$totalCount++; self::$count++; if (!$condition) { $trace = debug_backtrace(); $errorPrefix = (isset($trace[1]['class']) ? ($trace[1]['class'] . (isset($trace[1]['function']) ? '::' . $trace[1]['function'] : '') . (isset($trace[1]['line']) ? ' (' . $trace[1]['line'] . ')' : '') . ' -> ') : '') . $trace[0]['class'] . ' (' . $trace[0]['line'] . ")\n "; self::addError($errorPrefix . $errorMessage); self::$totalCountErrors++; if ($exitOnError) { exit; } } return (bool) $condition; }
[ "protected", "static", "function", "assert", "(", "$", "condition", ",", "string", "$", "errorMessage", "=", "''", ",", "bool", "$", "exitOnError", "=", "false", ")", ":", "bool", "{", "self", "::", "$", "totalCount", "++", ";", "self", "::", "$", "count", "++", ";", "if", "(", "!", "$", "condition", ")", "{", "$", "trace", "=", "debug_backtrace", "(", ")", ";", "$", "errorPrefix", "=", "(", "isset", "(", "$", "trace", "[", "1", "]", "[", "'class'", "]", ")", "?", "(", "$", "trace", "[", "1", "]", "[", "'class'", "]", ".", "(", "isset", "(", "$", "trace", "[", "1", "]", "[", "'function'", "]", ")", "?", "'::'", ".", "$", "trace", "[", "1", "]", "[", "'function'", "]", ":", "''", ")", ".", "(", "isset", "(", "$", "trace", "[", "1", "]", "[", "'line'", "]", ")", "?", "' ('", ".", "$", "trace", "[", "1", "]", "[", "'line'", "]", ".", "')'", ":", "''", ")", ".", "' -> '", ")", ":", "''", ")", ".", "$", "trace", "[", "0", "]", "[", "'class'", "]", ".", "' ('", ".", "$", "trace", "[", "0", "]", "[", "'line'", "]", ".", "\")\\n \"", ";", "self", "::", "addError", "(", "$", "errorPrefix", ".", "$", "errorMessage", ")", ";", "self", "::", "$", "totalCountErrors", "++", ";", "if", "(", "$", "exitOnError", ")", "{", "exit", ";", "}", "}", "return", "(", "bool", ")", "$", "condition", ";", "}" ]
Simple assert of the test application @param boolean $condition @param string $errorMessage @param boolean $exitOnError @return boolean
[ "Simple", "assert", "of", "the", "test", "application" ]
dca824d071aa7f84195b366ec9cf86ee7a1ec087
https://github.com/osflab/test/blob/dca824d071aa7f84195b366ec9cf86ee7a1ec087/Runner.php#L38-L56
7,702
osflab/test
Runner.php
Runner.assertFalseException
protected static function assertFalseException(\Exception $e): bool { $msg = 'EXCEPTION: ' . $e->getMessage(); $msg .= "\n " . $e->getFile() . ' (' . $e->getLine() . ')'; self::assert(false, $msg); }
php
protected static function assertFalseException(\Exception $e): bool { $msg = 'EXCEPTION: ' . $e->getMessage(); $msg .= "\n " . $e->getFile() . ' (' . $e->getLine() . ')'; self::assert(false, $msg); }
[ "protected", "static", "function", "assertFalseException", "(", "\\", "Exception", "$", "e", ")", ":", "bool", "{", "$", "msg", "=", "'EXCEPTION: '", ".", "$", "e", "->", "getMessage", "(", ")", ";", "$", "msg", ".=", "\"\\n \"", ".", "$", "e", "->", "getFile", "(", ")", ".", "' ('", ".", "$", "e", "->", "getLine", "(", ")", ".", "')'", ";", "self", "::", "assert", "(", "false", ",", "$", "msg", ")", ";", "}" ]
Assert false and display exception @param Exception $e
[ "Assert", "false", "and", "display", "exception" ]
dca824d071aa7f84195b366ec9cf86ee7a1ec087
https://github.com/osflab/test/blob/dca824d071aa7f84195b366ec9cf86ee7a1ec087/Runner.php#L88-L93
7,703
osflab/test
Runner.php
Runner.addError
private static function addError($message): void { if (self::$result === false) { self::$result = array(); } self::$result[] = $message; }
php
private static function addError($message): void { if (self::$result === false) { self::$result = array(); } self::$result[] = $message; }
[ "private", "static", "function", "addError", "(", "$", "message", ")", ":", "void", "{", "if", "(", "self", "::", "$", "result", "===", "false", ")", "{", "self", "::", "$", "result", "=", "array", "(", ")", ";", "}", "self", "::", "$", "result", "[", "]", "=", "$", "message", ";", "}" ]
Add an error in the table @param string $message
[ "Add", "an", "error", "in", "the", "table" ]
dca824d071aa7f84195b366ec9cf86ee7a1ec087
https://github.com/osflab/test/blob/dca824d071aa7f84195b366ec9cf86ee7a1ec087/Runner.php#L125-L131
7,704
osflab/test
Runner.php
Runner.runDirectory
public static function runDirectory( string $path, string $testSuffix = '/Test', ?string $filter = null, ?string $exclude = '/vendor/'): bool { foreach (new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::KEY_AS_PATHNAME), \RecursiveIteratorIterator::CHILD_FIRST) as $file => $info) { if (!preg_match('#^' . $path . '.*' . $testSuffix . '\.php$#', $file) || ($exclude !== null && strpos($file, $exclude) !== false)) { continue; } $matches = []; if (!preg_match('/^.*\nnamespace ([a-zA-Z\\\\]+); *\n.*$/m', file_get_contents($file), $matches)) { trigger_error($file . ' namespace not found'); } $className = '\\' . strtr($matches[1] . '/' . basename($file, '.php'), '/', '\\'); self::runClass($className, $filter); } echo "- " . self::$totalCountFiles . " test file(s), "; echo self::$totalCount . ' tests passed, '; if (self::$totalCountErrors > 0) { echo chr(033) . '[1;31m' . self::$totalCountErrors . ' failed' . chr(033) . '[0;0m'; } else { echo chr(033) . '[1;32msuccess ^^' . chr(033) . '[0;0m'; } echo "\n"; return !self::$totalCountErrors; }
php
public static function runDirectory( string $path, string $testSuffix = '/Test', ?string $filter = null, ?string $exclude = '/vendor/'): bool { foreach (new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::KEY_AS_PATHNAME), \RecursiveIteratorIterator::CHILD_FIRST) as $file => $info) { if (!preg_match('#^' . $path . '.*' . $testSuffix . '\.php$#', $file) || ($exclude !== null && strpos($file, $exclude) !== false)) { continue; } $matches = []; if (!preg_match('/^.*\nnamespace ([a-zA-Z\\\\]+); *\n.*$/m', file_get_contents($file), $matches)) { trigger_error($file . ' namespace not found'); } $className = '\\' . strtr($matches[1] . '/' . basename($file, '.php'), '/', '\\'); self::runClass($className, $filter); } echo "- " . self::$totalCountFiles . " test file(s), "; echo self::$totalCount . ' tests passed, '; if (self::$totalCountErrors > 0) { echo chr(033) . '[1;31m' . self::$totalCountErrors . ' failed' . chr(033) . '[0;0m'; } else { echo chr(033) . '[1;32msuccess ^^' . chr(033) . '[0;0m'; } echo "\n"; return !self::$totalCountErrors; }
[ "public", "static", "function", "runDirectory", "(", "string", "$", "path", ",", "string", "$", "testSuffix", "=", "'/Test'", ",", "?", "string", "$", "filter", "=", "null", ",", "?", "string", "$", "exclude", "=", "'/vendor/'", ")", ":", "bool", "{", "foreach", "(", "new", "\\", "RecursiveIteratorIterator", "(", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "path", ",", "\\", "RecursiveDirectoryIterator", "::", "KEY_AS_PATHNAME", ")", ",", "\\", "RecursiveIteratorIterator", "::", "CHILD_FIRST", ")", "as", "$", "file", "=>", "$", "info", ")", "{", "if", "(", "!", "preg_match", "(", "'#^'", ".", "$", "path", ".", "'.*'", ".", "$", "testSuffix", ".", "'\\.php$#'", ",", "$", "file", ")", "||", "(", "$", "exclude", "!==", "null", "&&", "strpos", "(", "$", "file", ",", "$", "exclude", ")", "!==", "false", ")", ")", "{", "continue", ";", "}", "$", "matches", "=", "[", "]", ";", "if", "(", "!", "preg_match", "(", "'/^.*\\nnamespace ([a-zA-Z\\\\\\\\]+); *\\n.*$/m'", ",", "file_get_contents", "(", "$", "file", ")", ",", "$", "matches", ")", ")", "{", "trigger_error", "(", "$", "file", ".", "' namespace not found'", ")", ";", "}", "$", "className", "=", "'\\\\'", ".", "strtr", "(", "$", "matches", "[", "1", "]", ".", "'/'", ".", "basename", "(", "$", "file", ",", "'.php'", ")", ",", "'/'", ",", "'\\\\'", ")", ";", "self", "::", "runClass", "(", "$", "className", ",", "$", "filter", ")", ";", "}", "echo", "\"- \"", ".", "self", "::", "$", "totalCountFiles", ".", "\" test file(s), \"", ";", "echo", "self", "::", "$", "totalCount", ".", "' tests passed, '", ";", "if", "(", "self", "::", "$", "totalCountErrors", ">", "0", ")", "{", "echo", "chr", "(", "033", ")", ".", "'[1;31m'", ".", "self", "::", "$", "totalCountErrors", ".", "' failed'", ".", "chr", "(", "033", ")", ".", "'[0;0m'", ";", "}", "else", "{", "echo", "chr", "(", "033", ")", ".", "'[1;32msuccess ^^'", ".", "chr", "(", "033", ")", ".", "'[0;0m'", ";", "}", "echo", "\"\\n\"", ";", "return", "!", "self", "::", "$", "totalCountErrors", ";", "}" ]
Run recursively a testsuite in a directory. @param string $path @return boolean
[ "Run", "recursively", "a", "testsuite", "in", "a", "directory", "." ]
dca824d071aa7f84195b366ec9cf86ee7a1ec087
https://github.com/osflab/test/blob/dca824d071aa7f84195b366ec9cf86ee7a1ec087/Runner.php#L148-L179
7,705
osflab/test
Runner.php
Runner.runClass
private static function runClass(string $className, ?string $filter): bool { echo Console::beginActionMessage($className); flush(); if (!is_null($filter) && !preg_match($filter, $className)) { echo Console::endActionSkip(); flush(); return false; } try { $result = call_user_func(array($className, 'run')); } catch (\Exception $e) { $result = array($e->getMessage(), 'Exception catched in the test library :', $e->getFile() . '(' . $e->getLine() . ')'); if (defined('APPLICATION_ENV') && APPLICATION_ENV == 'development') { echo Console::endActionFail(); echo self::exceptionToStr($e); exit; } } if ($result === false) { echo Console::endActionOK(); } else if ($result === true) { echo Console::endActionSkip(); } else { echo Console::endActionFail(); foreach ($result as $line) { echo ' - ' . $line . "\n"; } } flush(); return true; }
php
private static function runClass(string $className, ?string $filter): bool { echo Console::beginActionMessage($className); flush(); if (!is_null($filter) && !preg_match($filter, $className)) { echo Console::endActionSkip(); flush(); return false; } try { $result = call_user_func(array($className, 'run')); } catch (\Exception $e) { $result = array($e->getMessage(), 'Exception catched in the test library :', $e->getFile() . '(' . $e->getLine() . ')'); if (defined('APPLICATION_ENV') && APPLICATION_ENV == 'development') { echo Console::endActionFail(); echo self::exceptionToStr($e); exit; } } if ($result === false) { echo Console::endActionOK(); } else if ($result === true) { echo Console::endActionSkip(); } else { echo Console::endActionFail(); foreach ($result as $line) { echo ' - ' . $line . "\n"; } } flush(); return true; }
[ "private", "static", "function", "runClass", "(", "string", "$", "className", ",", "?", "string", "$", "filter", ")", ":", "bool", "{", "echo", "Console", "::", "beginActionMessage", "(", "$", "className", ")", ";", "flush", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "filter", ")", "&&", "!", "preg_match", "(", "$", "filter", ",", "$", "className", ")", ")", "{", "echo", "Console", "::", "endActionSkip", "(", ")", ";", "flush", "(", ")", ";", "return", "false", ";", "}", "try", "{", "$", "result", "=", "call_user_func", "(", "array", "(", "$", "className", ",", "'run'", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "result", "=", "array", "(", "$", "e", "->", "getMessage", "(", ")", ",", "'Exception catched in the test library :'", ",", "$", "e", "->", "getFile", "(", ")", ".", "'('", ".", "$", "e", "->", "getLine", "(", ")", ".", "')'", ")", ";", "if", "(", "defined", "(", "'APPLICATION_ENV'", ")", "&&", "APPLICATION_ENV", "==", "'development'", ")", "{", "echo", "Console", "::", "endActionFail", "(", ")", ";", "echo", "self", "::", "exceptionToStr", "(", "$", "e", ")", ";", "exit", ";", "}", "}", "if", "(", "$", "result", "===", "false", ")", "{", "echo", "Console", "::", "endActionOK", "(", ")", ";", "}", "else", "if", "(", "$", "result", "===", "true", ")", "{", "echo", "Console", "::", "endActionSkip", "(", ")", ";", "}", "else", "{", "echo", "Console", "::", "endActionFail", "(", ")", ";", "foreach", "(", "$", "result", "as", "$", "line", ")", "{", "echo", "' - '", ".", "$", "line", ".", "\"\\n\"", ";", "}", "}", "flush", "(", ")", ";", "return", "true", ";", "}" ]
Run a single test class @param string $className @param string|null $filter @return bool
[ "Run", "a", "single", "test", "class" ]
dca824d071aa7f84195b366ec9cf86ee7a1ec087
https://github.com/osflab/test/blob/dca824d071aa7f84195b366ec9cf86ee7a1ec087/Runner.php#L187-L220
7,706
mvccore/ext-form
src/MvcCore/Ext/Form/Session.php
Session.&
public function & ClearSession () { /** @var $this \MvcCore\Ext\Forms\IForm */ $this->values = []; $this->errors = []; $session = & $this->getSession(); $session->values = []; $session->csrf = []; $session->errors = []; return $this; }
php
public function & ClearSession () { /** @var $this \MvcCore\Ext\Forms\IForm */ $this->values = []; $this->errors = []; $session = & $this->getSession(); $session->values = []; $session->csrf = []; $session->errors = []; return $this; }
[ "public", "function", "&", "ClearSession", "(", ")", "{", "/** @var $this \\MvcCore\\Ext\\Forms\\IForm */", "$", "this", "->", "values", "=", "[", "]", ";", "$", "this", "->", "errors", "=", "[", "]", ";", "$", "session", "=", "&", "$", "this", "->", "getSession", "(", ")", ";", "$", "session", "->", "values", "=", "[", "]", ";", "$", "session", "->", "csrf", "=", "[", "]", ";", "$", "session", "->", "errors", "=", "[", "]", ";", "return", "$", "this", ";", "}" ]
Clear form values to empty array and clear form values in form session namespace, clear form errors to empty array and clear form errors in form session namespace and clear form CSRF tokens clear CRSF tokens in form session namespace. @return \MvcCore\Ext\Form|\MvcCore\Ext\Forms\IForm
[ "Clear", "form", "values", "to", "empty", "array", "and", "clear", "form", "values", "in", "form", "session", "namespace", "clear", "form", "errors", "to", "empty", "array", "and", "clear", "form", "errors", "in", "form", "session", "namespace", "and", "clear", "form", "CSRF", "tokens", "clear", "CRSF", "tokens", "in", "form", "session", "namespace", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/Session.php#L28-L37
7,707
mvccore/ext-form
src/MvcCore/Ext/Form/Session.php
Session.&
public function & SaveSession () { /** @var $this \MvcCore\Ext\Forms\IForm */ $session = & $this->getSession(); $session->errors = $this->errors; $session->values = $this->values; return $this; }
php
public function & SaveSession () { /** @var $this \MvcCore\Ext\Forms\IForm */ $session = & $this->getSession(); $session->errors = $this->errors; $session->values = $this->values; return $this; }
[ "public", "function", "&", "SaveSession", "(", ")", "{", "/** @var $this \\MvcCore\\Ext\\Forms\\IForm */", "$", "session", "=", "&", "$", "this", "->", "getSession", "(", ")", ";", "$", "session", "->", "errors", "=", "$", "this", "->", "errors", ";", "$", "session", "->", "values", "=", "$", "this", "->", "values", ";", "return", "$", "this", ";", "}" ]
Store form values, form errors and form CSRF tokens in it's own form session namespace. @return \MvcCore\Ext\Form|\MvcCore\Ext\Forms\IForm
[ "Store", "form", "values", "form", "errors", "and", "form", "CSRF", "tokens", "in", "it", "s", "own", "form", "session", "namespace", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/Session.php#L44-L50
7,708
mvccore/ext-form
src/MvcCore/Ext/Form/Session.php
Session.&
protected function & getSession () { if (isset(self::$allFormsSessions[$this->id])) { $sessionNamespace = & self::$allFormsSessions[$this->id]; } else { $sessionClass = self::$sessionClass; $toolClass = self::$toolClass; $formIdPc = $this->id; if (strpos($formIdPc, '-') !== FALSE) $formIdPc = $toolClass::GetPascalCaseFromDashed($formIdPc); if (strpos($formIdPc, '_') !== FALSE) $formIdPc = $toolClass::GetPascalCaseFromUnderscored($formIdPc); $namespaceName = '\\MvcCore\\Ext\\Form\\' . ucfirst($formIdPc); $sessionNamespace = $sessionClass::GetNamespace($namespaceName); // Do not use hoops expiration, because there is better // to set up any large value into session namespace // or zero value to browser close and after rendered // errors just clear the errors. //$sessionNamespace->SetExpirationHoops(1); $sessionNamespace->SetExpirationSeconds($this->sessionExpiration); if (!isset($sessionNamespace->values)) $sessionNamespace->values = []; if (!isset($sessionNamespace->csrf)) $sessionNamespace->csrf = []; if (!isset($sessionNamespace->errors)) $sessionNamespace->errors = []; self::$allFormsSessions[$this->id] = & $sessionNamespace; } return $sessionNamespace; }
php
protected function & getSession () { if (isset(self::$allFormsSessions[$this->id])) { $sessionNamespace = & self::$allFormsSessions[$this->id]; } else { $sessionClass = self::$sessionClass; $toolClass = self::$toolClass; $formIdPc = $this->id; if (strpos($formIdPc, '-') !== FALSE) $formIdPc = $toolClass::GetPascalCaseFromDashed($formIdPc); if (strpos($formIdPc, '_') !== FALSE) $formIdPc = $toolClass::GetPascalCaseFromUnderscored($formIdPc); $namespaceName = '\\MvcCore\\Ext\\Form\\' . ucfirst($formIdPc); $sessionNamespace = $sessionClass::GetNamespace($namespaceName); // Do not use hoops expiration, because there is better // to set up any large value into session namespace // or zero value to browser close and after rendered // errors just clear the errors. //$sessionNamespace->SetExpirationHoops(1); $sessionNamespace->SetExpirationSeconds($this->sessionExpiration); if (!isset($sessionNamespace->values)) $sessionNamespace->values = []; if (!isset($sessionNamespace->csrf)) $sessionNamespace->csrf = []; if (!isset($sessionNamespace->errors)) $sessionNamespace->errors = []; self::$allFormsSessions[$this->id] = & $sessionNamespace; } return $sessionNamespace; }
[ "protected", "function", "&", "getSession", "(", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "allFormsSessions", "[", "$", "this", "->", "id", "]", ")", ")", "{", "$", "sessionNamespace", "=", "&", "self", "::", "$", "allFormsSessions", "[", "$", "this", "->", "id", "]", ";", "}", "else", "{", "$", "sessionClass", "=", "self", "::", "$", "sessionClass", ";", "$", "toolClass", "=", "self", "::", "$", "toolClass", ";", "$", "formIdPc", "=", "$", "this", "->", "id", ";", "if", "(", "strpos", "(", "$", "formIdPc", ",", "'-'", ")", "!==", "FALSE", ")", "$", "formIdPc", "=", "$", "toolClass", "::", "GetPascalCaseFromDashed", "(", "$", "formIdPc", ")", ";", "if", "(", "strpos", "(", "$", "formIdPc", ",", "'_'", ")", "!==", "FALSE", ")", "$", "formIdPc", "=", "$", "toolClass", "::", "GetPascalCaseFromUnderscored", "(", "$", "formIdPc", ")", ";", "$", "namespaceName", "=", "'\\\\MvcCore\\\\Ext\\\\Form\\\\'", ".", "ucfirst", "(", "$", "formIdPc", ")", ";", "$", "sessionNamespace", "=", "$", "sessionClass", "::", "GetNamespace", "(", "$", "namespaceName", ")", ";", "// Do not use hoops expiration, because there is better", "// to set up any large value into session namespace", "// or zero value to browser close and after rendered", "// errors just clear the errors.", "//$sessionNamespace->SetExpirationHoops(1);", "$", "sessionNamespace", "->", "SetExpirationSeconds", "(", "$", "this", "->", "sessionExpiration", ")", ";", "if", "(", "!", "isset", "(", "$", "sessionNamespace", "->", "values", ")", ")", "$", "sessionNamespace", "->", "values", "=", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "sessionNamespace", "->", "csrf", ")", ")", "$", "sessionNamespace", "->", "csrf", "=", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "sessionNamespace", "->", "errors", ")", ")", "$", "sessionNamespace", "->", "errors", "=", "[", "]", ";", "self", "::", "$", "allFormsSessions", "[", "$", "this", "->", "id", "]", "=", "&", "$", "sessionNamespace", ";", "}", "return", "$", "sessionNamespace", ";", "}" ]
Get session namespace reference with configured expiration and predefined fields `values`, `csrf` and `errors` as arrays. @return \MvcCore\ISession
[ "Get", "session", "namespace", "reference", "with", "configured", "expiration", "and", "predefined", "fields", "values", "csrf", "and", "errors", "as", "arrays", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/Session.php#L57-L82
7,709
joomlatools/joomlatools-platform-categories
plugins/finder/categories/categories.php
PlgFinderCategories.onFinderDelete
public function onFinderDelete($context, $table) { if ($context == 'com_categories.category') { $id = $table->id; } elseif ($context == 'com_finder.index') { $id = $table->link_id; } else { return true; } // Remove item from the index. return $this->remove($id); }
php
public function onFinderDelete($context, $table) { if ($context == 'com_categories.category') { $id = $table->id; } elseif ($context == 'com_finder.index') { $id = $table->link_id; } else { return true; } // Remove item from the index. return $this->remove($id); }
[ "public", "function", "onFinderDelete", "(", "$", "context", ",", "$", "table", ")", "{", "if", "(", "$", "context", "==", "'com_categories.category'", ")", "{", "$", "id", "=", "$", "table", "->", "id", ";", "}", "elseif", "(", "$", "context", "==", "'com_finder.index'", ")", "{", "$", "id", "=", "$", "table", "->", "link_id", ";", "}", "else", "{", "return", "true", ";", "}", "// Remove item from the index.", "return", "$", "this", "->", "remove", "(", "$", "id", ")", ";", "}" ]
Method to remove the link information for items that have been deleted. @param string $context The context of the action being performed. @param JTable $table A JTable object containing the record to be deleted @return boolean True on success. @since 2.5 @throws Exception on database error.
[ "Method", "to", "remove", "the", "link", "information", "for", "items", "that", "have", "been", "deleted", "." ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/plugins/finder/categories/categories.php#L90-L107
7,710
joomlatools/joomlatools-platform-categories
plugins/finder/categories/categories.php
PlgFinderCategories.onFinderAfterSave
public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle categories here. if ($context == 'com_categories.category') { // Check if the access levels are different. if (!$isNew && $this->old_access != $row->access) { // Process the change. $this->itemAccessChange($row); } // Reindex the category item. $this->reindex($row->id); // Check if the parent access level is different. if (!$isNew && $this->old_cataccess != $row->access) { $this->categoryAccessChange($row); } } return true; }
php
public function onFinderAfterSave($context, $row, $isNew) { // We only want to handle categories here. if ($context == 'com_categories.category') { // Check if the access levels are different. if (!$isNew && $this->old_access != $row->access) { // Process the change. $this->itemAccessChange($row); } // Reindex the category item. $this->reindex($row->id); // Check if the parent access level is different. if (!$isNew && $this->old_cataccess != $row->access) { $this->categoryAccessChange($row); } } return true; }
[ "public", "function", "onFinderAfterSave", "(", "$", "context", ",", "$", "row", ",", "$", "isNew", ")", "{", "// We only want to handle categories here.", "if", "(", "$", "context", "==", "'com_categories.category'", ")", "{", "// Check if the access levels are different.", "if", "(", "!", "$", "isNew", "&&", "$", "this", "->", "old_access", "!=", "$", "row", "->", "access", ")", "{", "// Process the change.", "$", "this", "->", "itemAccessChange", "(", "$", "row", ")", ";", "}", "// Reindex the category item.", "$", "this", "->", "reindex", "(", "$", "row", "->", "id", ")", ";", "// Check if the parent access level is different.", "if", "(", "!", "$", "isNew", "&&", "$", "this", "->", "old_cataccess", "!=", "$", "row", "->", "access", ")", "{", "$", "this", "->", "categoryAccessChange", "(", "$", "row", ")", ";", "}", "}", "return", "true", ";", "}" ]
Smart Search after save content method. Reindexes the link information for a category that has been saved. It also makes adjustments if the access level of the category has changed. @param string $context The context of the category passed to the plugin. @param JTable $row A JTable object. @param boolean $isNew True if the category has just been created. @return boolean True on success. @since 2.5 @throws Exception on database error.
[ "Smart", "Search", "after", "save", "content", "method", ".", "Reindexes", "the", "link", "information", "for", "a", "category", "that", "has", "been", "saved", ".", "It", "also", "makes", "adjustments", "if", "the", "access", "level", "of", "the", "category", "has", "changed", "." ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/plugins/finder/categories/categories.php#L123-L146
7,711
joomlatools/joomlatools-platform-categories
plugins/finder/categories/categories.php
PlgFinderCategories.onFinderBeforeSave
public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle categories here. if ($context == 'com_categories.category') { // Query the database for the old access level and the parent if the item isn't new. if (!$isNew) { $this->checkItemAccess($row); $this->checkCategoryAccess($row); } } return true; }
php
public function onFinderBeforeSave($context, $row, $isNew) { // We only want to handle categories here. if ($context == 'com_categories.category') { // Query the database for the old access level and the parent if the item isn't new. if (!$isNew) { $this->checkItemAccess($row); $this->checkCategoryAccess($row); } } return true; }
[ "public", "function", "onFinderBeforeSave", "(", "$", "context", ",", "$", "row", ",", "$", "isNew", ")", "{", "// We only want to handle categories here.", "if", "(", "$", "context", "==", "'com_categories.category'", ")", "{", "// Query the database for the old access level and the parent if the item isn't new.", "if", "(", "!", "$", "isNew", ")", "{", "$", "this", "->", "checkItemAccess", "(", "$", "row", ")", ";", "$", "this", "->", "checkCategoryAccess", "(", "$", "row", ")", ";", "}", "}", "return", "true", ";", "}" ]
Smart Search before content save method. This event is fired before the data is actually saved. @param string $context The context of the category passed to the plugin. @param JTable $row A JTable object. @param boolean $isNew True if the category is just about to be created. @return boolean True on success. @since 2.5 @throws Exception on database error.
[ "Smart", "Search", "before", "content", "save", "method", ".", "This", "event", "is", "fired", "before", "the", "data", "is", "actually", "saved", "." ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/plugins/finder/categories/categories.php#L161-L175
7,712
joomlatools/joomlatools-platform-categories
plugins/finder/categories/categories.php
PlgFinderCategories.onFinderChangeState
public function onFinderChangeState($context, $pks, $value) { // We only want to handle categories here. if ($context == 'com_categories.category') { /* * The category published state is tied to the parent category * published state so we need to look up all published states * before we change anything. */ foreach ($pks as $pk) { $query = clone $this->getStateQuery(); $query->where('a.id = ' . (int) $pk); $this->db->setQuery($query); $item = $this->db->loadObject(); // Translate the state. $state = null; if ($item->parent_id != 1) { $state = $item->cat_state; } $temp = $this->translateState($value, $state); // Update the item. $this->change($pk, 'state', $temp); // Reindex the item. $this->reindex($pk); } } // Handle when the plugin is disabled. if ($context == 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } }
php
public function onFinderChangeState($context, $pks, $value) { // We only want to handle categories here. if ($context == 'com_categories.category') { /* * The category published state is tied to the parent category * published state so we need to look up all published states * before we change anything. */ foreach ($pks as $pk) { $query = clone $this->getStateQuery(); $query->where('a.id = ' . (int) $pk); $this->db->setQuery($query); $item = $this->db->loadObject(); // Translate the state. $state = null; if ($item->parent_id != 1) { $state = $item->cat_state; } $temp = $this->translateState($value, $state); // Update the item. $this->change($pk, 'state', $temp); // Reindex the item. $this->reindex($pk); } } // Handle when the plugin is disabled. if ($context == 'com_plugins.plugin' && $value === 0) { $this->pluginDisable($pks); } }
[ "public", "function", "onFinderChangeState", "(", "$", "context", ",", "$", "pks", ",", "$", "value", ")", "{", "// We only want to handle categories here.", "if", "(", "$", "context", "==", "'com_categories.category'", ")", "{", "/*\n\t\t\t * The category published state is tied to the parent category\n\t\t\t * published state so we need to look up all published states\n\t\t\t * before we change anything.\n\t\t\t */", "foreach", "(", "$", "pks", "as", "$", "pk", ")", "{", "$", "query", "=", "clone", "$", "this", "->", "getStateQuery", "(", ")", ";", "$", "query", "->", "where", "(", "'a.id = '", ".", "(", "int", ")", "$", "pk", ")", ";", "$", "this", "->", "db", "->", "setQuery", "(", "$", "query", ")", ";", "$", "item", "=", "$", "this", "->", "db", "->", "loadObject", "(", ")", ";", "// Translate the state.", "$", "state", "=", "null", ";", "if", "(", "$", "item", "->", "parent_id", "!=", "1", ")", "{", "$", "state", "=", "$", "item", "->", "cat_state", ";", "}", "$", "temp", "=", "$", "this", "->", "translateState", "(", "$", "value", ",", "$", "state", ")", ";", "// Update the item.", "$", "this", "->", "change", "(", "$", "pk", ",", "'state'", ",", "$", "temp", ")", ";", "// Reindex the item.", "$", "this", "->", "reindex", "(", "$", "pk", ")", ";", "}", "}", "// Handle when the plugin is disabled.", "if", "(", "$", "context", "==", "'com_plugins.plugin'", "&&", "$", "value", "===", "0", ")", "{", "$", "this", "->", "pluginDisable", "(", "$", "pks", ")", ";", "}", "}" ]
Method to update the link information for items that have been changed from outside the edit screen. This is fired when the item is published, unpublished, archived, or unarchived from the list view. @param string $context The context for the category passed to the plugin. @param array $pks An array of primary key ids of the category that has changed state. @param integer $value The value of the state that the category has been changed to. @return void @since 2.5
[ "Method", "to", "update", "the", "link", "information", "for", "items", "that", "have", "been", "changed", "from", "outside", "the", "edit", "screen", ".", "This", "is", "fired", "when", "the", "item", "is", "published", "unpublished", "archived", "or", "unarchived", "from", "the", "list", "view", "." ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/plugins/finder/categories/categories.php#L190-L231
7,713
joomlatools/joomlatools-platform-categories
plugins/finder/categories/categories.php
PlgFinderCategories.index
protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled. if (JComponentHelper::isEnabled($this->extension) == false) { return; } $item->setLanguage(); // Need to import component route helpers dynamically, hence the reason it's handled here. $path = JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php'; if (is_file($path)) { include_once $path; } $extension = ucfirst(substr($item->extension, 4)); // Initialize the item parameters. $registry = new Registry; $registry->loadString($item->params); $item->params = $registry; $registry = new Registry; $registry->loadString($item->metadata); $item->metadata = $registry; /* * Add the metadata processing instructions based on the category's * configuration parameters. */ // Add the meta author. $item->metaauthor = $item->metadata->get('author'); // Handle the link to the metadata. $item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); // Deactivated Methods // $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); // Trigger the onContentPrepare event. $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params); // Build the necessary route and path information. $item->url = $this->getUrl($item->id, $item->extension, $this->layout); $class = $extension . 'HelperRoute'; if (class_exists($class) && method_exists($class, 'getCategoryRoute')) { $item->route = $class::getCategoryRoute($item->id, $item->language); } else { $item->route = ContentHelperRoute::getCategoryRoute($item->id, $item->language); } $item->path = FinderIndexerHelper::getContentPath($item->route); // Get the menu title if it exists. $title = $this->getItemMenuTitle($item->url); // Adjust the title if necessary. if (!empty($title) && $this->params->get('use_menu_title', true)) { $item->title = $title; } // Translate the state. Categories should only be published if the parent category is published. $item->state = $this->translateState($item->state); // Add the type taxonomy data. $item->addTaxonomy('Type', 'Category'); // Add the language taxonomy data. $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. $this->indexer->index($item); }
php
protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled. if (JComponentHelper::isEnabled($this->extension) == false) { return; } $item->setLanguage(); // Need to import component route helpers dynamically, hence the reason it's handled here. $path = JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php'; if (is_file($path)) { include_once $path; } $extension = ucfirst(substr($item->extension, 4)); // Initialize the item parameters. $registry = new Registry; $registry->loadString($item->params); $item->params = $registry; $registry = new Registry; $registry->loadString($item->metadata); $item->metadata = $registry; /* * Add the metadata processing instructions based on the category's * configuration parameters. */ // Add the meta author. $item->metaauthor = $item->metadata->get('author'); // Handle the link to the metadata. $item->addInstruction(FinderIndexer::META_CONTEXT, 'link'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); // Deactivated Methods // $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias'); // Trigger the onContentPrepare event. $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params); // Build the necessary route and path information. $item->url = $this->getUrl($item->id, $item->extension, $this->layout); $class = $extension . 'HelperRoute'; if (class_exists($class) && method_exists($class, 'getCategoryRoute')) { $item->route = $class::getCategoryRoute($item->id, $item->language); } else { $item->route = ContentHelperRoute::getCategoryRoute($item->id, $item->language); } $item->path = FinderIndexerHelper::getContentPath($item->route); // Get the menu title if it exists. $title = $this->getItemMenuTitle($item->url); // Adjust the title if necessary. if (!empty($title) && $this->params->get('use_menu_title', true)) { $item->title = $title; } // Translate the state. Categories should only be published if the parent category is published. $item->state = $this->translateState($item->state); // Add the type taxonomy data. $item->addTaxonomy('Type', 'Category'); // Add the language taxonomy data. $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. $this->indexer->index($item); }
[ "protected", "function", "index", "(", "FinderIndexerResult", "$", "item", ",", "$", "format", "=", "'html'", ")", "{", "// Check if the extension is enabled.", "if", "(", "JComponentHelper", "::", "isEnabled", "(", "$", "this", "->", "extension", ")", "==", "false", ")", "{", "return", ";", "}", "$", "item", "->", "setLanguage", "(", ")", ";", "// Need to import component route helpers dynamically, hence the reason it's handled here.", "$", "path", "=", "JPATH_SITE", ".", "'/components/'", ".", "$", "item", "->", "extension", ".", "'/helpers/route.php'", ";", "if", "(", "is_file", "(", "$", "path", ")", ")", "{", "include_once", "$", "path", ";", "}", "$", "extension", "=", "ucfirst", "(", "substr", "(", "$", "item", "->", "extension", ",", "4", ")", ")", ";", "// Initialize the item parameters.", "$", "registry", "=", "new", "Registry", ";", "$", "registry", "->", "loadString", "(", "$", "item", "->", "params", ")", ";", "$", "item", "->", "params", "=", "$", "registry", ";", "$", "registry", "=", "new", "Registry", ";", "$", "registry", "->", "loadString", "(", "$", "item", "->", "metadata", ")", ";", "$", "item", "->", "metadata", "=", "$", "registry", ";", "/*\n\t\t * Add the metadata processing instructions based on the category's\n\t\t * configuration parameters.\n\t\t */", "// Add the meta author.", "$", "item", "->", "metaauthor", "=", "$", "item", "->", "metadata", "->", "get", "(", "'author'", ")", ";", "// Handle the link to the metadata.", "$", "item", "->", "addInstruction", "(", "FinderIndexer", "::", "META_CONTEXT", ",", "'link'", ")", ";", "$", "item", "->", "addInstruction", "(", "FinderIndexer", "::", "META_CONTEXT", ",", "'metakey'", ")", ";", "$", "item", "->", "addInstruction", "(", "FinderIndexer", "::", "META_CONTEXT", ",", "'metadesc'", ")", ";", "$", "item", "->", "addInstruction", "(", "FinderIndexer", "::", "META_CONTEXT", ",", "'metaauthor'", ")", ";", "$", "item", "->", "addInstruction", "(", "FinderIndexer", "::", "META_CONTEXT", ",", "'author'", ")", ";", "// Deactivated Methods", "// $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');", "// Trigger the onContentPrepare event.", "$", "item", "->", "summary", "=", "FinderIndexerHelper", "::", "prepareContent", "(", "$", "item", "->", "summary", ",", "$", "item", "->", "params", ")", ";", "// Build the necessary route and path information.", "$", "item", "->", "url", "=", "$", "this", "->", "getUrl", "(", "$", "item", "->", "id", ",", "$", "item", "->", "extension", ",", "$", "this", "->", "layout", ")", ";", "$", "class", "=", "$", "extension", ".", "'HelperRoute'", ";", "if", "(", "class_exists", "(", "$", "class", ")", "&&", "method_exists", "(", "$", "class", ",", "'getCategoryRoute'", ")", ")", "{", "$", "item", "->", "route", "=", "$", "class", "::", "getCategoryRoute", "(", "$", "item", "->", "id", ",", "$", "item", "->", "language", ")", ";", "}", "else", "{", "$", "item", "->", "route", "=", "ContentHelperRoute", "::", "getCategoryRoute", "(", "$", "item", "->", "id", ",", "$", "item", "->", "language", ")", ";", "}", "$", "item", "->", "path", "=", "FinderIndexerHelper", "::", "getContentPath", "(", "$", "item", "->", "route", ")", ";", "// Get the menu title if it exists.", "$", "title", "=", "$", "this", "->", "getItemMenuTitle", "(", "$", "item", "->", "url", ")", ";", "// Adjust the title if necessary.", "if", "(", "!", "empty", "(", "$", "title", ")", "&&", "$", "this", "->", "params", "->", "get", "(", "'use_menu_title'", ",", "true", ")", ")", "{", "$", "item", "->", "title", "=", "$", "title", ";", "}", "// Translate the state. Categories should only be published if the parent category is published.", "$", "item", "->", "state", "=", "$", "this", "->", "translateState", "(", "$", "item", "->", "state", ")", ";", "// Add the type taxonomy data.", "$", "item", "->", "addTaxonomy", "(", "'Type'", ",", "'Category'", ")", ";", "// Add the language taxonomy data.", "$", "item", "->", "addTaxonomy", "(", "'Language'", ",", "$", "item", "->", "language", ")", ";", "// Get content extras.", "FinderIndexerHelper", "::", "getContentExtras", "(", "$", "item", ")", ";", "// Index the item.", "$", "this", "->", "indexer", "->", "index", "(", "$", "item", ")", ";", "}" ]
Method to index an item. The item must be a FinderIndexerResult object. @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. @param string $format The item format. Not used. @return void @since 2.5 @throws Exception on database error.
[ "Method", "to", "index", "an", "item", ".", "The", "item", "must", "be", "a", "FinderIndexerResult", "object", "." ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/plugins/finder/categories/categories.php#L244-L332
7,714
joomlatools/joomlatools-platform-categories
plugins/finder/categories/categories.php
PlgFinderCategories.getListQuery
protected function getListQuery($query = null) { $db = JFactory::getDbo(); // Check if we can use the supplied SQL query. $query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true) ->select('a.id, a.title, a.alias, a.description AS summary, a.extension') ->select('a.created_user_id AS created_by, a.modified_time AS modified, a.modified_user_id AS modified_by') ->select('a.metakey, a.metadesc, a.metadata, a.language, a.lft, a.parent_id, a.level') ->select('a.created_time AS start_date, a.published AS state, a.access, a.params'); // Handle the alias CASE WHEN portion of the query. $case_when_item_alias = ' CASE WHEN '; $case_when_item_alias .= $query->charLength('a.alias', '!=', '0'); $case_when_item_alias .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when_item_alias .= ' ELSE '; $case_when_item_alias .= $a_id . ' END as slug'; $query->select($case_when_item_alias) ->from('#__categories AS a') ->where($db->quoteName('a.id') . ' > 1'); return $query; }
php
protected function getListQuery($query = null) { $db = JFactory::getDbo(); // Check if we can use the supplied SQL query. $query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true) ->select('a.id, a.title, a.alias, a.description AS summary, a.extension') ->select('a.created_user_id AS created_by, a.modified_time AS modified, a.modified_user_id AS modified_by') ->select('a.metakey, a.metadesc, a.metadata, a.language, a.lft, a.parent_id, a.level') ->select('a.created_time AS start_date, a.published AS state, a.access, a.params'); // Handle the alias CASE WHEN portion of the query. $case_when_item_alias = ' CASE WHEN '; $case_when_item_alias .= $query->charLength('a.alias', '!=', '0'); $case_when_item_alias .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when_item_alias .= ' ELSE '; $case_when_item_alias .= $a_id . ' END as slug'; $query->select($case_when_item_alias) ->from('#__categories AS a') ->where($db->quoteName('a.id') . ' > 1'); return $query; }
[ "protected", "function", "getListQuery", "(", "$", "query", "=", "null", ")", "{", "$", "db", "=", "JFactory", "::", "getDbo", "(", ")", ";", "// Check if we can use the supplied SQL query.", "$", "query", "=", "$", "query", "instanceof", "JDatabaseQuery", "?", "$", "query", ":", "$", "db", "->", "getQuery", "(", "true", ")", "->", "select", "(", "'a.id, a.title, a.alias, a.description AS summary, a.extension'", ")", "->", "select", "(", "'a.created_user_id AS created_by, a.modified_time AS modified, a.modified_user_id AS modified_by'", ")", "->", "select", "(", "'a.metakey, a.metadesc, a.metadata, a.language, a.lft, a.parent_id, a.level'", ")", "->", "select", "(", "'a.created_time AS start_date, a.published AS state, a.access, a.params'", ")", ";", "// Handle the alias CASE WHEN portion of the query.", "$", "case_when_item_alias", "=", "' CASE WHEN '", ";", "$", "case_when_item_alias", ".=", "$", "query", "->", "charLength", "(", "'a.alias'", ",", "'!='", ",", "'0'", ")", ";", "$", "case_when_item_alias", ".=", "' THEN '", ";", "$", "a_id", "=", "$", "query", "->", "castAsChar", "(", "'a.id'", ")", ";", "$", "case_when_item_alias", ".=", "$", "query", "->", "concatenate", "(", "array", "(", "$", "a_id", ",", "'a.alias'", ")", ",", "':'", ")", ";", "$", "case_when_item_alias", ".=", "' ELSE '", ";", "$", "case_when_item_alias", ".=", "$", "a_id", ".", "' END as slug'", ";", "$", "query", "->", "select", "(", "$", "case_when_item_alias", ")", "->", "from", "(", "'#__categories AS a'", ")", "->", "where", "(", "$", "db", "->", "quoteName", "(", "'a.id'", ")", ".", "' > 1'", ")", ";", "return", "$", "query", ";", "}" ]
Method to get the SQL query used to retrieve the list of content items. @param mixed $query A JDatabaseQuery object or null. @return JDatabaseQuery A database object. @since 2.5
[ "Method", "to", "get", "the", "SQL", "query", "used", "to", "retrieve", "the", "list", "of", "content", "items", "." ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/plugins/finder/categories/categories.php#L358-L382
7,715
joomlatools/joomlatools-platform-categories
plugins/finder/categories/categories.php
PlgFinderCategories.getStateQuery
protected function getStateQuery() { $query = $this->db->getQuery(true) ->select($this->db->quoteName('a.id')) ->select($this->db->quoteName('a.parent_id')) ->select('a.' . $this->state_field . ' AS state, c.published AS cat_state') ->select('a.access, c.access AS cat_access') ->from($this->db->quoteName('#__categories') . ' AS a') ->join('LEFT', '#__categories AS c ON c.id = a.parent_id'); return $query; }
php
protected function getStateQuery() { $query = $this->db->getQuery(true) ->select($this->db->quoteName('a.id')) ->select($this->db->quoteName('a.parent_id')) ->select('a.' . $this->state_field . ' AS state, c.published AS cat_state') ->select('a.access, c.access AS cat_access') ->from($this->db->quoteName('#__categories') . ' AS a') ->join('LEFT', '#__categories AS c ON c.id = a.parent_id'); return $query; }
[ "protected", "function", "getStateQuery", "(", ")", "{", "$", "query", "=", "$", "this", "->", "db", "->", "getQuery", "(", "true", ")", "->", "select", "(", "$", "this", "->", "db", "->", "quoteName", "(", "'a.id'", ")", ")", "->", "select", "(", "$", "this", "->", "db", "->", "quoteName", "(", "'a.parent_id'", ")", ")", "->", "select", "(", "'a.'", ".", "$", "this", "->", "state_field", ".", "' AS state, c.published AS cat_state'", ")", "->", "select", "(", "'a.access, c.access AS cat_access'", ")", "->", "from", "(", "$", "this", "->", "db", "->", "quoteName", "(", "'#__categories'", ")", ".", "' AS a'", ")", "->", "join", "(", "'LEFT'", ",", "'#__categories AS c ON c.id = a.parent_id'", ")", ";", "return", "$", "query", ";", "}" ]
Method to get a SQL query to load the published and access states for a category and its parents. @return JDatabaseQuery A database object. @since 2.5
[ "Method", "to", "get", "a", "SQL", "query", "to", "load", "the", "published", "and", "access", "states", "for", "a", "category", "and", "its", "parents", "." ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/plugins/finder/categories/categories.php#L392-L403
7,716
iriber/cose
src/main/php/Cose/utils/ClassLoader.php
ClassLoader.classExists
public static function classExists($className) { if (class_exists($className, false) || interface_exists($className, false)) { return true; } foreach (spl_autoload_functions() as $loader) { if (is_array($loader)) { // array(???, ???) if (is_object($loader[0])) { if ($loader[0] instanceof ClassLoader) { // array($obj, 'methodName') if ($loader[0]->canLoadClass($className)) { return true; } } else if ($loader[0]->{$loader[1]}($className)) { return true; } } else if ($loader[0]::$loader[1]($className)) { // array('ClassName', 'methodName') return true; } } else if ($loader instanceof \Closure) { // function($className) {..} if ($loader($className)) { return true; } } else if (is_string($loader) && $loader($className)) { // "MyClass::loadClass" return true; } } return class_exists($className, false) || interface_exists($className, false); }
php
public static function classExists($className) { if (class_exists($className, false) || interface_exists($className, false)) { return true; } foreach (spl_autoload_functions() as $loader) { if (is_array($loader)) { // array(???, ???) if (is_object($loader[0])) { if ($loader[0] instanceof ClassLoader) { // array($obj, 'methodName') if ($loader[0]->canLoadClass($className)) { return true; } } else if ($loader[0]->{$loader[1]}($className)) { return true; } } else if ($loader[0]::$loader[1]($className)) { // array('ClassName', 'methodName') return true; } } else if ($loader instanceof \Closure) { // function($className) {..} if ($loader($className)) { return true; } } else if (is_string($loader) && $loader($className)) { // "MyClass::loadClass" return true; } } return class_exists($className, false) || interface_exists($className, false); }
[ "public", "static", "function", "classExists", "(", "$", "className", ")", "{", "if", "(", "class_exists", "(", "$", "className", ",", "false", ")", "||", "interface_exists", "(", "$", "className", ",", "false", ")", ")", "{", "return", "true", ";", "}", "foreach", "(", "spl_autoload_functions", "(", ")", "as", "$", "loader", ")", "{", "if", "(", "is_array", "(", "$", "loader", ")", ")", "{", "// array(???, ???)\r", "if", "(", "is_object", "(", "$", "loader", "[", "0", "]", ")", ")", "{", "if", "(", "$", "loader", "[", "0", "]", "instanceof", "ClassLoader", ")", "{", "// array($obj, 'methodName')\r", "if", "(", "$", "loader", "[", "0", "]", "->", "canLoadClass", "(", "$", "className", ")", ")", "{", "return", "true", ";", "}", "}", "else", "if", "(", "$", "loader", "[", "0", "]", "->", "{", "$", "loader", "[", "1", "]", "}", "(", "$", "className", ")", ")", "{", "return", "true", ";", "}", "}", "else", "if", "(", "$", "loader", "[", "0", "]", "::", "$", "loader", "[", "1", "]", "(", "$", "className", ")", ")", "{", "// array('ClassName', 'methodName')\r", "return", "true", ";", "}", "}", "else", "if", "(", "$", "loader", "instanceof", "\\", "Closure", ")", "{", "// function($className) {..}\r", "if", "(", "$", "loader", "(", "$", "className", ")", ")", "{", "return", "true", ";", "}", "}", "else", "if", "(", "is_string", "(", "$", "loader", ")", "&&", "$", "loader", "(", "$", "className", ")", ")", "{", "// \"MyClass::loadClass\"\r", "return", "true", ";", "}", "}", "return", "class_exists", "(", "$", "className", ",", "false", ")", "||", "interface_exists", "(", "$", "className", ",", "false", ")", ";", "}" ]
Checks whether a class with a given name exists. A class "exists" if it is either already defined in the current request or if there is an autoloader on the SPL autoload stack that is a) responsible for the class in question and b) is able to load a class file in which the class definition resides. If the class is not already defined, each autoloader in the SPL autoload stack is asked whether it is able to tell if the class exists. If the autoloader is a <tt>ClassLoader</tt>, {@link canLoadClass} is used, otherwise the autoload function of the autoloader is invoked and expected to return a value that evaluates to TRUE if the class (file) exists. As soon as one autoloader reports that the class exists, TRUE is returned. Note that, depending on what kinds of autoloaders are installed on the SPL autoload stack, the class (file) might already be loaded as a result of checking for its existence. This is not the case with a <tt>ClassLoader</tt>, who separates these responsibilities. @param string $className The fully-qualified name of the class. @return boolean TRUE if the class exists as per the definition given above, FALSE otherwise.
[ "Checks", "whether", "a", "class", "with", "a", "given", "name", "exists", ".", "A", "class", "exists", "if", "it", "is", "either", "already", "defined", "in", "the", "current", "request", "or", "if", "there", "is", "an", "autoloader", "on", "the", "SPL", "autoload", "stack", "that", "is", "a", ")", "responsible", "for", "the", "class", "in", "question", "and", "b", ")", "is", "able", "to", "load", "a", "class", "file", "in", "which", "the", "class", "definition", "resides", "." ]
291ea274a86017bac173fdc7bfcd4fb13419679e
https://github.com/iriber/cose/blob/291ea274a86017bac173fdc7bfcd4fb13419679e/src/main/php/Cose/utils/ClassLoader.php#L189-L218
7,717
Rehyved/php-utilities
src/Rehyved/Utilities/Mapper/ObjectMapper.php
ObjectMapper.mapObjectToArray
public function mapObjectToArray($object, string $prefix = "") { if (!is_object($object)) { return $object; } if (get_class($object) === \stdClass::class) { return (array)$object; } $objectClass = new \ReflectionClass($object); $objectProperties = $this->getObjectProperties($objectClass); $array = array(); foreach ($objectProperties as $property) { if ($property->getGetter() == null && !$property->isPublic()) { continue; } $value = $this->getValue($object, $property); if ($value === null) { continue; } $propertyName = $property->getName(); $annotations = $property->getAnnotations(); $propertyKey = empty($prefix) ? $propertyName : $prefix . self::PATH_DELIMITER . $propertyName; if (is_array($value) && array_key_exists(TypeValidator::ANNOTATION, $annotations) && TypeHelper::isTypedArrayType($annotations[TypeValidator::ANNOTATION]) ) { $items = array(); foreach ($value as $index => $item) { $items[] = $this->mapObjectToArray($item); } $array[$propertyKey] = $items; } else { $array[$propertyKey] = $this->mapObjectToArray($value); } } return $array; }
php
public function mapObjectToArray($object, string $prefix = "") { if (!is_object($object)) { return $object; } if (get_class($object) === \stdClass::class) { return (array)$object; } $objectClass = new \ReflectionClass($object); $objectProperties = $this->getObjectProperties($objectClass); $array = array(); foreach ($objectProperties as $property) { if ($property->getGetter() == null && !$property->isPublic()) { continue; } $value = $this->getValue($object, $property); if ($value === null) { continue; } $propertyName = $property->getName(); $annotations = $property->getAnnotations(); $propertyKey = empty($prefix) ? $propertyName : $prefix . self::PATH_DELIMITER . $propertyName; if (is_array($value) && array_key_exists(TypeValidator::ANNOTATION, $annotations) && TypeHelper::isTypedArrayType($annotations[TypeValidator::ANNOTATION]) ) { $items = array(); foreach ($value as $index => $item) { $items[] = $this->mapObjectToArray($item); } $array[$propertyKey] = $items; } else { $array[$propertyKey] = $this->mapObjectToArray($value); } } return $array; }
[ "public", "function", "mapObjectToArray", "(", "$", "object", ",", "string", "$", "prefix", "=", "\"\"", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "return", "$", "object", ";", "}", "if", "(", "get_class", "(", "$", "object", ")", "===", "\\", "stdClass", "::", "class", ")", "{", "return", "(", "array", ")", "$", "object", ";", "}", "$", "objectClass", "=", "new", "\\", "ReflectionClass", "(", "$", "object", ")", ";", "$", "objectProperties", "=", "$", "this", "->", "getObjectProperties", "(", "$", "objectClass", ")", ";", "$", "array", "=", "array", "(", ")", ";", "foreach", "(", "$", "objectProperties", "as", "$", "property", ")", "{", "if", "(", "$", "property", "->", "getGetter", "(", ")", "==", "null", "&&", "!", "$", "property", "->", "isPublic", "(", ")", ")", "{", "continue", ";", "}", "$", "value", "=", "$", "this", "->", "getValue", "(", "$", "object", ",", "$", "property", ")", ";", "if", "(", "$", "value", "===", "null", ")", "{", "continue", ";", "}", "$", "propertyName", "=", "$", "property", "->", "getName", "(", ")", ";", "$", "annotations", "=", "$", "property", "->", "getAnnotations", "(", ")", ";", "$", "propertyKey", "=", "empty", "(", "$", "prefix", ")", "?", "$", "propertyName", ":", "$", "prefix", ".", "self", "::", "PATH_DELIMITER", ".", "$", "propertyName", ";", "if", "(", "is_array", "(", "$", "value", ")", "&&", "array_key_exists", "(", "TypeValidator", "::", "ANNOTATION", ",", "$", "annotations", ")", "&&", "TypeHelper", "::", "isTypedArrayType", "(", "$", "annotations", "[", "TypeValidator", "::", "ANNOTATION", "]", ")", ")", "{", "$", "items", "=", "array", "(", ")", ";", "foreach", "(", "$", "value", "as", "$", "index", "=>", "$", "item", ")", "{", "$", "items", "[", "]", "=", "$", "this", "->", "mapObjectToArray", "(", "$", "item", ")", ";", "}", "$", "array", "[", "$", "propertyKey", "]", "=", "$", "items", ";", "}", "else", "{", "$", "array", "[", "$", "propertyKey", "]", "=", "$", "this", "->", "mapObjectToArray", "(", "$", "value", ")", ";", "}", "}", "return", "$", "array", ";", "}" ]
Maps the provided object to an array or returns the provided object if it was of a built-in primitive type By using the 'arrayOf' annotation in the object's class for properties of type array the mapper will map these to arrays recursively. @param mixed $object The object to map to an array @param string $prefix with which the array keys should be prefixed i.e. the name of the object/variable passed @return mixed either an array containing the properties of the object or the provided object if it had a built-in primitive type
[ "Maps", "the", "provided", "object", "to", "an", "array", "or", "returns", "the", "provided", "object", "if", "it", "was", "of", "a", "built", "-", "in", "primitive", "type" ]
fae3754576eab4cf33ad99c5143aa1f972c325bd
https://github.com/Rehyved/php-utilities/blob/fae3754576eab4cf33ad99c5143aa1f972c325bd/src/Rehyved/Utilities/Mapper/ObjectMapper.php#L287-L331
7,718
LaBlog/LaBlog
src/Lablog/Lablog/Post/JsonPostConfig.php
JsonPostConfig.strip
public function strip($postContent, $wrap) { $pattern = '/'.$wrap.'(.*?)'.$wrap.'/s'; $match = preg_match($pattern, $postContent, $matches); if ($match) { $post['config'] = $matches[1]; $post['content'] = str_replace($matches[0], '', $postContent); return $post; } return array('config' => '', 'content' => $postContent); }
php
public function strip($postContent, $wrap) { $pattern = '/'.$wrap.'(.*?)'.$wrap.'/s'; $match = preg_match($pattern, $postContent, $matches); if ($match) { $post['config'] = $matches[1]; $post['content'] = str_replace($matches[0], '', $postContent); return $post; } return array('config' => '', 'content' => $postContent); }
[ "public", "function", "strip", "(", "$", "postContent", ",", "$", "wrap", ")", "{", "$", "pattern", "=", "'/'", ".", "$", "wrap", ".", "'(.*?)'", ".", "$", "wrap", ".", "'/s'", ";", "$", "match", "=", "preg_match", "(", "$", "pattern", ",", "$", "postContent", ",", "$", "matches", ")", ";", "if", "(", "$", "match", ")", "{", "$", "post", "[", "'config'", "]", "=", "$", "matches", "[", "1", "]", ";", "$", "post", "[", "'content'", "]", "=", "str_replace", "(", "$", "matches", "[", "0", "]", ",", "''", ",", "$", "postContent", ")", ";", "return", "$", "post", ";", "}", "return", "array", "(", "'config'", "=>", "''", ",", "'content'", "=>", "$", "postContent", ")", ";", "}" ]
Strip the config from the post and return the config and content in an array. @param string $postContent @param string $wrap @return array
[ "Strip", "the", "config", "from", "the", "post", "and", "return", "the", "config", "and", "content", "in", "an", "array", "." ]
d23f7848bd9a3993cbb5913d967626e9914a009c
https://github.com/LaBlog/LaBlog/blob/d23f7848bd9a3993cbb5913d967626e9914a009c/src/Lablog/Lablog/Post/JsonPostConfig.php#L19-L31
7,719
pletfix/core
src/Services/CommandFactory.php
CommandFactory.listCommands
private function listCommands(array &$list, $path, $namespace) { $classes = []; list_classes($classes, $path, $namespace); foreach ($classes as $class) { /** @var CommandContract $command */ $command = new $class; $name = $command->name(); $description = trim($command->description() ?: ''); $list[$name] = compact('class', 'name', 'description'); } }
php
private function listCommands(array &$list, $path, $namespace) { $classes = []; list_classes($classes, $path, $namespace); foreach ($classes as $class) { /** @var CommandContract $command */ $command = new $class; $name = $command->name(); $description = trim($command->description() ?: ''); $list[$name] = compact('class', 'name', 'description'); } }
[ "private", "function", "listCommands", "(", "array", "&", "$", "list", ",", "$", "path", ",", "$", "namespace", ")", "{", "$", "classes", "=", "[", "]", ";", "list_classes", "(", "$", "classes", ",", "$", "path", ",", "$", "namespace", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "/** @var CommandContract $command */", "$", "command", "=", "new", "$", "class", ";", "$", "name", "=", "$", "command", "->", "name", "(", ")", ";", "$", "description", "=", "trim", "(", "$", "command", "->", "description", "(", ")", "?", ":", "''", ")", ";", "$", "list", "[", "$", "name", "]", "=", "compact", "(", "'class'", ",", "'name'", ",", "'description'", ")", ";", "}", "}" ]
Read available commands recursive from given path. @param array &$list Receives the command information @param string $path @param string $namespace
[ "Read", "available", "commands", "recursive", "from", "given", "path", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/CommandFactory.php#L87-L98
7,720
pletfix/core
src/Services/CommandFactory.php
CommandFactory.createCommandList
private function createCommandList() { $list = []; // read all core commands $this->listCommands($list, __DIR__ . '/../Commands', 'Core\Commands'); // merge all plugin commands (plugin overrides the core) if (file_exists($this->pluginManifestOfCommands)) { /** @noinspection PhpIncludeInspection */ $list = array_merge($list, include $this->pluginManifestOfCommands); } // merge all commands defined by application (application overrides all other) $this->listCommands($list, app_path('Commands'), 'App\Commands'); // save the new command list ksort($list); return $list; }
php
private function createCommandList() { $list = []; // read all core commands $this->listCommands($list, __DIR__ . '/../Commands', 'Core\Commands'); // merge all plugin commands (plugin overrides the core) if (file_exists($this->pluginManifestOfCommands)) { /** @noinspection PhpIncludeInspection */ $list = array_merge($list, include $this->pluginManifestOfCommands); } // merge all commands defined by application (application overrides all other) $this->listCommands($list, app_path('Commands'), 'App\Commands'); // save the new command list ksort($list); return $list; }
[ "private", "function", "createCommandList", "(", ")", "{", "$", "list", "=", "[", "]", ";", "// read all core commands", "$", "this", "->", "listCommands", "(", "$", "list", ",", "__DIR__", ".", "'/../Commands'", ",", "'Core\\Commands'", ")", ";", "// merge all plugin commands (plugin overrides the core)", "if", "(", "file_exists", "(", "$", "this", "->", "pluginManifestOfCommands", ")", ")", "{", "/** @noinspection PhpIncludeInspection */", "$", "list", "=", "array_merge", "(", "$", "list", ",", "include", "$", "this", "->", "pluginManifestOfCommands", ")", ";", "}", "// merge all commands defined by application (application overrides all other)", "$", "this", "->", "listCommands", "(", "$", "list", ",", "app_path", "(", "'Commands'", ")", ",", "'App\\Commands'", ")", ";", "// save the new command list", "ksort", "(", "$", "list", ")", ";", "return", "$", "list", ";", "}" ]
Create a new command list. @return array
[ "Create", "a", "new", "command", "list", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/CommandFactory.php#L105-L125
7,721
pletfix/core
src/Services/CommandFactory.php
CommandFactory.isCacheUpToDate
private function isCacheUpToDate() { if (!file_exists($this->cachedFile)) { return false; } $cacheTime = filemtime($this->cachedFile); $mTime = $this->modificationTime(); return $cacheTime == $mTime; }
php
private function isCacheUpToDate() { if (!file_exists($this->cachedFile)) { return false; } $cacheTime = filemtime($this->cachedFile); $mTime = $this->modificationTime(); return $cacheTime == $mTime; }
[ "private", "function", "isCacheUpToDate", "(", ")", "{", "if", "(", "!", "file_exists", "(", "$", "this", "->", "cachedFile", ")", ")", "{", "return", "false", ";", "}", "$", "cacheTime", "=", "filemtime", "(", "$", "this", "->", "cachedFile", ")", ";", "$", "mTime", "=", "$", "this", "->", "modificationTime", "(", ")", ";", "return", "$", "cacheTime", "==", "$", "mTime", ";", "}" ]
Determine if the cached file is up to date with the command folder. @return bool
[ "Determine", "if", "the", "cached", "file", "is", "up", "to", "date", "with", "the", "command", "folder", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/CommandFactory.php#L132-L142
7,722
pletfix/core
src/Services/CommandFactory.php
CommandFactory.saveCommandListToCache
private function saveCommandListToCache($list) { if (!is_dir($cacheDir = dirname($this->cachedFile))) { if (!make_dir($cacheDir, 0775)) { throw new RuntimeException(sprintf('Command factory was not able to create directory "%s"', $cacheDir)); // @codeCoverageIgnore } } if (file_exists($this->cachedFile)) { unlink($this->cachedFile); // so we will to be the owner at the new file } if (file_put_contents($this->cachedFile, '<?php return ' . var_export($list, true) . ';' . PHP_EOL, LOCK_EX) === false) { throw new RuntimeException(sprintf('Command factory was not able to save cached file "%s"', $this->cachedFile)); // @codeCoverageIgnore } @chmod($this->cachedFile, 0664); $time = $this->modificationTime(); if (!@touch($this->cachedFile, $time)) { throw new RuntimeException(sprintf('Command factory was not able to modify time of cached file "%s"', $this->cachedFile)); // @codeCoverageIgnore } }
php
private function saveCommandListToCache($list) { if (!is_dir($cacheDir = dirname($this->cachedFile))) { if (!make_dir($cacheDir, 0775)) { throw new RuntimeException(sprintf('Command factory was not able to create directory "%s"', $cacheDir)); // @codeCoverageIgnore } } if (file_exists($this->cachedFile)) { unlink($this->cachedFile); // so we will to be the owner at the new file } if (file_put_contents($this->cachedFile, '<?php return ' . var_export($list, true) . ';' . PHP_EOL, LOCK_EX) === false) { throw new RuntimeException(sprintf('Command factory was not able to save cached file "%s"', $this->cachedFile)); // @codeCoverageIgnore } @chmod($this->cachedFile, 0664); $time = $this->modificationTime(); if (!@touch($this->cachedFile, $time)) { throw new RuntimeException(sprintf('Command factory was not able to modify time of cached file "%s"', $this->cachedFile)); // @codeCoverageIgnore } }
[ "private", "function", "saveCommandListToCache", "(", "$", "list", ")", "{", "if", "(", "!", "is_dir", "(", "$", "cacheDir", "=", "dirname", "(", "$", "this", "->", "cachedFile", ")", ")", ")", "{", "if", "(", "!", "make_dir", "(", "$", "cacheDir", ",", "0775", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Command factory was not able to create directory \"%s\"'", ",", "$", "cacheDir", ")", ")", ";", "// @codeCoverageIgnore", "}", "}", "if", "(", "file_exists", "(", "$", "this", "->", "cachedFile", ")", ")", "{", "unlink", "(", "$", "this", "->", "cachedFile", ")", ";", "// so we will to be the owner at the new file", "}", "if", "(", "file_put_contents", "(", "$", "this", "->", "cachedFile", ",", "'<?php return '", ".", "var_export", "(", "$", "list", ",", "true", ")", ".", "';'", ".", "PHP_EOL", ",", "LOCK_EX", ")", "===", "false", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Command factory was not able to save cached file \"%s\"'", ",", "$", "this", "->", "cachedFile", ")", ")", ";", "// @codeCoverageIgnore", "}", "@", "chmod", "(", "$", "this", "->", "cachedFile", ",", "0664", ")", ";", "$", "time", "=", "$", "this", "->", "modificationTime", "(", ")", ";", "if", "(", "!", "@", "touch", "(", "$", "this", "->", "cachedFile", ",", "$", "time", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Command factory was not able to modify time of cached file \"%s\"'", ",", "$", "this", "->", "cachedFile", ")", ")", ";", "// @codeCoverageIgnore", "}", "}" ]
Save the command list to the cache. @param array $list
[ "Save", "the", "command", "list", "to", "the", "cache", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/CommandFactory.php#L160-L183
7,723
pletfix/core
src/Services/CommandFactory.php
CommandFactory.modificationTime
private function modificationTime() { return max( file_exists($this->pluginManifestOfCommands) ? filemtime($this->pluginManifestOfCommands) : 0, filemtime(__DIR__ . '/../Commands'), file_exists(app_path('Commands')) ? filemtime(app_path('Commands')) : 0 ); }
php
private function modificationTime() { return max( file_exists($this->pluginManifestOfCommands) ? filemtime($this->pluginManifestOfCommands) : 0, filemtime(__DIR__ . '/../Commands'), file_exists(app_path('Commands')) ? filemtime(app_path('Commands')) : 0 ); }
[ "private", "function", "modificationTime", "(", ")", "{", "return", "max", "(", "file_exists", "(", "$", "this", "->", "pluginManifestOfCommands", ")", "?", "filemtime", "(", "$", "this", "->", "pluginManifestOfCommands", ")", ":", "0", ",", "filemtime", "(", "__DIR__", ".", "'/../Commands'", ")", ",", "file_exists", "(", "app_path", "(", "'Commands'", ")", ")", "?", "filemtime", "(", "app_path", "(", "'Commands'", ")", ")", ":", "0", ")", ";", "}" ]
Gets the modification time. @return int
[ "Gets", "the", "modification", "time", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/CommandFactory.php#L190-L197
7,724
coolms/common
src/Form/MessagesTrait.php
MessagesTrait.getMessages
public function getMessages($elementName = null) { if (null === $elementName) { $messages = $this->messages; foreach ($this->iterator as $name => $element) { $messageSet = $element->getMessages(); if (!is_array($messageSet) && !$messageSet instanceof Traversable || empty($messageSet) ) { continue; } $messages[$name] = $messageSet; } return $messages; } if (!$this->has($elementName)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid element name "%s" provided to %s', $elementName, __METHOD__ )); } $element = $this->get($elementName); return $element->getMessages(); }
php
public function getMessages($elementName = null) { if (null === $elementName) { $messages = $this->messages; foreach ($this->iterator as $name => $element) { $messageSet = $element->getMessages(); if (!is_array($messageSet) && !$messageSet instanceof Traversable || empty($messageSet) ) { continue; } $messages[$name] = $messageSet; } return $messages; } if (!$this->has($elementName)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid element name "%s" provided to %s', $elementName, __METHOD__ )); } $element = $this->get($elementName); return $element->getMessages(); }
[ "public", "function", "getMessages", "(", "$", "elementName", "=", "null", ")", "{", "if", "(", "null", "===", "$", "elementName", ")", "{", "$", "messages", "=", "$", "this", "->", "messages", ";", "foreach", "(", "$", "this", "->", "iterator", "as", "$", "name", "=>", "$", "element", ")", "{", "$", "messageSet", "=", "$", "element", "->", "getMessages", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "messageSet", ")", "&&", "!", "$", "messageSet", "instanceof", "Traversable", "||", "empty", "(", "$", "messageSet", ")", ")", "{", "continue", ";", "}", "$", "messages", "[", "$", "name", "]", "=", "$", "messageSet", ";", "}", "return", "$", "messages", ";", "}", "if", "(", "!", "$", "this", "->", "has", "(", "$", "elementName", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid element name \"%s\" provided to %s'", ",", "$", "elementName", ",", "__METHOD__", ")", ")", ";", "}", "$", "element", "=", "$", "this", "->", "get", "(", "$", "elementName", ")", ";", "return", "$", "element", "->", "getMessages", "(", ")", ";", "}" ]
Get validation error messages, if any Returns a hash of element names/messages for all elements failing validation, or, if $elementName is provided, messages for that element only. @param null|string $elementName @return array|Traversable @throws Exception\InvalidArgumentException
[ "Get", "validation", "error", "messages", "if", "any" ]
3572993cdcdb2898cdde396a2f1de9864b193660
https://github.com/coolms/common/blob/3572993cdcdb2898cdde396a2f1de9864b193660/src/Form/MessagesTrait.php#L67-L96
7,725
orkestra/orkestra-common
lib/Orkestra/Common/Type/DateTime.php
DateTime.createFromFormat
public static function createFromFormat($format, $time, $timezone = null) { if (null === $timezone) { $timezone = self::getServerTimezone(); } if (null === $timezone) { // This is necessary due to how native DateTime handles passing null for a timezone (it doesnt) $parent = parent::createFromFormat($format, $time); } else { $parent = parent::createFromFormat($format, $time, $timezone); } if (empty($parent)) { throw new TypeException('Could not create DateTime from the given format'); } $datetime = new self('@' . $parent->getTimestamp()); if (null !== $timezone) { $datetime->setTimezone($timezone); } return $datetime; }
php
public static function createFromFormat($format, $time, $timezone = null) { if (null === $timezone) { $timezone = self::getServerTimezone(); } if (null === $timezone) { // This is necessary due to how native DateTime handles passing null for a timezone (it doesnt) $parent = parent::createFromFormat($format, $time); } else { $parent = parent::createFromFormat($format, $time, $timezone); } if (empty($parent)) { throw new TypeException('Could not create DateTime from the given format'); } $datetime = new self('@' . $parent->getTimestamp()); if (null !== $timezone) { $datetime->setTimezone($timezone); } return $datetime; }
[ "public", "static", "function", "createFromFormat", "(", "$", "format", ",", "$", "time", ",", "$", "timezone", "=", "null", ")", "{", "if", "(", "null", "===", "$", "timezone", ")", "{", "$", "timezone", "=", "self", "::", "getServerTimezone", "(", ")", ";", "}", "if", "(", "null", "===", "$", "timezone", ")", "{", "// This is necessary due to how native DateTime handles passing null for a timezone (it doesnt)", "$", "parent", "=", "parent", "::", "createFromFormat", "(", "$", "format", ",", "$", "time", ")", ";", "}", "else", "{", "$", "parent", "=", "parent", "::", "createFromFormat", "(", "$", "format", ",", "$", "time", ",", "$", "timezone", ")", ";", "}", "if", "(", "empty", "(", "$", "parent", ")", ")", "{", "throw", "new", "TypeException", "(", "'Could not create DateTime from the given format'", ")", ";", "}", "$", "datetime", "=", "new", "self", "(", "'@'", ".", "$", "parent", "->", "getTimestamp", "(", ")", ")", ";", "if", "(", "null", "!==", "$", "timezone", ")", "{", "$", "datetime", "->", "setTimezone", "(", "$", "timezone", ")", ";", "}", "return", "$", "datetime", ";", "}" ]
Create From Format @param string $format @param string $time @param \DateTimeZone|null $timezone @throws \Orkestra\Common\Exception\TypeException @return \Orkestra\Common\Type\DateTime
[ "Create", "From", "Format" ]
620d62d41cd1d95365294e5bb0ae203a744b71cb
https://github.com/orkestra/orkestra-common/blob/620d62d41cd1d95365294e5bb0ae203a744b71cb/lib/Orkestra/Common/Type/DateTime.php#L47-L70
7,726
codebobbly/dvoconnector
Classes/Service/AssociationsApiService.php
AssociationsApiService.getEventsFromRootAssociations
public function getEventsFromRootAssociations($apiServiceFilterContext = null) { $result = []; foreach ($this->getRootAssociationIDs() as $key => $rootAssociationID) { try { $result[] = $this->getChildAssociationsFromAssociation($rootAssociationID, $apiServiceFilterContext); } catch (ContextException $e) { if ($key === count($this->getRootAssociationIDs()) - 1) { throw $e; } } } return $result; }
php
public function getEventsFromRootAssociations($apiServiceFilterContext = null) { $result = []; foreach ($this->getRootAssociationIDs() as $key => $rootAssociationID) { try { $result[] = $this->getChildAssociationsFromAssociation($rootAssociationID, $apiServiceFilterContext); } catch (ContextException $e) { if ($key === count($this->getRootAssociationIDs()) - 1) { throw $e; } } } return $result; }
[ "public", "function", "getEventsFromRootAssociations", "(", "$", "apiServiceFilterContext", "=", "null", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getRootAssociationIDs", "(", ")", "as", "$", "key", "=>", "$", "rootAssociationID", ")", "{", "try", "{", "$", "result", "[", "]", "=", "$", "this", "->", "getChildAssociationsFromAssociation", "(", "$", "rootAssociationID", ",", "$", "apiServiceFilterContext", ")", ";", "}", "catch", "(", "ContextException", "$", "e", ")", "{", "if", "(", "$", "key", "===", "count", "(", "$", "this", "->", "getRootAssociationIDs", "(", ")", ")", "-", "1", ")", "{", "throw", "$", "e", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
return a list of events from the root associations @param \RGU\Dvoconnector\Service\ApiServiceFilterContext $apiServiceFilterContext @return \SimpleXMLElement XML data
[ "return", "a", "list", "of", "events", "from", "the", "root", "associations" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/AssociationsApiService.php#L145-L160
7,727
codebobbly/dvoconnector
Classes/Service/AssociationsApiService.php
AssociationsApiService.getAnnouncementsFromRootAssociations
public function getAnnouncementsFromRootAssociations($apiServiceFilterContext = null) { $result = []; foreach ($this->getRootAssociationIDs() as $key => $rootAssociationID) { try { $result[] = $this->getAnnouncementsFromAssociation($rootAssociationID, $apiServiceFilterContext); } catch (ContextException $e) { if ($key === count($this->getRootAssociationIDs()) - 1) { throw $e; } } } return $result; }
php
public function getAnnouncementsFromRootAssociations($apiServiceFilterContext = null) { $result = []; foreach ($this->getRootAssociationIDs() as $key => $rootAssociationID) { try { $result[] = $this->getAnnouncementsFromAssociation($rootAssociationID, $apiServiceFilterContext); } catch (ContextException $e) { if ($key === count($this->getRootAssociationIDs()) - 1) { throw $e; } } } return $result; }
[ "public", "function", "getAnnouncementsFromRootAssociations", "(", "$", "apiServiceFilterContext", "=", "null", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getRootAssociationIDs", "(", ")", "as", "$", "key", "=>", "$", "rootAssociationID", ")", "{", "try", "{", "$", "result", "[", "]", "=", "$", "this", "->", "getAnnouncementsFromAssociation", "(", "$", "rootAssociationID", ",", "$", "apiServiceFilterContext", ")", ";", "}", "catch", "(", "ContextException", "$", "e", ")", "{", "if", "(", "$", "key", "===", "count", "(", "$", "this", "->", "getRootAssociationIDs", "(", ")", ")", "-", "1", ")", "{", "throw", "$", "e", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
return a list of announcements from the root associations @param \RGU\Dvoconnector\Service\ApiServiceFilterContext $apiServiceFilterContext @return array XML data
[ "return", "a", "list", "of", "announcements", "from", "the", "root", "associations" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/AssociationsApiService.php#L219-L234
7,728
codebobbly/dvoconnector
Classes/Service/AssociationsApiService.php
AssociationsApiService.getAnnouncementsFromAssociation
public function getAnnouncementsFromAssociation($aid, $apiServiceFilterContext = null) { $apiServiceFilterContext = $this->checkApiServiceFilterContext($apiServiceFilterContext, $aid); $url = $this->getBaseApiUrl() . '/associations/' . $aid . '/announcements'; $params = null; $xml = $this->queryXml($url, $apiServiceFilterContext); $this->checkValidContext($xml->list[self::CO_XML_ATTRIBUT_VALID_CONTEXT]); return $xml->list; }
php
public function getAnnouncementsFromAssociation($aid, $apiServiceFilterContext = null) { $apiServiceFilterContext = $this->checkApiServiceFilterContext($apiServiceFilterContext, $aid); $url = $this->getBaseApiUrl() . '/associations/' . $aid . '/announcements'; $params = null; $xml = $this->queryXml($url, $apiServiceFilterContext); $this->checkValidContext($xml->list[self::CO_XML_ATTRIBUT_VALID_CONTEXT]); return $xml->list; }
[ "public", "function", "getAnnouncementsFromAssociation", "(", "$", "aid", ",", "$", "apiServiceFilterContext", "=", "null", ")", "{", "$", "apiServiceFilterContext", "=", "$", "this", "->", "checkApiServiceFilterContext", "(", "$", "apiServiceFilterContext", ",", "$", "aid", ")", ";", "$", "url", "=", "$", "this", "->", "getBaseApiUrl", "(", ")", ".", "'/associations/'", ".", "$", "aid", ".", "'/announcements'", ";", "$", "params", "=", "null", ";", "$", "xml", "=", "$", "this", "->", "queryXml", "(", "$", "url", ",", "$", "apiServiceFilterContext", ")", ";", "$", "this", "->", "checkValidContext", "(", "$", "xml", "->", "list", "[", "self", "::", "CO_XML_ATTRIBUT_VALID_CONTEXT", "]", ")", ";", "return", "$", "xml", "->", "list", ";", "}" ]
return a list of announcements from a association @param string association id @param \RGU\Dvoconnector\Service\ApiServiceFilterContext $apiServiceFilterContext @return \SimpleXMLElement XML data
[ "return", "a", "list", "of", "announcements", "from", "a", "association" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/AssociationsApiService.php#L244-L257
7,729
codebobbly/dvoconnector
Classes/Service/AssociationsApiService.php
AssociationsApiService.getFunctionariesFromAssociation
public function getFunctionariesFromAssociation($aid, $apiServiceFilterContext = null) { $apiServiceFilterContext = $this->checkApiServiceFilterContext($apiServiceFilterContext, $aid); $url = $this->getBaseApiUrl() . '/associations/' . $aid . '/functionaries'; $params = null; $xml = $this->queryXml($url, $apiServiceFilterContext); $this->checkValidContext($xml->list[self::CO_XML_ATTRIBUT_VALID_CONTEXT]); $filterParamters = $apiServiceFilterContext->getParametersArray(); for ($i = 0; $i < count($xml->list->functionaries->functionary); $i++) { $functionaryChildEntry = $xml->list->functionaries->functionary[$i]; if (isset($filterParamters['f_role']) && preg_match('/(' . $filterParamters['f_role'] . ')/', $functionaryChildEntry['role']) == 0) { unset($xml->list->functionaries->functionary[$i]); $i--; } else { $functionaryChildEntry->addAttribute('associationid', $aid); } } return $xml->list; }
php
public function getFunctionariesFromAssociation($aid, $apiServiceFilterContext = null) { $apiServiceFilterContext = $this->checkApiServiceFilterContext($apiServiceFilterContext, $aid); $url = $this->getBaseApiUrl() . '/associations/' . $aid . '/functionaries'; $params = null; $xml = $this->queryXml($url, $apiServiceFilterContext); $this->checkValidContext($xml->list[self::CO_XML_ATTRIBUT_VALID_CONTEXT]); $filterParamters = $apiServiceFilterContext->getParametersArray(); for ($i = 0; $i < count($xml->list->functionaries->functionary); $i++) { $functionaryChildEntry = $xml->list->functionaries->functionary[$i]; if (isset($filterParamters['f_role']) && preg_match('/(' . $filterParamters['f_role'] . ')/', $functionaryChildEntry['role']) == 0) { unset($xml->list->functionaries->functionary[$i]); $i--; } else { $functionaryChildEntry->addAttribute('associationid', $aid); } } return $xml->list; }
[ "public", "function", "getFunctionariesFromAssociation", "(", "$", "aid", ",", "$", "apiServiceFilterContext", "=", "null", ")", "{", "$", "apiServiceFilterContext", "=", "$", "this", "->", "checkApiServiceFilterContext", "(", "$", "apiServiceFilterContext", ",", "$", "aid", ")", ";", "$", "url", "=", "$", "this", "->", "getBaseApiUrl", "(", ")", ".", "'/associations/'", ".", "$", "aid", ".", "'/functionaries'", ";", "$", "params", "=", "null", ";", "$", "xml", "=", "$", "this", "->", "queryXml", "(", "$", "url", ",", "$", "apiServiceFilterContext", ")", ";", "$", "this", "->", "checkValidContext", "(", "$", "xml", "->", "list", "[", "self", "::", "CO_XML_ATTRIBUT_VALID_CONTEXT", "]", ")", ";", "$", "filterParamters", "=", "$", "apiServiceFilterContext", "->", "getParametersArray", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "xml", "->", "list", "->", "functionaries", "->", "functionary", ")", ";", "$", "i", "++", ")", "{", "$", "functionaryChildEntry", "=", "$", "xml", "->", "list", "->", "functionaries", "->", "functionary", "[", "$", "i", "]", ";", "if", "(", "isset", "(", "$", "filterParamters", "[", "'f_role'", "]", ")", "&&", "preg_match", "(", "'/('", ".", "$", "filterParamters", "[", "'f_role'", "]", ".", "')/'", ",", "$", "functionaryChildEntry", "[", "'role'", "]", ")", "==", "0", ")", "{", "unset", "(", "$", "xml", "->", "list", "->", "functionaries", "->", "functionary", "[", "$", "i", "]", ")", ";", "$", "i", "--", ";", "}", "else", "{", "$", "functionaryChildEntry", "->", "addAttribute", "(", "'associationid'", ",", "$", "aid", ")", ";", "}", "}", "return", "$", "xml", "->", "list", ";", "}" ]
return a list of functionaries from a association @param string association id @param \RGU\Dvoconnector\Service\ApiServiceFilterContext $apiServiceFilterContext @return \SimpleXMLElement XML data
[ "return", "a", "list", "of", "functionaries", "from", "a", "association" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/AssociationsApiService.php#L317-L343
7,730
codebobbly/dvoconnector
Classes/Service/AssociationsApiService.php
AssociationsApiService.getFunctionariesFromRootAssociations
public function getFunctionariesFromRootAssociations($apiServiceFilterContext = null) { $result = []; foreach ($this->getRootAssociationIDs() as $key => $rootAssociationID) { try { $result[] = $this->getFunctionariesFromAssociation($rootAssociationID, $apiServiceFilterContext); } catch (ContextException $e) { if ($key === count($this->getRootAssociationIDs()) - 1) { throw $e; } } } return $result; }
php
public function getFunctionariesFromRootAssociations($apiServiceFilterContext = null) { $result = []; foreach ($this->getRootAssociationIDs() as $key => $rootAssociationID) { try { $result[] = $this->getFunctionariesFromAssociation($rootAssociationID, $apiServiceFilterContext); } catch (ContextException $e) { if ($key === count($this->getRootAssociationIDs()) - 1) { throw $e; } } } return $result; }
[ "public", "function", "getFunctionariesFromRootAssociations", "(", "$", "apiServiceFilterContext", "=", "null", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getRootAssociationIDs", "(", ")", "as", "$", "key", "=>", "$", "rootAssociationID", ")", "{", "try", "{", "$", "result", "[", "]", "=", "$", "this", "->", "getFunctionariesFromAssociation", "(", "$", "rootAssociationID", ",", "$", "apiServiceFilterContext", ")", ";", "}", "catch", "(", "ContextException", "$", "e", ")", "{", "if", "(", "$", "key", "===", "count", "(", "$", "this", "->", "getRootAssociationIDs", "(", ")", ")", "-", "1", ")", "{", "throw", "$", "e", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
return a list of functionaries from the root associations @param \RGU\Dvoconnector\Service\ApiServiceFilterContext $apiServiceFilterContext @return \SimpleXMLElement XML data
[ "return", "a", "list", "of", "functionaries", "from", "the", "root", "associations" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/AssociationsApiService.php#L352-L367
7,731
codebobbly/dvoconnector
Classes/Service/AssociationsApiService.php
AssociationsApiService.getFunctionaryFromAssociation
public function getFunctionaryFromAssociation($aid, $fid, $apiServiceFilterContext = null) { $apiServiceFilterContext = $this->checkApiServiceFilterContext($apiServiceFilterContext, $aid); $url = $this->getBaseApiUrl() . '/associations/' . $aid . '/functionaries/' . $fid . ''; $params = null; $xml = $this->queryXml($url, $apiServiceFilterContext); $this->checkValidContext($xml->query[self::CO_XML_ATTRIBUT_VALID_CONTEXT]); return $xml->query->children()[0]; }
php
public function getFunctionaryFromAssociation($aid, $fid, $apiServiceFilterContext = null) { $apiServiceFilterContext = $this->checkApiServiceFilterContext($apiServiceFilterContext, $aid); $url = $this->getBaseApiUrl() . '/associations/' . $aid . '/functionaries/' . $fid . ''; $params = null; $xml = $this->queryXml($url, $apiServiceFilterContext); $this->checkValidContext($xml->query[self::CO_XML_ATTRIBUT_VALID_CONTEXT]); return $xml->query->children()[0]; }
[ "public", "function", "getFunctionaryFromAssociation", "(", "$", "aid", ",", "$", "fid", ",", "$", "apiServiceFilterContext", "=", "null", ")", "{", "$", "apiServiceFilterContext", "=", "$", "this", "->", "checkApiServiceFilterContext", "(", "$", "apiServiceFilterContext", ",", "$", "aid", ")", ";", "$", "url", "=", "$", "this", "->", "getBaseApiUrl", "(", ")", ".", "'/associations/'", ".", "$", "aid", ".", "'/functionaries/'", ".", "$", "fid", ".", "''", ";", "$", "params", "=", "null", ";", "$", "xml", "=", "$", "this", "->", "queryXml", "(", "$", "url", ",", "$", "apiServiceFilterContext", ")", ";", "$", "this", "->", "checkValidContext", "(", "$", "xml", "->", "query", "[", "self", "::", "CO_XML_ATTRIBUT_VALID_CONTEXT", "]", ")", ";", "return", "$", "xml", "->", "query", "->", "children", "(", ")", "[", "0", "]", ";", "}" ]
return a functionary from a association @param string association id @param string functionary id @param \RGU\Dvoconnector\Service\ApiServiceFilterContext $apiServiceFilterContext @return \SimpleXMLElement XML data
[ "return", "a", "functionary", "from", "a", "association" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/AssociationsApiService.php#L378-L391
7,732
codebobbly/dvoconnector
Classes/Service/AssociationsApiService.php
AssociationsApiService.checkApiServiceFilterContext
protected function checkApiServiceFilterContext($apiServiceFilterContext = null, $aID = null) { if (is_null($apiServiceFilterContext)) { $resultApiServiceFilterContext = new \RGU\Dvoconnector\Domain\Filter\GenericFilterContext(); } else { $resultApiServiceFilterContext = clone $apiServiceFilterContext; } if (is_null($resultApiServiceFilterContext->getInsideAssociationID()) && isset($aID)) { $resultApiServiceFilterContext->setInsideAssociationID($aID); } return $resultApiServiceFilterContext; }
php
protected function checkApiServiceFilterContext($apiServiceFilterContext = null, $aID = null) { if (is_null($apiServiceFilterContext)) { $resultApiServiceFilterContext = new \RGU\Dvoconnector\Domain\Filter\GenericFilterContext(); } else { $resultApiServiceFilterContext = clone $apiServiceFilterContext; } if (is_null($resultApiServiceFilterContext->getInsideAssociationID()) && isset($aID)) { $resultApiServiceFilterContext->setInsideAssociationID($aID); } return $resultApiServiceFilterContext; }
[ "protected", "function", "checkApiServiceFilterContext", "(", "$", "apiServiceFilterContext", "=", "null", ",", "$", "aID", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "apiServiceFilterContext", ")", ")", "{", "$", "resultApiServiceFilterContext", "=", "new", "\\", "RGU", "\\", "Dvoconnector", "\\", "Domain", "\\", "Filter", "\\", "GenericFilterContext", "(", ")", ";", "}", "else", "{", "$", "resultApiServiceFilterContext", "=", "clone", "$", "apiServiceFilterContext", ";", "}", "if", "(", "is_null", "(", "$", "resultApiServiceFilterContext", "->", "getInsideAssociationID", "(", ")", ")", "&&", "isset", "(", "$", "aID", ")", ")", "{", "$", "resultApiServiceFilterContext", "->", "setInsideAssociationID", "(", "$", "aID", ")", ";", "}", "return", "$", "resultApiServiceFilterContext", ";", "}" ]
check that the filter has a inside association value @param \RGU\Dvoconnector\Service\ApiServiceFilterContext $apiServiceFilterContext @param string $aID association ID @return \RGU\Dvoconnector\Service\ApiServiceFilterContext
[ "check", "that", "the", "filter", "has", "a", "inside", "association", "value" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/AssociationsApiService.php#L427-L440
7,733
mtils/ems-signal
src/Signal/NamedEvent/FireTrait.php
FireTrait.fireIfNamed
public function fireIfNamed($event, $payload=[], $halt=false) { if(!$event){ return; } return $this->fire($event, $payload, $halt); }
php
public function fireIfNamed($event, $payload=[], $halt=false) { if(!$event){ return; } return $this->fire($event, $payload, $halt); }
[ "public", "function", "fireIfNamed", "(", "$", "event", ",", "$", "payload", "=", "[", "]", ",", "$", "halt", "=", "false", ")", "{", "if", "(", "!", "$", "event", ")", "{", "return", ";", "}", "return", "$", "this", "->", "fire", "(", "$", "event", ",", "$", "payload", ",", "$", "halt", ")", ";", "}" ]
Fire an event if a name was passed @param string $event The event name @param array $payload The event parameters @param bool $halt Stop propagation on trueish return values @return mixed @see self::fire()
[ "Fire", "an", "event", "if", "a", "name", "was", "passed" ]
3246eea699dce1a6d6f758bcfc89b20320f6becc
https://github.com/mtils/ems-signal/blob/3246eea699dce1a6d6f758bcfc89b20320f6becc/src/Signal/NamedEvent/FireTrait.php#L40-L46
7,734
mtils/ems-signal
src/Signal/NamedEvent/FireTrait.php
FireTrait.fireOnce
public function fireOnce($event, $payload=[], $halt=false) { if(isset($this->firedEvents[$event])){ return; } return $this->fire($event, $payload, $halt); }
php
public function fireOnce($event, $payload=[], $halt=false) { if(isset($this->firedEvents[$event])){ return; } return $this->fire($event, $payload, $halt); }
[ "public", "function", "fireOnce", "(", "$", "event", ",", "$", "payload", "=", "[", "]", ",", "$", "halt", "=", "false", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "firedEvents", "[", "$", "event", "]", ")", ")", "{", "return", ";", "}", "return", "$", "this", "->", "fire", "(", "$", "event", ",", "$", "payload", ",", "$", "halt", ")", ";", "}" ]
Fire an event once. The next event with this name will be ignored @param string $event The event name @param array $payload The event parameters @param bool $halt Stop propagation on trueish return values @return mixed @see self::fire()
[ "Fire", "an", "event", "once", ".", "The", "next", "event", "with", "this", "name", "will", "be", "ignored" ]
3246eea699dce1a6d6f758bcfc89b20320f6becc
https://github.com/mtils/ems-signal/blob/3246eea699dce1a6d6f758bcfc89b20320f6becc/src/Signal/NamedEvent/FireTrait.php#L57-L63
7,735
mtils/ems-signal
src/Signal/NamedEvent/FireTrait.php
FireTrait.fireOnceIfNamed
public function fireOnceIfNamed($event, $payload=[], $halt=false) { if(!$event){ return; } return $this->fireOnce($event, $payload, $halt); }
php
public function fireOnceIfNamed($event, $payload=[], $halt=false) { if(!$event){ return; } return $this->fireOnce($event, $payload, $halt); }
[ "public", "function", "fireOnceIfNamed", "(", "$", "event", ",", "$", "payload", "=", "[", "]", ",", "$", "halt", "=", "false", ")", "{", "if", "(", "!", "$", "event", ")", "{", "return", ";", "}", "return", "$", "this", "->", "fireOnce", "(", "$", "event", ",", "$", "payload", ",", "$", "halt", ")", ";", "}" ]
Fire an event once if named @param string $event The event name @param array $payload The event parameters @param bool $halt Stop propagation on trueish return values @return mixed @see self::fire()
[ "Fire", "an", "event", "once", "if", "named" ]
3246eea699dce1a6d6f758bcfc89b20320f6becc
https://github.com/mtils/ems-signal/blob/3246eea699dce1a6d6f758bcfc89b20320f6becc/src/Signal/NamedEvent/FireTrait.php#L74-L80
7,736
jivoo/http
src/ActionRequest.php
ActionRequest.accepts
public function accepts($type = null) { if (!isset($type)) { return $this->attributes['accepts']; } return in_array($type, $this->attributes['accepts']); }
php
public function accepts($type = null) { if (!isset($type)) { return $this->attributes['accepts']; } return in_array($type, $this->attributes['accepts']); }
[ "public", "function", "accepts", "(", "$", "type", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "type", ")", ")", "{", "return", "$", "this", "->", "attributes", "[", "'accepts'", "]", ";", "}", "return", "in_array", "(", "$", "type", ",", "$", "this", "->", "attributes", "[", "'accepts'", "]", ")", ";", "}" ]
Whether or not the client accepts the specified type. If the type is omitted then a list of acceptable types is returned. @param string $type MIME type. @return bool|string[] True if client accepts provided type, false otherwise. List of accepted MIME types if type parameter omitted.
[ "Whether", "or", "not", "the", "client", "accepts", "the", "specified", "type", ".", "If", "the", "type", "is", "omitted", "then", "a", "list", "of", "acceptable", "types", "is", "returned", "." ]
3c1d8dba66978bc91fc2b324dd941e5da3b253bc
https://github.com/jivoo/http/blob/3c1d8dba66978bc91fc2b324dd941e5da3b253bc/src/ActionRequest.php#L117-L123
7,737
jivoo/http
src/ActionRequest.php
ActionRequest.acceptsEncoding
public function acceptsEncoding($encoding = null) { if (!isset($encoding)) { return $this->attributes['encodings']; } return in_array($encoding, $this->attributes['encodings']); }
php
public function acceptsEncoding($encoding = null) { if (!isset($encoding)) { return $this->attributes['encodings']; } return in_array($encoding, $this->attributes['encodings']); }
[ "public", "function", "acceptsEncoding", "(", "$", "encoding", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "encoding", ")", ")", "{", "return", "$", "this", "->", "attributes", "[", "'encodings'", "]", ";", "}", "return", "in_array", "(", "$", "encoding", ",", "$", "this", "->", "attributes", "[", "'encodings'", "]", ")", ";", "}" ]
Whether or not the client accepts the specified encoding. If the type is omitted then a list of acceptable encodings is returned. @param string $encoding Encoding. @return bool|string[] True if client accepts provided encoding, false otherwise. List of accepted encodings if type parameter omitted.
[ "Whether", "or", "not", "the", "client", "accepts", "the", "specified", "encoding", ".", "If", "the", "type", "is", "omitted", "then", "a", "list", "of", "acceptable", "encodings", "is", "returned", "." ]
3c1d8dba66978bc91fc2b324dd941e5da3b253bc
https://github.com/jivoo/http/blob/3c1d8dba66978bc91fc2b324dd941e5da3b253bc/src/ActionRequest.php#L133-L139
7,738
jivoo/http
src/ActionRequest.php
ActionRequest.pathToString
public function pathToString($path, $rewrite = false) { if (is_string($path)) { return $path; } $str = $this->basePath; if ($str == '/') { $str = ''; } if (! ($this->rewrite or $rewrite)) { $str .= '/' . $this->scriptName; } $str .= '/' . implode('/', array_map('urlencode', $path)); $str = rtrim($str, '/'); if ($str == '') { return '/'; } return $str; }
php
public function pathToString($path, $rewrite = false) { if (is_string($path)) { return $path; } $str = $this->basePath; if ($str == '/') { $str = ''; } if (! ($this->rewrite or $rewrite)) { $str .= '/' . $this->scriptName; } $str .= '/' . implode('/', array_map('urlencode', $path)); $str = rtrim($str, '/'); if ($str == '') { return '/'; } return $str; }
[ "public", "function", "pathToString", "(", "$", "path", ",", "$", "rewrite", "=", "false", ")", "{", "if", "(", "is_string", "(", "$", "path", ")", ")", "{", "return", "$", "path", ";", "}", "$", "str", "=", "$", "this", "->", "basePath", ";", "if", "(", "$", "str", "==", "'/'", ")", "{", "$", "str", "=", "''", ";", "}", "if", "(", "!", "(", "$", "this", "->", "rewrite", "or", "$", "rewrite", ")", ")", "{", "$", "str", ".=", "'/'", ".", "$", "this", "->", "scriptName", ";", "}", "$", "str", ".=", "'/'", ".", "implode", "(", "'/'", ",", "array_map", "(", "'urlencode'", ",", "$", "path", ")", ")", ";", "$", "str", "=", "rtrim", "(", "$", "str", ",", "'/'", ")", ";", "if", "(", "$", "str", "==", "''", ")", "{", "return", "'/'", ";", "}", "return", "$", "str", ";", "}" ]
Convert path array to a string. @param string|string[] $path Path array or absolute url. @param bool $rewrite Whether to force removal of script name from path. @return string Path string.
[ "Convert", "path", "array", "to", "a", "string", "." ]
3c1d8dba66978bc91fc2b324dd941e5da3b253bc
https://github.com/jivoo/http/blob/3c1d8dba66978bc91fc2b324dd941e5da3b253bc/src/ActionRequest.php#L210-L228
7,739
jivoo/http
src/ActionRequest.php
ActionRequest.findPath
public static function findPath(\Psr\Http\Message\ServerRequestInterface $request) { $server = $request->getServerParams(); $path = $request->getUri()->getPath(); if (isset($server['SCRIPT_NAME'])) { $basePath = dirname($server['SCRIPT_NAME']); if ($basePath != '/') { $length = strlen($basePath); if (substr($path, 0, $length) == $basePath) { $path = substr($path, $length); } } } if ($path == '/' or $path == '') { return []; } if ($path[0] == '/') { $path = substr($path, 1); } return array_map('urldecode', explode('/', $path)); }
php
public static function findPath(\Psr\Http\Message\ServerRequestInterface $request) { $server = $request->getServerParams(); $path = $request->getUri()->getPath(); if (isset($server['SCRIPT_NAME'])) { $basePath = dirname($server['SCRIPT_NAME']); if ($basePath != '/') { $length = strlen($basePath); if (substr($path, 0, $length) == $basePath) { $path = substr($path, $length); } } } if ($path == '/' or $path == '') { return []; } if ($path[0] == '/') { $path = substr($path, 1); } return array_map('urldecode', explode('/', $path)); }
[ "public", "static", "function", "findPath", "(", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "ServerRequestInterface", "$", "request", ")", "{", "$", "server", "=", "$", "request", "->", "getServerParams", "(", ")", ";", "$", "path", "=", "$", "request", "->", "getUri", "(", ")", "->", "getPath", "(", ")", ";", "if", "(", "isset", "(", "$", "server", "[", "'SCRIPT_NAME'", "]", ")", ")", "{", "$", "basePath", "=", "dirname", "(", "$", "server", "[", "'SCRIPT_NAME'", "]", ")", ";", "if", "(", "$", "basePath", "!=", "'/'", ")", "{", "$", "length", "=", "strlen", "(", "$", "basePath", ")", ";", "if", "(", "substr", "(", "$", "path", ",", "0", ",", "$", "length", ")", "==", "$", "basePath", ")", "{", "$", "path", "=", "substr", "(", "$", "path", ",", "$", "length", ")", ";", "}", "}", "}", "if", "(", "$", "path", "==", "'/'", "or", "$", "path", "==", "''", ")", "{", "return", "[", "]", ";", "}", "if", "(", "$", "path", "[", "0", "]", "==", "'/'", ")", "{", "$", "path", "=", "substr", "(", "$", "path", ",", "1", ")", ";", "}", "return", "array_map", "(", "'urldecode'", ",", "explode", "(", "'/'", ",", "$", "path", ")", ")", ";", "}" ]
Find the path array for a request. @param \Psr\Http\Message\ServerRequestInterface $request @return string[]
[ "Find", "the", "path", "array", "for", "a", "request", "." ]
3c1d8dba66978bc91fc2b324dd941e5da3b253bc
https://github.com/jivoo/http/blob/3c1d8dba66978bc91fc2b324dd941e5da3b253bc/src/ActionRequest.php#L236-L256
7,740
phlexible/phlexible
src/Phlexible/Bundle/ElementtypeBundle/Doctrine/ViabilityManager.php
ViabilityManager.updateViability
public function updateViability(Elementtype $elementtype, array $parentIds) { $viabilityRepository = $this->entityManager->getRepository('PhlexibleElementtypeBundle:ElementtypeApply'); $viabilities = $viabilityRepository->findBy(['elementtypeId' => $elementtype->getId()]); foreach ($viabilities as $index => $viability) { if (in_array($viability->getUnderElementtypeId(), $parentIds)) { unset($parentIds[array_search($viability->getUnderElementtypeId(), $parentIds)]); unset($viabilities[$index]); } } foreach ($parentIds as $parentId) { $viability = new ElementtypeApply(); $viability ->setElementtypeId($elementtype->getId()) ->setUnderElementtypeId($parentId); $this->entityManager->persist($viability); } foreach ($viabilities as $viability) { $this->entityManager->remove($viability); } $this->entityManager->flush(); }
php
public function updateViability(Elementtype $elementtype, array $parentIds) { $viabilityRepository = $this->entityManager->getRepository('PhlexibleElementtypeBundle:ElementtypeApply'); $viabilities = $viabilityRepository->findBy(['elementtypeId' => $elementtype->getId()]); foreach ($viabilities as $index => $viability) { if (in_array($viability->getUnderElementtypeId(), $parentIds)) { unset($parentIds[array_search($viability->getUnderElementtypeId(), $parentIds)]); unset($viabilities[$index]); } } foreach ($parentIds as $parentId) { $viability = new ElementtypeApply(); $viability ->setElementtypeId($elementtype->getId()) ->setUnderElementtypeId($parentId); $this->entityManager->persist($viability); } foreach ($viabilities as $viability) { $this->entityManager->remove($viability); } $this->entityManager->flush(); }
[ "public", "function", "updateViability", "(", "Elementtype", "$", "elementtype", ",", "array", "$", "parentIds", ")", "{", "$", "viabilityRepository", "=", "$", "this", "->", "entityManager", "->", "getRepository", "(", "'PhlexibleElementtypeBundle:ElementtypeApply'", ")", ";", "$", "viabilities", "=", "$", "viabilityRepository", "->", "findBy", "(", "[", "'elementtypeId'", "=>", "$", "elementtype", "->", "getId", "(", ")", "]", ")", ";", "foreach", "(", "$", "viabilities", "as", "$", "index", "=>", "$", "viability", ")", "{", "if", "(", "in_array", "(", "$", "viability", "->", "getUnderElementtypeId", "(", ")", ",", "$", "parentIds", ")", ")", "{", "unset", "(", "$", "parentIds", "[", "array_search", "(", "$", "viability", "->", "getUnderElementtypeId", "(", ")", ",", "$", "parentIds", ")", "]", ")", ";", "unset", "(", "$", "viabilities", "[", "$", "index", "]", ")", ";", "}", "}", "foreach", "(", "$", "parentIds", "as", "$", "parentId", ")", "{", "$", "viability", "=", "new", "ElementtypeApply", "(", ")", ";", "$", "viability", "->", "setElementtypeId", "(", "$", "elementtype", "->", "getId", "(", ")", ")", "->", "setUnderElementtypeId", "(", "$", "parentId", ")", ";", "$", "this", "->", "entityManager", "->", "persist", "(", "$", "viability", ")", ";", "}", "foreach", "(", "$", "viabilities", "as", "$", "viability", ")", "{", "$", "this", "->", "entityManager", "->", "remove", "(", "$", "viability", ")", ";", "}", "$", "this", "->", "entityManager", "->", "flush", "(", ")", ";", "}" ]
Update viability. @param Elementtype $elementtype @param array $parentIds @return $this
[ "Update", "viability", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Doctrine/ViabilityManager.php#L71-L98
7,741
wasabi-cms/cms
src/Event/RouteListener.php
RouteListener.decoratePublishedQuery
public function decoratePublishedQuery(Event $event) { $query = $event->subject(); // Join the PagesTable $query ->select(['Pages.id']) ->join([ 'Pages' => [ 'table' => 'cms_pages', 'type' => 'LEFT', 'conditions' => [ 'MenuItems.foreign_model = "Wasabi/Cms.Pages"', 'MenuItems.foreign_id = Pages.id', 'Pages.status' => Page::STATUS_PUBLISHED ] ] ]); }
php
public function decoratePublishedQuery(Event $event) { $query = $event->subject(); // Join the PagesTable $query ->select(['Pages.id']) ->join([ 'Pages' => [ 'table' => 'cms_pages', 'type' => 'LEFT', 'conditions' => [ 'MenuItems.foreign_model = "Wasabi/Cms.Pages"', 'MenuItems.foreign_id = Pages.id', 'Pages.status' => Page::STATUS_PUBLISHED ] ] ]); }
[ "public", "function", "decoratePublishedQuery", "(", "Event", "$", "event", ")", "{", "$", "query", "=", "$", "event", "->", "subject", "(", ")", ";", "// Join the PagesTable", "$", "query", "->", "select", "(", "[", "'Pages.id'", "]", ")", "->", "join", "(", "[", "'Pages'", "=>", "[", "'table'", "=>", "'cms_pages'", ",", "'type'", "=>", "'LEFT'", ",", "'conditions'", "=>", "[", "'MenuItems.foreign_model = \"Wasabi/Cms.Pages\"'", ",", "'MenuItems.foreign_id = Pages.id'", ",", "'Pages.status'", "=>", "Page", "::", "STATUS_PUBLISHED", "]", "]", "]", ")", ";", "}" ]
Decorate the given query by joining the PagesTable. @param Event $event @return void
[ "Decorate", "the", "given", "query", "by", "joining", "the", "PagesTable", "." ]
2787b6422ea1d719cf49951b3253fd0ac31d22ca
https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/Event/RouteListener.php#L97-L115
7,742
zicht/z-plugin-log
log/Plugin.php
Plugin.slackify
private function slackify($data) { $fields = array(); foreach ($data as $key => $value) { $obj = new \stdClass(); $obj->title = $key; $obj->value = $value; $obj->short = true; $fields[] = $obj; } return array('text' => sprintf('%s - %s (%s)', $data['projectname'], $data['task'], $data['step']), 'fields' => $fields); }
php
private function slackify($data) { $fields = array(); foreach ($data as $key => $value) { $obj = new \stdClass(); $obj->title = $key; $obj->value = $value; $obj->short = true; $fields[] = $obj; } return array('text' => sprintf('%s - %s (%s)', $data['projectname'], $data['task'], $data['step']), 'fields' => $fields); }
[ "private", "function", "slackify", "(", "$", "data", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "obj", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "obj", "->", "title", "=", "$", "key", ";", "$", "obj", "->", "value", "=", "$", "value", ";", "$", "obj", "->", "short", "=", "true", ";", "$", "fields", "[", "]", "=", "$", "obj", ";", "}", "return", "array", "(", "'text'", "=>", "sprintf", "(", "'%s - %s (%s)'", ",", "$", "data", "[", "'projectname'", "]", ",", "$", "data", "[", "'task'", "]", ",", "$", "data", "[", "'step'", "]", ")", ",", "'fields'", "=>", "$", "fields", ")", ";", "}" ]
Format the data in slack format @param $data @return string
[ "Format", "the", "data", "in", "slack", "format" ]
4d738990500e5318e3e13f020b99e2f576f61728
https://github.com/zicht/z-plugin-log/blob/4d738990500e5318e3e13f020b99e2f576f61728/log/Plugin.php#L117-L131
7,743
Jinxes/layton
Layton/Services/DependentService.php
DependentService.call
public function call($subject, $inherentParams = []) { $reflectionFunction = new ReflectionFunction($subject); $reflectionParameters = $this->getReflectionParameters( $reflectionFunction, count($inherentParams) ); $dependentInstances = []; foreach($reflectionParameters as $reflectionParameter) { $dependentInstances[] = $this->getDependentByParameter($reflectionParameter) ->getInstance(); } $params = array_merge($dependentInstances, $inherentParams); $closure = $reflectionFunction->getClosure(); return call_user_func_array($closure, $params); }
php
public function call($subject, $inherentParams = []) { $reflectionFunction = new ReflectionFunction($subject); $reflectionParameters = $this->getReflectionParameters( $reflectionFunction, count($inherentParams) ); $dependentInstances = []; foreach($reflectionParameters as $reflectionParameter) { $dependentInstances[] = $this->getDependentByParameter($reflectionParameter) ->getInstance(); } $params = array_merge($dependentInstances, $inherentParams); $closure = $reflectionFunction->getClosure(); return call_user_func_array($closure, $params); }
[ "public", "function", "call", "(", "$", "subject", ",", "$", "inherentParams", "=", "[", "]", ")", "{", "$", "reflectionFunction", "=", "new", "ReflectionFunction", "(", "$", "subject", ")", ";", "$", "reflectionParameters", "=", "$", "this", "->", "getReflectionParameters", "(", "$", "reflectionFunction", ",", "count", "(", "$", "inherentParams", ")", ")", ";", "$", "dependentInstances", "=", "[", "]", ";", "foreach", "(", "$", "reflectionParameters", "as", "$", "reflectionParameter", ")", "{", "$", "dependentInstances", "[", "]", "=", "$", "this", "->", "getDependentByParameter", "(", "$", "reflectionParameter", ")", "->", "getInstance", "(", ")", ";", "}", "$", "params", "=", "array_merge", "(", "$", "dependentInstances", ",", "$", "inherentParams", ")", ";", "$", "closure", "=", "$", "reflectionFunction", "->", "getClosure", "(", ")", ";", "return", "call_user_func_array", "(", "$", "closure", ",", "$", "params", ")", ";", "}" ]
reverse a function and save singleton @param callback $subject @param array $inherentParams @return mixed
[ "reverse", "a", "function", "and", "save", "singleton" ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Services/DependentService.php#L48-L64
7,744
Jinxes/layton
Layton/Services/DependentService.php
DependentService.getReflectionParameters
protected function getReflectionParameters($reflection, $inherentNumber) { $reflectionParameters = $reflection->getParameters(); return array_slice($reflectionParameters, 0, count($reflectionParameters) - $inherentNumber); }
php
protected function getReflectionParameters($reflection, $inherentNumber) { $reflectionParameters = $reflection->getParameters(); return array_slice($reflectionParameters, 0, count($reflectionParameters) - $inherentNumber); }
[ "protected", "function", "getReflectionParameters", "(", "$", "reflection", ",", "$", "inherentNumber", ")", "{", "$", "reflectionParameters", "=", "$", "reflection", "->", "getParameters", "(", ")", ";", "return", "array_slice", "(", "$", "reflectionParameters", ",", "0", ",", "count", "(", "$", "reflectionParameters", ")", "-", "$", "inherentNumber", ")", ";", "}" ]
get instances of params from Reflection @param \Reflector $reflection @param num $inherentNumber @return ReflectionParameter[]
[ "get", "instances", "of", "params", "from", "Reflection" ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Services/DependentService.php#L97-L101
7,745
Jinxes/layton
Layton/Services/DependentService.php
DependentService.getParams
public function getParams($reflectionClass, $method, $inherentNumber = 0) { $instances = []; if (!$reflectionClass->hasMethod($method)) { return $instances; } $reflection = $reflectionClass->getMethod($method); $reflectionParameters = $this->getReflectionParameters($reflection, $inherentNumber); foreach($reflectionParameters as $reflectionParameter) { $instances[] = $this->getDependentByParameter($reflectionParameter)->getInstance(); } return $instances; }
php
public function getParams($reflectionClass, $method, $inherentNumber = 0) { $instances = []; if (!$reflectionClass->hasMethod($method)) { return $instances; } $reflection = $reflectionClass->getMethod($method); $reflectionParameters = $this->getReflectionParameters($reflection, $inherentNumber); foreach($reflectionParameters as $reflectionParameter) { $instances[] = $this->getDependentByParameter($reflectionParameter)->getInstance(); } return $instances; }
[ "public", "function", "getParams", "(", "$", "reflectionClass", ",", "$", "method", ",", "$", "inherentNumber", "=", "0", ")", "{", "$", "instances", "=", "[", "]", ";", "if", "(", "!", "$", "reflectionClass", "->", "hasMethod", "(", "$", "method", ")", ")", "{", "return", "$", "instances", ";", "}", "$", "reflection", "=", "$", "reflectionClass", "->", "getMethod", "(", "$", "method", ")", ";", "$", "reflectionParameters", "=", "$", "this", "->", "getReflectionParameters", "(", "$", "reflection", ",", "$", "inherentNumber", ")", ";", "foreach", "(", "$", "reflectionParameters", "as", "$", "reflectionParameter", ")", "{", "$", "instances", "[", "]", "=", "$", "this", "->", "getDependentByParameter", "(", "$", "reflectionParameter", ")", "->", "getInstance", "(", ")", ";", "}", "return", "$", "instances", ";", "}" ]
instantiation param list of method and save @param ReflectionClass $refClass @param string $method @param int inherentNumber @return array
[ "instantiation", "param", "list", "of", "method", "and", "save" ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Services/DependentService.php#L112-L126
7,746
rybakdigital/fapi
Component/Routing/Matcher.php
Matcher.match
public function match(RouteCollection $collection, Request $request) { // Save collection and Request $this->collection = $collection; $this->request = $request; // Get candidates and ask Voter to decide which candidate mathes best return $this->voter->vote($this->getCandidates(), $request); }
php
public function match(RouteCollection $collection, Request $request) { // Save collection and Request $this->collection = $collection; $this->request = $request; // Get candidates and ask Voter to decide which candidate mathes best return $this->voter->vote($this->getCandidates(), $request); }
[ "public", "function", "match", "(", "RouteCollection", "$", "collection", ",", "Request", "$", "request", ")", "{", "// Save collection and Request", "$", "this", "->", "collection", "=", "$", "collection", ";", "$", "this", "->", "request", "=", "$", "request", ";", "// Get candidates and ask Voter to decide which candidate mathes best", "return", "$", "this", "->", "voter", "->", "vote", "(", "$", "this", "->", "getCandidates", "(", ")", ",", "$", "request", ")", ";", "}" ]
Matches current Request to Route
[ "Matches", "current", "Request", "to", "Route" ]
739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027
https://github.com/rybakdigital/fapi/blob/739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027/Component/Routing/Matcher.php#L50-L58
7,747
rybakdigital/fapi
Component/Routing/Matcher.php
Matcher.getCandidates
public function getCandidates() { $candidates = array(); foreach ($this->collection->all() as $name => $route) { $specs = array(); preg_match_all('/\{\w+\}/', $route->getPath(), $matches); if (isset($matches[0])) { $specs = $matches[0]; } foreach ($specs as $spec) { $param = substr($spec, 1, -1); $regexSpec = '\\'.$spec.'\\'; $requirements = $route->getRequirements(); if (isset($requirements[$param])) { $route->setRegex( str_replace( $spec, $this->getRegexOperand($requirements[$param]), $route->getRegex() ) ); } } // Build regeular expression to match routes $route->setRegex('^'.'/'.ltrim(trim($route->getRegex()), '/').'/?$'); $route->setRegex('/'.str_replace('/', '\/', $route->getRegex()).'/'); if (preg_match($route->getRegex(), $this->request->getPathInfo())) { // We have a match $candidates[] = $route; } } return $candidates; }
php
public function getCandidates() { $candidates = array(); foreach ($this->collection->all() as $name => $route) { $specs = array(); preg_match_all('/\{\w+\}/', $route->getPath(), $matches); if (isset($matches[0])) { $specs = $matches[0]; } foreach ($specs as $spec) { $param = substr($spec, 1, -1); $regexSpec = '\\'.$spec.'\\'; $requirements = $route->getRequirements(); if (isset($requirements[$param])) { $route->setRegex( str_replace( $spec, $this->getRegexOperand($requirements[$param]), $route->getRegex() ) ); } } // Build regeular expression to match routes $route->setRegex('^'.'/'.ltrim(trim($route->getRegex()), '/').'/?$'); $route->setRegex('/'.str_replace('/', '\/', $route->getRegex()).'/'); if (preg_match($route->getRegex(), $this->request->getPathInfo())) { // We have a match $candidates[] = $route; } } return $candidates; }
[ "public", "function", "getCandidates", "(", ")", "{", "$", "candidates", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "collection", "->", "all", "(", ")", "as", "$", "name", "=>", "$", "route", ")", "{", "$", "specs", "=", "array", "(", ")", ";", "preg_match_all", "(", "'/\\{\\w+\\}/'", ",", "$", "route", "->", "getPath", "(", ")", ",", "$", "matches", ")", ";", "if", "(", "isset", "(", "$", "matches", "[", "0", "]", ")", ")", "{", "$", "specs", "=", "$", "matches", "[", "0", "]", ";", "}", "foreach", "(", "$", "specs", "as", "$", "spec", ")", "{", "$", "param", "=", "substr", "(", "$", "spec", ",", "1", ",", "-", "1", ")", ";", "$", "regexSpec", "=", "'\\\\'", ".", "$", "spec", ".", "'\\\\'", ";", "$", "requirements", "=", "$", "route", "->", "getRequirements", "(", ")", ";", "if", "(", "isset", "(", "$", "requirements", "[", "$", "param", "]", ")", ")", "{", "$", "route", "->", "setRegex", "(", "str_replace", "(", "$", "spec", ",", "$", "this", "->", "getRegexOperand", "(", "$", "requirements", "[", "$", "param", "]", ")", ",", "$", "route", "->", "getRegex", "(", ")", ")", ")", ";", "}", "}", "// Build regeular expression to match routes", "$", "route", "->", "setRegex", "(", "'^'", ".", "'/'", ".", "ltrim", "(", "trim", "(", "$", "route", "->", "getRegex", "(", ")", ")", ",", "'/'", ")", ".", "'/?$'", ")", ";", "$", "route", "->", "setRegex", "(", "'/'", ".", "str_replace", "(", "'/'", ",", "'\\/'", ",", "$", "route", "->", "getRegex", "(", ")", ")", ".", "'/'", ")", ";", "if", "(", "preg_match", "(", "$", "route", "->", "getRegex", "(", ")", ",", "$", "this", "->", "request", "->", "getPathInfo", "(", ")", ")", ")", "{", "// We have a match", "$", "candidates", "[", "]", "=", "$", "route", ";", "}", "}", "return", "$", "candidates", ";", "}" ]
Gets list of candidate Route objects for request @return array List of Route objects
[ "Gets", "list", "of", "candidate", "Route", "objects", "for", "request" ]
739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027
https://github.com/rybakdigital/fapi/blob/739dfa0fc0b17ab8e8ac8f8e86484f7e62b21027/Component/Routing/Matcher.php#L65-L106
7,748
unimatrix/cake
src/Lib/Paranoia.php
Paranoia.base64encode
public static function base64encode($input) { return strtr(base64_encode($input), key(self::$urlSafe), current(self::$urlSafe)); }
php
public static function base64encode($input) { return strtr(base64_encode($input), key(self::$urlSafe), current(self::$urlSafe)); }
[ "public", "static", "function", "base64encode", "(", "$", "input", ")", "{", "return", "strtr", "(", "base64_encode", "(", "$", "input", ")", ",", "key", "(", "self", "::", "$", "urlSafe", ")", ",", "current", "(", "self", "::", "$", "urlSafe", ")", ")", ";", "}" ]
Perform a URL safe base64 encode @param string $input @return string
[ "Perform", "a", "URL", "safe", "base64", "encode" ]
23003aba497822bd473fdbf60514052dda1874fc
https://github.com/unimatrix/cake/blob/23003aba497822bd473fdbf60514052dda1874fc/src/Lib/Paranoia.php#L121-L123
7,749
unimatrix/cake
src/Lib/Paranoia.php
Paranoia.base64decode
public static function base64decode($input) { return base64_decode(str_pad(strtr($input, current(self::$urlSafe), key(self::$urlSafe)), strlen($input) % 4, '=', STR_PAD_RIGHT)); }
php
public static function base64decode($input) { return base64_decode(str_pad(strtr($input, current(self::$urlSafe), key(self::$urlSafe)), strlen($input) % 4, '=', STR_PAD_RIGHT)); }
[ "public", "static", "function", "base64decode", "(", "$", "input", ")", "{", "return", "base64_decode", "(", "str_pad", "(", "strtr", "(", "$", "input", ",", "current", "(", "self", "::", "$", "urlSafe", ")", ",", "key", "(", "self", "::", "$", "urlSafe", ")", ")", ",", "strlen", "(", "$", "input", ")", "%", "4", ",", "'='", ",", "STR_PAD_RIGHT", ")", ")", ";", "}" ]
Perform a URL safe base 64 decode @param string $input @return string
[ "Perform", "a", "URL", "safe", "base", "64", "decode" ]
23003aba497822bd473fdbf60514052dda1874fc
https://github.com/unimatrix/cake/blob/23003aba497822bd473fdbf60514052dda1874fc/src/Lib/Paranoia.php#L130-L132
7,750
unimatrix/cake
src/Lib/Paranoia.php
Paranoia.xor
private static function xor($input, $secret = null) { // perform xor $inputSize = strlen($input); $secretSize = strlen($secret); for($y = 0, $x = 0; $y < $inputSize; $y++, $x++) { if($x >= $secretSize) $x = 0; $input[$y] = $input[$y] ^ $secret[$x]; } // output return $input; }
php
private static function xor($input, $secret = null) { // perform xor $inputSize = strlen($input); $secretSize = strlen($secret); for($y = 0, $x = 0; $y < $inputSize; $y++, $x++) { if($x >= $secretSize) $x = 0; $input[$y] = $input[$y] ^ $secret[$x]; } // output return $input; }
[ "private", "static", "function", "xor", "(", "$", "input", ",", "$", "secret", "=", "null", ")", "{", "// perform xor", "$", "inputSize", "=", "strlen", "(", "$", "input", ")", ";", "$", "secretSize", "=", "strlen", "(", "$", "secret", ")", ";", "for", "(", "$", "y", "=", "0", ",", "$", "x", "=", "0", ";", "$", "y", "<", "$", "inputSize", ";", "$", "y", "++", ",", "$", "x", "++", ")", "{", "if", "(", "$", "x", ">=", "$", "secretSize", ")", "$", "x", "=", "0", ";", "$", "input", "[", "$", "y", "]", "=", "$", "input", "[", "$", "y", "]", "^", "$", "secret", "[", "$", "x", "]", ";", "}", "// output", "return", "$", "input", ";", "}" ]
Perform the XOR @param string $input @param string $secret Paranoia secret @return string
[ "Perform", "the", "XOR" ]
23003aba497822bd473fdbf60514052dda1874fc
https://github.com/unimatrix/cake/blob/23003aba497822bd473fdbf60514052dda1874fc/src/Lib/Paranoia.php#L140-L153
7,751
vpg/titon.common
src/Titon/Common/Config.php
Config.add
public static function add($key, $value) { $data = (array) static::get($key, []); $data[] = $value; static::set($key, $data); }
php
public static function add($key, $value) { $data = (array) static::get($key, []); $data[] = $value; static::set($key, $data); }
[ "public", "static", "function", "add", "(", "$", "key", ",", "$", "value", ")", "{", "$", "data", "=", "(", "array", ")", "static", "::", "get", "(", "$", "key", ",", "[", "]", ")", ";", "$", "data", "[", "]", "=", "$", "value", ";", "static", "::", "set", "(", "$", "key", ",", "$", "data", ")", ";", "}" ]
Add a value to a key. If the value is not an array, make it one. @param string $key @param mixed $value
[ "Add", "a", "value", "to", "a", "key", ".", "If", "the", "value", "is", "not", "an", "array", "make", "it", "one", "." ]
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Config.php#L35-L40
7,752
vpg/titon.common
src/Titon/Common/Config.php
Config.get
public static function get($key, $default = null) { $value = Hash::get(static::$_config, $key); if ($value === null) { return $default; } return $value; }
php
public static function get($key, $default = null) { $value = Hash::get(static::$_config, $key); if ($value === null) { return $default; } return $value; }
[ "public", "static", "function", "get", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "$", "value", "=", "Hash", "::", "get", "(", "static", "::", "$", "_config", ",", "$", "key", ")", ";", "if", "(", "$", "value", "===", "null", ")", "{", "return", "$", "default", ";", "}", "return", "$", "value", ";", "}" ]
Grab a value from the current configuration. @param string $key @param mixed $default @return mixed
[ "Grab", "a", "value", "from", "the", "current", "configuration", "." ]
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Config.php#L67-L75
7,753
coolms/doctrine
src/Mapping/Relation/Mapping/Event/Adapter/ORM.php
ORM.relationToArray
private function relationToArray(RelationOverride $relation) { if ($relation->type && !is_numeric($relation->type)) { $relation->type = constant(ClassMetadata::class . '::' . $relation->type); } return array_filter([ 'type' => $relation->type, 'targetEntity' => $relation->targetEntity, 'fieldName' => $relation->name, 'inversedBy' => $relation->inversedBy, 'mappedBy' => $relation->mappedBy, 'fetch' => $relation->fetch, 'cascade' => $relation->cascade, 'orphanRemoval' => $relation->orphanRemoval, ]); }
php
private function relationToArray(RelationOverride $relation) { if ($relation->type && !is_numeric($relation->type)) { $relation->type = constant(ClassMetadata::class . '::' . $relation->type); } return array_filter([ 'type' => $relation->type, 'targetEntity' => $relation->targetEntity, 'fieldName' => $relation->name, 'inversedBy' => $relation->inversedBy, 'mappedBy' => $relation->mappedBy, 'fetch' => $relation->fetch, 'cascade' => $relation->cascade, 'orphanRemoval' => $relation->orphanRemoval, ]); }
[ "private", "function", "relationToArray", "(", "RelationOverride", "$", "relation", ")", "{", "if", "(", "$", "relation", "->", "type", "&&", "!", "is_numeric", "(", "$", "relation", "->", "type", ")", ")", "{", "$", "relation", "->", "type", "=", "constant", "(", "ClassMetadata", "::", "class", ".", "'::'", ".", "$", "relation", "->", "type", ")", ";", "}", "return", "array_filter", "(", "[", "'type'", "=>", "$", "relation", "->", "type", ",", "'targetEntity'", "=>", "$", "relation", "->", "targetEntity", ",", "'fieldName'", "=>", "$", "relation", "->", "name", ",", "'inversedBy'", "=>", "$", "relation", "->", "inversedBy", ",", "'mappedBy'", "=>", "$", "relation", "->", "mappedBy", ",", "'fetch'", "=>", "$", "relation", "->", "fetch", ",", "'cascade'", "=>", "$", "relation", "->", "cascade", ",", "'orphanRemoval'", "=>", "$", "relation", "->", "orphanRemoval", ",", "]", ")", ";", "}" ]
Parse the given RelationOverride as array @param RelationOverride $relation @return array
[ "Parse", "the", "given", "RelationOverride", "as", "array" ]
d7d233594b37cd0c3abc37a46e4e4b965767c3b4
https://github.com/coolms/doctrine/blob/d7d233594b37cd0c3abc37a46e4e4b965767c3b4/src/Mapping/Relation/Mapping/Event/Adapter/ORM.php#L182-L198
7,754
coolms/doctrine
src/Mapping/Relation/Mapping/Event/Adapter/ORM.php
ORM.joinColumnToArray
private function joinColumnToArray(JoinColumn $joinColumn) { return [ 'name' => $joinColumn->name, 'unique' => $joinColumn->unique, 'nullable' => $joinColumn->nullable, 'onDelete' => $joinColumn->onDelete, 'columnDefinition' => $joinColumn->columnDefinition, 'referencedColumnName' => $joinColumn->referencedColumnName, ]; }
php
private function joinColumnToArray(JoinColumn $joinColumn) { return [ 'name' => $joinColumn->name, 'unique' => $joinColumn->unique, 'nullable' => $joinColumn->nullable, 'onDelete' => $joinColumn->onDelete, 'columnDefinition' => $joinColumn->columnDefinition, 'referencedColumnName' => $joinColumn->referencedColumnName, ]; }
[ "private", "function", "joinColumnToArray", "(", "JoinColumn", "$", "joinColumn", ")", "{", "return", "[", "'name'", "=>", "$", "joinColumn", "->", "name", ",", "'unique'", "=>", "$", "joinColumn", "->", "unique", ",", "'nullable'", "=>", "$", "joinColumn", "->", "nullable", ",", "'onDelete'", "=>", "$", "joinColumn", "->", "onDelete", ",", "'columnDefinition'", "=>", "$", "joinColumn", "->", "columnDefinition", ",", "'referencedColumnName'", "=>", "$", "joinColumn", "->", "referencedColumnName", ",", "]", ";", "}" ]
Parse the given JoinColumn as array @param JoinColumn $joinColumn @return array
[ "Parse", "the", "given", "JoinColumn", "as", "array" ]
d7d233594b37cd0c3abc37a46e4e4b965767c3b4
https://github.com/coolms/doctrine/blob/d7d233594b37cd0c3abc37a46e4e4b965767c3b4/src/Mapping/Relation/Mapping/Event/Adapter/ORM.php#L206-L216
7,755
Opifer/FormBundle
Model/FormManager.php
FormManager.create
public function create() { $class = $this->getClass(); $form = new $class(); $schema = $this->schemaManager->create(); $schema->setObjectClass($this->postManager->getClass()); $form->setSchema($schema); return $form; }
php
public function create() { $class = $this->getClass(); $form = new $class(); $schema = $this->schemaManager->create(); $schema->setObjectClass($this->postManager->getClass()); $form->setSchema($schema); return $form; }
[ "public", "function", "create", "(", ")", "{", "$", "class", "=", "$", "this", "->", "getClass", "(", ")", ";", "$", "form", "=", "new", "$", "class", "(", ")", ";", "$", "schema", "=", "$", "this", "->", "schemaManager", "->", "create", "(", ")", ";", "$", "schema", "->", "setObjectClass", "(", "$", "this", "->", "postManager", "->", "getClass", "(", ")", ")", ";", "$", "form", "->", "setSchema", "(", "$", "schema", ")", ";", "return", "$", "form", ";", "}" ]
Create a new form instance. @return Form
[ "Create", "a", "new", "form", "instance", "." ]
cac3bc2e64de8297e18d90addb114694bd3ba756
https://github.com/Opifer/FormBundle/blob/cac3bc2e64de8297e18d90addb114694bd3ba756/Model/FormManager.php#L56-L67
7,756
kevindierkx/elicit
src/Query/Grammars/AbstractGrammar.php
AbstractGrammar.hasReplacedParameter
public function hasReplacedParameter(array $parameter) { foreach ($this->replacedParameters as $replacedParameter) { if ($replacedParameter['column'] === $parameter['column'] && $replacedParameter['value'] === $parameter['value'] ) { return true; } } return false; }
php
public function hasReplacedParameter(array $parameter) { foreach ($this->replacedParameters as $replacedParameter) { if ($replacedParameter['column'] === $parameter['column'] && $replacedParameter['value'] === $parameter['value'] ) { return true; } } return false; }
[ "public", "function", "hasReplacedParameter", "(", "array", "$", "parameter", ")", "{", "foreach", "(", "$", "this", "->", "replacedParameters", "as", "$", "replacedParameter", ")", "{", "if", "(", "$", "replacedParameter", "[", "'column'", "]", "===", "$", "parameter", "[", "'column'", "]", "&&", "$", "replacedParameter", "[", "'value'", "]", "===", "$", "parameter", "[", "'value'", "]", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Validate the existence of a replaced parameter. @param array $parameter @return boolean
[ "Validate", "the", "existence", "of", "a", "replaced", "parameter", "." ]
c277942f5f5f63b175bc37e9d392faa946888f65
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Query/Grammars/AbstractGrammar.php#L80-L91
7,757
mazarini/tools-bundle
src/DependencyInjection/Configuration.php
Configuration.build
protected function build(ArrayNodeDefinition $rootNode): void { $rootNode ->children() ->integerNode('max_items')->defaultValue(20)->info('How much for max items')->end() ; }
php
protected function build(ArrayNodeDefinition $rootNode): void { $rootNode ->children() ->integerNode('max_items')->defaultValue(20)->info('How much for max items')->end() ; }
[ "protected", "function", "build", "(", "ArrayNodeDefinition", "$", "rootNode", ")", ":", "void", "{", "$", "rootNode", "->", "children", "(", ")", "->", "integerNode", "(", "'max_items'", ")", "->", "defaultValue", "(", "20", ")", "->", "info", "(", "'How much for max items'", ")", "->", "end", "(", ")", ";", "}" ]
Build the config tree. @param ArrayNodeDefinition $rootNode
[ "Build", "the", "config", "tree", "." ]
60a4a45de85d7b5a6b7e84fe636a5c22f376c4d1
https://github.com/mazarini/tools-bundle/blob/60a4a45de85d7b5a6b7e84fe636a5c22f376c4d1/src/DependencyInjection/Configuration.php#L34-L40
7,758
interactivesolutions/honeycomb-menu
src/app/http/controllers/menu/GroupsController.php
GroupsController.options
public function options() { if( request()->has('language') ) { return HCMenuGroups::select("id", "name") ->where('language_code', request()->input('language')) ->orderBy('sequence') ->take(50) ->get(); } return []; }
php
public function options() { if( request()->has('language') ) { return HCMenuGroups::select("id", "name") ->where('language_code', request()->input('language')) ->orderBy('sequence') ->take(50) ->get(); } return []; }
[ "public", "function", "options", "(", ")", "{", "if", "(", "request", "(", ")", "->", "has", "(", "'language'", ")", ")", "{", "return", "HCMenuGroups", "::", "select", "(", "\"id\"", ",", "\"name\"", ")", "->", "where", "(", "'language_code'", ",", "request", "(", ")", "->", "input", "(", "'language'", ")", ")", "->", "orderBy", "(", "'sequence'", ")", "->", "take", "(", "50", ")", "->", "get", "(", ")", ";", "}", "return", "[", "]", ";", "}" ]
Search for users @return mixed
[ "Search", "for", "users" ]
9ba3a6581f9929fc4526b6f238991808b437657a
https://github.com/interactivesolutions/honeycomb-menu/blob/9ba3a6581f9929fc4526b6f238991808b437657a/src/app/http/controllers/menu/GroupsController.php#L255-L266
7,759
diatem-net/jin-webapp
src/WebApp/Context/View.php
View.executeAndReturnContent
public function executeAndReturnContent() { ob_start(); Output::$controller = WebApp::$page->controller; include $this->file; $content = ob_get_contents(); ob_clean(); return $content; }
php
public function executeAndReturnContent() { ob_start(); Output::$controller = WebApp::$page->controller; include $this->file; $content = ob_get_contents(); ob_clean(); return $content; }
[ "public", "function", "executeAndReturnContent", "(", ")", "{", "ob_start", "(", ")", ";", "Output", "::", "$", "controller", "=", "WebApp", "::", "$", "page", "->", "controller", ";", "include", "$", "this", "->", "file", ";", "$", "content", "=", "ob_get_contents", "(", ")", ";", "ob_clean", "(", ")", ";", "return", "$", "content", ";", "}" ]
Return the view content @return string
[ "Return", "the", "view", "content" ]
43e85f780c3841a536e3a5d41929523e5aacd272
https://github.com/diatem-net/jin-webapp/blob/43e85f780c3841a536e3a5d41929523e5aacd272/src/WebApp/Context/View.php#L47-L56
7,760
getconnect/connect-php
src/Event.php
Event.validate
private function validate() { $errors = []; foreach ($this->eventDetails as $key => $value) { if (strpos($key, 'tp_') !== false) { $errors[$key] = 'Property names cannot start with the reserved prefix \'tp_\''; } if (strpos($key, '.') !== false) { $errors[$key] = 'Property names cannot contain a period (.)'; } if (strcmp($key, '_id') == 0) { $errors[$key] = 'Top level properties cannot be named \'_id\''; } } if (!empty($errors)) { throw new InvalidPropertyNameException($errors); } }
php
private function validate() { $errors = []; foreach ($this->eventDetails as $key => $value) { if (strpos($key, 'tp_') !== false) { $errors[$key] = 'Property names cannot start with the reserved prefix \'tp_\''; } if (strpos($key, '.') !== false) { $errors[$key] = 'Property names cannot contain a period (.)'; } if (strcmp($key, '_id') == 0) { $errors[$key] = 'Top level properties cannot be named \'_id\''; } } if (!empty($errors)) { throw new InvalidPropertyNameException($errors); } }
[ "private", "function", "validate", "(", ")", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "eventDetails", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "key", ",", "'tp_'", ")", "!==", "false", ")", "{", "$", "errors", "[", "$", "key", "]", "=", "'Property names cannot start with the reserved prefix \\'tp_\\''", ";", "}", "if", "(", "strpos", "(", "$", "key", ",", "'.'", ")", "!==", "false", ")", "{", "$", "errors", "[", "$", "key", "]", "=", "'Property names cannot contain a period (.)'", ";", "}", "if", "(", "strcmp", "(", "$", "key", ",", "'_id'", ")", "==", "0", ")", "{", "$", "errors", "[", "$", "key", "]", "=", "'Top level properties cannot be named \\'_id\\''", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "errors", ")", ")", "{", "throw", "new", "InvalidPropertyNameException", "(", "$", "errors", ")", ";", "}", "}" ]
Checks if an event is valid for Connect. @throws InvalidPropertyNameException if the event contains invalid properties.
[ "Checks", "if", "an", "event", "is", "valid", "for", "Connect", "." ]
cbce3daae58eca16450df811ac6f1280fc1ef6b1
https://github.com/getconnect/connect-php/blob/cbce3daae58eca16450df811ac6f1280fc1ef6b1/src/Event.php#L35-L53
7,761
getconnect/connect-php
src/Event.php
Event.process
private function process(&$details) { foreach ($details as &$value) { if (is_array($value)) { $this->process($value); continue; } if ($value instanceof \DateTime) { $value = $value->format(\DateTime::ISO8601); continue; } } }
php
private function process(&$details) { foreach ($details as &$value) { if (is_array($value)) { $this->process($value); continue; } if ($value instanceof \DateTime) { $value = $value->format(\DateTime::ISO8601); continue; } } }
[ "private", "function", "process", "(", "&", "$", "details", ")", "{", "foreach", "(", "$", "details", "as", "&", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "this", "->", "process", "(", "$", "value", ")", ";", "continue", ";", "}", "if", "(", "$", "value", "instanceof", "\\", "DateTime", ")", "{", "$", "value", "=", "$", "value", "->", "format", "(", "\\", "DateTime", "::", "ISO8601", ")", ";", "continue", ";", "}", "}", "}" ]
Recursively converts any nested DateTime instances to ISO8601 strings in preparation for serialization. Note, mutates the supplied array. @param array Properties to convert.
[ "Recursively", "converts", "any", "nested", "DateTime", "instances", "to", "ISO8601", "strings", "in", "preparation", "for", "serialization", ".", "Note", "mutates", "the", "supplied", "array", "." ]
cbce3daae58eca16450df811ac6f1280fc1ef6b1
https://github.com/getconnect/connect-php/blob/cbce3daae58eca16450df811ac6f1280fc1ef6b1/src/Event.php#L60-L71
7,762
jianfengye/hades
src/Hades/Log/Logger.php
Logger.gc
public static function gc($name) { $files = glob(self::$folder . "/{$name}_*.log"); foreach ($files as $filename) { $date = str_replace(self::$folder . "/{$name}_" , "", $filename); $date = str_replace(".log", "", $date); if (time() - strtotime($date) > self::$rotate * 3600 * 24) { unlink($filename); } } }
php
public static function gc($name) { $files = glob(self::$folder . "/{$name}_*.log"); foreach ($files as $filename) { $date = str_replace(self::$folder . "/{$name}_" , "", $filename); $date = str_replace(".log", "", $date); if (time() - strtotime($date) > self::$rotate * 3600 * 24) { unlink($filename); } } }
[ "public", "static", "function", "gc", "(", "$", "name", ")", "{", "$", "files", "=", "glob", "(", "self", "::", "$", "folder", ".", "\"/{$name}_*.log\"", ")", ";", "foreach", "(", "$", "files", "as", "$", "filename", ")", "{", "$", "date", "=", "str_replace", "(", "self", "::", "$", "folder", ".", "\"/{$name}_\"", ",", "\"\"", ",", "$", "filename", ")", ";", "$", "date", "=", "str_replace", "(", "\".log\"", ",", "\"\"", ",", "$", "date", ")", ";", "if", "(", "time", "(", ")", "-", "strtotime", "(", "$", "date", ")", ">", "self", "::", "$", "rotate", "*", "3600", "*", "24", ")", "{", "unlink", "(", "$", "filename", ")", ";", "}", "}", "}" ]
gc the roate files
[ "gc", "the", "roate", "files" ]
a0690d96dada070b4cf4b9ff63ab3aa024c34a67
https://github.com/jianfengye/hades/blob/a0690d96dada070b4cf4b9ff63ab3aa024c34a67/src/Hades/Log/Logger.php#L58-L68
7,763
helsingborg-stad/search-statistics
source/php/SearchLogger.php
SearchLogger.log
public function log() { global $wp_query; if (!$wp_query->is_search() || max(1, get_query_var('paged')) > 1) { return; } global $wpdb; $query = get_search_query(); $hits = $wp_query->found_posts; $siteId = null; $loggedIn = is_user_logged_in(); if (isset($_COOKIE['search_log']) && is_array(unserialize(stripslashes($_COOKIE['search_log']))) && in_array($query, unserialize(stripslashes($_COOKIE['search_log'])))) { return; } if (is_multisite() && function_exists('get_current_blog_id')) { $siteId = get_current_blog_id(); } $insertedId = $wpdb->insert( \SearchStatistics\App::$dbTable, array( 'query' => $query, 'results' => $hits, 'site_id' => $siteId, 'logged_in' => $loggedIn ), array( '%s', '%d', '%d', '%d' ) ); $cookie = array(); if (isset($_COOKIE['search_log']) && is_array($_COOKIE['search_log'])) { $cookie = $_COOKIE['search_log']; } $cookie[] = $query; setcookie('search_log', serialize($cookie), time() + (86400 * 1), "/"); }
php
public function log() { global $wp_query; if (!$wp_query->is_search() || max(1, get_query_var('paged')) > 1) { return; } global $wpdb; $query = get_search_query(); $hits = $wp_query->found_posts; $siteId = null; $loggedIn = is_user_logged_in(); if (isset($_COOKIE['search_log']) && is_array(unserialize(stripslashes($_COOKIE['search_log']))) && in_array($query, unserialize(stripslashes($_COOKIE['search_log'])))) { return; } if (is_multisite() && function_exists('get_current_blog_id')) { $siteId = get_current_blog_id(); } $insertedId = $wpdb->insert( \SearchStatistics\App::$dbTable, array( 'query' => $query, 'results' => $hits, 'site_id' => $siteId, 'logged_in' => $loggedIn ), array( '%s', '%d', '%d', '%d' ) ); $cookie = array(); if (isset($_COOKIE['search_log']) && is_array($_COOKIE['search_log'])) { $cookie = $_COOKIE['search_log']; } $cookie[] = $query; setcookie('search_log', serialize($cookie), time() + (86400 * 1), "/"); }
[ "public", "function", "log", "(", ")", "{", "global", "$", "wp_query", ";", "if", "(", "!", "$", "wp_query", "->", "is_search", "(", ")", "||", "max", "(", "1", ",", "get_query_var", "(", "'paged'", ")", ")", ">", "1", ")", "{", "return", ";", "}", "global", "$", "wpdb", ";", "$", "query", "=", "get_search_query", "(", ")", ";", "$", "hits", "=", "$", "wp_query", "->", "found_posts", ";", "$", "siteId", "=", "null", ";", "$", "loggedIn", "=", "is_user_logged_in", "(", ")", ";", "if", "(", "isset", "(", "$", "_COOKIE", "[", "'search_log'", "]", ")", "&&", "is_array", "(", "unserialize", "(", "stripslashes", "(", "$", "_COOKIE", "[", "'search_log'", "]", ")", ")", ")", "&&", "in_array", "(", "$", "query", ",", "unserialize", "(", "stripslashes", "(", "$", "_COOKIE", "[", "'search_log'", "]", ")", ")", ")", ")", "{", "return", ";", "}", "if", "(", "is_multisite", "(", ")", "&&", "function_exists", "(", "'get_current_blog_id'", ")", ")", "{", "$", "siteId", "=", "get_current_blog_id", "(", ")", ";", "}", "$", "insertedId", "=", "$", "wpdb", "->", "insert", "(", "\\", "SearchStatistics", "\\", "App", "::", "$", "dbTable", ",", "array", "(", "'query'", "=>", "$", "query", ",", "'results'", "=>", "$", "hits", ",", "'site_id'", "=>", "$", "siteId", ",", "'logged_in'", "=>", "$", "loggedIn", ")", ",", "array", "(", "'%s'", ",", "'%d'", ",", "'%d'", ",", "'%d'", ")", ")", ";", "$", "cookie", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "_COOKIE", "[", "'search_log'", "]", ")", "&&", "is_array", "(", "$", "_COOKIE", "[", "'search_log'", "]", ")", ")", "{", "$", "cookie", "=", "$", "_COOKIE", "[", "'search_log'", "]", ";", "}", "$", "cookie", "[", "]", "=", "$", "query", ";", "setcookie", "(", "'search_log'", ",", "serialize", "(", "$", "cookie", ")", ",", "time", "(", ")", "+", "(", "86400", "*", "1", ")", ",", "\"/\"", ")", ";", "}" ]
Log search query to the database @return void
[ "Log", "search", "query", "to", "the", "database" ]
8ce0a6942a892fb0bbe67440c2527d282a3144d5
https://github.com/helsingborg-stad/search-statistics/blob/8ce0a6942a892fb0bbe67440c2527d282a3144d5/source/php/SearchLogger.php#L16-L65
7,764
slickframework/orm
src/Orm.php
Orm.setEmitter
public function setEmitter($entityClass, EmitterInterface $emitter) { $this->emitters->set($entityClass, $emitter); return $this; }
php
public function setEmitter($entityClass, EmitterInterface $emitter) { $this->emitters->set($entityClass, $emitter); return $this; }
[ "public", "function", "setEmitter", "(", "$", "entityClass", ",", "EmitterInterface", "$", "emitter", ")", "{", "$", "this", "->", "emitters", "->", "set", "(", "$", "entityClass", ",", "$", "emitter", ")", ";", "return", "$", "this", ";", "}" ]
Sets the emitter for provided class name @param string $entityClass @param EmitterInterface $emitter @return $this|self|Orm
[ "Sets", "the", "emitter", "for", "provided", "class", "name" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Orm.php#L140-L144
7,765
slickframework/orm
src/Orm.php
Orm.getRepositoryFor
public function getRepositoryFor($entityClass) { if (!is_subclass_of($entityClass, EntityInterface::class)) { throw new InvalidArgumentException( 'Cannot create ORM repository for a class that does not '. 'implement EntityInterface.' ); } return $this->repositories->containsKey($entityClass) ? $this->repositories->get($entityClass) : $this->createRepository($entityClass); }
php
public function getRepositoryFor($entityClass) { if (!is_subclass_of($entityClass, EntityInterface::class)) { throw new InvalidArgumentException( 'Cannot create ORM repository for a class that does not '. 'implement EntityInterface.' ); } return $this->repositories->containsKey($entityClass) ? $this->repositories->get($entityClass) : $this->createRepository($entityClass); }
[ "public", "function", "getRepositoryFor", "(", "$", "entityClass", ")", "{", "if", "(", "!", "is_subclass_of", "(", "$", "entityClass", ",", "EntityInterface", "::", "class", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Cannot create ORM repository for a class that does not '", ".", "'implement EntityInterface.'", ")", ";", "}", "return", "$", "this", "->", "repositories", "->", "containsKey", "(", "$", "entityClass", ")", "?", "$", "this", "->", "repositories", "->", "get", "(", "$", "entityClass", ")", ":", "$", "this", "->", "createRepository", "(", "$", "entityClass", ")", ";", "}" ]
Gets repository for provided entity class name @param string $entityClass FQ entity class name @return EntityRepository @throws InvalidArgumentException If provide class name is not from a class that implements the EntityInterface interface.
[ "Gets", "repository", "for", "provided", "entity", "class", "name" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Orm.php#L203-L215
7,766
slickframework/orm
src/Orm.php
Orm.getMapperFor
public function getMapperFor($entity) { return $this->mappers->containsKey($entity) ? $this->mappers->get($entity) : $this->createMapper($entity); }
php
public function getMapperFor($entity) { return $this->mappers->containsKey($entity) ? $this->mappers->get($entity) : $this->createMapper($entity); }
[ "public", "function", "getMapperFor", "(", "$", "entity", ")", "{", "return", "$", "this", "->", "mappers", "->", "containsKey", "(", "$", "entity", ")", "?", "$", "this", "->", "mappers", "->", "get", "(", "$", "entity", ")", ":", "$", "this", "->", "createMapper", "(", "$", "entity", ")", ";", "}" ]
Retrieves the mapper for provided entity If mapper does not exists it will be created and stored in the mapper map. @param string $entity @return EntityMapper
[ "Retrieves", "the", "mapper", "for", "provided", "entity" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Orm.php#L226-L231
7,767
slickframework/orm
src/Orm.php
Orm.getEmitterFor
public function getEmitterFor($entity) { $emitter = $this->emitters->containsKey($entity) ? $this->emitters->get($entity) : $this->createEmitter($entity); return $emitter; }
php
public function getEmitterFor($entity) { $emitter = $this->emitters->containsKey($entity) ? $this->emitters->get($entity) : $this->createEmitter($entity); return $emitter; }
[ "public", "function", "getEmitterFor", "(", "$", "entity", ")", "{", "$", "emitter", "=", "$", "this", "->", "emitters", "->", "containsKey", "(", "$", "entity", ")", "?", "$", "this", "->", "emitters", "->", "get", "(", "$", "entity", ")", ":", "$", "this", "->", "createEmitter", "(", "$", "entity", ")", ";", "return", "$", "emitter", ";", "}" ]
Gets the event emitter for provided entity @param string $entity @return Emitter
[ "Gets", "the", "event", "emitter", "for", "provided", "entity" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Orm.php#L240-L246
7,768
slickframework/orm
src/Orm.php
Orm.setAdapter
public function setAdapter($alias, AdapterInterface $adapter) { $this->adapters->set($alias, $adapter); return $this; }
php
public function setAdapter($alias, AdapterInterface $adapter) { $this->adapters->set($alias, $adapter); return $this; }
[ "public", "function", "setAdapter", "(", "$", "alias", ",", "AdapterInterface", "$", "adapter", ")", "{", "$", "this", "->", "adapters", "->", "set", "(", "$", "alias", ",", "$", "adapter", ")", ";", "return", "$", "this", ";", "}" ]
Sets an adapter mapped with alias name @param string $alias @param AdapterInterface $adapter @return $this|Orm|self
[ "Sets", "an", "adapter", "mapped", "with", "alias", "name" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Orm.php#L267-L271
7,769
slickframework/orm
src/Orm.php
Orm.createRepository
private function createRepository($entityClass) { $repository = new EntityRepository(); $repository->setAdapter( $this->adapters->get($this->getAdapterAlias($entityClass)) ) ->setEntityMapper($this->getMapperFor($entityClass)) ->setEntityDescriptor( EntityDescriptorRegistry::getInstance() ->getDescriptorFor($entityClass) ); $this->repositories->set($entityClass, $repository); return $repository; }
php
private function createRepository($entityClass) { $repository = new EntityRepository(); $repository->setAdapter( $this->adapters->get($this->getAdapterAlias($entityClass)) ) ->setEntityMapper($this->getMapperFor($entityClass)) ->setEntityDescriptor( EntityDescriptorRegistry::getInstance() ->getDescriptorFor($entityClass) ); $this->repositories->set($entityClass, $repository); return $repository; }
[ "private", "function", "createRepository", "(", "$", "entityClass", ")", "{", "$", "repository", "=", "new", "EntityRepository", "(", ")", ";", "$", "repository", "->", "setAdapter", "(", "$", "this", "->", "adapters", "->", "get", "(", "$", "this", "->", "getAdapterAlias", "(", "$", "entityClass", ")", ")", ")", "->", "setEntityMapper", "(", "$", "this", "->", "getMapperFor", "(", "$", "entityClass", ")", ")", "->", "setEntityDescriptor", "(", "EntityDescriptorRegistry", "::", "getInstance", "(", ")", "->", "getDescriptorFor", "(", "$", "entityClass", ")", ")", ";", "$", "this", "->", "repositories", "->", "set", "(", "$", "entityClass", ",", "$", "repository", ")", ";", "return", "$", "repository", ";", "}" ]
Creates a repository for provided entity class name @param string $entityClass @return EntityRepository
[ "Creates", "a", "repository", "for", "provided", "entity", "class", "name" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Orm.php#L279-L292
7,770
slickframework/orm
src/Orm.php
Orm.createMapper
private function createMapper($entity) { $mapper = new EntityMapper(); $mapper->setAdapter( $this->adapters->get( $this->getAdapterAlias($entity) ) ) ->setEntityClassName($entity); $this->mappers->set($entity, $mapper); return $mapper; }
php
private function createMapper($entity) { $mapper = new EntityMapper(); $mapper->setAdapter( $this->adapters->get( $this->getAdapterAlias($entity) ) ) ->setEntityClassName($entity); $this->mappers->set($entity, $mapper); return $mapper; }
[ "private", "function", "createMapper", "(", "$", "entity", ")", "{", "$", "mapper", "=", "new", "EntityMapper", "(", ")", ";", "$", "mapper", "->", "setAdapter", "(", "$", "this", "->", "adapters", "->", "get", "(", "$", "this", "->", "getAdapterAlias", "(", "$", "entity", ")", ")", ")", "->", "setEntityClassName", "(", "$", "entity", ")", ";", "$", "this", "->", "mappers", "->", "set", "(", "$", "entity", ",", "$", "mapper", ")", ";", "return", "$", "mapper", ";", "}" ]
Creates entity map for provided entity @param string $entity @return EntityMapper
[ "Creates", "entity", "map", "for", "provided", "entity" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Orm.php#L300-L311
7,771
slickframework/orm
src/Orm.php
Orm.createEmitter
private function createEmitter($entity) { $emitter = new Emitter(); $this->emitters->set($entity, $emitter); return $emitter; }
php
private function createEmitter($entity) { $emitter = new Emitter(); $this->emitters->set($entity, $emitter); return $emitter; }
[ "private", "function", "createEmitter", "(", "$", "entity", ")", "{", "$", "emitter", "=", "new", "Emitter", "(", ")", ";", "$", "this", "->", "emitters", "->", "set", "(", "$", "entity", ",", "$", "emitter", ")", ";", "return", "$", "emitter", ";", "}" ]
Creates an emitter for provided entity class name @param string $entity @return Emitter
[ "Creates", "an", "emitter", "for", "provided", "entity", "class", "name" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Orm.php#L319-L324
7,772
slickframework/orm
src/Orm.php
Orm.getAdapterAlias
private function getAdapterAlias($entity) { $descriptor = EntityDescriptorRegistry::getInstance() ->getDescriptorFor($entity); return $descriptor->getAdapterAlias() ? $descriptor->getAdapterAlias() : 'default'; }
php
private function getAdapterAlias($entity) { $descriptor = EntityDescriptorRegistry::getInstance() ->getDescriptorFor($entity); return $descriptor->getAdapterAlias() ? $descriptor->getAdapterAlias() : 'default'; }
[ "private", "function", "getAdapterAlias", "(", "$", "entity", ")", "{", "$", "descriptor", "=", "EntityDescriptorRegistry", "::", "getInstance", "(", ")", "->", "getDescriptorFor", "(", "$", "entity", ")", ";", "return", "$", "descriptor", "->", "getAdapterAlias", "(", ")", "?", "$", "descriptor", "->", "getAdapterAlias", "(", ")", ":", "'default'", ";", "}" ]
Gets the adapter alias for current working entity @param string $entity @return string
[ "Gets", "the", "adapter", "alias", "for", "current", "working", "entity" ]
c5c782f5e3a46cdc6c934eda4411cb9edc48f969
https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Orm.php#L333-L340
7,773
10usb/css-lib
src/parsers/RuleSet.php
RuleSet.parseSelector
public static function parseSelector($text){ $text = preg_replace('/(\>|\+|~)\s+/is', '$1', $text); $selector = null; foreach(preg_split('/\s+/', $text, -1, PREG_SPLIT_NO_EMPTY) as $part){ if(!preg_match('/^([\>\+~]?)([^ >\+~]+)$/is', $part, $matches)) throw new \Exception("Invalid selector part '$part'"); $selector = $selector ? $selector->add($matches[1] ? $matches[1] : false) : Selector::create(); $offset = 0; $subtext = $matches[2]; while($offset < strlen($subtext)){ if(!preg_match('/^([\.:#]?)((:?[a-z0-9\-]|\*)+)/is', substr($subtext, $offset), $matches)) throw new \Exception("Invalid property at '".substr($text, $offset, 20)."'"); switch($matches[1]){ case '': $selector->setTagName($matches[2]); break; case '#': $selector->setIdentification($matches[2]); break; case '.': $selector->addClass($matches[2]); break; case ':': $selector->addPseudo($matches[2]); break; default: throw new \Exception("Knonwn type '".$matches[1]."'"); } $offset+= strlen($matches[0]); } } return $selector->get(); }
php
public static function parseSelector($text){ $text = preg_replace('/(\>|\+|~)\s+/is', '$1', $text); $selector = null; foreach(preg_split('/\s+/', $text, -1, PREG_SPLIT_NO_EMPTY) as $part){ if(!preg_match('/^([\>\+~]?)([^ >\+~]+)$/is', $part, $matches)) throw new \Exception("Invalid selector part '$part'"); $selector = $selector ? $selector->add($matches[1] ? $matches[1] : false) : Selector::create(); $offset = 0; $subtext = $matches[2]; while($offset < strlen($subtext)){ if(!preg_match('/^([\.:#]?)((:?[a-z0-9\-]|\*)+)/is', substr($subtext, $offset), $matches)) throw new \Exception("Invalid property at '".substr($text, $offset, 20)."'"); switch($matches[1]){ case '': $selector->setTagName($matches[2]); break; case '#': $selector->setIdentification($matches[2]); break; case '.': $selector->addClass($matches[2]); break; case ':': $selector->addPseudo($matches[2]); break; default: throw new \Exception("Knonwn type '".$matches[1]."'"); } $offset+= strlen($matches[0]); } } return $selector->get(); }
[ "public", "static", "function", "parseSelector", "(", "$", "text", ")", "{", "$", "text", "=", "preg_replace", "(", "'/(\\>|\\+|~)\\s+/is'", ",", "'$1'", ",", "$", "text", ")", ";", "$", "selector", "=", "null", ";", "foreach", "(", "preg_split", "(", "'/\\s+/'", ",", "$", "text", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", "as", "$", "part", ")", "{", "if", "(", "!", "preg_match", "(", "'/^([\\>\\+~]?)([^ >\\+~]+)$/is'", ",", "$", "part", ",", "$", "matches", ")", ")", "throw", "new", "\\", "Exception", "(", "\"Invalid selector part '$part'\"", ")", ";", "$", "selector", "=", "$", "selector", "?", "$", "selector", "->", "add", "(", "$", "matches", "[", "1", "]", "?", "$", "matches", "[", "1", "]", ":", "false", ")", ":", "Selector", "::", "create", "(", ")", ";", "$", "offset", "=", "0", ";", "$", "subtext", "=", "$", "matches", "[", "2", "]", ";", "while", "(", "$", "offset", "<", "strlen", "(", "$", "subtext", ")", ")", "{", "if", "(", "!", "preg_match", "(", "'/^([\\.:#]?)((:?[a-z0-9\\-]|\\*)+)/is'", ",", "substr", "(", "$", "subtext", ",", "$", "offset", ")", ",", "$", "matches", ")", ")", "throw", "new", "\\", "Exception", "(", "\"Invalid property at '\"", ".", "substr", "(", "$", "text", ",", "$", "offset", ",", "20", ")", ".", "\"'\"", ")", ";", "switch", "(", "$", "matches", "[", "1", "]", ")", "{", "case", "''", ":", "$", "selector", "->", "setTagName", "(", "$", "matches", "[", "2", "]", ")", ";", "break", ";", "case", "'#'", ":", "$", "selector", "->", "setIdentification", "(", "$", "matches", "[", "2", "]", ")", ";", "break", ";", "case", "'.'", ":", "$", "selector", "->", "addClass", "(", "$", "matches", "[", "2", "]", ")", ";", "break", ";", "case", "':'", ":", "$", "selector", "->", "addPseudo", "(", "$", "matches", "[", "2", "]", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "Exception", "(", "\"Knonwn type '\"", ".", "$", "matches", "[", "1", "]", ".", "\"'\"", ")", ";", "}", "$", "offset", "+=", "strlen", "(", "$", "matches", "[", "0", "]", ")", ";", "}", "}", "return", "$", "selector", "->", "get", "(", ")", ";", "}" ]
Parses a selector @param string $text @return \csslib\Selector
[ "Parses", "a", "selector" ]
6370b1404bae3eecb44c214ed4eaaf33113858dd
https://github.com/10usb/css-lib/blob/6370b1404bae3eecb44c214ed4eaaf33113858dd/src/parsers/RuleSet.php#L51-L80
7,774
ntentan/utils
src/validator/Validation.php
Validation.evaluateResult
protected function evaluateResult($field, $result, $message) { $this->messages = []; if ($result) { return true; } else { if (is_array($field['name'])) { foreach ($field['name'] as $name) { $this->messages[$name][] = $field['options']['message'] ?? $message; } } else { $this->messages[$field['name']][] = $field['options']['message'] ?? $message; } return false; } }
php
protected function evaluateResult($field, $result, $message) { $this->messages = []; if ($result) { return true; } else { if (is_array($field['name'])) { foreach ($field['name'] as $name) { $this->messages[$name][] = $field['options']['message'] ?? $message; } } else { $this->messages[$field['name']][] = $field['options']['message'] ?? $message; } return false; } }
[ "protected", "function", "evaluateResult", "(", "$", "field", ",", "$", "result", ",", "$", "message", ")", "{", "$", "this", "->", "messages", "=", "[", "]", ";", "if", "(", "$", "result", ")", "{", "return", "true", ";", "}", "else", "{", "if", "(", "is_array", "(", "$", "field", "[", "'name'", "]", ")", ")", "{", "foreach", "(", "$", "field", "[", "'name'", "]", "as", "$", "name", ")", "{", "$", "this", "->", "messages", "[", "$", "name", "]", "[", "]", "=", "$", "field", "[", "'options'", "]", "[", "'message'", "]", "??", "$", "message", ";", "}", "}", "else", "{", "$", "this", "->", "messages", "[", "$", "field", "[", "'name'", "]", "]", "[", "]", "=", "$", "field", "[", "'options'", "]", "[", "'message'", "]", "??", "$", "message", ";", "}", "return", "false", ";", "}", "}" ]
Utility function that evaluates the result of a validation test and prepares validation messages. Receives a boolean from the validation function and a message to be displayed when the value is false. It also receives the options array so it could override the standard message that the validation code generates. @param array $field @param boolean $result @param string $message @return boolean
[ "Utility", "function", "that", "evaluates", "the", "result", "of", "a", "validation", "test", "and", "prepares", "validation", "messages", ".", "Receives", "a", "boolean", "from", "the", "validation", "function", "and", "a", "message", "to", "be", "displayed", "when", "the", "value", "is", "false", ".", "It", "also", "receives", "the", "options", "array", "so", "it", "could", "override", "the", "standard", "message", "that", "the", "validation", "code", "generates", "." ]
151f3582ee6007ea77a38d2b6c590289331e19a1
https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/validator/Validation.php#L36-L51
7,775
ntentan/utils
src/validator/Validation.php
Validation.getFieldValue
protected function getFieldValue($field, $data) { $value = null; if (isset($data[$field['name']])) { $value = $data[$field['name']]; } return $value; }
php
protected function getFieldValue($field, $data) { $value = null; if (isset($data[$field['name']])) { $value = $data[$field['name']]; } return $value; }
[ "protected", "function", "getFieldValue", "(", "$", "field", ",", "$", "data", ")", "{", "$", "value", "=", "null", ";", "if", "(", "isset", "(", "$", "data", "[", "$", "field", "[", "'name'", "]", "]", ")", ")", "{", "$", "value", "=", "$", "data", "[", "$", "field", "[", "'name'", "]", "]", ";", "}", "return", "$", "value", ";", "}" ]
Extracts the value of the field description from the data passed. @param array $field @param array $data @return mixed
[ "Extracts", "the", "value", "of", "the", "field", "description", "from", "the", "data", "passed", "." ]
151f3582ee6007ea77a38d2b6c590289331e19a1
https://github.com/ntentan/utils/blob/151f3582ee6007ea77a38d2b6c590289331e19a1/src/validator/Validation.php#L60-L67
7,776
xcitestudios/php-network
src/Server/Configuration/ServerConfiguration.php
ServerConfiguration.setPort
public function setPort($port) { if (!is_int($port) || $port < 0 || $port > 65535) { throw new InvalidArgumentException( sprintf('%s only accepts a port between 0 and 65535 inclusive', __FUNCTION__) ); } $this->port = $port; return $this; }
php
public function setPort($port) { if (!is_int($port) || $port < 0 || $port > 65535) { throw new InvalidArgumentException( sprintf('%s only accepts a port between 0 and 65535 inclusive', __FUNCTION__) ); } $this->port = $port; return $this; }
[ "public", "function", "setPort", "(", "$", "port", ")", "{", "if", "(", "!", "is_int", "(", "$", "port", ")", "||", "$", "port", "<", "0", "||", "$", "port", ">", "65535", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'%s only accepts a port between 0 and 65535 inclusive'", ",", "__FUNCTION__", ")", ")", ";", "}", "$", "this", "->", "port", "=", "$", "port", ";", "return", "$", "this", ";", "}" ]
Set the port to connect to. @param int $port @return static @throws InvalidArgumentException
[ "Set", "the", "port", "to", "connect", "to", "." ]
4278b7bd5b5cf64ceb08005f6bce18be79b76cd3
https://github.com/xcitestudios/php-network/blob/4278b7bd5b5cf64ceb08005f6bce18be79b76cd3/src/Server/Configuration/ServerConfiguration.php#L75-L86
7,777
xcitestudios/php-network
src/Server/Configuration/ServerConfiguration.php
ServerConfiguration.setSSL
public function setSSL($isEnabled) { if (!is_bool($isEnabled)) { throw new InvalidArgumentException( sprintf('%s only accepts a boolean', __FUNCTION__) ); } $this->ssl = (bool)$isEnabled; return $this; }
php
public function setSSL($isEnabled) { if (!is_bool($isEnabled)) { throw new InvalidArgumentException( sprintf('%s only accepts a boolean', __FUNCTION__) ); } $this->ssl = (bool)$isEnabled; return $this; }
[ "public", "function", "setSSL", "(", "$", "isEnabled", ")", "{", "if", "(", "!", "is_bool", "(", "$", "isEnabled", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'%s only accepts a boolean'", ",", "__FUNCTION__", ")", ")", ";", "}", "$", "this", "->", "ssl", "=", "(", "bool", ")", "$", "isEnabled", ";", "return", "$", "this", ";", "}" ]
Set if SSL should be used for the connection. @param bool $isEnabled @return static @throws InvalidArgumentException
[ "Set", "if", "SSL", "should", "be", "used", "for", "the", "connection", "." ]
4278b7bd5b5cf64ceb08005f6bce18be79b76cd3
https://github.com/xcitestudios/php-network/blob/4278b7bd5b5cf64ceb08005f6bce18be79b76cd3/src/Server/Configuration/ServerConfiguration.php#L105-L116
7,778
xcitestudios/php-network
src/Server/Configuration/ServerConfiguration.php
ServerConfiguration.setTLS
public function setTLS($isEnabled) { if (!is_bool($isEnabled)) { throw new InvalidArgumentException( sprintf('%s only accepts a boolean', __FUNCTION__) ); } $this->tls = (bool)$isEnabled; return $this; }
php
public function setTLS($isEnabled) { if (!is_bool($isEnabled)) { throw new InvalidArgumentException( sprintf('%s only accepts a boolean', __FUNCTION__) ); } $this->tls = (bool)$isEnabled; return $this; }
[ "public", "function", "setTLS", "(", "$", "isEnabled", ")", "{", "if", "(", "!", "is_bool", "(", "$", "isEnabled", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'%s only accepts a boolean'", ",", "__FUNCTION__", ")", ")", ";", "}", "$", "this", "->", "tls", "=", "(", "bool", ")", "$", "isEnabled", ";", "return", "$", "this", ";", "}" ]
Set if TLS should be used for the connection. @param bool $isEnabled @return static @throws InvalidArgumentException
[ "Set", "if", "TLS", "should", "be", "used", "for", "the", "connection", "." ]
4278b7bd5b5cf64ceb08005f6bce18be79b76cd3
https://github.com/xcitestudios/php-network/blob/4278b7bd5b5cf64ceb08005f6bce18be79b76cd3/src/Server/Configuration/ServerConfiguration.php#L135-L146
7,779
nonetallt/jinitialize-core
src/Procedure/ProcedureValidator.php
ProcedureValidator.checkPermissions
private function checkPermissions($style) { $warnings = []; foreach($this->procedure->getCommands() as $command) { /* Skip evalutating commands that do not recommend root */ if(! $command->hasPublicMethod('recommendsRoot')) continue; if($command->recommendsRoot() && ! ShellUser::getInstance()->isRoot()) { $name = $command->getName(); $user = ShellUser::getInstance()->getName(); $warnings[] = "Command $name recommends running as root, currently $user."; } } if(!empty($warnings)) { $style->warning($warnings); if($style->confirm("Would you like to abort current procedure ({$this->procedure->getName()})?")) { $this->abort("Procedure aborted by user"); } } }
php
private function checkPermissions($style) { $warnings = []; foreach($this->procedure->getCommands() as $command) { /* Skip evalutating commands that do not recommend root */ if(! $command->hasPublicMethod('recommendsRoot')) continue; if($command->recommendsRoot() && ! ShellUser::getInstance()->isRoot()) { $name = $command->getName(); $user = ShellUser::getInstance()->getName(); $warnings[] = "Command $name recommends running as root, currently $user."; } } if(!empty($warnings)) { $style->warning($warnings); if($style->confirm("Would you like to abort current procedure ({$this->procedure->getName()})?")) { $this->abort("Procedure aborted by user"); } } }
[ "private", "function", "checkPermissions", "(", "$", "style", ")", "{", "$", "warnings", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "procedure", "->", "getCommands", "(", ")", "as", "$", "command", ")", "{", "/* Skip evalutating commands that do not recommend root */", "if", "(", "!", "$", "command", "->", "hasPublicMethod", "(", "'recommendsRoot'", ")", ")", "continue", ";", "if", "(", "$", "command", "->", "recommendsRoot", "(", ")", "&&", "!", "ShellUser", "::", "getInstance", "(", ")", "->", "isRoot", "(", ")", ")", "{", "$", "name", "=", "$", "command", "->", "getName", "(", ")", ";", "$", "user", "=", "ShellUser", "::", "getInstance", "(", ")", "->", "getName", "(", ")", ";", "$", "warnings", "[", "]", "=", "\"Command $name recommends running as root, currently $user.\"", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "warnings", ")", ")", "{", "$", "style", "->", "warning", "(", "$", "warnings", ")", ";", "if", "(", "$", "style", "->", "confirm", "(", "\"Would you like to abort current procedure ({$this->procedure->getName()})?\"", ")", ")", "{", "$", "this", "->", "abort", "(", "\"Procedure aborted by user\"", ")", ";", "}", "}", "}" ]
Warn user if procedure should be ran as root and is being ran by some other user
[ "Warn", "user", "if", "procedure", "should", "be", "ran", "as", "root", "and", "is", "being", "ran", "by", "some", "other", "user" ]
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/Procedure/ProcedureValidator.php#L104-L126
7,780
Dhii/normalization-helper-base
src/NormalizeIterableCapableTrait.php
NormalizeIterableCapableTrait._normalizeIterable
protected function _normalizeIterable($iterable) { if ( is_array($iterable) || $iterable instanceof Traversable || $iterable instanceof stdClass ) { return $iterable; } throw $this->_createInvalidArgumentException( $this->__('Invalid iterable'), null, null, $iterable ); }
php
protected function _normalizeIterable($iterable) { if ( is_array($iterable) || $iterable instanceof Traversable || $iterable instanceof stdClass ) { return $iterable; } throw $this->_createInvalidArgumentException( $this->__('Invalid iterable'), null, null, $iterable ); }
[ "protected", "function", "_normalizeIterable", "(", "$", "iterable", ")", "{", "if", "(", "is_array", "(", "$", "iterable", ")", "||", "$", "iterable", "instanceof", "Traversable", "||", "$", "iterable", "instanceof", "stdClass", ")", "{", "return", "$", "iterable", ";", "}", "throw", "$", "this", "->", "_createInvalidArgumentException", "(", "$", "this", "->", "__", "(", "'Invalid iterable'", ")", ",", "null", ",", "null", ",", "$", "iterable", ")", ";", "}" ]
Normalizes an iterable. Makes sure that the return value can be iterated over. @since [*next-version*] @param mixed $iterable The iterable to normalize. @throws InvalidArgumentException If the iterable could not be normalized. @return array|Traversable|stdClass The normalized iterable.
[ "Normalizes", "an", "iterable", "." ]
1b64f0ea6b3e32f9478f854f6049500795b51da7
https://github.com/Dhii/normalization-helper-base/blob/1b64f0ea6b3e32f9478f854f6049500795b51da7/src/NormalizeIterableCapableTrait.php#L31-L47
7,781
Thuata/ComponentBundle
Display/Menu/Action.php
Action.addParameter
public function addParameter(string $name, $value) { if (!is_scalar($value)) { throw new InvalidParameterTypeException(__CLASS__, __METHOD__, 1, 'scalar', gettype($value)); } $this->parameters->set($name, $value); return $this; }
php
public function addParameter(string $name, $value) { if (!is_scalar($value)) { throw new InvalidParameterTypeException(__CLASS__, __METHOD__, 1, 'scalar', gettype($value)); } $this->parameters->set($name, $value); return $this; }
[ "public", "function", "addParameter", "(", "string", "$", "name", ",", "$", "value", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "value", ")", ")", "{", "throw", "new", "InvalidParameterTypeException", "(", "__CLASS__", ",", "__METHOD__", ",", "1", ",", "'scalar'", ",", "gettype", "(", "$", "value", ")", ")", ";", "}", "$", "this", "->", "parameters", "->", "set", "(", "$", "name", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Adds a parameter @param string $name @param mixed $value @return $this @throws \Thuata\ComponentBundle\Exception\InvalidParameterTypeException
[ "Adds", "a", "parameter" ]
1001aaf585d177daa4b2fef4989c530ff5963df0
https://github.com/Thuata/ComponentBundle/blob/1001aaf585d177daa4b2fef4989c530ff5963df0/Display/Menu/Action.php#L64-L73
7,782
marando/phpSOFA
src/Marando/IAU/iauTdbtcb.php
iauTdbtcb.Tdbtcb
public static function Tdbtcb($tdb1, $tdb2, &$tcb1, &$tcb2) { /* 1977 Jan 1 00:00:32.184 TT, as two-part JD */ $t77td = DJM0 + DJM77; $t77tf = TTMTAI / DAYSEC; /* TDB (days) at TAI 1977 Jan 1.0 */ $tdb0 = TDB0 / DAYSEC; /* TDB to TCB rate */ $elbb = ELB / (1.0 - ELB); $d; $f; /* Result, preserving date format but safeguarding precision. */ if ($tdb1 > $tdb2) { $d = $t77td - $tdb1; $f = $tdb2 - $tdb0; $tcb1 = $tdb1; $tcb2 = $f - ( $d - ( $f - $t77tf ) ) * $elbb; } else { $d = t77td - $tdb2; $f = $tdb1 - $tdb0; $tcb1 = $f + ( $d - ( $f - $t77tf ) ) * $elbb; $tcb2 = $tdb2; } /* Status (always OK). */ return 0; }
php
public static function Tdbtcb($tdb1, $tdb2, &$tcb1, &$tcb2) { /* 1977 Jan 1 00:00:32.184 TT, as two-part JD */ $t77td = DJM0 + DJM77; $t77tf = TTMTAI / DAYSEC; /* TDB (days) at TAI 1977 Jan 1.0 */ $tdb0 = TDB0 / DAYSEC; /* TDB to TCB rate */ $elbb = ELB / (1.0 - ELB); $d; $f; /* Result, preserving date format but safeguarding precision. */ if ($tdb1 > $tdb2) { $d = $t77td - $tdb1; $f = $tdb2 - $tdb0; $tcb1 = $tdb1; $tcb2 = $f - ( $d - ( $f - $t77tf ) ) * $elbb; } else { $d = t77td - $tdb2; $f = $tdb1 - $tdb0; $tcb1 = $f + ( $d - ( $f - $t77tf ) ) * $elbb; $tcb2 = $tdb2; } /* Status (always OK). */ return 0; }
[ "public", "static", "function", "Tdbtcb", "(", "$", "tdb1", ",", "$", "tdb2", ",", "&", "$", "tcb1", ",", "&", "$", "tcb2", ")", "{", "/* 1977 Jan 1 00:00:32.184 TT, as two-part JD */", "$", "t77td", "=", "DJM0", "+", "DJM77", ";", "$", "t77tf", "=", "TTMTAI", "/", "DAYSEC", ";", "/* TDB (days) at TAI 1977 Jan 1.0 */", "$", "tdb0", "=", "TDB0", "/", "DAYSEC", ";", "/* TDB to TCB rate */", "$", "elbb", "=", "ELB", "/", "(", "1.0", "-", "ELB", ")", ";", "$", "d", ";", "$", "f", ";", "/* Result, preserving date format but safeguarding precision. */", "if", "(", "$", "tdb1", ">", "$", "tdb2", ")", "{", "$", "d", "=", "$", "t77td", "-", "$", "tdb1", ";", "$", "f", "=", "$", "tdb2", "-", "$", "tdb0", ";", "$", "tcb1", "=", "$", "tdb1", ";", "$", "tcb2", "=", "$", "f", "-", "(", "$", "d", "-", "(", "$", "f", "-", "$", "t77tf", ")", ")", "*", "$", "elbb", ";", "}", "else", "{", "$", "d", "=", "t77td", "-", "$", "tdb2", ";", "$", "f", "=", "$", "tdb1", "-", "$", "tdb0", ";", "$", "tcb1", "=", "$", "f", "+", "(", "$", "d", "-", "(", "$", "f", "-", "$", "t77tf", ")", ")", "*", "$", "elbb", ";", "$", "tcb2", "=", "$", "tdb2", ";", "}", "/* Status (always OK). */", "return", "0", ";", "}" ]
- - - - - - - - - - i a u T d b t c b - - - - - - - - - - Time scale transformation: Barycentric Dynamical Time, TDB, to Barycentric Coordinate Time, TCB. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: canonical. Given: tdb1,tdb2 double TDB as a 2-part Julian Date Returned: tcb1,tcb2 double TCB as a 2-part Julian Date Returned (function value): int status: 0 = OK Notes: 1) tdb1+tdb2 is Julian Date, apportioned in any convenient way between the two arguments, for example where tdb1 is the Julian Day Number and tdb2 is the fraction of a day. The returned tcb1,tcb2 follow suit. 2) The 2006 IAU General Assembly introduced a conventional linear transformation between TDB and TCB. This transformation compensates for the drift between TCB and terrestrial time TT, and keeps TDB approximately centered on TT. Because the relationship between TT and TCB depends on the adopted solar system ephemeris, the degree of alignment between TDB and TT over long intervals will vary according to which ephemeris is used. Former definitions of TDB attempted to avoid this problem by stipulating that TDB and TT should differ only by periodic effects. This is a good description of the nature of the relationship but eluded precise mathematical formulation. The conventional linear relationship adopted in 2006 sidestepped these difficulties whilst delivering a TDB that in practice was consistent with values before that date. 3) TDB is essentially the same as Teph, the time argument for the JPL solar system ephemerides. Reference: IAU 2006 Resolution B3 This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "T", "d", "b", "t", "c", "b", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauTdbtcb.php#L64-L94
7,783
marando/phpSOFA
src/Marando/IAU/iauDtf2d.php
iauDtf2d.Dtf2d
public static function Dtf2d($scale, $iy, $im, $id, $ihr, $imn, $sec, &$d1, &$d2) { $js; $iy2; $im2; $id2; $dj; $w; $day; $seclim; $dat0; $dat12; $dat24; $dleap; $time; /* Today's Julian Day Number. */ $js = IAU::Cal2jd($iy, $im, $id, $dj, $w); if ($js) return $js; $dj += $w; /* Day length and final minute length in seconds (provisional). */ $day = DAYSEC; $seclim = 60.0; /* Deal with the UTC leap second case. */ if (!strcmp($scale, "UTC")) { /* TAI-UTC at 0h today. */ $js = IAU::Dat($iy, $im, $id, 0.0, $dat0); if ($js < 0) return $js; /* TAI-UTC at 12h today (to detect drift). */ $js = IAU::Dat($iy, $im, $id, 0.5, $dat12); if ($js < 0) return $js; /* TAI-UTC at 0h tomorrow (to detect jumps). */ $js = IAU::Jd2cal($dj, 1.5, $iy2, $im2, $id2, $w); if ($js) return js; $js = IAU::Dat($iy2, $im2, $id2, 0.0, $dat24); if ($js < 0) return $js; /* Any sudden change in TAI-UTC between today and tomorrow. */ $dleap = $dat24 - (2.0 * $dat12 - $dat0); /* If leap second day, correct the day and final minute lengths. */ $day += $dleap; if ($ihr == 23 && $imn == 59) $seclim += $dleap; /* End of UTC-specific actions. */ } /* Validate the time. */ if ($ihr >= 0 && $ihr <= 23) { if ($imn >= 0 && $imn <= 59) { if ($sec >= 0) { if ($sec >= $seclim) { $js += 2; } } else { $js = -6; } } else { $js = -5; } } else { $js = -4; } if ($js < 0) return $js; /* The time in days. */ $time = ( 60.0 * ( (double)( 60 * $ihr + $imn ) ) + $sec ) / $day; /* Return the date and time. */ $d1 = $dj; $d2 = $time; /* Status. */ return $js; }
php
public static function Dtf2d($scale, $iy, $im, $id, $ihr, $imn, $sec, &$d1, &$d2) { $js; $iy2; $im2; $id2; $dj; $w; $day; $seclim; $dat0; $dat12; $dat24; $dleap; $time; /* Today's Julian Day Number. */ $js = IAU::Cal2jd($iy, $im, $id, $dj, $w); if ($js) return $js; $dj += $w; /* Day length and final minute length in seconds (provisional). */ $day = DAYSEC; $seclim = 60.0; /* Deal with the UTC leap second case. */ if (!strcmp($scale, "UTC")) { /* TAI-UTC at 0h today. */ $js = IAU::Dat($iy, $im, $id, 0.0, $dat0); if ($js < 0) return $js; /* TAI-UTC at 12h today (to detect drift). */ $js = IAU::Dat($iy, $im, $id, 0.5, $dat12); if ($js < 0) return $js; /* TAI-UTC at 0h tomorrow (to detect jumps). */ $js = IAU::Jd2cal($dj, 1.5, $iy2, $im2, $id2, $w); if ($js) return js; $js = IAU::Dat($iy2, $im2, $id2, 0.0, $dat24); if ($js < 0) return $js; /* Any sudden change in TAI-UTC between today and tomorrow. */ $dleap = $dat24 - (2.0 * $dat12 - $dat0); /* If leap second day, correct the day and final minute lengths. */ $day += $dleap; if ($ihr == 23 && $imn == 59) $seclim += $dleap; /* End of UTC-specific actions. */ } /* Validate the time. */ if ($ihr >= 0 && $ihr <= 23) { if ($imn >= 0 && $imn <= 59) { if ($sec >= 0) { if ($sec >= $seclim) { $js += 2; } } else { $js = -6; } } else { $js = -5; } } else { $js = -4; } if ($js < 0) return $js; /* The time in days. */ $time = ( 60.0 * ( (double)( 60 * $ihr + $imn ) ) + $sec ) / $day; /* Return the date and time. */ $d1 = $dj; $d2 = $time; /* Status. */ return $js; }
[ "public", "static", "function", "Dtf2d", "(", "$", "scale", ",", "$", "iy", ",", "$", "im", ",", "$", "id", ",", "$", "ihr", ",", "$", "imn", ",", "$", "sec", ",", "&", "$", "d1", ",", "&", "$", "d2", ")", "{", "$", "js", ";", "$", "iy2", ";", "$", "im2", ";", "$", "id2", ";", "$", "dj", ";", "$", "w", ";", "$", "day", ";", "$", "seclim", ";", "$", "dat0", ";", "$", "dat12", ";", "$", "dat24", ";", "$", "dleap", ";", "$", "time", ";", "/* Today's Julian Day Number. */", "$", "js", "=", "IAU", "::", "Cal2jd", "(", "$", "iy", ",", "$", "im", ",", "$", "id", ",", "$", "dj", ",", "$", "w", ")", ";", "if", "(", "$", "js", ")", "return", "$", "js", ";", "$", "dj", "+=", "$", "w", ";", "/* Day length and final minute length in seconds (provisional). */", "$", "day", "=", "DAYSEC", ";", "$", "seclim", "=", "60.0", ";", "/* Deal with the UTC leap second case. */", "if", "(", "!", "strcmp", "(", "$", "scale", ",", "\"UTC\"", ")", ")", "{", "/* TAI-UTC at 0h today. */", "$", "js", "=", "IAU", "::", "Dat", "(", "$", "iy", ",", "$", "im", ",", "$", "id", ",", "0.0", ",", "$", "dat0", ")", ";", "if", "(", "$", "js", "<", "0", ")", "return", "$", "js", ";", "/* TAI-UTC at 12h today (to detect drift). */", "$", "js", "=", "IAU", "::", "Dat", "(", "$", "iy", ",", "$", "im", ",", "$", "id", ",", "0.5", ",", "$", "dat12", ")", ";", "if", "(", "$", "js", "<", "0", ")", "return", "$", "js", ";", "/* TAI-UTC at 0h tomorrow (to detect jumps). */", "$", "js", "=", "IAU", "::", "Jd2cal", "(", "$", "dj", ",", "1.5", ",", "$", "iy2", ",", "$", "im2", ",", "$", "id2", ",", "$", "w", ")", ";", "if", "(", "$", "js", ")", "return", "js", ";", "$", "js", "=", "IAU", "::", "Dat", "(", "$", "iy2", ",", "$", "im2", ",", "$", "id2", ",", "0.0", ",", "$", "dat24", ")", ";", "if", "(", "$", "js", "<", "0", ")", "return", "$", "js", ";", "/* Any sudden change in TAI-UTC between today and tomorrow. */", "$", "dleap", "=", "$", "dat24", "-", "(", "2.0", "*", "$", "dat12", "-", "$", "dat0", ")", ";", "/* If leap second day, correct the day and final minute lengths. */", "$", "day", "+=", "$", "dleap", ";", "if", "(", "$", "ihr", "==", "23", "&&", "$", "imn", "==", "59", ")", "$", "seclim", "+=", "$", "dleap", ";", "/* End of UTC-specific actions. */", "}", "/* Validate the time. */", "if", "(", "$", "ihr", ">=", "0", "&&", "$", "ihr", "<=", "23", ")", "{", "if", "(", "$", "imn", ">=", "0", "&&", "$", "imn", "<=", "59", ")", "{", "if", "(", "$", "sec", ">=", "0", ")", "{", "if", "(", "$", "sec", ">=", "$", "seclim", ")", "{", "$", "js", "+=", "2", ";", "}", "}", "else", "{", "$", "js", "=", "-", "6", ";", "}", "}", "else", "{", "$", "js", "=", "-", "5", ";", "}", "}", "else", "{", "$", "js", "=", "-", "4", ";", "}", "if", "(", "$", "js", "<", "0", ")", "return", "$", "js", ";", "/* The time in days. */", "$", "time", "=", "(", "60.0", "*", "(", "(", "double", ")", "(", "60", "*", "$", "ihr", "+", "$", "imn", ")", ")", "+", "$", "sec", ")", "/", "$", "day", ";", "/* Return the date and time. */", "$", "d1", "=", "$", "dj", ";", "$", "d2", "=", "$", "time", ";", "/* Status. */", "return", "$", "js", ";", "}" ]
- - - - - - - - - i a u D t f 2 d - - - - - - - - - Encode date and time fields into 2-part Julian Date (or in the case of UTC a quasi-JD form that includes special provision for leap seconds). This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: scale char[] time scale ID (Note 1) iy,im,id int year, month, day in Gregorian calendar (Note 2) ihr,imn int hour, minute sec double seconds Returned: d1,d2 double 2-part Julian Date (Notes 3,4) Returned (function value): int status: +3 = both of next two +2 = time is after end of day (Note 5) +1 = dubious year (Note 6) 0 = OK -1 = bad year -2 = bad month -3 = bad day -4 = bad hour -5 = bad minute -6 = bad second (<0) Notes: 1) scale identifies the time scale. Only the value "UTC" (in upper case) is significant, and enables handling of leap seconds (see Note 4). 2) For calendar conventions and limitations, see iauCal2jd. 3) The sum of the results, d1+d2, is Julian Date, where normally d1 is the Julian Day Number and d2 is the fraction of a day. In the case of UTC, where the use of JD is problematical, special conventions apply: see the next note. 4) JD cannot unambiguously represent UTC during a leap second unless special measures are taken. The SOFA internal convention is that the quasi-JD day represents UTC days whether the length is 86399, 86400 or 86401 SI seconds. In the 1960-1972 era there were smaller jumps (in either direction) each time the linear UTC(TAI) expression was changed, and these "mini-leaps" are also included in the SOFA convention. 5) The warning status "time is after end of day" usually means that the sec argument is greater than 60.0. However, in a day ending in a leap second the limit changes to 61.0 (or 59.0 in the case of a negative leap second). 6) 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. 7) Only in the case of continuous and regular time scales (TAI, TT, TCG, TCB and TDB) is the result d1+d2 a Julian Date, strictly speaking. In the other cases (UT1 and UTC) the result must be used with circumspection; in particular the difference between two such results cannot be interpreted as a precise time interval. Called: iauCal2jd Gregorian calendar to JD iauDat delta(AT) = TAI-UTC iauJd2cal JD to Gregorian calendar This revision: 2013 July 26 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "D", "t", "f", "2", "d", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauDtf2d.php#L90-L180
7,784
liverbool/dos-resource-bundle
EventListener/AjaxRedirect.php
AjaxRedirect.setJsonRedirection
public function setJsonRedirection(FilterResponseEvent $event) { if (!$event->isMasterRequest()) { return; } $request = $event->getRequest(); // no handle with ajax (except turbolinks) if ($event->getResponse() instanceof RedirectResponse && $request->isXmlHttpRequest()) { $uri = rtrim(explode('?', $request->getUri())[0], '/'); $target = rtrim(explode('?', $targetUrl = $event->getResponse()->getTargetUrl())[0], '/'); // when just sf route `/` matching redirect // most of index route end with `/` but we just enter `resources` // eg. `/users` may redirect to `/users/` if ($uri === $target) { return; } /** @var FlashBagInterface $flashes */ $flashes = $event->getRequest()->getSession()->getFlashBag(); $headers = array( 'x-location' => $targetUrl, 'x-flashes' => $flashes ? json_encode($flashes->all()) : null ); $event->setResponse(new Response(null, 204, $headers)); } }
php
public function setJsonRedirection(FilterResponseEvent $event) { if (!$event->isMasterRequest()) { return; } $request = $event->getRequest(); // no handle with ajax (except turbolinks) if ($event->getResponse() instanceof RedirectResponse && $request->isXmlHttpRequest()) { $uri = rtrim(explode('?', $request->getUri())[0], '/'); $target = rtrim(explode('?', $targetUrl = $event->getResponse()->getTargetUrl())[0], '/'); // when just sf route `/` matching redirect // most of index route end with `/` but we just enter `resources` // eg. `/users` may redirect to `/users/` if ($uri === $target) { return; } /** @var FlashBagInterface $flashes */ $flashes = $event->getRequest()->getSession()->getFlashBag(); $headers = array( 'x-location' => $targetUrl, 'x-flashes' => $flashes ? json_encode($flashes->all()) : null ); $event->setResponse(new Response(null, 204, $headers)); } }
[ "public", "function", "setJsonRedirection", "(", "FilterResponseEvent", "$", "event", ")", "{", "if", "(", "!", "$", "event", "->", "isMasterRequest", "(", ")", ")", "{", "return", ";", "}", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "// no handle with ajax (except turbolinks)", "if", "(", "$", "event", "->", "getResponse", "(", ")", "instanceof", "RedirectResponse", "&&", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "$", "uri", "=", "rtrim", "(", "explode", "(", "'?'", ",", "$", "request", "->", "getUri", "(", ")", ")", "[", "0", "]", ",", "'/'", ")", ";", "$", "target", "=", "rtrim", "(", "explode", "(", "'?'", ",", "$", "targetUrl", "=", "$", "event", "->", "getResponse", "(", ")", "->", "getTargetUrl", "(", ")", ")", "[", "0", "]", ",", "'/'", ")", ";", "// when just sf route `/` matching redirect", "// most of index route end with `/` but we just enter `resources`", "// eg. `/users` may redirect to `/users/`", "if", "(", "$", "uri", "===", "$", "target", ")", "{", "return", ";", "}", "/** @var FlashBagInterface $flashes */", "$", "flashes", "=", "$", "event", "->", "getRequest", "(", ")", "->", "getSession", "(", ")", "->", "getFlashBag", "(", ")", ";", "$", "headers", "=", "array", "(", "'x-location'", "=>", "$", "targetUrl", ",", "'x-flashes'", "=>", "$", "flashes", "?", "json_encode", "(", "$", "flashes", "->", "all", "(", ")", ")", ":", "null", ")", ";", "$", "event", "->", "setResponse", "(", "new", "Response", "(", "null", ",", "204", ",", "$", "headers", ")", ")", ";", "}", "}" ]
Set 204 status and return location redirect for ajax redirect. @param FilterResponseEvent $event
[ "Set", "204", "status", "and", "return", "location", "redirect", "for", "ajax", "redirect", "." ]
c8607a46c2cea80cc138994be74f4dea3c197abc
https://github.com/liverbool/dos-resource-bundle/blob/c8607a46c2cea80cc138994be74f4dea3c197abc/EventListener/AjaxRedirect.php#L17-L46
7,785
jetcms/models
src/User.php
User.hasRole
public function hasRole($name) { foreach ($this->roles as $role) { if ($role->name == $name) return true; } return false; }
php
public function hasRole($name) { foreach ($this->roles as $role) { if ($role->name == $name) return true; } return false; }
[ "public", "function", "hasRole", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "roles", "as", "$", "role", ")", "{", "if", "(", "$", "role", "->", "name", "==", "$", "name", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Does the user have a particular role? @param $name @return bool
[ "Does", "the", "user", "have", "a", "particular", "role?" ]
0528101caeea121361d21b8b82ac75485853018f
https://github.com/jetcms/models/blob/0528101caeea121361d21b8b82ac75485853018f/src/User.php#L59-L66
7,786
weipaitang/config
src/SwooleTableHandler.php
SwooleTableHandler.createSwooleTable
public function createSwooleTable() { $configTable = new SwooleTable(2048); $configTable->column('value', SwooleTable::TYPE_STRING, 1024); $configTable->create(); $this->table = $configTable; }
php
public function createSwooleTable() { $configTable = new SwooleTable(2048); $configTable->column('value', SwooleTable::TYPE_STRING, 1024); $configTable->create(); $this->table = $configTable; }
[ "public", "function", "createSwooleTable", "(", ")", "{", "$", "configTable", "=", "new", "SwooleTable", "(", "2048", ")", ";", "$", "configTable", "->", "column", "(", "'value'", ",", "SwooleTable", "::", "TYPE_STRING", ",", "1024", ")", ";", "$", "configTable", "->", "create", "(", ")", ";", "$", "this", "->", "table", "=", "$", "configTable", ";", "}" ]
create swoole table
[ "create", "swoole", "table" ]
8282ff5a79133135df7c0ee43c57a8a2163e3509
https://github.com/weipaitang/config/blob/8282ff5a79133135df7c0ee43c57a8a2163e3509/src/SwooleTableHandler.php#L41-L48
7,787
Silvestra/Silvestra
src/Silvestra/Component/Media/Image/ImageUploader.php
ImageUploader.createImage
public function createImage(UploadedFile $uploadedImage) { $image = $this->imageManager->create(); $filename = $this->getUniqueFilename($uploadedImage); $image->setFilename($filename); $image->setMimeType($uploadedImage->getClientMimeType()); $image->setOrderNr(1); $image->setOriginalPath($this->filesystem->getRelativeFilePath($filename)); $image->setPath($image->getOriginalPath()); $image->setSize($uploadedImage->getClientSize()); $image->setTemporary(true); $this->imageManager->add($image); $fileDir = $this->filesystem->getActualFileDir($filename); $uploadedImage->move($fileDir, $image->getFilename()); return $image; }
php
public function createImage(UploadedFile $uploadedImage) { $image = $this->imageManager->create(); $filename = $this->getUniqueFilename($uploadedImage); $image->setFilename($filename); $image->setMimeType($uploadedImage->getClientMimeType()); $image->setOrderNr(1); $image->setOriginalPath($this->filesystem->getRelativeFilePath($filename)); $image->setPath($image->getOriginalPath()); $image->setSize($uploadedImage->getClientSize()); $image->setTemporary(true); $this->imageManager->add($image); $fileDir = $this->filesystem->getActualFileDir($filename); $uploadedImage->move($fileDir, $image->getFilename()); return $image; }
[ "public", "function", "createImage", "(", "UploadedFile", "$", "uploadedImage", ")", "{", "$", "image", "=", "$", "this", "->", "imageManager", "->", "create", "(", ")", ";", "$", "filename", "=", "$", "this", "->", "getUniqueFilename", "(", "$", "uploadedImage", ")", ";", "$", "image", "->", "setFilename", "(", "$", "filename", ")", ";", "$", "image", "->", "setMimeType", "(", "$", "uploadedImage", "->", "getClientMimeType", "(", ")", ")", ";", "$", "image", "->", "setOrderNr", "(", "1", ")", ";", "$", "image", "->", "setOriginalPath", "(", "$", "this", "->", "filesystem", "->", "getRelativeFilePath", "(", "$", "filename", ")", ")", ";", "$", "image", "->", "setPath", "(", "$", "image", "->", "getOriginalPath", "(", ")", ")", ";", "$", "image", "->", "setSize", "(", "$", "uploadedImage", "->", "getClientSize", "(", ")", ")", ";", "$", "image", "->", "setTemporary", "(", "true", ")", ";", "$", "this", "->", "imageManager", "->", "add", "(", "$", "image", ")", ";", "$", "fileDir", "=", "$", "this", "->", "filesystem", "->", "getActualFileDir", "(", "$", "filename", ")", ";", "$", "uploadedImage", "->", "move", "(", "$", "fileDir", ",", "$", "image", "->", "getFilename", "(", ")", ")", ";", "return", "$", "image", ";", "}" ]
Create image. @param UploadedFile $uploadedImage @return ImageInterface
[ "Create", "image", "." ]
b7367601b01495ae3c492b42042f804dee13ab06
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Media/Image/ImageUploader.php#L65-L85
7,788
agalbourdin/agl-core
src/Mysql/Query/Update.php
Update.commit
public function commit() { try { $toUpdate = array_merge($this->getFieldsToUpdate(), $this->getFieldsToDelete()); if (! empty($toUpdate)) { $idField = $this->_item->getIdField(); $query = " UPDATE `" . $this->getDbPrefix() . $this->_item->getDbContainer() . "` SET " . $this->_getPreparedFields($toUpdate) . " WHERE `$idField` = ?"; if (! array_key_exists($idField, $toUpdate)) { $toUpdate[$idField] = $this->_item->getId()->getOrig(); } $prepared = Agl::app()->getDb()->getConnection()->prepare($query); if (! $prepared->execute(array_values($toUpdate))) { $error = $prepared->errorInfo(); throw new Exception("The update query failed (table '" . $this->getDbPrefix() . $this->_item->getDbContainer() . "') with message '" . $error[2] . "'"); } if (Agl::app()->isDebugMode()) { Agl::app()->getDb()->incrementCounter(); } return $prepared->rowCount(); } } catch (Exception $e) { throw new Exception($e); } return true; }
php
public function commit() { try { $toUpdate = array_merge($this->getFieldsToUpdate(), $this->getFieldsToDelete()); if (! empty($toUpdate)) { $idField = $this->_item->getIdField(); $query = " UPDATE `" . $this->getDbPrefix() . $this->_item->getDbContainer() . "` SET " . $this->_getPreparedFields($toUpdate) . " WHERE `$idField` = ?"; if (! array_key_exists($idField, $toUpdate)) { $toUpdate[$idField] = $this->_item->getId()->getOrig(); } $prepared = Agl::app()->getDb()->getConnection()->prepare($query); if (! $prepared->execute(array_values($toUpdate))) { $error = $prepared->errorInfo(); throw new Exception("The update query failed (table '" . $this->getDbPrefix() . $this->_item->getDbContainer() . "') with message '" . $error[2] . "'"); } if (Agl::app()->isDebugMode()) { Agl::app()->getDb()->incrementCounter(); } return $prepared->rowCount(); } } catch (Exception $e) { throw new Exception($e); } return true; }
[ "public", "function", "commit", "(", ")", "{", "try", "{", "$", "toUpdate", "=", "array_merge", "(", "$", "this", "->", "getFieldsToUpdate", "(", ")", ",", "$", "this", "->", "getFieldsToDelete", "(", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "toUpdate", ")", ")", "{", "$", "idField", "=", "$", "this", "->", "_item", "->", "getIdField", "(", ")", ";", "$", "query", "=", "\"\n UPDATE\n `\"", ".", "$", "this", "->", "getDbPrefix", "(", ")", ".", "$", "this", "->", "_item", "->", "getDbContainer", "(", ")", ".", "\"`\n SET\n \"", ".", "$", "this", "->", "_getPreparedFields", "(", "$", "toUpdate", ")", ".", "\"\n WHERE\n `$idField` = ?\"", ";", "if", "(", "!", "array_key_exists", "(", "$", "idField", ",", "$", "toUpdate", ")", ")", "{", "$", "toUpdate", "[", "$", "idField", "]", "=", "$", "this", "->", "_item", "->", "getId", "(", ")", "->", "getOrig", "(", ")", ";", "}", "$", "prepared", "=", "Agl", "::", "app", "(", ")", "->", "getDb", "(", ")", "->", "getConnection", "(", ")", "->", "prepare", "(", "$", "query", ")", ";", "if", "(", "!", "$", "prepared", "->", "execute", "(", "array_values", "(", "$", "toUpdate", ")", ")", ")", "{", "$", "error", "=", "$", "prepared", "->", "errorInfo", "(", ")", ";", "throw", "new", "Exception", "(", "\"The update query failed (table '\"", ".", "$", "this", "->", "getDbPrefix", "(", ")", ".", "$", "this", "->", "_item", "->", "getDbContainer", "(", ")", ".", "\"') with message '\"", ".", "$", "error", "[", "2", "]", ".", "\"'\"", ")", ";", "}", "if", "(", "Agl", "::", "app", "(", ")", "->", "isDebugMode", "(", ")", ")", "{", "Agl", "::", "app", "(", ")", "->", "getDb", "(", ")", "->", "incrementCounter", "(", ")", ";", "}", "return", "$", "prepared", "->", "rowCount", "(", ")", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", ")", ";", "}", "return", "true", ";", "}" ]
Commit the update to MySQL and check the query result. @return int Number of affected rows
[ "Commit", "the", "update", "to", "MySQL", "and", "check", "the", "query", "result", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Mysql/Query/Update.php#L49-L87
7,789
mariusbalcytis/oauth-commerce-lib-base
src/Maba/OAuthCommerceClient/Command.php
Command.build
protected function build() { if ($this->beforeExecute) { call_user_func($this->beforeExecute, $this); } if ($this->bodyEntity !== null) { if ($this->pendingRequest instanceof EntityEnclosingRequestInterface) { $this->pendingRequest->setBody( $this->serializer->serialize($this->bodyEntity, $this->requestFormat), $this->requestContentType ); } else { throw new \LogicException( 'Request must implement EntityEnclosingRequestInterface when command has body' ); } } if ($this->accessToken !== null) { $this->pendingRequest->getParams()->set('oauth_commerce.token', $this->accessToken); } $this->request = $this->pendingRequest; }
php
protected function build() { if ($this->beforeExecute) { call_user_func($this->beforeExecute, $this); } if ($this->bodyEntity !== null) { if ($this->pendingRequest instanceof EntityEnclosingRequestInterface) { $this->pendingRequest->setBody( $this->serializer->serialize($this->bodyEntity, $this->requestFormat), $this->requestContentType ); } else { throw new \LogicException( 'Request must implement EntityEnclosingRequestInterface when command has body' ); } } if ($this->accessToken !== null) { $this->pendingRequest->getParams()->set('oauth_commerce.token', $this->accessToken); } $this->request = $this->pendingRequest; }
[ "protected", "function", "build", "(", ")", "{", "if", "(", "$", "this", "->", "beforeExecute", ")", "{", "call_user_func", "(", "$", "this", "->", "beforeExecute", ",", "$", "this", ")", ";", "}", "if", "(", "$", "this", "->", "bodyEntity", "!==", "null", ")", "{", "if", "(", "$", "this", "->", "pendingRequest", "instanceof", "EntityEnclosingRequestInterface", ")", "{", "$", "this", "->", "pendingRequest", "->", "setBody", "(", "$", "this", "->", "serializer", "->", "serialize", "(", "$", "this", "->", "bodyEntity", ",", "$", "this", "->", "requestFormat", ")", ",", "$", "this", "->", "requestContentType", ")", ";", "}", "else", "{", "throw", "new", "\\", "LogicException", "(", "'Request must implement EntityEnclosingRequestInterface when command has body'", ")", ";", "}", "}", "if", "(", "$", "this", "->", "accessToken", "!==", "null", ")", "{", "$", "this", "->", "pendingRequest", "->", "getParams", "(", ")", "->", "set", "(", "'oauth_commerce.token'", ",", "$", "this", "->", "accessToken", ")", ";", "}", "$", "this", "->", "request", "=", "$", "this", "->", "pendingRequest", ";", "}" ]
Create the request object that will carry out the command
[ "Create", "the", "request", "object", "that", "will", "carry", "out", "the", "command" ]
996fc2ba0933a5a11384d537d32073c014ef4819
https://github.com/mariusbalcytis/oauth-commerce-lib-base/blob/996fc2ba0933a5a11384d537d32073c014ef4819/src/Maba/OAuthCommerceClient/Command.php#L212-L233
7,790
phlexible/phlexible
src/Phlexible/Bundle/GuiBundle/Response/ResultResponse.php
ResultResponse.setResult
public function setResult($result = self::RESULT_SUCCESS, $message = null, array $data = [], array $additional = []) { $this->headers->set('X-Phlexible-Response', 'result'); $values = [ 'success' => $result, 'msg' => $message, 'data' => $data, ]; if (is_array($additional) && count($additional)) { foreach ($additional as $key => $value) { $values += $additional; } } $this->setData($values); }
php
public function setResult($result = self::RESULT_SUCCESS, $message = null, array $data = [], array $additional = []) { $this->headers->set('X-Phlexible-Response', 'result'); $values = [ 'success' => $result, 'msg' => $message, 'data' => $data, ]; if (is_array($additional) && count($additional)) { foreach ($additional as $key => $value) { $values += $additional; } } $this->setData($values); }
[ "public", "function", "setResult", "(", "$", "result", "=", "self", "::", "RESULT_SUCCESS", ",", "$", "message", "=", "null", ",", "array", "$", "data", "=", "[", "]", ",", "array", "$", "additional", "=", "[", "]", ")", "{", "$", "this", "->", "headers", "->", "set", "(", "'X-Phlexible-Response'", ",", "'result'", ")", ";", "$", "values", "=", "[", "'success'", "=>", "$", "result", ",", "'msg'", "=>", "$", "message", ",", "'data'", "=>", "$", "data", ",", "]", ";", "if", "(", "is_array", "(", "$", "additional", ")", "&&", "count", "(", "$", "additional", ")", ")", "{", "foreach", "(", "$", "additional", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "values", "+=", "$", "additional", ";", "}", "}", "$", "this", "->", "setData", "(", "$", "values", ")", ";", "}" ]
Generate a standard result. @param bool $result True for success, false for failure @param array $message (Optional) Message @param array $data (Optional) Data @param array $additional (Optional) Additional values
[ "Generate", "a", "standard", "result", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/GuiBundle/Response/ResultResponse.php#L53-L73
7,791
bariew/yii2-notice-cms-module
components/MainBehavior.php
MainBehavior.refresh
public function refresh() { $behaviors = $this->owner->behaviors(); $settings = $behaviors[$this->getName()]; foreach ($settings as $attribute=>$value) { if (in_array($attribute, array('class'))) { continue; } $this->$attribute = $value; } return $this; }
php
public function refresh() { $behaviors = $this->owner->behaviors(); $settings = $behaviors[$this->getName()]; foreach ($settings as $attribute=>$value) { if (in_array($attribute, array('class'))) { continue; } $this->$attribute = $value; } return $this; }
[ "public", "function", "refresh", "(", ")", "{", "$", "behaviors", "=", "$", "this", "->", "owner", "->", "behaviors", "(", ")", ";", "$", "settings", "=", "$", "behaviors", "[", "$", "this", "->", "getName", "(", ")", "]", ";", "foreach", "(", "$", "settings", "as", "$", "attribute", "=>", "$", "value", ")", "{", "if", "(", "in_array", "(", "$", "attribute", ",", "array", "(", "'class'", ")", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "$", "attribute", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
refreshes its attributes from owner behavior method data @return \ActiveRecordBehavior this
[ "refreshes", "its", "attributes", "from", "owner", "behavior", "method", "data" ]
1dc9798b3ed2c511937e9d3e44867412c9f5a7b6
https://github.com/bariew/yii2-notice-cms-module/blob/1dc9798b3ed2c511937e9d3e44867412c9f5a7b6/components/MainBehavior.php#L43-L54
7,792
silencedis/phpunit-mock-helper
src/MockHelper.php
MockHelper.mockObject
public function mockObject($objectClassName, ...$configurations) { foreach ($configurations as &$configuration) { $this->prepareMockConfig($configuration); } $config = call_user_func_array('array_replace_recursive', $configurations); $willReturn = $this->pullOutArrayValue($config, 'willReturn', []); $will = $this->pullOutArrayValue($config, 'will'); $mockType = $this->pullOutArrayValue($config, 'mockType', self::MOCK_TYPE_DEFAULT); // 'methods' must be null for 'getMock' to not replace any element // (unlike 'getMockForAbstractClass') if (empty($config['methods'])) { if ($mockType == self::MOCK_TYPE_DEFAULT) { $config['methods'] = null; } } $mockBuilder = $this->testCase->getMockBuilder($objectClassName); foreach ($config as $property => $value) { $method = "set$property"; if (method_exists($mockBuilder, $method)) { $mockBuilder->$method($value); } } if ($this->getArrayValue($config, 'disableOriginalConstructor', true)) { $mockBuilder->disableOriginalConstructor(); } $mockMethod = $this->getMockMethod($mockType); /** @var \PHPUnit_Framework_MockObject_MockObject $mock */ $mock = $mockBuilder->$mockMethod(); foreach ($willReturn as $method => $value) { $mock->method($method)->willReturn($value); } foreach ($will as $method => $value) { $mock->method($method)->will($value); } return $mock; }
php
public function mockObject($objectClassName, ...$configurations) { foreach ($configurations as &$configuration) { $this->prepareMockConfig($configuration); } $config = call_user_func_array('array_replace_recursive', $configurations); $willReturn = $this->pullOutArrayValue($config, 'willReturn', []); $will = $this->pullOutArrayValue($config, 'will'); $mockType = $this->pullOutArrayValue($config, 'mockType', self::MOCK_TYPE_DEFAULT); // 'methods' must be null for 'getMock' to not replace any element // (unlike 'getMockForAbstractClass') if (empty($config['methods'])) { if ($mockType == self::MOCK_TYPE_DEFAULT) { $config['methods'] = null; } } $mockBuilder = $this->testCase->getMockBuilder($objectClassName); foreach ($config as $property => $value) { $method = "set$property"; if (method_exists($mockBuilder, $method)) { $mockBuilder->$method($value); } } if ($this->getArrayValue($config, 'disableOriginalConstructor', true)) { $mockBuilder->disableOriginalConstructor(); } $mockMethod = $this->getMockMethod($mockType); /** @var \PHPUnit_Framework_MockObject_MockObject $mock */ $mock = $mockBuilder->$mockMethod(); foreach ($willReturn as $method => $value) { $mock->method($method)->willReturn($value); } foreach ($will as $method => $value) { $mock->method($method)->will($value); } return $mock; }
[ "public", "function", "mockObject", "(", "$", "objectClassName", ",", "...", "$", "configurations", ")", "{", "foreach", "(", "$", "configurations", "as", "&", "$", "configuration", ")", "{", "$", "this", "->", "prepareMockConfig", "(", "$", "configuration", ")", ";", "}", "$", "config", "=", "call_user_func_array", "(", "'array_replace_recursive'", ",", "$", "configurations", ")", ";", "$", "willReturn", "=", "$", "this", "->", "pullOutArrayValue", "(", "$", "config", ",", "'willReturn'", ",", "[", "]", ")", ";", "$", "will", "=", "$", "this", "->", "pullOutArrayValue", "(", "$", "config", ",", "'will'", ")", ";", "$", "mockType", "=", "$", "this", "->", "pullOutArrayValue", "(", "$", "config", ",", "'mockType'", ",", "self", "::", "MOCK_TYPE_DEFAULT", ")", ";", "// 'methods' must be null for 'getMock' to not replace any element", "// (unlike 'getMockForAbstractClass')", "if", "(", "empty", "(", "$", "config", "[", "'methods'", "]", ")", ")", "{", "if", "(", "$", "mockType", "==", "self", "::", "MOCK_TYPE_DEFAULT", ")", "{", "$", "config", "[", "'methods'", "]", "=", "null", ";", "}", "}", "$", "mockBuilder", "=", "$", "this", "->", "testCase", "->", "getMockBuilder", "(", "$", "objectClassName", ")", ";", "foreach", "(", "$", "config", "as", "$", "property", "=>", "$", "value", ")", "{", "$", "method", "=", "\"set$property\"", ";", "if", "(", "method_exists", "(", "$", "mockBuilder", ",", "$", "method", ")", ")", "{", "$", "mockBuilder", "->", "$", "method", "(", "$", "value", ")", ";", "}", "}", "if", "(", "$", "this", "->", "getArrayValue", "(", "$", "config", ",", "'disableOriginalConstructor'", ",", "true", ")", ")", "{", "$", "mockBuilder", "->", "disableOriginalConstructor", "(", ")", ";", "}", "$", "mockMethod", "=", "$", "this", "->", "getMockMethod", "(", "$", "mockType", ")", ";", "/** @var \\PHPUnit_Framework_MockObject_MockObject $mock */", "$", "mock", "=", "$", "mockBuilder", "->", "$", "mockMethod", "(", ")", ";", "foreach", "(", "$", "willReturn", "as", "$", "method", "=>", "$", "value", ")", "{", "$", "mock", "->", "method", "(", "$", "method", ")", "->", "willReturn", "(", "$", "value", ")", ";", "}", "foreach", "(", "$", "will", "as", "$", "method", "=>", "$", "value", ")", "{", "$", "mock", "->", "method", "(", "$", "method", ")", "->", "will", "(", "$", "value", ")", ";", "}", "return", "$", "mock", ";", "}" ]
General method for mocking objects @param string $objectClassName @param array[] $configurations A variable number of configurations for creating of mock. You can use this feature, for example, to gather a several configurations from different sources and then just pass them to the `mockObject` method instead of merging them. It will merge them itself. Each configuration must be an array. Otherwise you will get an error. As default each item of array is considered as a name of property for which a getter may exist in the original mock builder. For example, the parameter `constructorArgs` actually will be used to make the method name `setConstructorArgs`. The values of these parameters are used as values which must be passed to the matched methods. But there are also special parameters that are handled in their own way. They are: - `constructor` - It's a shortcut of the `disableOriginalConstructor` parameter of the original mock builder. The value of parameter constructor is used to set the parameter `disableOriginalConstructor`. The value of the `constructor` must be a boolean value. The inverted boolean value will be set to the parameter `disableOriginalConstructor`. For example, if you'll set `constructor => false`, the parameter `disableOriginalConstructor` will get the value `false`. Note that the original parameter `disableOriginalConstructor` has a higher priority than parameter `constructor`. If the parameter `disableOriginalConstructor` is set, the parameter `constructor` will be ignored. - `willReturn` - It's a shortcut for the separated setting of returned values for methods. It must be an array. The keys of the array are considered as method names. The values of the array are considered as values, that must be returned by the appropriate methods. ```php // This part of configuration ... [ // ... 'willReturn' => [ 'method1' => 'value1', 'method2' => 'value2', ] // ... ] // ... equals to $mock->method('method1')->willReturn('value1'); $mock->method('method2')->willReturn('value2'); ``` - `will` - It's similar to `willReturn` but the method `will()` will used instead of `willReturn()`. - `mockType` - It's a type of mock. Allowed values are: - `default` (MockHelper::MOCK_TYPE_DEFAULT) - `abstract` (MockHelper::MOCK_TYPE_ABSTRACT) - `trait` (MockHelper::MOCK_TYPE_TRAIT) The value of this parameter is used to select a method of the original mock builder that must be used to create a mock. @return \PHPUnit_Framework_MockObject_MockObject @throws InvalidMockTypeException
[ "General", "method", "for", "mocking", "objects" ]
f0b2b1be37acd5695919882b92b294a1ece0c543
https://github.com/silencedis/phpunit-mock-helper/blob/f0b2b1be37acd5695919882b92b294a1ece0c543/src/MockHelper.php#L99-L145
7,793
silencedis/phpunit-mock-helper
src/MockHelper.php
MockHelper.prepareMockConfig
protected function prepareMockConfig(array &$config = []) { if (!isset($config['willReturn'])) { $config['willReturn'] = []; } if (!empty($config['methods']) && is_array($config['methods'])) { $methodNames = []; foreach ($config['methods'] as $key => $value) { $methodNames[] = is_numeric($key) ? $value : $key; if (!is_numeric($key)) { $config['willReturn'][$key] = $value; } } $config['methods'] = $methodNames; } if (!isset($config['will'])) { $config['will'] = []; } if(isset($config['constructor'], $config['disableOriginalConstructor'])) { unset($config['constructor']); } if (isset($config['constructor'])) { $config['disableOriginalConstructor'] = !$config['constructor']; unset($config['constructor']); } }
php
protected function prepareMockConfig(array &$config = []) { if (!isset($config['willReturn'])) { $config['willReturn'] = []; } if (!empty($config['methods']) && is_array($config['methods'])) { $methodNames = []; foreach ($config['methods'] as $key => $value) { $methodNames[] = is_numeric($key) ? $value : $key; if (!is_numeric($key)) { $config['willReturn'][$key] = $value; } } $config['methods'] = $methodNames; } if (!isset($config['will'])) { $config['will'] = []; } if(isset($config['constructor'], $config['disableOriginalConstructor'])) { unset($config['constructor']); } if (isset($config['constructor'])) { $config['disableOriginalConstructor'] = !$config['constructor']; unset($config['constructor']); } }
[ "protected", "function", "prepareMockConfig", "(", "array", "&", "$", "config", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'willReturn'", "]", ")", ")", "{", "$", "config", "[", "'willReturn'", "]", "=", "[", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'methods'", "]", ")", "&&", "is_array", "(", "$", "config", "[", "'methods'", "]", ")", ")", "{", "$", "methodNames", "=", "[", "]", ";", "foreach", "(", "$", "config", "[", "'methods'", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "methodNames", "[", "]", "=", "is_numeric", "(", "$", "key", ")", "?", "$", "value", ":", "$", "key", ";", "if", "(", "!", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "config", "[", "'willReturn'", "]", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "$", "config", "[", "'methods'", "]", "=", "$", "methodNames", ";", "}", "if", "(", "!", "isset", "(", "$", "config", "[", "'will'", "]", ")", ")", "{", "$", "config", "[", "'will'", "]", "=", "[", "]", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'constructor'", "]", ",", "$", "config", "[", "'disableOriginalConstructor'", "]", ")", ")", "{", "unset", "(", "$", "config", "[", "'constructor'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'constructor'", "]", ")", ")", "{", "$", "config", "[", "'disableOriginalConstructor'", "]", "=", "!", "$", "config", "[", "'constructor'", "]", ";", "unset", "(", "$", "config", "[", "'constructor'", "]", ")", ";", "}", "}" ]
Index keys of the item "setMethods" using its values @param array $config
[ "Index", "keys", "of", "the", "item", "setMethods", "using", "its", "values" ]
f0b2b1be37acd5695919882b92b294a1ece0c543
https://github.com/silencedis/phpunit-mock-helper/blob/f0b2b1be37acd5695919882b92b294a1ece0c543/src/MockHelper.php#L152-L181
7,794
silencedis/phpunit-mock-helper
src/MockHelper.php
MockHelper.getMockMethod
protected function getMockMethod($mockType) { if (!isset($this->mockTypesToMethodsMap[$mockType])) { throw new InvalidMockTypeException(); } return $this->mockTypesToMethodsMap[$mockType]; }
php
protected function getMockMethod($mockType) { if (!isset($this->mockTypesToMethodsMap[$mockType])) { throw new InvalidMockTypeException(); } return $this->mockTypesToMethodsMap[$mockType]; }
[ "protected", "function", "getMockMethod", "(", "$", "mockType", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "mockTypesToMethodsMap", "[", "$", "mockType", "]", ")", ")", "{", "throw", "new", "InvalidMockTypeException", "(", ")", ";", "}", "return", "$", "this", "->", "mockTypesToMethodsMap", "[", "$", "mockType", "]", ";", "}" ]
Returns a name of method for getting an instance of mock. @param string $mockType A mock type. @return string @throws InvalidMockTypeException
[ "Returns", "a", "name", "of", "method", "for", "getting", "an", "instance", "of", "mock", "." ]
f0b2b1be37acd5695919882b92b294a1ece0c543
https://github.com/silencedis/phpunit-mock-helper/blob/f0b2b1be37acd5695919882b92b294a1ece0c543/src/MockHelper.php#L191-L198
7,795
silencedis/phpunit-mock-helper
src/MockHelper.php
MockHelper.pullOutArrayValue
private function pullOutArrayValue(array &$array, string $key, $defaultValue = null) { if (!array_key_exists($key, $array)) { return $defaultValue; } $value = $array[$key]; unset($array[$key]); return $value; }
php
private function pullOutArrayValue(array &$array, string $key, $defaultValue = null) { if (!array_key_exists($key, $array)) { return $defaultValue; } $value = $array[$key]; unset($array[$key]); return $value; }
[ "private", "function", "pullOutArrayValue", "(", "array", "&", "$", "array", ",", "string", "$", "key", ",", "$", "defaultValue", "=", "null", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "array", ")", ")", "{", "return", "$", "defaultValue", ";", "}", "$", "value", "=", "$", "array", "[", "$", "key", "]", ";", "unset", "(", "$", "array", "[", "$", "key", "]", ")", ";", "return", "$", "value", ";", "}" ]
Returns an array item value and removes it from the array. @param array $array An array from which the value is pulled out. @param string $key A key of the array. @param mixed $defaultValue A default value which will be returned if the specified key doesn't exist in the array. @return mixed
[ "Returns", "an", "array", "item", "value", "and", "removes", "it", "from", "the", "array", "." ]
f0b2b1be37acd5695919882b92b294a1ece0c543
https://github.com/silencedis/phpunit-mock-helper/blob/f0b2b1be37acd5695919882b92b294a1ece0c543/src/MockHelper.php#L230-L240
7,796
dlabas/DlcCategory
src/DlcCategory/Service/Category.php
Category.getAllCategoryTreesAsArray
public function getAllCategoryTreesAsArray() { $rootIds = $this->getAllRootIds(); $trees = array(); foreach ($rootIds as $rootId) { $trees[$rootId] = $this->getCategoryTreeAsArray($rootId); } return $trees; }
php
public function getAllCategoryTreesAsArray() { $rootIds = $this->getAllRootIds(); $trees = array(); foreach ($rootIds as $rootId) { $trees[$rootId] = $this->getCategoryTreeAsArray($rootId); } return $trees; }
[ "public", "function", "getAllCategoryTreesAsArray", "(", ")", "{", "$", "rootIds", "=", "$", "this", "->", "getAllRootIds", "(", ")", ";", "$", "trees", "=", "array", "(", ")", ";", "foreach", "(", "$", "rootIds", "as", "$", "rootId", ")", "{", "$", "trees", "[", "$", "rootId", "]", "=", "$", "this", "->", "getCategoryTreeAsArray", "(", "$", "rootId", ")", ";", "}", "return", "$", "trees", ";", "}" ]
Returns an array of all category trees @return array
[ "Returns", "an", "array", "of", "all", "category", "trees" ]
cd4dbcae8c1c6a373f96fb0ad15ccebad383f256
https://github.com/dlabas/DlcCategory/blob/cd4dbcae8c1c6a373f96fb0ad15ccebad383f256/src/DlcCategory/Service/Category.php#L217-L227
7,797
dlabas/DlcCategory
src/DlcCategory/Service/Category.php
Category.deleteCategory
public function deleteCategory($id) { $this->validateId($id); $category = $this->getMapper()->find($id); if (null === $category) { throw new \InvalidArgumentException('No category found for id "' . $id . '"'); } $node = $this->getNestedSetManager()->wrapNode($category); $node->delete(); return $this; }
php
public function deleteCategory($id) { $this->validateId($id); $category = $this->getMapper()->find($id); if (null === $category) { throw new \InvalidArgumentException('No category found for id "' . $id . '"'); } $node = $this->getNestedSetManager()->wrapNode($category); $node->delete(); return $this; }
[ "public", "function", "deleteCategory", "(", "$", "id", ")", "{", "$", "this", "->", "validateId", "(", "$", "id", ")", ";", "$", "category", "=", "$", "this", "->", "getMapper", "(", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "null", "===", "$", "category", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'No category found for id \"'", ".", "$", "id", ".", "'\"'", ")", ";", "}", "$", "node", "=", "$", "this", "->", "getNestedSetManager", "(", ")", "->", "wrapNode", "(", "$", "category", ")", ";", "$", "node", "->", "delete", "(", ")", ";", "return", "$", "this", ";", "}" ]
Deletes a category node @param int $id @return \DlcCategory\Service\Category
[ "Deletes", "a", "category", "node" ]
cd4dbcae8c1c6a373f96fb0ad15ccebad383f256
https://github.com/dlabas/DlcCategory/blob/cd4dbcae8c1c6a373f96fb0ad15ccebad383f256/src/DlcCategory/Service/Category.php#L407-L421
7,798
ekyna/Characteristics
Schema/Group.php
Group.addDefinition
public function addDefinition(Definition $definition) { if ($this->hasDefinition($definition)) { throw new \InvalidArgumentException(sprintf('Definition "%s" allready exists.', $definition->getName())); } $this->definitions[$definition->getName()] = $definition; return $this; }
php
public function addDefinition(Definition $definition) { if ($this->hasDefinition($definition)) { throw new \InvalidArgumentException(sprintf('Definition "%s" allready exists.', $definition->getName())); } $this->definitions[$definition->getName()] = $definition; return $this; }
[ "public", "function", "addDefinition", "(", "Definition", "$", "definition", ")", "{", "if", "(", "$", "this", "->", "hasDefinition", "(", "$", "definition", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Definition \"%s\" allready exists.'", ",", "$", "definition", "->", "getName", "(", ")", ")", ")", ";", "}", "$", "this", "->", "definitions", "[", "$", "definition", "->", "getName", "(", ")", "]", "=", "$", "definition", ";", "return", "$", "this", ";", "}" ]
Adds a definition. @param Definition $definition @throws \InvalidArgumentException @return Group
[ "Adds", "a", "definition", "." ]
118a349fd98a7c28721d3cbaba67ce79d1cffada
https://github.com/ekyna/Characteristics/blob/118a349fd98a7c28721d3cbaba67ce79d1cffada/Schema/Group.php#L108-L117
7,799
ekyna/Characteristics
Schema/Group.php
Group.getDefinitionByName
public function getDefinitionByName($name) { if (!array_key_exists($name, $this->definitions)) { throw new \InvalidArgumentException(sprintf('Can\'t find "%s" Definition.', $name)); } return $this->definitions[$name]; }
php
public function getDefinitionByName($name) { if (!array_key_exists($name, $this->definitions)) { throw new \InvalidArgumentException(sprintf('Can\'t find "%s" Definition.', $name)); } return $this->definitions[$name]; }
[ "public", "function", "getDefinitionByName", "(", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "definitions", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Can\\'t find \"%s\" Definition.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "definitions", "[", "$", "name", "]", ";", "}" ]
Returns a definition by name. @param $name @throws \InvalidArgumentException @return Definition
[ "Returns", "a", "definition", "by", "name", "." ]
118a349fd98a7c28721d3cbaba67ce79d1cffada
https://github.com/ekyna/Characteristics/blob/118a349fd98a7c28721d3cbaba67ce79d1cffada/Schema/Group.php#L128-L135