id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
221,700
radphp/radphp
src/Utility/Inflection.php
Inflection.underscore
public static function underscore($word) { $word = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1_\2', $word); $word = preg_replace('/([a-z])([A-Z])/', '\1_\2', $word); return str_replace('-', '_', strtolower($word)); }
php
public static function underscore($word) { $word = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1_\2', $word); $word = preg_replace('/([a-z])([A-Z])/', '\1_\2', $word); return str_replace('-', '_', strtolower($word)); }
[ "public", "static", "function", "underscore", "(", "$", "word", ")", "{", "$", "word", "=", "preg_replace", "(", "'/([A-Z]+)([A-Z][a-z])/'", ",", "'\\1_\\2'", ",", "$", "word", ")", ";", "$", "word", "=", "preg_replace", "(", "'/([a-z])([A-Z])/'", ",", "'\\1_\\2'", ",", "$", "word", ")", ";", "return", "str_replace", "(", "'-'", ",", "'_'", ",", "strtolower", "(", "$", "word", ")", ")", ";", "}" ]
Make an underscored, lowercase form from the expression in the string. @param string $word @return mixed
[ "Make", "an", "underscored", "lowercase", "form", "from", "the", "expression", "in", "the", "string", "." ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Utility/Inflection.php#L51-L57
221,701
radphp/radphp
src/Network/Http/Response.php
Response.withNotModified
public function withNotModified() { return $this->withStatus(304) ->withoutHeader('Allow') ->withoutHeader('Content-Encoding') ->withoutHeader('Content-Language') ->withoutHeader('Content-Length') ->withoutHeader('Content-MD5') ->withoutHeader('Content-Type') ->withoutHeader('Last-Modified') ->withBody(new Stream('php://temp')); }
php
public function withNotModified() { return $this->withStatus(304) ->withoutHeader('Allow') ->withoutHeader('Content-Encoding') ->withoutHeader('Content-Language') ->withoutHeader('Content-Length') ->withoutHeader('Content-MD5') ->withoutHeader('Content-Type') ->withoutHeader('Last-Modified') ->withBody(new Stream('php://temp')); }
[ "public", "function", "withNotModified", "(", ")", "{", "return", "$", "this", "->", "withStatus", "(", "304", ")", "->", "withoutHeader", "(", "'Allow'", ")", "->", "withoutHeader", "(", "'Content-Encoding'", ")", "->", "withoutHeader", "(", "'Content-Language'", ")", "->", "withoutHeader", "(", "'Content-Length'", ")", "->", "withoutHeader", "(", "'Content-MD5'", ")", "->", "withoutHeader", "(", "'Content-Type'", ")", "->", "withoutHeader", "(", "'Last-Modified'", ")", "->", "withBody", "(", "new", "Stream", "(", "'php://temp'", ")", ")", ";", "}" ]
Sends a Not-Modified response @return Response
[ "Sends", "a", "Not", "-", "Modified", "response" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Response.php#L124-L135
221,702
radphp/radphp
src/Network/Http/Response.php
Response.withEtag
public function withEtag($hash, $weak = false) { return $this->withHeader('Etag', sprintf('%s"%s"', ($weak) ? 'W/' : null, $hash)); }
php
public function withEtag($hash, $weak = false) { return $this->withHeader('Etag', sprintf('%s"%s"', ($weak) ? 'W/' : null, $hash)); }
[ "public", "function", "withEtag", "(", "$", "hash", ",", "$", "weak", "=", "false", ")", "{", "return", "$", "this", "->", "withHeader", "(", "'Etag'", ",", "sprintf", "(", "'%s\"%s\"'", ",", "(", "$", "weak", ")", "?", "'W/'", ":", "null", ",", "$", "hash", ")", ")", ";", "}" ]
Set a custom ETag @param string $hash The unique hash that identifies this response @param bool $weak Whether the response is semantically the same as other with the same hash or not @return Response
[ "Set", "a", "custom", "ETag" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Response.php#L162-L165
221,703
radphp/radphp
src/Network/Http/Response.php
Response.sendHeaders
public function sendHeaders() { foreach ($this->getHeaders() as $name => $values) { foreach ($values as $value) { header(sprintf('%s: %s', $name, $value), false); } } return $this; }
php
public function sendHeaders() { foreach ($this->getHeaders() as $name => $values) { foreach ($values as $value) { header(sprintf('%s: %s', $name, $value), false); } } return $this; }
[ "public", "function", "sendHeaders", "(", ")", "{", "foreach", "(", "$", "this", "->", "getHeaders", "(", ")", "as", "$", "name", "=>", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "header", "(", "sprintf", "(", "'%s: %s'", ",", "$", "name", ",", "$", "value", ")", ",", "false", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Sends headers to the client @return Response
[ "Sends", "headers", "to", "the", "client" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Response.php#L192-L201
221,704
paquettg/leaguewrap
src/LeagueWrap/Dto/StaticData/SummonerSpellList.php
SummonerSpellList.getSpell
public function getSpell($spellId) { if (isset($this->info['data'][$spellId])) { return $this->info['data'][$spellId]; } return null; }
php
public function getSpell($spellId) { if (isset($this->info['data'][$spellId])) { return $this->info['data'][$spellId]; } return null; }
[ "public", "function", "getSpell", "(", "$", "spellId", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "info", "[", "'data'", "]", "[", "$", "spellId", "]", ")", ")", "{", "return", "$", "this", "->", "info", "[", "'data'", "]", "[", "$", "spellId", "]", ";", "}", "return", "null", ";", "}" ]
A quick short cut to get the summoner spells by id. @param int $spellId @return SummonerSpell|null
[ "A", "quick", "short", "cut", "to", "get", "the", "summoner", "spells", "by", "id", "." ]
0f91813b5d8292054e5e13619d591b6b14dc63e6
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Dto/StaticData/SummonerSpellList.php#L37-L45
221,705
CapMousse/React-Restify
src/Routing/Route.php
Route.where
public function where($param, $filter) { if (is_array($param)) { $this->filters = array_merge($this->filters, $param); return; } $this->filters[$param] = $filter; }
php
public function where($param, $filter) { if (is_array($param)) { $this->filters = array_merge($this->filters, $param); return; } $this->filters[$param] = $filter; }
[ "public", "function", "where", "(", "$", "param", ",", "$", "filter", ")", "{", "if", "(", "is_array", "(", "$", "param", ")", ")", "{", "$", "this", "->", "filters", "=", "array_merge", "(", "$", "this", "->", "filters", ",", "$", "param", ")", ";", "return", ";", "}", "$", "this", "->", "filters", "[", "$", "param", "]", "=", "$", "filter", ";", "}" ]
Create a new filter for current route @param String|array $param parameter to filter @param String $filter regexp to execute @return void
[ "Create", "a", "new", "filter", "for", "current", "route" ]
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Routing/Route.php#L65-L74
221,706
CapMousse/React-Restify
src/Routing/Route.php
Route.parse
public function parse() { preg_match_all("#\{(\w+)\}#", $this->uri, $params); $replace = []; foreach ($params[1] as $param) { $replace['{'.$param.'}'] = '(?<'.$param.'>'. (isset($this->filters[$param]) ? $this->filters[$param] : '[a-zA-Z+0-9-.]+') .')'; } $this->parsedRoute = str_replace(array_keys($replace), array_values($replace), $this->uri); }
php
public function parse() { preg_match_all("#\{(\w+)\}#", $this->uri, $params); $replace = []; foreach ($params[1] as $param) { $replace['{'.$param.'}'] = '(?<'.$param.'>'. (isset($this->filters[$param]) ? $this->filters[$param] : '[a-zA-Z+0-9-.]+') .')'; } $this->parsedRoute = str_replace(array_keys($replace), array_values($replace), $this->uri); }
[ "public", "function", "parse", "(", ")", "{", "preg_match_all", "(", "\"#\\{(\\w+)\\}#\"", ",", "$", "this", "->", "uri", ",", "$", "params", ")", ";", "$", "replace", "=", "[", "]", ";", "foreach", "(", "$", "params", "[", "1", "]", "as", "$", "param", ")", "{", "$", "replace", "[", "'{'", ".", "$", "param", ".", "'}'", "]", "=", "'(?<'", ".", "$", "param", ".", "'>'", ".", "(", "isset", "(", "$", "this", "->", "filters", "[", "$", "param", "]", ")", "?", "$", "this", "->", "filters", "[", "$", "param", "]", ":", "'[a-zA-Z+0-9-.]+'", ")", ".", "')'", ";", "}", "$", "this", "->", "parsedRoute", "=", "str_replace", "(", "array_keys", "(", "$", "replace", ")", ",", "array_values", "(", "$", "replace", ")", ",", "$", "this", "->", "uri", ")", ";", "}" ]
Parse route uri @return void
[ "Parse", "route", "uri" ]
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Routing/Route.php#L81-L91
221,707
CapMousse/React-Restify
src/Routing/Route.php
Route.match
public function match($path, $method) { if (!$this->isParsed()) $this->parse(); if (!preg_match('#'.$this->parsedRoute.'$#', $path)) return false; if (strtoupper($method) !== $this->method) return false; return true; }
php
public function match($path, $method) { if (!$this->isParsed()) $this->parse(); if (!preg_match('#'.$this->parsedRoute.'$#', $path)) return false; if (strtoupper($method) !== $this->method) return false; return true; }
[ "public", "function", "match", "(", "$", "path", ",", "$", "method", ")", "{", "if", "(", "!", "$", "this", "->", "isParsed", "(", ")", ")", "$", "this", "->", "parse", "(", ")", ";", "if", "(", "!", "preg_match", "(", "'#'", ".", "$", "this", "->", "parsedRoute", ".", "'$#'", ",", "$", "path", ")", ")", "return", "false", ";", "if", "(", "strtoupper", "(", "$", "method", ")", "!==", "$", "this", "->", "method", ")", "return", "false", ";", "return", "true", ";", "}" ]
Check if path match route uri @param String $path @param String $method @return bool
[ "Check", "if", "path", "match", "route", "uri" ]
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Routing/Route.php#L109-L117
221,708
CapMousse/React-Restify
src/Routing/Route.php
Route.getArgs
public function getArgs($path) { if (!$this->isParsed()) $this->parse(); $data = []; $args = []; preg_match('#'.$this->parsedRoute.'$#', $path, $data); foreach ($data as $name => $value) { if (is_int($name)) continue; $args[$name] = $value; } return $args; }
php
public function getArgs($path) { if (!$this->isParsed()) $this->parse(); $data = []; $args = []; preg_match('#'.$this->parsedRoute.'$#', $path, $data); foreach ($data as $name => $value) { if (is_int($name)) continue; $args[$name] = $value; } return $args; }
[ "public", "function", "getArgs", "(", "$", "path", ")", "{", "if", "(", "!", "$", "this", "->", "isParsed", "(", ")", ")", "$", "this", "->", "parse", "(", ")", ";", "$", "data", "=", "[", "]", ";", "$", "args", "=", "[", "]", ";", "preg_match", "(", "'#'", ".", "$", "this", "->", "parsedRoute", ".", "'$#'", ",", "$", "path", ",", "$", "data", ")", ";", "foreach", "(", "$", "data", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "is_int", "(", "$", "name", ")", ")", "continue", ";", "$", "args", "[", "$", "name", "]", "=", "$", "value", ";", "}", "return", "$", "args", ";", "}" ]
Parse route arguments @param String $path @return array
[ "Parse", "route", "arguments" ]
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Routing/Route.php#L124-L139
221,709
CapMousse/React-Restify
src/Routing/Route.php
Route.run
public function run(Callable $next, Request $request, Response $response) { $container = Container::getInstance(); $parameters = array_merge([ "request" => $request, "response" => $response, "next" => $next ], $request->getData()); try { $container->call($this->action, $parameters); $this->emit('after', [$request, $response, $this]); } catch (\Exception $e) { $this->emit('error', [$request, $response, $e->getMessage()]); } }
php
public function run(Callable $next, Request $request, Response $response) { $container = Container::getInstance(); $parameters = array_merge([ "request" => $request, "response" => $response, "next" => $next ], $request->getData()); try { $container->call($this->action, $parameters); $this->emit('after', [$request, $response, $this]); } catch (\Exception $e) { $this->emit('error', [$request, $response, $e->getMessage()]); } }
[ "public", "function", "run", "(", "Callable", "$", "next", ",", "Request", "$", "request", ",", "Response", "$", "response", ")", "{", "$", "container", "=", "Container", "::", "getInstance", "(", ")", ";", "$", "parameters", "=", "array_merge", "(", "[", "\"request\"", "=>", "$", "request", ",", "\"response\"", "=>", "$", "response", ",", "\"next\"", "=>", "$", "next", "]", ",", "$", "request", "->", "getData", "(", ")", ")", ";", "try", "{", "$", "container", "->", "call", "(", "$", "this", "->", "action", ",", "$", "parameters", ")", ";", "$", "this", "->", "emit", "(", "'after'", ",", "[", "$", "request", ",", "$", "response", ",", "$", "this", "]", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "emit", "(", "'error'", ",", "[", "$", "request", ",", "$", "response", ",", "$", "e", "->", "getMessage", "(", ")", "]", ")", ";", "}", "}" ]
Run the current route @param Callable $next @param \React\Http\Request $request @param \React\Restify\Response $response @return Void
[ "Run", "the", "current", "route" ]
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Routing/Route.php#L150-L165
221,710
adhocore/php-cron-expr
src/Expression.php
Expression.isCronDue
public function isCronDue($expr, $time = null) { list($expr, $times) = $this->process($expr, $time); foreach ($expr as $pos => $segment) { if ($segment === '*' || $segment === '?') { continue; } if (!$this->checker->checkDue($segment, $pos, $times)) { return false; } } return true; }
php
public function isCronDue($expr, $time = null) { list($expr, $times) = $this->process($expr, $time); foreach ($expr as $pos => $segment) { if ($segment === '*' || $segment === '?') { continue; } if (!$this->checker->checkDue($segment, $pos, $times)) { return false; } } return true; }
[ "public", "function", "isCronDue", "(", "$", "expr", ",", "$", "time", "=", "null", ")", "{", "list", "(", "$", "expr", ",", "$", "times", ")", "=", "$", "this", "->", "process", "(", "$", "expr", ",", "$", "time", ")", ";", "foreach", "(", "$", "expr", "as", "$", "pos", "=>", "$", "segment", ")", "{", "if", "(", "$", "segment", "===", "'*'", "||", "$", "segment", "===", "'?'", ")", "{", "continue", ";", "}", "if", "(", "!", "$", "this", "->", "checker", "->", "checkDue", "(", "$", "segment", ",", "$", "pos", ",", "$", "times", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Instance call. Parse cron expression to decide if it can be run on given time (or default now). @param string $expr The cron expression. @param mixed $time The timestamp to validate the cron expr against. Defaults to now. @return bool
[ "Instance", "call", "." ]
d7bfd342d62795a50ad6377964cf567eb727961a
https://github.com/adhocore/php-cron-expr/blob/d7bfd342d62795a50ad6377964cf567eb727961a/src/Expression.php#L120-L135
221,711
adhocore/php-cron-expr
src/Expression.php
Expression.filter
public function filter(array $jobs, $time = null) { $dues = $cache = []; $time = $this->normalizeTime($time); foreach ($jobs as $name => $expr) { $expr = $this->normalizeExpr($expr); if (!isset($cache[$expr])) { $cache[$expr] = $this->isCronDue($expr, $time); } if ($cache[$expr]) { $dues[] = $name; } } return $dues; }
php
public function filter(array $jobs, $time = null) { $dues = $cache = []; $time = $this->normalizeTime($time); foreach ($jobs as $name => $expr) { $expr = $this->normalizeExpr($expr); if (!isset($cache[$expr])) { $cache[$expr] = $this->isCronDue($expr, $time); } if ($cache[$expr]) { $dues[] = $name; } } return $dues; }
[ "public", "function", "filter", "(", "array", "$", "jobs", ",", "$", "time", "=", "null", ")", "{", "$", "dues", "=", "$", "cache", "=", "[", "]", ";", "$", "time", "=", "$", "this", "->", "normalizeTime", "(", "$", "time", ")", ";", "foreach", "(", "$", "jobs", "as", "$", "name", "=>", "$", "expr", ")", "{", "$", "expr", "=", "$", "this", "->", "normalizeExpr", "(", "$", "expr", ")", ";", "if", "(", "!", "isset", "(", "$", "cache", "[", "$", "expr", "]", ")", ")", "{", "$", "cache", "[", "$", "expr", "]", "=", "$", "this", "->", "isCronDue", "(", "$", "expr", ",", "$", "time", ")", ";", "}", "if", "(", "$", "cache", "[", "$", "expr", "]", ")", "{", "$", "dues", "[", "]", "=", "$", "name", ";", "}", "}", "return", "$", "dues", ";", "}" ]
Filter only the jobs that are due. @param array $jobs Jobs with cron exprs. [job1 => cron-expr1, job2 => cron-expr2, ...] @param mixed $time The timestamp to validate the cron expr against. Defaults to now. @return array Due job names: [job1name, ...];
[ "Filter", "only", "the", "jobs", "that", "are", "due", "." ]
d7bfd342d62795a50ad6377964cf567eb727961a
https://github.com/adhocore/php-cron-expr/blob/d7bfd342d62795a50ad6377964cf567eb727961a/src/Expression.php#L145-L163
221,712
adhocore/php-cron-expr
src/Expression.php
Expression.process
protected function process($expr, $time) { $expr = $this->normalizeExpr($expr); $expr = \str_ireplace(\array_keys(static::$literals), \array_values(static::$literals), $expr); $expr = \explode(' ', $expr); if (\count($expr) < 5 || \count($expr) > 6) { throw new \UnexpectedValueException( 'Cron $expr should have 5 or 6 segments delimited by space' ); } $time = static::normalizeTime($time); $times = \array_map('intval', \explode(' ', \date('i G j n w Y t d m N', $time))); return [$expr, $times]; }
php
protected function process($expr, $time) { $expr = $this->normalizeExpr($expr); $expr = \str_ireplace(\array_keys(static::$literals), \array_values(static::$literals), $expr); $expr = \explode(' ', $expr); if (\count($expr) < 5 || \count($expr) > 6) { throw new \UnexpectedValueException( 'Cron $expr should have 5 or 6 segments delimited by space' ); } $time = static::normalizeTime($time); $times = \array_map('intval', \explode(' ', \date('i G j n w Y t d m N', $time))); return [$expr, $times]; }
[ "protected", "function", "process", "(", "$", "expr", ",", "$", "time", ")", "{", "$", "expr", "=", "$", "this", "->", "normalizeExpr", "(", "$", "expr", ")", ";", "$", "expr", "=", "\\", "str_ireplace", "(", "\\", "array_keys", "(", "static", "::", "$", "literals", ")", ",", "\\", "array_values", "(", "static", "::", "$", "literals", ")", ",", "$", "expr", ")", ";", "$", "expr", "=", "\\", "explode", "(", "' '", ",", "$", "expr", ")", ";", "if", "(", "\\", "count", "(", "$", "expr", ")", "<", "5", "||", "\\", "count", "(", "$", "expr", ")", ">", "6", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Cron $expr should have 5 or 6 segments delimited by space'", ")", ";", "}", "$", "time", "=", "static", "::", "normalizeTime", "(", "$", "time", ")", ";", "$", "times", "=", "\\", "array_map", "(", "'intval'", ",", "\\", "explode", "(", "' '", ",", "\\", "date", "(", "'i G j n w Y t d m N'", ",", "$", "time", ")", ")", ")", ";", "return", "[", "$", "expr", ",", "$", "times", "]", ";", "}" ]
Process and prepare input. @param string $expr @param mixed $time @return array
[ "Process", "and", "prepare", "input", "." ]
d7bfd342d62795a50ad6377964cf567eb727961a
https://github.com/adhocore/php-cron-expr/blob/d7bfd342d62795a50ad6377964cf567eb727961a/src/Expression.php#L173-L189
221,713
CapMousse/React-Restify
src/Traits/WaterfallTrait.php
WaterfallTrait.callOnce
private function callOnce ($fn) { return function (...$args) use ($fn) { if ($fn === null) return; $fn(...$args); $fn = null; }; }
php
private function callOnce ($fn) { return function (...$args) use ($fn) { if ($fn === null) return; $fn(...$args); $fn = null; }; }
[ "private", "function", "callOnce", "(", "$", "fn", ")", "{", "return", "function", "(", "...", "$", "args", ")", "use", "(", "$", "fn", ")", "{", "if", "(", "$", "fn", "===", "null", ")", "return", ";", "$", "fn", "(", "...", "$", "args", ")", ";", "$", "fn", "=", "null", ";", "}", ";", "}" ]
Call callback one @param \Closure $fn @return \Closure
[ "Call", "callback", "one" ]
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Traits/WaterfallTrait.php#L12-L19
221,714
CapMousse/React-Restify
src/Traits/WaterfallTrait.php
WaterfallTrait.waterfall
private function waterfall (array $tasks, array $args) { $index = 0; $next = function () use (&$index, &$tasks, &$next, &$args) { if ($index == count($tasks)) { return; } $callback = $this->callOnce(function () use (&$next) { $next(); }); $tasks[$index++]($callback, ...$args); }; $next(); }
php
private function waterfall (array $tasks, array $args) { $index = 0; $next = function () use (&$index, &$tasks, &$next, &$args) { if ($index == count($tasks)) { return; } $callback = $this->callOnce(function () use (&$next) { $next(); }); $tasks[$index++]($callback, ...$args); }; $next(); }
[ "private", "function", "waterfall", "(", "array", "$", "tasks", ",", "array", "$", "args", ")", "{", "$", "index", "=", "0", ";", "$", "next", "=", "function", "(", ")", "use", "(", "&", "$", "index", ",", "&", "$", "tasks", ",", "&", "$", "next", ",", "&", "$", "args", ")", "{", "if", "(", "$", "index", "==", "count", "(", "$", "tasks", ")", ")", "{", "return", ";", "}", "$", "callback", "=", "$", "this", "->", "callOnce", "(", "function", "(", ")", "use", "(", "&", "$", "next", ")", "{", "$", "next", "(", ")", ";", "}", ")", ";", "$", "tasks", "[", "$", "index", "++", "]", "(", "$", "callback", ",", "...", "$", "args", ")", ";", "}", ";", "$", "next", "(", ")", ";", "}" ]
Run tasks in series @param \Closure[] $tasks @param array $args @return void
[ "Run", "tasks", "in", "series" ]
51fe94d6e4c7fafec06fb304f9e44badde4bfe71
https://github.com/CapMousse/React-Restify/blob/51fe94d6e4c7fafec06fb304f9e44badde4bfe71/src/Traits/WaterfallTrait.php#L27-L44
221,715
paquettg/leaguewrap
src/LeagueWrap/Api.php
Api.limit
public function limit($hits, $seconds, $region = 'all', LimitInterface $limit = null) { if (is_null($limit)) { // use the built in limit interface $limit = new Limit; } if ( ! $limit->isValid()) { // fall back to the file base limit handling $limit = new FileLimit; if ( ! $limit->isValid()) { throw new NoValidLimitInterfaceException("We could not load a valid limit interface."); } } if ($region == 'all') { foreach ([ 'br', 'eune', 'euw', 'kr', 'lan', 'las', 'na', 'oce', 'ru', 'tr'] as $region) { $newLimit = $limit->newInstance(); $newLimit->setRate($hits, $seconds, $region); $this->collection->addLimit($newLimit); } } else { // lower case the region $region = strtolower($region); $limit->setRate($hits, $seconds, $region); $this->collection->addLimit($limit); } return $this; }
php
public function limit($hits, $seconds, $region = 'all', LimitInterface $limit = null) { if (is_null($limit)) { // use the built in limit interface $limit = new Limit; } if ( ! $limit->isValid()) { // fall back to the file base limit handling $limit = new FileLimit; if ( ! $limit->isValid()) { throw new NoValidLimitInterfaceException("We could not load a valid limit interface."); } } if ($region == 'all') { foreach ([ 'br', 'eune', 'euw', 'kr', 'lan', 'las', 'na', 'oce', 'ru', 'tr'] as $region) { $newLimit = $limit->newInstance(); $newLimit->setRate($hits, $seconds, $region); $this->collection->addLimit($newLimit); } } else { // lower case the region $region = strtolower($region); $limit->setRate($hits, $seconds, $region); $this->collection->addLimit($limit); } return $this; }
[ "public", "function", "limit", "(", "$", "hits", ",", "$", "seconds", ",", "$", "region", "=", "'all'", ",", "LimitInterface", "$", "limit", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "limit", ")", ")", "{", "// use the built in limit interface", "$", "limit", "=", "new", "Limit", ";", "}", "if", "(", "!", "$", "limit", "->", "isValid", "(", ")", ")", "{", "// fall back to the file base limit handling", "$", "limit", "=", "new", "FileLimit", ";", "if", "(", "!", "$", "limit", "->", "isValid", "(", ")", ")", "{", "throw", "new", "NoValidLimitInterfaceException", "(", "\"We could not load a valid limit interface.\"", ")", ";", "}", "}", "if", "(", "$", "region", "==", "'all'", ")", "{", "foreach", "(", "[", "'br'", ",", "'eune'", ",", "'euw'", ",", "'kr'", ",", "'lan'", ",", "'las'", ",", "'na'", ",", "'oce'", ",", "'ru'", ",", "'tr'", "]", "as", "$", "region", ")", "{", "$", "newLimit", "=", "$", "limit", "->", "newInstance", "(", ")", ";", "$", "newLimit", "->", "setRate", "(", "$", "hits", ",", "$", "seconds", ",", "$", "region", ")", ";", "$", "this", "->", "collection", "->", "addLimit", "(", "$", "newLimit", ")", ";", "}", "}", "else", "{", "// lower case the region", "$", "region", "=", "strtolower", "(", "$", "region", ")", ";", "$", "limit", "->", "setRate", "(", "$", "hits", ",", "$", "seconds", ",", "$", "region", ")", ";", "$", "this", "->", "collection", "->", "addLimit", "(", "$", "limit", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets a limit to be added to the collection. @param int $hits @param int $seconds @param string $region @param LimitInterface $limit @return $this @throws NoValidLimitInterfaceException
[ "Sets", "a", "limit", "to", "be", "added", "to", "the", "collection", "." ]
0f91813b5d8292054e5e13619d591b6b14dc63e6
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api.php#L171-L216
221,716
neos/fluid
Classes/TYPO3/Fluid/Core/Parser/SyntaxTree/ViewHelperNode.php
ViewHelperNode.evaluate
public function evaluate(RenderingContextInterface $renderingContext) { if ($this->viewHelpersByContext->contains($renderingContext)) { $viewHelper = $this->viewHelpersByContext->offsetGet($renderingContext); $viewHelper->resetState(); } else { $viewHelper = clone $this->uninitializedViewHelper; $this->viewHelpersByContext->attach($renderingContext, $viewHelper); } $evaluatedArguments = array(); if (count($viewHelper->prepareArguments())) { /** @var $argumentDefinition ArgumentDefinition */ foreach ($viewHelper->prepareArguments() as $argumentName => $argumentDefinition) { if (isset($this->arguments[$argumentName])) { /** @var $argumentValue NodeInterface */ $argumentValue = $this->arguments[$argumentName]; $evaluatedArguments[$argumentName] = $argumentValue->evaluate($renderingContext); } else { $evaluatedArguments[$argumentName] = $argumentDefinition->getDefaultValue(); } } } $viewHelper->setArguments($evaluatedArguments); $viewHelper->setViewHelperNode($this); $viewHelper->setRenderingContext($renderingContext); if ($viewHelper instanceof ChildNodeAccessInterface) { $viewHelper->setChildNodes($this->childNodes); } $output = $viewHelper->initializeArgumentsAndRender(); return $output; }
php
public function evaluate(RenderingContextInterface $renderingContext) { if ($this->viewHelpersByContext->contains($renderingContext)) { $viewHelper = $this->viewHelpersByContext->offsetGet($renderingContext); $viewHelper->resetState(); } else { $viewHelper = clone $this->uninitializedViewHelper; $this->viewHelpersByContext->attach($renderingContext, $viewHelper); } $evaluatedArguments = array(); if (count($viewHelper->prepareArguments())) { /** @var $argumentDefinition ArgumentDefinition */ foreach ($viewHelper->prepareArguments() as $argumentName => $argumentDefinition) { if (isset($this->arguments[$argumentName])) { /** @var $argumentValue NodeInterface */ $argumentValue = $this->arguments[$argumentName]; $evaluatedArguments[$argumentName] = $argumentValue->evaluate($renderingContext); } else { $evaluatedArguments[$argumentName] = $argumentDefinition->getDefaultValue(); } } } $viewHelper->setArguments($evaluatedArguments); $viewHelper->setViewHelperNode($this); $viewHelper->setRenderingContext($renderingContext); if ($viewHelper instanceof ChildNodeAccessInterface) { $viewHelper->setChildNodes($this->childNodes); } $output = $viewHelper->initializeArgumentsAndRender(); return $output; }
[ "public", "function", "evaluate", "(", "RenderingContextInterface", "$", "renderingContext", ")", "{", "if", "(", "$", "this", "->", "viewHelpersByContext", "->", "contains", "(", "$", "renderingContext", ")", ")", "{", "$", "viewHelper", "=", "$", "this", "->", "viewHelpersByContext", "->", "offsetGet", "(", "$", "renderingContext", ")", ";", "$", "viewHelper", "->", "resetState", "(", ")", ";", "}", "else", "{", "$", "viewHelper", "=", "clone", "$", "this", "->", "uninitializedViewHelper", ";", "$", "this", "->", "viewHelpersByContext", "->", "attach", "(", "$", "renderingContext", ",", "$", "viewHelper", ")", ";", "}", "$", "evaluatedArguments", "=", "array", "(", ")", ";", "if", "(", "count", "(", "$", "viewHelper", "->", "prepareArguments", "(", ")", ")", ")", "{", "/** @var $argumentDefinition ArgumentDefinition */", "foreach", "(", "$", "viewHelper", "->", "prepareArguments", "(", ")", "as", "$", "argumentName", "=>", "$", "argumentDefinition", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "arguments", "[", "$", "argumentName", "]", ")", ")", "{", "/** @var $argumentValue NodeInterface */", "$", "argumentValue", "=", "$", "this", "->", "arguments", "[", "$", "argumentName", "]", ";", "$", "evaluatedArguments", "[", "$", "argumentName", "]", "=", "$", "argumentValue", "->", "evaluate", "(", "$", "renderingContext", ")", ";", "}", "else", "{", "$", "evaluatedArguments", "[", "$", "argumentName", "]", "=", "$", "argumentDefinition", "->", "getDefaultValue", "(", ")", ";", "}", "}", "}", "$", "viewHelper", "->", "setArguments", "(", "$", "evaluatedArguments", ")", ";", "$", "viewHelper", "->", "setViewHelperNode", "(", "$", "this", ")", ";", "$", "viewHelper", "->", "setRenderingContext", "(", "$", "renderingContext", ")", ";", "if", "(", "$", "viewHelper", "instanceof", "ChildNodeAccessInterface", ")", "{", "$", "viewHelper", "->", "setChildNodes", "(", "$", "this", "->", "childNodes", ")", ";", "}", "$", "output", "=", "$", "viewHelper", "->", "initializeArgumentsAndRender", "(", ")", ";", "return", "$", "output", ";", "}" ]
Call the view helper associated with this object. First, it evaluates the arguments of the view helper. If the view helper implements \TYPO3\Fluid\Core\ViewHelper\Facets\ChildNodeAccessInterface, it calls setChildNodes(array childNodes) on the view helper. Afterwards, checks that the view helper did not leave a variable lying around. @param RenderingContextInterface $renderingContext @return object evaluated node after the view helper has been called.
[ "Call", "the", "view", "helper", "associated", "with", "this", "object", "." ]
ded6be84a9487f7e0e204703a30b12d2c58c0efd
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/SyntaxTree/ViewHelperNode.php#L114-L149
221,717
neos/fluid
Classes/TYPO3/Fluid/ViewHelpers/CycleViewHelper.php
CycleViewHelper.render
public function render($values, $as) { if ($values === null) { return $this->renderChildren(); } if ($this->values === null) { $this->initializeValues($values); } if ($this->currentCycleIndex === null || $this->currentCycleIndex >= count($this->values)) { $this->currentCycleIndex = 0; } $currentValue = isset($this->values[$this->currentCycleIndex]) ? $this->values[$this->currentCycleIndex] : null; $this->templateVariableContainer->add($as, $currentValue); $output = $this->renderChildren(); $this->templateVariableContainer->remove($as); $this->currentCycleIndex++; return $output; }
php
public function render($values, $as) { if ($values === null) { return $this->renderChildren(); } if ($this->values === null) { $this->initializeValues($values); } if ($this->currentCycleIndex === null || $this->currentCycleIndex >= count($this->values)) { $this->currentCycleIndex = 0; } $currentValue = isset($this->values[$this->currentCycleIndex]) ? $this->values[$this->currentCycleIndex] : null; $this->templateVariableContainer->add($as, $currentValue); $output = $this->renderChildren(); $this->templateVariableContainer->remove($as); $this->currentCycleIndex++; return $output; }
[ "public", "function", "render", "(", "$", "values", ",", "$", "as", ")", "{", "if", "(", "$", "values", "===", "null", ")", "{", "return", "$", "this", "->", "renderChildren", "(", ")", ";", "}", "if", "(", "$", "this", "->", "values", "===", "null", ")", "{", "$", "this", "->", "initializeValues", "(", "$", "values", ")", ";", "}", "if", "(", "$", "this", "->", "currentCycleIndex", "===", "null", "||", "$", "this", "->", "currentCycleIndex", ">=", "count", "(", "$", "this", "->", "values", ")", ")", "{", "$", "this", "->", "currentCycleIndex", "=", "0", ";", "}", "$", "currentValue", "=", "isset", "(", "$", "this", "->", "values", "[", "$", "this", "->", "currentCycleIndex", "]", ")", "?", "$", "this", "->", "values", "[", "$", "this", "->", "currentCycleIndex", "]", ":", "null", ";", "$", "this", "->", "templateVariableContainer", "->", "add", "(", "$", "as", ",", "$", "currentValue", ")", ";", "$", "output", "=", "$", "this", "->", "renderChildren", "(", ")", ";", "$", "this", "->", "templateVariableContainer", "->", "remove", "(", "$", "as", ")", ";", "$", "this", "->", "currentCycleIndex", "++", ";", "return", "$", "output", ";", "}" ]
Renders cycle view helper @param array $values The array or object implementing \ArrayAccess (for example \SplObjectStorage) to iterated over @param string $as The name of the iteration variable @return string Rendered result @api
[ "Renders", "cycle", "view", "helper" ]
ded6be84a9487f7e0e204703a30b12d2c58c0efd
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/ViewHelpers/CycleViewHelper.php#L82-L102
221,718
paquettg/leaguewrap
src/LeagueWrap/Api/ConfigTrait.php
ConfigTrait.setRegion
public function setRegion($region) { if ( ! $region instanceof Region) { $region = new Region($region); } $this->region = $region; return $this; }
php
public function setRegion($region) { if ( ! $region instanceof Region) { $region = new Region($region); } $this->region = $region; return $this; }
[ "public", "function", "setRegion", "(", "$", "region", ")", "{", "if", "(", "!", "$", "region", "instanceof", "Region", ")", "{", "$", "region", "=", "new", "Region", "(", "$", "region", ")", ";", "}", "$", "this", "->", "region", "=", "$", "region", ";", "return", "$", "this", ";", "}" ]
Set the region code to a valid string. @param string|Region $region @return $this
[ "Set", "the", "region", "code", "to", "a", "valid", "string", "." ]
0f91813b5d8292054e5e13619d591b6b14dc63e6
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/ConfigTrait.php#L64-L73
221,719
paquettg/leaguewrap
src/LeagueWrap/Api/ConfigTrait.php
ConfigTrait.attachStaticData
public function attachStaticData($attach = true, Staticdata $static = null) { $this->attachStaticData = $attach; $this->staticData = $static; return $this; }
php
public function attachStaticData($attach = true, Staticdata $static = null) { $this->attachStaticData = $attach; $this->staticData = $static; return $this; }
[ "public", "function", "attachStaticData", "(", "$", "attach", "=", "true", ",", "Staticdata", "$", "static", "=", "null", ")", "{", "$", "this", "->", "attachStaticData", "=", "$", "attach", ";", "$", "this", "->", "staticData", "=", "$", "static", ";", "return", "$", "this", ";", "}" ]
Set wether to attach static data to the response. @param bool $attach @param StaticData $static @return $this
[ "Set", "wether", "to", "attach", "static", "data", "to", "the", "response", "." ]
0f91813b5d8292054e5e13619d591b6b14dc63e6
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/ConfigTrait.php#L139-L145
221,720
radphp/radphp
src/Core/Bundles.php
Bundles.loadAll
public static function loadAll(array $bundles) { foreach ($bundles as $bundle) { if (!$bundle instanceof BundleInterface) { throw new InvalidArgumentException('Bundle must be instance of "Rad\Core\BundleInterface".'); } self::load($bundle); } }
php
public static function loadAll(array $bundles) { foreach ($bundles as $bundle) { if (!$bundle instanceof BundleInterface) { throw new InvalidArgumentException('Bundle must be instance of "Rad\Core\BundleInterface".'); } self::load($bundle); } }
[ "public", "static", "function", "loadAll", "(", "array", "$", "bundles", ")", "{", "foreach", "(", "$", "bundles", "as", "$", "bundle", ")", "{", "if", "(", "!", "$", "bundle", "instanceof", "BundleInterface", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Bundle must be instance of \"Rad\\Core\\BundleInterface\".'", ")", ";", "}", "self", "::", "load", "(", "$", "bundle", ")", ";", "}", "}" ]
Load all bundles @param array $bundles @throws MissingBundleException
[ "Load", "all", "bundles" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Core/Bundles.php#L60-L69
221,721
radphp/radphp
src/Core/Bundles.php
Bundles.isLoaded
public static function isLoaded($bundleName) { $bundleName = Inflection::camelize($bundleName); return isset(self::$bundlesLoaded[$bundleName]); }
php
public static function isLoaded($bundleName) { $bundleName = Inflection::camelize($bundleName); return isset(self::$bundlesLoaded[$bundleName]); }
[ "public", "static", "function", "isLoaded", "(", "$", "bundleName", ")", "{", "$", "bundleName", "=", "Inflection", "::", "camelize", "(", "$", "bundleName", ")", ";", "return", "isset", "(", "self", "::", "$", "bundlesLoaded", "[", "$", "bundleName", "]", ")", ";", "}" ]
Check bundle is loaded @param string $bundleName Bundle name @return bool
[ "Check", "bundle", "is", "loaded" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Core/Bundles.php#L78-L83
221,722
radphp/radphp
src/Core/Bundles.php
Bundles.getNamespace
public static function getNamespace($bundleName) { if (isset(self::$bundlesLoaded[$bundleName])) { return self::$bundlesLoaded[$bundleName]['namespace']; } throw new MissingBundleException(sprintf('Bundle "%s" could not be found.', $bundleName)); }
php
public static function getNamespace($bundleName) { if (isset(self::$bundlesLoaded[$bundleName])) { return self::$bundlesLoaded[$bundleName]['namespace']; } throw new MissingBundleException(sprintf('Bundle "%s" could not be found.', $bundleName)); }
[ "public", "static", "function", "getNamespace", "(", "$", "bundleName", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "bundlesLoaded", "[", "$", "bundleName", "]", ")", ")", "{", "return", "self", "::", "$", "bundlesLoaded", "[", "$", "bundleName", "]", "[", "'namespace'", "]", ";", "}", "throw", "new", "MissingBundleException", "(", "sprintf", "(", "'Bundle \"%s\" could not be found.'", ",", "$", "bundleName", ")", ")", ";", "}" ]
Get bundle namespace @param string $bundleName Bundle name @return string @throws MissingBundleException
[ "Get", "bundle", "namespace" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Core/Bundles.php#L103-L110
221,723
radphp/radphp
src/Core/Bundles.php
Bundles.getPath
public static function getPath($bundleName) { if (isset(self::$bundlesLoaded[$bundleName])) { return self::$bundlesLoaded[$bundleName]['path']; } throw new MissingBundleException(sprintf('Bundle "%s" could not be found.', $bundleName)); }
php
public static function getPath($bundleName) { if (isset(self::$bundlesLoaded[$bundleName])) { return self::$bundlesLoaded[$bundleName]['path']; } throw new MissingBundleException(sprintf('Bundle "%s" could not be found.', $bundleName)); }
[ "public", "static", "function", "getPath", "(", "$", "bundleName", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "bundlesLoaded", "[", "$", "bundleName", "]", ")", ")", "{", "return", "self", "::", "$", "bundlesLoaded", "[", "$", "bundleName", "]", "[", "'path'", "]", ";", "}", "throw", "new", "MissingBundleException", "(", "sprintf", "(", "'Bundle \"%s\" could not be found.'", ",", "$", "bundleName", ")", ")", ";", "}" ]
Get bundle path @param string $bundleName Bundle name @return string @throws MissingBundleException
[ "Get", "bundle", "path" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Core/Bundles.php#L120-L127
221,724
neos/fluid
Classes/TYPO3/Fluid/ViewHelpers/GroupedForViewHelper.php
GroupedForViewHelper.groupElements
protected function groupElements(array $elements, $groupBy) { $groups = array('keys' => array(), 'values' => array()); foreach ($elements as $key => $value) { if (is_array($value)) { $currentGroupIndex = isset($value[$groupBy]) ? $value[$groupBy] : null; } elseif (is_object($value)) { $currentGroupIndex = ObjectAccess::getPropertyPath($value, $groupBy); } else { throw new ViewHelper\Exception('GroupedForViewHelper only supports multi-dimensional arrays and objects', 1253120365); } $currentGroupKeyValue = $currentGroupIndex; if ($currentGroupIndex instanceof \DateTimeInterface) { $currentGroupIndex = $currentGroupIndex->format(\DateTime::RFC850); } elseif (is_object($currentGroupIndex)) { $currentGroupIndex = spl_object_hash($currentGroupIndex); } $groups['keys'][$currentGroupIndex] = $currentGroupKeyValue; $groups['values'][$currentGroupIndex][$key] = $value; } return $groups; }
php
protected function groupElements(array $elements, $groupBy) { $groups = array('keys' => array(), 'values' => array()); foreach ($elements as $key => $value) { if (is_array($value)) { $currentGroupIndex = isset($value[$groupBy]) ? $value[$groupBy] : null; } elseif (is_object($value)) { $currentGroupIndex = ObjectAccess::getPropertyPath($value, $groupBy); } else { throw new ViewHelper\Exception('GroupedForViewHelper only supports multi-dimensional arrays and objects', 1253120365); } $currentGroupKeyValue = $currentGroupIndex; if ($currentGroupIndex instanceof \DateTimeInterface) { $currentGroupIndex = $currentGroupIndex->format(\DateTime::RFC850); } elseif (is_object($currentGroupIndex)) { $currentGroupIndex = spl_object_hash($currentGroupIndex); } $groups['keys'][$currentGroupIndex] = $currentGroupKeyValue; $groups['values'][$currentGroupIndex][$key] = $value; } return $groups; }
[ "protected", "function", "groupElements", "(", "array", "$", "elements", ",", "$", "groupBy", ")", "{", "$", "groups", "=", "array", "(", "'keys'", "=>", "array", "(", ")", ",", "'values'", "=>", "array", "(", ")", ")", ";", "foreach", "(", "$", "elements", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "currentGroupIndex", "=", "isset", "(", "$", "value", "[", "$", "groupBy", "]", ")", "?", "$", "value", "[", "$", "groupBy", "]", ":", "null", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "currentGroupIndex", "=", "ObjectAccess", "::", "getPropertyPath", "(", "$", "value", ",", "$", "groupBy", ")", ";", "}", "else", "{", "throw", "new", "ViewHelper", "\\", "Exception", "(", "'GroupedForViewHelper only supports multi-dimensional arrays and objects'", ",", "1253120365", ")", ";", "}", "$", "currentGroupKeyValue", "=", "$", "currentGroupIndex", ";", "if", "(", "$", "currentGroupIndex", "instanceof", "\\", "DateTimeInterface", ")", "{", "$", "currentGroupIndex", "=", "$", "currentGroupIndex", "->", "format", "(", "\\", "DateTime", "::", "RFC850", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "currentGroupIndex", ")", ")", "{", "$", "currentGroupIndex", "=", "spl_object_hash", "(", "$", "currentGroupIndex", ")", ";", "}", "$", "groups", "[", "'keys'", "]", "[", "$", "currentGroupIndex", "]", "=", "$", "currentGroupKeyValue", ";", "$", "groups", "[", "'values'", "]", "[", "$", "currentGroupIndex", "]", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "groups", ";", "}" ]
Groups the given array by the specified groupBy property. @param array $elements The array / traversable object to be grouped @param string $groupBy Group by this property @return array The grouped array in the form array('keys' => array('key1' => [key1value], 'key2' => [key2value], ...), 'values' => array('key1' => array([key1value] => [element1]), ...), ...) @throws ViewHelper\Exception
[ "Groups", "the", "given", "array", "by", "the", "specified", "groupBy", "property", "." ]
ded6be84a9487f7e0e204703a30b12d2c58c0efd
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/ViewHelpers/GroupedForViewHelper.php#L130-L151
221,725
paquettg/leaguewrap
src/LeagueWrap/Dto/PlayerStatsSummaryList.php
PlayerStatsSummaryList.playerStat
public function playerStat($playerStatId) { if ( ! isset($this->info['playerStatSummaries'][$playerStatId])) { return null; } return $this->info['playerStatSummaries'][$playerStatId]; }
php
public function playerStat($playerStatId) { if ( ! isset($this->info['playerStatSummaries'][$playerStatId])) { return null; } return $this->info['playerStatSummaries'][$playerStatId]; }
[ "public", "function", "playerStat", "(", "$", "playerStatId", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "info", "[", "'playerStatSummaries'", "]", "[", "$", "playerStatId", "]", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "info", "[", "'playerStatSummaries'", "]", "[", "$", "playerStatId", "]", ";", "}" ]
Get the playerstat but the id in the response. @param int $playerStatId @return PlayerStatsSummary|null
[ "Get", "the", "playerstat", "but", "the", "id", "in", "the", "response", "." ]
0f91813b5d8292054e5e13619d591b6b14dc63e6
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Dto/PlayerStatsSummaryList.php#L33-L41
221,726
neos/fluid
Classes/TYPO3/Fluid/View/StandaloneView.php
StandaloneView.getLayoutRootPath
public function getLayoutRootPath() { if ($this->layoutRootPath === null && $this->templatePathAndFilename === null) { throw new Exception\InvalidTemplateResourceException('No layout root path has been specified. Use setLayoutRootPath().', 1288091419); } if ($this->layoutRootPath === null) { $this->layoutRootPath = dirname($this->templatePathAndFilename) . '/Layouts'; } return $this->layoutRootPath; }
php
public function getLayoutRootPath() { if ($this->layoutRootPath === null && $this->templatePathAndFilename === null) { throw new Exception\InvalidTemplateResourceException('No layout root path has been specified. Use setLayoutRootPath().', 1288091419); } if ($this->layoutRootPath === null) { $this->layoutRootPath = dirname($this->templatePathAndFilename) . '/Layouts'; } return $this->layoutRootPath; }
[ "public", "function", "getLayoutRootPath", "(", ")", "{", "if", "(", "$", "this", "->", "layoutRootPath", "===", "null", "&&", "$", "this", "->", "templatePathAndFilename", "===", "null", ")", "{", "throw", "new", "Exception", "\\", "InvalidTemplateResourceException", "(", "'No layout root path has been specified. Use setLayoutRootPath().'", ",", "1288091419", ")", ";", "}", "if", "(", "$", "this", "->", "layoutRootPath", "===", "null", ")", "{", "$", "this", "->", "layoutRootPath", "=", "dirname", "(", "$", "this", "->", "templatePathAndFilename", ")", ".", "'/Layouts'", ";", "}", "return", "$", "this", "->", "layoutRootPath", ";", "}" ]
Returns the absolute path to the folder that contains Fluid layout files @return string Fluid layout root path @throws Exception\InvalidTemplateResourceException @api
[ "Returns", "the", "absolute", "path", "to", "the", "folder", "that", "contains", "Fluid", "layout", "files" ]
ded6be84a9487f7e0e204703a30b12d2c58c0efd
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/View/StandaloneView.php#L201-L210
221,727
neos/fluid
Classes/TYPO3/Fluid/View/StandaloneView.php
StandaloneView.getPartialRootPath
public function getPartialRootPath() { if ($this->partialRootPath === null && $this->templatePathAndFilename === null) { throw new Exception\InvalidTemplateResourceException('No partial root path has been specified. Use setPartialRootPath().', 1288094511); } if ($this->partialRootPath === null) { $this->partialRootPath = dirname($this->templatePathAndFilename) . '/Partials'; } return $this->partialRootPath; }
php
public function getPartialRootPath() { if ($this->partialRootPath === null && $this->templatePathAndFilename === null) { throw new Exception\InvalidTemplateResourceException('No partial root path has been specified. Use setPartialRootPath().', 1288094511); } if ($this->partialRootPath === null) { $this->partialRootPath = dirname($this->templatePathAndFilename) . '/Partials'; } return $this->partialRootPath; }
[ "public", "function", "getPartialRootPath", "(", ")", "{", "if", "(", "$", "this", "->", "partialRootPath", "===", "null", "&&", "$", "this", "->", "templatePathAndFilename", "===", "null", ")", "{", "throw", "new", "Exception", "\\", "InvalidTemplateResourceException", "(", "'No partial root path has been specified. Use setPartialRootPath().'", ",", "1288094511", ")", ";", "}", "if", "(", "$", "this", "->", "partialRootPath", "===", "null", ")", "{", "$", "this", "->", "partialRootPath", "=", "dirname", "(", "$", "this", "->", "templatePathAndFilename", ")", ".", "'/Partials'", ";", "}", "return", "$", "this", "->", "partialRootPath", ";", "}" ]
Returns the absolute path to the folder that contains Fluid partial files @return string Fluid partial root path @throws Exception\InvalidTemplateResourceException @api
[ "Returns", "the", "absolute", "path", "to", "the", "folder", "that", "contains", "Fluid", "partial", "files" ]
ded6be84a9487f7e0e204703a30b12d2c58c0efd
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/View/StandaloneView.php#L231-L240
221,728
neos/fluid
Classes/TYPO3/Fluid/View/StandaloneView.php
StandaloneView.getTemplateSource
protected function getTemplateSource($actionName = null) { if ($this->templateSource === null && $this->templatePathAndFilename === null) { throw new Exception\InvalidTemplateResourceException('No template has been specified. Use either setTemplateSource() or setTemplatePathAndFilename().', 1288085266); } if ($this->templateSource === null) { if (!is_file($this->templatePathAndFilename)) { throw new Exception\InvalidTemplateResourceException('Template could not be found at "' . $this->templatePathAndFilename . '".', 1288087061); } $this->templateSource = file_get_contents($this->templatePathAndFilename); } return $this->templateSource; }
php
protected function getTemplateSource($actionName = null) { if ($this->templateSource === null && $this->templatePathAndFilename === null) { throw new Exception\InvalidTemplateResourceException('No template has been specified. Use either setTemplateSource() or setTemplatePathAndFilename().', 1288085266); } if ($this->templateSource === null) { if (!is_file($this->templatePathAndFilename)) { throw new Exception\InvalidTemplateResourceException('Template could not be found at "' . $this->templatePathAndFilename . '".', 1288087061); } $this->templateSource = file_get_contents($this->templatePathAndFilename); } return $this->templateSource; }
[ "protected", "function", "getTemplateSource", "(", "$", "actionName", "=", "null", ")", "{", "if", "(", "$", "this", "->", "templateSource", "===", "null", "&&", "$", "this", "->", "templatePathAndFilename", "===", "null", ")", "{", "throw", "new", "Exception", "\\", "InvalidTemplateResourceException", "(", "'No template has been specified. Use either setTemplateSource() or setTemplatePathAndFilename().'", ",", "1288085266", ")", ";", "}", "if", "(", "$", "this", "->", "templateSource", "===", "null", ")", "{", "if", "(", "!", "is_file", "(", "$", "this", "->", "templatePathAndFilename", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidTemplateResourceException", "(", "'Template could not be found at \"'", ".", "$", "this", "->", "templatePathAndFilename", ".", "'\".'", ",", "1288087061", ")", ";", "}", "$", "this", "->", "templateSource", "=", "file_get_contents", "(", "$", "this", "->", "templatePathAndFilename", ")", ";", "}", "return", "$", "this", "->", "templateSource", ";", "}" ]
Returns the Fluid template source code @param string $actionName Name of the action. This argument is not used in this view! @return string Fluid template source @throws Exception\InvalidTemplateResourceException
[ "Returns", "the", "Fluid", "template", "source", "code" ]
ded6be84a9487f7e0e204703a30b12d2c58c0efd
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/View/StandaloneView.php#L294-L306
221,729
neos/fluid
Classes/TYPO3/Fluid/ViewHelpers/Validation/ResultsViewHelper.php
ResultsViewHelper.render
public function render($for = '', $as = 'validationResults') { $request = $this->controllerContext->getRequest(); /** @var $validationResults Result */ $validationResults = $request->getInternalArgument('__submittedArgumentValidationResults'); if ($validationResults !== null && $for !== '') { $validationResults = $validationResults->forProperty($for); } $this->templateVariableContainer->add($as, $validationResults); $output = $this->renderChildren(); $this->templateVariableContainer->remove($as); return $output; }
php
public function render($for = '', $as = 'validationResults') { $request = $this->controllerContext->getRequest(); /** @var $validationResults Result */ $validationResults = $request->getInternalArgument('__submittedArgumentValidationResults'); if ($validationResults !== null && $for !== '') { $validationResults = $validationResults->forProperty($for); } $this->templateVariableContainer->add($as, $validationResults); $output = $this->renderChildren(); $this->templateVariableContainer->remove($as); return $output; }
[ "public", "function", "render", "(", "$", "for", "=", "''", ",", "$", "as", "=", "'validationResults'", ")", "{", "$", "request", "=", "$", "this", "->", "controllerContext", "->", "getRequest", "(", ")", ";", "/** @var $validationResults Result */", "$", "validationResults", "=", "$", "request", "->", "getInternalArgument", "(", "'__submittedArgumentValidationResults'", ")", ";", "if", "(", "$", "validationResults", "!==", "null", "&&", "$", "for", "!==", "''", ")", "{", "$", "validationResults", "=", "$", "validationResults", "->", "forProperty", "(", "$", "for", ")", ";", "}", "$", "this", "->", "templateVariableContainer", "->", "add", "(", "$", "as", ",", "$", "validationResults", ")", ";", "$", "output", "=", "$", "this", "->", "renderChildren", "(", ")", ";", "$", "this", "->", "templateVariableContainer", "->", "remove", "(", "$", "as", ")", ";", "return", "$", "output", ";", "}" ]
Iterates through selected errors of the request. @param string $for The name of the error name (e.g. argument name or property name). This can also be a property path (like blog.title), and will then only display the validation errors of that property. @param string $as The name of the variable to store the current error @return string Rendered string @api
[ "Iterates", "through", "selected", "errors", "of", "the", "request", "." ]
ded6be84a9487f7e0e204703a30b12d2c58c0efd
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/ViewHelpers/Validation/ResultsViewHelper.php#L79-L92
221,730
paquettg/leaguewrap
src/LeagueWrap/Api/Match.php
Match.match
public function match($matchId, $includeTimeline = false) { if ($includeTimeline) { $response = $this->request('match/'.$matchId, ['includeTimeline' => ($includeTimeline) ? 'true' : 'false']); } else { $response = $this->request('match/'.$matchId); } return $this->attachStaticDataToDto(new MatchDto($response)); }
php
public function match($matchId, $includeTimeline = false) { if ($includeTimeline) { $response = $this->request('match/'.$matchId, ['includeTimeline' => ($includeTimeline) ? 'true' : 'false']); } else { $response = $this->request('match/'.$matchId); } return $this->attachStaticDataToDto(new MatchDto($response)); }
[ "public", "function", "match", "(", "$", "matchId", ",", "$", "includeTimeline", "=", "false", ")", "{", "if", "(", "$", "includeTimeline", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'match/'", ".", "$", "matchId", ",", "[", "'includeTimeline'", "=>", "(", "$", "includeTimeline", ")", "?", "'true'", ":", "'false'", "]", ")", ";", "}", "else", "{", "$", "response", "=", "$", "this", "->", "request", "(", "'match/'", ".", "$", "matchId", ")", ";", "}", "return", "$", "this", "->", "attachStaticDataToDto", "(", "new", "MatchDto", "(", "$", "response", ")", ")", ";", "}" ]
Get the match by match id. @param int $matchId @param bool $includeTimeline @return Match
[ "Get", "the", "match", "by", "match", "id", "." ]
0f91813b5d8292054e5e13619d591b6b14dc63e6
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Match.php#L58-L70
221,731
twizoapi/lib-api-php
src/Entity/Validation/Exception.php
Exception.setErrorField
protected function setErrorField($name, $value, $messages, $arrayIndex = null) { // Loop through all errors foreach ($messages as $errorType => $error) { // When the validation messages are about an array, they are set in a sub array (validation_errors) if (is_numeric($errorType) && is_array($error) && isset($error['validation_errors'])) { // Array index is 1 based so deduct one to create 0 based index $arrayIndex = ((int) $errorType) - 1; $this->setErrorField( $name, isset($value[$arrayIndex]) ? $value[$arrayIndex] : null, $error['validation_errors'], $arrayIndex ); } elseif (is_array($error)) { // When there is an array of errors returned, handle them recursively $this->setErrorField($name, $value, $error, $arrayIndex); } else { // Add error field with all information $this->errorFields[] = new ErrorField($name, $value, $errorType, $error, $arrayIndex); } } }
php
protected function setErrorField($name, $value, $messages, $arrayIndex = null) { // Loop through all errors foreach ($messages as $errorType => $error) { // When the validation messages are about an array, they are set in a sub array (validation_errors) if (is_numeric($errorType) && is_array($error) && isset($error['validation_errors'])) { // Array index is 1 based so deduct one to create 0 based index $arrayIndex = ((int) $errorType) - 1; $this->setErrorField( $name, isset($value[$arrayIndex]) ? $value[$arrayIndex] : null, $error['validation_errors'], $arrayIndex ); } elseif (is_array($error)) { // When there is an array of errors returned, handle them recursively $this->setErrorField($name, $value, $error, $arrayIndex); } else { // Add error field with all information $this->errorFields[] = new ErrorField($name, $value, $errorType, $error, $arrayIndex); } } }
[ "protected", "function", "setErrorField", "(", "$", "name", ",", "$", "value", ",", "$", "messages", ",", "$", "arrayIndex", "=", "null", ")", "{", "// Loop through all errors", "foreach", "(", "$", "messages", "as", "$", "errorType", "=>", "$", "error", ")", "{", "// When the validation messages are about an array, they are set in a sub array (validation_errors)", "if", "(", "is_numeric", "(", "$", "errorType", ")", "&&", "is_array", "(", "$", "error", ")", "&&", "isset", "(", "$", "error", "[", "'validation_errors'", "]", ")", ")", "{", "// Array index is 1 based so deduct one to create 0 based index", "$", "arrayIndex", "=", "(", "(", "int", ")", "$", "errorType", ")", "-", "1", ";", "$", "this", "->", "setErrorField", "(", "$", "name", ",", "isset", "(", "$", "value", "[", "$", "arrayIndex", "]", ")", "?", "$", "value", "[", "$", "arrayIndex", "]", ":", "null", ",", "$", "error", "[", "'validation_errors'", "]", ",", "$", "arrayIndex", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "error", ")", ")", "{", "// When there is an array of errors returned, handle them recursively", "$", "this", "->", "setErrorField", "(", "$", "name", ",", "$", "value", ",", "$", "error", ",", "$", "arrayIndex", ")", ";", "}", "else", "{", "// Add error field with all information", "$", "this", "->", "errorFields", "[", "]", "=", "new", "ErrorField", "(", "$", "name", ",", "$", "value", ",", "$", "errorType", ",", "$", "error", ",", "$", "arrayIndex", ")", ";", "}", "}", "}" ]
Add all validation messages for one field @param string $name @param mixed $value @param array $messages @param int $arrayIndex
[ "Add", "all", "validation", "messages", "for", "one", "field" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Entity/Validation/Exception.php#L62-L84
221,732
paquettg/leaguewrap
src/LeagueWrap/Dto/ImportStaticTrait.php
ImportStaticTrait.getStaticFields
protected function getStaticFields() { $splHash = spl_object_hash($this); $fields = [ $splHash => [], ]; foreach ($this->staticFields as $field => $data) { if( !isset($this->info[$field]) ) continue; $fieldValue = $this->info[$field]; if ( ! isset($fields[$splHash][$data])) { $fields[$splHash][$data] = []; } $fields[$splHash][$data][] = $fieldValue; } $fields += parent::getStaticFields(); return $fields; }
php
protected function getStaticFields() { $splHash = spl_object_hash($this); $fields = [ $splHash => [], ]; foreach ($this->staticFields as $field => $data) { if( !isset($this->info[$field]) ) continue; $fieldValue = $this->info[$field]; if ( ! isset($fields[$splHash][$data])) { $fields[$splHash][$data] = []; } $fields[$splHash][$data][] = $fieldValue; } $fields += parent::getStaticFields(); return $fields; }
[ "protected", "function", "getStaticFields", "(", ")", "{", "$", "splHash", "=", "spl_object_hash", "(", "$", "this", ")", ";", "$", "fields", "=", "[", "$", "splHash", "=>", "[", "]", ",", "]", ";", "foreach", "(", "$", "this", "->", "staticFields", "as", "$", "field", "=>", "$", "data", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "info", "[", "$", "field", "]", ")", ")", "continue", ";", "$", "fieldValue", "=", "$", "this", "->", "info", "[", "$", "field", "]", ";", "if", "(", "!", "isset", "(", "$", "fields", "[", "$", "splHash", "]", "[", "$", "data", "]", ")", ")", "{", "$", "fields", "[", "$", "splHash", "]", "[", "$", "data", "]", "=", "[", "]", ";", "}", "$", "fields", "[", "$", "splHash", "]", "[", "$", "data", "]", "[", "]", "=", "$", "fieldValue", ";", "}", "$", "fields", "+=", "parent", "::", "getStaticFields", "(", ")", ";", "return", "$", "fields", ";", "}" ]
Sets all the static fields in the current dto in the fields and aggrigates it with the child dto fields. @return array
[ "Sets", "all", "the", "static", "fields", "in", "the", "current", "dto", "in", "the", "fields", "and", "aggrigates", "it", "with", "the", "child", "dto", "fields", "." ]
0f91813b5d8292054e5e13619d591b6b14dc63e6
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Dto/ImportStaticTrait.php#L14-L35
221,733
paquettg/leaguewrap
src/LeagueWrap/Dto/ImportStaticTrait.php
ImportStaticTrait.addStaticData
protected function addStaticData(StaticOptimizer $optimizer) { $splHash = spl_object_hash($this); $info = $optimizer->getDataFromHash($splHash); foreach ($this->staticFields as $field => $data) { if( !isset($this->info[$field]) ) continue; $infoArray = $info[$data]; $fieldValue = $this->info[$field]; $staticData = $infoArray[$fieldValue]; $this->info[$data.'StaticData'] = $staticData; } parent::addStaticData($optimizer); }
php
protected function addStaticData(StaticOptimizer $optimizer) { $splHash = spl_object_hash($this); $info = $optimizer->getDataFromHash($splHash); foreach ($this->staticFields as $field => $data) { if( !isset($this->info[$field]) ) continue; $infoArray = $info[$data]; $fieldValue = $this->info[$field]; $staticData = $infoArray[$fieldValue]; $this->info[$data.'StaticData'] = $staticData; } parent::addStaticData($optimizer); }
[ "protected", "function", "addStaticData", "(", "StaticOptimizer", "$", "optimizer", ")", "{", "$", "splHash", "=", "spl_object_hash", "(", "$", "this", ")", ";", "$", "info", "=", "$", "optimizer", "->", "getDataFromHash", "(", "$", "splHash", ")", ";", "foreach", "(", "$", "this", "->", "staticFields", "as", "$", "field", "=>", "$", "data", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "info", "[", "$", "field", "]", ")", ")", "continue", ";", "$", "infoArray", "=", "$", "info", "[", "$", "data", "]", ";", "$", "fieldValue", "=", "$", "this", "->", "info", "[", "$", "field", "]", ";", "$", "staticData", "=", "$", "infoArray", "[", "$", "fieldValue", "]", ";", "$", "this", "->", "info", "[", "$", "data", ".", "'StaticData'", "]", "=", "$", "staticData", ";", "}", "parent", "::", "addStaticData", "(", "$", "optimizer", ")", ";", "}" ]
Takes a result array and attempts to fill in any needed static data. @param staticOptimizer $optimizer @return void
[ "Takes", "a", "result", "array", "and", "attempts", "to", "fill", "in", "any", "needed", "static", "data", "." ]
0f91813b5d8292054e5e13619d591b6b14dc63e6
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Dto/ImportStaticTrait.php#L44-L60
221,734
paquettg/leaguewrap
src/LeagueWrap/Response/ResponseException.php
ResponseException.withResponse
public static function withResponse($message, Response $response) { $e = new static(); $e->response = $response; $e->message = $message; return $e; }
php
public static function withResponse($message, Response $response) { $e = new static(); $e->response = $response; $e->message = $message; return $e; }
[ "public", "static", "function", "withResponse", "(", "$", "message", ",", "Response", "$", "response", ")", "{", "$", "e", "=", "new", "static", "(", ")", ";", "$", "e", "->", "response", "=", "$", "response", ";", "$", "e", "->", "message", "=", "$", "message", ";", "return", "$", "e", ";", "}" ]
Static constructor for including response. @param string $message @param Response $response @return static
[ "Static", "constructor", "for", "including", "response", "." ]
0f91813b5d8292054e5e13619d591b6b14dc63e6
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Response/ResponseException.php#L24-L31
221,735
neos/fluid
Classes/TYPO3/Fluid/ViewHelpers/RenderChildrenViewHelper.php
RenderChildrenViewHelper.removeArgumentsFromTemplateVariableContainer
protected function removeArgumentsFromTemplateVariableContainer(array $arguments) { $templateVariableContainer = $this->getWidgetRenderingContext()->getTemplateVariableContainer(); foreach ($arguments as $identifier => $value) { $templateVariableContainer->remove($identifier); } }
php
protected function removeArgumentsFromTemplateVariableContainer(array $arguments) { $templateVariableContainer = $this->getWidgetRenderingContext()->getTemplateVariableContainer(); foreach ($arguments as $identifier => $value) { $templateVariableContainer->remove($identifier); } }
[ "protected", "function", "removeArgumentsFromTemplateVariableContainer", "(", "array", "$", "arguments", ")", "{", "$", "templateVariableContainer", "=", "$", "this", "->", "getWidgetRenderingContext", "(", ")", "->", "getTemplateVariableContainer", "(", ")", ";", "foreach", "(", "$", "arguments", "as", "$", "identifier", "=>", "$", "value", ")", "{", "$", "templateVariableContainer", "->", "remove", "(", "$", "identifier", ")", ";", "}", "}" ]
Remove the given arguments from the TemplateVariableContainer of the widget. @param array $arguments @return void
[ "Remove", "the", "given", "arguments", "from", "the", "TemplateVariableContainer", "of", "the", "widget", "." ]
ded6be84a9487f7e0e204703a30b12d2c58c0efd
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/ViewHelpers/RenderChildrenViewHelper.php#L129-L135
221,736
salebab/database
src/database/Statement.php
Statement.getColumnValue
function getColumnValue($column_name) { return isset($this->last_row[$column_name]) ? $this->last_row[$column_name] : null; }
php
function getColumnValue($column_name) { return isset($this->last_row[$column_name]) ? $this->last_row[$column_name] : null; }
[ "function", "getColumnValue", "(", "$", "column_name", ")", "{", "return", "isset", "(", "$", "this", "->", "last_row", "[", "$", "column_name", "]", ")", "?", "$", "this", "->", "last_row", "[", "$", "column_name", "]", ":", "null", ";", "}" ]
Get value from column, from last row @param string $column_name @return mixed|NULL
[ "Get", "value", "from", "column", "from", "last", "row" ]
26e9253f274fb0719ad86c1db6e25ea5400b58a6
https://github.com/salebab/database/blob/26e9253f274fb0719ad86c1db6e25ea5400b58a6/src/database/Statement.php#L125-L128
221,737
paquettg/leaguewrap
src/LeagueWrap/Dto/Team/Roster.php
Roster.member
public function member($memberId) { if (isset($this->info['memberList'][$memberId])) { return $this->info['memberList'][$memberId]; } // could not find the member return null; }
php
public function member($memberId) { if (isset($this->info['memberList'][$memberId])) { return $this->info['memberList'][$memberId]; } // could not find the member return null; }
[ "public", "function", "member", "(", "$", "memberId", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "info", "[", "'memberList'", "]", "[", "$", "memberId", "]", ")", ")", "{", "return", "$", "this", "->", "info", "[", "'memberList'", "]", "[", "$", "memberId", "]", ";", "}", "// could not find the member", "return", "null", ";", "}" ]
Attempts to get a member by the member id. @param int $memberId @return null|Member
[ "Attempts", "to", "get", "a", "member", "by", "the", "member", "id", "." ]
0f91813b5d8292054e5e13619d591b6b14dc63e6
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Dto/Team/Roster.php#L37-L46
221,738
radphp/radphp
src/Network/Http/Request.php
Request.isMethod
public function isMethod($methods) { if (is_array($methods)) { return in_array($this->getMethod(), $methods); } if (is_string($methods)) { return ($this->getMethod() == $methods); } return false; }
php
public function isMethod($methods) { if (is_array($methods)) { return in_array($this->getMethod(), $methods); } if (is_string($methods)) { return ($this->getMethod() == $methods); } return false; }
[ "public", "function", "isMethod", "(", "$", "methods", ")", "{", "if", "(", "is_array", "(", "$", "methods", ")", ")", "{", "return", "in_array", "(", "$", "this", "->", "getMethod", "(", ")", ",", "$", "methods", ")", ";", "}", "if", "(", "is_string", "(", "$", "methods", ")", ")", "{", "return", "(", "$", "this", "->", "getMethod", "(", ")", "==", "$", "methods", ")", ";", "}", "return", "false", ";", "}" ]
Check if HTTP method match any of the passed methods @param string|array $methods @return bool
[ "Check", "if", "HTTP", "method", "match", "any", "of", "the", "passed", "methods" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Request.php#L207-L218
221,739
radphp/radphp
src/Network/Http/Request.php
Request.getMediaType
public function getMediaType() { $contentType = $this->getServer('CONTENT_TYPE'); if (!empty($contentType)) { if ($parts = explode(';', $contentType)) { return trim($parts[0]); } } return ''; }
php
public function getMediaType() { $contentType = $this->getServer('CONTENT_TYPE'); if (!empty($contentType)) { if ($parts = explode(';', $contentType)) { return trim($parts[0]); } } return ''; }
[ "public", "function", "getMediaType", "(", ")", "{", "$", "contentType", "=", "$", "this", "->", "getServer", "(", "'CONTENT_TYPE'", ")", ";", "if", "(", "!", "empty", "(", "$", "contentType", ")", ")", "{", "if", "(", "$", "parts", "=", "explode", "(", "';'", ",", "$", "contentType", ")", ")", "{", "return", "trim", "(", "$", "parts", "[", "0", "]", ")", ";", "}", "}", "return", "''", ";", "}" ]
Get request media type @return string
[ "Get", "request", "media", "type" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Request.php#L375-L385
221,740
radphp/radphp
src/Network/Http/Request.php
Request.getQualityHeader
protected function getQualityHeader($serverIndex, $name) { $httpServer = $this->getHeaderLine($serverIndex); $parts = preg_split('/,\\s*/', $httpServer); $output = []; foreach ($parts as $part) { $headerParts = explode(';', $part); if (isset($headerParts[1])) { $qualityPart = $headerParts[1]; $qVal = substr($qualityPart, 2); $quality = ($qVal == (int)$qVal) ? (int)$qVal : (float)$qVal; } else { $quality = 1; } $headerName = $headerParts[0]; $output[] = [$name => $headerName, 'quality' => $quality]; } return $output; }
php
protected function getQualityHeader($serverIndex, $name) { $httpServer = $this->getHeaderLine($serverIndex); $parts = preg_split('/,\\s*/', $httpServer); $output = []; foreach ($parts as $part) { $headerParts = explode(';', $part); if (isset($headerParts[1])) { $qualityPart = $headerParts[1]; $qVal = substr($qualityPart, 2); $quality = ($qVal == (int)$qVal) ? (int)$qVal : (float)$qVal; } else { $quality = 1; } $headerName = $headerParts[0]; $output[] = [$name => $headerName, 'quality' => $quality]; } return $output; }
[ "protected", "function", "getQualityHeader", "(", "$", "serverIndex", ",", "$", "name", ")", "{", "$", "httpServer", "=", "$", "this", "->", "getHeaderLine", "(", "$", "serverIndex", ")", ";", "$", "parts", "=", "preg_split", "(", "'/,\\\\s*/'", ",", "$", "httpServer", ")", ";", "$", "output", "=", "[", "]", ";", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "$", "headerParts", "=", "explode", "(", "';'", ",", "$", "part", ")", ";", "if", "(", "isset", "(", "$", "headerParts", "[", "1", "]", ")", ")", "{", "$", "qualityPart", "=", "$", "headerParts", "[", "1", "]", ";", "$", "qVal", "=", "substr", "(", "$", "qualityPart", ",", "2", ")", ";", "$", "quality", "=", "(", "$", "qVal", "==", "(", "int", ")", "$", "qVal", ")", "?", "(", "int", ")", "$", "qVal", ":", "(", "float", ")", "$", "qVal", ";", "}", "else", "{", "$", "quality", "=", "1", ";", "}", "$", "headerName", "=", "$", "headerParts", "[", "0", "]", ";", "$", "output", "[", "]", "=", "[", "$", "name", "=>", "$", "headerName", ",", "'quality'", "=>", "$", "quality", "]", ";", "}", "return", "$", "output", ";", "}" ]
Process a request header and return an array of values with their qualities @param string $serverIndex @param string $name @return array
[ "Process", "a", "request", "header", "and", "return", "an", "array", "of", "values", "with", "their", "qualities" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Request.php#L395-L416
221,741
radphp/radphp
src/Network/Http/Request.php
Request.getPreferredQuality
protected function getPreferredQuality(array $qualityParts, $name) { $i = 0; $quality = 0; $selectedName = ''; foreach ($qualityParts as $accept) { if ($i == 0) { $quality = $accept['quality']; $selectedName = $accept[$name]; } else { $acceptQuality = $accept['quality']; $preferredQuality = ($quality < $acceptQuality); if ($preferredQuality === true) { $quality = $acceptQuality; $selectedName = $accept[$name]; } } $i++; } return $selectedName; }
php
protected function getPreferredQuality(array $qualityParts, $name) { $i = 0; $quality = 0; $selectedName = ''; foreach ($qualityParts as $accept) { if ($i == 0) { $quality = $accept['quality']; $selectedName = $accept[$name]; } else { $acceptQuality = $accept['quality']; $preferredQuality = ($quality < $acceptQuality); if ($preferredQuality === true) { $quality = $acceptQuality; $selectedName = $accept[$name]; } } $i++; } return $selectedName; }
[ "protected", "function", "getPreferredQuality", "(", "array", "$", "qualityParts", ",", "$", "name", ")", "{", "$", "i", "=", "0", ";", "$", "quality", "=", "0", ";", "$", "selectedName", "=", "''", ";", "foreach", "(", "$", "qualityParts", "as", "$", "accept", ")", "{", "if", "(", "$", "i", "==", "0", ")", "{", "$", "quality", "=", "$", "accept", "[", "'quality'", "]", ";", "$", "selectedName", "=", "$", "accept", "[", "$", "name", "]", ";", "}", "else", "{", "$", "acceptQuality", "=", "$", "accept", "[", "'quality'", "]", ";", "$", "preferredQuality", "=", "(", "$", "quality", "<", "$", "acceptQuality", ")", ";", "if", "(", "$", "preferredQuality", "===", "true", ")", "{", "$", "quality", "=", "$", "acceptQuality", ";", "$", "selectedName", "=", "$", "accept", "[", "$", "name", "]", ";", "}", "}", "$", "i", "++", ";", "}", "return", "$", "selectedName", ";", "}" ]
Process a request header and return the one with preferred quality @param array $qualityParts @param string $name @return string
[ "Process", "a", "request", "header", "and", "return", "the", "one", "with", "preferred", "quality" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Request.php#L426-L449
221,742
radphp/radphp
src/Network/Http/Request.php
Request.prepareUploadedFiles
protected function prepareUploadedFiles($files) { $fileKeys = ['error', 'name', 'size', 'tmp_name', 'type']; $reformatFiles = new ReformatUploadedFiles($files); $output = []; foreach ($reformatFiles as $key => $value) { $keys = array_keys($value); sort($keys); if ($fileKeys == $keys && is_array($value['tmp_name'])) { $output[$key] = $this->prepareUploadedFiles($reformatFiles[$key]); continue; } $output[$key] = new UploadedFile( $value['tmp_name'], $value['error'], $value['name'], $value['type'], $value['size'] ); } return $output; }
php
protected function prepareUploadedFiles($files) { $fileKeys = ['error', 'name', 'size', 'tmp_name', 'type']; $reformatFiles = new ReformatUploadedFiles($files); $output = []; foreach ($reformatFiles as $key => $value) { $keys = array_keys($value); sort($keys); if ($fileKeys == $keys && is_array($value['tmp_name'])) { $output[$key] = $this->prepareUploadedFiles($reformatFiles[$key]); continue; } $output[$key] = new UploadedFile( $value['tmp_name'], $value['error'], $value['name'], $value['type'], $value['size'] ); } return $output; }
[ "protected", "function", "prepareUploadedFiles", "(", "$", "files", ")", "{", "$", "fileKeys", "=", "[", "'error'", ",", "'name'", ",", "'size'", ",", "'tmp_name'", ",", "'type'", "]", ";", "$", "reformatFiles", "=", "new", "ReformatUploadedFiles", "(", "$", "files", ")", ";", "$", "output", "=", "[", "]", ";", "foreach", "(", "$", "reformatFiles", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "value", ")", ";", "sort", "(", "$", "keys", ")", ";", "if", "(", "$", "fileKeys", "==", "$", "keys", "&&", "is_array", "(", "$", "value", "[", "'tmp_name'", "]", ")", ")", "{", "$", "output", "[", "$", "key", "]", "=", "$", "this", "->", "prepareUploadedFiles", "(", "$", "reformatFiles", "[", "$", "key", "]", ")", ";", "continue", ";", "}", "$", "output", "[", "$", "key", "]", "=", "new", "UploadedFile", "(", "$", "value", "[", "'tmp_name'", "]", ",", "$", "value", "[", "'error'", "]", ",", "$", "value", "[", "'name'", "]", ",", "$", "value", "[", "'type'", "]", ",", "$", "value", "[", "'size'", "]", ")", ";", "}", "return", "$", "output", ";", "}" ]
Prepare uploaded files @param $files @return array
[ "Prepare", "uploaded", "files" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Request.php#L458-L483
221,743
radphp/radphp
src/Network/Http/Request.php
Request.prepareHeaders
protected function prepareHeaders($server) { $output = []; if (!is_array($server)) { return $output; } foreach ($server as $key => $value) { if (is_string($key) && strlen($key) > 5 && strpos($key, 'HTTP_') !== false) { $output[substr($key, 5)] = $value; } } return $output; }
php
protected function prepareHeaders($server) { $output = []; if (!is_array($server)) { return $output; } foreach ($server as $key => $value) { if (is_string($key) && strlen($key) > 5 && strpos($key, 'HTTP_') !== false) { $output[substr($key, 5)] = $value; } } return $output; }
[ "protected", "function", "prepareHeaders", "(", "$", "server", ")", "{", "$", "output", "=", "[", "]", ";", "if", "(", "!", "is_array", "(", "$", "server", ")", ")", "{", "return", "$", "output", ";", "}", "foreach", "(", "$", "server", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", "&&", "strlen", "(", "$", "key", ")", ">", "5", "&&", "strpos", "(", "$", "key", ",", "'HTTP_'", ")", "!==", "false", ")", "{", "$", "output", "[", "substr", "(", "$", "key", ",", "5", ")", "]", "=", "$", "value", ";", "}", "}", "return", "$", "output", ";", "}" ]
Returns the available headers in the request @param array $server @return array
[ "Returns", "the", "available", "headers", "in", "the", "request" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Request.php#L492-L507
221,744
radphp/radphp
src/Network/Http/Request.php
Request.prepareParsedBody
protected function prepareParsedBody() { if ($this->method == self::METHOD_POST && in_array($this->getMediaType(), ['application/x-www-form-urlencoded', 'multipart/form-data']) ) { return $_POST; } else { $body = (string)$this->getBody(); switch ($this->getMediaType()) { case 'application/json': return json_decode($body, true); case 'application/xml': return simplexml_load_string($body); default: parse_str($body, $output); return $output; } } }
php
protected function prepareParsedBody() { if ($this->method == self::METHOD_POST && in_array($this->getMediaType(), ['application/x-www-form-urlencoded', 'multipart/form-data']) ) { return $_POST; } else { $body = (string)$this->getBody(); switch ($this->getMediaType()) { case 'application/json': return json_decode($body, true); case 'application/xml': return simplexml_load_string($body); default: parse_str($body, $output); return $output; } } }
[ "protected", "function", "prepareParsedBody", "(", ")", "{", "if", "(", "$", "this", "->", "method", "==", "self", "::", "METHOD_POST", "&&", "in_array", "(", "$", "this", "->", "getMediaType", "(", ")", ",", "[", "'application/x-www-form-urlencoded'", ",", "'multipart/form-data'", "]", ")", ")", "{", "return", "$", "_POST", ";", "}", "else", "{", "$", "body", "=", "(", "string", ")", "$", "this", "->", "getBody", "(", ")", ";", "switch", "(", "$", "this", "->", "getMediaType", "(", ")", ")", "{", "case", "'application/json'", ":", "return", "json_decode", "(", "$", "body", ",", "true", ")", ";", "case", "'application/xml'", ":", "return", "simplexml_load_string", "(", "$", "body", ")", ";", "default", ":", "parse_str", "(", "$", "body", ",", "$", "output", ")", ";", "return", "$", "output", ";", "}", "}", "}" ]
Prepare parsed body @return mixed|\SimpleXMLElement
[ "Prepare", "parsed", "body" ]
2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a
https://github.com/radphp/radphp/blob/2cbde2c12dd7204b1aba3f8a6e351b287ae85f0a/src/Network/Http/Request.php#L545-L567
221,745
twizoapi/lib-api-php
src/AbstractEntity.php
AbstractEntity.addPostField
protected function addPostField($key) { if (property_exists($this, $key)) { $this->postFields[$key] = $this->$key; } }
php
protected function addPostField($key) { if (property_exists($this, $key)) { $this->postFields[$key] = $this->$key; } }
[ "protected", "function", "addPostField", "(", "$", "key", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "$", "key", ")", ")", "{", "$", "this", "->", "postFields", "[", "$", "key", "]", "=", "$", "this", "->", "$", "key", ";", "}", "}" ]
Set a post field to be send to the server; lookup the value from the key @param string $key
[ "Set", "a", "post", "field", "to", "be", "send", "to", "the", "server", ";", "lookup", "the", "value", "from", "the", "key" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/AbstractEntity.php#L84-L89
221,746
twizoapi/lib-api-php
src/AbstractEntity.php
AbstractEntity.detectInvalidJsonFields
protected function detectInvalidJsonFields() { if (json_encode($this->postFields) === false) { $invalidFields = array(); foreach ($this->postFields as $key => $value) { if (json_encode($value) === false) { $invalidFields[] = $key; } } throw new EntityException('Invalid data found in field(s): ' . implode(', ', $invalidFields), EntityException::INVALID_FIELDS); } }
php
protected function detectInvalidJsonFields() { if (json_encode($this->postFields) === false) { $invalidFields = array(); foreach ($this->postFields as $key => $value) { if (json_encode($value) === false) { $invalidFields[] = $key; } } throw new EntityException('Invalid data found in field(s): ' . implode(', ', $invalidFields), EntityException::INVALID_FIELDS); } }
[ "protected", "function", "detectInvalidJsonFields", "(", ")", "{", "if", "(", "json_encode", "(", "$", "this", "->", "postFields", ")", "===", "false", ")", "{", "$", "invalidFields", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "postFields", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "json_encode", "(", "$", "value", ")", "===", "false", ")", "{", "$", "invalidFields", "[", "]", "=", "$", "key", ";", "}", "}", "throw", "new", "EntityException", "(", "'Invalid data found in field(s): '", ".", "implode", "(", "', '", ",", "$", "invalidFields", ")", ",", "EntityException", "::", "INVALID_FIELDS", ")", ";", "}", "}" ]
Detect invalid json fields in entity and throw exception when found @throws EntityException
[ "Detect", "invalid", "json", "fields", "in", "entity", "and", "throw", "exception", "when", "found" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/AbstractEntity.php#L96-L107
221,747
twizoapi/lib-api-php
src/AbstractEntity.php
AbstractEntity.setFields
public function setFields(array $fields) { foreach ($fields as $field => $value) { if (property_exists($this, $field)) { $this->{$field} = $value; } } if (isset($fields['_embedded'])) { foreach ($fields['_embedded'] as $embeddedType => $embeddedValue) { if (property_exists($this, $embeddedType)) { $propertyObject = $this->factory->createFromPropertyName($embeddedType); if ($propertyObject === null) { continue; } if (is_array($propertyObject)) { //Property is a collection foreach ($embeddedValue as $entityType => $entityFields) { $entityObject = $this->factory->createFromPropertyName($entityType); if ($entityObject === null) { continue; } $entityObject->setFields($entityFields); $propertyObject[] = $entityObject; } } else { //Property is an entity $propertyObject->setFields($embeddedValue); } $this->{$embeddedType} = $propertyObject; } } } }
php
public function setFields(array $fields) { foreach ($fields as $field => $value) { if (property_exists($this, $field)) { $this->{$field} = $value; } } if (isset($fields['_embedded'])) { foreach ($fields['_embedded'] as $embeddedType => $embeddedValue) { if (property_exists($this, $embeddedType)) { $propertyObject = $this->factory->createFromPropertyName($embeddedType); if ($propertyObject === null) { continue; } if (is_array($propertyObject)) { //Property is a collection foreach ($embeddedValue as $entityType => $entityFields) { $entityObject = $this->factory->createFromPropertyName($entityType); if ($entityObject === null) { continue; } $entityObject->setFields($entityFields); $propertyObject[] = $entityObject; } } else { //Property is an entity $propertyObject->setFields($embeddedValue); } $this->{$embeddedType} = $propertyObject; } } } }
[ "public", "function", "setFields", "(", "array", "$", "fields", ")", "{", "foreach", "(", "$", "fields", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "$", "field", ")", ")", "{", "$", "this", "->", "{", "$", "field", "}", "=", "$", "value", ";", "}", "}", "if", "(", "isset", "(", "$", "fields", "[", "'_embedded'", "]", ")", ")", "{", "foreach", "(", "$", "fields", "[", "'_embedded'", "]", "as", "$", "embeddedType", "=>", "$", "embeddedValue", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "$", "embeddedType", ")", ")", "{", "$", "propertyObject", "=", "$", "this", "->", "factory", "->", "createFromPropertyName", "(", "$", "embeddedType", ")", ";", "if", "(", "$", "propertyObject", "===", "null", ")", "{", "continue", ";", "}", "if", "(", "is_array", "(", "$", "propertyObject", ")", ")", "{", "//Property is a collection", "foreach", "(", "$", "embeddedValue", "as", "$", "entityType", "=>", "$", "entityFields", ")", "{", "$", "entityObject", "=", "$", "this", "->", "factory", "->", "createFromPropertyName", "(", "$", "entityType", ")", ";", "if", "(", "$", "entityObject", "===", "null", ")", "{", "continue", ";", "}", "$", "entityObject", "->", "setFields", "(", "$", "entityFields", ")", ";", "$", "propertyObject", "[", "]", "=", "$", "entityObject", ";", "}", "}", "else", "{", "//Property is an entity", "$", "propertyObject", "->", "setFields", "(", "$", "embeddedValue", ")", ";", "}", "$", "this", "->", "{", "$", "embeddedType", "}", "=", "$", "propertyObject", ";", "}", "}", "}", "}" ]
Set fields from api response @param array $fields @return void
[ "Set", "fields", "from", "api", "response" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/AbstractEntity.php#L195-L230
221,748
paquettg/leaguewrap
src/LeagueWrap/Api/Team.php
Team.team
public function team($identities) { if (is_array($identities)) { if (count($identities) > 10) { throw new ListMaxException('This request can only support a list of 10 elements, '.count($identities).' given.'); } } $ids = $this->extractIds($identities); $ids = implode(',', $ids); $array = $this->request('team/by-summoner/'.$ids); $summoners = []; foreach ($array as $summonerId => $summonerTeams) { $teams = []; foreach ($summonerTeams as $info) { $id = $info['fullId']; $team = $this->attachStaticDataToDto(new Dto\Team($info)); $teams[$id] = $team; } $summoners[$summonerId] = $teams; foreach ($teams as $id => $team) { $this->teams[$id] = $team; } } $this->attachResponses($identities, $summoners, 'teams'); if (is_array($identities)) { return $summoners; } else { return reset($summoners); } }
php
public function team($identities) { if (is_array($identities)) { if (count($identities) > 10) { throw new ListMaxException('This request can only support a list of 10 elements, '.count($identities).' given.'); } } $ids = $this->extractIds($identities); $ids = implode(',', $ids); $array = $this->request('team/by-summoner/'.$ids); $summoners = []; foreach ($array as $summonerId => $summonerTeams) { $teams = []; foreach ($summonerTeams as $info) { $id = $info['fullId']; $team = $this->attachStaticDataToDto(new Dto\Team($info)); $teams[$id] = $team; } $summoners[$summonerId] = $teams; foreach ($teams as $id => $team) { $this->teams[$id] = $team; } } $this->attachResponses($identities, $summoners, 'teams'); if (is_array($identities)) { return $summoners; } else { return reset($summoners); } }
[ "public", "function", "team", "(", "$", "identities", ")", "{", "if", "(", "is_array", "(", "$", "identities", ")", ")", "{", "if", "(", "count", "(", "$", "identities", ")", ">", "10", ")", "{", "throw", "new", "ListMaxException", "(", "'This request can only support a list of 10 elements, '", ".", "count", "(", "$", "identities", ")", ".", "' given.'", ")", ";", "}", "}", "$", "ids", "=", "$", "this", "->", "extractIds", "(", "$", "identities", ")", ";", "$", "ids", "=", "implode", "(", "','", ",", "$", "ids", ")", ";", "$", "array", "=", "$", "this", "->", "request", "(", "'team/by-summoner/'", ".", "$", "ids", ")", ";", "$", "summoners", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "summonerId", "=>", "$", "summonerTeams", ")", "{", "$", "teams", "=", "[", "]", ";", "foreach", "(", "$", "summonerTeams", "as", "$", "info", ")", "{", "$", "id", "=", "$", "info", "[", "'fullId'", "]", ";", "$", "team", "=", "$", "this", "->", "attachStaticDataToDto", "(", "new", "Dto", "\\", "Team", "(", "$", "info", ")", ")", ";", "$", "teams", "[", "$", "id", "]", "=", "$", "team", ";", "}", "$", "summoners", "[", "$", "summonerId", "]", "=", "$", "teams", ";", "foreach", "(", "$", "teams", "as", "$", "id", "=>", "$", "team", ")", "{", "$", "this", "->", "teams", "[", "$", "id", "]", "=", "$", "team", ";", "}", "}", "$", "this", "->", "attachResponses", "(", "$", "identities", ",", "$", "summoners", ",", "'teams'", ")", ";", "if", "(", "is_array", "(", "$", "identities", ")", ")", "{", "return", "$", "summoners", ";", "}", "else", "{", "return", "reset", "(", "$", "summoners", ")", ";", "}", "}" ]
Gets the team information by summoner id or list of summoner ids. @param Summoner|Int $identities @return array @throws ListMaxException
[ "Gets", "the", "team", "information", "by", "summoner", "id", "or", "list", "of", "summoner", "ids", "." ]
0f91813b5d8292054e5e13619d591b6b14dc63e6
https://github.com/paquettg/leaguewrap/blob/0f91813b5d8292054e5e13619d591b6b14dc63e6/src/LeagueWrap/Api/Team.php#L66-L109
221,749
neos/fluid
Classes/TYPO3/Fluid/ViewHelpers/SwitchViewHelper.php
SwitchViewHelper.backupSwitchState
protected function backupSwitchState() { if ($this->renderingContext->getViewHelperVariableContainer()->exists(\TYPO3\Fluid\ViewHelpers\SwitchViewHelper::class, 'switchExpression')) { $this->backupSwitchExpression = $this->renderingContext->getViewHelperVariableContainer()->get(\TYPO3\Fluid\ViewHelpers\SwitchViewHelper::class, 'switchExpression'); } if ($this->renderingContext->getViewHelperVariableContainer()->exists(\TYPO3\Fluid\ViewHelpers\SwitchViewHelper::class, 'break')) { $this->backupBreakState = $this->renderingContext->getViewHelperVariableContainer()->get(\TYPO3\Fluid\ViewHelpers\SwitchViewHelper::class, 'break'); } }
php
protected function backupSwitchState() { if ($this->renderingContext->getViewHelperVariableContainer()->exists(\TYPO3\Fluid\ViewHelpers\SwitchViewHelper::class, 'switchExpression')) { $this->backupSwitchExpression = $this->renderingContext->getViewHelperVariableContainer()->get(\TYPO3\Fluid\ViewHelpers\SwitchViewHelper::class, 'switchExpression'); } if ($this->renderingContext->getViewHelperVariableContainer()->exists(\TYPO3\Fluid\ViewHelpers\SwitchViewHelper::class, 'break')) { $this->backupBreakState = $this->renderingContext->getViewHelperVariableContainer()->get(\TYPO3\Fluid\ViewHelpers\SwitchViewHelper::class, 'break'); } }
[ "protected", "function", "backupSwitchState", "(", ")", "{", "if", "(", "$", "this", "->", "renderingContext", "->", "getViewHelperVariableContainer", "(", ")", "->", "exists", "(", "\\", "TYPO3", "\\", "Fluid", "\\", "ViewHelpers", "\\", "SwitchViewHelper", "::", "class", ",", "'switchExpression'", ")", ")", "{", "$", "this", "->", "backupSwitchExpression", "=", "$", "this", "->", "renderingContext", "->", "getViewHelperVariableContainer", "(", ")", "->", "get", "(", "\\", "TYPO3", "\\", "Fluid", "\\", "ViewHelpers", "\\", "SwitchViewHelper", "::", "class", ",", "'switchExpression'", ")", ";", "}", "if", "(", "$", "this", "->", "renderingContext", "->", "getViewHelperVariableContainer", "(", ")", "->", "exists", "(", "\\", "TYPO3", "\\", "Fluid", "\\", "ViewHelpers", "\\", "SwitchViewHelper", "::", "class", ",", "'break'", ")", ")", "{", "$", "this", "->", "backupBreakState", "=", "$", "this", "->", "renderingContext", "->", "getViewHelperVariableContainer", "(", ")", "->", "get", "(", "\\", "TYPO3", "\\", "Fluid", "\\", "ViewHelpers", "\\", "SwitchViewHelper", "::", "class", ",", "'break'", ")", ";", "}", "}" ]
Backups "switch expression" and "break" state of a possible parent switch ViewHelper to support nesting @return void
[ "Backups", "switch", "expression", "and", "break", "state", "of", "a", "possible", "parent", "switch", "ViewHelper", "to", "support", "nesting" ]
ded6be84a9487f7e0e204703a30b12d2c58c0efd
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/ViewHelpers/SwitchViewHelper.php#L124-L132
221,750
twizoapi/lib-api-php
src/Twizo.php
Twizo.createBioVoiceRegistration
public function createBioVoiceRegistration($recipient, $language = null, $webHook = null) { $bioVoiceRegistration = $this->factory->createBioVoiceRegistration($recipient, $language, $webHook); return $bioVoiceRegistration; }
php
public function createBioVoiceRegistration($recipient, $language = null, $webHook = null) { $bioVoiceRegistration = $this->factory->createBioVoiceRegistration($recipient, $language, $webHook); return $bioVoiceRegistration; }
[ "public", "function", "createBioVoiceRegistration", "(", "$", "recipient", ",", "$", "language", "=", "null", ",", "$", "webHook", "=", "null", ")", "{", "$", "bioVoiceRegistration", "=", "$", "this", "->", "factory", "->", "createBioVoiceRegistration", "(", "$", "recipient", ",", "$", "language", ",", "$", "webHook", ")", ";", "return", "$", "bioVoiceRegistration", ";", "}" ]
Create bio voice registration for the supplied recipient @param string $recipient @param string|null $language @param string|null $webHook @return BioVoiceRegistration
[ "Create", "bio", "voice", "registration", "for", "the", "supplied", "recipient" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L73-L78
221,751
twizoapi/lib-api-php
src/Twizo.php
Twizo.createTotp
public function createTotp($identifier, $issuer = null) { $totp = $this->factory->createTotp($identifier, $issuer); return $totp; }
php
public function createTotp($identifier, $issuer = null) { $totp = $this->factory->createTotp($identifier, $issuer); return $totp; }
[ "public", "function", "createTotp", "(", "$", "identifier", ",", "$", "issuer", "=", "null", ")", "{", "$", "totp", "=", "$", "this", "->", "factory", "->", "createTotp", "(", "$", "identifier", ",", "$", "issuer", ")", ";", "return", "$", "totp", ";", "}" ]
Create TOTP secret @param string $identifier @param string|null $issuer @return Entity\Totp
[ "Create", "TOTP", "secret" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L126-L131
221,752
twizoapi/lib-api-php
src/Twizo.php
Twizo.createWidgetSession
public function createWidgetSession(array $allowedTypes = null, $recipient = null, $backupCodeIdentifier = null, $totpIdentifier = null, $issuer = null) { $widgetSession = $this->factory->createWidgetSession($allowedTypes, $recipient, $backupCodeIdentifier, $totpIdentifier, $issuer); return $widgetSession; }
php
public function createWidgetSession(array $allowedTypes = null, $recipient = null, $backupCodeIdentifier = null, $totpIdentifier = null, $issuer = null) { $widgetSession = $this->factory->createWidgetSession($allowedTypes, $recipient, $backupCodeIdentifier, $totpIdentifier, $issuer); return $widgetSession; }
[ "public", "function", "createWidgetSession", "(", "array", "$", "allowedTypes", "=", "null", ",", "$", "recipient", "=", "null", ",", "$", "backupCodeIdentifier", "=", "null", ",", "$", "totpIdentifier", "=", "null", ",", "$", "issuer", "=", "null", ")", "{", "$", "widgetSession", "=", "$", "this", "->", "factory", "->", "createWidgetSession", "(", "$", "allowedTypes", ",", "$", "recipient", ",", "$", "backupCodeIdentifier", ",", "$", "totpIdentifier", ",", "$", "issuer", ")", ";", "return", "$", "widgetSession", ";", "}" ]
Create widget session with the supplied data @param array|null $allowedTypes @param string|null $recipient @param string|null $backupCodeIdentifier @param string|null $totpIdentifier @param string|null $issuer @return WidgetSession
[ "Create", "widget", "session", "with", "the", "supplied", "data" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L158-L163
221,753
twizoapi/lib-api-php
src/Twizo.php
Twizo.createWidgetRegisterSession
public function createWidgetRegisterSession(array $allowedTypes = null, $recipient = null, $backupCodeIdentifier = null, $totpIdentifier = null, $issuer = null) { $widgetRegisterSession = $this->factory->createWidgetRegisterSession($allowedTypes, $recipient, $backupCodeIdentifier, $totpIdentifier, $issuer); return $widgetRegisterSession; }
php
public function createWidgetRegisterSession(array $allowedTypes = null, $recipient = null, $backupCodeIdentifier = null, $totpIdentifier = null, $issuer = null) { $widgetRegisterSession = $this->factory->createWidgetRegisterSession($allowedTypes, $recipient, $backupCodeIdentifier, $totpIdentifier, $issuer); return $widgetRegisterSession; }
[ "public", "function", "createWidgetRegisterSession", "(", "array", "$", "allowedTypes", "=", "null", ",", "$", "recipient", "=", "null", ",", "$", "backupCodeIdentifier", "=", "null", ",", "$", "totpIdentifier", "=", "null", ",", "$", "issuer", "=", "null", ")", "{", "$", "widgetRegisterSession", "=", "$", "this", "->", "factory", "->", "createWidgetRegisterSession", "(", "$", "allowedTypes", ",", "$", "recipient", ",", "$", "backupCodeIdentifier", ",", "$", "totpIdentifier", ",", "$", "issuer", ")", ";", "return", "$", "widgetRegisterSession", ";", "}" ]
Create widget register session with the supplied data @param array|null $allowedTypes @param string|null $recipient @param string|null $backupCodeIdentifier @param string|null $totpIdentifier @param string|null $issuer @return WidgetRegisterSession
[ "Create", "widget", "register", "session", "with", "the", "supplied", "data" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L176-L181
221,754
twizoapi/lib-api-php
src/Twizo.php
Twizo.getBackupCode
public function getBackupCode($identifier) { $backupCode = $this->factory->createEmptyBackupCode(); $backupCode->populate($identifier); return $backupCode; }
php
public function getBackupCode($identifier) { $backupCode = $this->factory->createEmptyBackupCode(); $backupCode->populate($identifier); return $backupCode; }
[ "public", "function", "getBackupCode", "(", "$", "identifier", ")", "{", "$", "backupCode", "=", "$", "this", "->", "factory", "->", "createEmptyBackupCode", "(", ")", ";", "$", "backupCode", "->", "populate", "(", "$", "identifier", ")", ";", "return", "$", "backupCode", ";", "}" ]
Get backup code status for the supplied identifier @param string $identifier @return BackupCode @throws Exception
[ "Get", "backup", "code", "status", "for", "the", "supplied", "identifier" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L192-L198
221,755
twizoapi/lib-api-php
src/Twizo.php
Twizo.getBioVoiceRegistration
public function getBioVoiceRegistration($registrationId) { $bioVoiceRegistration = $this->factory->createEmptyBioVoiceRegistration(); $bioVoiceRegistration->populate($registrationId); return $bioVoiceRegistration; }
php
public function getBioVoiceRegistration($registrationId) { $bioVoiceRegistration = $this->factory->createEmptyBioVoiceRegistration(); $bioVoiceRegistration->populate($registrationId); return $bioVoiceRegistration; }
[ "public", "function", "getBioVoiceRegistration", "(", "$", "registrationId", ")", "{", "$", "bioVoiceRegistration", "=", "$", "this", "->", "factory", "->", "createEmptyBioVoiceRegistration", "(", ")", ";", "$", "bioVoiceRegistration", "->", "populate", "(", "$", "registrationId", ")", ";", "return", "$", "bioVoiceRegistration", ";", "}" ]
Get bio voice registration status for the supplied registrationId @param string $registrationId @return BioVoiceRegistration @throws Exception
[ "Get", "bio", "voice", "registration", "status", "for", "the", "supplied", "registrationId" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L222-L228
221,756
twizoapi/lib-api-php
src/Twizo.php
Twizo.getBioVoiceSubscription
public function getBioVoiceSubscription($recipient) { $bioVoiceSubscription = $this->factory->createEmptyBioVoiceSubscription(); $bioVoiceSubscription->populate($recipient); return $bioVoiceSubscription; }
php
public function getBioVoiceSubscription($recipient) { $bioVoiceSubscription = $this->factory->createEmptyBioVoiceSubscription(); $bioVoiceSubscription->populate($recipient); return $bioVoiceSubscription; }
[ "public", "function", "getBioVoiceSubscription", "(", "$", "recipient", ")", "{", "$", "bioVoiceSubscription", "=", "$", "this", "->", "factory", "->", "createEmptyBioVoiceSubscription", "(", ")", ";", "$", "bioVoiceSubscription", "->", "populate", "(", "$", "recipient", ")", ";", "return", "$", "bioVoiceSubscription", ";", "}" ]
Get bio voice subscription status for the supplied recipient @param string $recipient @return BioVoiceSubscription @throws Exception
[ "Get", "bio", "voice", "subscription", "status", "for", "the", "supplied", "recipient" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L238-L244
221,757
twizoapi/lib-api-php
src/Twizo.php
Twizo.getInstance
public static function getInstance($secret, $apiHost) { if (!isset(self::$instances[$secret][$apiHost])) { self::$instances[$secret][$apiHost] = new self( new Entity\Factory( new Client\Curl($secret, $apiHost) ) ); } return self::$instances[$secret][$apiHost]; }
php
public static function getInstance($secret, $apiHost) { if (!isset(self::$instances[$secret][$apiHost])) { self::$instances[$secret][$apiHost] = new self( new Entity\Factory( new Client\Curl($secret, $apiHost) ) ); } return self::$instances[$secret][$apiHost]; }
[ "public", "static", "function", "getInstance", "(", "$", "secret", ",", "$", "apiHost", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instances", "[", "$", "secret", "]", "[", "$", "apiHost", "]", ")", ")", "{", "self", "::", "$", "instances", "[", "$", "secret", "]", "[", "$", "apiHost", "]", "=", "new", "self", "(", "new", "Entity", "\\", "Factory", "(", "new", "Client", "\\", "Curl", "(", "$", "secret", ",", "$", "apiHost", ")", ")", ")", ";", "}", "return", "self", "::", "$", "instances", "[", "$", "secret", "]", "[", "$", "apiHost", "]", ";", "}" ]
Get a new Twizo instance @param string $secret @param string $apiHost @return TwizoInterface
[ "Get", "a", "new", "Twizo", "instance" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L254-L265
221,758
twizoapi/lib-api-php
src/Twizo.php
Twizo.getNumberLookup
public function getNumberLookup($messageId) { $numberLookup = $this->factory->createEmptyNumberLookup(); $numberLookup->populate($messageId); return $numberLookup; }
php
public function getNumberLookup($messageId) { $numberLookup = $this->factory->createEmptyNumberLookup(); $numberLookup->populate($messageId); return $numberLookup; }
[ "public", "function", "getNumberLookup", "(", "$", "messageId", ")", "{", "$", "numberLookup", "=", "$", "this", "->", "factory", "->", "createEmptyNumberLookup", "(", ")", ";", "$", "numberLookup", "->", "populate", "(", "$", "messageId", ")", ";", "return", "$", "numberLookup", ";", "}" ]
Get number lookup status for the supplied message id @param string $messageId @return NumberLookup @throws Exception
[ "Get", "number", "lookup", "status", "for", "the", "supplied", "message", "id" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L276-L282
221,759
twizoapi/lib-api-php
src/Twizo.php
Twizo.getNumberLookupResults
public function getNumberLookupResults() { $numberLookupPoll = $this->factory->createNumberLookupPoll(); $numberLookupPoll->send(); $resultList = array(); foreach ($numberLookupPoll->getMessages() as $message) { $resultList[] = $numberLookup = $this->factory->createEmptyNumberLookup(); $numberLookup->setFields($message); } $numberLookupPoll->delete(); return $resultList; }
php
public function getNumberLookupResults() { $numberLookupPoll = $this->factory->createNumberLookupPoll(); $numberLookupPoll->send(); $resultList = array(); foreach ($numberLookupPoll->getMessages() as $message) { $resultList[] = $numberLookup = $this->factory->createEmptyNumberLookup(); $numberLookup->setFields($message); } $numberLookupPoll->delete(); return $resultList; }
[ "public", "function", "getNumberLookupResults", "(", ")", "{", "$", "numberLookupPoll", "=", "$", "this", "->", "factory", "->", "createNumberLookupPoll", "(", ")", ";", "$", "numberLookupPoll", "->", "send", "(", ")", ";", "$", "resultList", "=", "array", "(", ")", ";", "foreach", "(", "$", "numberLookupPoll", "->", "getMessages", "(", ")", "as", "$", "message", ")", "{", "$", "resultList", "[", "]", "=", "$", "numberLookup", "=", "$", "this", "->", "factory", "->", "createEmptyNumberLookup", "(", ")", ";", "$", "numberLookup", "->", "setFields", "(", "$", "message", ")", ";", "}", "$", "numberLookupPoll", "->", "delete", "(", ")", ";", "return", "$", "resultList", ";", "}" ]
Get number lookup polling results; returns only results for messages which have result type polling enabled @return array @throws Exception
[ "Get", "number", "lookup", "polling", "results", ";", "returns", "only", "results", "for", "messages", "which", "have", "result", "type", "polling", "enabled" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L291-L305
221,760
twizoapi/lib-api-php
src/Twizo.php
Twizo.getSms
public function getSms($messageId) { $sms = $this->factory->createEmptySms(); $sms->populate($messageId); return $sms; }
php
public function getSms($messageId) { $sms = $this->factory->createEmptySms(); $sms->populate($messageId); return $sms; }
[ "public", "function", "getSms", "(", "$", "messageId", ")", "{", "$", "sms", "=", "$", "this", "->", "factory", "->", "createEmptySms", "(", ")", ";", "$", "sms", "->", "populate", "(", "$", "messageId", ")", ";", "return", "$", "sms", ";", "}" ]
Get sms status for the supplied message id @param string $messageId @return Sms @throws Exception
[ "Get", "sms", "status", "for", "the", "supplied", "message", "id" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L316-L322
221,761
twizoapi/lib-api-php
src/Twizo.php
Twizo.getSmsResults
public function getSmsResults() { $smsPoll = $this->factory->createSmsPoll(); $smsPoll->send(); $resultList = array(); foreach ($smsPoll->getMessages() as $message) { $resultList[] = $sms = $this->factory->createEmptySms(); $sms->setFields($message); } $smsPoll->delete(); return $resultList; }
php
public function getSmsResults() { $smsPoll = $this->factory->createSmsPoll(); $smsPoll->send(); $resultList = array(); foreach ($smsPoll->getMessages() as $message) { $resultList[] = $sms = $this->factory->createEmptySms(); $sms->setFields($message); } $smsPoll->delete(); return $resultList; }
[ "public", "function", "getSmsResults", "(", ")", "{", "$", "smsPoll", "=", "$", "this", "->", "factory", "->", "createSmsPoll", "(", ")", ";", "$", "smsPoll", "->", "send", "(", ")", ";", "$", "resultList", "=", "array", "(", ")", ";", "foreach", "(", "$", "smsPoll", "->", "getMessages", "(", ")", "as", "$", "message", ")", "{", "$", "resultList", "[", "]", "=", "$", "sms", "=", "$", "this", "->", "factory", "->", "createEmptySms", "(", ")", ";", "$", "sms", "->", "setFields", "(", "$", "message", ")", ";", "}", "$", "smsPoll", "->", "delete", "(", ")", ";", "return", "$", "resultList", ";", "}" ]
Get sms polling results; returns only results for messages which have result type polling enabled @return Sms[] @throws Exception
[ "Get", "sms", "polling", "results", ";", "returns", "only", "results", "for", "messages", "which", "have", "result", "type", "polling", "enabled" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L331-L345
221,762
twizoapi/lib-api-php
src/Twizo.php
Twizo.getTokenResult
public function getTokenResult($messageId, $token) { $verification = $this->factory->createEmptyVerification(); $verification->verify($token, $messageId); return $verification; }
php
public function getTokenResult($messageId, $token) { $verification = $this->factory->createEmptyVerification(); $verification->verify($token, $messageId); return $verification; }
[ "public", "function", "getTokenResult", "(", "$", "messageId", ",", "$", "token", ")", "{", "$", "verification", "=", "$", "this", "->", "factory", "->", "createEmptyVerification", "(", ")", ";", "$", "verification", "->", "verify", "(", "$", "token", ",", "$", "messageId", ")", ";", "return", "$", "verification", ";", "}" ]
Verify token and return the verification object when successfully verified; otherwise return an exception @param string $messageId @param string $token @return Verification @throws Exception
[ "Verify", "token", "and", "return", "the", "verification", "object", "when", "successfully", "verified", ";", "otherwise", "return", "an", "exception" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L357-L363
221,763
twizoapi/lib-api-php
src/Twizo.php
Twizo.getTotp
public function getTotp($identifier) { $totp = $this->factory->createEmptyTotp(); $totp->populate($identifier); return $totp; }
php
public function getTotp($identifier) { $totp = $this->factory->createEmptyTotp(); $totp->populate($identifier); return $totp; }
[ "public", "function", "getTotp", "(", "$", "identifier", ")", "{", "$", "totp", "=", "$", "this", "->", "factory", "->", "createEmptyTotp", "(", ")", ";", "$", "totp", "->", "populate", "(", "$", "identifier", ")", ";", "return", "$", "totp", ";", "}" ]
Get totp status for the supplied identifier @param string $identifier @return Totp @throws Exception
[ "Get", "totp", "status", "for", "the", "supplied", "identifier" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L374-L380
221,764
twizoapi/lib-api-php
src/Twizo.php
Twizo.getVerification
public function getVerification($messageId) { $verification = $this->factory->createEmptyVerification(); $verification->populate($messageId); return $verification; }
php
public function getVerification($messageId) { $verification = $this->factory->createEmptyVerification(); $verification->populate($messageId); return $verification; }
[ "public", "function", "getVerification", "(", "$", "messageId", ")", "{", "$", "verification", "=", "$", "this", "->", "factory", "->", "createEmptyVerification", "(", ")", ";", "$", "verification", "->", "populate", "(", "$", "messageId", ")", ";", "return", "$", "verification", ";", "}" ]
Get verification status for the supplied message id @param string $messageId @return Verification @throws Exception
[ "Get", "verification", "status", "for", "the", "supplied", "message", "id" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L391-L397
221,765
twizoapi/lib-api-php
src/Twizo.php
Twizo.getWidgetSession
public function getWidgetSession($sessionToken, $recipient = null, $backupCodeIdentifier = null, $totpIdentifier = null) { $widgetSession = $this->factory->createEmptyWidgetSession(); $widgetSession->populate($sessionToken, $recipient, $backupCodeIdentifier, $totpIdentifier); return $widgetSession; }
php
public function getWidgetSession($sessionToken, $recipient = null, $backupCodeIdentifier = null, $totpIdentifier = null) { $widgetSession = $this->factory->createEmptyWidgetSession(); $widgetSession->populate($sessionToken, $recipient, $backupCodeIdentifier, $totpIdentifier); return $widgetSession; }
[ "public", "function", "getWidgetSession", "(", "$", "sessionToken", ",", "$", "recipient", "=", "null", ",", "$", "backupCodeIdentifier", "=", "null", ",", "$", "totpIdentifier", "=", "null", ")", "{", "$", "widgetSession", "=", "$", "this", "->", "factory", "->", "createEmptyWidgetSession", "(", ")", ";", "$", "widgetSession", "->", "populate", "(", "$", "sessionToken", ",", "$", "recipient", ",", "$", "backupCodeIdentifier", ",", "$", "totpIdentifier", ")", ";", "return", "$", "widgetSession", ";", "}" ]
Get widget session status for the supplied session token @param string $sessionToken @param string|null $recipient @param string|null $backupCodeIdentifier @param string|null $totpIdentifier @return WidgetSession @throws Exception
[ "Get", "widget", "session", "status", "for", "the", "supplied", "session", "token" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L426-L432
221,766
twizoapi/lib-api-php
src/Twizo.php
Twizo.getWidgetRegisterSession
public function getWidgetRegisterSession($sessionToken) { $widgetRegisterSession = $this->factory->createEmptyWidgetRegisterSession(); $widgetRegisterSession->populate($sessionToken); return $widgetRegisterSession; }
php
public function getWidgetRegisterSession($sessionToken) { $widgetRegisterSession = $this->factory->createEmptyWidgetRegisterSession(); $widgetRegisterSession->populate($sessionToken); return $widgetRegisterSession; }
[ "public", "function", "getWidgetRegisterSession", "(", "$", "sessionToken", ")", "{", "$", "widgetRegisterSession", "=", "$", "this", "->", "factory", "->", "createEmptyWidgetRegisterSession", "(", ")", ";", "$", "widgetRegisterSession", "->", "populate", "(", "$", "sessionToken", ")", ";", "return", "$", "widgetRegisterSession", ";", "}" ]
Get widget register session status for the supplied session token @param string $sessionToken @return WidgetRegisterSession @throws Exception
[ "Get", "widget", "register", "session", "status", "for", "the", "supplied", "session", "token" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L443-L449
221,767
twizoapi/lib-api-php
src/Twizo.php
Twizo.verifyToken
public function verifyToken($messageId, $token) { try { $verification = $this->getTokenResult($messageId, $token); return ($verification->getStatusCode() === Verification::STATUS_SUCCESS); } catch (Exception $e) { return false; } }
php
public function verifyToken($messageId, $token) { try { $verification = $this->getTokenResult($messageId, $token); return ($verification->getStatusCode() === Verification::STATUS_SUCCESS); } catch (Exception $e) { return false; } }
[ "public", "function", "verifyToken", "(", "$", "messageId", ",", "$", "token", ")", "{", "try", "{", "$", "verification", "=", "$", "this", "->", "getTokenResult", "(", "$", "messageId", ",", "$", "token", ")", ";", "return", "(", "$", "verification", "->", "getStatusCode", "(", ")", "===", "Verification", "::", "STATUS_SUCCESS", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Verify token and return true when successful and false when there is an error @param string $messageId @param string $token @return bool
[ "Verify", "token", "and", "return", "true", "when", "successful", "and", "false", "when", "there", "is", "an", "error" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/src/Twizo.php#L474-L483
221,768
neos/fluid
Classes/TYPO3/Fluid/Core/Parser/SyntaxTree/BooleanNode.php
BooleanNode.convertToBoolean
public static function convertToBoolean($value) { if (is_bool($value)) { return $value; } if (is_numeric($value)) { return $value > 0; } if (is_string($value)) { return (!empty($value) && strtolower($value) !== 'false'); } if (is_array($value) || (is_object($value) && $value instanceof \Countable)) { return count($value) > 0; } if (is_object($value)) { return true; } return false; }
php
public static function convertToBoolean($value) { if (is_bool($value)) { return $value; } if (is_numeric($value)) { return $value > 0; } if (is_string($value)) { return (!empty($value) && strtolower($value) !== 'false'); } if (is_array($value) || (is_object($value) && $value instanceof \Countable)) { return count($value) > 0; } if (is_object($value)) { return true; } return false; }
[ "public", "static", "function", "convertToBoolean", "(", "$", "value", ")", "{", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "if", "(", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "$", "value", ">", "0", ";", "}", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "return", "(", "!", "empty", "(", "$", "value", ")", "&&", "strtolower", "(", "$", "value", ")", "!==", "'false'", ")", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", "||", "(", "is_object", "(", "$", "value", ")", "&&", "$", "value", "instanceof", "\\", "Countable", ")", ")", "{", "return", "count", "(", "$", "value", ")", ">", "0", ";", "}", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Convert argument strings to their equivalents. Needed to handle strings with a boolean meaning. Must be public and static as it is used from inside cached templates. @param mixed $value Value to be converted to boolean @return boolean
[ "Convert", "argument", "strings", "to", "their", "equivalents", ".", "Needed", "to", "handle", "strings", "with", "a", "boolean", "meaning", "." ]
ded6be84a9487f7e0e204703a30b12d2c58c0efd
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/SyntaxTree/BooleanNode.php#L335-L353
221,769
neos/fluid
Classes/TYPO3/Fluid/Core/Parser/SyntaxTree/AbstractNode.php
AbstractNode.evaluateChildNodes
public function evaluateChildNodes(RenderingContextInterface $renderingContext) { $output = null; /** @var $subNode NodeInterface */ foreach ($this->childNodes as $subNode) { if ($output === null) { $output = $subNode->evaluate($renderingContext); } else { if (is_object($output)) { if (!method_exists($output, '__toString')) { throw new Parser\Exception('Cannot cast object of type "' . get_class($output) . '" to string.', 1248356140); } $output = $output->__toString(); } else { $output = (string) $output; } $subNodeOutput = $subNode->evaluate($renderingContext); if (is_object($subNodeOutput)) { if (!method_exists($subNodeOutput, '__toString')) { throw new Parser\Exception('Cannot cast object of type "' . get_class($subNodeOutput) . '" to string.', 1273753083); } $output .= $subNodeOutput->__toString(); } else { $output .= (string) $subNodeOutput; } } } return $output; }
php
public function evaluateChildNodes(RenderingContextInterface $renderingContext) { $output = null; /** @var $subNode NodeInterface */ foreach ($this->childNodes as $subNode) { if ($output === null) { $output = $subNode->evaluate($renderingContext); } else { if (is_object($output)) { if (!method_exists($output, '__toString')) { throw new Parser\Exception('Cannot cast object of type "' . get_class($output) . '" to string.', 1248356140); } $output = $output->__toString(); } else { $output = (string) $output; } $subNodeOutput = $subNode->evaluate($renderingContext); if (is_object($subNodeOutput)) { if (!method_exists($subNodeOutput, '__toString')) { throw new Parser\Exception('Cannot cast object of type "' . get_class($subNodeOutput) . '" to string.', 1273753083); } $output .= $subNodeOutput->__toString(); } else { $output .= (string) $subNodeOutput; } } } return $output; }
[ "public", "function", "evaluateChildNodes", "(", "RenderingContextInterface", "$", "renderingContext", ")", "{", "$", "output", "=", "null", ";", "/** @var $subNode NodeInterface */", "foreach", "(", "$", "this", "->", "childNodes", "as", "$", "subNode", ")", "{", "if", "(", "$", "output", "===", "null", ")", "{", "$", "output", "=", "$", "subNode", "->", "evaluate", "(", "$", "renderingContext", ")", ";", "}", "else", "{", "if", "(", "is_object", "(", "$", "output", ")", ")", "{", "if", "(", "!", "method_exists", "(", "$", "output", ",", "'__toString'", ")", ")", "{", "throw", "new", "Parser", "\\", "Exception", "(", "'Cannot cast object of type \"'", ".", "get_class", "(", "$", "output", ")", ".", "'\" to string.'", ",", "1248356140", ")", ";", "}", "$", "output", "=", "$", "output", "->", "__toString", "(", ")", ";", "}", "else", "{", "$", "output", "=", "(", "string", ")", "$", "output", ";", "}", "$", "subNodeOutput", "=", "$", "subNode", "->", "evaluate", "(", "$", "renderingContext", ")", ";", "if", "(", "is_object", "(", "$", "subNodeOutput", ")", ")", "{", "if", "(", "!", "method_exists", "(", "$", "subNodeOutput", ",", "'__toString'", ")", ")", "{", "throw", "new", "Parser", "\\", "Exception", "(", "'Cannot cast object of type \"'", ".", "get_class", "(", "$", "subNodeOutput", ")", ".", "'\" to string.'", ",", "1273753083", ")", ";", "}", "$", "output", ".=", "$", "subNodeOutput", "->", "__toString", "(", ")", ";", "}", "else", "{", "$", "output", ".=", "(", "string", ")", "$", "subNodeOutput", ";", "}", "}", "}", "return", "$", "output", ";", "}" ]
Evaluate all child nodes and return the evaluated results. @param RenderingContextInterface $renderingContext @return mixed Normally, an object is returned - in case it is concatenated with a string, a string is returned. @throws Parser\Exception
[ "Evaluate", "all", "child", "nodes", "and", "return", "the", "evaluated", "results", "." ]
ded6be84a9487f7e0e204703a30b12d2c58c0efd
https://github.com/neos/fluid/blob/ded6be84a9487f7e0e204703a30b12d2c58c0efd/Classes/TYPO3/Fluid/Core/Parser/SyntaxTree/AbstractNode.php#L36-L65
221,770
twizoapi/lib-api-php
examples/util/EntityFormatter.php
EntityFormatter.getEntityValues
public static function getEntityValues(\Twizo\Api\AbstractEntity $entity) { $result = array(); $methods = get_class_methods($entity); sort($methods); foreach ($methods as $method) { if (substr($method, 0, 3) == 'get') { $result[$method] = $entity->$method(); } } return $result; }
php
public static function getEntityValues(\Twizo\Api\AbstractEntity $entity) { $result = array(); $methods = get_class_methods($entity); sort($methods); foreach ($methods as $method) { if (substr($method, 0, 3) == 'get') { $result[$method] = $entity->$method(); } } return $result; }
[ "public", "static", "function", "getEntityValues", "(", "\\", "Twizo", "\\", "Api", "\\", "AbstractEntity", "$", "entity", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "methods", "=", "get_class_methods", "(", "$", "entity", ")", ";", "sort", "(", "$", "methods", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "if", "(", "substr", "(", "$", "method", ",", "0", ",", "3", ")", "==", "'get'", ")", "{", "$", "result", "[", "$", "method", "]", "=", "$", "entity", "->", "$", "method", "(", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Retrieve all getter function values from object @param \Twizo\Api\AbstractEntity $entity @return array
[ "Retrieve", "all", "getter", "function", "values", "from", "object" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/examples/util/EntityFormatter.php#L24-L36
221,771
twizoapi/lib-api-php
examples/util/EntityFormatter.php
EntityFormatter.getEntity
public static function getEntity(\Twizo\Api\AbstractEntity $entity) { $result = ''; $values = self::getEntityValues($entity); $result .= str_repeat('-', strlen(get_class($entity)) + 4) . PHP_EOL; $result .= '| ' . get_class($entity) . ' |' . PHP_EOL; $result .= str_repeat('-', strlen(get_class($entity)) + 4) . PHP_EOL; foreach ($values as $method => $value) { $result .= substr($method, 3) . ' : ' . var_export($value, true) . PHP_EOL; } return $result; }
php
public static function getEntity(\Twizo\Api\AbstractEntity $entity) { $result = ''; $values = self::getEntityValues($entity); $result .= str_repeat('-', strlen(get_class($entity)) + 4) . PHP_EOL; $result .= '| ' . get_class($entity) . ' |' . PHP_EOL; $result .= str_repeat('-', strlen(get_class($entity)) + 4) . PHP_EOL; foreach ($values as $method => $value) { $result .= substr($method, 3) . ' : ' . var_export($value, true) . PHP_EOL; } return $result; }
[ "public", "static", "function", "getEntity", "(", "\\", "Twizo", "\\", "Api", "\\", "AbstractEntity", "$", "entity", ")", "{", "$", "result", "=", "''", ";", "$", "values", "=", "self", "::", "getEntityValues", "(", "$", "entity", ")", ";", "$", "result", ".=", "str_repeat", "(", "'-'", ",", "strlen", "(", "get_class", "(", "$", "entity", ")", ")", "+", "4", ")", ".", "PHP_EOL", ";", "$", "result", ".=", "'| '", ".", "get_class", "(", "$", "entity", ")", ".", "' |'", ".", "PHP_EOL", ";", "$", "result", ".=", "str_repeat", "(", "'-'", ",", "strlen", "(", "get_class", "(", "$", "entity", ")", ")", "+", "4", ")", ".", "PHP_EOL", ";", "foreach", "(", "$", "values", "as", "$", "method", "=>", "$", "value", ")", "{", "$", "result", ".=", "substr", "(", "$", "method", ",", "3", ")", ".", "' : '", ".", "var_export", "(", "$", "value", ",", "true", ")", ".", "PHP_EOL", ";", "}", "return", "$", "result", ";", "}" ]
Generate string with entity class name and a list of the entity values @param \Twizo\Api\AbstractEntity $entity @return string
[ "Generate", "string", "with", "entity", "class", "name", "and", "a", "list", "of", "the", "entity", "values" ]
2e545d859784184138332c9b5bfc063940e3c926
https://github.com/twizoapi/lib-api-php/blob/2e545d859784184138332c9b5bfc063940e3c926/examples/util/EntityFormatter.php#L55-L69
221,772
puli/composer-plugin
src/PuliRunner.php
PuliRunner.run
public function run($command, array $args = array()) { $replacements = array(); foreach ($args as $key => $arg) { $replacements['%'.$key.'%'] = ProcessUtils::escapeArgument($arg); } // Disable colorization so that we can process the output // Enable exception traces by using the "-vv" switch $fullCommand = sprintf('%s %s --no-ansi -vv', $this->puli, strtr($command, $replacements)); $process = new Process($fullCommand); $process->run(); if (!$process->isSuccessful()) { throw PuliRunnerException::forProcess($process); } // Normalize line endings across systems return str_replace("\r\n", "\n", $process->getOutput()); }
php
public function run($command, array $args = array()) { $replacements = array(); foreach ($args as $key => $arg) { $replacements['%'.$key.'%'] = ProcessUtils::escapeArgument($arg); } // Disable colorization so that we can process the output // Enable exception traces by using the "-vv" switch $fullCommand = sprintf('%s %s --no-ansi -vv', $this->puli, strtr($command, $replacements)); $process = new Process($fullCommand); $process->run(); if (!$process->isSuccessful()) { throw PuliRunnerException::forProcess($process); } // Normalize line endings across systems return str_replace("\r\n", "\n", $process->getOutput()); }
[ "public", "function", "run", "(", "$", "command", ",", "array", "$", "args", "=", "array", "(", ")", ")", "{", "$", "replacements", "=", "array", "(", ")", ";", "foreach", "(", "$", "args", "as", "$", "key", "=>", "$", "arg", ")", "{", "$", "replacements", "[", "'%'", ".", "$", "key", ".", "'%'", "]", "=", "ProcessUtils", "::", "escapeArgument", "(", "$", "arg", ")", ";", "}", "// Disable colorization so that we can process the output", "// Enable exception traces by using the \"-vv\" switch", "$", "fullCommand", "=", "sprintf", "(", "'%s %s --no-ansi -vv'", ",", "$", "this", "->", "puli", ",", "strtr", "(", "$", "command", ",", "$", "replacements", ")", ")", ";", "$", "process", "=", "new", "Process", "(", "$", "fullCommand", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "!", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "throw", "PuliRunnerException", "::", "forProcess", "(", "$", "process", ")", ";", "}", "// Normalize line endings across systems", "return", "str_replace", "(", "\"\\r\\n\"", ",", "\"\\n\"", ",", "$", "process", "->", "getOutput", "(", ")", ")", ";", "}" ]
Runs a Puli command. @param string $command The Puli command to run. @param string[] $args Arguments to quote and insert into the command. For each key "key" in this array, the placeholder "%key%" should be present in the command string. @return string The lines of the output.
[ "Runs", "a", "Puli", "command", "." ]
8b71670fb2cfd23de4e6cd0e93c03df2c86c46ba
https://github.com/puli/composer-plugin/blob/8b71670fb2cfd23de4e6cd0e93c03df2c86c46ba/src/PuliRunner.php#L96-L117
221,773
puli/composer-plugin
src/PuliPluginImpl.php
PuliPluginImpl.loadComposerPackages
private function loadComposerPackages() { $repository = $this->composer->getRepositoryManager()->getLocalRepository(); $packages = array(); foreach ($repository->getPackages() as $package) { /* @var PackageInterface $package */ $packages[$package->getName()] = $package; } return $packages; }
php
private function loadComposerPackages() { $repository = $this->composer->getRepositoryManager()->getLocalRepository(); $packages = array(); foreach ($repository->getPackages() as $package) { /* @var PackageInterface $package */ $packages[$package->getName()] = $package; } return $packages; }
[ "private", "function", "loadComposerPackages", "(", ")", "{", "$", "repository", "=", "$", "this", "->", "composer", "->", "getRepositoryManager", "(", ")", "->", "getLocalRepository", "(", ")", ";", "$", "packages", "=", "array", "(", ")", ";", "foreach", "(", "$", "repository", "->", "getPackages", "(", ")", "as", "$", "package", ")", "{", "/* @var PackageInterface $package */", "$", "packages", "[", "$", "package", "->", "getName", "(", ")", "]", "=", "$", "package", ";", "}", "return", "$", "packages", ";", "}" ]
Loads Composer's currently installed packages. @return PackageInterface[] The installed packages indexed by their names.
[ "Loads", "Composer", "s", "currently", "installed", "packages", "." ]
8b71670fb2cfd23de4e6cd0e93c03df2c86c46ba
https://github.com/puli/composer-plugin/blob/8b71670fb2cfd23de4e6cd0e93c03df2c86c46ba/src/PuliPluginImpl.php#L523-L534
221,774
tgallice/wit-php
src/Model/Context.php
Context.setReferenceTime
public function setReferenceTime(\DateTimeInterface $dateTime) { $dt = $dateTime->format(DATE_ISO8601); $this->add('reference_time', $dt); }
php
public function setReferenceTime(\DateTimeInterface $dateTime) { $dt = $dateTime->format(DATE_ISO8601); $this->add('reference_time', $dt); }
[ "public", "function", "setReferenceTime", "(", "\\", "DateTimeInterface", "$", "dateTime", ")", "{", "$", "dt", "=", "$", "dateTime", "->", "format", "(", "DATE_ISO8601", ")", ";", "$", "this", "->", "add", "(", "'reference_time'", ",", "$", "dt", ")", ";", "}" ]
Set the reference time in ISO8601 format @param \DateTimeInterface $dateTime
[ "Set", "the", "reference", "time", "in", "ISO8601", "format" ]
06b8531ea61f8b8c286a12c08d29b1ede9474f13
https://github.com/tgallice/wit-php/blob/06b8531ea61f8b8c286a12c08d29b1ede9474f13/src/Model/Context.php#L51-L55
221,775
rkit/filemanager-yii2
src/actions/UploadAction.php
UploadAction.applyPreset
private function applyPreset($presetAfterUpload, $file) { foreach ($presetAfterUpload as $preset) { $this->model->thumbUrl($this->attribute, $preset, $file); } }
php
private function applyPreset($presetAfterUpload, $file) { foreach ($presetAfterUpload as $preset) { $this->model->thumbUrl($this->attribute, $preset, $file); } }
[ "private", "function", "applyPreset", "(", "$", "presetAfterUpload", ",", "$", "file", ")", "{", "foreach", "(", "$", "presetAfterUpload", "as", "$", "preset", ")", "{", "$", "this", "->", "model", "->", "thumbUrl", "(", "$", "this", "->", "attribute", ",", "$", "preset", ",", "$", "file", ")", ";", "}", "}" ]
Apply preset for file @param array $presetAfterUpload @param ActiveRecord $file The file model @return void
[ "Apply", "preset", "for", "file" ]
02c7e772710690163f1f1b8a5c5822d18ffaf9f6
https://github.com/rkit/filemanager-yii2/blob/02c7e772710690163f1f1b8a5c5822d18ffaf9f6/src/actions/UploadAction.php#L139-L144
221,776
rkit/filemanager-yii2
src/behaviors/FileBehavior.php
FileBehavior.generateThumb
private function generateThumb($attribute, $preset, $path) { $thumbPath = pathinfo($path, PATHINFO_FILENAME); $thumbPath = str_replace($thumbPath, $preset . '_' . $thumbPath, $path); $realPath = $this->fileStorage($attribute)->path; if (!file_exists($realPath . $thumbPath) && file_exists($realPath . $path)) { $handlerPreset = $this->fileOption($attribute, 'preset.'.$preset); $handlerPreset($realPath, $path, $thumbPath); } return $thumbPath; }
php
private function generateThumb($attribute, $preset, $path) { $thumbPath = pathinfo($path, PATHINFO_FILENAME); $thumbPath = str_replace($thumbPath, $preset . '_' . $thumbPath, $path); $realPath = $this->fileStorage($attribute)->path; if (!file_exists($realPath . $thumbPath) && file_exists($realPath . $path)) { $handlerPreset = $this->fileOption($attribute, 'preset.'.$preset); $handlerPreset($realPath, $path, $thumbPath); } return $thumbPath; }
[ "private", "function", "generateThumb", "(", "$", "attribute", ",", "$", "preset", ",", "$", "path", ")", "{", "$", "thumbPath", "=", "pathinfo", "(", "$", "path", ",", "PATHINFO_FILENAME", ")", ";", "$", "thumbPath", "=", "str_replace", "(", "$", "thumbPath", ",", "$", "preset", ".", "'_'", ".", "$", "thumbPath", ",", "$", "path", ")", ";", "$", "realPath", "=", "$", "this", "->", "fileStorage", "(", "$", "attribute", ")", "->", "path", ";", "if", "(", "!", "file_exists", "(", "$", "realPath", ".", "$", "thumbPath", ")", "&&", "file_exists", "(", "$", "realPath", ".", "$", "path", ")", ")", "{", "$", "handlerPreset", "=", "$", "this", "->", "fileOption", "(", "$", "attribute", ",", "'preset.'", ".", "$", "preset", ")", ";", "$", "handlerPreset", "(", "$", "realPath", ",", "$", "path", ",", "$", "thumbPath", ")", ";", "}", "return", "$", "thumbPath", ";", "}" ]
Generate a thumb @param string $attribute The attribute name @param string $preset The preset name @param string $path The file path @return string The thumb path
[ "Generate", "a", "thumb" ]
02c7e772710690163f1f1b8a5c5822d18ffaf9f6
https://github.com/rkit/filemanager-yii2/blob/02c7e772710690163f1f1b8a5c5822d18ffaf9f6/src/behaviors/FileBehavior.php#L170-L182
221,777
rkit/filemanager-yii2
src/behaviors/FileBehavior.php
FileBehavior.templatePath
private function templatePath($attribute, $file = null) { $value = $this->owner->{$attribute}; $saveFilePath = $this->fileOption($attribute, 'saveFilePathInAttribute'); $isFilledPath = $saveFilePath && !empty($value); $saveFileId = $this->fileOption($attribute, 'saveFileIdInAttribute'); $isFilledId = $saveFileId && is_numeric($value) && $value; if (($isFilledPath || $isFilledId) && $file === null) { $file = $this->file($attribute); } if ($file !== null) { $handlerTemplatePath = $this->fileOption($attribute, 'templatePath'); return $handlerTemplatePath($file); } return $value; }
php
private function templatePath($attribute, $file = null) { $value = $this->owner->{$attribute}; $saveFilePath = $this->fileOption($attribute, 'saveFilePathInAttribute'); $isFilledPath = $saveFilePath && !empty($value); $saveFileId = $this->fileOption($attribute, 'saveFileIdInAttribute'); $isFilledId = $saveFileId && is_numeric($value) && $value; if (($isFilledPath || $isFilledId) && $file === null) { $file = $this->file($attribute); } if ($file !== null) { $handlerTemplatePath = $this->fileOption($attribute, 'templatePath'); return $handlerTemplatePath($file); } return $value; }
[ "private", "function", "templatePath", "(", "$", "attribute", ",", "$", "file", "=", "null", ")", "{", "$", "value", "=", "$", "this", "->", "owner", "->", "{", "$", "attribute", "}", ";", "$", "saveFilePath", "=", "$", "this", "->", "fileOption", "(", "$", "attribute", ",", "'saveFilePathInAttribute'", ")", ";", "$", "isFilledPath", "=", "$", "saveFilePath", "&&", "!", "empty", "(", "$", "value", ")", ";", "$", "saveFileId", "=", "$", "this", "->", "fileOption", "(", "$", "attribute", ",", "'saveFileIdInAttribute'", ")", ";", "$", "isFilledId", "=", "$", "saveFileId", "&&", "is_numeric", "(", "$", "value", ")", "&&", "$", "value", ";", "if", "(", "(", "$", "isFilledPath", "||", "$", "isFilledId", ")", "&&", "$", "file", "===", "null", ")", "{", "$", "file", "=", "$", "this", "->", "file", "(", "$", "attribute", ")", ";", "}", "if", "(", "$", "file", "!==", "null", ")", "{", "$", "handlerTemplatePath", "=", "$", "this", "->", "fileOption", "(", "$", "attribute", ",", "'templatePath'", ")", ";", "return", "$", "handlerTemplatePath", "(", "$", "file", ")", ";", "}", "return", "$", "value", ";", "}" ]
Generate file path by template @param string $attribute The attribute name @param ActiveRecord $file The file model @return string The file path
[ "Generate", "file", "path", "by", "template" ]
02c7e772710690163f1f1b8a5c5822d18ffaf9f6
https://github.com/rkit/filemanager-yii2/blob/02c7e772710690163f1f1b8a5c5822d18ffaf9f6/src/behaviors/FileBehavior.php#L191-L210
221,778
rkit/filemanager-yii2
src/behaviors/FileBehavior.php
FileBehavior.fileOption
public function fileOption($attribute, $option, $defaultValue = null) { return ArrayHelper::getValue($this->attributes[$attribute], $option, $defaultValue); }
php
public function fileOption($attribute, $option, $defaultValue = null) { return ArrayHelper::getValue($this->attributes[$attribute], $option, $defaultValue); }
[ "public", "function", "fileOption", "(", "$", "attribute", ",", "$", "option", ",", "$", "defaultValue", "=", "null", ")", "{", "return", "ArrayHelper", "::", "getValue", "(", "$", "this", "->", "attributes", "[", "$", "attribute", "]", ",", "$", "option", ",", "$", "defaultValue", ")", ";", "}" ]
Get file option @param string $attribute The attribute name @param string $option Option name @param mixed $defaultValue Default value @return mixed
[ "Get", "file", "option" ]
02c7e772710690163f1f1b8a5c5822d18ffaf9f6
https://github.com/rkit/filemanager-yii2/blob/02c7e772710690163f1f1b8a5c5822d18ffaf9f6/src/behaviors/FileBehavior.php#L234-L237
221,779
rkit/filemanager-yii2
src/behaviors/FileBehavior.php
FileBehavior.fileUrl
public function fileUrl($attribute, $file = null) { $path = $this->templatePath($attribute, $file); return Yii::getAlias($this->fileOption($attribute, 'baseUrl')) . $path; }
php
public function fileUrl($attribute, $file = null) { $path = $this->templatePath($attribute, $file); return Yii::getAlias($this->fileOption($attribute, 'baseUrl')) . $path; }
[ "public", "function", "fileUrl", "(", "$", "attribute", ",", "$", "file", "=", "null", ")", "{", "$", "path", "=", "$", "this", "->", "templatePath", "(", "$", "attribute", ",", "$", "file", ")", ";", "return", "Yii", "::", "getAlias", "(", "$", "this", "->", "fileOption", "(", "$", "attribute", ",", "'baseUrl'", ")", ")", ".", "$", "path", ";", "}" ]
Get file url @param string $attribute The attribute name @param ActiveRecord $file Use this file model @return string The file url
[ "Get", "file", "url" ]
02c7e772710690163f1f1b8a5c5822d18ffaf9f6
https://github.com/rkit/filemanager-yii2/blob/02c7e772710690163f1f1b8a5c5822d18ffaf9f6/src/behaviors/FileBehavior.php#L270-L274
221,780
rkit/filemanager-yii2
src/behaviors/FileBehavior.php
FileBehavior.fileExtraFields
public function fileExtraFields($attribute) { $fields = $this->fileBind->relations($this->owner, $attribute); if (!$this->fileOption($attribute, 'multiple')) { return array_shift($fields); } return $fields; }
php
public function fileExtraFields($attribute) { $fields = $this->fileBind->relations($this->owner, $attribute); if (!$this->fileOption($attribute, 'multiple')) { return array_shift($fields); } return $fields; }
[ "public", "function", "fileExtraFields", "(", "$", "attribute", ")", "{", "$", "fields", "=", "$", "this", "->", "fileBind", "->", "relations", "(", "$", "this", "->", "owner", ",", "$", "attribute", ")", ";", "if", "(", "!", "$", "this", "->", "fileOption", "(", "$", "attribute", ",", "'multiple'", ")", ")", "{", "return", "array_shift", "(", "$", "fields", ")", ";", "}", "return", "$", "fields", ";", "}" ]
Get extra fields of file @param string $attribute The attribute name @return array
[ "Get", "extra", "fields", "of", "file" ]
02c7e772710690163f1f1b8a5c5822d18ffaf9f6
https://github.com/rkit/filemanager-yii2/blob/02c7e772710690163f1f1b8a5c5822d18ffaf9f6/src/behaviors/FileBehavior.php#L282-L289
221,781
rkit/filemanager-yii2
src/behaviors/FileBehavior.php
FileBehavior.fileState
public function fileState($attribute) { $state = Yii::$app->session->get(Yii::$app->fileManager->sessionName); return ArrayHelper::getValue($state === null ? [] : $state, $attribute, []); }
php
public function fileState($attribute) { $state = Yii::$app->session->get(Yii::$app->fileManager->sessionName); return ArrayHelper::getValue($state === null ? [] : $state, $attribute, []); }
[ "public", "function", "fileState", "(", "$", "attribute", ")", "{", "$", "state", "=", "Yii", "::", "$", "app", "->", "session", "->", "get", "(", "Yii", "::", "$", "app", "->", "fileManager", "->", "sessionName", ")", ";", "return", "ArrayHelper", "::", "getValue", "(", "$", "state", "===", "null", "?", "[", "]", ":", "$", "state", ",", "$", "attribute", ",", "[", "]", ")", ";", "}" ]
Get file state @param string $attribute The attribute name @return array
[ "Get", "file", "state" ]
02c7e772710690163f1f1b8a5c5822d18ffaf9f6
https://github.com/rkit/filemanager-yii2/blob/02c7e772710690163f1f1b8a5c5822d18ffaf9f6/src/behaviors/FileBehavior.php#L336-L340
221,782
rkit/filemanager-yii2
src/behaviors/FileBehavior.php
FileBehavior.filePresetAfterUpload
public function filePresetAfterUpload($attribute) { $preset = $this->fileOption($attribute, 'applyPresetAfterUpload', []); if (is_string($preset) && $preset === '*') { return array_keys($this->fileOption($attribute, 'preset', [])); } return $preset; }
php
public function filePresetAfterUpload($attribute) { $preset = $this->fileOption($attribute, 'applyPresetAfterUpload', []); if (is_string($preset) && $preset === '*') { return array_keys($this->fileOption($attribute, 'preset', [])); } return $preset; }
[ "public", "function", "filePresetAfterUpload", "(", "$", "attribute", ")", "{", "$", "preset", "=", "$", "this", "->", "fileOption", "(", "$", "attribute", ",", "'applyPresetAfterUpload'", ",", "[", "]", ")", ";", "if", "(", "is_string", "(", "$", "preset", ")", "&&", "$", "preset", "===", "'*'", ")", "{", "return", "array_keys", "(", "$", "this", "->", "fileOption", "(", "$", "attribute", ",", "'preset'", ",", "[", "]", ")", ")", ";", "}", "return", "$", "preset", ";", "}" ]
Get the presets of the file for apply after upload @param string $attribute The attribute name @return array
[ "Get", "the", "presets", "of", "the", "file", "for", "apply", "after", "upload" ]
02c7e772710690163f1f1b8a5c5822d18ffaf9f6
https://github.com/rkit/filemanager-yii2/blob/02c7e772710690163f1f1b8a5c5822d18ffaf9f6/src/behaviors/FileBehavior.php#L348-L355
221,783
rkit/filemanager-yii2
src/behaviors/FileBehavior.php
FileBehavior.thumbUrl
public function thumbUrl($attribute, $preset, $file = null) { $path = $this->templatePath($attribute, $file); $thumbPath = $this->generateThumb($attribute, $preset, $path); return Yii::getAlias($this->fileOption($attribute, 'baseUrl')) . $thumbPath; }
php
public function thumbUrl($attribute, $preset, $file = null) { $path = $this->templatePath($attribute, $file); $thumbPath = $this->generateThumb($attribute, $preset, $path); return Yii::getAlias($this->fileOption($attribute, 'baseUrl')) . $thumbPath; }
[ "public", "function", "thumbUrl", "(", "$", "attribute", ",", "$", "preset", ",", "$", "file", "=", "null", ")", "{", "$", "path", "=", "$", "this", "->", "templatePath", "(", "$", "attribute", ",", "$", "file", ")", ";", "$", "thumbPath", "=", "$", "this", "->", "generateThumb", "(", "$", "attribute", ",", "$", "preset", ",", "$", "path", ")", ";", "return", "Yii", "::", "getAlias", "(", "$", "this", "->", "fileOption", "(", "$", "attribute", ",", "'baseUrl'", ")", ")", ".", "$", "thumbPath", ";", "}" ]
Create a thumb and return url @param string $attribute The attribute name @param string $preset The preset name @param ActiveRecord $file Use this file model @return string The file url
[ "Create", "a", "thumb", "and", "return", "url" ]
02c7e772710690163f1f1b8a5c5822d18ffaf9f6
https://github.com/rkit/filemanager-yii2/blob/02c7e772710690163f1f1b8a5c5822d18ffaf9f6/src/behaviors/FileBehavior.php#L365-L371
221,784
rkit/filemanager-yii2
src/behaviors/FileBehavior.php
FileBehavior.thumbPath
public function thumbPath($attribute, $preset, $file = null) { $path = $this->templatePath($attribute, $file); $thumbPath = $this->generateThumb($attribute, $preset, $path); return $this->fileStorage($attribute)->path . $thumbPath; }
php
public function thumbPath($attribute, $preset, $file = null) { $path = $this->templatePath($attribute, $file); $thumbPath = $this->generateThumb($attribute, $preset, $path); return $this->fileStorage($attribute)->path . $thumbPath; }
[ "public", "function", "thumbPath", "(", "$", "attribute", ",", "$", "preset", ",", "$", "file", "=", "null", ")", "{", "$", "path", "=", "$", "this", "->", "templatePath", "(", "$", "attribute", ",", "$", "file", ")", ";", "$", "thumbPath", "=", "$", "this", "->", "generateThumb", "(", "$", "attribute", ",", "$", "preset", ",", "$", "path", ")", ";", "return", "$", "this", "->", "fileStorage", "(", "$", "attribute", ")", "->", "path", ".", "$", "thumbPath", ";", "}" ]
Create a thumb and return full path @param string $attribute The attribute name @param string $preset The preset name @param ActiveRecord $file Use this file model @return string The file path
[ "Create", "a", "thumb", "and", "return", "full", "path" ]
02c7e772710690163f1f1b8a5c5822d18ffaf9f6
https://github.com/rkit/filemanager-yii2/blob/02c7e772710690163f1f1b8a5c5822d18ffaf9f6/src/behaviors/FileBehavior.php#L381-L387
221,785
FriendsOfCake/crud-users
src/Traits/VerifyTrait.php
VerifyTrait._tokenError
protected function _tokenError($error = 'tokenNotFound') { $subject = $this->_subject(['success' => false]); $this->_trigger($error, $subject); $message = $this->message($error, compact('token')); $exceptionClass = $message['class']; throw new $exceptionClass($message['text'], $message['code']); }
php
protected function _tokenError($error = 'tokenNotFound') { $subject = $this->_subject(['success' => false]); $this->_trigger($error, $subject); $message = $this->message($error, compact('token')); $exceptionClass = $message['class']; throw new $exceptionClass($message['text'], $message['code']); }
[ "protected", "function", "_tokenError", "(", "$", "error", "=", "'tokenNotFound'", ")", "{", "$", "subject", "=", "$", "this", "->", "_subject", "(", "[", "'success'", "=>", "false", "]", ")", ";", "$", "this", "->", "_trigger", "(", "$", "error", ",", "$", "subject", ")", ";", "$", "message", "=", "$", "this", "->", "message", "(", "$", "error", ",", "compact", "(", "'token'", ")", ")", ";", "$", "exceptionClass", "=", "$", "message", "[", "'class'", "]", ";", "throw", "new", "$", "exceptionClass", "(", "$", "message", "[", "'text'", "]", ",", "$", "message", "[", "'code'", "]", ")", ";", "}" ]
Throw exception if token not found or expired. @param string $error Error type. Default "tokenNotFound" @return void @throws \Exception
[ "Throw", "exception", "if", "token", "not", "found", "or", "expired", "." ]
391c178c04699e5059f3f1de0569bb88275c6708
https://github.com/FriendsOfCake/crud-users/blob/391c178c04699e5059f3f1de0569bb88275c6708/src/Traits/VerifyTrait.php#L85-L93
221,786
joselfonseca/laravel-tactician
src/Bus.php
Bus.mapInputToCommand
protected function mapInputToCommand($command, $input) { if (is_object($command)) { return $command; } $dependencies = []; $class = new ReflectionClass($command); foreach ($class->getConstructor()->getParameters() as $parameter) { if ( $parameter->getPosition() == 0 && $parameter->isArray() ) { if ($input !== []) { $dependencies[] = $input; } else { $dependencies[] = $this->getDefaultValueOrFail($parameter); } } else { $name = $parameter->getName(); if (array_key_exists($name, $input)) { $dependencies[] = $input[$name]; } else { $dependencies[] = $this->getDefaultValueOrFail($parameter); } } } return $class->newInstanceArgs($dependencies); }
php
protected function mapInputToCommand($command, $input) { if (is_object($command)) { return $command; } $dependencies = []; $class = new ReflectionClass($command); foreach ($class->getConstructor()->getParameters() as $parameter) { if ( $parameter->getPosition() == 0 && $parameter->isArray() ) { if ($input !== []) { $dependencies[] = $input; } else { $dependencies[] = $this->getDefaultValueOrFail($parameter); } } else { $name = $parameter->getName(); if (array_key_exists($name, $input)) { $dependencies[] = $input[$name]; } else { $dependencies[] = $this->getDefaultValueOrFail($parameter); } } } return $class->newInstanceArgs($dependencies); }
[ "protected", "function", "mapInputToCommand", "(", "$", "command", ",", "$", "input", ")", "{", "if", "(", "is_object", "(", "$", "command", ")", ")", "{", "return", "$", "command", ";", "}", "$", "dependencies", "=", "[", "]", ";", "$", "class", "=", "new", "ReflectionClass", "(", "$", "command", ")", ";", "foreach", "(", "$", "class", "->", "getConstructor", "(", ")", "->", "getParameters", "(", ")", "as", "$", "parameter", ")", "{", "if", "(", "$", "parameter", "->", "getPosition", "(", ")", "==", "0", "&&", "$", "parameter", "->", "isArray", "(", ")", ")", "{", "if", "(", "$", "input", "!==", "[", "]", ")", "{", "$", "dependencies", "[", "]", "=", "$", "input", ";", "}", "else", "{", "$", "dependencies", "[", "]", "=", "$", "this", "->", "getDefaultValueOrFail", "(", "$", "parameter", ")", ";", "}", "}", "else", "{", "$", "name", "=", "$", "parameter", "->", "getName", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "input", ")", ")", "{", "$", "dependencies", "[", "]", "=", "$", "input", "[", "$", "name", "]", ";", "}", "else", "{", "$", "dependencies", "[", "]", "=", "$", "this", "->", "getDefaultValueOrFail", "(", "$", "parameter", ")", ";", "}", "}", "}", "return", "$", "class", "->", "newInstanceArgs", "(", "$", "dependencies", ")", ";", "}" ]
Map the input to the command @param $command @param $input @return object
[ "Map", "the", "input", "to", "the", "command" ]
00367bb789856be2210542fb8b3589d58aa6653b
https://github.com/joselfonseca/laravel-tactician/blob/00367bb789856be2210542fb8b3589d58aa6653b/src/Bus.php#L123-L148
221,787
dwightwatson/breadcrumbs
src/Breadcrumbs/Registrar.php
Registrar.get
public function get(string $name): Closure { if ( ! $this->has($name)) { throw new DefinitionNotFoundException("No breadcrumbs defined for route [{$name}]."); } return $this->definitions[$name]; }
php
public function get(string $name): Closure { if ( ! $this->has($name)) { throw new DefinitionNotFoundException("No breadcrumbs defined for route [{$name}]."); } return $this->definitions[$name]; }
[ "public", "function", "get", "(", "string", "$", "name", ")", ":", "Closure", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "throw", "new", "DefinitionNotFoundException", "(", "\"No breadcrumbs defined for route [{$name}].\"", ")", ";", "}", "return", "$", "this", "->", "definitions", "[", "$", "name", "]", ";", "}" ]
Get a definition for a route name. @param string $name @return \Closure @throws \Watson\Breadcrumbs\DefinitionNotFoundException
[ "Get", "a", "definition", "for", "a", "route", "name", "." ]
b54dc7e1fc131749ff60c88115ca70bf7c6443ca
https://github.com/dwightwatson/breadcrumbs/blob/b54dc7e1fc131749ff60c88115ca70bf7c6443ca/src/Breadcrumbs/Registrar.php#L25-L32
221,788
dwightwatson/breadcrumbs
src/Breadcrumbs/Registrar.php
Registrar.set
public function set(string $name, Closure $definition) { if ($this->has($name)) { throw new DefinitionAlreadyExistsException( "Breadcrumbs have already been defined for route [{$name}]." ); } $this->definitions[$name] = $definition; }
php
public function set(string $name, Closure $definition) { if ($this->has($name)) { throw new DefinitionAlreadyExistsException( "Breadcrumbs have already been defined for route [{$name}]." ); } $this->definitions[$name] = $definition; }
[ "public", "function", "set", "(", "string", "$", "name", ",", "Closure", "$", "definition", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "throw", "new", "DefinitionAlreadyExistsException", "(", "\"Breadcrumbs have already been defined for route [{$name}].\"", ")", ";", "}", "$", "this", "->", "definitions", "[", "$", "name", "]", "=", "$", "definition", ";", "}" ]
Set the registration for a route name. @param string $name @param \Closure $definition @return void @throws \Watson\Breadcrumbs\DefinitionAlreadyExists
[ "Set", "the", "registration", "for", "a", "route", "name", "." ]
b54dc7e1fc131749ff60c88115ca70bf7c6443ca
https://github.com/dwightwatson/breadcrumbs/blob/b54dc7e1fc131749ff60c88115ca70bf7c6443ca/src/Breadcrumbs/Registrar.php#L53-L62
221,789
abhi1693/yii2-sms
components/Sms.php
Sms.send
public function send($carrier, $phoneNumber, $subject, $message, $split = FALSE) { // Check for valid Carrier $carriers = $this->getCarriers(); if (empty($carriers[$carrier])) { return 0; } // Clean up the phone number $phoneNumber = str_replace([' ', '-'], '', $phoneNumber); // Calculate the prefix and suffix // If separator is not found that means its a suffix list($prefix, $suffix) = strpos($carriers[$carrier], $this->prefixSuffixSeparator) !== FALSE ? explode($this->prefixSuffixSeparator, $carriers[$carrier]) : ['', $carriers[$carrier]]; // Calculate Address $to = "{$prefix}{$phoneNumber}@{$suffix}"; // Calculate message // Result in an array of count 1 $messages = $split ? $this->splitMessage($message, $this->splitLength) : [$message]; // Send Email $successCount = 0; foreach ($messages as $message) { $successCount += $this->_mail($to, $subject, $message); } return $successCount; }
php
public function send($carrier, $phoneNumber, $subject, $message, $split = FALSE) { // Check for valid Carrier $carriers = $this->getCarriers(); if (empty($carriers[$carrier])) { return 0; } // Clean up the phone number $phoneNumber = str_replace([' ', '-'], '', $phoneNumber); // Calculate the prefix and suffix // If separator is not found that means its a suffix list($prefix, $suffix) = strpos($carriers[$carrier], $this->prefixSuffixSeparator) !== FALSE ? explode($this->prefixSuffixSeparator, $carriers[$carrier]) : ['', $carriers[$carrier]]; // Calculate Address $to = "{$prefix}{$phoneNumber}@{$suffix}"; // Calculate message // Result in an array of count 1 $messages = $split ? $this->splitMessage($message, $this->splitLength) : [$message]; // Send Email $successCount = 0; foreach ($messages as $message) { $successCount += $this->_mail($to, $subject, $message); } return $successCount; }
[ "public", "function", "send", "(", "$", "carrier", ",", "$", "phoneNumber", ",", "$", "subject", ",", "$", "message", ",", "$", "split", "=", "FALSE", ")", "{", "// Check for valid Carrier", "$", "carriers", "=", "$", "this", "->", "getCarriers", "(", ")", ";", "if", "(", "empty", "(", "$", "carriers", "[", "$", "carrier", "]", ")", ")", "{", "return", "0", ";", "}", "// Clean up the phone number", "$", "phoneNumber", "=", "str_replace", "(", "[", "' '", ",", "'-'", "]", ",", "''", ",", "$", "phoneNumber", ")", ";", "// Calculate the prefix and suffix", "// If separator is not found that means its a suffix", "list", "(", "$", "prefix", ",", "$", "suffix", ")", "=", "strpos", "(", "$", "carriers", "[", "$", "carrier", "]", ",", "$", "this", "->", "prefixSuffixSeparator", ")", "!==", "FALSE", "?", "explode", "(", "$", "this", "->", "prefixSuffixSeparator", ",", "$", "carriers", "[", "$", "carrier", "]", ")", ":", "[", "''", ",", "$", "carriers", "[", "$", "carrier", "]", "]", ";", "// Calculate Address", "$", "to", "=", "\"{$prefix}{$phoneNumber}@{$suffix}\"", ";", "// Calculate message", "// Result in an array of count 1", "$", "messages", "=", "$", "split", "?", "$", "this", "->", "splitMessage", "(", "$", "message", ",", "$", "this", "->", "splitLength", ")", ":", "[", "$", "message", "]", ";", "// Send Email", "$", "successCount", "=", "0", ";", "foreach", "(", "$", "messages", "as", "$", "message", ")", "{", "$", "successCount", "+=", "$", "this", "->", "_mail", "(", "$", "to", ",", "$", "subject", ",", "$", "message", ")", ";", "}", "return", "$", "successCount", ";", "}" ]
Sends text message @param string $carrier @param string $phoneNumber @param string $subject @param string $message @param bool $split @return int The number of text messages sent
[ "Sends", "text", "message" ]
eb8c40352999013999a8de3f0d2d41759ca050f6
https://github.com/abhi1693/yii2-sms/blob/eb8c40352999013999a8de3f0d2d41759ca050f6/components/Sms.php#L104-L137
221,790
abhi1693/yii2-sms
components/Sms.php
Sms._mail
private function _mail($to, $subject, $message) { // Set up swift mailer if needed if (!$this->_mailer) { $transport = NULL; // Set transport to php if (strtolower($this->transportType) == 'php') { $transport = Swift_MailTransport::newInstance(); } // Set transport to smtp elseif (strtolower($this->transportType) == 'smtp') { $transport = \Swift_SmtpTransport::newInstance(); foreach ($this->transportOptions as $option => $value) { $methodName = 'set' . ucfirst($option); $transport->$methodName($value); } } // Create Mailer object $this->_mailer = \Swift_Mailer::newInstance($transport); } // Set up message $mailer = $this->_mailer; $message = Swift_Message::newInstance($subject)->setFrom('not@used.com')->setTo($to)->setBody($message); return $mailer->send($message); }
php
private function _mail($to, $subject, $message) { // Set up swift mailer if needed if (!$this->_mailer) { $transport = NULL; // Set transport to php if (strtolower($this->transportType) == 'php') { $transport = Swift_MailTransport::newInstance(); } // Set transport to smtp elseif (strtolower($this->transportType) == 'smtp') { $transport = \Swift_SmtpTransport::newInstance(); foreach ($this->transportOptions as $option => $value) { $methodName = 'set' . ucfirst($option); $transport->$methodName($value); } } // Create Mailer object $this->_mailer = \Swift_Mailer::newInstance($transport); } // Set up message $mailer = $this->_mailer; $message = Swift_Message::newInstance($subject)->setFrom('not@used.com')->setTo($to)->setBody($message); return $mailer->send($message); }
[ "private", "function", "_mail", "(", "$", "to", ",", "$", "subject", ",", "$", "message", ")", "{", "// Set up swift mailer if needed", "if", "(", "!", "$", "this", "->", "_mailer", ")", "{", "$", "transport", "=", "NULL", ";", "// Set transport to php", "if", "(", "strtolower", "(", "$", "this", "->", "transportType", ")", "==", "'php'", ")", "{", "$", "transport", "=", "Swift_MailTransport", "::", "newInstance", "(", ")", ";", "}", "// Set transport to smtp", "elseif", "(", "strtolower", "(", "$", "this", "->", "transportType", ")", "==", "'smtp'", ")", "{", "$", "transport", "=", "\\", "Swift_SmtpTransport", "::", "newInstance", "(", ")", ";", "foreach", "(", "$", "this", "->", "transportOptions", "as", "$", "option", "=>", "$", "value", ")", "{", "$", "methodName", "=", "'set'", ".", "ucfirst", "(", "$", "option", ")", ";", "$", "transport", "->", "$", "methodName", "(", "$", "value", ")", ";", "}", "}", "// Create Mailer object", "$", "this", "->", "_mailer", "=", "\\", "Swift_Mailer", "::", "newInstance", "(", "$", "transport", ")", ";", "}", "// Set up message", "$", "mailer", "=", "$", "this", "->", "_mailer", ";", "$", "message", "=", "Swift_Message", "::", "newInstance", "(", "$", "subject", ")", "->", "setFrom", "(", "'not@used.com'", ")", "->", "setTo", "(", "$", "to", ")", "->", "setBody", "(", "$", "message", ")", ";", "return", "$", "mailer", "->", "send", "(", "$", "message", ")", ";", "}" ]
Sends email in order to send text message @param string $to @param string $subject @param string $message @return int
[ "Sends", "email", "in", "order", "to", "send", "text", "message" ]
eb8c40352999013999a8de3f0d2d41759ca050f6
https://github.com/abhi1693/yii2-sms/blob/eb8c40352999013999a8de3f0d2d41759ca050f6/components/Sms.php#L148-L175
221,791
abhi1693/yii2-sms
components/Sms.php
Sms.splitMessage
public function splitMessage($message, $splitLength) { // Split up $messages = $this->wordwrapArray($message, $splitLength); // Add counter to each message $total = count($messages); if ($total > 1) { $count = 1; foreach ($messages as $key => $currMsgWrapped) { $messages[$key] = "$currMsgWrapped ($count/$total)"; $count++; } } return $messages; }
php
public function splitMessage($message, $splitLength) { // Split up $messages = $this->wordwrapArray($message, $splitLength); // Add counter to each message $total = count($messages); if ($total > 1) { $count = 1; foreach ($messages as $key => $currMsgWrapped) { $messages[$key] = "$currMsgWrapped ($count/$total)"; $count++; } } return $messages; }
[ "public", "function", "splitMessage", "(", "$", "message", ",", "$", "splitLength", ")", "{", "// Split up", "$", "messages", "=", "$", "this", "->", "wordwrapArray", "(", "$", "message", ",", "$", "splitLength", ")", ";", "// Add counter to each message", "$", "total", "=", "count", "(", "$", "messages", ")", ";", "if", "(", "$", "total", ">", "1", ")", "{", "$", "count", "=", "1", ";", "foreach", "(", "$", "messages", "as", "$", "key", "=>", "$", "currMsgWrapped", ")", "{", "$", "messages", "[", "$", "key", "]", "=", "\"$currMsgWrapped ($count/$total)\"", ";", "$", "count", "++", ";", "}", "}", "return", "$", "messages", ";", "}" ]
Splits up messages and add counter at the end @param string $message @param int $splitLength @return array
[ "Splits", "up", "messages", "and", "add", "counter", "at", "the", "end" ]
eb8c40352999013999a8de3f0d2d41759ca050f6
https://github.com/abhi1693/yii2-sms/blob/eb8c40352999013999a8de3f0d2d41759ca050f6/components/Sms.php#L185-L202
221,792
abhi1693/yii2-sms
components/Sms.php
Sms.wordwrapArray
public function wordwrapArray($string, $width) { if (($len = mb_strlen($string, 'UTF-8')) <= $width) { return [$string]; } $return = []; $last_space = FALSE; $i = 0; do { if (mb_substr($string, $i, 1, 'UTF-8') == ' ') { $last_space = $i; } if ($i > $width) { $last_space = ($last_space == 0) ? $width : $last_space; $return[] = trim(mb_substr($string, 0, $last_space, 'UTF-8')); $string = mb_substr($string, $last_space, $len, 'UTF-8'); $len = mb_strlen($string, 'UTF-8'); $i = 0; } $i++; } while ($i < $len); $return[] = trim($string); return $return; }
php
public function wordwrapArray($string, $width) { if (($len = mb_strlen($string, 'UTF-8')) <= $width) { return [$string]; } $return = []; $last_space = FALSE; $i = 0; do { if (mb_substr($string, $i, 1, 'UTF-8') == ' ') { $last_space = $i; } if ($i > $width) { $last_space = ($last_space == 0) ? $width : $last_space; $return[] = trim(mb_substr($string, 0, $last_space, 'UTF-8')); $string = mb_substr($string, $last_space, $len, 'UTF-8'); $len = mb_strlen($string, 'UTF-8'); $i = 0; } $i++; } while ($i < $len); $return[] = trim($string); return $return; }
[ "public", "function", "wordwrapArray", "(", "$", "string", ",", "$", "width", ")", "{", "if", "(", "(", "$", "len", "=", "mb_strlen", "(", "$", "string", ",", "'UTF-8'", ")", ")", "<=", "$", "width", ")", "{", "return", "[", "$", "string", "]", ";", "}", "$", "return", "=", "[", "]", ";", "$", "last_space", "=", "FALSE", ";", "$", "i", "=", "0", ";", "do", "{", "if", "(", "mb_substr", "(", "$", "string", ",", "$", "i", ",", "1", ",", "'UTF-8'", ")", "==", "' '", ")", "{", "$", "last_space", "=", "$", "i", ";", "}", "if", "(", "$", "i", ">", "$", "width", ")", "{", "$", "last_space", "=", "(", "$", "last_space", "==", "0", ")", "?", "$", "width", ":", "$", "last_space", ";", "$", "return", "[", "]", "=", "trim", "(", "mb_substr", "(", "$", "string", ",", "0", ",", "$", "last_space", ",", "'UTF-8'", ")", ")", ";", "$", "string", "=", "mb_substr", "(", "$", "string", ",", "$", "last_space", ",", "$", "len", ",", "'UTF-8'", ")", ";", "$", "len", "=", "mb_strlen", "(", "$", "string", ",", "'UTF-8'", ")", ";", "$", "i", "=", "0", ";", "}", "$", "i", "++", ";", "}", "while", "(", "$", "i", "<", "$", "len", ")", ";", "$", "return", "[", "]", "=", "trim", "(", "$", "string", ")", ";", "return", "$", "return", ";", "}" ]
Wordwrap in UTF-8 supports, return as array @param string $string @param int $width @return array
[ "Wordwrap", "in", "UTF", "-", "8", "supports", "return", "as", "array" ]
eb8c40352999013999a8de3f0d2d41759ca050f6
https://github.com/abhi1693/yii2-sms/blob/eb8c40352999013999a8de3f0d2d41759ca050f6/components/Sms.php#L212-L236
221,793
joselfonseca/laravel-tactician
src/Providers/LaravelTacticianServiceProvider.php
LaravelTacticianServiceProvider.register
public function register() { $this->registerConfig(); $this->app->bind('Joselfonseca\LaravelTactician\Locator\LocatorInterface', config('laravel-tactician.locator')); $this->app->bind('League\Tactician\Handler\MethodNameInflector\MethodNameInflector', config('laravel-tactician.inflector')); $this->app->bind('League\Tactician\Handler\CommandNameExtractor\CommandNameExtractor', config('laravel-tactician.extractor')); $this->app->bind('Joselfonseca\LaravelTactician\CommandBusInterface', config('laravel-tactician.bus')); // Register Command Generator $this->app->singleton( 'laravel-tactician.make.command', function ($app) { return new MakeTacticianCommandCommand($app['files']); } ); $this->commands('laravel-tactician.make.command'); // Register Handler Generator $this->app->singleton( 'laravel-tactician.make.handler', function ($app) { return new MakeTacticianHandlerCommand($app['files']); } ); $this->commands('laravel-tactician.make.handler'); // Register Comman+Handler Generator Command $this->app->singleton( 'laravel-tactician.make.tactician', function () { return new MakeTacticianCommand(); } ); $this->commands('laravel-tactician.make.tactician'); }
php
public function register() { $this->registerConfig(); $this->app->bind('Joselfonseca\LaravelTactician\Locator\LocatorInterface', config('laravel-tactician.locator')); $this->app->bind('League\Tactician\Handler\MethodNameInflector\MethodNameInflector', config('laravel-tactician.inflector')); $this->app->bind('League\Tactician\Handler\CommandNameExtractor\CommandNameExtractor', config('laravel-tactician.extractor')); $this->app->bind('Joselfonseca\LaravelTactician\CommandBusInterface', config('laravel-tactician.bus')); // Register Command Generator $this->app->singleton( 'laravel-tactician.make.command', function ($app) { return new MakeTacticianCommandCommand($app['files']); } ); $this->commands('laravel-tactician.make.command'); // Register Handler Generator $this->app->singleton( 'laravel-tactician.make.handler', function ($app) { return new MakeTacticianHandlerCommand($app['files']); } ); $this->commands('laravel-tactician.make.handler'); // Register Comman+Handler Generator Command $this->app->singleton( 'laravel-tactician.make.tactician', function () { return new MakeTacticianCommand(); } ); $this->commands('laravel-tactician.make.tactician'); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "registerConfig", "(", ")", ";", "$", "this", "->", "app", "->", "bind", "(", "'Joselfonseca\\LaravelTactician\\Locator\\LocatorInterface'", ",", "config", "(", "'laravel-tactician.locator'", ")", ")", ";", "$", "this", "->", "app", "->", "bind", "(", "'League\\Tactician\\Handler\\MethodNameInflector\\MethodNameInflector'", ",", "config", "(", "'laravel-tactician.inflector'", ")", ")", ";", "$", "this", "->", "app", "->", "bind", "(", "'League\\Tactician\\Handler\\CommandNameExtractor\\CommandNameExtractor'", ",", "config", "(", "'laravel-tactician.extractor'", ")", ")", ";", "$", "this", "->", "app", "->", "bind", "(", "'Joselfonseca\\LaravelTactician\\CommandBusInterface'", ",", "config", "(", "'laravel-tactician.bus'", ")", ")", ";", "// Register Command Generator", "$", "this", "->", "app", "->", "singleton", "(", "'laravel-tactician.make.command'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "MakeTacticianCommandCommand", "(", "$", "app", "[", "'files'", "]", ")", ";", "}", ")", ";", "$", "this", "->", "commands", "(", "'laravel-tactician.make.command'", ")", ";", "// Register Handler Generator", "$", "this", "->", "app", "->", "singleton", "(", "'laravel-tactician.make.handler'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "MakeTacticianHandlerCommand", "(", "$", "app", "[", "'files'", "]", ")", ";", "}", ")", ";", "$", "this", "->", "commands", "(", "'laravel-tactician.make.handler'", ")", ";", "// Register Comman+Handler Generator Command", "$", "this", "->", "app", "->", "singleton", "(", "'laravel-tactician.make.tactician'", ",", "function", "(", ")", "{", "return", "new", "MakeTacticianCommand", "(", ")", ";", "}", ")", ";", "$", "this", "->", "commands", "(", "'laravel-tactician.make.tactician'", ")", ";", "}" ]
Do the bindings so any implementation can be swapped @return void
[ "Do", "the", "bindings", "so", "any", "implementation", "can", "be", "swapped" ]
00367bb789856be2210542fb8b3589d58aa6653b
https://github.com/joselfonseca/laravel-tactician/blob/00367bb789856be2210542fb8b3589d58aa6653b/src/Providers/LaravelTacticianServiceProvider.php#L23-L54
221,794
farhadi/IntlDateTime
IntlDateTime.php
IntlDateTime.getFormatter
protected function getFormatter($options = array()) { $locale = empty($options['locale']) ? $this->locale : $options['locale']; $calendar = empty($options['calendar']) ? $this->calendar : $options['calendar']; $timezone = empty($options['timezone']) ? $this->getTimezone() : $options['timezone']; if (is_a($timezone, 'DateTimeZone')) $timezone = $timezone->getName(); $pattern = empty($options['pattern']) ? null : $options['pattern']; return new \IntlDateFormatter($locale . '@calendar=' . $calendar, \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, $timezone, $calendar == 'gregorian' ? \IntlDateFormatter::GREGORIAN : \IntlDateFormatter::TRADITIONAL, $pattern); }
php
protected function getFormatter($options = array()) { $locale = empty($options['locale']) ? $this->locale : $options['locale']; $calendar = empty($options['calendar']) ? $this->calendar : $options['calendar']; $timezone = empty($options['timezone']) ? $this->getTimezone() : $options['timezone']; if (is_a($timezone, 'DateTimeZone')) $timezone = $timezone->getName(); $pattern = empty($options['pattern']) ? null : $options['pattern']; return new \IntlDateFormatter($locale . '@calendar=' . $calendar, \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, $timezone, $calendar == 'gregorian' ? \IntlDateFormatter::GREGORIAN : \IntlDateFormatter::TRADITIONAL, $pattern); }
[ "protected", "function", "getFormatter", "(", "$", "options", "=", "array", "(", ")", ")", "{", "$", "locale", "=", "empty", "(", "$", "options", "[", "'locale'", "]", ")", "?", "$", "this", "->", "locale", ":", "$", "options", "[", "'locale'", "]", ";", "$", "calendar", "=", "empty", "(", "$", "options", "[", "'calendar'", "]", ")", "?", "$", "this", "->", "calendar", ":", "$", "options", "[", "'calendar'", "]", ";", "$", "timezone", "=", "empty", "(", "$", "options", "[", "'timezone'", "]", ")", "?", "$", "this", "->", "getTimezone", "(", ")", ":", "$", "options", "[", "'timezone'", "]", ";", "if", "(", "is_a", "(", "$", "timezone", ",", "'DateTimeZone'", ")", ")", "$", "timezone", "=", "$", "timezone", "->", "getName", "(", ")", ";", "$", "pattern", "=", "empty", "(", "$", "options", "[", "'pattern'", "]", ")", "?", "null", ":", "$", "options", "[", "'pattern'", "]", ";", "return", "new", "\\", "IntlDateFormatter", "(", "$", "locale", ".", "'@calendar='", ".", "$", "calendar", ",", "\\", "IntlDateFormatter", "::", "FULL", ",", "\\", "IntlDateFormatter", "::", "FULL", ",", "$", "timezone", ",", "$", "calendar", "==", "'gregorian'", "?", "\\", "IntlDateFormatter", "::", "GREGORIAN", ":", "\\", "IntlDateFormatter", "::", "TRADITIONAL", ",", "$", "pattern", ")", ";", "}" ]
Returns an instance of IntlDateFormatter with specified options. @param array $options @return IntlDateFormatter
[ "Returns", "an", "instance", "of", "IntlDateFormatter", "with", "specified", "options", "." ]
4f500ffeb75d37e72961cdb79f1ca1cbeec27f47
https://github.com/farhadi/IntlDateTime/blob/4f500ffeb75d37e72961cdb79f1ca1cbeec27f47/IntlDateTime.php#L54-L63
221,795
farhadi/IntlDateTime
IntlDateTime.php
IntlDateTime.setTimestamp
public function setTimestamp($unixtimestamp) { $diff = $unixtimestamp - $this->getTimestamp(); $days = floor($diff / 86400); $seconds = $diff - $days * 86400; $timezone = $this->getTimezone(); $this->setTimezone('UTC'); parent::modify("$days days $seconds seconds"); $this->setTimezone($timezone); return $this; }
php
public function setTimestamp($unixtimestamp) { $diff = $unixtimestamp - $this->getTimestamp(); $days = floor($diff / 86400); $seconds = $diff - $days * 86400; $timezone = $this->getTimezone(); $this->setTimezone('UTC'); parent::modify("$days days $seconds seconds"); $this->setTimezone($timezone); return $this; }
[ "public", "function", "setTimestamp", "(", "$", "unixtimestamp", ")", "{", "$", "diff", "=", "$", "unixtimestamp", "-", "$", "this", "->", "getTimestamp", "(", ")", ";", "$", "days", "=", "floor", "(", "$", "diff", "/", "86400", ")", ";", "$", "seconds", "=", "$", "diff", "-", "$", "days", "*", "86400", ";", "$", "timezone", "=", "$", "this", "->", "getTimezone", "(", ")", ";", "$", "this", "->", "setTimezone", "(", "'UTC'", ")", ";", "parent", "::", "modify", "(", "\"$days days $seconds seconds\"", ")", ";", "$", "this", "->", "setTimezone", "(", "$", "timezone", ")", ";", "return", "$", "this", ";", "}" ]
Overrides the setTimestamp method to support timestamps out of the integer range. @param float $unixtimestamp Unix timestamp representing the date. @return IntlDateTime the modified DateTime.
[ "Overrides", "the", "setTimestamp", "method", "to", "support", "timestamps", "out", "of", "the", "integer", "range", "." ]
4f500ffeb75d37e72961cdb79f1ca1cbeec27f47
https://github.com/farhadi/IntlDateTime/blob/4f500ffeb75d37e72961cdb79f1ca1cbeec27f47/IntlDateTime.php#L173-L182
221,796
farhadi/IntlDateTime
IntlDateTime.php
IntlDateTime.setDate
public function setDate($year, $month, $day) { $this->set("$year/$month/$day ".$this->format('HH:mm:ss'), null, 'yyyy/MM/dd HH:mm:ss'); return $this; }
php
public function setDate($year, $month, $day) { $this->set("$year/$month/$day ".$this->format('HH:mm:ss'), null, 'yyyy/MM/dd HH:mm:ss'); return $this; }
[ "public", "function", "setDate", "(", "$", "year", ",", "$", "month", ",", "$", "day", ")", "{", "$", "this", "->", "set", "(", "\"$year/$month/$day \"", ".", "$", "this", "->", "format", "(", "'HH:mm:ss'", ")", ",", "null", ",", "'yyyy/MM/dd HH:mm:ss'", ")", ";", "return", "$", "this", ";", "}" ]
Resets the current date of the object. @param integer $year @param integer $month @param integer $day @return IntlDateTime The modified DateTime.
[ "Resets", "the", "current", "date", "of", "the", "object", "." ]
4f500ffeb75d37e72961cdb79f1ca1cbeec27f47
https://github.com/farhadi/IntlDateTime/blob/4f500ffeb75d37e72961cdb79f1ca1cbeec27f47/IntlDateTime.php#L244-L247
221,797
farhadi/IntlDateTime
IntlDateTime.php
IntlDateTime.setTimezone
public function setTimezone($timezone) { if (!is_a($timezone, 'DateTimeZone')) $timezone = new \DateTimeZone($timezone); parent::setTimezone($timezone); return $this; }
php
public function setTimezone($timezone) { if (!is_a($timezone, 'DateTimeZone')) $timezone = new \DateTimeZone($timezone); parent::setTimezone($timezone); return $this; }
[ "public", "function", "setTimezone", "(", "$", "timezone", ")", "{", "if", "(", "!", "is_a", "(", "$", "timezone", ",", "'DateTimeZone'", ")", ")", "$", "timezone", "=", "new", "\\", "DateTimeZone", "(", "$", "timezone", ")", ";", "parent", "::", "setTimezone", "(", "$", "timezone", ")", ";", "return", "$", "this", ";", "}" ]
Sets the timezone for the object. @param mixed $timezone DateTimeZone object or timezone identifier as full name (e.g. Asia/Tehran) or abbreviation (e.g. IRDT). @return IntlDateTime The modified DateTime.
[ "Sets", "the", "timezone", "for", "the", "object", "." ]
4f500ffeb75d37e72961cdb79f1ca1cbeec27f47
https://github.com/farhadi/IntlDateTime/blob/4f500ffeb75d37e72961cdb79f1ca1cbeec27f47/IntlDateTime.php#L255-L259
221,798
farhadi/IntlDateTime
IntlDateTime.php
IntlDateTime.modifyCallback
protected function modifyCallback($matches) { if (!empty($matches[1])) { parent::modify($matches[1]); } list($y, $m, $d) = explode('-', $this->format('y-M-d')); $change = strtolower($matches[2]); $unit = strtolower($matches[3]); switch ($change) { case "next": $change = 1; break; case "last": case "previous": $change = -1; break; } switch ($unit) { case "month": $m += $change; if ($m > 12) { $y += floor($m/12); $m = $m % 12; } elseif ($m < 1) { $y += ceil($m/12) - 1; $m = $m % 12 + 12; } break; case "year": $y += $change; break; } $this->setDate($y, $m, $d); return ''; }
php
protected function modifyCallback($matches) { if (!empty($matches[1])) { parent::modify($matches[1]); } list($y, $m, $d) = explode('-', $this->format('y-M-d')); $change = strtolower($matches[2]); $unit = strtolower($matches[3]); switch ($change) { case "next": $change = 1; break; case "last": case "previous": $change = -1; break; } switch ($unit) { case "month": $m += $change; if ($m > 12) { $y += floor($m/12); $m = $m % 12; } elseif ($m < 1) { $y += ceil($m/12) - 1; $m = $m % 12 + 12; } break; case "year": $y += $change; break; } $this->setDate($y, $m, $d); return ''; }
[ "protected", "function", "modifyCallback", "(", "$", "matches", ")", "{", "if", "(", "!", "empty", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "parent", "::", "modify", "(", "$", "matches", "[", "1", "]", ")", ";", "}", "list", "(", "$", "y", ",", "$", "m", ",", "$", "d", ")", "=", "explode", "(", "'-'", ",", "$", "this", "->", "format", "(", "'y-M-d'", ")", ")", ";", "$", "change", "=", "strtolower", "(", "$", "matches", "[", "2", "]", ")", ";", "$", "unit", "=", "strtolower", "(", "$", "matches", "[", "3", "]", ")", ";", "switch", "(", "$", "change", ")", "{", "case", "\"next\"", ":", "$", "change", "=", "1", ";", "break", ";", "case", "\"last\"", ":", "case", "\"previous\"", ":", "$", "change", "=", "-", "1", ";", "break", ";", "}", "switch", "(", "$", "unit", ")", "{", "case", "\"month\"", ":", "$", "m", "+=", "$", "change", ";", "if", "(", "$", "m", ">", "12", ")", "{", "$", "y", "+=", "floor", "(", "$", "m", "/", "12", ")", ";", "$", "m", "=", "$", "m", "%", "12", ";", "}", "elseif", "(", "$", "m", "<", "1", ")", "{", "$", "y", "+=", "ceil", "(", "$", "m", "/", "12", ")", "-", "1", ";", "$", "m", "=", "$", "m", "%", "12", "+", "12", ";", "}", "break", ";", "case", "\"year\"", ":", "$", "y", "+=", "$", "change", ";", "break", ";", "}", "$", "this", "->", "setDate", "(", "$", "y", ",", "$", "m", ",", "$", "d", ")", ";", "return", "''", ";", "}" ]
Internally used by modify method to calculate calendar-aware modifications @param array $matches @return string An empty string
[ "Internally", "used", "by", "modify", "method", "to", "calculate", "calendar", "-", "aware", "modifications" ]
4f500ffeb75d37e72961cdb79f1ca1cbeec27f47
https://github.com/farhadi/IntlDateTime/blob/4f500ffeb75d37e72961cdb79f1ca1cbeec27f47/IntlDateTime.php#L267-L307
221,799
farhadi/IntlDateTime
IntlDateTime.php
IntlDateTime.format
public function format($pattern, $timezone = null) { if (isset($timezone)) { $tempTimezone = $this->getTimezone(); $this->setTimezone($timezone); } // Timezones DST data in ICU are not as accurate as PHP. // So we get timezone offset from php and pass it to ICU. $result = $this->getFormatter(array( 'timezone' => 'GMT' . (parent::format('Z') ? parent::format('P') : ''), 'pattern' => $pattern ))->format($this->getTimestamp()); if (isset($timezone)) { $this->setTimezone($tempTimezone); } return $result; }
php
public function format($pattern, $timezone = null) { if (isset($timezone)) { $tempTimezone = $this->getTimezone(); $this->setTimezone($timezone); } // Timezones DST data in ICU are not as accurate as PHP. // So we get timezone offset from php and pass it to ICU. $result = $this->getFormatter(array( 'timezone' => 'GMT' . (parent::format('Z') ? parent::format('P') : ''), 'pattern' => $pattern ))->format($this->getTimestamp()); if (isset($timezone)) { $this->setTimezone($tempTimezone); } return $result; }
[ "public", "function", "format", "(", "$", "pattern", ",", "$", "timezone", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "timezone", ")", ")", "{", "$", "tempTimezone", "=", "$", "this", "->", "getTimezone", "(", ")", ";", "$", "this", "->", "setTimezone", "(", "$", "timezone", ")", ";", "}", "// Timezones DST data in ICU are not as accurate as PHP.", "// So we get timezone offset from php and pass it to ICU.", "$", "result", "=", "$", "this", "->", "getFormatter", "(", "array", "(", "'timezone'", "=>", "'GMT'", ".", "(", "parent", "::", "format", "(", "'Z'", ")", "?", "parent", "::", "format", "(", "'P'", ")", ":", "''", ")", ",", "'pattern'", "=>", "$", "pattern", ")", ")", "->", "format", "(", "$", "this", "->", "getTimestamp", "(", ")", ")", ";", "if", "(", "isset", "(", "$", "timezone", ")", ")", "{", "$", "this", "->", "setTimezone", "(", "$", "tempTimezone", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns date formatted according to given pattern. @param string $pattern Date pattern in ICU syntax (@link http://userguide.icu-project.org/formatparse/datetime) @param mixed $timezone DateTimeZone object or timezone identifier as full name (e.g. Asia/Tehran) or abbreviation (e.g. IRDT). @return string Formatted date on success or FALSE on failure.
[ "Returns", "date", "formatted", "according", "to", "given", "pattern", "." ]
4f500ffeb75d37e72961cdb79f1ca1cbeec27f47
https://github.com/farhadi/IntlDateTime/blob/4f500ffeb75d37e72961cdb79f1ca1cbeec27f47/IntlDateTime.php#L329-L347