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
6,500
OWeb/OWeb-Framework
OWeb/OWeb.php
OWeb.loadSettings
private function loadSettings() { $settings = $this->manage_settings->getSetting($this); if (isset($settings['extensions'])) { //loading all extensions try { $this->loadExtensions($settings['extensions']); } catch (\Exception $ex) { throw new \OWeb\Exception('Failed to load all Extensions in' . OWEB_CONFIG, 0, $ex); } } }
php
private function loadSettings() { $settings = $this->manage_settings->getSetting($this); if (isset($settings['extensions'])) { //loading all extensions try { $this->loadExtensions($settings['extensions']); } catch (\Exception $ex) { throw new \OWeb\Exception('Failed to load all Extensions in' . OWEB_CONFIG, 0, $ex); } } }
[ "private", "function", "loadSettings", "(", ")", "{", "$", "settings", "=", "$", "this", "->", "manage_settings", "->", "getSetting", "(", "$", "this", ")", ";", "if", "(", "isset", "(", "$", "settings", "[", "'extensions'", "]", ")", ")", "{", "//loading all extensions", "try", "{", "$", "this", "->", "loadExtensions", "(", "$", "settings", "[", "'extensions'", "]", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "throw", "new", "\\", "OWeb", "\\", "Exception", "(", "'Failed to load all Extensions in'", ".", "OWEB_CONFIG", ",", "0", ",", "$", "ex", ")", ";", "}", "}", "}" ]
Will load the settings from the Default config file. And will after loads the extensions @throws \OWeb\Exception If there is any error while loading the Settings
[ "Will", "load", "the", "settings", "from", "the", "Default", "config", "file", ".", "And", "will", "after", "loads", "the", "extensions" ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/OWeb.php#L200-L213
6,501
eghojansu/nutrition
src/Utils/Breadcrumb.php
Breadcrumb.setRoot
public function setRoot($route, array $args = null, $label = null) { array_unshift($this->hierarchy, [ 'label' => $label ?: static::titleIze($route), 'route' => $route, 'args' => (array) $args ]); $this->lastKey = null; return $this; }
php
public function setRoot($route, array $args = null, $label = null) { array_unshift($this->hierarchy, [ 'label' => $label ?: static::titleIze($route), 'route' => $route, 'args' => (array) $args ]); $this->lastKey = null; return $this; }
[ "public", "function", "setRoot", "(", "$", "route", ",", "array", "$", "args", "=", "null", ",", "$", "label", "=", "null", ")", "{", "array_unshift", "(", "$", "this", "->", "hierarchy", ",", "[", "'label'", "=>", "$", "label", "?", ":", "static", "::", "titleIze", "(", "$", "route", ")", ",", "'route'", "=>", "$", "route", ",", "'args'", "=>", "(", "array", ")", "$", "args", "]", ")", ";", "$", "this", "->", "lastKey", "=", "null", ";", "return", "$", "this", ";", "}" ]
Set breadcrumb root @param string $route @param array|null $args @param string $label
[ "Set", "breadcrumb", "root" ]
3941c62aeb6dafda55349a38dd4107d521f8964a
https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/Utils/Breadcrumb.php#L35-L45
6,502
eghojansu/nutrition
src/Utils/Breadcrumb.php
Breadcrumb.add
public function add($route, array $args = null, $label = null) { $this->hierarchy[] = [ 'label' => $label ?: static::titleIze($route), 'route' => $route, 'args' => (array) $args ]; $this->lastKey = null; return $this; }
php
public function add($route, array $args = null, $label = null) { $this->hierarchy[] = [ 'label' => $label ?: static::titleIze($route), 'route' => $route, 'args' => (array) $args ]; $this->lastKey = null; return $this; }
[ "public", "function", "add", "(", "$", "route", ",", "array", "$", "args", "=", "null", ",", "$", "label", "=", "null", ")", "{", "$", "this", "->", "hierarchy", "[", "]", "=", "[", "'label'", "=>", "$", "label", "?", ":", "static", "::", "titleIze", "(", "$", "route", ")", ",", "'route'", "=>", "$", "route", ",", "'args'", "=>", "(", "array", ")", "$", "args", "]", ";", "$", "this", "->", "lastKey", "=", "null", ";", "return", "$", "this", ";", "}" ]
Append to breadcrumb @param string $route @param array|null $args @param string $label
[ "Append", "to", "breadcrumb" ]
3941c62aeb6dafda55349a38dd4107d521f8964a
https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/Utils/Breadcrumb.php#L53-L63
6,503
eghojansu/nutrition
src/Utils/Breadcrumb.php
Breadcrumb.addCurrentRoute
public function addCurrentRoute($label = null) { $base = Base::instance(); $args = ($base['PARAMS'] ?: []) + ($base['GET'] ?: []); unset($args[0]); return $this->add($base['ALIAS'], $args, $label); }
php
public function addCurrentRoute($label = null) { $base = Base::instance(); $args = ($base['PARAMS'] ?: []) + ($base['GET'] ?: []); unset($args[0]); return $this->add($base['ALIAS'], $args, $label); }
[ "public", "function", "addCurrentRoute", "(", "$", "label", "=", "null", ")", "{", "$", "base", "=", "Base", "::", "instance", "(", ")", ";", "$", "args", "=", "(", "$", "base", "[", "'PARAMS'", "]", "?", ":", "[", "]", ")", "+", "(", "$", "base", "[", "'GET'", "]", "?", ":", "[", "]", ")", ";", "unset", "(", "$", "args", "[", "0", "]", ")", ";", "return", "$", "this", "->", "add", "(", "$", "base", "[", "'ALIAS'", "]", ",", "$", "args", ",", "$", "label", ")", ";", "}" ]
Add current route to breadcrumb @param string $label
[ "Add", "current", "route", "to", "breadcrumb" ]
3941c62aeb6dafda55349a38dd4107d521f8964a
https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/Utils/Breadcrumb.php#L69-L76
6,504
eghojansu/nutrition
src/Utils/Breadcrumb.php
Breadcrumb.addGroup
public function addGroup( GroupChecker $groupChecker, $firstLabel = null, $route = null, array $routeArgs = null ) { $routeArgs = (array) $routeArgs; if (empty($route)) { $base = Base::instance(); $routeArgs = ($base['PARAMS'] ?: []) + ($base['GET'] ?: []); $route = $base['ALIAS']; unset($routeArgs[0]); } $i = 0; foreach ($groupChecker->getGroups() as $label => $group) { if ($i === 0 && $firstLabel) { $label = $firstLabel; } $this->add($route, ['group' => $group] + $routeArgs, $label); $i++; if ($groupChecker->isEqual($group)) { break; } } return $this; }
php
public function addGroup( GroupChecker $groupChecker, $firstLabel = null, $route = null, array $routeArgs = null ) { $routeArgs = (array) $routeArgs; if (empty($route)) { $base = Base::instance(); $routeArgs = ($base['PARAMS'] ?: []) + ($base['GET'] ?: []); $route = $base['ALIAS']; unset($routeArgs[0]); } $i = 0; foreach ($groupChecker->getGroups() as $label => $group) { if ($i === 0 && $firstLabel) { $label = $firstLabel; } $this->add($route, ['group' => $group] + $routeArgs, $label); $i++; if ($groupChecker->isEqual($group)) { break; } } return $this; }
[ "public", "function", "addGroup", "(", "GroupChecker", "$", "groupChecker", ",", "$", "firstLabel", "=", "null", ",", "$", "route", "=", "null", ",", "array", "$", "routeArgs", "=", "null", ")", "{", "$", "routeArgs", "=", "(", "array", ")", "$", "routeArgs", ";", "if", "(", "empty", "(", "$", "route", ")", ")", "{", "$", "base", "=", "Base", "::", "instance", "(", ")", ";", "$", "routeArgs", "=", "(", "$", "base", "[", "'PARAMS'", "]", "?", ":", "[", "]", ")", "+", "(", "$", "base", "[", "'GET'", "]", "?", ":", "[", "]", ")", ";", "$", "route", "=", "$", "base", "[", "'ALIAS'", "]", ";", "unset", "(", "$", "routeArgs", "[", "0", "]", ")", ";", "}", "$", "i", "=", "0", ";", "foreach", "(", "$", "groupChecker", "->", "getGroups", "(", ")", "as", "$", "label", "=>", "$", "group", ")", "{", "if", "(", "$", "i", "===", "0", "&&", "$", "firstLabel", ")", "{", "$", "label", "=", "$", "firstLabel", ";", "}", "$", "this", "->", "add", "(", "$", "route", ",", "[", "'group'", "=>", "$", "group", "]", "+", "$", "routeArgs", ",", "$", "label", ")", ";", "$", "i", "++", ";", "if", "(", "$", "groupChecker", "->", "isEqual", "(", "$", "group", ")", ")", "{", "break", ";", "}", "}", "return", "$", "this", ";", "}" ]
Add Group to breadcrumb @param GroupChecker $groupChecker @param string $firstLabel @param string $route @param array|null $routeArgs
[ "Add", "Group", "to", "breadcrumb" ]
3941c62aeb6dafda55349a38dd4107d521f8964a
https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/Utils/Breadcrumb.php#L85-L114
6,505
eghojansu/nutrition
src/Utils/Breadcrumb.php
Breadcrumb.isLast
public function isLast($key) { if (null === $this->lastKey) { end($this->hierarchy); $this->lastKey = key($this->hierarchy); } return $key === $this->lastKey; }
php
public function isLast($key) { if (null === $this->lastKey) { end($this->hierarchy); $this->lastKey = key($this->hierarchy); } return $key === $this->lastKey; }
[ "public", "function", "isLast", "(", "$", "key", ")", "{", "if", "(", "null", "===", "$", "this", "->", "lastKey", ")", "{", "end", "(", "$", "this", "->", "hierarchy", ")", ";", "$", "this", "->", "lastKey", "=", "key", "(", "$", "this", "->", "hierarchy", ")", ";", "}", "return", "$", "key", "===", "$", "this", "->", "lastKey", ";", "}" ]
Check if key is las key @param mixed $key @return boolean
[ "Check", "if", "key", "is", "las", "key" ]
3941c62aeb6dafda55349a38dd4107d521f8964a
https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/Utils/Breadcrumb.php#L130-L138
6,506
Persata/SymfonyApiExtension
src/ApiClient.php
ApiClient.reset
public function reset(): ApiClient { $this->internalRequest = new InternalRequest($this->baseUrl, 'GET'); $this->request = null; $this->response = null; $this->profiler = false; $this->hasPerformedRequest = false; $this->kernel->shutdown(); $this->kernel->boot(); return $this; }
php
public function reset(): ApiClient { $this->internalRequest = new InternalRequest($this->baseUrl, 'GET'); $this->request = null; $this->response = null; $this->profiler = false; $this->hasPerformedRequest = false; $this->kernel->shutdown(); $this->kernel->boot(); return $this; }
[ "public", "function", "reset", "(", ")", ":", "ApiClient", "{", "$", "this", "->", "internalRequest", "=", "new", "InternalRequest", "(", "$", "this", "->", "baseUrl", ",", "'GET'", ")", ";", "$", "this", "->", "request", "=", "null", ";", "$", "this", "->", "response", "=", "null", ";", "$", "this", "->", "profiler", "=", "false", ";", "$", "this", "->", "hasPerformedRequest", "=", "false", ";", "$", "this", "->", "kernel", "->", "shutdown", "(", ")", ";", "$", "this", "->", "kernel", "->", "boot", "(", ")", ";", "return", "$", "this", ";", "}" ]
Reset the internal state of the API client
[ "Reset", "the", "internal", "state", "of", "the", "API", "client" ]
89fcfbd13b462c184ab208215b8b12199e8647dd
https://github.com/Persata/SymfonyApiExtension/blob/89fcfbd13b462c184ab208215b8b12199e8647dd/src/ApiClient.php#L78-L91
6,507
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/State.php
PHP_ParserGenerator_State.stateResortCompare
static function stateResortCompare($a, $b) { $n = $b->nNtAct - $a->nNtAct; if ($n === 0) { $n = $b->nTknAct - $a->nTknAct; } return $n; }
php
static function stateResortCompare($a, $b) { $n = $b->nNtAct - $a->nNtAct; if ($n === 0) { $n = $b->nTknAct - $a->nTknAct; } return $n; }
[ "static", "function", "stateResortCompare", "(", "$", "a", ",", "$", "b", ")", "{", "$", "n", "=", "$", "b", "->", "nNtAct", "-", "$", "a", "->", "nNtAct", ";", "if", "(", "$", "n", "===", "0", ")", "{", "$", "n", "=", "$", "b", "->", "nTknAct", "-", "$", "a", "->", "nTknAct", ";", "}", "return", "$", "n", ";", "}" ]
Compare two states for sorting purposes. The smaller state is the one with the most non-terminal actions. If they have the same number of non-terminal actions, then the smaller is the one with the most token actions.
[ "Compare", "two", "states", "for", "sorting", "purposes", ".", "The", "smaller", "state", "is", "the", "one", "with", "the", "most", "non", "-", "terminal", "actions", ".", "If", "they", "have", "the", "same", "number", "of", "non", "-", "terminal", "actions", "then", "the", "smaller", "is", "the", "one", "with", "the", "most", "token", "actions", "." ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/State.php#L155-L162
6,508
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/State.php
PHP_ParserGenerator_State.statecmp
static function statecmp($a, $b) { for ($rc = 0; $rc == 0 && $a && $b; $a = $a->bp, $b = $b->bp) { $rc = $a->rp->index - $b->rp->index; if ($rc === 0) { $rc = $a->dot - $b->dot; } } if ($rc == 0) { if ($a) { $rc = 1; } if ($b) { $rc = -1; } } return $rc; }
php
static function statecmp($a, $b) { for ($rc = 0; $rc == 0 && $a && $b; $a = $a->bp, $b = $b->bp) { $rc = $a->rp->index - $b->rp->index; if ($rc === 0) { $rc = $a->dot - $b->dot; } } if ($rc == 0) { if ($a) { $rc = 1; } if ($b) { $rc = -1; } } return $rc; }
[ "static", "function", "statecmp", "(", "$", "a", ",", "$", "b", ")", "{", "for", "(", "$", "rc", "=", "0", ";", "$", "rc", "==", "0", "&&", "$", "a", "&&", "$", "b", ";", "$", "a", "=", "$", "a", "->", "bp", ",", "$", "b", "=", "$", "b", "->", "bp", ")", "{", "$", "rc", "=", "$", "a", "->", "rp", "->", "index", "-", "$", "b", "->", "rp", "->", "index", ";", "if", "(", "$", "rc", "===", "0", ")", "{", "$", "rc", "=", "$", "a", "->", "dot", "-", "$", "b", "->", "dot", ";", "}", "}", "if", "(", "$", "rc", "==", "0", ")", "{", "if", "(", "$", "a", ")", "{", "$", "rc", "=", "1", ";", "}", "if", "(", "$", "b", ")", "{", "$", "rc", "=", "-", "1", ";", "}", "}", "return", "$", "rc", ";", "}" ]
Compare two states based on their configurations @param PHP_ParserGenerator_Config|0 $a @param PHP_ParserGenerator_Config|0 $b @return int
[ "Compare", "two", "states", "based", "on", "their", "configurations" ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/State.php#L171-L188
6,509
rodchyn/elephant-lang
lib/ParserGenerator/PHP/ParserGenerator/State.php
PHP_ParserGenerator_State.statehash
private static function statehash(PHP_ParserGenerator_Config $a) { $h = 0; while ($a) { $h = $h * 571 + $a->rp->index * 37 + $a->dot; $a = $a->bp; } return (int) $h; }
php
private static function statehash(PHP_ParserGenerator_Config $a) { $h = 0; while ($a) { $h = $h * 571 + $a->rp->index * 37 + $a->dot; $a = $a->bp; } return (int) $h; }
[ "private", "static", "function", "statehash", "(", "PHP_ParserGenerator_Config", "$", "a", ")", "{", "$", "h", "=", "0", ";", "while", "(", "$", "a", ")", "{", "$", "h", "=", "$", "h", "*", "571", "+", "$", "a", "->", "rp", "->", "index", "*", "37", "+", "$", "a", "->", "dot", ";", "$", "a", "=", "$", "a", "->", "bp", ";", "}", "return", "(", "int", ")", "$", "h", ";", "}" ]
Hash a state based on its configuration @return int
[ "Hash", "a", "state", "based", "on", "its", "configuration" ]
e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf
https://github.com/rodchyn/elephant-lang/blob/e0acc26eec1ab4dbfcc90ad79efc23318eaba5cf/lib/ParserGenerator/PHP/ParserGenerator/State.php#L195-L203
6,510
nia-php/translating
sources/Filter/ValueFormatterFilter.php
ValueFormatterFilter.extractArguments
private function extractArguments(string $argumentList): array { $arguments = []; foreach (array_map('trim', explode(',', $argumentList)) as $rawArgument) { if ($rawArgument === '') { continue; } list ($argumentName, $argumentValue) = array_map('trim', explode('=', $rawArgument, 2) + [ null, null ]); $arguments[$argumentName] = $argumentValue; } return $arguments; }
php
private function extractArguments(string $argumentList): array { $arguments = []; foreach (array_map('trim', explode(',', $argumentList)) as $rawArgument) { if ($rawArgument === '') { continue; } list ($argumentName, $argumentValue) = array_map('trim', explode('=', $rawArgument, 2) + [ null, null ]); $arguments[$argumentName] = $argumentValue; } return $arguments; }
[ "private", "function", "extractArguments", "(", "string", "$", "argumentList", ")", ":", "array", "{", "$", "arguments", "=", "[", "]", ";", "foreach", "(", "array_map", "(", "'trim'", ",", "explode", "(", "','", ",", "$", "argumentList", ")", ")", "as", "$", "rawArgument", ")", "{", "if", "(", "$", "rawArgument", "===", "''", ")", "{", "continue", ";", "}", "list", "(", "$", "argumentName", ",", "$", "argumentValue", ")", "=", "array_map", "(", "'trim'", ",", "explode", "(", "'='", ",", "$", "rawArgument", ",", "2", ")", "+", "[", "null", ",", "null", "]", ")", ";", "$", "arguments", "[", "$", "argumentName", "]", "=", "$", "argumentValue", ";", "}", "return", "$", "arguments", ";", "}" ]
Extracts the arguments for a raw argument list. @param string $argumentList The raw argument list. @return string[] Native map with extracted arguments.
[ "Extracts", "the", "arguments", "for", "a", "raw", "argument", "list", "." ]
9348eeef0216b08c3efb102abc02e8d07c043dca
https://github.com/nia-php/translating/blob/9348eeef0216b08c3efb102abc02e8d07c043dca/sources/Filter/ValueFormatterFilter.php#L132-L150
6,511
mikegibson/sentient
src/Utility/StringHelper.php
StringHelper.wrap
public function wrap($text, $options = array()) { if (is_numeric($options)) { $options = array('width' => $options); } $options += array('width' => 72, 'wordWrap' => true, 'indent' => null, 'indentAt' => 0); if ($options['wordWrap']) { $wrapped = $this->wordWrap($text, $options['width'], "\n"); } else { $wrapped = trim(chunk_split($text, $options['width'] - 1, "\n")); } if (!empty($options['indent'])) { $chunks = explode("\n", $wrapped); for ($i = $options['indentAt'], $len = count($chunks); $i < $len; $i++) { $chunks[$i] = $options['indent'] . $chunks[$i]; } $wrapped = implode("\n", $chunks); } return $wrapped; }
php
public function wrap($text, $options = array()) { if (is_numeric($options)) { $options = array('width' => $options); } $options += array('width' => 72, 'wordWrap' => true, 'indent' => null, 'indentAt' => 0); if ($options['wordWrap']) { $wrapped = $this->wordWrap($text, $options['width'], "\n"); } else { $wrapped = trim(chunk_split($text, $options['width'] - 1, "\n")); } if (!empty($options['indent'])) { $chunks = explode("\n", $wrapped); for ($i = $options['indentAt'], $len = count($chunks); $i < $len; $i++) { $chunks[$i] = $options['indent'] . $chunks[$i]; } $wrapped = implode("\n", $chunks); } return $wrapped; }
[ "public", "function", "wrap", "(", "$", "text", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "is_numeric", "(", "$", "options", ")", ")", "{", "$", "options", "=", "array", "(", "'width'", "=>", "$", "options", ")", ";", "}", "$", "options", "+=", "array", "(", "'width'", "=>", "72", ",", "'wordWrap'", "=>", "true", ",", "'indent'", "=>", "null", ",", "'indentAt'", "=>", "0", ")", ";", "if", "(", "$", "options", "[", "'wordWrap'", "]", ")", "{", "$", "wrapped", "=", "$", "this", "->", "wordWrap", "(", "$", "text", ",", "$", "options", "[", "'width'", "]", ",", "\"\\n\"", ")", ";", "}", "else", "{", "$", "wrapped", "=", "trim", "(", "chunk_split", "(", "$", "text", ",", "$", "options", "[", "'width'", "]", "-", "1", ",", "\"\\n\"", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'indent'", "]", ")", ")", "{", "$", "chunks", "=", "explode", "(", "\"\\n\"", ",", "$", "wrapped", ")", ";", "for", "(", "$", "i", "=", "$", "options", "[", "'indentAt'", "]", ",", "$", "len", "=", "count", "(", "$", "chunks", ")", ";", "$", "i", "<", "$", "len", ";", "$", "i", "++", ")", "{", "$", "chunks", "[", "$", "i", "]", "=", "$", "options", "[", "'indent'", "]", ".", "$", "chunks", "[", "$", "i", "]", ";", "}", "$", "wrapped", "=", "implode", "(", "\"\\n\"", ",", "$", "chunks", ")", ";", "}", "return", "$", "wrapped", ";", "}" ]
Wraps text to a specific width, can optionally wrap at word breaks. ### Options - `width` The width to wrap to. Defaults to 72. - `wordWrap` Only wrap on words breaks (spaces) Defaults to true. - `indent` String to indent with. Defaults to null. - `indentAt` 0 based index to start indenting at. Defaults to 0. @param string $text The text to format. @param array|integer $options Array of options to use, or an integer to wrap the text to. @return string Formatted text.
[ "Wraps", "text", "to", "a", "specific", "width", "can", "optionally", "wrap", "at", "word", "breaks", "." ]
05aaaa0cd8e649d2b526df52a59c9fb53c114338
https://github.com/mikegibson/sentient/blob/05aaaa0cd8e649d2b526df52a59c9fb53c114338/src/Utility/StringHelper.php#L276-L297
6,512
mikegibson/sentient
src/Utility/StringHelper.php
StringHelper.wordWrap
public function wordWrap($text, $width = 72, $break = "\n", $cut = false) { if ($cut) { $parts = array(); while (mb_strlen($text) > 0) { $part = mb_substr($text, 0, $width); $parts[] = trim($part); $text = trim(mb_substr($text, mb_strlen($part))); } return implode($break, $parts); } $parts = array(); while (mb_strlen($text) > 0) { if ($width >= mb_strlen($text)) { $parts[] = trim($text); break; } $part = mb_substr($text, 0, $width); $nextChar = mb_substr($text, $width, 1); if ($nextChar !== ' ') { $breakAt = mb_strrpos($part, ' '); if ($breakAt === false) { $breakAt = mb_strpos($text, ' ', $width); } if ($breakAt === false) { $parts[] = trim($text); break; } $part = mb_substr($text, 0, $breakAt); } $part = trim($part); $parts[] = $part; $text = trim(mb_substr($text, mb_strlen($part))); } return implode($break, $parts); }
php
public function wordWrap($text, $width = 72, $break = "\n", $cut = false) { if ($cut) { $parts = array(); while (mb_strlen($text) > 0) { $part = mb_substr($text, 0, $width); $parts[] = trim($part); $text = trim(mb_substr($text, mb_strlen($part))); } return implode($break, $parts); } $parts = array(); while (mb_strlen($text) > 0) { if ($width >= mb_strlen($text)) { $parts[] = trim($text); break; } $part = mb_substr($text, 0, $width); $nextChar = mb_substr($text, $width, 1); if ($nextChar !== ' ') { $breakAt = mb_strrpos($part, ' '); if ($breakAt === false) { $breakAt = mb_strpos($text, ' ', $width); } if ($breakAt === false) { $parts[] = trim($text); break; } $part = mb_substr($text, 0, $breakAt); } $part = trim($part); $parts[] = $part; $text = trim(mb_substr($text, mb_strlen($part))); } return implode($break, $parts); }
[ "public", "function", "wordWrap", "(", "$", "text", ",", "$", "width", "=", "72", ",", "$", "break", "=", "\"\\n\"", ",", "$", "cut", "=", "false", ")", "{", "if", "(", "$", "cut", ")", "{", "$", "parts", "=", "array", "(", ")", ";", "while", "(", "mb_strlen", "(", "$", "text", ")", ">", "0", ")", "{", "$", "part", "=", "mb_substr", "(", "$", "text", ",", "0", ",", "$", "width", ")", ";", "$", "parts", "[", "]", "=", "trim", "(", "$", "part", ")", ";", "$", "text", "=", "trim", "(", "mb_substr", "(", "$", "text", ",", "mb_strlen", "(", "$", "part", ")", ")", ")", ";", "}", "return", "implode", "(", "$", "break", ",", "$", "parts", ")", ";", "}", "$", "parts", "=", "array", "(", ")", ";", "while", "(", "mb_strlen", "(", "$", "text", ")", ">", "0", ")", "{", "if", "(", "$", "width", ">=", "mb_strlen", "(", "$", "text", ")", ")", "{", "$", "parts", "[", "]", "=", "trim", "(", "$", "text", ")", ";", "break", ";", "}", "$", "part", "=", "mb_substr", "(", "$", "text", ",", "0", ",", "$", "width", ")", ";", "$", "nextChar", "=", "mb_substr", "(", "$", "text", ",", "$", "width", ",", "1", ")", ";", "if", "(", "$", "nextChar", "!==", "' '", ")", "{", "$", "breakAt", "=", "mb_strrpos", "(", "$", "part", ",", "' '", ")", ";", "if", "(", "$", "breakAt", "===", "false", ")", "{", "$", "breakAt", "=", "mb_strpos", "(", "$", "text", ",", "' '", ",", "$", "width", ")", ";", "}", "if", "(", "$", "breakAt", "===", "false", ")", "{", "$", "parts", "[", "]", "=", "trim", "(", "$", "text", ")", ";", "break", ";", "}", "$", "part", "=", "mb_substr", "(", "$", "text", ",", "0", ",", "$", "breakAt", ")", ";", "}", "$", "part", "=", "trim", "(", "$", "part", ")", ";", "$", "parts", "[", "]", "=", "$", "part", ";", "$", "text", "=", "trim", "(", "mb_substr", "(", "$", "text", ",", "mb_strlen", "(", "$", "part", ")", ")", ")", ";", "}", "return", "implode", "(", "$", "break", ",", "$", "parts", ")", ";", "}" ]
Unicode aware version of wordwrap. @param string $text The text to format. @param integer $width The width to wrap to. Defaults to 72. @param string $break The line is broken using the optional break parameter. Defaults to '\n'. @param boolean $cut If the cut is set to true, the string is always wrapped at the specified width. @return string Formatted text.
[ "Unicode", "aware", "version", "of", "wordwrap", "." ]
05aaaa0cd8e649d2b526df52a59c9fb53c114338
https://github.com/mikegibson/sentient/blob/05aaaa0cd8e649d2b526df52a59c9fb53c114338/src/Utility/StringHelper.php#L308-L349
6,513
mikegibson/sentient
src/Utility/StringHelper.php
StringHelper.ascii
public function ascii($array) { $ascii = ''; foreach ($array as $utf8) { if ($utf8 < 128) { $ascii .= chr($utf8); } elseif ($utf8 < 2048) { $ascii .= chr(192 + (($utf8 - ($utf8 % 64)) / 64)); $ascii .= chr(128 + ($utf8 % 64)); } else { $ascii .= chr(224 + (($utf8 - ($utf8 % 4096)) / 4096)); $ascii .= chr(128 + ((($utf8 % 4096) - ($utf8 % 64)) / 64)); $ascii .= chr(128 + ($utf8 % 64)); } } return $ascii; }
php
public function ascii($array) { $ascii = ''; foreach ($array as $utf8) { if ($utf8 < 128) { $ascii .= chr($utf8); } elseif ($utf8 < 2048) { $ascii .= chr(192 + (($utf8 - ($utf8 % 64)) / 64)); $ascii .= chr(128 + ($utf8 % 64)); } else { $ascii .= chr(224 + (($utf8 - ($utf8 % 4096)) / 4096)); $ascii .= chr(128 + ((($utf8 % 4096) - ($utf8 % 64)) / 64)); $ascii .= chr(128 + ($utf8 % 64)); } } return $ascii; }
[ "public", "function", "ascii", "(", "$", "array", ")", "{", "$", "ascii", "=", "''", ";", "foreach", "(", "$", "array", "as", "$", "utf8", ")", "{", "if", "(", "$", "utf8", "<", "128", ")", "{", "$", "ascii", ".=", "chr", "(", "$", "utf8", ")", ";", "}", "elseif", "(", "$", "utf8", "<", "2048", ")", "{", "$", "ascii", ".=", "chr", "(", "192", "+", "(", "(", "$", "utf8", "-", "(", "$", "utf8", "%", "64", ")", ")", "/", "64", ")", ")", ";", "$", "ascii", ".=", "chr", "(", "128", "+", "(", "$", "utf8", "%", "64", ")", ")", ";", "}", "else", "{", "$", "ascii", ".=", "chr", "(", "224", "+", "(", "(", "$", "utf8", "-", "(", "$", "utf8", "%", "4096", ")", ")", "/", "4096", ")", ")", ";", "$", "ascii", ".=", "chr", "(", "128", "+", "(", "(", "(", "$", "utf8", "%", "4096", ")", "-", "(", "$", "utf8", "%", "64", ")", ")", "/", "64", ")", ")", ";", "$", "ascii", ".=", "chr", "(", "128", "+", "(", "$", "utf8", "%", "64", ")", ")", ";", "}", "}", "return", "$", "ascii", ";", "}" ]
Converts the decimal value of a multibyte character string to a string @param array $array @return string
[ "Converts", "the", "decimal", "value", "of", "a", "multibyte", "character", "string", "to", "a", "string" ]
05aaaa0cd8e649d2b526df52a59c9fb53c114338
https://github.com/mikegibson/sentient/blob/05aaaa0cd8e649d2b526df52a59c9fb53c114338/src/Utility/StringHelper.php#L720-L739
6,514
common-libs/storage
src/Options.php
Options.setPath
public function setPath(File $path) { $this->path = $path; if ($this->isCreateIfNotExists() && !$path->isFile()) { $path->getParent()->mkdir(); $path->write(""); $this->setCreateDefault(true); if (!$path->isFile()) { throw new FileNotFoundException($path); } } $this->content = $path->getContent(); }
php
public function setPath(File $path) { $this->path = $path; if ($this->isCreateIfNotExists() && !$path->isFile()) { $path->getParent()->mkdir(); $path->write(""); $this->setCreateDefault(true); if (!$path->isFile()) { throw new FileNotFoundException($path); } } $this->content = $path->getContent(); }
[ "public", "function", "setPath", "(", "File", "$", "path", ")", "{", "$", "this", "->", "path", "=", "$", "path", ";", "if", "(", "$", "this", "->", "isCreateIfNotExists", "(", ")", "&&", "!", "$", "path", "->", "isFile", "(", ")", ")", "{", "$", "path", "->", "getParent", "(", ")", "->", "mkdir", "(", ")", ";", "$", "path", "->", "write", "(", "\"\"", ")", ";", "$", "this", "->", "setCreateDefault", "(", "true", ")", ";", "if", "(", "!", "$", "path", "->", "isFile", "(", ")", ")", "{", "throw", "new", "FileNotFoundException", "(", "$", "path", ")", ";", "}", "}", "$", "this", "->", "content", "=", "$", "path", "->", "getContent", "(", ")", ";", "}" ]
sets file path @param File $path file path @since 0.2.1 @throws FileNotFoundException
[ "sets", "file", "path" ]
7bfc8b551baf600d49a8762f343d829cbe25a361
https://github.com/common-libs/storage/blob/7bfc8b551baf600d49a8762f343d829cbe25a361/src/Options.php#L99-L110
6,515
budkit/budkit-framework
src/Budkit/Application/Instance.php
Instance.createRequestFromGlobals
protected function createRequestFromGlobals() { $_ATTRIBUTES = array_merge([], isset($_SESSION) ? $_SESSION : []); $SERVER = $_SERVER; if (isset($_POST["_method"])) { //Hack to allow PATCH, DELETE, OPTIONS etc! $SERVER['REQUEST_METHOD'] = $_POST["_method"]; } return new Http\Request($_GET, $_POST, $_ATTRIBUTES, $_COOKIE, $_FILES, $SERVER); }
php
protected function createRequestFromGlobals() { $_ATTRIBUTES = array_merge([], isset($_SESSION) ? $_SESSION : []); $SERVER = $_SERVER; if (isset($_POST["_method"])) { //Hack to allow PATCH, DELETE, OPTIONS etc! $SERVER['REQUEST_METHOD'] = $_POST["_method"]; } return new Http\Request($_GET, $_POST, $_ATTRIBUTES, $_COOKIE, $_FILES, $SERVER); }
[ "protected", "function", "createRequestFromGlobals", "(", ")", "{", "$", "_ATTRIBUTES", "=", "array_merge", "(", "[", "]", ",", "isset", "(", "$", "_SESSION", ")", "?", "$", "_SESSION", ":", "[", "]", ")", ";", "$", "SERVER", "=", "$", "_SERVER", ";", "if", "(", "isset", "(", "$", "_POST", "[", "\"_method\"", "]", ")", ")", "{", "//Hack to allow PATCH, DELETE, OPTIONS etc!", "$", "SERVER", "[", "'REQUEST_METHOD'", "]", "=", "$", "_POST", "[", "\"_method\"", "]", ";", "}", "return", "new", "Http", "\\", "Request", "(", "$", "_GET", ",", "$", "_POST", ",", "$", "_ATTRIBUTES", ",", "$", "_COOKIE", ",", "$", "_FILES", ",", "$", "SERVER", ")", ";", "}" ]
Creates an Http\Request object - Captures global request variables `$_ENV`, `$_SESSION`, `$_SERVER`, `$_POST`, `$_GET`, `$_COOKIE`, `$_FILES`. - These global variables (except `$_POST`) are sanitized, then destroyed by the created Request object. *Hint: To handle non HTTP Request, fork this class and overwrite this method* //1. Fork this class; use Budkit\Application; class myApplication extends Application\Instance{ //Must return an object of kind Budkit/Protocol/Request protected function createRequestFromGlobals(){ //Return your custom Request object } } //2. Then use as follows $app = new myApplication(); $app->execute(); @return \Budkit\Protocol\Http\Request [#](?file=Budkit/Protocol/Http/Request.php)
[ "Creates", "an", "Http", "\\", "Request", "object" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Application/Instance.php#L93-L105
6,516
budkit/budkit-framework
src/Budkit/Application/Instance.php
Instance.execute
public function execute(Request $request = null) { $request = $request ?: $this->request; $this->dispatcher->dispatch($request, $this->response); }
php
public function execute(Request $request = null) { $request = $request ?: $this->request; $this->dispatcher->dispatch($request, $this->response); }
[ "public", "function", "execute", "(", "Request", "$", "request", "=", "null", ")", "{", "$", "request", "=", "$", "request", "?", ":", "$", "this", "->", "request", ";", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "$", "request", ",", "$", "this", "->", "response", ")", ";", "}" ]
Dispatches the request to the router; @param \Budkit\Protocol\Request $request [#](?file=Budkit/Protocol/Request.php)
[ "Dispatches", "the", "request", "to", "the", "router", ";" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Application/Instance.php#L113-L119
6,517
remote-office/libx
src/External/LocationServer/Api/LocationServerClient.php
LocationServerClient.suggest
public function suggest($zipcode, $number, $addition = null) { // Concat url $url = self::API_URL . '/suggest?q=' . $zipcode . '-' . $number . (!empty($addition) ? '-' . $addition : ''); // Create a REST request $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_GET); // Create a REST response $response = new \LibX\Net\Rest\Response(); // Make the call $data = $this->call($request, $response); if($data->response->numFound > 1) throw new Exception('More then one document found'); // Get document $document = array_pop($data->response->docs); // Check type if($document->type !== 'adres') throw new Exception('Invalid document type found (' . $doc->type . ')'); // Get address id $id = $document->id; return $id; }
php
public function suggest($zipcode, $number, $addition = null) { // Concat url $url = self::API_URL . '/suggest?q=' . $zipcode . '-' . $number . (!empty($addition) ? '-' . $addition : ''); // Create a REST request $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_GET); // Create a REST response $response = new \LibX\Net\Rest\Response(); // Make the call $data = $this->call($request, $response); if($data->response->numFound > 1) throw new Exception('More then one document found'); // Get document $document = array_pop($data->response->docs); // Check type if($document->type !== 'adres') throw new Exception('Invalid document type found (' . $doc->type . ')'); // Get address id $id = $document->id; return $id; }
[ "public", "function", "suggest", "(", "$", "zipcode", ",", "$", "number", ",", "$", "addition", "=", "null", ")", "{", "// Concat url", "$", "url", "=", "self", "::", "API_URL", ".", "'/suggest?q='", ".", "$", "zipcode", ".", "'-'", ".", "$", "number", ".", "(", "!", "empty", "(", "$", "addition", ")", "?", "'-'", ".", "$", "addition", ":", "''", ")", ";", "// Create a REST request", "$", "request", "=", "new", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Request", "(", "$", "url", ",", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Request", "::", "REQUEST_METHOD_GET", ")", ";", "// Create a REST response", "$", "response", "=", "new", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Response", "(", ")", ";", "// Make the call", "$", "data", "=", "$", "this", "->", "call", "(", "$", "request", ",", "$", "response", ")", ";", "if", "(", "$", "data", "->", "response", "->", "numFound", ">", "1", ")", "throw", "new", "Exception", "(", "'More then one document found'", ")", ";", "// Get document", "$", "document", "=", "array_pop", "(", "$", "data", "->", "response", "->", "docs", ")", ";", "// Check type", "if", "(", "$", "document", "->", "type", "!==", "'adres'", ")", "throw", "new", "Exception", "(", "'Invalid document type found ('", ".", "$", "doc", "->", "type", ".", "')'", ")", ";", "// Get address id", "$", "id", "=", "$", "document", "->", "id", ";", "return", "$", "id", ";", "}" ]
Suggest an address id @param string $zipcode @param integer $number @param string $addition @return string
[ "Suggest", "an", "address", "id" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/External/LocationServer/Api/LocationServerClient.php#L26-L54
6,518
remote-office/libx
src/External/LocationServer/Api/LocationServerClient.php
LocationServerClient.lookup
public function lookup($id) { // Concat url $url = self::API_URL . '/lookup?id=' . $id; // Create a REST request $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_GET); // Create a REST response $response = new \LibX\Net\Rest\Response(); // Make the call $data = $this->call($request, $response); if($data->response->numFound > 1) throw new Exception('More then one document found'); // Get document $document = array_pop($data->response->docs); // Check type if($document->type !== 'adres') throw new Exception('Invalid document type found (' . $doc->type . ')'); $state = $document->provincienaam; $municipality = $document->gemeentenaam; $city = $document->woonplaatsnaam; $area = $document->wijknaam; $neighbourhood = $document->buurtnaam; $street = $document->straatnaam; $number = $document->huisnummer; if(isset($document->huisnummertoevoeging) && isset($document->huisletter)) $addition = $document->huisnummertoevoeging . $document->huisletter; elseif(isset($document->huisnummertoevoeging)) $addition = $document->huisnummertoevoeging; elseif(isset($document->huisletter)) $addition = $document->huisletter; else $addition = null; $zipcode = $document->postcode; if($document->bron === 'BAG') { $address = new \LibX\External\Bag\Address(); $address->setId($document->id); $address->setStateCode($document->provinciecode); $address->setMunicipalityCode($document->gemeentecode); $address->setCityCode($document->woonplaatscode); $address->setDistrictCode($document->wijkcode); $address->setNeighbourhoodCode($document->buurtcode); $address->setPublicSpaceId($document->openbareruimte_id); $address->setNumberIndicationId($document->nummeraanduiding_id); $address->setAddressableObjectId($document->adresseerbaarobject_id); } else { $address = new \LibX\Util\Address(); } $address->setCountry('Nederland'); $address->setState($state); $address->setMunicipality($municipality); $address->setCity($city); $address->setDistrict($area); $address->setNeighbourhood($neighbourhood); $address->setStreet($street); $address->setNumber($number); $address->setAddition($addition); $address->setZipcode($zipcode); return $address; }
php
public function lookup($id) { // Concat url $url = self::API_URL . '/lookup?id=' . $id; // Create a REST request $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_GET); // Create a REST response $response = new \LibX\Net\Rest\Response(); // Make the call $data = $this->call($request, $response); if($data->response->numFound > 1) throw new Exception('More then one document found'); // Get document $document = array_pop($data->response->docs); // Check type if($document->type !== 'adres') throw new Exception('Invalid document type found (' . $doc->type . ')'); $state = $document->provincienaam; $municipality = $document->gemeentenaam; $city = $document->woonplaatsnaam; $area = $document->wijknaam; $neighbourhood = $document->buurtnaam; $street = $document->straatnaam; $number = $document->huisnummer; if(isset($document->huisnummertoevoeging) && isset($document->huisletter)) $addition = $document->huisnummertoevoeging . $document->huisletter; elseif(isset($document->huisnummertoevoeging)) $addition = $document->huisnummertoevoeging; elseif(isset($document->huisletter)) $addition = $document->huisletter; else $addition = null; $zipcode = $document->postcode; if($document->bron === 'BAG') { $address = new \LibX\External\Bag\Address(); $address->setId($document->id); $address->setStateCode($document->provinciecode); $address->setMunicipalityCode($document->gemeentecode); $address->setCityCode($document->woonplaatscode); $address->setDistrictCode($document->wijkcode); $address->setNeighbourhoodCode($document->buurtcode); $address->setPublicSpaceId($document->openbareruimte_id); $address->setNumberIndicationId($document->nummeraanduiding_id); $address->setAddressableObjectId($document->adresseerbaarobject_id); } else { $address = new \LibX\Util\Address(); } $address->setCountry('Nederland'); $address->setState($state); $address->setMunicipality($municipality); $address->setCity($city); $address->setDistrict($area); $address->setNeighbourhood($neighbourhood); $address->setStreet($street); $address->setNumber($number); $address->setAddition($addition); $address->setZipcode($zipcode); return $address; }
[ "public", "function", "lookup", "(", "$", "id", ")", "{", "// Concat url", "$", "url", "=", "self", "::", "API_URL", ".", "'/lookup?id='", ".", "$", "id", ";", "// Create a REST request", "$", "request", "=", "new", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Request", "(", "$", "url", ",", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Request", "::", "REQUEST_METHOD_GET", ")", ";", "// Create a REST response", "$", "response", "=", "new", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Response", "(", ")", ";", "// Make the call", "$", "data", "=", "$", "this", "->", "call", "(", "$", "request", ",", "$", "response", ")", ";", "if", "(", "$", "data", "->", "response", "->", "numFound", ">", "1", ")", "throw", "new", "Exception", "(", "'More then one document found'", ")", ";", "// Get document", "$", "document", "=", "array_pop", "(", "$", "data", "->", "response", "->", "docs", ")", ";", "// Check type", "if", "(", "$", "document", "->", "type", "!==", "'adres'", ")", "throw", "new", "Exception", "(", "'Invalid document type found ('", ".", "$", "doc", "->", "type", ".", "')'", ")", ";", "$", "state", "=", "$", "document", "->", "provincienaam", ";", "$", "municipality", "=", "$", "document", "->", "gemeentenaam", ";", "$", "city", "=", "$", "document", "->", "woonplaatsnaam", ";", "$", "area", "=", "$", "document", "->", "wijknaam", ";", "$", "neighbourhood", "=", "$", "document", "->", "buurtnaam", ";", "$", "street", "=", "$", "document", "->", "straatnaam", ";", "$", "number", "=", "$", "document", "->", "huisnummer", ";", "if", "(", "isset", "(", "$", "document", "->", "huisnummertoevoeging", ")", "&&", "isset", "(", "$", "document", "->", "huisletter", ")", ")", "$", "addition", "=", "$", "document", "->", "huisnummertoevoeging", ".", "$", "document", "->", "huisletter", ";", "elseif", "(", "isset", "(", "$", "document", "->", "huisnummertoevoeging", ")", ")", "$", "addition", "=", "$", "document", "->", "huisnummertoevoeging", ";", "elseif", "(", "isset", "(", "$", "document", "->", "huisletter", ")", ")", "$", "addition", "=", "$", "document", "->", "huisletter", ";", "else", "$", "addition", "=", "null", ";", "$", "zipcode", "=", "$", "document", "->", "postcode", ";", "if", "(", "$", "document", "->", "bron", "===", "'BAG'", ")", "{", "$", "address", "=", "new", "\\", "LibX", "\\", "External", "\\", "Bag", "\\", "Address", "(", ")", ";", "$", "address", "->", "setId", "(", "$", "document", "->", "id", ")", ";", "$", "address", "->", "setStateCode", "(", "$", "document", "->", "provinciecode", ")", ";", "$", "address", "->", "setMunicipalityCode", "(", "$", "document", "->", "gemeentecode", ")", ";", "$", "address", "->", "setCityCode", "(", "$", "document", "->", "woonplaatscode", ")", ";", "$", "address", "->", "setDistrictCode", "(", "$", "document", "->", "wijkcode", ")", ";", "$", "address", "->", "setNeighbourhoodCode", "(", "$", "document", "->", "buurtcode", ")", ";", "$", "address", "->", "setPublicSpaceId", "(", "$", "document", "->", "openbareruimte_id", ")", ";", "$", "address", "->", "setNumberIndicationId", "(", "$", "document", "->", "nummeraanduiding_id", ")", ";", "$", "address", "->", "setAddressableObjectId", "(", "$", "document", "->", "adresseerbaarobject_id", ")", ";", "}", "else", "{", "$", "address", "=", "new", "\\", "LibX", "\\", "Util", "\\", "Address", "(", ")", ";", "}", "$", "address", "->", "setCountry", "(", "'Nederland'", ")", ";", "$", "address", "->", "setState", "(", "$", "state", ")", ";", "$", "address", "->", "setMunicipality", "(", "$", "municipality", ")", ";", "$", "address", "->", "setCity", "(", "$", "city", ")", ";", "$", "address", "->", "setDistrict", "(", "$", "area", ")", ";", "$", "address", "->", "setNeighbourhood", "(", "$", "neighbourhood", ")", ";", "$", "address", "->", "setStreet", "(", "$", "street", ")", ";", "$", "address", "->", "setNumber", "(", "$", "number", ")", ";", "$", "address", "->", "setAddition", "(", "$", "addition", ")", ";", "$", "address", "->", "setZipcode", "(", "$", "zipcode", ")", ";", "return", "$", "address", ";", "}" ]
Lookup an address id @param string $id @return string
[ "Lookup", "an", "address", "id" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/External/LocationServer/Api/LocationServerClient.php#L62-L135
6,519
Dhii/i18n-helper-base
src/StringTranslatorAwareTrait.php
StringTranslatorAwareTrait._setTranslator
protected function _setTranslator($translator) { if (!(is_null($translator) || $translator instanceof StringTranslatorInterface)) { throw new InvalidArgumentException('Invalid translator'); } $this->translator = $translator; return $this; }
php
protected function _setTranslator($translator) { if (!(is_null($translator) || $translator instanceof StringTranslatorInterface)) { throw new InvalidArgumentException('Invalid translator'); } $this->translator = $translator; return $this; }
[ "protected", "function", "_setTranslator", "(", "$", "translator", ")", "{", "if", "(", "!", "(", "is_null", "(", "$", "translator", ")", "||", "$", "translator", "instanceof", "StringTranslatorInterface", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid translator'", ")", ";", "}", "$", "this", "->", "translator", "=", "$", "translator", ";", "return", "$", "this", ";", "}" ]
Assigns the translator to be used by this instance. @since [*next-version*] @param StringTranslatorInterface|null $translator The translator. @throws InvalidArgumentException If translator is invalid. @return $this
[ "Assigns", "the", "translator", "to", "be", "used", "by", "this", "instance", "." ]
fc4c881f3e528ea918588831ebeffb92738f8dd5
https://github.com/Dhii/i18n-helper-base/blob/fc4c881f3e528ea918588831ebeffb92738f8dd5/src/StringTranslatorAwareTrait.php#L34-L43
6,520
jeromeklam/freefw
src/FreeFW/Application/Config.php
Config.readConfig
protected function readConfig() { if ($this->loaded == false) { $this->config = $this->loader->getDatas(); $this->loaded = true; } return $this; }
php
protected function readConfig() { if ($this->loaded == false) { $this->config = $this->loader->getDatas(); $this->loaded = true; } return $this; }
[ "protected", "function", "readConfig", "(", ")", "{", "if", "(", "$", "this", "->", "loaded", "==", "false", ")", "{", "$", "this", "->", "config", "=", "$", "this", "->", "loader", "->", "getDatas", "(", ")", ";", "$", "this", "->", "loaded", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Lecture de la configuration @return \FreeFW\Application\Config
[ "Lecture", "de", "la", "configuration" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Application/Config.php#L68-L76
6,521
jeromeklam/freefw
src/FreeFW/Application/Config.php
Config.getFactory
public static function getFactory($p_name, $p_file = null) { if (self::$factory === null) { self::$factory = array(); } if (!array_key_exists($p_name, self::$factory)) { self::$factory[$p_name] = new self($p_file); } return self::$factory[$p_name]; }
php
public static function getFactory($p_name, $p_file = null) { if (self::$factory === null) { self::$factory = array(); } if (!array_key_exists($p_name, self::$factory)) { self::$factory[$p_name] = new self($p_file); } return self::$factory[$p_name]; }
[ "public", "static", "function", "getFactory", "(", "$", "p_name", ",", "$", "p_file", "=", "null", ")", "{", "if", "(", "self", "::", "$", "factory", "===", "null", ")", "{", "self", "::", "$", "factory", "=", "array", "(", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "p_name", ",", "self", "::", "$", "factory", ")", ")", "{", "self", "::", "$", "factory", "[", "$", "p_name", "]", "=", "new", "self", "(", "$", "p_file", ")", ";", "}", "return", "self", "::", "$", "factory", "[", "$", "p_name", "]", ";", "}" ]
Retourne l'instance @var string $p_name @var string $p_file @return \FreeFW\Application\Config
[ "Retourne", "l", "instance" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Application/Config.php#L98-L108
6,522
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/num.php
Num._init
public static function _init() { \Lang::load('byte_units', true); static::$config = \Config::load('num', true); static::$byte_units = \Lang::get('byte_units'); }
php
public static function _init() { \Lang::load('byte_units', true); static::$config = \Config::load('num', true); static::$byte_units = \Lang::get('byte_units'); }
[ "public", "static", "function", "_init", "(", ")", "{", "\\", "Lang", "::", "load", "(", "'byte_units'", ",", "true", ")", ";", "static", "::", "$", "config", "=", "\\", "Config", "::", "load", "(", "'num'", ",", "true", ")", ";", "static", "::", "$", "byte_units", "=", "\\", "Lang", "::", "get", "(", "'byte_units'", ")", ";", "}" ]
Class initialization callback @return void
[ "Class", "initialization", "callback" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/num.php#L51-L57
6,523
Dhii/tokenizer-abstract
src/TokenAwareTrait.php
TokenAwareTrait._setToken
protected function _setToken($token) { if ($token !== null && !($token instanceof TokenInterface)) { throw $this->_createInvalidArgumentException($this->__('Invalid token'), null, null, $token); } $this->token = $token; }
php
protected function _setToken($token) { if ($token !== null && !($token instanceof TokenInterface)) { throw $this->_createInvalidArgumentException($this->__('Invalid token'), null, null, $token); } $this->token = $token; }
[ "protected", "function", "_setToken", "(", "$", "token", ")", "{", "if", "(", "$", "token", "!==", "null", "&&", "!", "(", "$", "token", "instanceof", "TokenInterface", ")", ")", "{", "throw", "$", "this", "->", "_createInvalidArgumentException", "(", "$", "this", "->", "__", "(", "'Invalid token'", ")", ",", "null", ",", "null", ",", "$", "token", ")", ";", "}", "$", "this", "->", "token", "=", "$", "token", ";", "}" ]
Assigns a token to this instance. @since [*next-version*] @param TokenInterface|null $token The token.
[ "Assigns", "a", "token", "to", "this", "instance", "." ]
45588113b1fca6daf62b776aade8627d08970565
https://github.com/Dhii/tokenizer-abstract/blob/45588113b1fca6daf62b776aade8627d08970565/src/TokenAwareTrait.php#L41-L48
6,524
bfitech/zapmin
src/AdminStore.php
AdminStore.adm_login
public function adm_login($args) { $this->init(); $logger = $this->logger; if ($this->store_is_logged_in()) return [AdminStoreError::USER_ALREADY_LOGGED_IN]; if (!isset($args['post'])) return [AdminStoreError::DATA_INCOMPLETE]; if (!Common::check_idict($args['post'], ['uname', 'upass'])) return [AdminStoreError::DATA_INCOMPLETE]; extract($args['post']); $usalt = $this->store->query( "SELECT usalt FROM udata WHERE uname=? LIMIT 1", [$uname]); if (!$usalt) # user not found return [AdminStoreError::USER_NOT_FOUND]; $usalt = $usalt['usalt']; $udata = $this->store_match_password($uname, $upass, $usalt); if (!$udata) { # wrong password $logger->warning( "Zapmin: login: wrong password: '$uname'."); return [AdminStoreError::WRONG_PASSWORD]; } // generate token $token = $this->generate_secret( $upass . $usalt . time(), $usalt); $sid = $this->store->insert('usess', [ 'uid' => $udata['uid'], 'token' => $token, ], 'sid'); if ($this->dbtype == 'mysql') { // mysql has no parametrized default values, and can't // invoke trigger on currently inserted table $expire_at = $this->store->stmt_fragment('datetime', [ 'delta' => $this->expiration, ]); $this->store->query_raw(sprintf( "UPDATE usess SET expire=(%s) WHERE sid='%s'", $expire_at, $sid)); } // token must be used by the router; this is a subset // of return value of get_safe_user_data() so it needs // a re-request after signing in $logger->info("Zapmin: login: OK: '$uname'."); return [0, [ 'uid' => $udata['uid'], 'uname' => $udata['uname'], 'token' => $token, ]]; }
php
public function adm_login($args) { $this->init(); $logger = $this->logger; if ($this->store_is_logged_in()) return [AdminStoreError::USER_ALREADY_LOGGED_IN]; if (!isset($args['post'])) return [AdminStoreError::DATA_INCOMPLETE]; if (!Common::check_idict($args['post'], ['uname', 'upass'])) return [AdminStoreError::DATA_INCOMPLETE]; extract($args['post']); $usalt = $this->store->query( "SELECT usalt FROM udata WHERE uname=? LIMIT 1", [$uname]); if (!$usalt) # user not found return [AdminStoreError::USER_NOT_FOUND]; $usalt = $usalt['usalt']; $udata = $this->store_match_password($uname, $upass, $usalt); if (!$udata) { # wrong password $logger->warning( "Zapmin: login: wrong password: '$uname'."); return [AdminStoreError::WRONG_PASSWORD]; } // generate token $token = $this->generate_secret( $upass . $usalt . time(), $usalt); $sid = $this->store->insert('usess', [ 'uid' => $udata['uid'], 'token' => $token, ], 'sid'); if ($this->dbtype == 'mysql') { // mysql has no parametrized default values, and can't // invoke trigger on currently inserted table $expire_at = $this->store->stmt_fragment('datetime', [ 'delta' => $this->expiration, ]); $this->store->query_raw(sprintf( "UPDATE usess SET expire=(%s) WHERE sid='%s'", $expire_at, $sid)); } // token must be used by the router; this is a subset // of return value of get_safe_user_data() so it needs // a re-request after signing in $logger->info("Zapmin: login: OK: '$uname'."); return [0, [ 'uid' => $udata['uid'], 'uname' => $udata['uname'], 'token' => $token, ]]; }
[ "public", "function", "adm_login", "(", "$", "args", ")", "{", "$", "this", "->", "init", "(", ")", ";", "$", "logger", "=", "$", "this", "->", "logger", ";", "if", "(", "$", "this", "->", "store_is_logged_in", "(", ")", ")", "return", "[", "AdminStoreError", "::", "USER_ALREADY_LOGGED_IN", "]", ";", "if", "(", "!", "isset", "(", "$", "args", "[", "'post'", "]", ")", ")", "return", "[", "AdminStoreError", "::", "DATA_INCOMPLETE", "]", ";", "if", "(", "!", "Common", "::", "check_idict", "(", "$", "args", "[", "'post'", "]", ",", "[", "'uname'", ",", "'upass'", "]", ")", ")", "return", "[", "AdminStoreError", "::", "DATA_INCOMPLETE", "]", ";", "extract", "(", "$", "args", "[", "'post'", "]", ")", ";", "$", "usalt", "=", "$", "this", "->", "store", "->", "query", "(", "\"SELECT usalt FROM udata WHERE uname=? LIMIT 1\"", ",", "[", "$", "uname", "]", ")", ";", "if", "(", "!", "$", "usalt", ")", "# user not found", "return", "[", "AdminStoreError", "::", "USER_NOT_FOUND", "]", ";", "$", "usalt", "=", "$", "usalt", "[", "'usalt'", "]", ";", "$", "udata", "=", "$", "this", "->", "store_match_password", "(", "$", "uname", ",", "$", "upass", ",", "$", "usalt", ")", ";", "if", "(", "!", "$", "udata", ")", "{", "# wrong password", "$", "logger", "->", "warning", "(", "\"Zapmin: login: wrong password: '$uname'.\"", ")", ";", "return", "[", "AdminStoreError", "::", "WRONG_PASSWORD", "]", ";", "}", "// generate token", "$", "token", "=", "$", "this", "->", "generate_secret", "(", "$", "upass", ".", "$", "usalt", ".", "time", "(", ")", ",", "$", "usalt", ")", ";", "$", "sid", "=", "$", "this", "->", "store", "->", "insert", "(", "'usess'", ",", "[", "'uid'", "=>", "$", "udata", "[", "'uid'", "]", ",", "'token'", "=>", "$", "token", ",", "]", ",", "'sid'", ")", ";", "if", "(", "$", "this", "->", "dbtype", "==", "'mysql'", ")", "{", "// mysql has no parametrized default values, and can't", "// invoke trigger on currently inserted table", "$", "expire_at", "=", "$", "this", "->", "store", "->", "stmt_fragment", "(", "'datetime'", ",", "[", "'delta'", "=>", "$", "this", "->", "expiration", ",", "]", ")", ";", "$", "this", "->", "store", "->", "query_raw", "(", "sprintf", "(", "\"UPDATE usess SET expire=(%s) WHERE sid='%s'\"", ",", "$", "expire_at", ",", "$", "sid", ")", ")", ";", "}", "// token must be used by the router; this is a subset", "// of return value of get_safe_user_data() so it needs", "// a re-request after signing in", "$", "logger", "->", "info", "(", "\"Zapmin: login: OK: '$uname'.\"", ")", ";", "return", "[", "0", ",", "[", "'uid'", "=>", "$", "udata", "[", "'uid'", "]", ",", "'uname'", "=>", "$", "udata", "[", "'uname'", "]", ",", "'token'", "=>", "$", "token", ",", "]", "]", ";", "}" ]
Sign in. @param array $args Dict with keys: `uname`, `upass`. @return array An array of the form: @code (array)[ (int errno), (dict){ 'uid': (int uid), 'uname': (string uname), 'token': (string token) } ] @endcode
[ "Sign", "in", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStore.php#L39-L96
6,525
bfitech/zapmin
src/AdminStore.php
AdminStore.adm_logout
public function adm_logout() { if (!$this->store_is_logged_in()) return [AdminStoreError::USER_NOT_LOGGED_IN]; # this just close sessions with current sid, whether it exists # or not, including the case of account self-deletion $this->store_close_session($this->user_data['sid']); # reset status $this->store_reset_status(); # router must set appropriate cookie $this->logger->info(sprintf( "Zapmin: logout: OK: '%s'.", $this->user_data['uname'] )); return [0]; }
php
public function adm_logout() { if (!$this->store_is_logged_in()) return [AdminStoreError::USER_NOT_LOGGED_IN]; # this just close sessions with current sid, whether it exists # or not, including the case of account self-deletion $this->store_close_session($this->user_data['sid']); # reset status $this->store_reset_status(); # router must set appropriate cookie $this->logger->info(sprintf( "Zapmin: logout: OK: '%s'.", $this->user_data['uname'] )); return [0]; }
[ "public", "function", "adm_logout", "(", ")", "{", "if", "(", "!", "$", "this", "->", "store_is_logged_in", "(", ")", ")", "return", "[", "AdminStoreError", "::", "USER_NOT_LOGGED_IN", "]", ";", "# this just close sessions with current sid, whether it exists", "# or not, including the case of account self-deletion", "$", "this", "->", "store_close_session", "(", "$", "this", "->", "user_data", "[", "'sid'", "]", ")", ";", "# reset status", "$", "this", "->", "store_reset_status", "(", ")", ";", "# router must set appropriate cookie", "$", "this", "->", "logger", "->", "info", "(", "sprintf", "(", "\"Zapmin: logout: OK: '%s'.\"", ",", "$", "this", "->", "user_data", "[", "'uname'", "]", ")", ")", ";", "return", "[", "0", "]", ";", "}" ]
Sign out. @note Using _GET is enough for this operation.
[ "Sign", "out", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStore.php#L103-L121
6,526
bfitech/zapmin
src/AdminStore.php
AdminStore.adm_change_bio
public function adm_change_bio($args) { if (!$this->store_is_logged_in()) return [AdminStoreError::USER_NOT_LOGGED_IN]; if (!isset($args['post'])) return [AdminStoreError::DATA_INCOMPLETE]; $post = $args['post']; $vars = []; foreach (['fname', 'site'] as $key) { if (!isset($post[$key])) continue; $val = trim($post[$key]); if (!$val) continue; $vars[$key] = $val; } if (!$vars) # no change return [0]; extract($vars); # verify site url value if (isset($site) && !self::verify_site_url($site)) { $this->logger->warning( "Zapmin: chbio: site URL invalid: '$site'."); return [AdminStoreError::SITEURL_INVALID]; } $this->store->update('udata', $vars, [ 'uid' => $this->user_data['uid'] ]); # also update redis cache $expire = $this->store->stmt_fragment('datetime'); $session = $this->store->query( sprintf( "SELECT * FROM v_usess " . "WHERE token=? AND expire>%s " . "LIMIT 1", $expire ), [$this->user_token]); # update cache value $updated_data = array_merge($this->user_data, $vars); if ($session) $this->store_redis_cache_write($this->user_token, $updated_data, $session['expire']); # reset user data but not user token $this->user_data = null; $this->adm_status(); # ok $this->logger->info(sprintf( "Zapmin: chbio: OK: '%s'.", $this->user_data['uname'] )); return [0]; }
php
public function adm_change_bio($args) { if (!$this->store_is_logged_in()) return [AdminStoreError::USER_NOT_LOGGED_IN]; if (!isset($args['post'])) return [AdminStoreError::DATA_INCOMPLETE]; $post = $args['post']; $vars = []; foreach (['fname', 'site'] as $key) { if (!isset($post[$key])) continue; $val = trim($post[$key]); if (!$val) continue; $vars[$key] = $val; } if (!$vars) # no change return [0]; extract($vars); # verify site url value if (isset($site) && !self::verify_site_url($site)) { $this->logger->warning( "Zapmin: chbio: site URL invalid: '$site'."); return [AdminStoreError::SITEURL_INVALID]; } $this->store->update('udata', $vars, [ 'uid' => $this->user_data['uid'] ]); # also update redis cache $expire = $this->store->stmt_fragment('datetime'); $session = $this->store->query( sprintf( "SELECT * FROM v_usess " . "WHERE token=? AND expire>%s " . "LIMIT 1", $expire ), [$this->user_token]); # update cache value $updated_data = array_merge($this->user_data, $vars); if ($session) $this->store_redis_cache_write($this->user_token, $updated_data, $session['expire']); # reset user data but not user token $this->user_data = null; $this->adm_status(); # ok $this->logger->info(sprintf( "Zapmin: chbio: OK: '%s'.", $this->user_data['uname'] )); return [0]; }
[ "public", "function", "adm_change_bio", "(", "$", "args", ")", "{", "if", "(", "!", "$", "this", "->", "store_is_logged_in", "(", ")", ")", "return", "[", "AdminStoreError", "::", "USER_NOT_LOGGED_IN", "]", ";", "if", "(", "!", "isset", "(", "$", "args", "[", "'post'", "]", ")", ")", "return", "[", "AdminStoreError", "::", "DATA_INCOMPLETE", "]", ";", "$", "post", "=", "$", "args", "[", "'post'", "]", ";", "$", "vars", "=", "[", "]", ";", "foreach", "(", "[", "'fname'", ",", "'site'", "]", "as", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "post", "[", "$", "key", "]", ")", ")", "continue", ";", "$", "val", "=", "trim", "(", "$", "post", "[", "$", "key", "]", ")", ";", "if", "(", "!", "$", "val", ")", "continue", ";", "$", "vars", "[", "$", "key", "]", "=", "$", "val", ";", "}", "if", "(", "!", "$", "vars", ")", "# no change", "return", "[", "0", "]", ";", "extract", "(", "$", "vars", ")", ";", "# verify site url value", "if", "(", "isset", "(", "$", "site", ")", "&&", "!", "self", "::", "verify_site_url", "(", "$", "site", ")", ")", "{", "$", "this", "->", "logger", "->", "warning", "(", "\"Zapmin: chbio: site URL invalid: '$site'.\"", ")", ";", "return", "[", "AdminStoreError", "::", "SITEURL_INVALID", "]", ";", "}", "$", "this", "->", "store", "->", "update", "(", "'udata'", ",", "$", "vars", ",", "[", "'uid'", "=>", "$", "this", "->", "user_data", "[", "'uid'", "]", "]", ")", ";", "# also update redis cache", "$", "expire", "=", "$", "this", "->", "store", "->", "stmt_fragment", "(", "'datetime'", ")", ";", "$", "session", "=", "$", "this", "->", "store", "->", "query", "(", "sprintf", "(", "\"SELECT * FROM v_usess \"", ".", "\"WHERE token=? AND expire>%s \"", ".", "\"LIMIT 1\"", ",", "$", "expire", ")", ",", "[", "$", "this", "->", "user_token", "]", ")", ";", "# update cache value", "$", "updated_data", "=", "array_merge", "(", "$", "this", "->", "user_data", ",", "$", "vars", ")", ";", "if", "(", "$", "session", ")", "$", "this", "->", "store_redis_cache_write", "(", "$", "this", "->", "user_token", ",", "$", "updated_data", ",", "$", "session", "[", "'expire'", "]", ")", ";", "# reset user data but not user token", "$", "this", "->", "user_data", "=", "null", ";", "$", "this", "->", "adm_status", "(", ")", ";", "# ok", "$", "this", "->", "logger", "->", "info", "(", "sprintf", "(", "\"Zapmin: chbio: OK: '%s'.\"", ",", "$", "this", "->", "user_data", "[", "'uname'", "]", ")", ")", ";", "return", "[", "0", "]", ";", "}" ]
Change user info. @param array $args Dict with keys: `fname`, `site`. @manonly @SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity) @endmanonly
[ "Change", "user", "info", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStore.php#L204-L262
6,527
bfitech/zapmin
src/AdminStore.php
AdminStore._add_user_verify_name
private function _add_user_verify_name($addname) { $logger = $this->logger; # check name, allow multi-byte chars but not whitespace if (strlen($addname) > 64) { # max 64 chars $logger->warning( "Zapmin: usradd: name invalid: '$addname'."); return AdminStoreError::USERNAME_TOO_LONG; } foreach([" ", "\n", "\r", "\t"] as $white) { # never allow whitespace in the middle if (strpos($addname, $white) !== false) { $logger->warning( "Zapmin: usradd: name invalid: '$addname'."); return AdminStoreError::USERNAME_HAS_WHITESPACE; } } if ($addname[0] == '+') { # leading '+' is reserved for passwordless accounts $logger->warning( "Zapmin: usradd: name invalid: '$addname'."); return AdminStoreError::USERNAME_LEADING_PLUS; } return 0; }
php
private function _add_user_verify_name($addname) { $logger = $this->logger; # check name, allow multi-byte chars but not whitespace if (strlen($addname) > 64) { # max 64 chars $logger->warning( "Zapmin: usradd: name invalid: '$addname'."); return AdminStoreError::USERNAME_TOO_LONG; } foreach([" ", "\n", "\r", "\t"] as $white) { # never allow whitespace in the middle if (strpos($addname, $white) !== false) { $logger->warning( "Zapmin: usradd: name invalid: '$addname'."); return AdminStoreError::USERNAME_HAS_WHITESPACE; } } if ($addname[0] == '+') { # leading '+' is reserved for passwordless accounts $logger->warning( "Zapmin: usradd: name invalid: '$addname'."); return AdminStoreError::USERNAME_LEADING_PLUS; } return 0; }
[ "private", "function", "_add_user_verify_name", "(", "$", "addname", ")", "{", "$", "logger", "=", "$", "this", "->", "logger", ";", "# check name, allow multi-byte chars but not whitespace", "if", "(", "strlen", "(", "$", "addname", ")", ">", "64", ")", "{", "# max 64 chars", "$", "logger", "->", "warning", "(", "\"Zapmin: usradd: name invalid: '$addname'.\"", ")", ";", "return", "AdminStoreError", "::", "USERNAME_TOO_LONG", ";", "}", "foreach", "(", "[", "\" \"", ",", "\"\\n\"", ",", "\"\\r\"", ",", "\"\\t\"", "]", "as", "$", "white", ")", "{", "# never allow whitespace in the middle", "if", "(", "strpos", "(", "$", "addname", ",", "$", "white", ")", "!==", "false", ")", "{", "$", "logger", "->", "warning", "(", "\"Zapmin: usradd: name invalid: '$addname'.\"", ")", ";", "return", "AdminStoreError", "::", "USERNAME_HAS_WHITESPACE", ";", "}", "}", "if", "(", "$", "addname", "[", "0", "]", "==", "'+'", ")", "{", "# leading '+' is reserved for passwordless accounts", "$", "logger", "->", "warning", "(", "\"Zapmin: usradd: name invalid: '$addname'.\"", ")", ";", "return", "AdminStoreError", "::", "USERNAME_LEADING_PLUS", ";", "}", "return", "0", ";", "}" ]
Verify username of new user.
[ "Verify", "username", "of", "new", "user", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStore.php#L276-L302
6,528
bfitech/zapmin
src/AdminStore.php
AdminStore._add_user_verify_email
private function _add_user_verify_email($email, $addname) { $logger = $this->logger; if (!self::verify_email_address($email)) { $logger->warning(sprintf( "Zapmin: usradd: email invalid: '%s' <- '%s'.", $addname, $email)); return AdminStoreError::EMAIL_INVALID; } if ($this->store->query( "SELECT uid FROM udata WHERE email=? LIMIT 1", [$email]) ) { $logger->warning(sprintf( "Zapmin: usradd: email exists: '%s' <- '%s'.", $addname, $email)); return AdminStoreError::EMAIL_EXISTS; } return 0; }
php
private function _add_user_verify_email($email, $addname) { $logger = $this->logger; if (!self::verify_email_address($email)) { $logger->warning(sprintf( "Zapmin: usradd: email invalid: '%s' <- '%s'.", $addname, $email)); return AdminStoreError::EMAIL_INVALID; } if ($this->store->query( "SELECT uid FROM udata WHERE email=? LIMIT 1", [$email]) ) { $logger->warning(sprintf( "Zapmin: usradd: email exists: '%s' <- '%s'.", $addname, $email)); return AdminStoreError::EMAIL_EXISTS; } return 0; }
[ "private", "function", "_add_user_verify_email", "(", "$", "email", ",", "$", "addname", ")", "{", "$", "logger", "=", "$", "this", "->", "logger", ";", "if", "(", "!", "self", "::", "verify_email_address", "(", "$", "email", ")", ")", "{", "$", "logger", "->", "warning", "(", "sprintf", "(", "\"Zapmin: usradd: email invalid: '%s' <- '%s'.\"", ",", "$", "addname", ",", "$", "email", ")", ")", ";", "return", "AdminStoreError", "::", "EMAIL_INVALID", ";", "}", "if", "(", "$", "this", "->", "store", "->", "query", "(", "\"SELECT uid FROM udata WHERE email=? LIMIT 1\"", ",", "[", "$", "email", "]", ")", ")", "{", "$", "logger", "->", "warning", "(", "sprintf", "(", "\"Zapmin: usradd: email exists: '%s' <- '%s'.\"", ",", "$", "addname", ",", "$", "email", ")", ")", ";", "return", "AdminStoreError", "::", "EMAIL_EXISTS", ";", "}", "return", "0", ";", "}" ]
Verify email of new user.
[ "Verify", "email", "of", "new", "user", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStore.php#L307-L328
6,529
bfitech/zapmin
src/AdminStore.php
AdminStore.adm_self_add_user
public function adm_self_add_user( $args, $pass_twice=null, $email_required=null ) { if ($this->store_is_logged_in()) return [AdminStoreError::USER_ALREADY_LOGGED_IN]; return $this->adm_add_user( $args, $pass_twice, true, $email_required); }
php
public function adm_self_add_user( $args, $pass_twice=null, $email_required=null ) { if ($this->store_is_logged_in()) return [AdminStoreError::USER_ALREADY_LOGGED_IN]; return $this->adm_add_user( $args, $pass_twice, true, $email_required); }
[ "public", "function", "adm_self_add_user", "(", "$", "args", ",", "$", "pass_twice", "=", "null", ",", "$", "email_required", "=", "null", ")", "{", "if", "(", "$", "this", "->", "store_is_logged_in", "(", ")", ")", "return", "[", "AdminStoreError", "::", "USER_ALREADY_LOGGED_IN", "]", ";", "return", "$", "this", "->", "adm_add_user", "(", "$", "args", ",", "$", "pass_twice", ",", "true", ",", "$", "email_required", ")", ";", "}" ]
Self-register. @note This is just a special case of adm_add_user() with additional condition: user must not be authenticated. @param array $args Dict with keys: `addname`, `addpass1`, and optional `addpass2` unless `$pass_twice` is set to true. @param bool $pass_twice Whether password must be entered twice. @param bool $email_required Whether an email address must be provided.
[ "Self", "-", "register", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStore.php#L433-L440
6,530
bfitech/zapmin
src/AdminStore.php
AdminStore.adm_self_add_user_passwordless
public function adm_self_add_user_passwordless($args) { if ($this->store_is_logged_in()) return [AdminStoreError::USER_ALREADY_LOGGED_IN]; # check vars if (!isset($args['service'])) return [AdminStoreError::DATA_INCOMPLETE]; $uname = $uservice = null; $service = Common::check_idict($args['service'], ['uname', 'uservice']); if (!$service) return [AdminStoreError::DATA_INCOMPLETE]; extract($service); $dbuname = '+' . $uname . ':' . $uservice; $check = $this->store->query( "SELECT uid FROM udata WHERE uname=? LIMIT 1", [$dbuname]); $uid = $check ? $check['uid'] : $this->store->insert("udata", [ 'uname' => $dbuname, ], 'uid'); # token generation is a little different $token = $this->generate_secret( $dbuname . uniqid(), $uname); # explicitly use byway expiration, default column value # is strictly for standard expiration $date_expire = $this->store->query( sprintf( "SELECT %s AS date_expire", $this->store->stmt_fragment( 'datetime', ['delta' => $this->byway_expiration]) ) )['date_expire']; # insert $sid = $this->store->insert('usess', [ 'uid' => $uid, 'token' => $token, 'expire' => $date_expire, ], 'sid'); # use token for next request $this->logger->info("Zapmin: usradd: OK: $uid:'$dbuname'."); return [0, [ 'uid' => $uid, 'uname' => $dbuname, 'token' => $token, 'sid' => $sid, ]]; }
php
public function adm_self_add_user_passwordless($args) { if ($this->store_is_logged_in()) return [AdminStoreError::USER_ALREADY_LOGGED_IN]; # check vars if (!isset($args['service'])) return [AdminStoreError::DATA_INCOMPLETE]; $uname = $uservice = null; $service = Common::check_idict($args['service'], ['uname', 'uservice']); if (!$service) return [AdminStoreError::DATA_INCOMPLETE]; extract($service); $dbuname = '+' . $uname . ':' . $uservice; $check = $this->store->query( "SELECT uid FROM udata WHERE uname=? LIMIT 1", [$dbuname]); $uid = $check ? $check['uid'] : $this->store->insert("udata", [ 'uname' => $dbuname, ], 'uid'); # token generation is a little different $token = $this->generate_secret( $dbuname . uniqid(), $uname); # explicitly use byway expiration, default column value # is strictly for standard expiration $date_expire = $this->store->query( sprintf( "SELECT %s AS date_expire", $this->store->stmt_fragment( 'datetime', ['delta' => $this->byway_expiration]) ) )['date_expire']; # insert $sid = $this->store->insert('usess', [ 'uid' => $uid, 'token' => $token, 'expire' => $date_expire, ], 'sid'); # use token for next request $this->logger->info("Zapmin: usradd: OK: $uid:'$dbuname'."); return [0, [ 'uid' => $uid, 'uname' => $dbuname, 'token' => $token, 'sid' => $sid, ]]; }
[ "public", "function", "adm_self_add_user_passwordless", "(", "$", "args", ")", "{", "if", "(", "$", "this", "->", "store_is_logged_in", "(", ")", ")", "return", "[", "AdminStoreError", "::", "USER_ALREADY_LOGGED_IN", "]", ";", "# check vars", "if", "(", "!", "isset", "(", "$", "args", "[", "'service'", "]", ")", ")", "return", "[", "AdminStoreError", "::", "DATA_INCOMPLETE", "]", ";", "$", "uname", "=", "$", "uservice", "=", "null", ";", "$", "service", "=", "Common", "::", "check_idict", "(", "$", "args", "[", "'service'", "]", ",", "[", "'uname'", ",", "'uservice'", "]", ")", ";", "if", "(", "!", "$", "service", ")", "return", "[", "AdminStoreError", "::", "DATA_INCOMPLETE", "]", ";", "extract", "(", "$", "service", ")", ";", "$", "dbuname", "=", "'+'", ".", "$", "uname", ".", "':'", ".", "$", "uservice", ";", "$", "check", "=", "$", "this", "->", "store", "->", "query", "(", "\"SELECT uid FROM udata WHERE uname=? LIMIT 1\"", ",", "[", "$", "dbuname", "]", ")", ";", "$", "uid", "=", "$", "check", "?", "$", "check", "[", "'uid'", "]", ":", "$", "this", "->", "store", "->", "insert", "(", "\"udata\"", ",", "[", "'uname'", "=>", "$", "dbuname", ",", "]", ",", "'uid'", ")", ";", "# token generation is a little different", "$", "token", "=", "$", "this", "->", "generate_secret", "(", "$", "dbuname", ".", "uniqid", "(", ")", ",", "$", "uname", ")", ";", "# explicitly use byway expiration, default column value", "# is strictly for standard expiration", "$", "date_expire", "=", "$", "this", "->", "store", "->", "query", "(", "sprintf", "(", "\"SELECT %s AS date_expire\"", ",", "$", "this", "->", "store", "->", "stmt_fragment", "(", "'datetime'", ",", "[", "'delta'", "=>", "$", "this", "->", "byway_expiration", "]", ")", ")", ")", "[", "'date_expire'", "]", ";", "# insert", "$", "sid", "=", "$", "this", "->", "store", "->", "insert", "(", "'usess'", ",", "[", "'uid'", "=>", "$", "uid", ",", "'token'", "=>", "$", "token", ",", "'expire'", "=>", "$", "date_expire", ",", "]", ",", "'sid'", ")", ";", "# use token for next request", "$", "this", "->", "logger", "->", "info", "(", "\"Zapmin: usradd: OK: $uid:'$dbuname'.\"", ")", ";", "return", "[", "0", ",", "[", "'uid'", "=>", "$", "uid", ",", "'uname'", "=>", "$", "dbuname", ",", "'token'", "=>", "$", "token", ",", "'sid'", "=>", "$", "sid", ",", "]", "]", ";", "}" ]
Passwordless self-registration. This byway registration doesn't differ sign in and sign up. Use this with caution, e.g. with proper authentication via OAuth*, SMTP or the like. Unlike add user with password, this also returns `sid` to associate `session.sid` with a column on different table. @param array $args Dict of the form: @code (dict){ 'service': (dict){ 'uname': (string uname), 'uservice': (string uservice) } } @endcode @return array An array of the form: @code (array)[ (int errno), (dict){ 'uid': (int uid), 'uname': (string uname), 'token': (string token) 'sid': (int sid), } ] @endcode
[ "Passwordless", "self", "-", "registration", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStore.php#L474-L528
6,531
bfitech/zapmin
src/AdminStore.php
AdminStore.authz_delete_user
public function authz_delete_user($uid) { $udata = $this->user_data; if ($udata['uid'] == 1 && $uid != 1) return true; if ($udata['uid'] == $uid) return true; return false; }
php
public function authz_delete_user($uid) { $udata = $this->user_data; if ($udata['uid'] == 1 && $uid != 1) return true; if ($udata['uid'] == $uid) return true; return false; }
[ "public", "function", "authz_delete_user", "(", "$", "uid", ")", "{", "$", "udata", "=", "$", "this", "->", "user_data", ";", "if", "(", "$", "udata", "[", "'uid'", "]", "==", "1", "&&", "$", "uid", "!=", "1", ")", "return", "true", ";", "if", "(", "$", "udata", "[", "'uid'", "]", "==", "$", "uid", ")", "return", "true", ";", "return", "false", ";", "}" ]
Default method to decide if user deletion is allowed. This succeeds if current user is root, or if it's a case of self-deletion for non-root user. @param int $uid User ID to delete.
[ "Default", "method", "to", "decide", "if", "user", "deletion", "is", "allowed", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStore.php#L538-L545
6,532
bfitech/zapmin
src/AdminStore.php
AdminStore.adm_list_user
public function adm_list_user($args) { $this->init(); if (!$this->store_is_logged_in()) return [AdminStoreError::USER_NOT_LOGGED_IN]; if (!$this->authz_list_user()) return [AdminStoreError::USER_NOT_AUTHORIZED]; extract($args['post']); $page = isset($page) ? (int)$page : 0; if ($page < 0) $page = 0; $limit = isset($limit) ? (int)$limit : 10; if ($limit <= 0 || $limit >= 40) $limit = 10; $offset = $page * $limit; if (!isset($order) || !in_array($order, ['ASC', 'DESC'])) $order = ''; // @note MySQL doesn't support '?' placeholder for limit and // offset. $stmt = sprintf( "SELECT uid, uname, fname, site, since " . "FROM udata ORDER BY uid %s LIMIT %s OFFSET %s", $order, $limit, $offset); return [0, $this->store->query($stmt, [], true)]; }
php
public function adm_list_user($args) { $this->init(); if (!$this->store_is_logged_in()) return [AdminStoreError::USER_NOT_LOGGED_IN]; if (!$this->authz_list_user()) return [AdminStoreError::USER_NOT_AUTHORIZED]; extract($args['post']); $page = isset($page) ? (int)$page : 0; if ($page < 0) $page = 0; $limit = isset($limit) ? (int)$limit : 10; if ($limit <= 0 || $limit >= 40) $limit = 10; $offset = $page * $limit; if (!isset($order) || !in_array($order, ['ASC', 'DESC'])) $order = ''; // @note MySQL doesn't support '?' placeholder for limit and // offset. $stmt = sprintf( "SELECT uid, uname, fname, site, since " . "FROM udata ORDER BY uid %s LIMIT %s OFFSET %s", $order, $limit, $offset); return [0, $this->store->query($stmt, [], true)]; }
[ "public", "function", "adm_list_user", "(", "$", "args", ")", "{", "$", "this", "->", "init", "(", ")", ";", "if", "(", "!", "$", "this", "->", "store_is_logged_in", "(", ")", ")", "return", "[", "AdminStoreError", "::", "USER_NOT_LOGGED_IN", "]", ";", "if", "(", "!", "$", "this", "->", "authz_list_user", "(", ")", ")", "return", "[", "AdminStoreError", "::", "USER_NOT_AUTHORIZED", "]", ";", "extract", "(", "$", "args", "[", "'post'", "]", ")", ";", "$", "page", "=", "isset", "(", "$", "page", ")", "?", "(", "int", ")", "$", "page", ":", "0", ";", "if", "(", "$", "page", "<", "0", ")", "$", "page", "=", "0", ";", "$", "limit", "=", "isset", "(", "$", "limit", ")", "?", "(", "int", ")", "$", "limit", ":", "10", ";", "if", "(", "$", "limit", "<=", "0", "||", "$", "limit", ">=", "40", ")", "$", "limit", "=", "10", ";", "$", "offset", "=", "$", "page", "*", "$", "limit", ";", "if", "(", "!", "isset", "(", "$", "order", ")", "||", "!", "in_array", "(", "$", "order", ",", "[", "'ASC'", ",", "'DESC'", "]", ")", ")", "$", "order", "=", "''", ";", "// @note MySQL doesn't support '?' placeholder for limit and", "// offset.", "$", "stmt", "=", "sprintf", "(", "\"SELECT uid, uname, fname, site, since \"", ".", "\"FROM udata ORDER BY uid %s LIMIT %s OFFSET %s\"", ",", "$", "order", ",", "$", "limit", ",", "$", "offset", ")", ";", "return", "[", "0", ",", "$", "this", "->", "store", "->", "query", "(", "$", "stmt", ",", "[", "]", ",", "true", ")", "]", ";", "}" ]
List all users. @param array $args Dict with keys: `page`, `limit`, `order` where `order` is `ASC` or `DESC`. @manonly @SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity) @endmanonly
[ "List", "all", "users", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStore.php#L614-L646
6,533
edunola13/enolaphp-framework
src/Support/View.php
View.urlFor
function urlFor($internalUri, $locale = NULL){ $internalUri= ltrim($internalUri, '/'); if($locale == NULL)return $this->request->realBaseUrl . $internalUri; else return $this->request->realBaseUrl . $locale . '/' . $internalUri; }
php
function urlFor($internalUri, $locale = NULL){ $internalUri= ltrim($internalUri, '/'); if($locale == NULL)return $this->request->realBaseUrl . $internalUri; else return $this->request->realBaseUrl . $locale . '/' . $internalUri; }
[ "function", "urlFor", "(", "$", "internalUri", ",", "$", "locale", "=", "NULL", ")", "{", "$", "internalUri", "=", "ltrim", "(", "$", "internalUri", ",", "'/'", ")", ";", "if", "(", "$", "locale", "==", "NULL", ")", "return", "$", "this", "->", "request", "->", "realBaseUrl", ".", "$", "internalUri", ";", "else", "return", "$", "this", "->", "request", "->", "realBaseUrl", ".", "$", "locale", ".", "'/'", ".", "$", "internalUri", ";", "}" ]
Arma una url para una URI interna @param type $internalUri @param type $locale @return string
[ "Arma", "una", "url", "para", "una", "URI", "interna" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Support/View.php#L79-L83
6,534
edunola13/enolaphp-framework
src/Support/View.php
View.i18n
function i18n($file, $locale = NULL){ $this->fileName= $file; $this->i18nContent= NULL; if($locale != NULL){ if(file_exists(PATHAPP . 'src/content/' . $file . "_$locale" . '.txt')){ $this->i18nContent= \E_fn\load_application_file('src/content/' . $file . "_$locale" . '.txt'); $this->i18nContent= \E_fn\parse_properties($this->i18nContent); $this->locale= $locale; } } if($this->i18nContent == NULL){ $this->i18nContent= \E_fn\load_application_file('src/content/' . $file . '.txt'); $this->i18nContent= \E_fn\parse_properties($this->i18nContent); $this->locale= 'Default'; } }
php
function i18n($file, $locale = NULL){ $this->fileName= $file; $this->i18nContent= NULL; if($locale != NULL){ if(file_exists(PATHAPP . 'src/content/' . $file . "_$locale" . '.txt')){ $this->i18nContent= \E_fn\load_application_file('src/content/' . $file . "_$locale" . '.txt'); $this->i18nContent= \E_fn\parse_properties($this->i18nContent); $this->locale= $locale; } } if($this->i18nContent == NULL){ $this->i18nContent= \E_fn\load_application_file('src/content/' . $file . '.txt'); $this->i18nContent= \E_fn\parse_properties($this->i18nContent); $this->locale= 'Default'; } }
[ "function", "i18n", "(", "$", "file", ",", "$", "locale", "=", "NULL", ")", "{", "$", "this", "->", "fileName", "=", "$", "file", ";", "$", "this", "->", "i18nContent", "=", "NULL", ";", "if", "(", "$", "locale", "!=", "NULL", ")", "{", "if", "(", "file_exists", "(", "PATHAPP", ".", "'src/content/'", ".", "$", "file", ".", "\"_$locale\"", ".", "'.txt'", ")", ")", "{", "$", "this", "->", "i18nContent", "=", "\\", "E_fn", "\\", "load_application_file", "(", "'src/content/'", ".", "$", "file", ".", "\"_$locale\"", ".", "'.txt'", ")", ";", "$", "this", "->", "i18nContent", "=", "\\", "E_fn", "\\", "parse_properties", "(", "$", "this", "->", "i18nContent", ")", ";", "$", "this", "->", "locale", "=", "$", "locale", ";", "}", "}", "if", "(", "$", "this", "->", "i18nContent", "==", "NULL", ")", "{", "$", "this", "->", "i18nContent", "=", "\\", "E_fn", "\\", "load_application_file", "(", "'src/content/'", ".", "$", "file", ".", "'.txt'", ")", ";", "$", "this", "->", "i18nContent", "=", "\\", "E_fn", "\\", "parse_properties", "(", "$", "this", "->", "i18nContent", ")", ";", "$", "this", "->", "locale", "=", "'Default'", ";", "}", "}" ]
Carga un archivo de internacionalizacion. Si no se especifica el locale carga el archivo por defecto, si no le agrega el locale pasado como parametro @param string $file @param string $locale
[ "Carga", "un", "archivo", "de", "internacionalizacion", ".", "Si", "no", "se", "especifica", "el", "locale", "carga", "el", "archivo", "por", "defecto", "si", "no", "le", "agrega", "el", "locale", "pasado", "como", "parametro" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Support/View.php#L132-L147
6,535
edunola13/enolaphp-framework
src/Support/View.php
View.i18n_change_locale
function i18n_change_locale($locale){ if(isset($this->fileName)){ i18n($this->fileName, $locale); } else{ \Enola\Error::general_error('I18n Error', 'Before call i18n_change_locale is necesary call i18n'); } }
php
function i18n_change_locale($locale){ if(isset($this->fileName)){ i18n($this->fileName, $locale); } else{ \Enola\Error::general_error('I18n Error', 'Before call i18n_change_locale is necesary call i18n'); } }
[ "function", "i18n_change_locale", "(", "$", "locale", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "fileName", ")", ")", "{", "i18n", "(", "$", "this", "->", "fileName", ",", "$", "locale", ")", ";", "}", "else", "{", "\\", "Enola", "\\", "Error", "::", "general_error", "(", "'I18n Error'", ",", "'Before call i18n_change_locale is necesary call i18n'", ")", ";", "}", "}" ]
Cambia el archivo de internacionalizacion cargado. Lo cambia segun el locale pasado @param string $locale
[ "Cambia", "el", "archivo", "de", "internacionalizacion", "cargado", ".", "Lo", "cambia", "segun", "el", "locale", "pasado" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Support/View.php#L152-L159
6,536
edunola13/enolaphp-framework
src/Support/View.php
View.i18n_value
function i18n_value($val_key, $params = NULL){ if(isset($this->i18nContent)){ if(isset($this->i18nContent[$val_key])){ $mensaje= $this->i18nContent[$val_key]; //Analiza si se pasaron parametros y si se pasaron cambia los valores correspondientes if($params != NULL){ foreach ($params as $key => $valor) { $mensaje= str_replace(":$key", $valor, $mensaje); } } return $mensaje; } } else{ \Enola\Error::general_error('I18n Error', 'Not specified any I18n file to make it run the i18n function'); } }
php
function i18n_value($val_key, $params = NULL){ if(isset($this->i18nContent)){ if(isset($this->i18nContent[$val_key])){ $mensaje= $this->i18nContent[$val_key]; //Analiza si se pasaron parametros y si se pasaron cambia los valores correspondientes if($params != NULL){ foreach ($params as $key => $valor) { $mensaje= str_replace(":$key", $valor, $mensaje); } } return $mensaje; } } else{ \Enola\Error::general_error('I18n Error', 'Not specified any I18n file to make it run the i18n function'); } }
[ "function", "i18n_value", "(", "$", "val_key", ",", "$", "params", "=", "NULL", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "i18nContent", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "i18nContent", "[", "$", "val_key", "]", ")", ")", "{", "$", "mensaje", "=", "$", "this", "->", "i18nContent", "[", "$", "val_key", "]", ";", "//Analiza si se pasaron parametros y si se pasaron cambia los valores correspondientes", "if", "(", "$", "params", "!=", "NULL", ")", "{", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "valor", ")", "{", "$", "mensaje", "=", "str_replace", "(", "\":$key\"", ",", "$", "valor", ",", "$", "mensaje", ")", ";", "}", "}", "return", "$", "mensaje", ";", "}", "}", "else", "{", "\\", "Enola", "\\", "Error", "::", "general_error", "(", "'I18n Error'", ",", "'Not specified any I18n file to make it run the i18n function'", ")", ";", "}", "}" ]
Devuelve el valor segun el archivo de internacionalizacion que se encuentre cargado @param string $val_key @param array $params @return string
[ "Devuelve", "el", "valor", "segun", "el", "archivo", "de", "internacionalizacion", "que", "se", "encuentre", "cargado" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Support/View.php#L166-L183
6,537
vinala/kernel
src/Atomium/Compiler/AtomiumCompileInstruction.php
AtomiumCompileInstruction.openTag
public static function openTag($script, $openTag, $phpOpenTag, $endOpenTag, $phpEndOpenTag) { $data = Strings::splite($script, $openTag); // $output = $data[0]; // for ($i = 1; $i < Collection::count($data); $i++) { $output .= $phpOpenTag; // $next = Strings::splite($data[$i], $endOpenTag); $output .= $next[0].$phpEndOpenTag; // for ($j = 1; $j < Collection::count($next); $j++) { if ($j == (Collection::count($next) - 1)) { $output .= $next[$j]; } else { $output .= $next[$j].$endOpenTag; } } } return $output; }
php
public static function openTag($script, $openTag, $phpOpenTag, $endOpenTag, $phpEndOpenTag) { $data = Strings::splite($script, $openTag); // $output = $data[0]; // for ($i = 1; $i < Collection::count($data); $i++) { $output .= $phpOpenTag; // $next = Strings::splite($data[$i], $endOpenTag); $output .= $next[0].$phpEndOpenTag; // for ($j = 1; $j < Collection::count($next); $j++) { if ($j == (Collection::count($next) - 1)) { $output .= $next[$j]; } else { $output .= $next[$j].$endOpenTag; } } } return $output; }
[ "public", "static", "function", "openTag", "(", "$", "script", ",", "$", "openTag", ",", "$", "phpOpenTag", ",", "$", "endOpenTag", ",", "$", "phpEndOpenTag", ")", "{", "$", "data", "=", "Strings", "::", "splite", "(", "$", "script", ",", "$", "openTag", ")", ";", "//", "$", "output", "=", "$", "data", "[", "0", "]", ";", "//", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "Collection", "::", "count", "(", "$", "data", ")", ";", "$", "i", "++", ")", "{", "$", "output", ".=", "$", "phpOpenTag", ";", "//", "$", "next", "=", "Strings", "::", "splite", "(", "$", "data", "[", "$", "i", "]", ",", "$", "endOpenTag", ")", ";", "$", "output", ".=", "$", "next", "[", "0", "]", ".", "$", "phpEndOpenTag", ";", "//", "for", "(", "$", "j", "=", "1", ";", "$", "j", "<", "Collection", "::", "count", "(", "$", "next", ")", ";", "$", "j", "++", ")", "{", "if", "(", "$", "j", "==", "(", "Collection", "::", "count", "(", "$", "next", ")", "-", "1", ")", ")", "{", "$", "output", ".=", "$", "next", "[", "$", "j", "]", ";", "}", "else", "{", "$", "output", ".=", "$", "next", "[", "$", "j", "]", ".", "$", "endOpenTag", ";", "}", "}", "}", "return", "$", "output", ";", "}" ]
To replace open tag end it's end with PHP tag. @var string
[ "To", "replace", "open", "tag", "end", "it", "s", "end", "with", "PHP", "tag", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Atomium/Compiler/AtomiumCompileInstruction.php#L15-L37
6,538
morrelinko/simple-photo
src/Toolbox/ArrayUtils.php
ArrayUtils.hasKeys
public static function hasKeys(array $haystack) { $fails = false; $keys = func_get_args(); array_shift($keys); foreach ($keys as $key) { if (!array_key_exists($key, $haystack)) { $fails = true; break; } } return !$fails; }
php
public static function hasKeys(array $haystack) { $fails = false; $keys = func_get_args(); array_shift($keys); foreach ($keys as $key) { if (!array_key_exists($key, $haystack)) { $fails = true; break; } } return !$fails; }
[ "public", "static", "function", "hasKeys", "(", "array", "$", "haystack", ")", "{", "$", "fails", "=", "false", ";", "$", "keys", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "keys", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "haystack", ")", ")", "{", "$", "fails", "=", "true", ";", "break", ";", "}", "}", "return", "!", "$", "fails", ";", "}" ]
Ensures that specified keys exists in the array @param array $haystack @return bool
[ "Ensures", "that", "specified", "keys", "exists", "in", "the", "array" ]
be1fbe3139d32eb39e88cff93f847154bb6a8cb2
https://github.com/morrelinko/simple-photo/blob/be1fbe3139d32eb39e88cff93f847154bb6a8cb2/src/Toolbox/ArrayUtils.php#L34-L48
6,539
2upmedia/hooky
src/HooksTrait.php
HooksTrait.checkCallable
private static function checkCallable( $classInstance, callable $callable, $method = null ) { // if there are args and debug mode is on if ($method && self::$checkCallableParameters) { $originalMethodReflection = new \ReflectionMethod($classInstance, $method); if ($originalMethodReflection->getNumberOfParameters() === 0) { return; } $originalMethodReflectionParameters = $originalMethodReflection->getParameters(); if (is_array($callable)) { $callableReflection = new \ReflectionMethod($callable[0], $callable[1]); $callableReflectionParameters = $callableReflection->getParameters(); } elseif ($callable instanceof \Closure) { $callableReflection = new \ReflectionFunction($callable); $callableReflectionParameters = $callableReflection->getParameters(); } $originalParameters = self::getReflectionParameters($originalMethodReflectionParameters); $callableParameters = self::getReflectionParameters($callableReflectionParameters); $parameterOffset = 0; // remove default parameters if ($method && $callableParameters && $callable instanceof \Closure === false) { $callableParameters = array_slice($callableParameters, 1); $parameterOffset = 1; } /** * [ * 0 => [ * 'original' => 'resourceLocation' * 'callable' => 'uri' * 'dirty' => true * ], * * 1 => [ * 'original' => 'message' * 'callable' => null * 'missing' => true */ $parameterMeta = array_map( function ($originalParameter, $callableParameter) { return ['original' => $originalParameter, 'callable' => $callableParameter]; }, $originalParameters, $callableParameters ); $parameterDiff = array_filter( $parameterMeta, function ($item) { return $item['original'] !== $item['callable']; } ); // remove matching fields, preserves keys if ($parameterDiff) { self::findParameterIssues( $method, $callableParameters, $parameterDiff, $parameterOffset ); } } }
php
private static function checkCallable( $classInstance, callable $callable, $method = null ) { // if there are args and debug mode is on if ($method && self::$checkCallableParameters) { $originalMethodReflection = new \ReflectionMethod($classInstance, $method); if ($originalMethodReflection->getNumberOfParameters() === 0) { return; } $originalMethodReflectionParameters = $originalMethodReflection->getParameters(); if (is_array($callable)) { $callableReflection = new \ReflectionMethod($callable[0], $callable[1]); $callableReflectionParameters = $callableReflection->getParameters(); } elseif ($callable instanceof \Closure) { $callableReflection = new \ReflectionFunction($callable); $callableReflectionParameters = $callableReflection->getParameters(); } $originalParameters = self::getReflectionParameters($originalMethodReflectionParameters); $callableParameters = self::getReflectionParameters($callableReflectionParameters); $parameterOffset = 0; // remove default parameters if ($method && $callableParameters && $callable instanceof \Closure === false) { $callableParameters = array_slice($callableParameters, 1); $parameterOffset = 1; } /** * [ * 0 => [ * 'original' => 'resourceLocation' * 'callable' => 'uri' * 'dirty' => true * ], * * 1 => [ * 'original' => 'message' * 'callable' => null * 'missing' => true */ $parameterMeta = array_map( function ($originalParameter, $callableParameter) { return ['original' => $originalParameter, 'callable' => $callableParameter]; }, $originalParameters, $callableParameters ); $parameterDiff = array_filter( $parameterMeta, function ($item) { return $item['original'] !== $item['callable']; } ); // remove matching fields, preserves keys if ($parameterDiff) { self::findParameterIssues( $method, $callableParameters, $parameterDiff, $parameterOffset ); } } }
[ "private", "static", "function", "checkCallable", "(", "$", "classInstance", ",", "callable", "$", "callable", ",", "$", "method", "=", "null", ")", "{", "// if there are args and debug mode is on", "if", "(", "$", "method", "&&", "self", "::", "$", "checkCallableParameters", ")", "{", "$", "originalMethodReflection", "=", "new", "\\", "ReflectionMethod", "(", "$", "classInstance", ",", "$", "method", ")", ";", "if", "(", "$", "originalMethodReflection", "->", "getNumberOfParameters", "(", ")", "===", "0", ")", "{", "return", ";", "}", "$", "originalMethodReflectionParameters", "=", "$", "originalMethodReflection", "->", "getParameters", "(", ")", ";", "if", "(", "is_array", "(", "$", "callable", ")", ")", "{", "$", "callableReflection", "=", "new", "\\", "ReflectionMethod", "(", "$", "callable", "[", "0", "]", ",", "$", "callable", "[", "1", "]", ")", ";", "$", "callableReflectionParameters", "=", "$", "callableReflection", "->", "getParameters", "(", ")", ";", "}", "elseif", "(", "$", "callable", "instanceof", "\\", "Closure", ")", "{", "$", "callableReflection", "=", "new", "\\", "ReflectionFunction", "(", "$", "callable", ")", ";", "$", "callableReflectionParameters", "=", "$", "callableReflection", "->", "getParameters", "(", ")", ";", "}", "$", "originalParameters", "=", "self", "::", "getReflectionParameters", "(", "$", "originalMethodReflectionParameters", ")", ";", "$", "callableParameters", "=", "self", "::", "getReflectionParameters", "(", "$", "callableReflectionParameters", ")", ";", "$", "parameterOffset", "=", "0", ";", "// remove default parameters", "if", "(", "$", "method", "&&", "$", "callableParameters", "&&", "$", "callable", "instanceof", "\\", "Closure", "===", "false", ")", "{", "$", "callableParameters", "=", "array_slice", "(", "$", "callableParameters", ",", "1", ")", ";", "$", "parameterOffset", "=", "1", ";", "}", "/**\n * [\n * 0 => [\n * 'original' => 'resourceLocation'\n * 'callable' => 'uri'\n * 'dirty' => true\n * ],\n *\n * 1 => [\n * 'original' => 'message'\n * 'callable' => null\n * 'missing' => true\n */", "$", "parameterMeta", "=", "array_map", "(", "function", "(", "$", "originalParameter", ",", "$", "callableParameter", ")", "{", "return", "[", "'original'", "=>", "$", "originalParameter", ",", "'callable'", "=>", "$", "callableParameter", "]", ";", "}", ",", "$", "originalParameters", ",", "$", "callableParameters", ")", ";", "$", "parameterDiff", "=", "array_filter", "(", "$", "parameterMeta", ",", "function", "(", "$", "item", ")", "{", "return", "$", "item", "[", "'original'", "]", "!==", "$", "item", "[", "'callable'", "]", ";", "}", ")", ";", "// remove matching fields, preserves keys", "if", "(", "$", "parameterDiff", ")", "{", "self", "::", "findParameterIssues", "(", "$", "method", ",", "$", "callableParameters", ",", "$", "parameterDiff", ",", "$", "parameterOffset", ")", ";", "}", "}", "}" ]
Currently checks for mismatching parameters @param object|string $classInstance @param callable $callable @param string $method [optional]
[ "Currently", "checks", "for", "mismatching", "parameters" ]
06a461762492d2daf77b18c7e3fd8cf6d3fbf97b
https://github.com/2upmedia/hooky/blob/06a461762492d2daf77b18c7e3fd8cf6d3fbf97b/src/HooksTrait.php#L823-L898
6,540
nattreid/app-manager
src/Helpers/Files.php
Files.clearCss
public function clearCss(): void { foreach ($this->webLoaderDir as $dir) { if (file_exists($dir)) { foreach (Finder::findFiles('*.css') ->exclude('.htaccess', 'web.config') ->in($dir) as $file) { unlink((string) $file); } } } }
php
public function clearCss(): void { foreach ($this->webLoaderDir as $dir) { if (file_exists($dir)) { foreach (Finder::findFiles('*.css') ->exclude('.htaccess', 'web.config') ->in($dir) as $file) { unlink((string) $file); } } } }
[ "public", "function", "clearCss", "(", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "webLoaderDir", "as", "$", "dir", ")", "{", "if", "(", "file_exists", "(", "$", "dir", ")", ")", "{", "foreach", "(", "Finder", "::", "findFiles", "(", "'*.css'", ")", "->", "exclude", "(", "'.htaccess'", ",", "'web.config'", ")", "->", "in", "(", "$", "dir", ")", "as", "$", "file", ")", "{", "unlink", "(", "(", "string", ")", "$", "file", ")", ";", "}", "}", "}", "}" ]
Smaze CSS cache
[ "Smaze", "CSS", "cache" ]
7821d09a0b3e58ba9c6eb81d44e35aacce55de75
https://github.com/nattreid/app-manager/blob/7821d09a0b3e58ba9c6eb81d44e35aacce55de75/src/Helpers/Files.php#L117-L128
6,541
novuso/system
src/Collection/Chain/SetBucketChain.php
SetBucketChain.current
public function current() { if ($this->current instanceof TerminalBucket) { return null; } /** @var ItemBucket $current */ $current = $this->current; return $current->item(); }
php
public function current() { if ($this->current instanceof TerminalBucket) { return null; } /** @var ItemBucket $current */ $current = $this->current; return $current->item(); }
[ "public", "function", "current", "(", ")", "{", "if", "(", "$", "this", "->", "current", "instanceof", "TerminalBucket", ")", "{", "return", "null", ";", "}", "/** @var ItemBucket $current */", "$", "current", "=", "$", "this", "->", "current", ";", "return", "$", "current", "->", "item", "(", ")", ";", "}" ]
Retrieves the item from the current bucket Returns null if the pointer is not at a valid offset. @return mixed
[ "Retrieves", "the", "item", "from", "the", "current", "bucket" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Chain/SetBucketChain.php#L232-L242
6,542
novuso/system
src/Collection/Chain/SetBucketChain.php
SetBucketChain.locate
protected function locate($item): ?ItemBucket { for ($this->rewind(); $this->valid(); $this->next()) { /** @var ItemBucket $current */ $current = $this->current; if (Validate::areEqual($item, $current->item())) { return $current; } } return null; }
php
protected function locate($item): ?ItemBucket { for ($this->rewind(); $this->valid(); $this->next()) { /** @var ItemBucket $current */ $current = $this->current; if (Validate::areEqual($item, $current->item())) { return $current; } } return null; }
[ "protected", "function", "locate", "(", "$", "item", ")", ":", "?", "ItemBucket", "{", "for", "(", "$", "this", "->", "rewind", "(", ")", ";", "$", "this", "->", "valid", "(", ")", ";", "$", "this", "->", "next", "(", ")", ")", "{", "/** @var ItemBucket $current */", "$", "current", "=", "$", "this", "->", "current", ";", "if", "(", "Validate", "::", "areEqual", "(", "$", "item", ",", "$", "current", "->", "item", "(", ")", ")", ")", "{", "return", "$", "current", ";", "}", "}", "return", "null", ";", "}" ]
Locates a bucket by item Returns null if the item is not found. @param mixed $item The item @return ItemBucket|null
[ "Locates", "a", "bucket", "by", "item" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Chain/SetBucketChain.php#L279-L290
6,543
novuso/system
src/Collection/Chain/SetBucketChain.php
SetBucketChain.insertBetween
protected function insertBetween($item, Bucket $prev, Bucket $next): void { $bucket = new ItemBucket($item); $prev->setNext($bucket); $next->setPrev($bucket); $bucket->setPrev($prev); $bucket->setNext($next); $this->current = $bucket; $this->count++; }
php
protected function insertBetween($item, Bucket $prev, Bucket $next): void { $bucket = new ItemBucket($item); $prev->setNext($bucket); $next->setPrev($bucket); $bucket->setPrev($prev); $bucket->setNext($next); $this->current = $bucket; $this->count++; }
[ "protected", "function", "insertBetween", "(", "$", "item", ",", "Bucket", "$", "prev", ",", "Bucket", "$", "next", ")", ":", "void", "{", "$", "bucket", "=", "new", "ItemBucket", "(", "$", "item", ")", ";", "$", "prev", "->", "setNext", "(", "$", "bucket", ")", ";", "$", "next", "->", "setPrev", "(", "$", "bucket", ")", ";", "$", "bucket", "->", "setPrev", "(", "$", "prev", ")", ";", "$", "bucket", "->", "setNext", "(", "$", "next", ")", ";", "$", "this", "->", "current", "=", "$", "bucket", ";", "$", "this", "->", "count", "++", ";", "}" ]
Inserts an item between two nodes @param mixed $item The item @param Bucket $prev The previous bucket @param Bucket $next The next bucket @return void
[ "Inserts", "an", "item", "between", "two", "nodes" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Collection/Chain/SetBucketChain.php#L319-L331
6,544
webriq/core
module/Core/src/Grid/Core/View/Helper/ViewWidget.php
ViewWidget.addWidget
public function addWidget( $widget, $service, $priority = null ) { if ( ! isset( $this->widgets[$widget] ) ) { $this->widgets[$widget] = new PriorityQueue; } if ( ! is_a( $service, static::WIDGET_INTERFACE, true ) ) { throw new \InvalidArgumentException( sprintf( '%s: $service must implement "%s"', __METHOD__, static::WIDGET_INTERFACE ) ); } $this->widgets[$widget]->insert( $service, null === $priority ? 1 : (int) $priority ); return $this; }
php
public function addWidget( $widget, $service, $priority = null ) { if ( ! isset( $this->widgets[$widget] ) ) { $this->widgets[$widget] = new PriorityQueue; } if ( ! is_a( $service, static::WIDGET_INTERFACE, true ) ) { throw new \InvalidArgumentException( sprintf( '%s: $service must implement "%s"', __METHOD__, static::WIDGET_INTERFACE ) ); } $this->widgets[$widget]->insert( $service, null === $priority ? 1 : (int) $priority ); return $this; }
[ "public", "function", "addWidget", "(", "$", "widget", ",", "$", "service", ",", "$", "priority", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "widgets", "[", "$", "widget", "]", ")", ")", "{", "$", "this", "->", "widgets", "[", "$", "widget", "]", "=", "new", "PriorityQueue", ";", "}", "if", "(", "!", "is_a", "(", "$", "service", ",", "static", "::", "WIDGET_INTERFACE", ",", "true", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'%s: $service must implement \"%s\"'", ",", "__METHOD__", ",", "static", "::", "WIDGET_INTERFACE", ")", ")", ";", "}", "$", "this", "->", "widgets", "[", "$", "widget", "]", "->", "insert", "(", "$", "service", ",", "null", "===", "$", "priority", "?", "1", ":", "(", "int", ")", "$", "priority", ")", ";", "return", "$", "this", ";", "}" ]
Add a widget @param string $widget @param string $service @param int|null $priority @return ViewWidget
[ "Add", "a", "widget" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/View/Helper/ViewWidget.php#L59-L81
6,545
codenamephp/prototype.utils
src/main/php/de/codenamephp/prototype/utils/answerCollector/FromSerializedArrayFile.php
FromSerializedArrayFile.getAnswers
public function getAnswers(\SplFileInfo $file): array { if($file->isReadable()) { return unserialize($file->openFile()->fread($file->getSize())); } throw new \InvalidArgumentException(sprintf('Given file does not exist or is not readable: "%s"', $file->getPathname())); }
php
public function getAnswers(\SplFileInfo $file): array { if($file->isReadable()) { return unserialize($file->openFile()->fread($file->getSize())); } throw new \InvalidArgumentException(sprintf('Given file does not exist or is not readable: "%s"', $file->getPathname())); }
[ "public", "function", "getAnswers", "(", "\\", "SplFileInfo", "$", "file", ")", ":", "array", "{", "if", "(", "$", "file", "->", "isReadable", "(", ")", ")", "{", "return", "unserialize", "(", "$", "file", "->", "openFile", "(", ")", "->", "fread", "(", "$", "file", "->", "getSize", "(", ")", ")", ")", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Given file does not exist or is not readable: \"%s\"'", ",", "$", "file", "->", "getPathname", "(", ")", ")", ")", ";", "}" ]
Checks if the given file is readable. If so, the file is read an unserialized. No further checking of the content is performed! If the file is not readable (e.g. it does not exist or has no read permissions) a \InvalidArgumentException is thrown. @param \SplFileInfo $file The file to read the serialized array from @return array The unserialized array from the file @throws \InvalidArgumentException if the file is not readable
[ "Checks", "if", "the", "given", "file", "is", "readable", ".", "If", "so", "the", "file", "is", "read", "an", "unserialized", ".", "No", "further", "checking", "of", "the", "content", "is", "performed!" ]
aeb81e1e03624534e8b3e38d6466efda04e435d6
https://github.com/codenamephp/prototype.utils/blob/aeb81e1e03624534e8b3e38d6466efda04e435d6/src/main/php/de/codenamephp/prototype/utils/answerCollector/FromSerializedArrayFile.php#L41-L46
6,546
titon/g11n
src/Titon/G11n/Locale.php
Locale.addResourcePath
public function addResourcePath($domain, $path) { $code = $this->getCode(); $this->getLocaleBundle()->addPath($domain, sprintf('%s/locales/%s', $path, $code)); $this->getMessageBundle()->addPaths($domain, [ sprintf('%s/messages/%s', $path, $code), sprintf('%s/messages/%s/LC_MESSAGES', $path, $code) // gettext ]); return $this; }
php
public function addResourcePath($domain, $path) { $code = $this->getCode(); $this->getLocaleBundle()->addPath($domain, sprintf('%s/locales/%s', $path, $code)); $this->getMessageBundle()->addPaths($domain, [ sprintf('%s/messages/%s', $path, $code), sprintf('%s/messages/%s/LC_MESSAGES', $path, $code) // gettext ]); return $this; }
[ "public", "function", "addResourcePath", "(", "$", "domain", ",", "$", "path", ")", "{", "$", "code", "=", "$", "this", "->", "getCode", "(", ")", ";", "$", "this", "->", "getLocaleBundle", "(", ")", "->", "addPath", "(", "$", "domain", ",", "sprintf", "(", "'%s/locales/%s'", ",", "$", "path", ",", "$", "code", ")", ")", ";", "$", "this", "->", "getMessageBundle", "(", ")", "->", "addPaths", "(", "$", "domain", ",", "[", "sprintf", "(", "'%s/messages/%s'", ",", "$", "path", ",", "$", "code", ")", ",", "sprintf", "(", "'%s/messages/%s/LC_MESSAGES'", ",", "$", "path", ",", "$", "code", ")", "// gettext", "]", ")", ";", "return", "$", "this", ";", "}" ]
Add resource path lookups for locales and messages. @param string $domain @param string $path @return $this
[ "Add", "resource", "path", "lookups", "for", "locales", "and", "messages", "." ]
4b3192055c868167f557b7fb58c37ea620de8df3
https://github.com/titon/g11n/blob/4b3192055c868167f557b7fb58c37ea620de8df3/src/Titon/G11n/Locale.php#L80-L91
6,547
titon/g11n
src/Titon/G11n/Locale.php
Locale.initialize
public function initialize() { if ($data = $this->getLocaleBundle()->loadResource(null, 'locale')) { $data = \Locale::parseLocale($data['code']) + $data; $config = $this->allConfig(); unset($config['code'], $config['initialize']); $this->addConfig($config + $data); } // Force parent config to merge $this->getParentLocale(); return $this; }
php
public function initialize() { if ($data = $this->getLocaleBundle()->loadResource(null, 'locale')) { $data = \Locale::parseLocale($data['code']) + $data; $config = $this->allConfig(); unset($config['code'], $config['initialize']); $this->addConfig($config + $data); } // Force parent config to merge $this->getParentLocale(); return $this; }
[ "public", "function", "initialize", "(", ")", "{", "if", "(", "$", "data", "=", "$", "this", "->", "getLocaleBundle", "(", ")", "->", "loadResource", "(", "null", ",", "'locale'", ")", ")", "{", "$", "data", "=", "\\", "Locale", "::", "parseLocale", "(", "$", "data", "[", "'code'", "]", ")", "+", "$", "data", ";", "$", "config", "=", "$", "this", "->", "allConfig", "(", ")", ";", "unset", "(", "$", "config", "[", "'code'", "]", ",", "$", "config", "[", "'initialize'", "]", ")", ";", "$", "this", "->", "addConfig", "(", "$", "config", "+", "$", "data", ")", ";", "}", "// Force parent config to merge", "$", "this", "->", "getParentLocale", "(", ")", ";", "return", "$", "this", ";", "}" ]
Instantiate the locale and message bundles using the resource paths. @uses Locale @uses Titon\Common\Config @return $this
[ "Instantiate", "the", "locale", "and", "message", "bundles", "using", "the", "resource", "paths", "." ]
4b3192055c868167f557b7fb58c37ea620de8df3
https://github.com/titon/g11n/blob/4b3192055c868167f557b7fb58c37ea620de8df3/src/Titon/G11n/Locale.php#L116-L130
6,548
titon/g11n
src/Titon/G11n/Locale.php
Locale.getParentLocale
public function getParentLocale() { if ($this->_parent) { return $this->_parent; } if (!$this->hasConfig('parent')) { return null; } $parent = new Locale($this->getConfig('parent')); $parent->initialize(); // Merge parent config $this->addConfig($this->allConfig() + $parent->allConfig()); $this->_parent = $parent; return $parent; }
php
public function getParentLocale() { if ($this->_parent) { return $this->_parent; } if (!$this->hasConfig('parent')) { return null; } $parent = new Locale($this->getConfig('parent')); $parent->initialize(); // Merge parent config $this->addConfig($this->allConfig() + $parent->allConfig()); $this->_parent = $parent; return $parent; }
[ "public", "function", "getParentLocale", "(", ")", "{", "if", "(", "$", "this", "->", "_parent", ")", "{", "return", "$", "this", "->", "_parent", ";", "}", "if", "(", "!", "$", "this", "->", "hasConfig", "(", "'parent'", ")", ")", "{", "return", "null", ";", "}", "$", "parent", "=", "new", "Locale", "(", "$", "this", "->", "getConfig", "(", "'parent'", ")", ")", ";", "$", "parent", "->", "initialize", "(", ")", ";", "// Merge parent config", "$", "this", "->", "addConfig", "(", "$", "this", "->", "allConfig", "(", ")", "+", "$", "parent", "->", "allConfig", "(", ")", ")", ";", "$", "this", "->", "_parent", "=", "$", "parent", ";", "return", "$", "parent", ";", "}" ]
Return the parent locale if it exists. @uses Titon\G11n\Locale @return \Titon\G11n\Locale
[ "Return", "the", "parent", "locale", "if", "it", "exists", "." ]
4b3192055c868167f557b7fb58c37ea620de8df3
https://github.com/titon/g11n/blob/4b3192055c868167f557b7fb58c37ea620de8df3/src/Titon/G11n/Locale.php#L184-L202
6,549
titon/g11n
src/Titon/G11n/Locale.php
Locale._loadResource
protected function _loadResource($resource) { return $this->cache([__METHOD__, $resource], function() use ($resource) { $data = $this->getLocaleBundle()->loadResource(null, $resource); if ($parent = $this->getParentLocale()) { $data = array_merge( $parent->getLocaleBundle()->loadResource(null, $resource), $data ); } return $data; }); }
php
protected function _loadResource($resource) { return $this->cache([__METHOD__, $resource], function() use ($resource) { $data = $this->getLocaleBundle()->loadResource(null, $resource); if ($parent = $this->getParentLocale()) { $data = array_merge( $parent->getLocaleBundle()->loadResource(null, $resource), $data ); } return $data; }); }
[ "protected", "function", "_loadResource", "(", "$", "resource", ")", "{", "return", "$", "this", "->", "cache", "(", "[", "__METHOD__", ",", "$", "resource", "]", ",", "function", "(", ")", "use", "(", "$", "resource", ")", "{", "$", "data", "=", "$", "this", "->", "getLocaleBundle", "(", ")", "->", "loadResource", "(", "null", ",", "$", "resource", ")", ";", "if", "(", "$", "parent", "=", "$", "this", "->", "getParentLocale", "(", ")", ")", "{", "$", "data", "=", "array_merge", "(", "$", "parent", "->", "getLocaleBundle", "(", ")", "->", "loadResource", "(", "null", ",", "$", "resource", ")", ",", "$", "data", ")", ";", "}", "return", "$", "data", ";", "}", ")", ";", "}" ]
Load a resource from the locale bundle and merge with the parent if possible. @param string $resource @return array
[ "Load", "a", "resource", "from", "the", "locale", "bundle", "and", "merge", "with", "the", "parent", "if", "possible", "." ]
4b3192055c868167f557b7fb58c37ea620de8df3
https://github.com/titon/g11n/blob/4b3192055c868167f557b7fb58c37ea620de8df3/src/Titon/G11n/Locale.php#L228-L241
6,550
needle-project/common
src/Util/ErrorToExceptionConverter.php
ErrorToExceptionConverter.convertErrorsToExceptions
public function convertErrorsToExceptions($level = null, $exceptionClass = null) { $this->isHandledLocal = true; if (is_null($level)) { $level = E_ALL; } if (is_null($exceptionClass)) { $exceptionClass = static::EXCEPTION_THROW_CLASS; } set_error_handler(function ($errorNumber, $errorMessage, $errorFile, $errorLine) use ($exceptionClass) { throw new $exceptionClass( sprintf("%s in %s on line %s!", $errorMessage, $errorFile, $errorLine), $errorNumber ); }, $level); }
php
public function convertErrorsToExceptions($level = null, $exceptionClass = null) { $this->isHandledLocal = true; if (is_null($level)) { $level = E_ALL; } if (is_null($exceptionClass)) { $exceptionClass = static::EXCEPTION_THROW_CLASS; } set_error_handler(function ($errorNumber, $errorMessage, $errorFile, $errorLine) use ($exceptionClass) { throw new $exceptionClass( sprintf("%s in %s on line %s!", $errorMessage, $errorFile, $errorLine), $errorNumber ); }, $level); }
[ "public", "function", "convertErrorsToExceptions", "(", "$", "level", "=", "null", ",", "$", "exceptionClass", "=", "null", ")", "{", "$", "this", "->", "isHandledLocal", "=", "true", ";", "if", "(", "is_null", "(", "$", "level", ")", ")", "{", "$", "level", "=", "E_ALL", ";", "}", "if", "(", "is_null", "(", "$", "exceptionClass", ")", ")", "{", "$", "exceptionClass", "=", "static", "::", "EXCEPTION_THROW_CLASS", ";", "}", "set_error_handler", "(", "function", "(", "$", "errorNumber", ",", "$", "errorMessage", ",", "$", "errorFile", ",", "$", "errorLine", ")", "use", "(", "$", "exceptionClass", ")", "{", "throw", "new", "$", "exceptionClass", "(", "sprintf", "(", "\"%s in %s on line %s!\"", ",", "$", "errorMessage", ",", "$", "errorFile", ",", "$", "errorLine", ")", ",", "$", "errorNumber", ")", ";", "}", ",", "$", "level", ")", ";", "}" ]
Converts errors to exceptions @param int|null $level The error level to be handled. See http://php.net/manual/en/errorfunc.constants.php @param string|null $exceptionClass
[ "Converts", "errors", "to", "exceptions" ]
07630d51a7d4ffe31e3d39e8fa3b106055290dad
https://github.com/needle-project/common/blob/07630d51a7d4ffe31e3d39e8fa3b106055290dad/src/Util/ErrorToExceptionConverter.php#L38-L53
6,551
vincenttouzet/AdminConfigurationBundle
Manager/ConfigValueManager.php
ConfigValueManager.set
public function set($path, $value) { $configValue = $this->getRepository()->findOneByPath($path); if ($configValue) { $configValue->setValue($value); $this->update($configValue); } }
php
public function set($path, $value) { $configValue = $this->getRepository()->findOneByPath($path); if ($configValue) { $configValue->setValue($value); $this->update($configValue); } }
[ "public", "function", "set", "(", "$", "path", ",", "$", "value", ")", "{", "$", "configValue", "=", "$", "this", "->", "getRepository", "(", ")", "->", "findOneByPath", "(", "$", "path", ")", ";", "if", "(", "$", "configValue", ")", "{", "$", "configValue", "->", "setValue", "(", "$", "value", ")", ";", "$", "this", "->", "update", "(", "$", "configValue", ")", ";", "}", "}" ]
Set the value of config value @param string $path [description] @param string $value [description] @return null
[ "Set", "the", "value", "of", "config", "value" ]
8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb
https://github.com/vincenttouzet/AdminConfigurationBundle/blob/8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb/Manager/ConfigValueManager.php#L54-L61
6,552
Silvestra/Silvestra
src/Silvestra/Component/Banner/BannerZoneSynchronizer.php
BannerZoneSynchronizer.synchronize
public function synchronize($locale) { $existingSystemZones = $this->manager->findSystemSlugs(); $newZones = array(); foreach ($this->registry->getConfigs() as $config) { if (false === in_array($config->getSlug(), $existingSystemZones)) { $newZones[] = $this->createZone($config); } } if (0 < count($newZones)) { $this->manager->save(); foreach ($newZones as $zone) { $this->eventDispatcher->dispatch(BannerZoneEvents::CREATE, new BannerZoneEvent($zone, $locale)); } } }
php
public function synchronize($locale) { $existingSystemZones = $this->manager->findSystemSlugs(); $newZones = array(); foreach ($this->registry->getConfigs() as $config) { if (false === in_array($config->getSlug(), $existingSystemZones)) { $newZones[] = $this->createZone($config); } } if (0 < count($newZones)) { $this->manager->save(); foreach ($newZones as $zone) { $this->eventDispatcher->dispatch(BannerZoneEvents::CREATE, new BannerZoneEvent($zone, $locale)); } } }
[ "public", "function", "synchronize", "(", "$", "locale", ")", "{", "$", "existingSystemZones", "=", "$", "this", "->", "manager", "->", "findSystemSlugs", "(", ")", ";", "$", "newZones", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "registry", "->", "getConfigs", "(", ")", "as", "$", "config", ")", "{", "if", "(", "false", "===", "in_array", "(", "$", "config", "->", "getSlug", "(", ")", ",", "$", "existingSystemZones", ")", ")", "{", "$", "newZones", "[", "]", "=", "$", "this", "->", "createZone", "(", "$", "config", ")", ";", "}", "}", "if", "(", "0", "<", "count", "(", "$", "newZones", ")", ")", "{", "$", "this", "->", "manager", "->", "save", "(", ")", ";", "foreach", "(", "$", "newZones", "as", "$", "zone", ")", "{", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "BannerZoneEvents", "::", "CREATE", ",", "new", "BannerZoneEvent", "(", "$", "zone", ",", "$", "locale", ")", ")", ";", "}", "}", "}" ]
Synchronize system banner zones. @param string $locale
[ "Synchronize", "system", "banner", "zones", "." ]
b7367601b01495ae3c492b42042f804dee13ab06
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Banner/BannerZoneSynchronizer.php#L76-L94
6,553
Silvestra/Silvestra
src/Silvestra/Component/Banner/BannerZoneSynchronizer.php
BannerZoneSynchronizer.createZone
private function createZone(BannerZoneConfig $config) { list($width, $height) = $config->getSize(); $zone = $this->manager->create(); $name = $config->getName(); if ($config->getTranslationDomain()) { $name = $this->translator->trans($name, array(), $config->getTranslationDomain()); } $zone->setName($name); $zone->setCode($config->getSlug()); $zone->setSlug($config->getSlug()); $zone->setWidth($width); $zone->setHeight($height); $zone->setSystem(true); $this->manager->add($zone); return $zone; }
php
private function createZone(BannerZoneConfig $config) { list($width, $height) = $config->getSize(); $zone = $this->manager->create(); $name = $config->getName(); if ($config->getTranslationDomain()) { $name = $this->translator->trans($name, array(), $config->getTranslationDomain()); } $zone->setName($name); $zone->setCode($config->getSlug()); $zone->setSlug($config->getSlug()); $zone->setWidth($width); $zone->setHeight($height); $zone->setSystem(true); $this->manager->add($zone); return $zone; }
[ "private", "function", "createZone", "(", "BannerZoneConfig", "$", "config", ")", "{", "list", "(", "$", "width", ",", "$", "height", ")", "=", "$", "config", "->", "getSize", "(", ")", ";", "$", "zone", "=", "$", "this", "->", "manager", "->", "create", "(", ")", ";", "$", "name", "=", "$", "config", "->", "getName", "(", ")", ";", "if", "(", "$", "config", "->", "getTranslationDomain", "(", ")", ")", "{", "$", "name", "=", "$", "this", "->", "translator", "->", "trans", "(", "$", "name", ",", "array", "(", ")", ",", "$", "config", "->", "getTranslationDomain", "(", ")", ")", ";", "}", "$", "zone", "->", "setName", "(", "$", "name", ")", ";", "$", "zone", "->", "setCode", "(", "$", "config", "->", "getSlug", "(", ")", ")", ";", "$", "zone", "->", "setSlug", "(", "$", "config", "->", "getSlug", "(", ")", ")", ";", "$", "zone", "->", "setWidth", "(", "$", "width", ")", ";", "$", "zone", "->", "setHeight", "(", "$", "height", ")", ";", "$", "zone", "->", "setSystem", "(", "true", ")", ";", "$", "this", "->", "manager", "->", "add", "(", "$", "zone", ")", ";", "return", "$", "zone", ";", "}" ]
Create banner zone. @param BannerZoneConfig $config @return BannerZoneInterface
[ "Create", "banner", "zone", "." ]
b7367601b01495ae3c492b42042f804dee13ab06
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Banner/BannerZoneSynchronizer.php#L103-L122
6,554
Celarius/nofuzz-framework
src/Application.php
Application.createLogger
protected function createLogger(string $loggerName) { # Create the Logger Object $this->logger = new \Nofuzz\Log\Logger($loggerName); # Get the conf options $logLevel = $this->getConfig()->get('log.level','error'); $logDriver = $this->getConfig()->get('log.driver','file'); $logDateFormat = $this->getConfig()->get('log.drivers.'.$logDriver.'.line_datetime','Y-m-d H:i:s'); $logLineFormat = $this->getConfig()->get('log.drivers.'.$logDriver.'.line_format','%datetime% > %level_name% > %message% %context% %extra%'); if ( strcasecmp($logDriver,"file")==0 ) { $logFilePath = $this->getConfig()->get('log.drivers.'.$logDriver.'.file_path','storage/log'); $logFileFormat = $this->getConfig()->get('log.drivers.'.$logDriver.'.file_format','Y-m-d'); # Create the Log Handler $handler = new \Monolog\Handler\StreamHandler( realpath($this->basePath.'/'.$logFilePath).'/'.date($logFileFormat).'.log', $this->getLogger()->toMonologLevel($logLevel) ); } else if ( strcasecmp($logDriver,"php")==0 ) { # Create the Log Handler $handler = new \Monolog\Handler\ErrorLogHandler ( \Monolog\Handler\ErrorLogHandler::OPERATING_SYSTEM, $this->getLogger()->toMonologLevel($logLevel) ); } # finally, create a formatter for it $formatter = new \Monolog\Formatter\LineFormatter($logLineFormat, $logDateFormat); $handler->setFormatter($formatter); # Push the handler to the logger $this->logger->pushHandler($handler); # Set our own error handlers $this->setErrorHandlers(); return $this; }
php
protected function createLogger(string $loggerName) { # Create the Logger Object $this->logger = new \Nofuzz\Log\Logger($loggerName); # Get the conf options $logLevel = $this->getConfig()->get('log.level','error'); $logDriver = $this->getConfig()->get('log.driver','file'); $logDateFormat = $this->getConfig()->get('log.drivers.'.$logDriver.'.line_datetime','Y-m-d H:i:s'); $logLineFormat = $this->getConfig()->get('log.drivers.'.$logDriver.'.line_format','%datetime% > %level_name% > %message% %context% %extra%'); if ( strcasecmp($logDriver,"file")==0 ) { $logFilePath = $this->getConfig()->get('log.drivers.'.$logDriver.'.file_path','storage/log'); $logFileFormat = $this->getConfig()->get('log.drivers.'.$logDriver.'.file_format','Y-m-d'); # Create the Log Handler $handler = new \Monolog\Handler\StreamHandler( realpath($this->basePath.'/'.$logFilePath).'/'.date($logFileFormat).'.log', $this->getLogger()->toMonologLevel($logLevel) ); } else if ( strcasecmp($logDriver,"php")==0 ) { # Create the Log Handler $handler = new \Monolog\Handler\ErrorLogHandler ( \Monolog\Handler\ErrorLogHandler::OPERATING_SYSTEM, $this->getLogger()->toMonologLevel($logLevel) ); } # finally, create a formatter for it $formatter = new \Monolog\Formatter\LineFormatter($logLineFormat, $logDateFormat); $handler->setFormatter($formatter); # Push the handler to the logger $this->logger->pushHandler($handler); # Set our own error handlers $this->setErrorHandlers(); return $this; }
[ "protected", "function", "createLogger", "(", "string", "$", "loggerName", ")", "{", "# Create the Logger Object", "$", "this", "->", "logger", "=", "new", "\\", "Nofuzz", "\\", "Log", "\\", "Logger", "(", "$", "loggerName", ")", ";", "# Get the conf options", "$", "logLevel", "=", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "'log.level'", ",", "'error'", ")", ";", "$", "logDriver", "=", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "'log.driver'", ",", "'file'", ")", ";", "$", "logDateFormat", "=", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "'log.drivers.'", ".", "$", "logDriver", ".", "'.line_datetime'", ",", "'Y-m-d H:i:s'", ")", ";", "$", "logLineFormat", "=", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "'log.drivers.'", ".", "$", "logDriver", ".", "'.line_format'", ",", "'%datetime% > %level_name% > %message% %context% %extra%'", ")", ";", "if", "(", "strcasecmp", "(", "$", "logDriver", ",", "\"file\"", ")", "==", "0", ")", "{", "$", "logFilePath", "=", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "'log.drivers.'", ".", "$", "logDriver", ".", "'.file_path'", ",", "'storage/log'", ")", ";", "$", "logFileFormat", "=", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "'log.drivers.'", ".", "$", "logDriver", ".", "'.file_format'", ",", "'Y-m-d'", ")", ";", "# Create the Log Handler", "$", "handler", "=", "new", "\\", "Monolog", "\\", "Handler", "\\", "StreamHandler", "(", "realpath", "(", "$", "this", "->", "basePath", ".", "'/'", ".", "$", "logFilePath", ")", ".", "'/'", ".", "date", "(", "$", "logFileFormat", ")", ".", "'.log'", ",", "$", "this", "->", "getLogger", "(", ")", "->", "toMonologLevel", "(", "$", "logLevel", ")", ")", ";", "}", "else", "if", "(", "strcasecmp", "(", "$", "logDriver", ",", "\"php\"", ")", "==", "0", ")", "{", "# Create the Log Handler", "$", "handler", "=", "new", "\\", "Monolog", "\\", "Handler", "\\", "ErrorLogHandler", "(", "\\", "Monolog", "\\", "Handler", "\\", "ErrorLogHandler", "::", "OPERATING_SYSTEM", ",", "$", "this", "->", "getLogger", "(", ")", "->", "toMonologLevel", "(", "$", "logLevel", ")", ")", ";", "}", "# finally, create a formatter for it", "$", "formatter", "=", "new", "\\", "Monolog", "\\", "Formatter", "\\", "LineFormatter", "(", "$", "logLineFormat", ",", "$", "logDateFormat", ")", ";", "$", "handler", "->", "setFormatter", "(", "$", "formatter", ")", ";", "# Push the handler to the logger", "$", "this", "->", "logger", "->", "pushHandler", "(", "$", "handler", ")", ";", "# Set our own error handlers", "$", "this", "->", "setErrorHandlers", "(", ")", ";", "return", "$", "this", ";", "}" ]
Creates and Initializes the Logger @return self
[ "Creates", "and", "Initializes", "the", "Logger" ]
867c5150baa431e8f800624a26ba80e95eebd4e5
https://github.com/Celarius/nofuzz-framework/blob/867c5150baa431e8f800624a26ba80e95eebd4e5/src/Application.php#L111-L151
6,555
Celarius/nofuzz-framework
src/Application.php
Application.loadRoutes
protected function loadRoutes(string $filename) { $filename = realpath($filename); if ( file_exists($filename) ) { $routesFile = json_decode( file_get_contents($filename), true ); if ($routesFile) { $routeGroups = $routesFile['groups'] ?? []; # Add each RouteGroup foreach ($routeGroups as $routeGroupDef) { # Create new Route Group $routeGroup = new \Nofuzz\Route\Group($routeGroupDef); # Add to list $this->routeGroups[] = $routeGroup; } # Common Middlewares $this->beforeMiddleware = ($routesFile['common']['before'] ?? []); $this->afterMiddleware = ($routesFile['common']['after'] ?? []); } else { throw new \RunTimeException('Invalid JSON file "'.$filename.'"'); } # Debug log $this->getLogger()->debug('Loaded routes',['file'=>$filename]); return true; // routes added } return false; // file not found }
php
protected function loadRoutes(string $filename) { $filename = realpath($filename); if ( file_exists($filename) ) { $routesFile = json_decode( file_get_contents($filename), true ); if ($routesFile) { $routeGroups = $routesFile['groups'] ?? []; # Add each RouteGroup foreach ($routeGroups as $routeGroupDef) { # Create new Route Group $routeGroup = new \Nofuzz\Route\Group($routeGroupDef); # Add to list $this->routeGroups[] = $routeGroup; } # Common Middlewares $this->beforeMiddleware = ($routesFile['common']['before'] ?? []); $this->afterMiddleware = ($routesFile['common']['after'] ?? []); } else { throw new \RunTimeException('Invalid JSON file "'.$filename.'"'); } # Debug log $this->getLogger()->debug('Loaded routes',['file'=>$filename]); return true; // routes added } return false; // file not found }
[ "protected", "function", "loadRoutes", "(", "string", "$", "filename", ")", "{", "$", "filename", "=", "realpath", "(", "$", "filename", ")", ";", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "routesFile", "=", "json_decode", "(", "file_get_contents", "(", "$", "filename", ")", ",", "true", ")", ";", "if", "(", "$", "routesFile", ")", "{", "$", "routeGroups", "=", "$", "routesFile", "[", "'groups'", "]", "??", "[", "]", ";", "# Add each RouteGroup", "foreach", "(", "$", "routeGroups", "as", "$", "routeGroupDef", ")", "{", "# Create new Route Group", "$", "routeGroup", "=", "new", "\\", "Nofuzz", "\\", "Route", "\\", "Group", "(", "$", "routeGroupDef", ")", ";", "# Add to list", "$", "this", "->", "routeGroups", "[", "]", "=", "$", "routeGroup", ";", "}", "# Common Middlewares", "$", "this", "->", "beforeMiddleware", "=", "(", "$", "routesFile", "[", "'common'", "]", "[", "'before'", "]", "??", "[", "]", ")", ";", "$", "this", "->", "afterMiddleware", "=", "(", "$", "routesFile", "[", "'common'", "]", "[", "'after'", "]", "??", "[", "]", ")", ";", "}", "else", "{", "throw", "new", "\\", "RunTimeException", "(", "'Invalid JSON file \"'", ".", "$", "filename", ".", "'\"'", ")", ";", "}", "# Debug log", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "'Loaded routes'", ",", "[", "'file'", "=>", "$", "filename", "]", ")", ";", "return", "true", ";", "// routes added", "}", "return", "false", ";", "// file not found", "}" ]
Load the "routes.json" and create all RouteGroups @param string $filename [description] @return bool
[ "Load", "the", "routes", ".", "json", "and", "create", "all", "RouteGroups" ]
867c5150baa431e8f800624a26ba80e95eebd4e5
https://github.com/Celarius/nofuzz-framework/blob/867c5150baa431e8f800624a26ba80e95eebd4e5/src/Application.php#L411-L444
6,556
Celarius/nofuzz-framework
src/Application.php
Application.existsRouteGroup
public function existsRouteGroup(string $groupName): bool { foreach ($this->routeGroups as $routeGroup) { if ( strcasecmp($routeGroup->getName(),$groupName)==0 ) { return true; } } return false; }
php
public function existsRouteGroup(string $groupName): bool { foreach ($this->routeGroups as $routeGroup) { if ( strcasecmp($routeGroup->getName(),$groupName)==0 ) { return true; } } return false; }
[ "public", "function", "existsRouteGroup", "(", "string", "$", "groupName", ")", ":", "bool", "{", "foreach", "(", "$", "this", "->", "routeGroups", "as", "$", "routeGroup", ")", "{", "if", "(", "strcasecmp", "(", "$", "routeGroup", "->", "getName", "(", ")", ",", "$", "groupName", ")", "==", "0", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if a RouteGroup exists @param string $groupName [description] @return bool
[ "Checks", "if", "a", "RouteGroup", "exists" ]
867c5150baa431e8f800624a26ba80e95eebd4e5
https://github.com/Celarius/nofuzz-framework/blob/867c5150baa431e8f800624a26ba80e95eebd4e5/src/Application.php#L480-L490
6,557
sharkodlak/php-gettext
src/SprintfTranslatorDecorator.php
SprintfTranslatorDecorator.gettext
public function gettext($message) { $args = func_get_args(); $methodArgsNumber = 1; $message = $this->callMethodAndSprintf(__FUNCTION__, $args, $methodArgsNumber); return $message; }
php
public function gettext($message) { $args = func_get_args(); $methodArgsNumber = 1; $message = $this->callMethodAndSprintf(__FUNCTION__, $args, $methodArgsNumber); return $message; }
[ "public", "function", "gettext", "(", "$", "message", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "methodArgsNumber", "=", "1", ";", "$", "message", "=", "$", "this", "->", "callMethodAndSprintf", "(", "__FUNCTION__", ",", "$", "args", ",", "$", "methodArgsNumber", ")", ";", "return", "$", "message", ";", "}" ]
Call sprintf on the translation result. @param string $message Message to translate (in singular form). @param mixed $arg,... First argument that will be formated according to format specified in translated $message.
[ "Call", "sprintf", "on", "the", "translation", "result", "." ]
383162b6cd4d3f33787f7cc614dafe5509b4924d
https://github.com/sharkodlak/php-gettext/blob/383162b6cd4d3f33787f7cc614dafe5509b4924d/src/SprintfTranslatorDecorator.php#L57-L62
6,558
MattRWallace/Exegesis
annotationparser.php
AnnotationParser.getAnnotationArray
public function getAnnotationArray() { // lazy instantiation of the annotations array if (empty($this->annotations)) { // custom parser? if (self::$parser) { $parser = new self::$parser($this->docs); $this->annotations = $parser->getAnnotationArray(); } // use built in parser else $this->parse(); } return $this->annotations; }
php
public function getAnnotationArray() { // lazy instantiation of the annotations array if (empty($this->annotations)) { // custom parser? if (self::$parser) { $parser = new self::$parser($this->docs); $this->annotations = $parser->getAnnotationArray(); } // use built in parser else $this->parse(); } return $this->annotations; }
[ "public", "function", "getAnnotationArray", "(", ")", "{", "// lazy instantiation of the annotations array", "if", "(", "empty", "(", "$", "this", "->", "annotations", ")", ")", "{", "// custom parser?", "if", "(", "self", "::", "$", "parser", ")", "{", "$", "parser", "=", "new", "self", "::", "$", "parser", "(", "$", "this", "->", "docs", ")", ";", "$", "this", "->", "annotations", "=", "$", "parser", "->", "getAnnotationArray", "(", ")", ";", "}", "// use built in parser", "else", "$", "this", "->", "parse", "(", ")", ";", "}", "return", "$", "this", "->", "annotations", ";", "}" ]
Returns an array of the parsed annotations @access public @return void
[ "Returns", "an", "array", "of", "the", "parsed", "annotations" ]
8e7ba6494fa2ab4f0b9dcfb14015f967c40464d4
https://github.com/MattRWallace/Exegesis/blob/8e7ba6494fa2ab4f0b9dcfb14015f967c40464d4/annotationparser.php#L160-L173
6,559
wasabi-cms/core
src/Nav.php
Nav.getMenu
public static function getMenu($alias, $ordered = false) { if (!isset(self::$_menus[$alias])) { throw new Exception(__d('wasabi_core', 'No menu with alias "{0}" does exist.', $alias)); } if (!$ordered) { return self::$_menus[$alias]; } return self::$_menus[$alias]->getOrderedArray(); }
php
public static function getMenu($alias, $ordered = false) { if (!isset(self::$_menus[$alias])) { throw new Exception(__d('wasabi_core', 'No menu with alias "{0}" does exist.', $alias)); } if (!$ordered) { return self::$_menus[$alias]; } return self::$_menus[$alias]->getOrderedArray(); }
[ "public", "static", "function", "getMenu", "(", "$", "alias", ",", "$", "ordered", "=", "false", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "_menus", "[", "$", "alias", "]", ")", ")", "{", "throw", "new", "Exception", "(", "__d", "(", "'wasabi_core'", ",", "'No menu with alias \"{0}\" does exist.'", ",", "$", "alias", ")", ")", ";", "}", "if", "(", "!", "$", "ordered", ")", "{", "return", "self", "::", "$", "_menus", "[", "$", "alias", "]", ";", "}", "return", "self", "::", "$", "_menus", "[", "$", "alias", "]", "->", "getOrderedArray", "(", ")", ";", "}" ]
Get a Menu instance or an ordered array of menu items of a menu. @param string $alias the alias of the menu @param bool $ordered true: return array of priority ordered menu items, false: return WasabiMenu instance @throws Exception @return array|Menu
[ "Get", "a", "Menu", "instance", "or", "an", "ordered", "array", "of", "menu", "items", "of", "a", "menu", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Nav.php#L53-L63
6,560
phlexible/indexer-bundle
Storage/Operation/Operator.php
Operator.queue
public function queue(Operations $operations) { foreach ($operations->getOperations() as $operation) { if ($operation instanceof AddDocumentOperation) { $identity = $operation->getDocument()->getIdentity(); $job = new Job('indexer:add', array((string) $identity)); } elseif ($operation instanceof AddIdentityOperation) { $identity = $operation->getIdentity(); $job = new Job('indexer:add', array((string) $identity)); } elseif ($operation instanceof UpdateDocumentOperation) { $identity = $operation->getDocument()->getIdentity(); $job = new Job('indexer:add', array('--update', (string) $identity)); } elseif ($operation instanceof UpdateIdentityOperation) { $identity = $operation->getIdentity(); $job = new Job('indexer:add', array('--update', (string) $identity)); } elseif ($operation instanceof DeleteDocumentOperation) { $identity = $operation->getDocument()->getIdentity(); $job = new Job('indexer:delete', array('--identifier', (string) $identity)); } elseif ($operation instanceof DeleteIdentityOperation) { $identity = $operation->getIdentity(); $job = new Job('indexer:delete', array('--identifier', (string) $identity)); } elseif ($operation instanceof DeleteTypeOperation) { $job = new Job('indexer:delete', array('--type', $operation->getType())); } elseif ($operation instanceof DeleteAllOperation) { $job = new Job('indexer:delete', array('--all')); } elseif ($operation instanceof FlushOperation) { $job = new Job('indexer:index', array('--flush')); } elseif ($operation instanceof OptimizeOperation) { $job = new Job('indexer:index', array('--optimize')); } elseif ($operation instanceof CommitOperation) { $job = new Job('indexer:index', array('--commit')); } elseif ($operation instanceof RollbackOperation) { $job = new Job('indexer:index', array('--rollback')); } else { continue; } $this->jobManager->addJob($job); } return true; }
php
public function queue(Operations $operations) { foreach ($operations->getOperations() as $operation) { if ($operation instanceof AddDocumentOperation) { $identity = $operation->getDocument()->getIdentity(); $job = new Job('indexer:add', array((string) $identity)); } elseif ($operation instanceof AddIdentityOperation) { $identity = $operation->getIdentity(); $job = new Job('indexer:add', array((string) $identity)); } elseif ($operation instanceof UpdateDocumentOperation) { $identity = $operation->getDocument()->getIdentity(); $job = new Job('indexer:add', array('--update', (string) $identity)); } elseif ($operation instanceof UpdateIdentityOperation) { $identity = $operation->getIdentity(); $job = new Job('indexer:add', array('--update', (string) $identity)); } elseif ($operation instanceof DeleteDocumentOperation) { $identity = $operation->getDocument()->getIdentity(); $job = new Job('indexer:delete', array('--identifier', (string) $identity)); } elseif ($operation instanceof DeleteIdentityOperation) { $identity = $operation->getIdentity(); $job = new Job('indexer:delete', array('--identifier', (string) $identity)); } elseif ($operation instanceof DeleteTypeOperation) { $job = new Job('indexer:delete', array('--type', $operation->getType())); } elseif ($operation instanceof DeleteAllOperation) { $job = new Job('indexer:delete', array('--all')); } elseif ($operation instanceof FlushOperation) { $job = new Job('indexer:index', array('--flush')); } elseif ($operation instanceof OptimizeOperation) { $job = new Job('indexer:index', array('--optimize')); } elseif ($operation instanceof CommitOperation) { $job = new Job('indexer:index', array('--commit')); } elseif ($operation instanceof RollbackOperation) { $job = new Job('indexer:index', array('--rollback')); } else { continue; } $this->jobManager->addJob($job); } return true; }
[ "public", "function", "queue", "(", "Operations", "$", "operations", ")", "{", "foreach", "(", "$", "operations", "->", "getOperations", "(", ")", "as", "$", "operation", ")", "{", "if", "(", "$", "operation", "instanceof", "AddDocumentOperation", ")", "{", "$", "identity", "=", "$", "operation", "->", "getDocument", "(", ")", "->", "getIdentity", "(", ")", ";", "$", "job", "=", "new", "Job", "(", "'indexer:add'", ",", "array", "(", "(", "string", ")", "$", "identity", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "AddIdentityOperation", ")", "{", "$", "identity", "=", "$", "operation", "->", "getIdentity", "(", ")", ";", "$", "job", "=", "new", "Job", "(", "'indexer:add'", ",", "array", "(", "(", "string", ")", "$", "identity", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "UpdateDocumentOperation", ")", "{", "$", "identity", "=", "$", "operation", "->", "getDocument", "(", ")", "->", "getIdentity", "(", ")", ";", "$", "job", "=", "new", "Job", "(", "'indexer:add'", ",", "array", "(", "'--update'", ",", "(", "string", ")", "$", "identity", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "UpdateIdentityOperation", ")", "{", "$", "identity", "=", "$", "operation", "->", "getIdentity", "(", ")", ";", "$", "job", "=", "new", "Job", "(", "'indexer:add'", ",", "array", "(", "'--update'", ",", "(", "string", ")", "$", "identity", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "DeleteDocumentOperation", ")", "{", "$", "identity", "=", "$", "operation", "->", "getDocument", "(", ")", "->", "getIdentity", "(", ")", ";", "$", "job", "=", "new", "Job", "(", "'indexer:delete'", ",", "array", "(", "'--identifier'", ",", "(", "string", ")", "$", "identity", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "DeleteIdentityOperation", ")", "{", "$", "identity", "=", "$", "operation", "->", "getIdentity", "(", ")", ";", "$", "job", "=", "new", "Job", "(", "'indexer:delete'", ",", "array", "(", "'--identifier'", ",", "(", "string", ")", "$", "identity", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "DeleteTypeOperation", ")", "{", "$", "job", "=", "new", "Job", "(", "'indexer:delete'", ",", "array", "(", "'--type'", ",", "$", "operation", "->", "getType", "(", ")", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "DeleteAllOperation", ")", "{", "$", "job", "=", "new", "Job", "(", "'indexer:delete'", ",", "array", "(", "'--all'", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "FlushOperation", ")", "{", "$", "job", "=", "new", "Job", "(", "'indexer:index'", ",", "array", "(", "'--flush'", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "OptimizeOperation", ")", "{", "$", "job", "=", "new", "Job", "(", "'indexer:index'", ",", "array", "(", "'--optimize'", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "CommitOperation", ")", "{", "$", "job", "=", "new", "Job", "(", "'indexer:index'", ",", "array", "(", "'--commit'", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "RollbackOperation", ")", "{", "$", "job", "=", "new", "Job", "(", "'indexer:index'", ",", "array", "(", "'--rollback'", ")", ")", ";", "}", "else", "{", "continue", ";", "}", "$", "this", "->", "jobManager", "->", "addJob", "(", "$", "job", ")", ";", "}", "return", "true", ";", "}" ]
Queue operations. @param Operations $operations @return bool
[ "Queue", "operations", "." ]
5c568d056f6c71f7cb80a7ff9e36d35bc487f7f8
https://github.com/phlexible/indexer-bundle/blob/5c568d056f6c71f7cb80a7ff9e36d35bc487f7f8/Storage/Operation/Operator.php#L69-L110
6,561
phlexible/indexer-bundle
Storage/Operation/Operator.php
Operator.execute
public function execute(StorageInterface $storage, Operations $operations) { foreach ($operations->getOperations() as $operation) { if ($operation instanceof AddDocumentOperation) { $document = $operation->getDocument(); $event = new DocumentEvent($document); if ($this->eventDispatcher->dispatch(IndexerEvents::BEFORE_STORAGE_ADD_DOCUMENT, $event) ->isPropagationStopped() ) { continue; } $storage->addDocument($document); $event = new DocumentEvent($document); $this->eventDispatcher->dispatch(IndexerEvents::STORAGE_ADD_DOCUMENT, $event); } elseif ($operation instanceof AddIdentityOperation) { throw new InvalidArgumentException('Add identity command not supported by run().'); } elseif ($operation instanceof UpdateDocumentOperation) { $document = $operation->getDocument(); $event = new DocumentEvent($document); if ($this->eventDispatcher->dispatch(IndexerEvents::BEFORE_STORAGE_UPDATE_DOCUMENT, $event)->isPropagationStopped()) { continue; } $storage->updateDocument($document); $event = new DocumentEvent($document); $this->eventDispatcher->dispatch(IndexerEvents::STORAGE_UPDATE_DOCUMENT, $event); } elseif ($operation instanceof UpdateIdentityOperation) { throw new InvalidArgumentException('Update identity command not supported by run().'); } elseif ($operation instanceof DeleteDocumentOperation) { $storage->deleteDocument($operation->getDocument()); } elseif ($operation instanceof DeleteIdentityOperation) { $storage->delete($operation->getIdentity()); } elseif ($operation instanceof DeleteTypeOperation) { $storage->deleteType($operation->getType()); } elseif ($operation instanceof DeleteAllOperation) { $storage->deleteAll(); } elseif ($operation instanceof FlushOperation) { if ($storage instanceof Flushable) { $storage->flush(); } } elseif ($operation instanceof OptimizeOperation) { if ($storage instanceof Optimizable) { $storage->optimize(); } } elseif ($operation instanceof CommitOperation) { if ($storage instanceof Commitable) { $storage->commit(); } } elseif ($operation instanceof RollbackOperation) { if ($storage instanceof Rollbackable) { $storage->rollback(); } } } return true; }
php
public function execute(StorageInterface $storage, Operations $operations) { foreach ($operations->getOperations() as $operation) { if ($operation instanceof AddDocumentOperation) { $document = $operation->getDocument(); $event = new DocumentEvent($document); if ($this->eventDispatcher->dispatch(IndexerEvents::BEFORE_STORAGE_ADD_DOCUMENT, $event) ->isPropagationStopped() ) { continue; } $storage->addDocument($document); $event = new DocumentEvent($document); $this->eventDispatcher->dispatch(IndexerEvents::STORAGE_ADD_DOCUMENT, $event); } elseif ($operation instanceof AddIdentityOperation) { throw new InvalidArgumentException('Add identity command not supported by run().'); } elseif ($operation instanceof UpdateDocumentOperation) { $document = $operation->getDocument(); $event = new DocumentEvent($document); if ($this->eventDispatcher->dispatch(IndexerEvents::BEFORE_STORAGE_UPDATE_DOCUMENT, $event)->isPropagationStopped()) { continue; } $storage->updateDocument($document); $event = new DocumentEvent($document); $this->eventDispatcher->dispatch(IndexerEvents::STORAGE_UPDATE_DOCUMENT, $event); } elseif ($operation instanceof UpdateIdentityOperation) { throw new InvalidArgumentException('Update identity command not supported by run().'); } elseif ($operation instanceof DeleteDocumentOperation) { $storage->deleteDocument($operation->getDocument()); } elseif ($operation instanceof DeleteIdentityOperation) { $storage->delete($operation->getIdentity()); } elseif ($operation instanceof DeleteTypeOperation) { $storage->deleteType($operation->getType()); } elseif ($operation instanceof DeleteAllOperation) { $storage->deleteAll(); } elseif ($operation instanceof FlushOperation) { if ($storage instanceof Flushable) { $storage->flush(); } } elseif ($operation instanceof OptimizeOperation) { if ($storage instanceof Optimizable) { $storage->optimize(); } } elseif ($operation instanceof CommitOperation) { if ($storage instanceof Commitable) { $storage->commit(); } } elseif ($operation instanceof RollbackOperation) { if ($storage instanceof Rollbackable) { $storage->rollback(); } } } return true; }
[ "public", "function", "execute", "(", "StorageInterface", "$", "storage", ",", "Operations", "$", "operations", ")", "{", "foreach", "(", "$", "operations", "->", "getOperations", "(", ")", "as", "$", "operation", ")", "{", "if", "(", "$", "operation", "instanceof", "AddDocumentOperation", ")", "{", "$", "document", "=", "$", "operation", "->", "getDocument", "(", ")", ";", "$", "event", "=", "new", "DocumentEvent", "(", "$", "document", ")", ";", "if", "(", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "IndexerEvents", "::", "BEFORE_STORAGE_ADD_DOCUMENT", ",", "$", "event", ")", "->", "isPropagationStopped", "(", ")", ")", "{", "continue", ";", "}", "$", "storage", "->", "addDocument", "(", "$", "document", ")", ";", "$", "event", "=", "new", "DocumentEvent", "(", "$", "document", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "IndexerEvents", "::", "STORAGE_ADD_DOCUMENT", ",", "$", "event", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "AddIdentityOperation", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Add identity command not supported by run().'", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "UpdateDocumentOperation", ")", "{", "$", "document", "=", "$", "operation", "->", "getDocument", "(", ")", ";", "$", "event", "=", "new", "DocumentEvent", "(", "$", "document", ")", ";", "if", "(", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "IndexerEvents", "::", "BEFORE_STORAGE_UPDATE_DOCUMENT", ",", "$", "event", ")", "->", "isPropagationStopped", "(", ")", ")", "{", "continue", ";", "}", "$", "storage", "->", "updateDocument", "(", "$", "document", ")", ";", "$", "event", "=", "new", "DocumentEvent", "(", "$", "document", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "IndexerEvents", "::", "STORAGE_UPDATE_DOCUMENT", ",", "$", "event", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "UpdateIdentityOperation", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Update identity command not supported by run().'", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "DeleteDocumentOperation", ")", "{", "$", "storage", "->", "deleteDocument", "(", "$", "operation", "->", "getDocument", "(", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "DeleteIdentityOperation", ")", "{", "$", "storage", "->", "delete", "(", "$", "operation", "->", "getIdentity", "(", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "DeleteTypeOperation", ")", "{", "$", "storage", "->", "deleteType", "(", "$", "operation", "->", "getType", "(", ")", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "DeleteAllOperation", ")", "{", "$", "storage", "->", "deleteAll", "(", ")", ";", "}", "elseif", "(", "$", "operation", "instanceof", "FlushOperation", ")", "{", "if", "(", "$", "storage", "instanceof", "Flushable", ")", "{", "$", "storage", "->", "flush", "(", ")", ";", "}", "}", "elseif", "(", "$", "operation", "instanceof", "OptimizeOperation", ")", "{", "if", "(", "$", "storage", "instanceof", "Optimizable", ")", "{", "$", "storage", "->", "optimize", "(", ")", ";", "}", "}", "elseif", "(", "$", "operation", "instanceof", "CommitOperation", ")", "{", "if", "(", "$", "storage", "instanceof", "Commitable", ")", "{", "$", "storage", "->", "commit", "(", ")", ";", "}", "}", "elseif", "(", "$", "operation", "instanceof", "RollbackOperation", ")", "{", "if", "(", "$", "storage", "instanceof", "Rollbackable", ")", "{", "$", "storage", "->", "rollback", "(", ")", ";", "}", "}", "}", "return", "true", ";", "}" ]
Execute operations. @param StorageInterface $storage @param Operations $operations @return bool
[ "Execute", "operations", "." ]
5c568d056f6c71f7cb80a7ff9e36d35bc487f7f8
https://github.com/phlexible/indexer-bundle/blob/5c568d056f6c71f7cb80a7ff9e36d35bc487f7f8/Storage/Operation/Operator.php#L120-L179
6,562
elastification/php-client
src/ClientVersionMap.php
ClientVersionMap.getVersion
public function getVersion($version) { foreach ($this->versions as $versionPattern) { if (preg_match($versionPattern['regex'], $version)) { return $versionPattern['version']; } } throw new VersionException('Version not found'); }
php
public function getVersion($version) { foreach ($this->versions as $versionPattern) { if (preg_match($versionPattern['regex'], $version)) { return $versionPattern['version']; } } throw new VersionException('Version not found'); }
[ "public", "function", "getVersion", "(", "$", "version", ")", "{", "foreach", "(", "$", "this", "->", "versions", "as", "$", "versionPattern", ")", "{", "if", "(", "preg_match", "(", "$", "versionPattern", "[", "'regex'", "]", ",", "$", "version", ")", ")", "{", "return", "$", "versionPattern", "[", "'version'", "]", ";", "}", "}", "throw", "new", "VersionException", "(", "'Version not found'", ")", ";", "}" ]
Get the defined version for folders. We throw an exception in case of a non-matching version. @param string $version A version string in the schema of 0.90.x. @return string The internal namespace/folder @throws VersionException @author Daniel Wendlandt
[ "Get", "the", "defined", "version", "for", "folders", ".", "We", "throw", "an", "exception", "in", "case", "of", "a", "non", "-", "matching", "version", "." ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/ClientVersionMap.php#L49-L59
6,563
AnonymPHP/Anonym-Library
src/Anonym/View/LanguageManager.php
LanguageManager.getLanguage
public function getLanguage($file = '') { $path = $this->path . DIRECTORY_SEPARATOR . $file . '.php'; if (file_exists($path)) { $variables = require $path; return $variables; } else { return false; } }
php
public function getLanguage($file = '') { $path = $this->path . DIRECTORY_SEPARATOR . $file . '.php'; if (file_exists($path)) { $variables = require $path; return $variables; } else { return false; } }
[ "public", "function", "getLanguage", "(", "$", "file", "=", "''", ")", "{", "$", "path", "=", "$", "this", "->", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "file", ".", "'.php'", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "$", "variables", "=", "require", "$", "path", ";", "return", "$", "variables", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
get the language variables with file path @param string $file the file name @return array|bool registered varibles on file
[ "get", "the", "language", "variables", "with", "file", "path" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/View/LanguageManager.php#L41-L50
6,564
synapsestudios/synapse-base
src/Synapse/Application/Services.php
Services.registerSecurityFirewalls
public function registerSecurityFirewalls(Application $app) { $app['security.firewalls'] = $app->share(function () { return [ 'base.api' => [ 'pattern' => '^/', 'oauth' => true, ], ]; }); $app['security.access_rules'] = $app->share(function () { return []; }); }
php
public function registerSecurityFirewalls(Application $app) { $app['security.firewalls'] = $app->share(function () { return [ 'base.api' => [ 'pattern' => '^/', 'oauth' => true, ], ]; }); $app['security.access_rules'] = $app->share(function () { return []; }); }
[ "public", "function", "registerSecurityFirewalls", "(", "Application", "$", "app", ")", "{", "$", "app", "[", "'security.firewalls'", "]", "=", "$", "app", "->", "share", "(", "function", "(", ")", "{", "return", "[", "'base.api'", "=>", "[", "'pattern'", "=>", "'^/'", ",", "'oauth'", "=>", "true", ",", "]", ",", "]", ";", "}", ")", ";", "$", "app", "[", "'security.access_rules'", "]", "=", "$", "app", "->", "share", "(", "function", "(", ")", "{", "return", "[", "]", ";", "}", ")", ";", "}" ]
Register the security firewalls for use with the Security Context in SecurityServiceProvider How to add application-specific firewalls: $app->extend('security.firewalls', function ($firewalls, $app) { $newFirewalls = [...]; return array_merge($newFirewalls, $firewalls); }); It's important to return an array with $firewalls at the end, as in the example, so that the catch-all 'base.api' firewall does not preclude more specific firewalls. Application-specific firewalls should only be needed to allow passthrough for public endpoints, since 'base.api' requires authentication. Firewalls available include: - oauth - Requires the user to be logged in - oauth-optional - Does not require the user to be logged in - If the user is logged in, sets their token on the security context so that their info can be accessed - anonymous - Does not require the user to be logged in - Does not attempt to retrieve user's information if Authentication header is sent The same can be done with security.access_rules, which are used to restrict sections of the application based on a user's role: $app->extend('security.access_rules', function ($rules, $app) { $newRules = [...]; return array_merge($newRules, $rules); }); @link http://silex.sensiolabs.org/doc/providers/security.html#defining-more-than-one-firewall @link http://silex.sensiolabs.org/doc/providers/security.html#defining-access-rules @param Application $app
[ "Register", "the", "security", "firewalls", "for", "use", "with", "the", "Security", "Context", "in", "SecurityServiceProvider" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Application/Services.php#L110-L124
6,565
artscorestudio/website-bundle
Controller/PublicController.php
PublicController.pageAction
public function pageAction($path) { $parts = explode('/', $path); $result = $this->get('asf_document.page.manager')->getRepository()->findBySlug($path); if ( count($result) == 0 ) { throw new NotFoundHttpException('Ooops ! Page not found.'); } $page = $result[0]; return $this->render('ASFWebsiteBundle:Public:page.html.twig', array( 'page' => $page )); }
php
public function pageAction($path) { $parts = explode('/', $path); $result = $this->get('asf_document.page.manager')->getRepository()->findBySlug($path); if ( count($result) == 0 ) { throw new NotFoundHttpException('Ooops ! Page not found.'); } $page = $result[0]; return $this->render('ASFWebsiteBundle:Public:page.html.twig', array( 'page' => $page )); }
[ "public", "function", "pageAction", "(", "$", "path", ")", "{", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "path", ")", ";", "$", "result", "=", "$", "this", "->", "get", "(", "'asf_document.page.manager'", ")", "->", "getRepository", "(", ")", "->", "findBySlug", "(", "$", "path", ")", ";", "if", "(", "count", "(", "$", "result", ")", "==", "0", ")", "{", "throw", "new", "NotFoundHttpException", "(", "'Ooops ! Page not found.'", ")", ";", "}", "$", "page", "=", "$", "result", "[", "0", "]", ";", "return", "$", "this", "->", "render", "(", "'ASFWebsiteBundle:Public:page.html.twig'", ",", "array", "(", "'page'", "=>", "$", "page", ")", ")", ";", "}" ]
Website Page Controller @param string $path @throws \Exception @return \Symfony\Component\HttpFoundation\Response
[ "Website", "Page", "Controller" ]
016d62d7558cd8c2fe821ae2645735149c5e6ee5
https://github.com/artscorestudio/website-bundle/blob/016d62d7558cd8c2fe821ae2645735149c5e6ee5/Controller/PublicController.php#L40-L55
6,566
easy-system/es-models
src/ValueObject.php
ValueObject.getItem
public function getItem($key, $default = null) { if (isset($this->container[$key])) { return $this->container[$key]; } return $default; }
php
public function getItem($key, $default = null) { if (isset($this->container[$key])) { return $this->container[$key]; } return $default; }
[ "public", "function", "getItem", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "container", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "container", "[", "$", "key", "]", ";", "}", "return", "$", "default", ";", "}" ]
Gets the item value. @param int|string $key The key of item @param mixed $default Optional; null by default. The default value @return mixed Returns the item value, if any, $default otherwise
[ "Gets", "the", "item", "value", "." ]
e03b2d3b4de70b02090ec0a74ae37d1b8a231d4e
https://github.com/easy-system/es-models/blob/e03b2d3b4de70b02090ec0a74ae37d1b8a231d4e/src/ValueObject.php#L58-L65
6,567
easy-system/es-container
src/Merging/MergingTrait.php
MergingTrait.merge
public function merge($source) { if ($source instanceof MergingInterface) { $source = $source->toArray(); } elseif ($source instanceof Traversable) { $source = iterator_to_array($source); } elseif ($source instanceof \stdClass) { $source = (array) $source; } elseif (! is_array($source)) { throw new InvalidArgumentException(sprintf( 'Failed to merge with source of type "%s".', is_object($source) ? get_class($source) : gettype($source) )); } $this->container = $this->arrayMerge($this->container, $source); }
php
public function merge($source) { if ($source instanceof MergingInterface) { $source = $source->toArray(); } elseif ($source instanceof Traversable) { $source = iterator_to_array($source); } elseif ($source instanceof \stdClass) { $source = (array) $source; } elseif (! is_array($source)) { throw new InvalidArgumentException(sprintf( 'Failed to merge with source of type "%s".', is_object($source) ? get_class($source) : gettype($source) )); } $this->container = $this->arrayMerge($this->container, $source); }
[ "public", "function", "merge", "(", "$", "source", ")", "{", "if", "(", "$", "source", "instanceof", "MergingInterface", ")", "{", "$", "source", "=", "$", "source", "->", "toArray", "(", ")", ";", "}", "elseif", "(", "$", "source", "instanceof", "Traversable", ")", "{", "$", "source", "=", "iterator_to_array", "(", "$", "source", ")", ";", "}", "elseif", "(", "$", "source", "instanceof", "\\", "stdClass", ")", "{", "$", "source", "=", "(", "array", ")", "$", "source", ";", "}", "elseif", "(", "!", "is_array", "(", "$", "source", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Failed to merge with source of type \"%s\".'", ",", "is_object", "(", "$", "source", ")", "?", "get_class", "(", "$", "source", ")", ":", "gettype", "(", "$", "source", ")", ")", ")", ";", "}", "$", "this", "->", "container", "=", "$", "this", "->", "arrayMerge", "(", "$", "this", "->", "container", ",", "$", "source", ")", ";", "}" ]
Merges data from other data sources. Any available data source will be converted into an array. The values, that have an string keys, will be overwritten. The values, that have an integer keys, will be added. Any object that presents in the data source and implements the MergingInterface, will be converted into array. @param array|MergingInterface|\Traversable|\stdClass $source The data source @throws \InvalidArgumentException If the data source type is not compatible
[ "Merges", "data", "from", "other", "data", "sources", "." ]
0e917d8ff2c3622f53b82d34436295539858be7d
https://github.com/easy-system/es-container/blob/0e917d8ff2c3622f53b82d34436295539858be7d/src/Merging/MergingTrait.php#L38-L53
6,568
easy-system/es-container
src/Merging/MergingTrait.php
MergingTrait.arrayMerge
protected function arrayMerge(array $target, array $source) { foreach ($source as $key => $value) { if ($value instanceof MergingInterface) { $value = $value->toArray(); } if (isset($target[$key]) || array_key_exists($key, $target)) { if (is_int($key)) { $target[] = $value; } elseif (is_array($value) && is_array($target[$key])) { $target[$key] = $this->arrayMerge($target[$key], $value); } else { $target[$key] = $value; } } else { $target[$key] = $value; } } return $target; }
php
protected function arrayMerge(array $target, array $source) { foreach ($source as $key => $value) { if ($value instanceof MergingInterface) { $value = $value->toArray(); } if (isset($target[$key]) || array_key_exists($key, $target)) { if (is_int($key)) { $target[] = $value; } elseif (is_array($value) && is_array($target[$key])) { $target[$key] = $this->arrayMerge($target[$key], $value); } else { $target[$key] = $value; } } else { $target[$key] = $value; } } return $target; }
[ "protected", "function", "arrayMerge", "(", "array", "$", "target", ",", "array", "$", "source", ")", "{", "foreach", "(", "$", "source", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "MergingInterface", ")", "{", "$", "value", "=", "$", "value", "->", "toArray", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "target", "[", "$", "key", "]", ")", "||", "array_key_exists", "(", "$", "key", ",", "$", "target", ")", ")", "{", "if", "(", "is_int", "(", "$", "key", ")", ")", "{", "$", "target", "[", "]", "=", "$", "value", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", "&&", "is_array", "(", "$", "target", "[", "$", "key", "]", ")", ")", "{", "$", "target", "[", "$", "key", "]", "=", "$", "this", "->", "arrayMerge", "(", "$", "target", "[", "$", "key", "]", ",", "$", "value", ")", ";", "}", "else", "{", "$", "target", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "else", "{", "$", "target", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "target", ";", "}" ]
Merge data from two arrays. @param array $target The target array @param array $source The sourse array @return array The result of merging
[ "Merge", "data", "from", "two", "arrays", "." ]
0e917d8ff2c3622f53b82d34436295539858be7d
https://github.com/easy-system/es-container/blob/0e917d8ff2c3622f53b82d34436295539858be7d/src/Merging/MergingTrait.php#L63-L83
6,569
marando/phpSOFA
src/Marando/IAU/iauAf2a.php
iauAf2a.Af2a
public static function Af2a($s, $ideg, $iamin, $asec, &$rad) { /* Compute the interval. */ $rad = ( $s == '-' ? -1.0 : 1.0 ) * ( 60.0 * ( 60.0 * ( (double)abs($ideg) ) + ( (double)abs($iamin) ) ) + abs($asec) ) * DAS2R; /* Validate arguments and return status. */ if ($ideg < 0 || $ideg > 359) return 1; if ($iamin < 0 || $iamin > 59) return 2; if ($asec < 0.0 || $asec >= 60.0) return 3; return 0; }
php
public static function Af2a($s, $ideg, $iamin, $asec, &$rad) { /* Compute the interval. */ $rad = ( $s == '-' ? -1.0 : 1.0 ) * ( 60.0 * ( 60.0 * ( (double)abs($ideg) ) + ( (double)abs($iamin) ) ) + abs($asec) ) * DAS2R; /* Validate arguments and return status. */ if ($ideg < 0 || $ideg > 359) return 1; if ($iamin < 0 || $iamin > 59) return 2; if ($asec < 0.0 || $asec >= 60.0) return 3; return 0; }
[ "public", "static", "function", "Af2a", "(", "$", "s", ",", "$", "ideg", ",", "$", "iamin", ",", "$", "asec", ",", "&", "$", "rad", ")", "{", "/* Compute the interval. */", "$", "rad", "=", "(", "$", "s", "==", "'-'", "?", "-", "1.0", ":", "1.0", ")", "*", "(", "60.0", "*", "(", "60.0", "*", "(", "(", "double", ")", "abs", "(", "$", "ideg", ")", ")", "+", "(", "(", "double", ")", "abs", "(", "$", "iamin", ")", ")", ")", "+", "abs", "(", "$", "asec", ")", ")", "*", "DAS2R", ";", "/* Validate arguments and return status. */", "if", "(", "$", "ideg", "<", "0", "||", "$", "ideg", ">", "359", ")", "return", "1", ";", "if", "(", "$", "iamin", "<", "0", "||", "$", "iamin", ">", "59", ")", "return", "2", ";", "if", "(", "$", "asec", "<", "0.0", "||", "$", "asec", ">=", "60.0", ")", "return", "3", ";", "return", "0", ";", "}" ]
- - - - - - - - i a u A f 2 a - - - - - - - - Convert degrees, arcminutes, arcseconds to radians. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: s char sign: '-' = negative, otherwise positive ideg int degrees iamin int arcminutes asec double arcseconds Returned: rad double angle in radians Returned (function value): int status: 0 = OK 1 = ideg outside range 0-359 2 = iamin outside range 0-59 3 = asec outside range 0-59.999... Notes: 1) The result is computed even if any of the range checks fail. 2) Negative ideg, iamin and/or asec produce a warning status, but the absolute value is used in the conversion. 3) If there are multiple errors, the status value reflects only the first, the smallest taking precedence. This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "A", "f", "2", "a", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauAf2a.php#L50-L65
6,570
Flowpack/Flowpack.SingleSignOn.Client
Classes/Flowpack/SingleSignOn/Client/Security/RequestPattern/ConjunctionPattern.php
ConjunctionPattern.matchRequest
public function matchRequest(\TYPO3\Flow\Mvc\RequestInterface $request) { /** @var \TYPO3\Flow\Security\RequestPatternInterface $pattern */ foreach ($this->subPatterns as $pattern) { if ($pattern->matchRequest($request) === FALSE) { return FALSE; } } return TRUE; }
php
public function matchRequest(\TYPO3\Flow\Mvc\RequestInterface $request) { /** @var \TYPO3\Flow\Security\RequestPatternInterface $pattern */ foreach ($this->subPatterns as $pattern) { if ($pattern->matchRequest($request) === FALSE) { return FALSE; } } return TRUE; }
[ "public", "function", "matchRequest", "(", "\\", "TYPO3", "\\", "Flow", "\\", "Mvc", "\\", "RequestInterface", "$", "request", ")", "{", "/** @var \\TYPO3\\Flow\\Security\\RequestPatternInterface $pattern */", "foreach", "(", "$", "this", "->", "subPatterns", "as", "$", "pattern", ")", "{", "if", "(", "$", "pattern", "->", "matchRequest", "(", "$", "request", ")", "===", "FALSE", ")", "{", "return", "FALSE", ";", "}", "}", "return", "TRUE", ";", "}" ]
Matches a \TYPO3\Flow\Mvc\RequestInterface against its set pattern rules @param \TYPO3\Flow\Mvc\RequestInterface $request The request that should be matched @return boolean TRUE if the pattern matched, FALSE otherwise
[ "Matches", "a", "\\", "TYPO3", "\\", "Flow", "\\", "Mvc", "\\", "RequestInterface", "against", "its", "set", "pattern", "rules" ]
0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00
https://github.com/Flowpack/Flowpack.SingleSignOn.Client/blob/0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00/Classes/Flowpack/SingleSignOn/Client/Security/RequestPattern/ConjunctionPattern.php#L71-L80
6,571
phossa2/libs
src/Phossa2/Db/Manager.php
Manager.addDriver
public function addDriver(DriverInterface $driver, /*# int */ $factor = 1) { // get unique driver id $id = $this->getDriverId($driver); // fix factor range: 1 - 10 $this->factors[$id] = $this->fixFactor($factor); // add to the pool $this->drivers[$id] = $driver; return $this; }
php
public function addDriver(DriverInterface $driver, /*# int */ $factor = 1) { // get unique driver id $id = $this->getDriverId($driver); // fix factor range: 1 - 10 $this->factors[$id] = $this->fixFactor($factor); // add to the pool $this->drivers[$id] = $driver; return $this; }
[ "public", "function", "addDriver", "(", "DriverInterface", "$", "driver", ",", "/*# int */", "$", "factor", "=", "1", ")", "{", "// get unique driver id", "$", "id", "=", "$", "this", "->", "getDriverId", "(", "$", "driver", ")", ";", "// fix factor range: 1 - 10", "$", "this", "->", "factors", "[", "$", "id", "]", "=", "$", "this", "->", "fixFactor", "(", "$", "factor", ")", ";", "// add to the pool", "$", "this", "->", "drivers", "[", "$", "id", "]", "=", "$", "driver", ";", "return", "$", "this", ";", "}" ]
Specify a weighting factor for the driver. normally 1 - 10 {@inheritDoc} @param int $factor weight factor for round-robin
[ "Specify", "a", "weighting", "factor", "for", "the", "driver", ".", "normally", "1", "-", "10" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Db/Manager.php#L99-L111
6,572
phossa2/libs
src/Phossa2/Db/Manager.php
Manager.getDriver
public function getDriver(/*# string */ $tag = '')/*# : DriverInterface */ { // match drivers $matched = $this->driverMatcher($tag); if (count($matched) > 0) { return $this->drivers[$matched[rand(1, count($matched)) - 1]]; } else { throw new NotFoundException( Message::get(Message::DB_DRIVER_NOTFOUND), Message::DB_DRIVER_NOTFOUND ); } }
php
public function getDriver(/*# string */ $tag = '')/*# : DriverInterface */ { // match drivers $matched = $this->driverMatcher($tag); if (count($matched) > 0) { return $this->drivers[$matched[rand(1, count($matched)) - 1]]; } else { throw new NotFoundException( Message::get(Message::DB_DRIVER_NOTFOUND), Message::DB_DRIVER_NOTFOUND ); } }
[ "public", "function", "getDriver", "(", "/*# string */", "$", "tag", "=", "''", ")", "/*# : DriverInterface */", "{", "// match drivers", "$", "matched", "=", "$", "this", "->", "driverMatcher", "(", "$", "tag", ")", ";", "if", "(", "count", "(", "$", "matched", ")", ">", "0", ")", "{", "return", "$", "this", "->", "drivers", "[", "$", "matched", "[", "rand", "(", "1", ",", "count", "(", "$", "matched", ")", ")", "-", "1", "]", "]", ";", "}", "else", "{", "throw", "new", "NotFoundException", "(", "Message", "::", "get", "(", "Message", "::", "DB_DRIVER_NOTFOUND", ")", ",", "Message", "::", "DB_DRIVER_NOTFOUND", ")", ";", "}", "}" ]
Get a driver with a tag matched {@inheritDoc}
[ "Get", "a", "driver", "with", "a", "tag", "matched" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Db/Manager.php#L118-L131
6,573
phossa2/libs
src/Phossa2/Db/Manager.php
Manager.driverMatcher
protected function driverMatcher(/*# string */ $tag)/*# : array */ { $matched = []; foreach ($this->drivers as $id => $driver) { if ($this->tagMatched($tag, $driver) && $this->pingDriver($driver)) { $this->expandWithFactor($matched, $id); } } return $matched; }
php
protected function driverMatcher(/*# string */ $tag)/*# : array */ { $matched = []; foreach ($this->drivers as $id => $driver) { if ($this->tagMatched($tag, $driver) && $this->pingDriver($driver)) { $this->expandWithFactor($matched, $id); } } return $matched; }
[ "protected", "function", "driverMatcher", "(", "/*# string */", "$", "tag", ")", "/*# : array */", "{", "$", "matched", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "drivers", "as", "$", "id", "=>", "$", "driver", ")", "{", "if", "(", "$", "this", "->", "tagMatched", "(", "$", "tag", ",", "$", "driver", ")", "&&", "$", "this", "->", "pingDriver", "(", "$", "driver", ")", ")", "{", "$", "this", "->", "expandWithFactor", "(", "$", "matched", ",", "$", "id", ")", ";", "}", "}", "return", "$", "matched", ";", "}" ]
Match drivers with tag @param string $tag tag to match @return array @access protected
[ "Match", "drivers", "with", "tag" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Db/Manager.php#L165-L174
6,574
naturalweb/FileStorage
src/NaturalWeb/FileStorage/Storage/FileSystemStorage.php
FileSystemStorage.copyDir
private function copyDir($from, $to) { mkdir($to, 0777, true); $items = new FilesystemIterator($from); foreach ($items as $item) { $pattern = preg_quote($from, "/"); $Key = preg_replace("/^{$pattern}/", "", $item); $subFrom = strval($item); $subTo = $to.$Key; if (filetype($item) == 'dir') { $this->copyDir($subFrom, $subTo); } else { $this->copyFile($subFrom, $subTo); } } return true; }
php
private function copyDir($from, $to) { mkdir($to, 0777, true); $items = new FilesystemIterator($from); foreach ($items as $item) { $pattern = preg_quote($from, "/"); $Key = preg_replace("/^{$pattern}/", "", $item); $subFrom = strval($item); $subTo = $to.$Key; if (filetype($item) == 'dir') { $this->copyDir($subFrom, $subTo); } else { $this->copyFile($subFrom, $subTo); } } return true; }
[ "private", "function", "copyDir", "(", "$", "from", ",", "$", "to", ")", "{", "mkdir", "(", "$", "to", ",", "0777", ",", "true", ")", ";", "$", "items", "=", "new", "FilesystemIterator", "(", "$", "from", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "pattern", "=", "preg_quote", "(", "$", "from", ",", "\"/\"", ")", ";", "$", "Key", "=", "preg_replace", "(", "\"/^{$pattern}/\"", ",", "\"\"", ",", "$", "item", ")", ";", "$", "subFrom", "=", "strval", "(", "$", "item", ")", ";", "$", "subTo", "=", "$", "to", ".", "$", "Key", ";", "if", "(", "filetype", "(", "$", "item", ")", "==", "'dir'", ")", "{", "$", "this", "->", "copyDir", "(", "$", "subFrom", ",", "$", "subTo", ")", ";", "}", "else", "{", "$", "this", "->", "copyFile", "(", "$", "subFrom", ",", "$", "subTo", ")", ";", "}", "}", "return", "true", ";", "}" ]
Copy Directory Recursive @param string $from Path From @param string $to Path To @return bool @access private
[ "Copy", "Directory", "Recursive" ]
3d2c9b0187685da8fc71bdf08456da8732f751dd
https://github.com/naturalweb/FileStorage/blob/3d2c9b0187685da8fc71bdf08456da8732f751dd/src/NaturalWeb/FileStorage/Storage/FileSystemStorage.php#L283-L306
6,575
digitalicagroup/slack-hook-framework
lib/SlackHookFramework/AbstractCommand.php
AbstractCommand.post
public function post() { $json = $this->result->toJson (); $this->log->debug ( "AbstractCommand (" . get_class ( $this ) . "): response json: $json" ); $result = Util::post ( $this->config->slack_webhook_url, $json ); if (! $result) { $this->log->error ( "AbstractCommand: Error sending json: $json to slack hook: " . $this->config->slack_webhook_url ); } return $result; }
php
public function post() { $json = $this->result->toJson (); $this->log->debug ( "AbstractCommand (" . get_class ( $this ) . "): response json: $json" ); $result = Util::post ( $this->config->slack_webhook_url, $json ); if (! $result) { $this->log->error ( "AbstractCommand: Error sending json: $json to slack hook: " . $this->config->slack_webhook_url ); } return $result; }
[ "public", "function", "post", "(", ")", "{", "$", "json", "=", "$", "this", "->", "result", "->", "toJson", "(", ")", ";", "$", "this", "->", "log", "->", "debug", "(", "\"AbstractCommand (\"", ".", "get_class", "(", "$", "this", ")", ".", "\"): response json: $json\"", ")", ";", "$", "result", "=", "Util", "::", "post", "(", "$", "this", "->", "config", "->", "slack_webhook_url", ",", "$", "json", ")", ";", "if", "(", "!", "$", "result", ")", "{", "$", "this", "->", "log", "->", "error", "(", "\"AbstractCommand: Error sending json: $json to slack hook: \"", ".", "$", "this", "->", "config", "->", "slack_webhook_url", ")", ";", "}", "return", "$", "result", ";", "}" ]
Post the SlackResult json representation to the Slack Incoming WebHook.
[ "Post", "the", "SlackResult", "json", "representation", "to", "the", "Slack", "Incoming", "WebHook", "." ]
b2357275d6042e49cb082e375716effd4c001ee0
https://github.com/digitalicagroup/slack-hook-framework/blob/b2357275d6042e49cb082e375716effd4c001ee0/lib/SlackHookFramework/AbstractCommand.php#L117-L125
6,576
vinala/kernel
src/Lumos/Commands/NewViewCommand.php
NewViewCommand.name
private function name($extra) { $file = $extra[0]; $file = str_replace('.', '/', $file); // switch ($extra[1]) { case 'smarty': $extention = '.tpl.php'; break; case 'atom': $extention = '.atom'; break; default: $extention = '.php'; break; } return $file.$extention; }
php
private function name($extra) { $file = $extra[0]; $file = str_replace('.', '/', $file); // switch ($extra[1]) { case 'smarty': $extention = '.tpl.php'; break; case 'atom': $extention = '.atom'; break; default: $extention = '.php'; break; } return $file.$extention; }
[ "private", "function", "name", "(", "$", "extra", ")", "{", "$", "file", "=", "$", "extra", "[", "0", "]", ";", "$", "file", "=", "str_replace", "(", "'.'", ",", "'/'", ",", "$", "file", ")", ";", "//", "switch", "(", "$", "extra", "[", "1", "]", ")", "{", "case", "'smarty'", ":", "$", "extention", "=", "'.tpl.php'", ";", "break", ";", "case", "'atom'", ":", "$", "extention", "=", "'.atom'", ";", "break", ";", "default", ":", "$", "extention", "=", "'.php'", ";", "break", ";", "}", "return", "$", "file", ".", "$", "extention", ";", "}" ]
Get the path , name , and type of view. @param string $name @return string
[ "Get", "the", "path", "name", "and", "type", "of", "view", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands/NewViewCommand.php#L96-L108
6,577
dzegarra/jsonrpcsmd
src/Greplab/Jsonrpcsmd/Smd/Parameter.php
Parameter.toArray
public function toArray() { return array( //'name' => $this->param->getName(), 'optional' => $this->param->isOptional(), 'default' => $this->param->isDefaultValueAvailable() ? $this->param->getDefaultValue() : null ); }
php
public function toArray() { return array( //'name' => $this->param->getName(), 'optional' => $this->param->isOptional(), 'default' => $this->param->isDefaultValueAvailable() ? $this->param->getDefaultValue() : null ); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array", "(", "//'name' => $this->param->getName(),", "'optional'", "=>", "$", "this", "->", "param", "->", "isOptional", "(", ")", ",", "'default'", "=>", "$", "this", "->", "param", "->", "isDefaultValueAvailable", "(", ")", "?", "$", "this", "->", "param", "->", "getDefaultValue", "(", ")", ":", "null", ")", ";", "}" ]
Return a representation of the current param. @return array
[ "Return", "a", "representation", "of", "the", "current", "param", "." ]
2f423b575d34d9ef2370495b89b9efd96f0cd30b
https://github.com/dzegarra/jsonrpcsmd/blob/2f423b575d34d9ef2370495b89b9efd96f0cd30b/src/Greplab/Jsonrpcsmd/Smd/Parameter.php#L36-L43
6,578
easy-system/es-system
src/System.php
System.init
public static function init(array $config = [], $devMode = false) { if (static::$instance instanceof static) { return; } $system = static::$instance = new static(); $system->devMode = (bool) $devMode; $services = $system->getServices(); $services->set('System', $system); $items = []; if (isset($config['components'])) { $items = (array) $config['components']; } $components = $system->getComponents(); foreach ($items as $index => $item) { $config['components'][$index] = $components->register($item); } $systemConfig = new SystemConfig($config); $services->set('Config', $systemConfig); $listeners = new Listeners(); $services->set('Listeners', $listeners); $events = new Events(); $services->set('Events', $events); $components->init($services, $listeners, $events, $systemConfig); $events->trigger($system->getEvent()); return $system; }
php
public static function init(array $config = [], $devMode = false) { if (static::$instance instanceof static) { return; } $system = static::$instance = new static(); $system->devMode = (bool) $devMode; $services = $system->getServices(); $services->set('System', $system); $items = []; if (isset($config['components'])) { $items = (array) $config['components']; } $components = $system->getComponents(); foreach ($items as $index => $item) { $config['components'][$index] = $components->register($item); } $systemConfig = new SystemConfig($config); $services->set('Config', $systemConfig); $listeners = new Listeners(); $services->set('Listeners', $listeners); $events = new Events(); $services->set('Events', $events); $components->init($services, $listeners, $events, $systemConfig); $events->trigger($system->getEvent()); return $system; }
[ "public", "static", "function", "init", "(", "array", "$", "config", "=", "[", "]", ",", "$", "devMode", "=", "false", ")", "{", "if", "(", "static", "::", "$", "instance", "instanceof", "static", ")", "{", "return", ";", "}", "$", "system", "=", "static", "::", "$", "instance", "=", "new", "static", "(", ")", ";", "$", "system", "->", "devMode", "=", "(", "bool", ")", "$", "devMode", ";", "$", "services", "=", "$", "system", "->", "getServices", "(", ")", ";", "$", "services", "->", "set", "(", "'System'", ",", "$", "system", ")", ";", "$", "items", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "config", "[", "'components'", "]", ")", ")", "{", "$", "items", "=", "(", "array", ")", "$", "config", "[", "'components'", "]", ";", "}", "$", "components", "=", "$", "system", "->", "getComponents", "(", ")", ";", "foreach", "(", "$", "items", "as", "$", "index", "=>", "$", "item", ")", "{", "$", "config", "[", "'components'", "]", "[", "$", "index", "]", "=", "$", "components", "->", "register", "(", "$", "item", ")", ";", "}", "$", "systemConfig", "=", "new", "SystemConfig", "(", "$", "config", ")", ";", "$", "services", "->", "set", "(", "'Config'", ",", "$", "systemConfig", ")", ";", "$", "listeners", "=", "new", "Listeners", "(", ")", ";", "$", "services", "->", "set", "(", "'Listeners'", ",", "$", "listeners", ")", ";", "$", "events", "=", "new", "Events", "(", ")", ";", "$", "services", "->", "set", "(", "'Events'", ",", "$", "events", ")", ";", "$", "components", "->", "init", "(", "$", "services", ",", "$", "listeners", ",", "$", "events", ",", "$", "systemConfig", ")", ";", "$", "events", "->", "trigger", "(", "$", "system", "->", "getEvent", "(", ")", ")", ";", "return", "$", "system", ";", "}" ]
Initializes system. Returns an instance of the system only once at initialization. @param array $config Optional; the system configuration @param bool $devMode Optional; false by default. The system mode @return self|void Returns the instance of System only once
[ "Initializes", "system", ".", "Returns", "an", "instance", "of", "the", "system", "only", "once", "at", "initialization", "." ]
750632b7a57f8c65d98c61cd0c29d2da3a9a04cc
https://github.com/easy-system/es-system/blob/750632b7a57f8c65d98c61cd0c29d2da3a9a04cc/src/System.php#L63-L98
6,579
easy-system/es-system
src/System.php
System.run
public function run() { $services = $this->getServices(); $events = $services->get('Events'); $event = $this->getEvent(); $event->setContext($this); $course = [ SystemEvent::BOOTSTRAP, SystemEvent::ROUTE, SystemEvent::DISPATCH, SystemEvent::RENDER, ]; try { foreach ($course as $eventName) { if ($event->getResult(SystemEvent::FINISH)) { break; } $events->trigger($event($eventName)); } $events->trigger($event(SystemEvent::FINISH)); } catch (Error $ex) { $error = new ErrorEvent(ErrorEvent::FATAL_ERROR, $ex, $this); $events->trigger($error); } catch (Exception $ex) { $error = new ErrorEvent(ErrorEvent::FATAL_ERROR, $ex, $this); $events->trigger($error); } }
php
public function run() { $services = $this->getServices(); $events = $services->get('Events'); $event = $this->getEvent(); $event->setContext($this); $course = [ SystemEvent::BOOTSTRAP, SystemEvent::ROUTE, SystemEvent::DISPATCH, SystemEvent::RENDER, ]; try { foreach ($course as $eventName) { if ($event->getResult(SystemEvent::FINISH)) { break; } $events->trigger($event($eventName)); } $events->trigger($event(SystemEvent::FINISH)); } catch (Error $ex) { $error = new ErrorEvent(ErrorEvent::FATAL_ERROR, $ex, $this); $events->trigger($error); } catch (Exception $ex) { $error = new ErrorEvent(ErrorEvent::FATAL_ERROR, $ex, $this); $events->trigger($error); } }
[ "public", "function", "run", "(", ")", "{", "$", "services", "=", "$", "this", "->", "getServices", "(", ")", ";", "$", "events", "=", "$", "services", "->", "get", "(", "'Events'", ")", ";", "$", "event", "=", "$", "this", "->", "getEvent", "(", ")", ";", "$", "event", "->", "setContext", "(", "$", "this", ")", ";", "$", "course", "=", "[", "SystemEvent", "::", "BOOTSTRAP", ",", "SystemEvent", "::", "ROUTE", ",", "SystemEvent", "::", "DISPATCH", ",", "SystemEvent", "::", "RENDER", ",", "]", ";", "try", "{", "foreach", "(", "$", "course", "as", "$", "eventName", ")", "{", "if", "(", "$", "event", "->", "getResult", "(", "SystemEvent", "::", "FINISH", ")", ")", "{", "break", ";", "}", "$", "events", "->", "trigger", "(", "$", "event", "(", "$", "eventName", ")", ")", ";", "}", "$", "events", "->", "trigger", "(", "$", "event", "(", "SystemEvent", "::", "FINISH", ")", ")", ";", "}", "catch", "(", "Error", "$", "ex", ")", "{", "$", "error", "=", "new", "ErrorEvent", "(", "ErrorEvent", "::", "FATAL_ERROR", ",", "$", "ex", ",", "$", "this", ")", ";", "$", "events", "->", "trigger", "(", "$", "error", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "$", "error", "=", "new", "ErrorEvent", "(", "ErrorEvent", "::", "FATAL_ERROR", ",", "$", "ex", ",", "$", "this", ")", ";", "$", "events", "->", "trigger", "(", "$", "error", ")", ";", "}", "}" ]
Runs system.
[ "Runs", "system", "." ]
750632b7a57f8c65d98c61cd0c29d2da3a9a04cc
https://github.com/easy-system/es-system/blob/750632b7a57f8c65d98c61cd0c29d2da3a9a04cc/src/System.php#L113-L144
6,580
phpthinktank/blast-config
src/Factory.php
Factory.create
public function create($repository) { //if repository is a string //given repository should be a valid directory path if (is_string($repository)) { //clear stat cache to avoid loading cached files, //which where unlinked in system clearstatcache(TRUE); if (!is_dir($repository)) { throw new FileNotFoundException($repository); } $repository = new FilesystemRepository($repository); } //if there is no valid instance cancel creation if (!($repository instanceof FilesystemRepository)) { throw new \RuntimeException(sprintf('Expected instance of FilesystemRepository. %s given', get_class($repository))); } $locator = new Locator($repository); return $locator; }
php
public function create($repository) { //if repository is a string //given repository should be a valid directory path if (is_string($repository)) { //clear stat cache to avoid loading cached files, //which where unlinked in system clearstatcache(TRUE); if (!is_dir($repository)) { throw new FileNotFoundException($repository); } $repository = new FilesystemRepository($repository); } //if there is no valid instance cancel creation if (!($repository instanceof FilesystemRepository)) { throw new \RuntimeException(sprintf('Expected instance of FilesystemRepository. %s given', get_class($repository))); } $locator = new Locator($repository); return $locator; }
[ "public", "function", "create", "(", "$", "repository", ")", "{", "//if repository is a string", "//given repository should be a valid directory path", "if", "(", "is_string", "(", "$", "repository", ")", ")", "{", "//clear stat cache to avoid loading cached files,", "//which where unlinked in system", "clearstatcache", "(", "TRUE", ")", ";", "if", "(", "!", "is_dir", "(", "$", "repository", ")", ")", "{", "throw", "new", "FileNotFoundException", "(", "$", "repository", ")", ";", "}", "$", "repository", "=", "new", "FilesystemRepository", "(", "$", "repository", ")", ";", "}", "//if there is no valid instance cancel creation", "if", "(", "!", "(", "$", "repository", "instanceof", "FilesystemRepository", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Expected instance of FilesystemRepository. %s given'", ",", "get_class", "(", "$", "repository", ")", ")", ")", ";", "}", "$", "locator", "=", "new", "Locator", "(", "$", "repository", ")", ";", "return", "$", "locator", ";", "}" ]
Create locator from repository. Repository could be a FilesystemRepository or a valid path @param string|FilesystemRepository $repository @return Locator
[ "Create", "locator", "from", "repository", ".", "Repository", "could", "be", "a", "FilesystemRepository", "or", "a", "valid", "path" ]
ffa9645425091c7f0da115f1181c195dce2a5393
https://github.com/phpthinktank/blast-config/blob/ffa9645425091c7f0da115f1181c195dce2a5393/src/Factory.php#L26-L50
6,581
phpthinktank/blast-config
src/Factory.php
Factory.load
public function load($path, LocatorInterface $locator, array $loaders = [], array $config = []) { $resource = $locator->locate($path); if(count($loaders) < 1){ $loaders = [ new PhpLoader(), new JsonLoader() ]; } foreach($loaders as $loader){ if(pathinfo($resource->getPath(), PATHINFO_EXTENSION) !== $loader->getExtension()){ continue; } $config = $loader->load($resource); break; } return $config; }
php
public function load($path, LocatorInterface $locator, array $loaders = [], array $config = []) { $resource = $locator->locate($path); if(count($loaders) < 1){ $loaders = [ new PhpLoader(), new JsonLoader() ]; } foreach($loaders as $loader){ if(pathinfo($resource->getPath(), PATHINFO_EXTENSION) !== $loader->getExtension()){ continue; } $config = $loader->load($resource); break; } return $config; }
[ "public", "function", "load", "(", "$", "path", ",", "LocatorInterface", "$", "locator", ",", "array", "$", "loaders", "=", "[", "]", ",", "array", "$", "config", "=", "[", "]", ")", "{", "$", "resource", "=", "$", "locator", "->", "locate", "(", "$", "path", ")", ";", "if", "(", "count", "(", "$", "loaders", ")", "<", "1", ")", "{", "$", "loaders", "=", "[", "new", "PhpLoader", "(", ")", ",", "new", "JsonLoader", "(", ")", "]", ";", "}", "foreach", "(", "$", "loaders", "as", "$", "loader", ")", "{", "if", "(", "pathinfo", "(", "$", "resource", "->", "getPath", "(", ")", ",", "PATHINFO_EXTENSION", ")", "!==", "$", "loader", "->", "getExtension", "(", ")", ")", "{", "continue", ";", "}", "$", "config", "=", "$", "loader", "->", "load", "(", "$", "resource", ")", ";", "break", ";", "}", "return", "$", "config", ";", "}" ]
Load configuration from locator @param string $path Path to configuration, relative to configured locator repository path e.g. /config/config.php @param LocatorInterface $locator @param LoaderInterface[] $loaders If is empty, PhpLoader and JsonLoader is loading by default @param array $config Default configuration, overwrite by found config @return array
[ "Load", "configuration", "from", "locator" ]
ffa9645425091c7f0da115f1181c195dce2a5393
https://github.com/phpthinktank/blast-config/blob/ffa9645425091c7f0da115f1181c195dce2a5393/src/Factory.php#L60-L81
6,582
pdenis/SnideTravinizerBundle
Helper/GithubHelper.php
GithubHelper.getRawFileUrl
public function getRawFileUrl($slug, $branch, $path) { return sprintf( '%s/%s/%s/%s', $this->rawHost, $slug, $branch, $path ); }
php
public function getRawFileUrl($slug, $branch, $path) { return sprintf( '%s/%s/%s/%s', $this->rawHost, $slug, $branch, $path ); }
[ "public", "function", "getRawFileUrl", "(", "$", "slug", ",", "$", "branch", ",", "$", "path", ")", "{", "return", "sprintf", "(", "'%s/%s/%s/%s'", ",", "$", "this", "->", "rawHost", ",", "$", "slug", ",", "$", "branch", ",", "$", "path", ")", ";", "}" ]
Get repository raw file @param string $slug Repository slug @param string $branch Repository branch @param string $path File path @return string
[ "Get", "repository", "raw", "file" ]
53a6fd647280d81a496018d379e4b5c446f81729
https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Helper/GithubHelper.php#L64-L73
6,583
glynnforrest/reform
src/Reform/Helper/Html.php
Html.attributes
public static function attributes(array $attributes = array()) { $text = array(); foreach ($attributes as $key => $value) { //if we have numeric keys (e.g. checked), set the value as //the $key (e.g. checked="checked"), but only if it //doesn't exist already if (is_numeric($key)) { $value = htmlspecialchars($value); if (!isset($attributes[$value])) { $text[] = $value . '="' . $value . '"'; } continue; } $text[] = $key . '="' . htmlspecialchars($value) . '"'; } return empty($text) ? '' : ' ' . implode(' ', $text); }
php
public static function attributes(array $attributes = array()) { $text = array(); foreach ($attributes as $key => $value) { //if we have numeric keys (e.g. checked), set the value as //the $key (e.g. checked="checked"), but only if it //doesn't exist already if (is_numeric($key)) { $value = htmlspecialchars($value); if (!isset($attributes[$value])) { $text[] = $value . '="' . $value . '"'; } continue; } $text[] = $key . '="' . htmlspecialchars($value) . '"'; } return empty($text) ? '' : ' ' . implode(' ', $text); }
[ "public", "static", "function", "attributes", "(", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "text", "=", "array", "(", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "//if we have numeric keys (e.g. checked), set the value as", "//the $key (e.g. checked=\"checked\"), but only if it", "//doesn't exist already", "if", "(", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "value", "=", "htmlspecialchars", "(", "$", "value", ")", ";", "if", "(", "!", "isset", "(", "$", "attributes", "[", "$", "value", "]", ")", ")", "{", "$", "text", "[", "]", "=", "$", "value", ".", "'=\"'", ".", "$", "value", ".", "'\"'", ";", "}", "continue", ";", "}", "$", "text", "[", "]", "=", "$", "key", ".", "'=\"'", ".", "htmlspecialchars", "(", "$", "value", ")", ".", "'\"'", ";", "}", "return", "empty", "(", "$", "text", ")", "?", "''", ":", "' '", ".", "implode", "(", "' '", ",", "$", "text", ")", ";", "}" ]
Create a string of attributes to use in an HTML tag. @param array $attributes An array of keys and values @return string The attributes with a leading space
[ "Create", "a", "string", "of", "attributes", "to", "use", "in", "an", "HTML", "tag", "." ]
a2a33dfa73933875f9c1dd0691b21e678a541a9e
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Helper/Html.php#L18-L36
6,584
glynnforrest/reform
src/Reform/Helper/Html.php
Html.addToAttribute
public static function addToAttribute($attribute, $addition) { $new = array_unique(array_merge(explode(' ', $attribute), explode(' ', $addition))); //strip out any empty strings from extra whitespace between values //e.g. class=" foo bar baz " $new = array_filter($new, function($value) { return $value !== ''; }); return implode(' ', $new); }
php
public static function addToAttribute($attribute, $addition) { $new = array_unique(array_merge(explode(' ', $attribute), explode(' ', $addition))); //strip out any empty strings from extra whitespace between values //e.g. class=" foo bar baz " $new = array_filter($new, function($value) { return $value !== ''; }); return implode(' ', $new); }
[ "public", "static", "function", "addToAttribute", "(", "$", "attribute", ",", "$", "addition", ")", "{", "$", "new", "=", "array_unique", "(", "array_merge", "(", "explode", "(", "' '", ",", "$", "attribute", ")", ",", "explode", "(", "' '", ",", "$", "addition", ")", ")", ")", ";", "//strip out any empty strings from extra whitespace between values", "//e.g. class=\" foo bar baz \"", "$", "new", "=", "array_filter", "(", "$", "new", ",", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "''", ";", "}", ")", ";", "return", "implode", "(", "' '", ",", "$", "new", ")", ";", "}" ]
Add to the value of an attribute, checking for duplicates. This could be used to add css classes when css classes already exist. @param string $attribute The value of the attribute @param string $addition The text to add
[ "Add", "to", "the", "value", "of", "an", "attribute", "checking", "for", "duplicates", ".", "This", "could", "be", "used", "to", "add", "css", "classes", "when", "css", "classes", "already", "exist", "." ]
a2a33dfa73933875f9c1dd0691b21e678a541a9e
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Helper/Html.php#L46-L57
6,585
glynnforrest/reform
src/Reform/Helper/Html.php
Html.addToAttributeArray
public static function addToAttributeArray(array $attributes, $name, $addition) { $attribute = isset($attributes[$name]) ? $attributes[$name] : ''; $attributes[$name] = self::addToAttribute($attribute, $addition); return $attributes; }
php
public static function addToAttributeArray(array $attributes, $name, $addition) { $attribute = isset($attributes[$name]) ? $attributes[$name] : ''; $attributes[$name] = self::addToAttribute($attribute, $addition); return $attributes; }
[ "public", "static", "function", "addToAttributeArray", "(", "array", "$", "attributes", ",", "$", "name", ",", "$", "addition", ")", "{", "$", "attribute", "=", "isset", "(", "$", "attributes", "[", "$", "name", "]", ")", "?", "$", "attributes", "[", "$", "name", "]", ":", "''", ";", "$", "attributes", "[", "$", "name", "]", "=", "self", "::", "addToAttribute", "(", "$", "attribute", ",", "$", "addition", ")", ";", "return", "$", "attributes", ";", "}" ]
Add to the value of an attribute in an array of attributes. The attribute will be created if it doesn't exist. @param array $attributes The attributes @param string $name The name of the attribute to add to @param string $addition The text to add
[ "Add", "to", "the", "value", "of", "an", "attribute", "in", "an", "array", "of", "attributes", ".", "The", "attribute", "will", "be", "created", "if", "it", "doesn", "t", "exist", "." ]
a2a33dfa73933875f9c1dd0691b21e678a541a9e
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Helper/Html.php#L67-L73
6,586
glynnforrest/reform
src/Reform/Helper/Html.php
Html.tag
public static function tag($tag, $content = null, array $attributes = array()) { return self::openTag($tag, $attributes) . $content . self::closeTag($tag); }
php
public static function tag($tag, $content = null, array $attributes = array()) { return self::openTag($tag, $attributes) . $content . self::closeTag($tag); }
[ "public", "static", "function", "tag", "(", "$", "tag", ",", "$", "content", "=", "null", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "return", "self", "::", "openTag", "(", "$", "tag", ",", "$", "attributes", ")", ".", "$", "content", ".", "self", "::", "closeTag", "(", "$", "tag", ")", ";", "}" ]
Create an HTML tag. @param string $tag The name of the tag @param string $content The HTML content of the tag @param array $attributes An array of html attributes @return string The tag
[ "Create", "an", "HTML", "tag", "." ]
a2a33dfa73933875f9c1dd0691b21e678a541a9e
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Helper/Html.php#L106-L109
6,587
glynnforrest/reform
src/Reform/Helper/Html.php
Html.label
public static function label($for, $content = null, array $attributes = array()) { $attributes = array_merge(array('for' => $for), $attributes); return self::tag('label', $content, $attributes); }
php
public static function label($for, $content = null, array $attributes = array()) { $attributes = array_merge(array('for' => $for), $attributes); return self::tag('label', $content, $attributes); }
[ "public", "static", "function", "label", "(", "$", "for", ",", "$", "content", "=", "null", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "attributes", "=", "array_merge", "(", "array", "(", "'for'", "=>", "$", "for", ")", ",", "$", "attributes", ")", ";", "return", "self", "::", "tag", "(", "'label'", ",", "$", "content", ",", "$", "attributes", ")", ";", "}" ]
Create a label tag. @param string $for The name of the input the label is for @param string $content The content of the label, if any @param array $attributes An array of html attributes @return string The label tag
[ "Create", "a", "label", "tag", "." ]
a2a33dfa73933875f9c1dd0691b21e678a541a9e
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Helper/Html.php#L213-L218
6,588
novuso/common
src/Application/Service/ServiceContainer.php
ServiceContainer.set
public function set(string $name, callable $callback): void { $this->services[$name] = function ($c) use ($callback) { static $object; if ($object === null) { $object = $callback($c); } return $object; }; }
php
public function set(string $name, callable $callback): void { $this->services[$name] = function ($c) use ($callback) { static $object; if ($object === null) { $object = $callback($c); } return $object; }; }
[ "public", "function", "set", "(", "string", "$", "name", ",", "callable", "$", "callback", ")", ":", "void", "{", "$", "this", "->", "services", "[", "$", "name", "]", "=", "function", "(", "$", "c", ")", "use", "(", "$", "callback", ")", "{", "static", "$", "object", ";", "if", "(", "$", "object", "===", "null", ")", "{", "$", "object", "=", "$", "callback", "(", "$", "c", ")", ";", "}", "return", "$", "object", ";", "}", ";", "}" ]
Defines a shared service @param string $name The service name @param callable $callback The service factory callback @return void
[ "Defines", "a", "shared", "service" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Service/ServiceContainer.php#L53-L64
6,589
novuso/common
src/Application/Service/ServiceContainer.php
ServiceContainer.get
public function get($name) { if (!isset($this->services[$name])) { throw ServiceNotFoundException::fromName($name); } return $this->services[$name]($this); }
php
public function get($name) { if (!isset($this->services[$name])) { throw ServiceNotFoundException::fromName($name); } return $this->services[$name]($this); }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "services", "[", "$", "name", "]", ")", ")", "{", "throw", "ServiceNotFoundException", "::", "fromName", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "services", "[", "$", "name", "]", "(", "$", "this", ")", ";", "}" ]
Retrieves a service by name @param string $name The service name @return mixed @throws ServiceNotFoundException When the service is not found
[ "Retrieves", "a", "service", "by", "name" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Service/ServiceContainer.php#L75-L82
6,590
novuso/common
src/Application/Service/ServiceContainer.php
ServiceContainer.hasParameter
public function hasParameter(string $name): bool { return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters); }
php
public function hasParameter(string $name): bool { return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters); }
[ "public", "function", "hasParameter", "(", "string", "$", "name", ")", ":", "bool", "{", "return", "isset", "(", "$", "this", "->", "parameters", "[", "$", "name", "]", ")", "||", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "parameters", ")", ";", "}" ]
Checks if a parameter exists @param string $name The parameter name @return bool
[ "Checks", "if", "a", "parameter", "exists" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Service/ServiceContainer.php#L145-L148
6,591
dlin-me/geocoder
src/Dlin/Geocoder/Geocoder.php
Geocoder.forward
public function forward($address, $countryCode=null){ $attempt = 0; while( $this->getCurrentGeocoding() && $attempt <= count($this->sourceConfig)){ if($parsedAddress = $this->getCurrentGeocoding()->forward($address, $countryCode)){ return $parsedAddress; }else{ $this->setCurrentGeocoding($this->getNextGeocoding()); } $attempt++; } return null; }
php
public function forward($address, $countryCode=null){ $attempt = 0; while( $this->getCurrentGeocoding() && $attempt <= count($this->sourceConfig)){ if($parsedAddress = $this->getCurrentGeocoding()->forward($address, $countryCode)){ return $parsedAddress; }else{ $this->setCurrentGeocoding($this->getNextGeocoding()); } $attempt++; } return null; }
[ "public", "function", "forward", "(", "$", "address", ",", "$", "countryCode", "=", "null", ")", "{", "$", "attempt", "=", "0", ";", "while", "(", "$", "this", "->", "getCurrentGeocoding", "(", ")", "&&", "$", "attempt", "<=", "count", "(", "$", "this", "->", "sourceConfig", ")", ")", "{", "if", "(", "$", "parsedAddress", "=", "$", "this", "->", "getCurrentGeocoding", "(", ")", "->", "forward", "(", "$", "address", ",", "$", "countryCode", ")", ")", "{", "return", "$", "parsedAddress", ";", "}", "else", "{", "$", "this", "->", "setCurrentGeocoding", "(", "$", "this", "->", "getNextGeocoding", "(", ")", ")", ";", "}", "$", "attempt", "++", ";", "}", "return", "null", ";", "}" ]
Forward Geocoding is the process of taking a given location in address format and returning the closes known coordinates to the address provided. The address can be a country, county, city, state, zip code, street address, or any combination of these. @param $address @param $countryCode, optional country code (e.g. AU) to improve the accuracy for Google @return GeoAddress
[ "Forward", "Geocoding", "is", "the", "process", "of", "taking", "a", "given", "location", "in", "address", "format", "and", "returning", "the", "closes", "known", "coordinates", "to", "the", "address", "provided", ".", "The", "address", "can", "be", "a", "country", "county", "city", "state", "zip", "code", "street", "address", "or", "any", "combination", "of", "these", "." ]
50596ff3dcaccd95034e5799ae02fd1c753b5cd2
https://github.com/dlin-me/geocoder/blob/50596ff3dcaccd95034e5799ae02fd1c753b5cd2/src/Dlin/Geocoder/Geocoder.php#L138-L151
6,592
eix/core
src/php/main/Eix/Core/Responses/Http/Media/XslPage.php
XslPage.prepare
protected function prepare() { // Set data into dataDocument structure; if (is_array($this->data)) { foreach ($this->data as $key => $value) { $this->addData($key, $value); } } Logger::get()->debug("Response data:\n" . $this->dataDocument->toString(false)); // Merge data with template. $this->document = $this->dataDocument->transform($this->getTemplate()); }
php
protected function prepare() { // Set data into dataDocument structure; if (is_array($this->data)) { foreach ($this->data as $key => $value) { $this->addData($key, $value); } } Logger::get()->debug("Response data:\n" . $this->dataDocument->toString(false)); // Merge data with template. $this->document = $this->dataDocument->transform($this->getTemplate()); }
[ "protected", "function", "prepare", "(", ")", "{", "// Set data into dataDocument structure;", "if", "(", "is_array", "(", "$", "this", "->", "data", ")", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "addData", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "Logger", "::", "get", "(", ")", "->", "debug", "(", "\"Response data:\\n\"", ".", "$", "this", "->", "dataDocument", "->", "toString", "(", "false", ")", ")", ";", "// Merge data with template.", "$", "this", "->", "document", "=", "$", "this", "->", "dataDocument", "->", "transform", "(", "$", "this", "->", "getTemplate", "(", ")", ")", ";", "}" ]
Prepares the document by merging the template and the data.
[ "Prepares", "the", "document", "by", "merging", "the", "template", "and", "the", "data", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Responses/Http/Media/XslPage.php#L111-L124
6,593
strident/Trident
src/Trident/Component/Templating/Templating.php
Templating.render
public function render($template, array $parameters = array(), Response $response = null) { if ( ! $response instanceof Response) { $response = new Response(); } $response->setContent($this->engine->render($template, $parameters)); return $response; }
php
public function render($template, array $parameters = array(), Response $response = null) { if ( ! $response instanceof Response) { $response = new Response(); } $response->setContent($this->engine->render($template, $parameters)); return $response; }
[ "public", "function", "render", "(", "$", "template", ",", "array", "$", "parameters", "=", "array", "(", ")", ",", "Response", "$", "response", "=", "null", ")", "{", "if", "(", "!", "$", "response", "instanceof", "Response", ")", "{", "$", "response", "=", "new", "Response", "(", ")", ";", "}", "$", "response", "->", "setContent", "(", "$", "this", "->", "engine", "->", "render", "(", "$", "template", ",", "$", "parameters", ")", ")", ";", "return", "$", "response", ";", "}" ]
Render a template with the template engine @param string $template @param array $parameters @return Response
[ "Render", "a", "template", "with", "the", "template", "engine" ]
a112f0b75601b897c470a49d85791dc386c29952
https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Component/Templating/Templating.php#L37-L46
6,594
docit/core
src/Providers/RouteServiceProvider.php
RouteServiceProvider.map
public function map(Router $router) { $router->group([ 'prefix' => config('docit.base_route'), 'namespace' => $this->namespace ], function ($router) { require(realpath(__DIR__ . '/../Http/routes.php')); }); }
php
public function map(Router $router) { $router->group([ 'prefix' => config('docit.base_route'), 'namespace' => $this->namespace ], function ($router) { require(realpath(__DIR__ . '/../Http/routes.php')); }); }
[ "public", "function", "map", "(", "Router", "$", "router", ")", "{", "$", "router", "->", "group", "(", "[", "'prefix'", "=>", "config", "(", "'docit.base_route'", ")", ",", "'namespace'", "=>", "$", "this", "->", "namespace", "]", ",", "function", "(", "$", "router", ")", "{", "require", "(", "realpath", "(", "__DIR__", ".", "'/../Http/routes.php'", ")", ")", ";", "}", ")", ";", "}" ]
Define the routes for Docit. @param Illuminate\Routing\Router $router @return void
[ "Define", "the", "routes", "for", "Docit", "." ]
448e1cdca18a8ffb6c08430cad8d22162171ac35
https://github.com/docit/core/blob/448e1cdca18a8ffb6c08430cad8d22162171ac35/src/Providers/RouteServiceProvider.php#L53-L60
6,595
phox-pro/pulsar-core
src/app/Logic/ENV.php
ENV.set
public static function set(string $key, string $value, bool $to_file = true, bool $put = true, bool $set = true) { if ($to_file) { self::toFile($key, $value); } if ($put) { putenv("$key=$value"); } if ($set) { $_ENV[$key] = $value; } }
php
public static function set(string $key, string $value, bool $to_file = true, bool $put = true, bool $set = true) { if ($to_file) { self::toFile($key, $value); } if ($put) { putenv("$key=$value"); } if ($set) { $_ENV[$key] = $value; } }
[ "public", "static", "function", "set", "(", "string", "$", "key", ",", "string", "$", "value", ",", "bool", "$", "to_file", "=", "true", ",", "bool", "$", "put", "=", "true", ",", "bool", "$", "set", "=", "true", ")", "{", "if", "(", "$", "to_file", ")", "{", "self", "::", "toFile", "(", "$", "key", ",", "$", "value", ")", ";", "}", "if", "(", "$", "put", ")", "{", "putenv", "(", "\"$key=$value\"", ")", ";", "}", "if", "(", "$", "set", ")", "{", "$", "_ENV", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}" ]
Replaces the value of the env variable in the .env file @param string $key @param string $value @return bool If the file was overwritten, it returns true. When the error appears false
[ "Replaces", "the", "value", "of", "the", "env", "variable", "in", "the", ".", "env", "file" ]
fa9c66f6578180253a65c91edf422fc3c51b32ba
https://github.com/phox-pro/pulsar-core/blob/fa9c66f6578180253a65c91edf422fc3c51b32ba/src/app/Logic/ENV.php#L14-L27
6,596
EarthlingInteractive/PHPCMIPREST
lib/EarthIT/CMIPREST/RequestParser/Util.php
EarthIT_CMIPREST_RequestParser_Util.parseFilter2
public static function parseFilter2( array $requestFilters, EarthIT_Schema_ResourceClass $rc, EarthIT_Schema $schema ) { $filterComponents = array(); foreach( $requestFilters as $filter ) { $filterComponents[] = EarthIT_Storage_ItemFilters::parsePattern( $filter['fieldName'], $filter['pattern'], $rc, $schema, true ); } return EarthIT_Storage_ItemFilters::anded($filterComponents); }
php
public static function parseFilter2( array $requestFilters, EarthIT_Schema_ResourceClass $rc, EarthIT_Schema $schema ) { $filterComponents = array(); foreach( $requestFilters as $filter ) { $filterComponents[] = EarthIT_Storage_ItemFilters::parsePattern( $filter['fieldName'], $filter['pattern'], $rc, $schema, true ); } return EarthIT_Storage_ItemFilters::anded($filterComponents); }
[ "public", "static", "function", "parseFilter2", "(", "array", "$", "requestFilters", ",", "EarthIT_Schema_ResourceClass", "$", "rc", ",", "EarthIT_Schema", "$", "schema", ")", "{", "$", "filterComponents", "=", "array", "(", ")", ";", "foreach", "(", "$", "requestFilters", "as", "$", "filter", ")", "{", "$", "filterComponents", "[", "]", "=", "EarthIT_Storage_ItemFilters", "::", "parsePattern", "(", "$", "filter", "[", "'fieldName'", "]", ",", "$", "filter", "[", "'pattern'", "]", ",", "$", "rc", ",", "$", "schema", ",", "true", ")", ";", "}", "return", "EarthIT_Storage_ItemFilters", "::", "anded", "(", "$", "filterComponents", ")", ";", "}" ]
Better than the first one!
[ "Better", "than", "the", "first", "one!" ]
db0398ea4fc07fa62f2de9ba43f2f3137170d9f0
https://github.com/EarthlingInteractive/PHPCMIPREST/blob/db0398ea4fc07fa62f2de9ba43f2f3137170d9f0/lib/EarthIT/CMIPREST/RequestParser/Util.php#L106-L114
6,597
themichaelhall/bluemvc-core
src/Collections/UploadedFileCollection.php
UploadedFileCollection.get
public function get(string $name): ?UploadedFileInterface { if (!isset($this->uploadedFiles[$name])) { return null; } return $this->uploadedFiles[$name]; }
php
public function get(string $name): ?UploadedFileInterface { if (!isset($this->uploadedFiles[$name])) { return null; } return $this->uploadedFiles[$name]; }
[ "public", "function", "get", "(", "string", "$", "name", ")", ":", "?", "UploadedFileInterface", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "uploadedFiles", "[", "$", "name", "]", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "uploadedFiles", "[", "$", "name", "]", ";", "}" ]
Returns the uploaded file by name if it exists, null otherwise. @since 1.0.0 @param string $name The name. @return UploadedFileInterface|null The the uploaded file by name if it exists, null otherwise.
[ "Returns", "the", "uploaded", "file", "by", "name", "if", "it", "exists", "null", "otherwise", "." ]
cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680
https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Collections/UploadedFileCollection.php#L64-L71
6,598
themichaelhall/bluemvc-core
src/Collections/UploadedFileCollection.php
UploadedFileCollection.set
public function set(string $name, UploadedFileInterface $uploadedFile): void { $this->uploadedFiles[$name] = $uploadedFile; }
php
public function set(string $name, UploadedFileInterface $uploadedFile): void { $this->uploadedFiles[$name] = $uploadedFile; }
[ "public", "function", "set", "(", "string", "$", "name", ",", "UploadedFileInterface", "$", "uploadedFile", ")", ":", "void", "{", "$", "this", "->", "uploadedFiles", "[", "$", "name", "]", "=", "$", "uploadedFile", ";", "}" ]
Sets an uploaded file by name. @since 1.0.0 @param string $name The name. @param UploadedFileInterface $uploadedFile The uploaded file.
[ "Sets", "an", "uploaded", "file", "by", "name", "." ]
cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680
https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Collections/UploadedFileCollection.php#L113-L116
6,599
mtils/beetree
src/BeeTree/Eloquent/AdjacencyList/WholeTreeModelTrait.php
WholeTreeModelTrait.tree
public function tree($rootId, array $columns=[]) { $columns = $this->pickColumns($columns); $columnsId = $this->getColumnsCacheId($columns); if (isset($this->_hierachyCache[$columnsId][$rootId])) { return $this->_hierachyCache[$columnsId][$rootId]; } $result = $this->queryTree($rootId) ->get($this->toSelectColumns($columns)); $this->fillNodeCache($columnsId, $result); return $this->_rootNodeCache[$columnsId][$rootId]; }
php
public function tree($rootId, array $columns=[]) { $columns = $this->pickColumns($columns); $columnsId = $this->getColumnsCacheId($columns); if (isset($this->_hierachyCache[$columnsId][$rootId])) { return $this->_hierachyCache[$columnsId][$rootId]; } $result = $this->queryTree($rootId) ->get($this->toSelectColumns($columns)); $this->fillNodeCache($columnsId, $result); return $this->_rootNodeCache[$columnsId][$rootId]; }
[ "public", "function", "tree", "(", "$", "rootId", ",", "array", "$", "columns", "=", "[", "]", ")", "{", "$", "columns", "=", "$", "this", "->", "pickColumns", "(", "$", "columns", ")", ";", "$", "columnsId", "=", "$", "this", "->", "getColumnsCacheId", "(", "$", "columns", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_hierachyCache", "[", "$", "columnsId", "]", "[", "$", "rootId", "]", ")", ")", "{", "return", "$", "this", "->", "_hierachyCache", "[", "$", "columnsId", "]", "[", "$", "rootId", "]", ";", "}", "$", "result", "=", "$", "this", "->", "queryTree", "(", "$", "rootId", ")", "->", "get", "(", "$", "this", "->", "toSelectColumns", "(", "$", "columns", ")", ")", ";", "$", "this", "->", "fillNodeCache", "(", "$", "columnsId", ",", "$", "result", ")", ";", "return", "$", "this", "->", "_rootNodeCache", "[", "$", "columnsId", "]", "[", "$", "rootId", "]", ";", "}" ]
Retrieve a tree by its rootId @param mixed $rootId The id of its root node, which is the same as node->getRootId() @param array $columns (Optional) Determine which columns have to be fetched from persistence @return \BeeTree\NodeInterface
[ "Retrieve", "a", "tree", "by", "its", "rootId" ]
4a68fc94ec14d5faef773b1628c9060db7bf1ce2
https://github.com/mtils/beetree/blob/4a68fc94ec14d5faef773b1628c9060db7bf1ce2/src/BeeTree/Eloquent/AdjacencyList/WholeTreeModelTrait.php#L28-L45