id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
19,100
tableau-mkt/eggs-n-cereal
src/Serializer.php
Serializer.errorStop
protected function errorStop($use) { foreach (libxml_get_errors() as $error) { switch ($error->level) { case LIBXML_ERR_WARNING: case LIBXML_ERR_ERROR: $level = LogLevel::WARNING; break; case LIBXML_ERR_FATAL: $level = LogLevel::ERROR; break; default: $level = LogLevel::INFO; } $this->log($level, '%error on line %num. Error code: %code.', array( '%error' => trim($error->message), '%num' => $error->line, '%code' => $error->code, )); } libxml_clear_errors(); libxml_use_internal_errors($use); }
php
protected function errorStop($use) { foreach (libxml_get_errors() as $error) { switch ($error->level) { case LIBXML_ERR_WARNING: case LIBXML_ERR_ERROR: $level = LogLevel::WARNING; break; case LIBXML_ERR_FATAL: $level = LogLevel::ERROR; break; default: $level = LogLevel::INFO; } $this->log($level, '%error on line %num. Error code: %code.', array( '%error' => trim($error->message), '%num' => $error->line, '%code' => $error->code, )); } libxml_clear_errors(); libxml_use_internal_errors($use); }
[ "protected", "function", "errorStop", "(", "$", "use", ")", "{", "foreach", "(", "libxml_get_errors", "(", ")", "as", "$", "error", ")", "{", "switch", "(", "$", "error", "->", "level", ")", "{", "case", "LIBXML_ERR_WARNING", ":", "case", "LIBXML_ERR_ERROR", ":", "$", "level", "=", "LogLevel", "::", "WARNING", ";", "break", ";", "case", "LIBXML_ERR_FATAL", ":", "$", "level", "=", "LogLevel", "::", "ERROR", ";", "break", ";", "default", ":", "$", "level", "=", "LogLevel", "::", "INFO", ";", "}", "$", "this", "->", "log", "(", "$", "level", ",", "'%error on line %num. Error code: %code.'", ",", "array", "(", "'%error'", "=>", "trim", "(", "$", "error", "->", "message", ")", ",", "'%num'", "=>", "$", "error", "->", "line", ",", "'%code'", "=>", "$", "error", "->", "code", ",", ")", ")", ";", "}", "libxml_clear_errors", "(", ")", ";", "libxml_use_internal_errors", "(", "$", "use", ")", ";", "}" ]
Ends custom error handling. @param bool $use The return value of Serializer::errorStart().
[ "Ends", "custom", "error", "handling", "." ]
778b83ddae1dd687724a84545ce8afa1a31e4bcf
https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Serializer.php#L455-L479
19,101
prowebcraft/dot
src/Dot.php
Dot.getValue
public static function getValue($array, $key, $default = null) { if (is_string($key)) { // Iterate path $keys = explode('.', $key); foreach ($keys as $key) { if (!isset($array[$key])) { return $default; } $array = &$array[$key]; } // Get value return $array; } elseif (is_null($key)) { // Get all data return $array; } return null; }
php
public static function getValue($array, $key, $default = null) { if (is_string($key)) { // Iterate path $keys = explode('.', $key); foreach ($keys as $key) { if (!isset($array[$key])) { return $default; } $array = &$array[$key]; } // Get value return $array; } elseif (is_null($key)) { // Get all data return $array; } return null; }
[ "public", "static", "function", "getValue", "(", "$", "array", ",", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "// Iterate path", "$", "keys", "=", "explode", "(", "'.'", ",", "$", "key", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "array", "[", "$", "key", "]", ")", ")", "{", "return", "$", "default", ";", "}", "$", "array", "=", "&", "$", "array", "[", "$", "key", "]", ";", "}", "// Get value", "return", "$", "array", ";", "}", "elseif", "(", "is_null", "(", "$", "key", ")", ")", "{", "// Get all data", "return", "$", "array", ";", "}", "return", "null", ";", "}" ]
Get value of path, default value if path doesn't exist or all data @param array $array Source Array @param mixed|null $key Path @param mixed|null $default Default value @return mixed Value of path
[ "Get", "value", "of", "path", "default", "value", "if", "path", "doesn", "t", "exist", "or", "all", "data" ]
de47137ec650f39c6835f30474a42cd9548063c4
https://github.com/prowebcraft/dot/blob/de47137ec650f39c6835f30474a42cd9548063c4/src/Dot.php#L39-L57
19,102
lmammino/e-foundation
src/Variation/Model/OptionSubjectTrait.php
OptionSubjectTrait.addOption
public function addOption(OptionInterface $option) { if (!$this->hasOption($option)) { $this->options->add($option); } return $this; }
php
public function addOption(OptionInterface $option) { if (!$this->hasOption($option)) { $this->options->add($option); } return $this; }
[ "public", "function", "addOption", "(", "OptionInterface", "$", "option", ")", "{", "if", "(", "!", "$", "this", "->", "hasOption", "(", "$", "option", ")", ")", "{", "$", "this", "->", "options", "->", "add", "(", "$", "option", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add a given option @param OptionInterface $option @return $this
[ "Add", "a", "given", "option" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/OptionSubjectTrait.php#L71-L78
19,103
lmammino/e-foundation
src/Variation/Model/OptionSubjectTrait.php
OptionSubjectTrait.removeOption
public function removeOption(OptionInterface $option) { if ($this->hasOption($option)) { $this->options->removeElement($option); } return $this; }
php
public function removeOption(OptionInterface $option) { if ($this->hasOption($option)) { $this->options->removeElement($option); } return $this; }
[ "public", "function", "removeOption", "(", "OptionInterface", "$", "option", ")", "{", "if", "(", "$", "this", "->", "hasOption", "(", "$", "option", ")", ")", "{", "$", "this", "->", "options", "->", "removeElement", "(", "$", "option", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove a given option @param OptionInterface $option @return $this
[ "Remove", "a", "given", "option" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/OptionSubjectTrait.php#L86-L93
19,104
atkrad/data-tables
src/Column/Action.php
Action.getContent
public function getContent($rowResult) { if ($this->callManager($rowResult) === false) { return ''; } return $this->builder->render($this->template); }
php
public function getContent($rowResult) { if ($this->callManager($rowResult) === false) { return ''; } return $this->builder->render($this->template); }
[ "public", "function", "getContent", "(", "$", "rowResult", ")", "{", "if", "(", "$", "this", "->", "callManager", "(", "$", "rowResult", ")", "===", "false", ")", "{", "return", "''", ";", "}", "return", "$", "this", "->", "builder", "->", "render", "(", "$", "this", "->", "template", ")", ";", "}" ]
Get column content @param mixed $rowResult Per row result @return string
[ "Get", "column", "content" ]
5afcc337ab624ca626e29d9674459c5105982b16
https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Column/Action.php#L75-L82
19,105
atkrad/data-tables
src/Column/Action.php
Action.setManager
public function setManager(Closure $manager) { if (!is_callable($manager)) { throw new Exception('Manager must be callable.'); } $this->manager = $manager; return $this; }
php
public function setManager(Closure $manager) { if (!is_callable($manager)) { throw new Exception('Manager must be callable.'); } $this->manager = $manager; return $this; }
[ "public", "function", "setManager", "(", "Closure", "$", "manager", ")", "{", "if", "(", "!", "is_callable", "(", "$", "manager", ")", ")", "{", "throw", "new", "Exception", "(", "'Manager must be callable.'", ")", ";", "}", "$", "this", "->", "manager", "=", "$", "manager", ";", "return", "$", "this", ";", "}" ]
Set action manager @param callable $manager @throws \DataTable\Exception @return Action
[ "Set", "action", "manager" ]
5afcc337ab624ca626e29d9674459c5105982b16
https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Column/Action.php#L92-L101
19,106
barebone-php/barebone-core
lib/Controller.php
Controller.render
protected function render($template, $data = [], $status = 200) { $rendered = View::render($template, $data); $this->response->getBody()->write($rendered); return $this->getResponse() ->withStatus($status) ->withHeader('Content-Type', 'text/html; charset=utf-8'); }
php
protected function render($template, $data = [], $status = 200) { $rendered = View::render($template, $data); $this->response->getBody()->write($rendered); return $this->getResponse() ->withStatus($status) ->withHeader('Content-Type', 'text/html; charset=utf-8'); }
[ "protected", "function", "render", "(", "$", "template", ",", "$", "data", "=", "[", "]", ",", "$", "status", "=", "200", ")", "{", "$", "rendered", "=", "View", "::", "render", "(", "$", "template", ",", "$", "data", ")", ";", "$", "this", "->", "response", "->", "getBody", "(", ")", "->", "write", "(", "$", "rendered", ")", ";", "return", "$", "this", "->", "getResponse", "(", ")", "->", "withStatus", "(", "$", "status", ")", "->", "withHeader", "(", "'Content-Type'", ",", "'text/html; charset=utf-8'", ")", ";", "}" ]
Render a view template with optional data @param string $template Relative Path to Template File @param array|object $data Associate Array or Object (key => value) @param int $status HTTP status code (100-599, default 200) @return Response
[ "Render", "a", "view", "template", "with", "optional", "data" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Controller.php#L109-L118
19,107
barebone-php/barebone-core
lib/Controller.php
Controller.redirect
protected function redirect($url, $status = 302) { return $this->getResponse() ->withStatus($status) ->withHeader('Location', (string)$url); }
php
protected function redirect($url, $status = 302) { return $this->getResponse() ->withStatus($status) ->withHeader('Location', (string)$url); }
[ "protected", "function", "redirect", "(", "$", "url", ",", "$", "status", "=", "302", ")", "{", "return", "$", "this", "->", "getResponse", "(", ")", "->", "withStatus", "(", "$", "status", ")", "->", "withHeader", "(", "'Location'", ",", "(", "string", ")", "$", "url", ")", ";", "}" ]
Redirect to URL with optional status @param string $url The redirect destination. @param int $status The redirect HTTP status code (between 100 and 599). @return Response
[ "Redirect", "to", "URL", "with", "optional", "status" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Controller.php#L150-L155
19,108
barebone-php/barebone-core
lib/Controller.php
Controller.routerError
public function routerError($error = null, $subject = null) { switch ($error) { case Router::ERR_NOT_FOUND: $status = 404; $template = 'router/error404'; break; case Router::ERR_BAD_METHOD: $status = 405; $template = 'router/error405'; break; case Router::ERR_MISSING_CONTROLLER: case Router::ERR_MISSING_ACTION: default: $status = 500; $template = 'router/error'; break; } return $this->render($template, compact('error', 'subject'), $status); }
php
public function routerError($error = null, $subject = null) { switch ($error) { case Router::ERR_NOT_FOUND: $status = 404; $template = 'router/error404'; break; case Router::ERR_BAD_METHOD: $status = 405; $template = 'router/error405'; break; case Router::ERR_MISSING_CONTROLLER: case Router::ERR_MISSING_ACTION: default: $status = 500; $template = 'router/error'; break; } return $this->render($template, compact('error', 'subject'), $status); }
[ "public", "function", "routerError", "(", "$", "error", "=", "null", ",", "$", "subject", "=", "null", ")", "{", "switch", "(", "$", "error", ")", "{", "case", "Router", "::", "ERR_NOT_FOUND", ":", "$", "status", "=", "404", ";", "$", "template", "=", "'router/error404'", ";", "break", ";", "case", "Router", "::", "ERR_BAD_METHOD", ":", "$", "status", "=", "405", ";", "$", "template", "=", "'router/error405'", ";", "break", ";", "case", "Router", "::", "ERR_MISSING_CONTROLLER", ":", "case", "Router", "::", "ERR_MISSING_ACTION", ":", "default", ":", "$", "status", "=", "500", ";", "$", "template", "=", "'router/error'", ";", "break", ";", "}", "return", "$", "this", "->", "render", "(", "$", "template", ",", "compact", "(", "'error'", ",", "'subject'", ")", ",", "$", "status", ")", ";", "}" ]
Router Error Action @param string $error Router::ERR_* @param mixed $subject Optional value for the error template @return Response
[ "Router", "Error", "Action" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Controller.php#L165-L185
19,109
barebone-php/barebone-core
lib/Controller.php
Controller.setRequest
public function setRequest(Request $request) { $this->request = $request; $parsedBody = $this->request->getParsedBody(); if (!empty($parsedBody)) { if (is_array($parsedBody)) { $this->data = array_map('trim', (array)$parsedBody); } else { $this->data = $parsedBody; } } return $this; }
php
public function setRequest(Request $request) { $this->request = $request; $parsedBody = $this->request->getParsedBody(); if (!empty($parsedBody)) { if (is_array($parsedBody)) { $this->data = array_map('trim', (array)$parsedBody); } else { $this->data = $parsedBody; } } return $this; }
[ "public", "function", "setRequest", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "request", "=", "$", "request", ";", "$", "parsedBody", "=", "$", "this", "->", "request", "->", "getParsedBody", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "parsedBody", ")", ")", "{", "if", "(", "is_array", "(", "$", "parsedBody", ")", ")", "{", "$", "this", "->", "data", "=", "array_map", "(", "'trim'", ",", "(", "array", ")", "$", "parsedBody", ")", ";", "}", "else", "{", "$", "this", "->", "data", "=", "$", "parsedBody", ";", "}", "}", "return", "$", "this", ";", "}" ]
Assign a request object @param Request $request FIG-7 Request Interface @return self
[ "Assign", "a", "request", "object" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Controller.php#L278-L293
19,110
steeffeen/FancyManiaLinks
FML/Controls/Frame3d.php
Frame3d.setStyle3dId
public function setStyle3dId($style3dId) { $this->style3dId = (string)$style3dId; $this->style3d = null; return $this; }
php
public function setStyle3dId($style3dId) { $this->style3dId = (string)$style3dId; $this->style3d = null; return $this; }
[ "public", "function", "setStyle3dId", "(", "$", "style3dId", ")", "{", "$", "this", "->", "style3dId", "=", "(", "string", ")", "$", "style3dId", ";", "$", "this", "->", "style3d", "=", "null", ";", "return", "$", "this", ";", "}" ]
Set the Style3d id @api @param string $style3dId Style3d id @return static
[ "Set", "the", "Style3d", "id" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Frame3d.php#L81-L86
19,111
steeffeen/FancyManiaLinks
FML/Controls/Frame3d.php
Frame3d.setStyle3d
public function setStyle3d(Style3d $style3d) { $this->style3dId = null; $this->style3d = $style3d; return $this; }
php
public function setStyle3d(Style3d $style3d) { $this->style3dId = null; $this->style3d = $style3d; return $this; }
[ "public", "function", "setStyle3d", "(", "Style3d", "$", "style3d", ")", "{", "$", "this", "->", "style3dId", "=", "null", ";", "$", "this", "->", "style3d", "=", "$", "style3d", ";", "return", "$", "this", ";", "}" ]
Set the Style3d @api @param Style3d $style3d Style3d @return static
[ "Set", "the", "Style3d" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Frame3d.php#L106-L111
19,112
SignpostMarv/daft-object
src/AbstractArrayBackedDaftObject.php
AbstractArrayBackedDaftObject.RetrievePropertyValueFromData
protected function RetrievePropertyValueFromData(string $property) { $isNullable = in_array( $property, static::DaftObjectNullableProperties(), DefinitionAssistant::IN_ARRAY_STRICT_MODE ); if ( ! array_key_exists($property, $this->data) && ! $isNullable) { throw Exceptions\Factory::PropertyNotNullableException(static::class, $property); } elseif ($isNullable) { return $this->data[$property] ?? null; } return $this->data[$property]; }
php
protected function RetrievePropertyValueFromData(string $property) { $isNullable = in_array( $property, static::DaftObjectNullableProperties(), DefinitionAssistant::IN_ARRAY_STRICT_MODE ); if ( ! array_key_exists($property, $this->data) && ! $isNullable) { throw Exceptions\Factory::PropertyNotNullableException(static::class, $property); } elseif ($isNullable) { return $this->data[$property] ?? null; } return $this->data[$property]; }
[ "protected", "function", "RetrievePropertyValueFromData", "(", "string", "$", "property", ")", "{", "$", "isNullable", "=", "in_array", "(", "$", "property", ",", "static", "::", "DaftObjectNullableProperties", "(", ")", ",", "DefinitionAssistant", "::", "IN_ARRAY_STRICT_MODE", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "property", ",", "$", "this", "->", "data", ")", "&&", "!", "$", "isNullable", ")", "{", "throw", "Exceptions", "\\", "Factory", "::", "PropertyNotNullableException", "(", "static", "::", "class", ",", "$", "property", ")", ";", "}", "elseif", "(", "$", "isNullable", ")", "{", "return", "$", "this", "->", "data", "[", "$", "property", "]", "??", "null", ";", "}", "return", "$", "this", "->", "data", "[", "$", "property", "]", ";", "}" ]
Retrieve a property from data. @param string $property the property being retrieved @throws Exceptions\PropertyNotNullableException if value is not set and $property is not listed as nullabe @return scalar|array|object|null the property value
[ "Retrieve", "a", "property", "from", "data", "." ]
514886592b64986cc637040045f098335e27c037
https://github.com/SignpostMarv/daft-object/blob/514886592b64986cc637040045f098335e27c037/src/AbstractArrayBackedDaftObject.php#L180-L195
19,113
haldayne/boost
src/MapOfCollections.php
MapOfCollections.pluck
public function pluck($key_for_value, $key_for_key = null) { $map = new Map; $this->walk(function ($v) use ($key_for_value, $key_for_key, $map) { // get the key to use if (null === $key_for_key) { $key = null; } else if ($v->has($key_for_key)) { $key = $v->get($key_for_key); } else { throw new \OutOfBoundsException(); } // add the value at that key, provided we have one if ($v->has($key_for_value)) { $map[$key] = $v->get($key_for_value); } else { throw new \OutOfBoundsException(); } }); return $map; }
php
public function pluck($key_for_value, $key_for_key = null) { $map = new Map; $this->walk(function ($v) use ($key_for_value, $key_for_key, $map) { // get the key to use if (null === $key_for_key) { $key = null; } else if ($v->has($key_for_key)) { $key = $v->get($key_for_key); } else { throw new \OutOfBoundsException(); } // add the value at that key, provided we have one if ($v->has($key_for_value)) { $map[$key] = $v->get($key_for_value); } else { throw new \OutOfBoundsException(); } }); return $map; }
[ "public", "function", "pluck", "(", "$", "key_for_value", ",", "$", "key_for_key", "=", "null", ")", "{", "$", "map", "=", "new", "Map", ";", "$", "this", "->", "walk", "(", "function", "(", "$", "v", ")", "use", "(", "$", "key_for_value", ",", "$", "key_for_key", ",", "$", "map", ")", "{", "// get the key to use", "if", "(", "null", "===", "$", "key_for_key", ")", "{", "$", "key", "=", "null", ";", "}", "else", "if", "(", "$", "v", "->", "has", "(", "$", "key_for_key", ")", ")", "{", "$", "key", "=", "$", "v", "->", "get", "(", "$", "key_for_key", ")", ";", "}", "else", "{", "throw", "new", "\\", "OutOfBoundsException", "(", ")", ";", "}", "// add the value at that key, provided we have one", "if", "(", "$", "v", "->", "has", "(", "$", "key_for_value", ")", ")", "{", "$", "map", "[", "$", "key", "]", "=", "$", "v", "->", "get", "(", "$", "key_for_value", ")", ";", "}", "else", "{", "throw", "new", "\\", "OutOfBoundsException", "(", ")", ";", "}", "}", ")", ";", "return", "$", "map", ";", "}" ]
Create a new map by pulling the given key out of all contained maps. Thinking of a Map of Collections as a two-dimensional array, this method slices a column out: ``` use Haldayne\Boost\MapOfCollections; $map = new MapOfCollections; $map->push([ 'id' => 5, 'name' => 'Ada', 'age' => 16 ]); $map->push([ 'id' => 6, 'name' => 'Bee', 'age' => 12 ]); $map->push([ 'id' => 7, 'name' => 'Cam', 'age' => 37 ]); var_dump( $map->pluck('name')->toArray(); // [ 'Ada', 'Bee', 'Cam' ] $map->pluck('name', 'id')->toArray(); // [ 5=>'Ada', 6=>'Bee', 7=>'Cam' ] ); ``` @param $mixed $key_for_value The key holding the new value. @param $mixed $key_for_key The key holding the new value's key. @return \Haldayne\Boost\Map @api
[ "Create", "a", "new", "map", "by", "pulling", "the", "given", "key", "out", "of", "all", "contained", "maps", "." ]
d18cc398557e23f9c316ea7fb40b90f84cc53650
https://github.com/haldayne/boost/blob/d18cc398557e23f9c316ea7fb40b90f84cc53650/src/MapOfCollections.php#L40-L61
19,114
Ocramius/OcraDiCompiler
src/OcraDiCompiler/Mvc/Service/DiFactory.php
DiFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); ErrorHandler::start(); $compiledInstantiators = include $config['ocra_di_compiler']['compiled_di_instantiator_filename']; ErrorHandler::stop(); if (!is_array($compiledInstantiators)) { $di = $this->createDi($config); $this->compileDi($di, $config); $this->getDiDefinitions($config, $di); $compiledInstantiators = include $config['ocra_di_compiler']['compiled_di_instantiator_filename']; } $di = new CompiledInstantiatorsDi(); $this->configureDi($di, $config); $di->setCompiledInstantiators($compiledInstantiators); $this->registerAbstractFactory($serviceLocator, $di); return $di; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); ErrorHandler::start(); $compiledInstantiators = include $config['ocra_di_compiler']['compiled_di_instantiator_filename']; ErrorHandler::stop(); if (!is_array($compiledInstantiators)) { $di = $this->createDi($config); $this->compileDi($di, $config); $this->getDiDefinitions($config, $di); $compiledInstantiators = include $config['ocra_di_compiler']['compiled_di_instantiator_filename']; } $di = new CompiledInstantiatorsDi(); $this->configureDi($di, $config); $di->setCompiledInstantiators($compiledInstantiators); $this->registerAbstractFactory($serviceLocator, $di); return $di; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "config", "=", "$", "serviceLocator", "->", "get", "(", "'Config'", ")", ";", "ErrorHandler", "::", "start", "(", ")", ";", "$", "compiledInstantiators", "=", "include", "$", "config", "[", "'ocra_di_compiler'", "]", "[", "'compiled_di_instantiator_filename'", "]", ";", "ErrorHandler", "::", "stop", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "compiledInstantiators", ")", ")", "{", "$", "di", "=", "$", "this", "->", "createDi", "(", "$", "config", ")", ";", "$", "this", "->", "compileDi", "(", "$", "di", ",", "$", "config", ")", ";", "$", "this", "->", "getDiDefinitions", "(", "$", "config", ",", "$", "di", ")", ";", "$", "compiledInstantiators", "=", "include", "$", "config", "[", "'ocra_di_compiler'", "]", "[", "'compiled_di_instantiator_filename'", "]", ";", "}", "$", "di", "=", "new", "CompiledInstantiatorsDi", "(", ")", ";", "$", "this", "->", "configureDi", "(", "$", "di", ",", "$", "config", ")", ";", "$", "di", "->", "setCompiledInstantiators", "(", "$", "compiledInstantiators", ")", ";", "$", "this", "->", "registerAbstractFactory", "(", "$", "serviceLocator", ",", "$", "di", ")", ";", "return", "$", "di", ";", "}" ]
Generates a compiled Di proxy to be used as a replacement for \Zend\Di\Di @param ServiceLocatorInterface $serviceLocator @return Di
[ "Generates", "a", "compiled", "Di", "proxy", "to", "be", "used", "as", "a", "replacement", "for", "\\", "Zend", "\\", "Di", "\\", "Di" ]
667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a
https://github.com/Ocramius/OcraDiCompiler/blob/667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a/src/OcraDiCompiler/Mvc/Service/DiFactory.php#L55-L77
19,115
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Util/ArrayUtil.php
ArrayUtil.flatten
public static function flatten(array $array, $prefix = '', $join = '.') { $flat = array(); foreach ($array as $key => $value) { $key = $prefix ? $prefix . $join . $key : $key; if (is_array($value)) { $flat = array_merge( $flat, self::flatten($value, $key, $join) ); } else { $flat[$key] = $value; } } return $flat; }
php
public static function flatten(array $array, $prefix = '', $join = '.') { $flat = array(); foreach ($array as $key => $value) { $key = $prefix ? $prefix . $join . $key : $key; if (is_array($value)) { $flat = array_merge( $flat, self::flatten($value, $key, $join) ); } else { $flat[$key] = $value; } } return $flat; }
[ "public", "static", "function", "flatten", "(", "array", "$", "array", ",", "$", "prefix", "=", "''", ",", "$", "join", "=", "'.'", ")", "{", "$", "flat", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "$", "prefix", "?", "$", "prefix", ".", "$", "join", ".", "$", "key", ":", "$", "key", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "flat", "=", "array_merge", "(", "$", "flat", ",", "self", "::", "flatten", "(", "$", "value", ",", "$", "key", ",", "$", "join", ")", ")", ";", "}", "else", "{", "$", "flat", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "flat", ";", "}" ]
Flattens an associative array. @param array $array An array. @param string $prefix A key prefix. @param string $join The key join character. @return array The flattened array.
[ "Flattens", "an", "associative", "array", "." ]
7621e0be7dbb2a015d68197d290fe8469f539a4d
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Util/ArrayUtil.php#L21-L39
19,116
webforge-labs/psc-cms
lib/Psc/HTML/WidgetBase.php
WidgetBase.doInit
protected function doInit() { if ($this->loadWith === self::JAVASCRIPT) { jQuery::widget($this->html, $this->widgetName, (array) $this->widgetOptions); } else { $this->html ->setAttribute('data-widget', $this->widgetName) ->setAttribute('data-widget-options', $this->getJSONConverter()->stringify((object) $this->widgetOptions)) ->addClass('widget-not-initialized') ; } }
php
protected function doInit() { if ($this->loadWith === self::JAVASCRIPT) { jQuery::widget($this->html, $this->widgetName, (array) $this->widgetOptions); } else { $this->html ->setAttribute('data-widget', $this->widgetName) ->setAttribute('data-widget-options', $this->getJSONConverter()->stringify((object) $this->widgetOptions)) ->addClass('widget-not-initialized') ; } }
[ "protected", "function", "doInit", "(", ")", "{", "if", "(", "$", "this", "->", "loadWith", "===", "self", "::", "JAVASCRIPT", ")", "{", "jQuery", "::", "widget", "(", "$", "this", "->", "html", ",", "$", "this", "->", "widgetName", ",", "(", "array", ")", "$", "this", "->", "widgetOptions", ")", ";", "}", "else", "{", "$", "this", "->", "html", "->", "setAttribute", "(", "'data-widget'", ",", "$", "this", "->", "widgetName", ")", "->", "setAttribute", "(", "'data-widget-options'", ",", "$", "this", "->", "getJSONConverter", "(", ")", "->", "stringify", "(", "(", "object", ")", "$", "this", "->", "widgetOptions", ")", ")", "->", "addClass", "(", "'widget-not-initialized'", ")", ";", "}", "}" ]
Initialisiert das Widget des objektes wenn loadWith === self::JAVASCRIPT ist an das Element wird inline Javascript angehängt welcher jQuery( elementSelector ).$widgetName.({ $options}) aufruft ansonsten wird im Element die attribute data-widget und data-widget-options (ein JSON string) gesetzt
[ "Initialisiert", "das", "Widget", "des", "objektes" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/HTML/WidgetBase.php#L40-L50
19,117
anime-db/app-bundle
src/Event/Listener/Project.php
Project.onUpdatedProposeUpdateTask
public function onUpdatedProposeUpdateTask() { /* @var $task Task */ $task = $this->em ->getRepository('AnimeDbAppBundle:Task') ->findOneBy(['command' => 'animedb:propose-update']); $next_run = new \DateTime(); $next_run->modify(sprintf('+%s seconds 01:00:00', ProposeUpdateCommand::INERVAL_UPDATE)); $this->em->persist($task->setNextRun($next_run)); $this->em->flush(); }
php
public function onUpdatedProposeUpdateTask() { /* @var $task Task */ $task = $this->em ->getRepository('AnimeDbAppBundle:Task') ->findOneBy(['command' => 'animedb:propose-update']); $next_run = new \DateTime(); $next_run->modify(sprintf('+%s seconds 01:00:00', ProposeUpdateCommand::INERVAL_UPDATE)); $this->em->persist($task->setNextRun($next_run)); $this->em->flush(); }
[ "public", "function", "onUpdatedProposeUpdateTask", "(", ")", "{", "/* @var $task Task */", "$", "task", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'AnimeDbAppBundle:Task'", ")", "->", "findOneBy", "(", "[", "'command'", "=>", "'animedb:propose-update'", "]", ")", ";", "$", "next_run", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "next_run", "->", "modify", "(", "sprintf", "(", "'+%s seconds 01:00:00'", ",", "ProposeUpdateCommand", "::", "INERVAL_UPDATE", ")", ")", ";", "$", "this", "->", "em", "->", "persist", "(", "$", "task", "->", "setNextRun", "(", "$", "next_run", ")", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}" ]
Update next run date for the propose update task.
[ "Update", "next", "run", "date", "for", "the", "propose", "update", "task", "." ]
ca3b342081719d41ba018792a75970cbb1f1fe22
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Event/Listener/Project.php#L52-L64
19,118
stanislav-web/phalcon-ulogin
src/ULogin/Init.php
Init.setProviders
public function setProviders($providers) { $array = Parser::map($providers); // collection data if (empty($array['required']) === false) { $this->requiredProviders = implode(',', $array['required']); } if (empty($array['hidden']) === false) { $this->hiddenProviders = implode(',', $array['hidden']); } return $this; }
php
public function setProviders($providers) { $array = Parser::map($providers); // collection data if (empty($array['required']) === false) { $this->requiredProviders = implode(',', $array['required']); } if (empty($array['hidden']) === false) { $this->hiddenProviders = implode(',', $array['hidden']); } return $this; }
[ "public", "function", "setProviders", "(", "$", "providers", ")", "{", "$", "array", "=", "Parser", "::", "map", "(", "$", "providers", ")", ";", "// collection data", "if", "(", "empty", "(", "$", "array", "[", "'required'", "]", ")", "===", "false", ")", "{", "$", "this", "->", "requiredProviders", "=", "implode", "(", "','", ",", "$", "array", "[", "'required'", "]", ")", ";", "}", "if", "(", "empty", "(", "$", "array", "[", "'hidden'", "]", ")", "===", "false", ")", "{", "$", "this", "->", "hiddenProviders", "=", "implode", "(", "','", ",", "$", "array", "[", "'hidden'", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Allows you to add authentication providers in the list of available. @param mixed $providers as ('provider' => true, 'provider' => false) or string separated by comma @example <code> $this->setProviders([ 'vkontakte' => true, 'odnoklassniki' => true, 'mailru' => true, 'facebook' => true, 'twitter' => false, // in drop down 'google' => false, // in drop down 'yandex' => false, // in drop down 'livejournal' => false, // in drop down 'openid' => false // in drop down ]); $this->setProviders('vkontakte=true,odnoklassniki=true,mailru=true,openid=false'); </code> @return Init
[ "Allows", "you", "to", "add", "authentication", "providers", "in", "the", "list", "of", "available", "." ]
0cea8510a244ebb9b1333085b325a283e4fb9f2f
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Init.php#L129-L143
19,119
stanislav-web/phalcon-ulogin
src/ULogin/Init.php
Init.setFields
public function setFields($fields) { if (empty($fields) === false) { if (is_array($fields) === true) { $this->requiredFields = implode(',', $fields); } else { $this->requiredFields = $fields; } } return $this; }
php
public function setFields($fields) { if (empty($fields) === false) { if (is_array($fields) === true) { $this->requiredFields = implode(',', $fields); } else { $this->requiredFields = $fields; } } return $this; }
[ "public", "function", "setFields", "(", "$", "fields", ")", "{", "if", "(", "empty", "(", "$", "fields", ")", "===", "false", ")", "{", "if", "(", "is_array", "(", "$", "fields", ")", "===", "true", ")", "{", "$", "this", "->", "requiredFields", "=", "implode", "(", "','", ",", "$", "fields", ")", ";", "}", "else", "{", "$", "this", "->", "requiredFields", "=", "$", "fields", ";", "}", "}", "return", "$", "this", ";", "}" ]
Allows you to add to the list of fields requested for the provider's authorization. @param mixed $fields as ('field1', 'field2', ...) or string separated by comma @example <code> $this->setFields([ 'first_name', 'last_name', 'photo' ]); $this->setFields('first_name,last_name,photo'); </code> @return Init
[ "Allows", "you", "to", "add", "to", "the", "list", "of", "fields", "requested", "for", "the", "provider", "s", "authorization", "." ]
0cea8510a244ebb9b1333085b325a283e4fb9f2f
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Init.php#L160-L174
19,120
stanislav-web/phalcon-ulogin
src/ULogin/Init.php
Init.setOptional
public function setOptional($fields) { if (empty($fields) === false) { if (is_array($fields) === true) { $this->optionalFields = implode(',', $fields); } else { $this->optionalFields = $fields; } } return $this; }
php
public function setOptional($fields) { if (empty($fields) === false) { if (is_array($fields) === true) { $this->optionalFields = implode(',', $fields); } else { $this->optionalFields = $fields; } } return $this; }
[ "public", "function", "setOptional", "(", "$", "fields", ")", "{", "if", "(", "empty", "(", "$", "fields", ")", "===", "false", ")", "{", "if", "(", "is_array", "(", "$", "fields", ")", "===", "true", ")", "{", "$", "this", "->", "optionalFields", "=", "implode", "(", "','", ",", "$", "fields", ")", ";", "}", "else", "{", "$", "this", "->", "optionalFields", "=", "$", "fields", ";", "}", "}", "return", "$", "this", ";", "}" ]
Allows you to add to the list of optionals fields. @param mixed $fields as ('field1', 'field2', ...) or string separated by comma @example <code> $this->setOptional([ 'bday', 'city', 'sex' ]); $this->setOptional('bday,city,sex'); </code> @return Init
[ "Allows", "you", "to", "add", "to", "the", "list", "of", "optionals", "fields", "." ]
0cea8510a244ebb9b1333085b325a283e4fb9f2f
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Init.php#L191-L206
19,121
stanislav-web/phalcon-ulogin
src/ULogin/Init.php
Init.setType
public function setType($type) { if(is_array($type) === true) { $type = $type[key($type)]; } $this->types = array_flip($this->types); if (isset($this->types[$type]) === true) { $this->widget = $type; } return $this; }
php
public function setType($type) { if(is_array($type) === true) { $type = $type[key($type)]; } $this->types = array_flip($this->types); if (isset($this->types[$type]) === true) { $this->widget = $type; } return $this; }
[ "public", "function", "setType", "(", "$", "type", ")", "{", "if", "(", "is_array", "(", "$", "type", ")", "===", "true", ")", "{", "$", "type", "=", "$", "type", "[", "key", "(", "$", "type", ")", "]", ";", "}", "$", "this", "->", "types", "=", "array_flip", "(", "$", "this", "->", "types", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "types", "[", "$", "type", "]", ")", "===", "true", ")", "{", "$", "this", "->", "widget", "=", "$", "type", ";", "}", "return", "$", "this", ";", "}" ]
Lets you specify the widget type. Must match the variable `types` @param $type @example <code> $this->setType('small'); </code> @return Init
[ "Lets", "you", "specify", "the", "widget", "type", ".", "Must", "match", "the", "variable", "types" ]
0cea8510a244ebb9b1333085b325a283e4fb9f2f
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Init.php#L217-L231
19,122
stanislav-web/phalcon-ulogin
src/ULogin/Init.php
Init.setUrl
public function setUrl($url = '') { if(is_array($url) === true) { $url = $url[key($url)]; } $request = new Request(); if (empty($url) === true) { $this->url = $request->getScheme() . '://' . $request->getHttpHost() . (new Router())->getRewriteUri(); } else { $this->url = $request->getScheme() . '://' . $request->getHttpHost() . $url; } return $this; }
php
public function setUrl($url = '') { if(is_array($url) === true) { $url = $url[key($url)]; } $request = new Request(); if (empty($url) === true) { $this->url = $request->getScheme() . '://' . $request->getHttpHost() . (new Router())->getRewriteUri(); } else { $this->url = $request->getScheme() . '://' . $request->getHttpHost() . $url; } return $this; }
[ "public", "function", "setUrl", "(", "$", "url", "=", "''", ")", "{", "if", "(", "is_array", "(", "$", "url", ")", "===", "true", ")", "{", "$", "url", "=", "$", "url", "[", "key", "(", "$", "url", ")", "]", ";", "}", "$", "request", "=", "new", "Request", "(", ")", ";", "if", "(", "empty", "(", "$", "url", ")", "===", "true", ")", "{", "$", "this", "->", "url", "=", "$", "request", "->", "getScheme", "(", ")", ".", "'://'", ".", "$", "request", "->", "getHttpHost", "(", ")", ".", "(", "new", "Router", "(", ")", ")", "->", "getRewriteUri", "(", ")", ";", "}", "else", "{", "$", "this", "->", "url", "=", "$", "request", "->", "getScheme", "(", ")", ".", "'://'", ".", "$", "request", "->", "getHttpHost", "(", ")", ".", "$", "url", ";", "}", "return", "$", "this", ";", "}" ]
Lets you specify the callback url to redirect to when authorizing the page is reloaded. If the url is not specified and is used to redirect the authorization, the authorization after the current page just updated @param string $url page that will be implemented to redirect after login (accept QUERY_STRING) @return $this
[ "Lets", "you", "specify", "the", "callback", "url", "to", "redirect", "to", "when", "authorizing", "the", "page", "is", "reloaded", ".", "If", "the", "url", "is", "not", "specified", "and", "is", "used", "to", "redirect", "the", "authorization", "the", "authorization", "after", "the", "current", "page", "just", "updated" ]
0cea8510a244ebb9b1333085b325a283e4fb9f2f
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Init.php#L241-L257
19,123
stanislav-web/phalcon-ulogin
src/ULogin/Init.php
Init.destroyUserData
private function destroyUserData() { if (is_array($this->user) === true && isset($this->user["error"]) === true ) { $this->user = false; return true; } return false; }
php
private function destroyUserData() { if (is_array($this->user) === true && isset($this->user["error"]) === true ) { $this->user = false; return true; } return false; }
[ "private", "function", "destroyUserData", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "user", ")", "===", "true", "&&", "isset", "(", "$", "this", "->", "user", "[", "\"error\"", "]", ")", "===", "true", ")", "{", "$", "this", "->", "user", "=", "false", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Destroy user data @return bool
[ "Destroy", "user", "data" ]
0cea8510a244ebb9b1333085b325a283e4fb9f2f
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Init.php#L264-L274
19,124
stanislav-web/phalcon-ulogin
src/ULogin/Init.php
Init.getToken
public function getToken() { $request = new Request(); if ($request->isPost() === true) { $this->token = $request->getPost('token', null, false); } else { $this->token = $request->getQuery('token', null, false); } return $this->token; }
php
public function getToken() { $request = new Request(); if ($request->isPost() === true) { $this->token = $request->getPost('token', null, false); } else { $this->token = $request->getQuery('token', null, false); } return $this->token; }
[ "public", "function", "getToken", "(", ")", "{", "$", "request", "=", "new", "Request", "(", ")", ";", "if", "(", "$", "request", "->", "isPost", "(", ")", "===", "true", ")", "{", "$", "this", "->", "token", "=", "$", "request", "->", "getPost", "(", "'token'", ",", "null", ",", "false", ")", ";", "}", "else", "{", "$", "this", "->", "token", "=", "$", "request", "->", "getQuery", "(", "'token'", ",", "null", ",", "false", ")", ";", "}", "return", "$", "this", "->", "token", ";", "}" ]
Reads the parameters passed to the script, and selects the authorization key ULogin @return bool|mixed
[ "Reads", "the", "parameters", "passed", "to", "the", "script", "and", "selects", "the", "authorization", "key", "ULogin" ]
0cea8510a244ebb9b1333085b325a283e4fb9f2f
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Init.php#L281-L293
19,125
stanislav-web/phalcon-ulogin
src/ULogin/Init.php
Init.getUser
public function getUser() { // destroy previous content $this->destroyUserData(); if ($this->user === false) { // get user $url = 'http://ulogin.ru/token.php?token=' . $this->getToken() . '&host=' . (new Request())->getHttpHost(); $content = file_get_contents($url); $this->user = json_decode($content, true); // if use has error , destroy user data if ($this->destroyUserData() === true) { $this->logout(); } } return $this->user; }
php
public function getUser() { // destroy previous content $this->destroyUserData(); if ($this->user === false) { // get user $url = 'http://ulogin.ru/token.php?token=' . $this->getToken() . '&host=' . (new Request())->getHttpHost(); $content = file_get_contents($url); $this->user = json_decode($content, true); // if use has error , destroy user data if ($this->destroyUserData() === true) { $this->logout(); } } return $this->user; }
[ "public", "function", "getUser", "(", ")", "{", "// destroy previous content", "$", "this", "->", "destroyUserData", "(", ")", ";", "if", "(", "$", "this", "->", "user", "===", "false", ")", "{", "// get user", "$", "url", "=", "'http://ulogin.ru/token.php?token='", ".", "$", "this", "->", "getToken", "(", ")", ".", "'&host='", ".", "(", "new", "Request", "(", ")", ")", "->", "getHttpHost", "(", ")", ";", "$", "content", "=", "file_get_contents", "(", "$", "url", ")", ";", "$", "this", "->", "user", "=", "json_decode", "(", "$", "content", ",", "true", ")", ";", "// if use has error , destroy user data", "if", "(", "$", "this", "->", "destroyUserData", "(", ")", "===", "true", ")", "{", "$", "this", "->", "logout", "(", ")", ";", "}", "}", "return", "$", "this", "->", "user", ";", "}" ]
Returns an associative array with the data about the user. Fields array described in the method setFields @example <code> $this->getUser(); </code> @return array|bool|mixed data provided by the ISP login
[ "Returns", "an", "associative", "array", "with", "the", "data", "about", "the", "user", ".", "Fields", "array", "described", "in", "the", "method", "setFields" ]
0cea8510a244ebb9b1333085b325a283e4fb9f2f
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Init.php#L305-L326
19,126
stanislav-web/phalcon-ulogin
src/ULogin/Init.php
Init.isAuthorised
public function isAuthorised() { if (is_array($this->user) === true && isset($this->user['error']) === false ) { return true; } return $this->getUser(); }
php
public function isAuthorised() { if (is_array($this->user) === true && isset($this->user['error']) === false ) { return true; } return $this->getUser(); }
[ "public", "function", "isAuthorised", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "user", ")", "===", "true", "&&", "isset", "(", "$", "this", "->", "user", "[", "'error'", "]", ")", "===", "false", ")", "{", "return", "true", ";", "}", "return", "$", "this", "->", "getUser", "(", ")", ";", "}" ]
Checks whether logon @return array|bool|mixed
[ "Checks", "whether", "logon" ]
0cea8510a244ebb9b1333085b325a283e4fb9f2f
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Init.php#L333-L344
19,127
stanislav-web/phalcon-ulogin
src/ULogin/Init.php
Init.getForm
public function getForm() { $view = new View(); return $view->render(__DIR__ . '/../views/ulogin', [ 'widget' => $this->widget, 'fields' => $this->requiredFields, 'optional' => $this->optionalFields, 'providers' => $this->requiredProviders, 'hidden' => $this->hiddenProviders, 'url' => $this->url ]); }
php
public function getForm() { $view = new View(); return $view->render(__DIR__ . '/../views/ulogin', [ 'widget' => $this->widget, 'fields' => $this->requiredFields, 'optional' => $this->optionalFields, 'providers' => $this->requiredProviders, 'hidden' => $this->hiddenProviders, 'url' => $this->url ]); }
[ "public", "function", "getForm", "(", ")", "{", "$", "view", "=", "new", "View", "(", ")", ";", "return", "$", "view", "->", "render", "(", "__DIR__", ".", "'/../views/ulogin'", ",", "[", "'widget'", "=>", "$", "this", "->", "widget", ",", "'fields'", "=>", "$", "this", "->", "requiredFields", ",", "'optional'", "=>", "$", "this", "->", "optionalFields", ",", "'providers'", "=>", "$", "this", "->", "requiredProviders", ",", "'hidden'", "=>", "$", "this", "->", "hiddenProviders", ",", "'url'", "=>", "$", "this", "->", "url", "]", ")", ";", "}" ]
Returns the html-form widget @return View
[ "Returns", "the", "html", "-", "form", "widget" ]
0cea8510a244ebb9b1333085b325a283e4fb9f2f
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Init.php#L366-L380
19,128
jfusion/org.jfusion.framework
src/Installer/Installer.php
Installer.setOverwrite
public function setOverwrite($state = false) { $tmp = $this->overwrite; if ($state) { $this->overwrite = true; } else { $this->overwrite = false; } return $tmp; }
php
public function setOverwrite($state = false) { $tmp = $this->overwrite; if ($state) { $this->overwrite = true; } else { $this->overwrite = false; } return $tmp; }
[ "public", "function", "setOverwrite", "(", "$", "state", "=", "false", ")", "{", "$", "tmp", "=", "$", "this", "->", "overwrite", ";", "if", "(", "$", "state", ")", "{", "$", "this", "->", "overwrite", "=", "true", ";", "}", "else", "{", "$", "this", "->", "overwrite", "=", "false", ";", "}", "return", "$", "tmp", ";", "}" ]
Set the allow overwrite switch @param boolean $state Overwrite switch state @return boolean True it state is set, false if it is not @since 3.1
[ "Set", "the", "allow", "overwrite", "switch" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Installer.php#L125-L139
19,129
jfusion/org.jfusion.framework
src/Installer/Installer.php
Installer.setUpgrade
public function setUpgrade($state = false) { $tmp = $this->upgrade; if ($state) { $this->upgrade = true; } else { $this->upgrade = false; } return $tmp; }
php
public function setUpgrade($state = false) { $tmp = $this->upgrade; if ($state) { $this->upgrade = true; } else { $this->upgrade = false; } return $tmp; }
[ "public", "function", "setUpgrade", "(", "$", "state", "=", "false", ")", "{", "$", "tmp", "=", "$", "this", "->", "upgrade", ";", "if", "(", "$", "state", ")", "{", "$", "this", "->", "upgrade", "=", "true", ";", "}", "else", "{", "$", "this", "->", "upgrade", "=", "false", ";", "}", "return", "$", "tmp", ";", "}" ]
Set the upgrade switch @param boolean $state Upgrade switch state @return boolean True if upgrade, false otherwise @since 3.1
[ "Set", "the", "upgrade", "switch" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Installer.php#L162-L176
19,130
jfusion/org.jfusion.framework
src/Installer/Installer.php
Installer.getPath
public function getPath($name, $default = null) { return (!empty($this->paths[$name])) ? $this->paths[$name] : $default; }
php
public function getPath($name, $default = null) { return (!empty($this->paths[$name])) ? $this->paths[$name] : $default; }
[ "public", "function", "getPath", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "return", "(", "!", "empty", "(", "$", "this", "->", "paths", "[", "$", "name", "]", ")", ")", "?", "$", "this", "->", "paths", "[", "$", "name", "]", ":", "$", "default", ";", "}" ]
Get an installer path by name @param string $name Path name @param string $default Default value @return string Path @since 3.1
[ "Get", "an", "installer", "path", "by", "name" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Installer.php#L188-L191
19,131
jfusion/org.jfusion.framework
src/Installer/Installer.php
Installer.abort
public function abort($msg = null, $type = null) { $retval = true; $step = array_pop($this->stepStack); // Raise abort warning if ($msg) { $this->log(LogLevel::WARNING, $msg); } while ($step != null) { switch ($step['type']) { case 'file': // Remove the file $stepval = File::delete($step['path']); break; case 'folder': // Remove the folder $stepval = File::delete($step['path']); break; default: $stepval = false; break; } // Only set the return value if it is false if ($stepval === false) { $retval = false; } // Get the next step and continue $step = array_pop($this->stepStack); } $debug = Config::get()->get('debug'); if ($debug) { throw new RuntimeException('Installation unexpectedly terminated: ' . $msg, 500); } return $retval; }
php
public function abort($msg = null, $type = null) { $retval = true; $step = array_pop($this->stepStack); // Raise abort warning if ($msg) { $this->log(LogLevel::WARNING, $msg); } while ($step != null) { switch ($step['type']) { case 'file': // Remove the file $stepval = File::delete($step['path']); break; case 'folder': // Remove the folder $stepval = File::delete($step['path']); break; default: $stepval = false; break; } // Only set the return value if it is false if ($stepval === false) { $retval = false; } // Get the next step and continue $step = array_pop($this->stepStack); } $debug = Config::get()->get('debug'); if ($debug) { throw new RuntimeException('Installation unexpectedly terminated: ' . $msg, 500); } return $retval; }
[ "public", "function", "abort", "(", "$", "msg", "=", "null", ",", "$", "type", "=", "null", ")", "{", "$", "retval", "=", "true", ";", "$", "step", "=", "array_pop", "(", "$", "this", "->", "stepStack", ")", ";", "// Raise abort warning", "if", "(", "$", "msg", ")", "{", "$", "this", "->", "log", "(", "LogLevel", "::", "WARNING", ",", "$", "msg", ")", ";", "}", "while", "(", "$", "step", "!=", "null", ")", "{", "switch", "(", "$", "step", "[", "'type'", "]", ")", "{", "case", "'file'", ":", "// Remove the file", "$", "stepval", "=", "File", "::", "delete", "(", "$", "step", "[", "'path'", "]", ")", ";", "break", ";", "case", "'folder'", ":", "// Remove the folder", "$", "stepval", "=", "File", "::", "delete", "(", "$", "step", "[", "'path'", "]", ")", ";", "break", ";", "default", ":", "$", "stepval", "=", "false", ";", "break", ";", "}", "// Only set the return value if it is false", "if", "(", "$", "stepval", "===", "false", ")", "{", "$", "retval", "=", "false", ";", "}", "// Get the next step and continue", "$", "step", "=", "array_pop", "(", "$", "this", "->", "stepStack", ")", ";", "}", "$", "debug", "=", "Config", "::", "get", "(", ")", "->", "get", "(", "'debug'", ")", ";", "if", "(", "$", "debug", ")", "{", "throw", "new", "RuntimeException", "(", "'Installation unexpectedly terminated: '", ".", "$", "msg", ",", "500", ")", ";", "}", "return", "$", "retval", ";", "}" ]
Installation abort method @param string $msg Abort message from the installer @param string $type Package type if defined @return boolean True if successful @since 3.1 @throws RuntimeException
[ "Installation", "abort", "method" ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Installer.php#L233-L279
19,132
jfusion/org.jfusion.framework
src/Installer/Installer.php
Installer.parseFiles
public function parseFiles(SimpleXMLElement $element, $cid = 0, $oldFiles = null, $oldMD5 = null) { // Get the array of file nodes to process; we checked whether this had children above. if (!$element || !$element->children()->count()) { // Either the tag does not exist or has no children (hence no files to process) therefore we return zero files processed. return 0; } $copyfiles = array(); /* * Here we set the folder we are going to remove the files from. */ $pathname = 'extension_root'; $destination = $this->getPath($pathname); /* * Here we set the folder we are going to copy the files from. * * Does the element have a folder attribute? * * If so this indicates that the files are in a subdirectory of the source * folder and we should append the folder attribute to the source path when * copying files. */ $folder = (string) $element->attributes()->folder; if ($folder && file_exists($this->getPath('source') . '/' . $folder)) { $source = $this->getPath('source') . '/' . $folder; } else { $source = $this->getPath('source'); } // Work out what files have been deleted if ($oldFiles && ($oldFiles instanceof SimpleXMLElement)) { $oldEntries = $oldFiles->children(); if ($oldEntries->count()) { $deletions = $this->findDeletedFiles($oldEntries, $element->children()); foreach ($deletions['folders'] as $deleted_folder) { Folder::delete($destination . '/' . $deleted_folder); } foreach ($deletions['files'] as $deleted_file) { File::delete($destination . '/' . $deleted_file); } } } $path = array(); // Copy the MD5SUMS file if it exists if (file_exists($source . '/MD5SUMS')) { $path['src'] = $source . '/MD5SUMS'; $path['dest'] = $destination . '/MD5SUMS'; $path['type'] = 'file'; $copyfiles[] = $path; } // Process each file in the $files array (children of $tagName). /** * @ignore * @var SimpleXMLElement $file */ foreach ($element->children() as $file) { $path['src'] = $source . '/' . $file; $path['dest'] = $destination . '/' . $file; // Is this path a file or folder? $path['type'] = ($file->getName() == 'folder') ? 'folder' : 'file'; /* * Before we can add a file to the copyfiles array we need to ensure * that the folder we are copying our file to exits and if it doesn't, * we need to create it. */ if (basename($path['dest']) != $path['dest']) { $newdir = dirname($path['dest']); if (!Folder::create($newdir)) { $this->log(LogLevel::WARNING, Text::sprintf('JLIB_INSTALLER_ERROR_CREATE_DIRECTORY', $newdir)); return false; } } // Add the file to the copyfiles array $copyfiles[] = $path; } return $this->copyFiles($copyfiles); }
php
public function parseFiles(SimpleXMLElement $element, $cid = 0, $oldFiles = null, $oldMD5 = null) { // Get the array of file nodes to process; we checked whether this had children above. if (!$element || !$element->children()->count()) { // Either the tag does not exist or has no children (hence no files to process) therefore we return zero files processed. return 0; } $copyfiles = array(); /* * Here we set the folder we are going to remove the files from. */ $pathname = 'extension_root'; $destination = $this->getPath($pathname); /* * Here we set the folder we are going to copy the files from. * * Does the element have a folder attribute? * * If so this indicates that the files are in a subdirectory of the source * folder and we should append the folder attribute to the source path when * copying files. */ $folder = (string) $element->attributes()->folder; if ($folder && file_exists($this->getPath('source') . '/' . $folder)) { $source = $this->getPath('source') . '/' . $folder; } else { $source = $this->getPath('source'); } // Work out what files have been deleted if ($oldFiles && ($oldFiles instanceof SimpleXMLElement)) { $oldEntries = $oldFiles->children(); if ($oldEntries->count()) { $deletions = $this->findDeletedFiles($oldEntries, $element->children()); foreach ($deletions['folders'] as $deleted_folder) { Folder::delete($destination . '/' . $deleted_folder); } foreach ($deletions['files'] as $deleted_file) { File::delete($destination . '/' . $deleted_file); } } } $path = array(); // Copy the MD5SUMS file if it exists if (file_exists($source . '/MD5SUMS')) { $path['src'] = $source . '/MD5SUMS'; $path['dest'] = $destination . '/MD5SUMS'; $path['type'] = 'file'; $copyfiles[] = $path; } // Process each file in the $files array (children of $tagName). /** * @ignore * @var SimpleXMLElement $file */ foreach ($element->children() as $file) { $path['src'] = $source . '/' . $file; $path['dest'] = $destination . '/' . $file; // Is this path a file or folder? $path['type'] = ($file->getName() == 'folder') ? 'folder' : 'file'; /* * Before we can add a file to the copyfiles array we need to ensure * that the folder we are copying our file to exits and if it doesn't, * we need to create it. */ if (basename($path['dest']) != $path['dest']) { $newdir = dirname($path['dest']); if (!Folder::create($newdir)) { $this->log(LogLevel::WARNING, Text::sprintf('JLIB_INSTALLER_ERROR_CREATE_DIRECTORY', $newdir)); return false; } } // Add the file to the copyfiles array $copyfiles[] = $path; } return $this->copyFiles($copyfiles); }
[ "public", "function", "parseFiles", "(", "SimpleXMLElement", "$", "element", ",", "$", "cid", "=", "0", ",", "$", "oldFiles", "=", "null", ",", "$", "oldMD5", "=", "null", ")", "{", "// Get the array of file nodes to process; we checked whether this had children above.", "if", "(", "!", "$", "element", "||", "!", "$", "element", "->", "children", "(", ")", "->", "count", "(", ")", ")", "{", "// Either the tag does not exist or has no children (hence no files to process) therefore we return zero files processed.", "return", "0", ";", "}", "$", "copyfiles", "=", "array", "(", ")", ";", "/*\n\t\t * Here we set the folder we are going to remove the files from.\n\t\t */", "$", "pathname", "=", "'extension_root'", ";", "$", "destination", "=", "$", "this", "->", "getPath", "(", "$", "pathname", ")", ";", "/*\n\t\t * Here we set the folder we are going to copy the files from.\n\t\t *\n\t\t * Does the element have a folder attribute?\n\t\t *\n\t\t * If so this indicates that the files are in a subdirectory of the source\n\t\t * folder and we should append the folder attribute to the source path when\n\t\t * copying files.\n\t\t */", "$", "folder", "=", "(", "string", ")", "$", "element", "->", "attributes", "(", ")", "->", "folder", ";", "if", "(", "$", "folder", "&&", "file_exists", "(", "$", "this", "->", "getPath", "(", "'source'", ")", ".", "'/'", ".", "$", "folder", ")", ")", "{", "$", "source", "=", "$", "this", "->", "getPath", "(", "'source'", ")", ".", "'/'", ".", "$", "folder", ";", "}", "else", "{", "$", "source", "=", "$", "this", "->", "getPath", "(", "'source'", ")", ";", "}", "// Work out what files have been deleted", "if", "(", "$", "oldFiles", "&&", "(", "$", "oldFiles", "instanceof", "SimpleXMLElement", ")", ")", "{", "$", "oldEntries", "=", "$", "oldFiles", "->", "children", "(", ")", ";", "if", "(", "$", "oldEntries", "->", "count", "(", ")", ")", "{", "$", "deletions", "=", "$", "this", "->", "findDeletedFiles", "(", "$", "oldEntries", ",", "$", "element", "->", "children", "(", ")", ")", ";", "foreach", "(", "$", "deletions", "[", "'folders'", "]", "as", "$", "deleted_folder", ")", "{", "Folder", "::", "delete", "(", "$", "destination", ".", "'/'", ".", "$", "deleted_folder", ")", ";", "}", "foreach", "(", "$", "deletions", "[", "'files'", "]", "as", "$", "deleted_file", ")", "{", "File", "::", "delete", "(", "$", "destination", ".", "'/'", ".", "$", "deleted_file", ")", ";", "}", "}", "}", "$", "path", "=", "array", "(", ")", ";", "// Copy the MD5SUMS file if it exists", "if", "(", "file_exists", "(", "$", "source", ".", "'/MD5SUMS'", ")", ")", "{", "$", "path", "[", "'src'", "]", "=", "$", "source", ".", "'/MD5SUMS'", ";", "$", "path", "[", "'dest'", "]", "=", "$", "destination", ".", "'/MD5SUMS'", ";", "$", "path", "[", "'type'", "]", "=", "'file'", ";", "$", "copyfiles", "[", "]", "=", "$", "path", ";", "}", "// Process each file in the $files array (children of $tagName).", "/**\n\t\t * @ignore\n\t\t * @var SimpleXMLElement $file\n\t\t */", "foreach", "(", "$", "element", "->", "children", "(", ")", "as", "$", "file", ")", "{", "$", "path", "[", "'src'", "]", "=", "$", "source", ".", "'/'", ".", "$", "file", ";", "$", "path", "[", "'dest'", "]", "=", "$", "destination", ".", "'/'", ".", "$", "file", ";", "// Is this path a file or folder?", "$", "path", "[", "'type'", "]", "=", "(", "$", "file", "->", "getName", "(", ")", "==", "'folder'", ")", "?", "'folder'", ":", "'file'", ";", "/*\n\t\t\t * Before we can add a file to the copyfiles array we need to ensure\n\t\t\t * that the folder we are copying our file to exits and if it doesn't,\n\t\t\t * we need to create it.\n\t\t\t */", "if", "(", "basename", "(", "$", "path", "[", "'dest'", "]", ")", "!=", "$", "path", "[", "'dest'", "]", ")", "{", "$", "newdir", "=", "dirname", "(", "$", "path", "[", "'dest'", "]", ")", ";", "if", "(", "!", "Folder", "::", "create", "(", "$", "newdir", ")", ")", "{", "$", "this", "->", "log", "(", "LogLevel", "::", "WARNING", ",", "Text", "::", "sprintf", "(", "'JLIB_INSTALLER_ERROR_CREATE_DIRECTORY'", ",", "$", "newdir", ")", ")", ";", "return", "false", ";", "}", "}", "// Add the file to the copyfiles array", "$", "copyfiles", "[", "]", "=", "$", "path", ";", "}", "return", "$", "this", "->", "copyFiles", "(", "$", "copyfiles", ")", ";", "}" ]
Method to parse through a files element of the installation manifest and take appropriate action. @param SimpleXMLElement $element The XML node to process @param integer $cid Application ID of application to install to @param array $oldFiles List of old files (SimpleXMLElement's) @param array $oldMD5 List of old MD5 sums (indexed by filename with value as MD5) @return boolean True on success @since 3.1
[ "Method", "to", "parse", "through", "a", "files", "element", "of", "the", "installation", "manifest", "and", "take", "appropriate", "action", "." ]
65771963f23ccabcf1f867eb17c9452299cfe683
https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Installer/Installer.php#L295-L400
19,133
Lansoweb/LosReCaptcha
src/Service/Request/ZendHttpClient.php
ZendHttpClient.send
public function send(Parameters $params) { $this->client->setUri(ReCaptcha::VERIFY_SERVER); $this->client->setRawBody($params->toQueryString()); $this->client->setEncType('application/x-www-form-urlencoded'); $result = $this->client->setMethod('POST')->send(); return $result ? $result->getBody() : null; }
php
public function send(Parameters $params) { $this->client->setUri(ReCaptcha::VERIFY_SERVER); $this->client->setRawBody($params->toQueryString()); $this->client->setEncType('application/x-www-form-urlencoded'); $result = $this->client->setMethod('POST')->send(); return $result ? $result->getBody() : null; }
[ "public", "function", "send", "(", "Parameters", "$", "params", ")", "{", "$", "this", "->", "client", "->", "setUri", "(", "ReCaptcha", "::", "VERIFY_SERVER", ")", ";", "$", "this", "->", "client", "->", "setRawBody", "(", "$", "params", "->", "toQueryString", "(", ")", ")", ";", "$", "this", "->", "client", "->", "setEncType", "(", "'application/x-www-form-urlencoded'", ")", ";", "$", "result", "=", "$", "this", "->", "client", "->", "setMethod", "(", "'POST'", ")", "->", "send", "(", ")", ";", "return", "$", "result", "?", "$", "result", "->", "getBody", "(", ")", ":", "null", ";", "}" ]
Submit ReCaptcha API request, return response body. @param Parameters $params ReCaptcha parameters @return string
[ "Submit", "ReCaptcha", "API", "request", "return", "response", "body", "." ]
8df866995501db087c3850f97fd2b6547632e6ed
https://github.com/Lansoweb/LosReCaptcha/blob/8df866995501db087c3850f97fd2b6547632e6ed/src/Service/Request/ZendHttpClient.php#L33-L40
19,134
wikimedia/CLDRPluralRuleParser
src/Converter/Operator.php
Operator.operate
public function operate( Expression $left, Expression $right ) { $typeSpec = self::$opTypes[$this->name]; $leftType = self::$typeSpecMap[$typeSpec[0]]; $rightType = self::$typeSpecMap[$typeSpec[1]]; $resultType = self::$typeSpecMap[$typeSpec[2]]; $start = min( $this->pos, $left->pos, $right->pos ); $end = max( $this->end, $left->end, $right->end ); $length = $end - $start; $newExpr = new Expression( $this->parser, $resultType, "{$left->rpn} {$right->rpn} {$this->name}", $start, $length ); if ( !$left->isType( $leftType ) ) { $newExpr->error( "invalid type for left operand: expected $leftType, got {$left->type}" ); } if ( !$right->isType( $rightType ) ) { $newExpr->error( "invalid type for right operand: expected $rightType, got {$right->type}" ); } return $newExpr; }
php
public function operate( Expression $left, Expression $right ) { $typeSpec = self::$opTypes[$this->name]; $leftType = self::$typeSpecMap[$typeSpec[0]]; $rightType = self::$typeSpecMap[$typeSpec[1]]; $resultType = self::$typeSpecMap[$typeSpec[2]]; $start = min( $this->pos, $left->pos, $right->pos ); $end = max( $this->end, $left->end, $right->end ); $length = $end - $start; $newExpr = new Expression( $this->parser, $resultType, "{$left->rpn} {$right->rpn} {$this->name}", $start, $length ); if ( !$left->isType( $leftType ) ) { $newExpr->error( "invalid type for left operand: expected $leftType, got {$left->type}" ); } if ( !$right->isType( $rightType ) ) { $newExpr->error( "invalid type for right operand: expected $rightType, got {$right->type}" ); } return $newExpr; }
[ "public", "function", "operate", "(", "Expression", "$", "left", ",", "Expression", "$", "right", ")", "{", "$", "typeSpec", "=", "self", "::", "$", "opTypes", "[", "$", "this", "->", "name", "]", ";", "$", "leftType", "=", "self", "::", "$", "typeSpecMap", "[", "$", "typeSpec", "[", "0", "]", "]", ";", "$", "rightType", "=", "self", "::", "$", "typeSpecMap", "[", "$", "typeSpec", "[", "1", "]", "]", ";", "$", "resultType", "=", "self", "::", "$", "typeSpecMap", "[", "$", "typeSpec", "[", "2", "]", "]", ";", "$", "start", "=", "min", "(", "$", "this", "->", "pos", ",", "$", "left", "->", "pos", ",", "$", "right", "->", "pos", ")", ";", "$", "end", "=", "max", "(", "$", "this", "->", "end", ",", "$", "left", "->", "end", ",", "$", "right", "->", "end", ")", ";", "$", "length", "=", "$", "end", "-", "$", "start", ";", "$", "newExpr", "=", "new", "Expression", "(", "$", "this", "->", "parser", ",", "$", "resultType", ",", "\"{$left->rpn} {$right->rpn} {$this->name}\"", ",", "$", "start", ",", "$", "length", ")", ";", "if", "(", "!", "$", "left", "->", "isType", "(", "$", "leftType", ")", ")", "{", "$", "newExpr", "->", "error", "(", "\"invalid type for left operand: expected $leftType, got {$left->type}\"", ")", ";", "}", "if", "(", "!", "$", "right", "->", "isType", "(", "$", "rightType", ")", ")", "{", "$", "newExpr", "->", "error", "(", "\"invalid type for right operand: expected $rightType, got {$right->type}\"", ")", ";", "}", "return", "$", "newExpr", ";", "}" ]
Compute the operation @param Expression $left The left part of the expression @param Expression $right The right part of the expression @return Expression The result of the operation
[ "Compute", "the", "operation" ]
4c5d71a3fd62a75871da8562310ca2258647ee6d
https://github.com/wikimedia/CLDRPluralRuleParser/blob/4c5d71a3fd62a75871da8562310ca2258647ee6d/src/Converter/Operator.php#L89-L113
19,135
steeffeen/FancyManiaLinks
FML/Script/Features/Paging.php
Paging.addPageControl
public function addPageControl(Control $pageControl, $pageNumber = null) { if ($pageNumber === null) { $pageNumber = count($this->pages) + 1; } $page = new PagingPage($pageControl, $pageNumber); return $this->addPage($page); }
php
public function addPageControl(Control $pageControl, $pageNumber = null) { if ($pageNumber === null) { $pageNumber = count($this->pages) + 1; } $page = new PagingPage($pageControl, $pageNumber); return $this->addPage($page); }
[ "public", "function", "addPageControl", "(", "Control", "$", "pageControl", ",", "$", "pageNumber", "=", "null", ")", "{", "if", "(", "$", "pageNumber", "===", "null", ")", "{", "$", "pageNumber", "=", "count", "(", "$", "this", "->", "pages", ")", "+", "1", ";", "}", "$", "page", "=", "new", "PagingPage", "(", "$", "pageControl", ",", "$", "pageNumber", ")", ";", "return", "$", "this", "->", "addPage", "(", "$", "page", ")", ";", "}" ]
Add a new Page Control @api @param Control $pageControl Page Control @param string $pageNumber (optional) Page number @return static
[ "Add", "a", "new", "Page", "Control" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Paging.php#L133-L140
19,136
steeffeen/FancyManiaLinks
FML/Script/Features/Paging.php
Paging.addPage
public function addPage(PagingPage $page) { if (!in_array($page, $this->pages, true)) { array_push($this->pages, $page); } return $this; }
php
public function addPage(PagingPage $page) { if (!in_array($page, $this->pages, true)) { array_push($this->pages, $page); } return $this; }
[ "public", "function", "addPage", "(", "PagingPage", "$", "page", ")", "{", "if", "(", "!", "in_array", "(", "$", "page", ",", "$", "this", "->", "pages", ",", "true", ")", ")", "{", "array_push", "(", "$", "this", "->", "pages", ",", "$", "page", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add a new Page @api @param PagingPage $page Page @return static
[ "Add", "a", "new", "Page" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Paging.php#L149-L155
19,137
steeffeen/FancyManiaLinks
FML/Script/Features/Paging.php
Paging.setPages
public function setPages(array $pages) { $this->pages = array(); foreach ($pages as $page) { $this->addPage($page); } return $this; }
php
public function setPages(array $pages) { $this->pages = array(); foreach ($pages as $page) { $this->addPage($page); } return $this; }
[ "public", "function", "setPages", "(", "array", "$", "pages", ")", "{", "$", "this", "->", "pages", "=", "array", "(", ")", ";", "foreach", "(", "$", "pages", "as", "$", "page", ")", "{", "$", "this", "->", "addPage", "(", "$", "page", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add new Pages @api @param PagingPage[] $pages Pages @return static
[ "Add", "new", "Pages" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Paging.php#L164-L171
19,138
steeffeen/FancyManiaLinks
FML/Script/Features/Paging.php
Paging.addButtonControl
public function addButtonControl(Control $buttonControl, $browseAction = null) { if ($browseAction === null) { $buttonCount = count($this->buttons); if ($buttonCount % 2 === 0) { $browseAction = $buttonCount / 2 + 1; } else { $browseAction = $buttonCount / -2 - 1; } } $button = new PagingButton($buttonControl, $browseAction); return $this->addButton($button); }
php
public function addButtonControl(Control $buttonControl, $browseAction = null) { if ($browseAction === null) { $buttonCount = count($this->buttons); if ($buttonCount % 2 === 0) { $browseAction = $buttonCount / 2 + 1; } else { $browseAction = $buttonCount / -2 - 1; } } $button = new PagingButton($buttonControl, $browseAction); return $this->addButton($button); }
[ "public", "function", "addButtonControl", "(", "Control", "$", "buttonControl", ",", "$", "browseAction", "=", "null", ")", "{", "if", "(", "$", "browseAction", "===", "null", ")", "{", "$", "buttonCount", "=", "count", "(", "$", "this", "->", "buttons", ")", ";", "if", "(", "$", "buttonCount", "%", "2", "===", "0", ")", "{", "$", "browseAction", "=", "$", "buttonCount", "/", "2", "+", "1", ";", "}", "else", "{", "$", "browseAction", "=", "$", "buttonCount", "/", "-", "2", "-", "1", ";", "}", "}", "$", "button", "=", "new", "PagingButton", "(", "$", "buttonControl", ",", "$", "browseAction", ")", ";", "return", "$", "this", "->", "addButton", "(", "$", "button", ")", ";", "}" ]
Add a new Button Control to browse through the Pages @api @param Control $buttonControl Button used for browsing @param int $browseAction (optional) Number of browsed Pages per click @return static
[ "Add", "a", "new", "Button", "Control", "to", "browse", "through", "the", "Pages" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Paging.php#L192-L204
19,139
steeffeen/FancyManiaLinks
FML/Script/Features/Paging.php
Paging.addButton
public function addButton(PagingButton $button) { if (!in_array($button, $this->buttons, true)) { array_push($this->buttons, $button); } return $this; }
php
public function addButton(PagingButton $button) { if (!in_array($button, $this->buttons, true)) { array_push($this->buttons, $button); } return $this; }
[ "public", "function", "addButton", "(", "PagingButton", "$", "button", ")", "{", "if", "(", "!", "in_array", "(", "$", "button", ",", "$", "this", "->", "buttons", ",", "true", ")", ")", "{", "array_push", "(", "$", "this", "->", "buttons", ",", "$", "button", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add a new Button to browse through Pages @api @param PagingButton $button Paging Button @return static
[ "Add", "a", "new", "Button", "to", "browse", "through", "Pages" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Paging.php#L213-L219
19,140
steeffeen/FancyManiaLinks
FML/Script/Features/Paging.php
Paging.setButtons
public function setButtons(array $buttons) { $this->buttons = array(); foreach ($buttons as $button) { $this->addButton($button); } return $this; }
php
public function setButtons(array $buttons) { $this->buttons = array(); foreach ($buttons as $button) { $this->addButton($button); } return $this; }
[ "public", "function", "setButtons", "(", "array", "$", "buttons", ")", "{", "$", "this", "->", "buttons", "=", "array", "(", ")", ";", "foreach", "(", "$", "buttons", "as", "$", "button", ")", "{", "$", "this", "->", "addButton", "(", "$", "button", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the Paging Buttons @api @param PagingButton[] $buttons Paging Buttons @return static
[ "Set", "the", "Paging", "Buttons" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Paging.php#L228-L235
19,141
steeffeen/FancyManiaLinks
FML/Script/Features/Paging.php
Paging.getMinPage
protected function getMinPage() { $minPageNumber = null; $minPage = null; foreach ($this->pages as $page) { $pageNumber = $page->getPageNumber(); if ($minPageNumber === null || $pageNumber < $minPageNumber) { $minPageNumber = $pageNumber; $minPage = $page; } } return $minPage; }
php
protected function getMinPage() { $minPageNumber = null; $minPage = null; foreach ($this->pages as $page) { $pageNumber = $page->getPageNumber(); if ($minPageNumber === null || $pageNumber < $minPageNumber) { $minPageNumber = $pageNumber; $minPage = $page; } } return $minPage; }
[ "protected", "function", "getMinPage", "(", ")", "{", "$", "minPageNumber", "=", "null", ";", "$", "minPage", "=", "null", ";", "foreach", "(", "$", "this", "->", "pages", "as", "$", "page", ")", "{", "$", "pageNumber", "=", "$", "page", "->", "getPageNumber", "(", ")", ";", "if", "(", "$", "minPageNumber", "===", "null", "||", "$", "pageNumber", "<", "$", "minPageNumber", ")", "{", "$", "minPageNumber", "=", "$", "pageNumber", ";", "$", "minPage", "=", "$", "page", ";", "}", "}", "return", "$", "minPage", ";", "}" ]
Get the minimum Page @return PagingPage
[ "Get", "the", "minimum", "Page" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Paging.php#L466-L478
19,142
steeffeen/FancyManiaLinks
FML/Script/Features/Paging.php
Paging.getMaxPage
protected function getMaxPage() { $maxPageNumber = null; $maxPage = null; foreach ($this->pages as $page) { $pageNumber = $page->getPageNumber(); if ($maxPageNumber === null || $pageNumber > $maxPageNumber) { $maxPageNumber = $pageNumber; $maxPage = $page; } } return $maxPage; }
php
protected function getMaxPage() { $maxPageNumber = null; $maxPage = null; foreach ($this->pages as $page) { $pageNumber = $page->getPageNumber(); if ($maxPageNumber === null || $pageNumber > $maxPageNumber) { $maxPageNumber = $pageNumber; $maxPage = $page; } } return $maxPage; }
[ "protected", "function", "getMaxPage", "(", ")", "{", "$", "maxPageNumber", "=", "null", ";", "$", "maxPage", "=", "null", ";", "foreach", "(", "$", "this", "->", "pages", "as", "$", "page", ")", "{", "$", "pageNumber", "=", "$", "page", "->", "getPageNumber", "(", ")", ";", "if", "(", "$", "maxPageNumber", "===", "null", "||", "$", "pageNumber", ">", "$", "maxPageNumber", ")", "{", "$", "maxPageNumber", "=", "$", "pageNumber", ";", "$", "maxPage", "=", "$", "page", ";", "}", "}", "return", "$", "maxPage", ";", "}" ]
Get the maximum Page @return PagingPage
[ "Get", "the", "maximum", "Page" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Paging.php#L485-L497
19,143
steeffeen/FancyManiaLinks
FML/Script/Features/Paging.php
Paging.getPagesArrayText
protected function getPagesArrayText() { if (empty($this->pages)) { return Builder::getArray(array(0 => ''), true); } $pages = array(); foreach ($this->pages as $page) { $pages[$page->getPageNumber()] = $page->getControl() ->getId(); } return Builder::getArray($pages, true); }
php
protected function getPagesArrayText() { if (empty($this->pages)) { return Builder::getArray(array(0 => ''), true); } $pages = array(); foreach ($this->pages as $page) { $pages[$page->getPageNumber()] = $page->getControl() ->getId(); } return Builder::getArray($pages, true); }
[ "protected", "function", "getPagesArrayText", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "pages", ")", ")", "{", "return", "Builder", "::", "getArray", "(", "array", "(", "0", "=>", "''", ")", ",", "true", ")", ";", "}", "$", "pages", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "pages", "as", "$", "page", ")", "{", "$", "pages", "[", "$", "page", "->", "getPageNumber", "(", ")", "]", "=", "$", "page", "->", "getControl", "(", ")", "->", "getId", "(", ")", ";", "}", "return", "Builder", "::", "getArray", "(", "$", "pages", ",", "true", ")", ";", "}" ]
Build the array text for the Pages @return string
[ "Build", "the", "array", "text", "for", "the", "Pages" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Paging.php#L504-L515
19,144
steeffeen/FancyManiaLinks
FML/Script/Features/Paging.php
Paging.getPageButtonsArrayText
protected function getPageButtonsArrayText() { if (empty($this->buttons)) { return Builder::getArray(array('' => 0), true); } $pageButtons = array(); foreach ($this->buttons as $pageButton) { $pageButtons[$pageButton->getControl() ->getId()] = $pageButton->getPagingCount(); } return Builder::getArray($pageButtons, true); }
php
protected function getPageButtonsArrayText() { if (empty($this->buttons)) { return Builder::getArray(array('' => 0), true); } $pageButtons = array(); foreach ($this->buttons as $pageButton) { $pageButtons[$pageButton->getControl() ->getId()] = $pageButton->getPagingCount(); } return Builder::getArray($pageButtons, true); }
[ "protected", "function", "getPageButtonsArrayText", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "buttons", ")", ")", "{", "return", "Builder", "::", "getArray", "(", "array", "(", "''", "=>", "0", ")", ",", "true", ")", ";", "}", "$", "pageButtons", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "buttons", "as", "$", "pageButton", ")", "{", "$", "pageButtons", "[", "$", "pageButton", "->", "getControl", "(", ")", "->", "getId", "(", ")", "]", "=", "$", "pageButton", "->", "getPagingCount", "(", ")", ";", "}", "return", "Builder", "::", "getArray", "(", "$", "pageButtons", ",", "true", ")", ";", "}" ]
Build the array text for the Page Buttons @return string
[ "Build", "the", "array", "text", "for", "the", "Page", "Buttons" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Paging.php#L522-L533
19,145
guillermoandrae/php-repository
src/Repositories/RepositoryFactory.php
RepositoryFactory.factory
public static function factory(string $name, $options = null): RepositoryInterface { try { $className = sprintf( '%s\%sRepository', self::getNamespace(), ucfirst(strtolower($name)) ); $reflectionClass = new \ReflectionClass($className); if (is_null($options)) { return $reflectionClass->newInstance(); } return $reflectionClass->newInstance($options); } catch (\ReflectionException $ex) { throw new InvalidRepositoryException( sprintf('The %s repository does not exist.', $name) ); } }
php
public static function factory(string $name, $options = null): RepositoryInterface { try { $className = sprintf( '%s\%sRepository', self::getNamespace(), ucfirst(strtolower($name)) ); $reflectionClass = new \ReflectionClass($className); if (is_null($options)) { return $reflectionClass->newInstance(); } return $reflectionClass->newInstance($options); } catch (\ReflectionException $ex) { throw new InvalidRepositoryException( sprintf('The %s repository does not exist.', $name) ); } }
[ "public", "static", "function", "factory", "(", "string", "$", "name", ",", "$", "options", "=", "null", ")", ":", "RepositoryInterface", "{", "try", "{", "$", "className", "=", "sprintf", "(", "'%s\\%sRepository'", ",", "self", "::", "getNamespace", "(", ")", ",", "ucfirst", "(", "strtolower", "(", "$", "name", ")", ")", ")", ";", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "className", ")", ";", "if", "(", "is_null", "(", "$", "options", ")", ")", "{", "return", "$", "reflectionClass", "->", "newInstance", "(", ")", ";", "}", "return", "$", "reflectionClass", "->", "newInstance", "(", "$", "options", ")", ";", "}", "catch", "(", "\\", "ReflectionException", "$", "ex", ")", "{", "throw", "new", "InvalidRepositoryException", "(", "sprintf", "(", "'The %s repository does not exist.'", ",", "$", "name", ")", ")", ";", "}", "}" ]
Returns the desired repository using the provided data. @param string $name The name of the desired repository. @param mixed|null $options The data needed to build the repository. @return RepositoryInterface @throws InvalidRepositoryException Thrown when an invalid repository is requested.
[ "Returns", "the", "desired", "repository", "using", "the", "provided", "data", "." ]
8cf9c50c7c7f4c08190b3232df77e21e706e7a2a
https://github.com/guillermoandrae/php-repository/blob/8cf9c50c7c7f4c08190b3232df77e21e706e7a2a/src/Repositories/RepositoryFactory.php#L53-L71
19,146
xinix-technology/norm
src/Norm/Type/Object.php
Object.toObject
public function toObject() { $obj = new stdClass(); if (! empty($this->attributes)) { foreach ($this->attributes as $key => $value) { $obj->$key = $value; } } return $obj; }
php
public function toObject() { $obj = new stdClass(); if (! empty($this->attributes)) { foreach ($this->attributes as $key => $value) { $obj->$key = $value; } } return $obj; }
[ "public", "function", "toObject", "(", ")", "{", "$", "obj", "=", "new", "stdClass", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "attributes", ")", ")", "{", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "obj", "->", "$", "key", "=", "$", "value", ";", "}", "}", "return", "$", "obj", ";", "}" ]
Convert this class to a standard object. @return \stdClass
[ "Convert", "this", "class", "to", "a", "standard", "object", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Type/Object.php#L20-L31
19,147
davidgorges/color-contrast-php
src/ContrastAlgorithm/LuminosityContrast.php
LuminosityContrast.calculate
public function calculate(ColorJizz $foreground, ColorJizz $background) { $fgLuma = $this->relativeLuminosity($foreground->toRGB()); $bgLuma = $this->relativeLuminosity($background->toRGB()); if ($fgLuma > $bgLuma) { return ($fgLuma + 0.05) / ($bgLuma + 0.05); } else { return ($bgLuma + 0.05) / ($fgLuma + 0.05); } }
php
public function calculate(ColorJizz $foreground, ColorJizz $background) { $fgLuma = $this->relativeLuminosity($foreground->toRGB()); $bgLuma = $this->relativeLuminosity($background->toRGB()); if ($fgLuma > $bgLuma) { return ($fgLuma + 0.05) / ($bgLuma + 0.05); } else { return ($bgLuma + 0.05) / ($fgLuma + 0.05); } }
[ "public", "function", "calculate", "(", "ColorJizz", "$", "foreground", ",", "ColorJizz", "$", "background", ")", "{", "$", "fgLuma", "=", "$", "this", "->", "relativeLuminosity", "(", "$", "foreground", "->", "toRGB", "(", ")", ")", ";", "$", "bgLuma", "=", "$", "this", "->", "relativeLuminosity", "(", "$", "background", "->", "toRGB", "(", ")", ")", ";", "if", "(", "$", "fgLuma", ">", "$", "bgLuma", ")", "{", "return", "(", "$", "fgLuma", "+", "0.05", ")", "/", "(", "$", "bgLuma", "+", "0.05", ")", ";", "}", "else", "{", "return", "(", "$", "bgLuma", "+", "0.05", ")", "/", "(", "$", "fgLuma", "+", "0.05", ")", ";", "}", "}" ]
returns the contrast ratio between foreground and background color. @param ColorJizz $foreground @param ColorJizz $background @return float
[ "returns", "the", "contrast", "ratio", "between", "foreground", "and", "background", "color", "." ]
11edc6e04ce73d8d9b0bffeda1586f2c2fa22e71
https://github.com/davidgorges/color-contrast-php/blob/11edc6e04ce73d8d9b0bffeda1586f2c2fa22e71/src/ContrastAlgorithm/LuminosityContrast.php#L24-L34
19,148
stanislav-web/phalcon-ulogin
src/ULogin/Parser.php
Parser.arrayResolve
public static function arrayResolve(array $data) { $array = []; foreach ($data as $provider => $bool) { if ($bool === true) { $array['required'][] = $provider; } else { $array['hidden'][] = $provider; } } return $array; }
php
public static function arrayResolve(array $data) { $array = []; foreach ($data as $provider => $bool) { if ($bool === true) { $array['required'][] = $provider; } else { $array['hidden'][] = $provider; } } return $array; }
[ "public", "static", "function", "arrayResolve", "(", "array", "$", "data", ")", "{", "$", "array", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "provider", "=>", "$", "bool", ")", "{", "if", "(", "$", "bool", "===", "true", ")", "{", "$", "array", "[", "'required'", "]", "[", "]", "=", "$", "provider", ";", "}", "else", "{", "$", "array", "[", "'hidden'", "]", "[", "]", "=", "$", "provider", ";", "}", "}", "return", "$", "array", ";", "}" ]
Resolve array data as providers @param array $data @access static @return array
[ "Resolve", "array", "data", "as", "providers" ]
0cea8510a244ebb9b1333085b325a283e4fb9f2f
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Parser.php#L44-L64
19,149
stanislav-web/phalcon-ulogin
src/ULogin/Parser.php
Parser.isDelim
private static function isDelim($provider, $delimiter = '=') { if (mb_strpos($provider, $delimiter) !== false) { $res = explode('=', $provider); return $res; } return false; }
php
private static function isDelim($provider, $delimiter = '=') { if (mb_strpos($provider, $delimiter) !== false) { $res = explode('=', $provider); return $res; } return false; }
[ "private", "static", "function", "isDelim", "(", "$", "provider", ",", "$", "delimiter", "=", "'='", ")", "{", "if", "(", "mb_strpos", "(", "$", "provider", ",", "$", "delimiter", ")", "!==", "false", ")", "{", "$", "res", "=", "explode", "(", "'='", ",", "$", "provider", ")", ";", "return", "$", "res", ";", "}", "return", "false", ";", "}" ]
Check if data has delimiter @param string $provider @param string $delimiter @access static @return array|false
[ "Check", "if", "data", "has", "delimiter" ]
0cea8510a244ebb9b1333085b325a283e4fb9f2f
https://github.com/stanislav-web/phalcon-ulogin/blob/0cea8510a244ebb9b1333085b325a283e4fb9f2f/src/ULogin/Parser.php#L120-L131
19,150
yuncms/framework
src/helpers/Html.php
Html.encodeParams
public static function encodeParams(string $html, array $variables = []): string { // Normalize the param keys $normalizedVariables = []; if (is_array($variables)) { foreach ($variables as $key => $value) { $key = '{' . trim($key, '{}') . '}'; $normalizedVariables[$key] = static::encode($value); } $html = strtr($html, $normalizedVariables); } return $html; }
php
public static function encodeParams(string $html, array $variables = []): string { // Normalize the param keys $normalizedVariables = []; if (is_array($variables)) { foreach ($variables as $key => $value) { $key = '{' . trim($key, '{}') . '}'; $normalizedVariables[$key] = static::encode($value); } $html = strtr($html, $normalizedVariables); } return $html; }
[ "public", "static", "function", "encodeParams", "(", "string", "$", "html", ",", "array", "$", "variables", "=", "[", "]", ")", ":", "string", "{", "// Normalize the param keys", "$", "normalizedVariables", "=", "[", "]", ";", "if", "(", "is_array", "(", "$", "variables", ")", ")", "{", "foreach", "(", "$", "variables", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "'{'", ".", "trim", "(", "$", "key", ",", "'{}'", ")", ".", "'}'", ";", "$", "normalizedVariables", "[", "$", "key", "]", "=", "static", "::", "encode", "(", "$", "value", ")", ";", "}", "$", "html", "=", "strtr", "(", "$", "html", ",", "$", "normalizedVariables", ")", ";", "}", "return", "$", "html", ";", "}" ]
Will take an HTML string and an associative array of key=>value pairs, HTML encode the values and swap them back into the original string using the keys as tokens. @param string $html The HTML string. @param array $variables An associative array of key => value pairs to be applied to the HTML string using `strtr`. @return string The HTML string with the encoded variable values swapped in.
[ "Will", "take", "an", "HTML", "string", "and", "an", "associative", "array", "of", "key", "=", ">", "value", "pairs", "HTML", "encode", "the", "values", "and", "swap", "them", "back", "into", "the", "original", "string", "using", "the", "keys", "as", "tokens", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/Html.php#L82-L94
19,151
factorio-item-browser/export-data
src/Entity/Icon/Color.php
Color.setRed
public function setRed(float $red, float $scale = 1.) { $this->red = $this->setComponent($red, $scale); return $this; }
php
public function setRed(float $red, float $scale = 1.) { $this->red = $this->setComponent($red, $scale); return $this; }
[ "public", "function", "setRed", "(", "float", "$", "red", ",", "float", "$", "scale", "=", "1.", ")", "{", "$", "this", "->", "red", "=", "$", "this", "->", "setComponent", "(", "$", "red", ",", "$", "scale", ")", ";", "return", "$", "this", ";", "}" ]
Sets the red component of the color. @param float $red @param float $scale @return $this
[ "Sets", "the", "red", "component", "of", "the", "color", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon/Color.php#L50-L54
19,152
factorio-item-browser/export-data
src/Entity/Icon/Color.php
Color.setGreen
public function setGreen(float $green, float $scale = 1.) { $this->green = $this->setComponent($green, $scale); return $this; }
php
public function setGreen(float $green, float $scale = 1.) { $this->green = $this->setComponent($green, $scale); return $this; }
[ "public", "function", "setGreen", "(", "float", "$", "green", ",", "float", "$", "scale", "=", "1.", ")", "{", "$", "this", "->", "green", "=", "$", "this", "->", "setComponent", "(", "$", "green", ",", "$", "scale", ")", ";", "return", "$", "this", ";", "}" ]
Sets the green component of the color. @param float $green @param float $scale @return $this
[ "Sets", "the", "green", "component", "of", "the", "color", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon/Color.php#L72-L76
19,153
factorio-item-browser/export-data
src/Entity/Icon/Color.php
Color.setBlue
public function setBlue(float $blue, float $scale = 1.) { $this->blue = $this->setComponent($blue, $scale); return $this; }
php
public function setBlue(float $blue, float $scale = 1.) { $this->blue = $this->setComponent($blue, $scale); return $this; }
[ "public", "function", "setBlue", "(", "float", "$", "blue", ",", "float", "$", "scale", "=", "1.", ")", "{", "$", "this", "->", "blue", "=", "$", "this", "->", "setComponent", "(", "$", "blue", ",", "$", "scale", ")", ";", "return", "$", "this", ";", "}" ]
Sets the blue component of the color. @param float $blue @param float $scale @return $this
[ "Sets", "the", "blue", "component", "of", "the", "color", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon/Color.php#L94-L98
19,154
factorio-item-browser/export-data
src/Entity/Icon/Color.php
Color.setAlpha
public function setAlpha(float $alpha, float $scale = 1.) { $this->alpha = $this->setComponent($alpha, $scale); return $this; }
php
public function setAlpha(float $alpha, float $scale = 1.) { $this->alpha = $this->setComponent($alpha, $scale); return $this; }
[ "public", "function", "setAlpha", "(", "float", "$", "alpha", ",", "float", "$", "scale", "=", "1.", ")", "{", "$", "this", "->", "alpha", "=", "$", "this", "->", "setComponent", "(", "$", "alpha", ",", "$", "scale", ")", ";", "return", "$", "this", ";", "}" ]
Sets the alpha component of the color. @param float $alpha @param float $scale @return $this
[ "Sets", "the", "alpha", "component", "of", "the", "color", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon/Color.php#L116-L120
19,155
factorio-item-browser/export-data
src/Entity/Icon/Color.php
Color.setComponent
protected function setComponent(float $value, float $scale): float { return ($scale < 0) ? (1 - $value / -$scale) : ($value / $scale); }
php
protected function setComponent(float $value, float $scale): float { return ($scale < 0) ? (1 - $value / -$scale) : ($value / $scale); }
[ "protected", "function", "setComponent", "(", "float", "$", "value", ",", "float", "$", "scale", ")", ":", "float", "{", "return", "(", "$", "scale", "<", "0", ")", "?", "(", "1", "-", "$", "value", "/", "-", "$", "scale", ")", ":", "(", "$", "value", "/", "$", "scale", ")", ";", "}" ]
Calculates the value to set a component. @param float $value @param float $scale @return float
[ "Calculates", "the", "value", "to", "set", "a", "component", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon/Color.php#L138-L141
19,156
factorio-item-browser/export-data
src/Entity/Icon/Color.php
Color.getComponent
protected function getComponent(float $value, float $scale): float { return ($scale < 0) ? ((1 - $value) * -$scale) : ($value * $scale); }
php
protected function getComponent(float $value, float $scale): float { return ($scale < 0) ? ((1 - $value) * -$scale) : ($value * $scale); }
[ "protected", "function", "getComponent", "(", "float", "$", "value", ",", "float", "$", "scale", ")", ":", "float", "{", "return", "(", "$", "scale", "<", "0", ")", "?", "(", "(", "1", "-", "$", "value", ")", "*", "-", "$", "scale", ")", ":", "(", "$", "value", "*", "$", "scale", ")", ";", "}" ]
Calculates the value to get a component. @param float $value @param float $scale @return float
[ "Calculates", "the", "value", "to", "get", "a", "component", "." ]
1413b2eed0fbfed0521457ac7ef0d668ac30c212
https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon/Color.php#L149-L152
19,157
aedart/laravel-helpers
src/Traits/Notifications/NotificationDispatcherTrait.php
NotificationDispatcherTrait.getNotificationDispatcher
public function getNotificationDispatcher(): ?Dispatcher { if (!$this->hasNotificationDispatcher()) { $this->setNotificationDispatcher($this->getDefaultNotificationDispatcher()); } return $this->notificationDispatcher; }
php
public function getNotificationDispatcher(): ?Dispatcher { if (!$this->hasNotificationDispatcher()) { $this->setNotificationDispatcher($this->getDefaultNotificationDispatcher()); } return $this->notificationDispatcher; }
[ "public", "function", "getNotificationDispatcher", "(", ")", ":", "?", "Dispatcher", "{", "if", "(", "!", "$", "this", "->", "hasNotificationDispatcher", "(", ")", ")", "{", "$", "this", "->", "setNotificationDispatcher", "(", "$", "this", "->", "getDefaultNotificationDispatcher", "(", ")", ")", ";", "}", "return", "$", "this", "->", "notificationDispatcher", ";", "}" ]
Get notification dispatcher If no notification dispatcher has been set, this method will set and return a default notification dispatcher, if any such value is available @see getDefaultNotificationDispatcher() @return Dispatcher|null notification dispatcher or null if none notification dispatcher has been set
[ "Get", "notification", "dispatcher" ]
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Notifications/NotificationDispatcherTrait.php#L53-L59
19,158
ClanCats/Core
src/classes/CCUrl.php
CCUrl._init
public static function _init() { static::$path_offset = ClanCats::$config->get( 'url.path', '/' ); if ( empty( static::$path_offset ) ) { static::$path_offset = '/'; } if ( substr( static::$path_offset, -1 ) != '/' ) { static::$path_offset .= '/'; } // register the default parameter providers static::$parameter_provider = array( // Adds a session fingerprint to the parameter list 'fingerprint' => function() { return array( ClanCats::$config->get( 'session.default_fingerprint_parameter' ) => fingerprint() ); }, // Adds the next redirect uri to redirect back on request 'back' => function() { $params = CCIn::$_instance->GET; unset( $params['next'] ); return array( 'next' => CCUrl::current( $params ) ); }, ); }
php
public static function _init() { static::$path_offset = ClanCats::$config->get( 'url.path', '/' ); if ( empty( static::$path_offset ) ) { static::$path_offset = '/'; } if ( substr( static::$path_offset, -1 ) != '/' ) { static::$path_offset .= '/'; } // register the default parameter providers static::$parameter_provider = array( // Adds a session fingerprint to the parameter list 'fingerprint' => function() { return array( ClanCats::$config->get( 'session.default_fingerprint_parameter' ) => fingerprint() ); }, // Adds the next redirect uri to redirect back on request 'back' => function() { $params = CCIn::$_instance->GET; unset( $params['next'] ); return array( 'next' => CCUrl::current( $params ) ); }, ); }
[ "public", "static", "function", "_init", "(", ")", "{", "static", "::", "$", "path_offset", "=", "ClanCats", "::", "$", "config", "->", "get", "(", "'url.path'", ",", "'/'", ")", ";", "if", "(", "empty", "(", "static", "::", "$", "path_offset", ")", ")", "{", "static", "::", "$", "path_offset", "=", "'/'", ";", "}", "if", "(", "substr", "(", "static", "::", "$", "path_offset", ",", "-", "1", ")", "!=", "'/'", ")", "{", "static", "::", "$", "path_offset", ".=", "'/'", ";", "}", "// register the default parameter providers", "static", "::", "$", "parameter_provider", "=", "array", "(", "// Adds a session fingerprint to the parameter list", "'fingerprint'", "=>", "function", "(", ")", "{", "return", "array", "(", "ClanCats", "::", "$", "config", "->", "get", "(", "'session.default_fingerprint_parameter'", ")", "=>", "fingerprint", "(", ")", ")", ";", "}", ",", "// Adds the next redirect uri to redirect back on request", "'back'", "=>", "function", "(", ")", "{", "$", "params", "=", "CCIn", "::", "$", "_instance", "->", "GET", ";", "unset", "(", "$", "params", "[", "'next'", "]", ")", ";", "return", "array", "(", "'next'", "=>", "CCUrl", "::", "current", "(", "$", "params", ")", ")", ";", "}", ",", ")", ";", "}" ]
static CCUrl initialisation
[ "static", "CCUrl", "initialisation" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCUrl.php#L32-L62
19,159
ClanCats/Core
src/classes/CCUrl.php
CCUrl.to
public static function to( $uri = '', $params = array(), $retain = false ) { // To avoid // urls we check for a single slash. if ( $uri === '/' ) { $uri = ''; } // When the uri starts with an @ sign we handle the uri as route alias. if ( substr( $uri, 0, 1 ) == '@' ) { return static::alias( substr( $uri, 1 ), $params, $retain ); } // Are there already parameters in the uri? Parse them // and merge them with current argument parameters if ( strpos( $uri, '?' ) !== false ) { $parts = explode( '?', $uri ); $uri = $parts[0]; if ( isset( $parts[1] ) ) { parse_str( $parts[1], $old_params ); $params = array_merge( $old_params, $params ); } } // When the uri contains a protocoll or starts with a slash we assume // a full url is given and we don't have to add a path offest. if ( strpos( $uri, '://' ) === false && substr( $uri, 0, 1 ) !== '/' ) { $uri = static::$path_offset.$uri; } // Try to replace parameters in the uri and remove them from // the array so we can append them as get parameters foreach( $params as $key => $value ) { // replace the parameter provider if ( is_numeric( $key ) && is_string($value) && $value[0] === ':' ) { $param_provider_key = substr( $value, 1 ); // remove the parameter provider from the parameter list unset( $params[$key] ); if ( array_key_exists( $param_provider_key, static::$parameter_provider ) ) { $params = $params + call_user_func( static::$parameter_provider[$param_provider_key] ); } } // replace the parameters if ( !is_array($value)) { $uri = str_replace( ':'.$key, $value, $uri, $count ); if ( $count > 0 ) { unset( $params[$key] ); } } } // Should we keep the get parameters? If retain is enabled // we merge the get parameter array with argument parameters if ( $retain ) { $params = array_merge( CCIn::$_instance->GET, $params ); } // When we still got parameters add them to the url if ( !empty( $params ) ) { $uri .= '?'.http_build_query( $params ); } return $uri; }
php
public static function to( $uri = '', $params = array(), $retain = false ) { // To avoid // urls we check for a single slash. if ( $uri === '/' ) { $uri = ''; } // When the uri starts with an @ sign we handle the uri as route alias. if ( substr( $uri, 0, 1 ) == '@' ) { return static::alias( substr( $uri, 1 ), $params, $retain ); } // Are there already parameters in the uri? Parse them // and merge them with current argument parameters if ( strpos( $uri, '?' ) !== false ) { $parts = explode( '?', $uri ); $uri = $parts[0]; if ( isset( $parts[1] ) ) { parse_str( $parts[1], $old_params ); $params = array_merge( $old_params, $params ); } } // When the uri contains a protocoll or starts with a slash we assume // a full url is given and we don't have to add a path offest. if ( strpos( $uri, '://' ) === false && substr( $uri, 0, 1 ) !== '/' ) { $uri = static::$path_offset.$uri; } // Try to replace parameters in the uri and remove them from // the array so we can append them as get parameters foreach( $params as $key => $value ) { // replace the parameter provider if ( is_numeric( $key ) && is_string($value) && $value[0] === ':' ) { $param_provider_key = substr( $value, 1 ); // remove the parameter provider from the parameter list unset( $params[$key] ); if ( array_key_exists( $param_provider_key, static::$parameter_provider ) ) { $params = $params + call_user_func( static::$parameter_provider[$param_provider_key] ); } } // replace the parameters if ( !is_array($value)) { $uri = str_replace( ':'.$key, $value, $uri, $count ); if ( $count > 0 ) { unset( $params[$key] ); } } } // Should we keep the get parameters? If retain is enabled // we merge the get parameter array with argument parameters if ( $retain ) { $params = array_merge( CCIn::$_instance->GET, $params ); } // When we still got parameters add them to the url if ( !empty( $params ) ) { $uri .= '?'.http_build_query( $params ); } return $uri; }
[ "public", "static", "function", "to", "(", "$", "uri", "=", "''", ",", "$", "params", "=", "array", "(", ")", ",", "$", "retain", "=", "false", ")", "{", "// To avoid // urls we check for a single slash.", "if", "(", "$", "uri", "===", "'/'", ")", "{", "$", "uri", "=", "''", ";", "}", "// When the uri starts with an @ sign we handle the uri as route alias.", "if", "(", "substr", "(", "$", "uri", ",", "0", ",", "1", ")", "==", "'@'", ")", "{", "return", "static", "::", "alias", "(", "substr", "(", "$", "uri", ",", "1", ")", ",", "$", "params", ",", "$", "retain", ")", ";", "}", "// Are there already parameters in the uri? Parse them", "// and merge them with current argument parameters", "if", "(", "strpos", "(", "$", "uri", ",", "'?'", ")", "!==", "false", ")", "{", "$", "parts", "=", "explode", "(", "'?'", ",", "$", "uri", ")", ";", "$", "uri", "=", "$", "parts", "[", "0", "]", ";", "if", "(", "isset", "(", "$", "parts", "[", "1", "]", ")", ")", "{", "parse_str", "(", "$", "parts", "[", "1", "]", ",", "$", "old_params", ")", ";", "$", "params", "=", "array_merge", "(", "$", "old_params", ",", "$", "params", ")", ";", "}", "}", "// When the uri contains a protocoll or starts with a slash we assume", "// a full url is given and we don't have to add a path offest.", "if", "(", "strpos", "(", "$", "uri", ",", "'://'", ")", "===", "false", "&&", "substr", "(", "$", "uri", ",", "0", ",", "1", ")", "!==", "'/'", ")", "{", "$", "uri", "=", "static", "::", "$", "path_offset", ".", "$", "uri", ";", "}", "// Try to replace parameters in the uri and remove them from", "// the array so we can append them as get parameters", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "// replace the parameter provider", "if", "(", "is_numeric", "(", "$", "key", ")", "&&", "is_string", "(", "$", "value", ")", "&&", "$", "value", "[", "0", "]", "===", "':'", ")", "{", "$", "param_provider_key", "=", "substr", "(", "$", "value", ",", "1", ")", ";", "// remove the parameter provider from the parameter list", "unset", "(", "$", "params", "[", "$", "key", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "param_provider_key", ",", "static", "::", "$", "parameter_provider", ")", ")", "{", "$", "params", "=", "$", "params", "+", "call_user_func", "(", "static", "::", "$", "parameter_provider", "[", "$", "param_provider_key", "]", ")", ";", "}", "}", "// replace the parameters", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "uri", "=", "str_replace", "(", "':'", ".", "$", "key", ",", "$", "value", ",", "$", "uri", ",", "$", "count", ")", ";", "if", "(", "$", "count", ">", "0", ")", "{", "unset", "(", "$", "params", "[", "$", "key", "]", ")", ";", "}", "}", "}", "// Should we keep the get parameters? If retain is enabled", "// we merge the get parameter array with argument parameters", "if", "(", "$", "retain", ")", "{", "$", "params", "=", "array_merge", "(", "CCIn", "::", "$", "_instance", "->", "GET", ",", "$", "params", ")", ";", "}", "// When we still got parameters add them to the url", "if", "(", "!", "empty", "(", "$", "params", ")", ")", "{", "$", "uri", ".=", "'?'", ".", "http_build_query", "(", "$", "params", ")", ";", "}", "return", "$", "uri", ";", "}" ]
Generate an url @param string $uri @param array $params @param bool $retain Should we keep the get parameters? @return string
[ "Generate", "an", "url" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCUrl.php#L84-L167
19,160
ClanCats/Core
src/classes/CCUrl.php
CCUrl.alias
public static function alias( $alias, $params = array(), $retain = false ) { $route_params = array(); // to handle the suffix after a slash in an alias define $suffix = ''; if ( strpos( $alias, '/' ) !== false && $alias !== '/' ) { // slashes in aliases get appended as suffix list( $alias, $suffix ) = explode( '/', $alias ); $suffix = '/'.$suffix; } // get the parameters with the numeric keys so we can // pass them as route parameters like [any]-[num]-[num]/[any]/ foreach( $params as $key => $value ) { if ( is_int( $key ) ) { $route_params[] = $value; unset( $params[$key] ); } } return CCUrl::to( CCRouter::alias( $alias, $route_params ).$suffix, $params, $retain ); }
php
public static function alias( $alias, $params = array(), $retain = false ) { $route_params = array(); // to handle the suffix after a slash in an alias define $suffix = ''; if ( strpos( $alias, '/' ) !== false && $alias !== '/' ) { // slashes in aliases get appended as suffix list( $alias, $suffix ) = explode( '/', $alias ); $suffix = '/'.$suffix; } // get the parameters with the numeric keys so we can // pass them as route parameters like [any]-[num]-[num]/[any]/ foreach( $params as $key => $value ) { if ( is_int( $key ) ) { $route_params[] = $value; unset( $params[$key] ); } } return CCUrl::to( CCRouter::alias( $alias, $route_params ).$suffix, $params, $retain ); }
[ "public", "static", "function", "alias", "(", "$", "alias", ",", "$", "params", "=", "array", "(", ")", ",", "$", "retain", "=", "false", ")", "{", "$", "route_params", "=", "array", "(", ")", ";", "// to handle the suffix after a slash in an alias define", "$", "suffix", "=", "''", ";", "if", "(", "strpos", "(", "$", "alias", ",", "'/'", ")", "!==", "false", "&&", "$", "alias", "!==", "'/'", ")", "{", "// slashes in aliases get appended as suffix", "list", "(", "$", "alias", ",", "$", "suffix", ")", "=", "explode", "(", "'/'", ",", "$", "alias", ")", ";", "$", "suffix", "=", "'/'", ".", "$", "suffix", ";", "}", "// get the parameters with the numeric keys so we can ", "// pass them as route parameters like [any]-[num]-[num]/[any]/", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_int", "(", "$", "key", ")", ")", "{", "$", "route_params", "[", "]", "=", "$", "value", ";", "unset", "(", "$", "params", "[", "$", "key", "]", ")", ";", "}", "}", "return", "CCUrl", "::", "to", "(", "CCRouter", "::", "alias", "(", "$", "alias", ",", "$", "route_params", ")", ".", "$", "suffix", ",", "$", "params", ",", "$", "retain", ")", ";", "}" ]
Create an URL based on an router alias @param string $alias @param array $params @param bool $retain Should we keep the get parameters? @return string
[ "Create", "an", "URL", "based", "on", "an", "router", "alias" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCUrl.php#L177-L204
19,161
ClanCats/Core
src/classes/CCUrl.php
CCUrl.full
public static function full( $uri = '', $params = array(), $retain = false ) { return CCIn::protocol().'://'.CCIn::host().static::to( $uri, $params, $retain ); }
php
public static function full( $uri = '', $params = array(), $retain = false ) { return CCIn::protocol().'://'.CCIn::host().static::to( $uri, $params, $retain ); }
[ "public", "static", "function", "full", "(", "$", "uri", "=", "''", ",", "$", "params", "=", "array", "(", ")", ",", "$", "retain", "=", "false", ")", "{", "return", "CCIn", "::", "protocol", "(", ")", ".", "'://'", ".", "CCIn", "::", "host", "(", ")", ".", "static", "::", "to", "(", "$", "uri", ",", "$", "params", ",", "$", "retain", ")", ";", "}" ]
Create the full url including protocol and hostname @param string $uri @param array $params @param bool $retain Should we keep the get parameters? @return string
[ "Create", "the", "full", "url", "including", "protocol", "and", "hostname" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCUrl.php#L214-L217
19,162
ClanCats/Core
src/classes/CCUrl.php
CCUrl.secure
public static function secure( $uri = '', $params = array(), $retain = false ) { return 'https://'.CCIn::host().static::to( $uri, $params, $retain ); }
php
public static function secure( $uri = '', $params = array(), $retain = false ) { return 'https://'.CCIn::host().static::to( $uri, $params, $retain ); }
[ "public", "static", "function", "secure", "(", "$", "uri", "=", "''", ",", "$", "params", "=", "array", "(", ")", ",", "$", "retain", "=", "false", ")", "{", "return", "'https://'", ".", "CCIn", "::", "host", "(", ")", ".", "static", "::", "to", "(", "$", "uri", ",", "$", "params", ",", "$", "retain", ")", ";", "}" ]
Create the url and force the https protocol @param string $uri @param array $params @param bool $retain Should we keep the get parameters? @return string
[ "Create", "the", "url", "and", "force", "the", "https", "protocol" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCUrl.php#L227-L230
19,163
ClanCats/Core
src/classes/CCUrl.php
CCUrl.action
public static function action( $action = '', $params = array(), $retain = false ) { if ( $action == 'index' ) { $action = ''; } if ( CCRequest::current() && ( $route = CCRequest::current()->route ) ) { $uri = $route->uri; if ( !is_null( $route->action ) ) { $uri = substr( $uri, 0, strlen( $route->action ) * -1 ); } if ( substr( $uri, -1 ) != '/' ) { $uri .= '/'; } return static::to( $uri.$action, $params, $retain ); } throw new CCException( 'CCUrl::action - There has been no route executed yet.' ); }
php
public static function action( $action = '', $params = array(), $retain = false ) { if ( $action == 'index' ) { $action = ''; } if ( CCRequest::current() && ( $route = CCRequest::current()->route ) ) { $uri = $route->uri; if ( !is_null( $route->action ) ) { $uri = substr( $uri, 0, strlen( $route->action ) * -1 ); } if ( substr( $uri, -1 ) != '/' ) { $uri .= '/'; } return static::to( $uri.$action, $params, $retain ); } throw new CCException( 'CCUrl::action - There has been no route executed yet.' ); }
[ "public", "static", "function", "action", "(", "$", "action", "=", "''", ",", "$", "params", "=", "array", "(", ")", ",", "$", "retain", "=", "false", ")", "{", "if", "(", "$", "action", "==", "'index'", ")", "{", "$", "action", "=", "''", ";", "}", "if", "(", "CCRequest", "::", "current", "(", ")", "&&", "(", "$", "route", "=", "CCRequest", "::", "current", "(", ")", "->", "route", ")", ")", "{", "$", "uri", "=", "$", "route", "->", "uri", ";", "if", "(", "!", "is_null", "(", "$", "route", "->", "action", ")", ")", "{", "$", "uri", "=", "substr", "(", "$", "uri", ",", "0", ",", "strlen", "(", "$", "route", "->", "action", ")", "*", "-", "1", ")", ";", "}", "if", "(", "substr", "(", "$", "uri", ",", "-", "1", ")", "!=", "'/'", ")", "{", "$", "uri", ".=", "'/'", ";", "}", "return", "static", "::", "to", "(", "$", "uri", ".", "$", "action", ",", "$", "params", ",", "$", "retain", ")", ";", "}", "throw", "new", "CCException", "(", "'CCUrl::action - There has been no route executed yet.'", ")", ";", "}" ]
Get the url to a action of the current route !Important it's not possible to link between action on multiple routes This method always assumes that all actions are in the same route. If you want to link to another route using an alias you could do something like: CCUrl::to( '@myalias/myaction' ); @param string $action @param array $params @param bool $retain Should we keep the get parameters? @return string
[ "Get", "the", "url", "to", "a", "action", "of", "the", "current", "route" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCUrl.php#L258-L283
19,164
ClanCats/Core
src/classes/CCUrl.php
CCUrl.active
public static function active( $url ) { $url = parse_url( $url, PHP_URL_PATH ); if ( empty( $url ) ) { return false; } if ( $url[0] !== '/' ) { $url = static::to( $url ); } // when we are on "/" only "/" counts as active. if ( $url === '/' ) { return static::current() == $url; } // for everything else we cut the url and compare $cut = substr( static::current(), 0, strlen( $url ) ); return $cut == $url; }
php
public static function active( $url ) { $url = parse_url( $url, PHP_URL_PATH ); if ( empty( $url ) ) { return false; } if ( $url[0] !== '/' ) { $url = static::to( $url ); } // when we are on "/" only "/" counts as active. if ( $url === '/' ) { return static::current() == $url; } // for everything else we cut the url and compare $cut = substr( static::current(), 0, strlen( $url ) ); return $cut == $url; }
[ "public", "static", "function", "active", "(", "$", "url", ")", "{", "$", "url", "=", "parse_url", "(", "$", "url", ",", "PHP_URL_PATH", ")", ";", "if", "(", "empty", "(", "$", "url", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "url", "[", "0", "]", "!==", "'/'", ")", "{", "$", "url", "=", "static", "::", "to", "(", "$", "url", ")", ";", "}", "// when we are on \"/\" only \"/\" counts as active.", "if", "(", "$", "url", "===", "'/'", ")", "{", "return", "static", "::", "current", "(", ")", "==", "$", "url", ";", "}", "// for everything else we cut the url and compare", "$", "cut", "=", "substr", "(", "static", "::", "current", "(", ")", ",", "0", ",", "strlen", "(", "$", "url", ")", ")", ";", "return", "$", "cut", "==", "$", "url", ";", "}" ]
Is the given url active? This function ignores the domain and the parameters if the uri matches the current uri true will be returned. @param string $url @return bool
[ "Is", "the", "given", "url", "active?", "This", "function", "ignores", "the", "domain", "and", "the", "parameters", "if", "the", "uri", "matches", "the", "current", "uri", "true", "will", "be", "returned", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCUrl.php#L293-L317
19,165
CakeCMS/Core
src/Plugin.php
Plugin.getData
public static function getData($plugin, $key = null) { $data = self::_checkData($plugin); if (empty($data) && $path = self::getManifestPath($plugin)) { if (FS::isFile($path)) { /** @noinspection PhpIncludeInspection */ $plgData = include $path; $plgData = (array) $plgData; if (!empty($plgData)) { self::$_data[$plugin] = $plgData; $data = $plgData; } } } return self::_getPluginData($data, $key); }
php
public static function getData($plugin, $key = null) { $data = self::_checkData($plugin); if (empty($data) && $path = self::getManifestPath($plugin)) { if (FS::isFile($path)) { /** @noinspection PhpIncludeInspection */ $plgData = include $path; $plgData = (array) $plgData; if (!empty($plgData)) { self::$_data[$plugin] = $plgData; $data = $plgData; } } } return self::_getPluginData($data, $key); }
[ "public", "static", "function", "getData", "(", "$", "plugin", ",", "$", "key", "=", "null", ")", "{", "$", "data", "=", "self", "::", "_checkData", "(", "$", "plugin", ")", ";", "if", "(", "empty", "(", "$", "data", ")", "&&", "$", "path", "=", "self", "::", "getManifestPath", "(", "$", "plugin", ")", ")", "{", "if", "(", "FS", "::", "isFile", "(", "$", "path", ")", ")", "{", "/** @noinspection PhpIncludeInspection */", "$", "plgData", "=", "include", "$", "path", ";", "$", "plgData", "=", "(", "array", ")", "$", "plgData", ";", "if", "(", "!", "empty", "(", "$", "plgData", ")", ")", "{", "self", "::", "$", "_data", "[", "$", "plugin", "]", "=", "$", "plgData", ";", "$", "data", "=", "$", "plgData", ";", "}", "}", "}", "return", "self", "::", "_getPluginData", "(", "$", "data", ",", "$", "key", ")", ";", "}" ]
Get plugin manifest data. @param string $plugin @param null|string $key @return Data
[ "Get", "plugin", "manifest", "data", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Plugin.php#L88-L104
19,166
CakeCMS/Core
src/Plugin.php
Plugin.getManifestPath
public static function getManifestPath($plugin) { if (self::loaded($plugin)) { return FS::clean(self::path($plugin) . DS . self::PLUGIN_MANIFEST); } return null; }
php
public static function getManifestPath($plugin) { if (self::loaded($plugin)) { return FS::clean(self::path($plugin) . DS . self::PLUGIN_MANIFEST); } return null; }
[ "public", "static", "function", "getManifestPath", "(", "$", "plugin", ")", "{", "if", "(", "self", "::", "loaded", "(", "$", "plugin", ")", ")", "{", "return", "FS", "::", "clean", "(", "self", "::", "path", "(", "$", "plugin", ")", ".", "DS", ".", "self", "::", "PLUGIN_MANIFEST", ")", ";", "}", "return", "null", ";", "}" ]
Get absolute plugin manifest file path. @param string $plugin @return null|string
[ "Get", "absolute", "plugin", "manifest", "file", "path", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Plugin.php#L123-L130
19,167
CakeCMS/Core
src/Plugin.php
Plugin.loadList
public static function loadList(array $plugins) { foreach ($plugins as $name) { if (self::loaded($name)) { continue; } if ($path = self::_findPlugin($name)) { self::load($name, self::_getConfigForLoad($path)); } } }
php
public static function loadList(array $plugins) { foreach ($plugins as $name) { if (self::loaded($name)) { continue; } if ($path = self::_findPlugin($name)) { self::load($name, self::_getConfigForLoad($path)); } } }
[ "public", "static", "function", "loadList", "(", "array", "$", "plugins", ")", "{", "foreach", "(", "$", "plugins", "as", "$", "name", ")", "{", "if", "(", "self", "::", "loaded", "(", "$", "name", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "path", "=", "self", "::", "_findPlugin", "(", "$", "name", ")", ")", "{", "self", "::", "load", "(", "$", "name", ",", "self", "::", "_getConfigForLoad", "(", "$", "path", ")", ")", ";", "}", "}", "}" ]
Load list plugin. @param array $plugins @return void
[ "Load", "list", "plugin", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Plugin.php#L168-L179
19,168
CakeCMS/Core
src/Plugin.php
Plugin.manifestEvent
public static function manifestEvent() { $args = func_get_args(); $callback = array_shift($args); if (Arr::key($callback, self::$_eventList)) { $callbacks = self::$_eventList[$callback]; foreach ($callbacks as $method) { call_user_func_array($method, $args); } } }
php
public static function manifestEvent() { $args = func_get_args(); $callback = array_shift($args); if (Arr::key($callback, self::$_eventList)) { $callbacks = self::$_eventList[$callback]; foreach ($callbacks as $method) { call_user_func_array($method, $args); } } }
[ "public", "static", "function", "manifestEvent", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "callback", "=", "array_shift", "(", "$", "args", ")", ";", "if", "(", "Arr", "::", "key", "(", "$", "callback", ",", "self", "::", "$", "_eventList", ")", ")", "{", "$", "callbacks", "=", "self", "::", "$", "_eventList", "[", "$", "callback", "]", ";", "foreach", "(", "$", "callbacks", "as", "$", "method", ")", "{", "call_user_func_array", "(", "$", "method", ",", "$", "args", ")", ";", "}", "}", "}" ]
Call plugin manifest callbacks. @return void
[ "Call", "plugin", "manifest", "callbacks", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Plugin.php#L186-L197
19,169
CakeCMS/Core
src/Plugin.php
Plugin.unload
public static function unload($plugin = null) { if (self::loaded($plugin)) { $locales = Configure::read('App.paths.locales'); foreach ($locales as $key => $path) { if ($path == self::getLocalePath($plugin)) { unset($locales[$key]); } } Configure::write('App.paths.locales', $locales); } parent::unload($plugin); }
php
public static function unload($plugin = null) { if (self::loaded($plugin)) { $locales = Configure::read('App.paths.locales'); foreach ($locales as $key => $path) { if ($path == self::getLocalePath($plugin)) { unset($locales[$key]); } } Configure::write('App.paths.locales', $locales); } parent::unload($plugin); }
[ "public", "static", "function", "unload", "(", "$", "plugin", "=", "null", ")", "{", "if", "(", "self", "::", "loaded", "(", "$", "plugin", ")", ")", "{", "$", "locales", "=", "Configure", "::", "read", "(", "'App.paths.locales'", ")", ";", "foreach", "(", "$", "locales", "as", "$", "key", "=>", "$", "path", ")", "{", "if", "(", "$", "path", "==", "self", "::", "getLocalePath", "(", "$", "plugin", ")", ")", "{", "unset", "(", "$", "locales", "[", "$", "key", "]", ")", ";", "}", "}", "Configure", "::", "write", "(", "'App.paths.locales'", ",", "$", "locales", ")", ";", "}", "parent", "::", "unload", "(", "$", "plugin", ")", ";", "}" ]
Unload the plugin. @param null|string $plugin @return void
[ "Unload", "the", "plugin", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Plugin.php#L205-L219
19,170
CakeCMS/Core
src/Plugin.php
Plugin._addManifestCallback
protected static function _addManifestCallback($plugin) { $data = Plugin::getData($plugin); foreach ($data as $name => $callback) { if (self::_isCallablePluginData($name, $plugin, $callback) && $plugin !== 'Core') { self::$_eventList[$name][$plugin] = $callback; } } }
php
protected static function _addManifestCallback($plugin) { $data = Plugin::getData($plugin); foreach ($data as $name => $callback) { if (self::_isCallablePluginData($name, $plugin, $callback) && $plugin !== 'Core') { self::$_eventList[$name][$plugin] = $callback; } } }
[ "protected", "static", "function", "_addManifestCallback", "(", "$", "plugin", ")", "{", "$", "data", "=", "Plugin", "::", "getData", "(", "$", "plugin", ")", ";", "foreach", "(", "$", "data", "as", "$", "name", "=>", "$", "callback", ")", "{", "if", "(", "self", "::", "_isCallablePluginData", "(", "$", "name", ",", "$", "plugin", ",", "$", "callback", ")", "&&", "$", "plugin", "!==", "'Core'", ")", "{", "self", "::", "$", "_eventList", "[", "$", "name", "]", "[", "$", "plugin", "]", "=", "$", "callback", ";", "}", "}", "}" ]
Registration plugin manifest callbacks. @param string $plugin @return void
[ "Registration", "plugin", "manifest", "callbacks", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Plugin.php#L227-L235
19,171
CakeCMS/Core
src/Plugin.php
Plugin._checkData
protected static function _checkData($plugin) { return (Arr::in($plugin, self::$_data)) ? self::$_data[$plugin] : []; }
php
protected static function _checkData($plugin) { return (Arr::in($plugin, self::$_data)) ? self::$_data[$plugin] : []; }
[ "protected", "static", "function", "_checkData", "(", "$", "plugin", ")", "{", "return", "(", "Arr", "::", "in", "(", "$", "plugin", ",", "self", "::", "$", "_data", ")", ")", "?", "self", "::", "$", "_data", "[", "$", "plugin", "]", ":", "[", "]", ";", "}" ]
Check plugin data. @param string $plugin @return array
[ "Check", "plugin", "data", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Plugin.php#L243-L246
19,172
CakeCMS/Core
src/Plugin.php
Plugin._findPlugin
protected static function _findPlugin($name) { $output = null; $paths = App::path('Plugin'); $plugin = Configure::read('plugins.' . $name); if ($plugin !== null) { return $plugin; } foreach ($paths as $path) { $plgPath = $path . $name . DS; if (FS::isDir($plgPath)) { $output = $plgPath; break; } } return $output; }
php
protected static function _findPlugin($name) { $output = null; $paths = App::path('Plugin'); $plugin = Configure::read('plugins.' . $name); if ($plugin !== null) { return $plugin; } foreach ($paths as $path) { $plgPath = $path . $name . DS; if (FS::isDir($plgPath)) { $output = $plgPath; break; } } return $output; }
[ "protected", "static", "function", "_findPlugin", "(", "$", "name", ")", "{", "$", "output", "=", "null", ";", "$", "paths", "=", "App", "::", "path", "(", "'Plugin'", ")", ";", "$", "plugin", "=", "Configure", "::", "read", "(", "'plugins.'", ".", "$", "name", ")", ";", "if", "(", "$", "plugin", "!==", "null", ")", "{", "return", "$", "plugin", ";", "}", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "$", "plgPath", "=", "$", "path", ".", "$", "name", ".", "DS", ";", "if", "(", "FS", "::", "isDir", "(", "$", "plgPath", ")", ")", "{", "$", "output", "=", "$", "plgPath", ";", "break", ";", "}", "}", "return", "$", "output", ";", "}" ]
Find plugin dir in registered paths. @param string $name @return null|string
[ "Find", "plugin", "dir", "in", "registered", "paths", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Plugin.php#L254-L273
19,173
CakeCMS/Core
src/Plugin.php
Plugin._getConfigForLoad
protected static function _getConfigForLoad($path) { $config = ['autoload' => true]; $routes = $path . 'config' . DS . Plugin::FILE_ROUTES; $bootstrap = $path . 'config' . DS . Plugin::FILE_BOOTSTRAP; if (FS::isFile($bootstrap)) { $config['bootstrap'] = true; } if (FS::isFile($routes)) { $config['routes'] = true; } $config['path'] = $path; return $config; }
php
protected static function _getConfigForLoad($path) { $config = ['autoload' => true]; $routes = $path . 'config' . DS . Plugin::FILE_ROUTES; $bootstrap = $path . 'config' . DS . Plugin::FILE_BOOTSTRAP; if (FS::isFile($bootstrap)) { $config['bootstrap'] = true; } if (FS::isFile($routes)) { $config['routes'] = true; } $config['path'] = $path; return $config; }
[ "protected", "static", "function", "_getConfigForLoad", "(", "$", "path", ")", "{", "$", "config", "=", "[", "'autoload'", "=>", "true", "]", ";", "$", "routes", "=", "$", "path", ".", "'config'", ".", "DS", ".", "Plugin", "::", "FILE_ROUTES", ";", "$", "bootstrap", "=", "$", "path", ".", "'config'", ".", "DS", ".", "Plugin", "::", "FILE_BOOTSTRAP", ";", "if", "(", "FS", "::", "isFile", "(", "$", "bootstrap", ")", ")", "{", "$", "config", "[", "'bootstrap'", "]", "=", "true", ";", "}", "if", "(", "FS", "::", "isFile", "(", "$", "routes", ")", ")", "{", "$", "config", "[", "'routes'", "]", "=", "true", ";", "}", "$", "config", "[", "'path'", "]", "=", "$", "path", ";", "return", "$", "config", ";", "}" ]
Get plugin configuration for load plugin. @param string $path @return array
[ "Get", "plugin", "configuration", "for", "load", "plugin", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Plugin.php#L281-L298
19,174
CakeCMS/Core
src/Plugin.php
Plugin._getPluginData
protected static function _getPluginData(array $data, $key = null) { if (isset($data[$key])) { $data = $data[$key]; } return new Data($data); }
php
protected static function _getPluginData(array $data, $key = null) { if (isset($data[$key])) { $data = $data[$key]; } return new Data($data); }
[ "protected", "static", "function", "_getPluginData", "(", "array", "$", "data", ",", "$", "key", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "$", "key", "]", ")", ")", "{", "$", "data", "=", "$", "data", "[", "$", "key", "]", ";", "}", "return", "new", "Data", "(", "$", "data", ")", ";", "}" ]
Get current plugin data. @param array $data @param null|string $key @return Data
[ "Get", "current", "plugin", "data", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Plugin.php#L307-L314
19,175
CakeCMS/Core
src/Plugin.php
Plugin._isCallablePluginData
protected static function _isCallablePluginData($name, $plugin, $callback) { if (Arr::in($name, self::$_manifestEvents) && !isset(self::$_eventList[$name][$plugin]) && is_callable($callback) ) { return true; } return false; }
php
protected static function _isCallablePluginData($name, $plugin, $callback) { if (Arr::in($name, self::$_manifestEvents) && !isset(self::$_eventList[$name][$plugin]) && is_callable($callback) ) { return true; } return false; }
[ "protected", "static", "function", "_isCallablePluginData", "(", "$", "name", ",", "$", "plugin", ",", "$", "callback", ")", "{", "if", "(", "Arr", "::", "in", "(", "$", "name", ",", "self", "::", "$", "_manifestEvents", ")", "&&", "!", "isset", "(", "self", "::", "$", "_eventList", "[", "$", "name", "]", "[", "$", "plugin", "]", ")", "&&", "is_callable", "(", "$", "callback", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check manifest param on callable. @param string $name @param string $plugin @param mixed $callback @return bool
[ "Check", "manifest", "param", "on", "callable", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Plugin.php#L324-L334
19,176
yuncms/framework
src/helpers/PasswordHelper.php
PasswordHelper.generate
public static function generate($length): string { $sets = ['abcdefghjkmnpqrstuvwxyz', 'ABCDEFGHJKMNPQRSTUVWXYZ', '23456789']; $all = ''; $password = ''; foreach ($sets as $set) { $password .= $set[array_rand(str_split($set))]; $all .= $set; } $all = str_split($all); for ($i = 0; $i < $length - count($sets); $i++) { $password .= $all[array_rand($all)]; } $password = str_shuffle($password); return $password; }
php
public static function generate($length): string { $sets = ['abcdefghjkmnpqrstuvwxyz', 'ABCDEFGHJKMNPQRSTUVWXYZ', '23456789']; $all = ''; $password = ''; foreach ($sets as $set) { $password .= $set[array_rand(str_split($set))]; $all .= $set; } $all = str_split($all); for ($i = 0; $i < $length - count($sets); $i++) { $password .= $all[array_rand($all)]; } $password = str_shuffle($password); return $password; }
[ "public", "static", "function", "generate", "(", "$", "length", ")", ":", "string", "{", "$", "sets", "=", "[", "'abcdefghjkmnpqrstuvwxyz'", ",", "'ABCDEFGHJKMNPQRSTUVWXYZ'", ",", "'23456789'", "]", ";", "$", "all", "=", "''", ";", "$", "password", "=", "''", ";", "foreach", "(", "$", "sets", "as", "$", "set", ")", "{", "$", "password", ".=", "$", "set", "[", "array_rand", "(", "str_split", "(", "$", "set", ")", ")", "]", ";", "$", "all", ".=", "$", "set", ";", "}", "$", "all", "=", "str_split", "(", "$", "all", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "length", "-", "count", "(", "$", "sets", ")", ";", "$", "i", "++", ")", "{", "$", "password", ".=", "$", "all", "[", "array_rand", "(", "$", "all", ")", "]", ";", "}", "$", "password", "=", "str_shuffle", "(", "$", "password", ")", ";", "return", "$", "password", ";", "}" ]
Generates user-friendly random password containing at least one lower case letter, one uppercase letter and one digit. The remaining characters in the password are chosen at random from those three sets. @see https://gist.github.com/tylerhall/521810 @param $length @return string
[ "Generates", "user", "-", "friendly", "random", "password", "containing", "at", "least", "one", "lower", "case", "letter", "one", "uppercase", "letter", "and", "one", "digit", ".", "The", "remaining", "characters", "in", "the", "password", "are", "chosen", "at", "random", "from", "those", "three", "sets", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/helpers/PasswordHelper.php#L56-L74
19,177
devemio/php-readable-timer
src/TimerPool.php
TimerPool.stop
public function stop($marker) { if (array_key_exists($marker, $this->timers)) { $this->timers[$marker]->stop(); } }
php
public function stop($marker) { if (array_key_exists($marker, $this->timers)) { $this->timers[$marker]->stop(); } }
[ "public", "function", "stop", "(", "$", "marker", ")", "{", "if", "(", "array_key_exists", "(", "$", "marker", ",", "$", "this", "->", "timers", ")", ")", "{", "$", "this", "->", "timers", "[", "$", "marker", "]", "->", "stop", "(", ")", ";", "}", "}" ]
Stop timer with a specific marker. @param string $marker
[ "Stop", "timer", "with", "a", "specific", "marker", "." ]
50916b630eda07999dc6676528afe59fb2105615
https://github.com/devemio/php-readable-timer/blob/50916b630eda07999dc6676528afe59fb2105615/src/TimerPool.php#L48-L53
19,178
devemio/php-readable-timer
src/TimerPool.php
TimerPool.build
public function build() { foreach ($this->timers as $marker => $timer) { $this->markers[$marker] = $timer->time(); } arsort($this->markers); return $this->markers; }
php
public function build() { foreach ($this->timers as $marker => $timer) { $this->markers[$marker] = $timer->time(); } arsort($this->markers); return $this->markers; }
[ "public", "function", "build", "(", ")", "{", "foreach", "(", "$", "this", "->", "timers", "as", "$", "marker", "=>", "$", "timer", ")", "{", "$", "this", "->", "markers", "[", "$", "marker", "]", "=", "$", "timer", "->", "time", "(", ")", ";", "}", "arsort", "(", "$", "this", "->", "markers", ")", ";", "return", "$", "this", "->", "markers", ";", "}" ]
Return sorted times. @return string[]
[ "Return", "sorted", "times", "." ]
50916b630eda07999dc6676528afe59fb2105615
https://github.com/devemio/php-readable-timer/blob/50916b630eda07999dc6676528afe59fb2105615/src/TimerPool.php#L60-L67
19,179
lmammino/e-foundation
src/Price/Model/PricedItemTrait.php
PricedItemTrait.calculateTotal
public function calculateTotal() { $this->calculateAdjustmentsTotal(); $this->total = ($this->quantity * $this->unitPrice) + $this->adjustmentsTotal; if ($this->total < 0) { $this->total = 0; } return $this; }
php
public function calculateTotal() { $this->calculateAdjustmentsTotal(); $this->total = ($this->quantity * $this->unitPrice) + $this->adjustmentsTotal; if ($this->total < 0) { $this->total = 0; } return $this; }
[ "public", "function", "calculateTotal", "(", ")", "{", "$", "this", "->", "calculateAdjustmentsTotal", "(", ")", ";", "$", "this", "->", "total", "=", "(", "$", "this", "->", "quantity", "*", "$", "this", "->", "unitPrice", ")", "+", "$", "this", "->", "adjustmentsTotal", ";", "if", "(", "$", "this", "->", "total", "<", "0", ")", "{", "$", "this", "->", "total", "=", "0", ";", "}", "return", "$", "this", ";", "}" ]
Calculates the total for the item @return $this
[ "Calculates", "the", "total", "for", "the", "item" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Price/Model/PricedItemTrait.php#L153-L164
19,180
lmammino/e-foundation
src/Price/Model/PricedItemsContainerTrait.php
PricedItemsContainerTrait.addItem
public function addItem(PricedItemInterface $item) { if ($this->hasItem($item)) { return $this; } foreach ($this->items as $existingItem) { if ($item->equals($existingItem)) { $existingItem->merge($item, false); $this->itemsTotal = null; $this->total = null; return $this; } } $item->setContainer($this); $this->items->add($item); $this->itemsTotal = null; $this->total = null; return $this; }
php
public function addItem(PricedItemInterface $item) { if ($this->hasItem($item)) { return $this; } foreach ($this->items as $existingItem) { if ($item->equals($existingItem)) { $existingItem->merge($item, false); $this->itemsTotal = null; $this->total = null; return $this; } } $item->setContainer($this); $this->items->add($item); $this->itemsTotal = null; $this->total = null; return $this; }
[ "public", "function", "addItem", "(", "PricedItemInterface", "$", "item", ")", "{", "if", "(", "$", "this", "->", "hasItem", "(", "$", "item", ")", ")", "{", "return", "$", "this", ";", "}", "foreach", "(", "$", "this", "->", "items", "as", "$", "existingItem", ")", "{", "if", "(", "$", "item", "->", "equals", "(", "$", "existingItem", ")", ")", "{", "$", "existingItem", "->", "merge", "(", "$", "item", ",", "false", ")", ";", "$", "this", "->", "itemsTotal", "=", "null", ";", "$", "this", "->", "total", "=", "null", ";", "return", "$", "this", ";", "}", "}", "$", "item", "->", "setContainer", "(", "$", "this", ")", ";", "$", "this", "->", "items", "->", "add", "(", "$", "item", ")", ";", "$", "this", "->", "itemsTotal", "=", "null", ";", "$", "this", "->", "total", "=", "null", ";", "return", "$", "this", ";", "}" ]
Add an item @param PricedItemInterface $item @return $this
[ "Add", "an", "item" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Price/Model/PricedItemsContainerTrait.php#L121-L145
19,181
lmammino/e-foundation
src/Price/Model/PricedItemsContainerTrait.php
PricedItemsContainerTrait.removeItem
public function removeItem(PricedItemInterface $item) { if ($this->hasItem($item)) { $item->setContainer(null); $this->items->removeElement($item); $this->itemsTotal = null; $this->total = null; } return $this; }
php
public function removeItem(PricedItemInterface $item) { if ($this->hasItem($item)) { $item->setContainer(null); $this->items->removeElement($item); $this->itemsTotal = null; $this->total = null; } return $this; }
[ "public", "function", "removeItem", "(", "PricedItemInterface", "$", "item", ")", "{", "if", "(", "$", "this", "->", "hasItem", "(", "$", "item", ")", ")", "{", "$", "item", "->", "setContainer", "(", "null", ")", ";", "$", "this", "->", "items", "->", "removeElement", "(", "$", "item", ")", ";", "$", "this", "->", "itemsTotal", "=", "null", ";", "$", "this", "->", "total", "=", "null", ";", "}", "return", "$", "this", ";", "}" ]
Remove a given item @param PricedItemInterface $item @return $this
[ "Remove", "a", "given", "item" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Price/Model/PricedItemsContainerTrait.php#L154-L165
19,182
lmammino/e-foundation
src/Price/Model/PricedItemsContainerTrait.php
PricedItemsContainerTrait.calculateItemsTotal
public function calculateItemsTotal() { $itemsTotal = 0; foreach ($this->items as $item) { $itemsTotal += $item->getTotal(); } $this->itemsTotal = $itemsTotal; return $this; }
php
public function calculateItemsTotal() { $itemsTotal = 0; foreach ($this->items as $item) { $itemsTotal += $item->getTotal(); } $this->itemsTotal = $itemsTotal; return $this; }
[ "public", "function", "calculateItemsTotal", "(", ")", "{", "$", "itemsTotal", "=", "0", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "$", "itemsTotal", "+=", "$", "item", "->", "getTotal", "(", ")", ";", "}", "$", "this", "->", "itemsTotal", "=", "$", "itemsTotal", ";", "return", "$", "this", ";", "}" ]
Calculate the total price for all the items @return $this
[ "Calculate", "the", "total", "price", "for", "all", "the", "items" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Price/Model/PricedItemsContainerTrait.php#L196-L207
19,183
lmammino/e-foundation
src/Price/Model/PricedItemsContainerTrait.php
PricedItemsContainerTrait.calculateTotal
public function calculateTotal() { $this->total = $this->getItemsTotal() + $this->getAdjustmentTotal(); if ($this->total < 0) { $this->total = 0; } return $this; }
php
public function calculateTotal() { $this->total = $this->getItemsTotal() + $this->getAdjustmentTotal(); if ($this->total < 0) { $this->total = 0; } return $this; }
[ "public", "function", "calculateTotal", "(", ")", "{", "$", "this", "->", "total", "=", "$", "this", "->", "getItemsTotal", "(", ")", "+", "$", "this", "->", "getAdjustmentTotal", "(", ")", ";", "if", "(", "$", "this", "->", "total", "<", "0", ")", "{", "$", "this", "->", "total", "=", "0", ";", "}", "return", "$", "this", ";", "}" ]
Calculate the total amount for the whole container @return $this
[ "Calculate", "the", "total", "amount", "for", "the", "whole", "container" ]
198b7047d93eb11c9bc0c7ddf0bfa8229d42807a
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Price/Model/PricedItemsContainerTrait.php#L241-L250
19,184
forxer/tao
src/Tao/Controller/Controller.php
Controller.serve401
public function serve401() { $response = new Response(); $response->setStatusCode(Response::HTTP_UNAUTHORIZED); return $this->render('Errors/401', [], $response); }
php
public function serve401() { $response = new Response(); $response->setStatusCode(Response::HTTP_UNAUTHORIZED); return $this->render('Errors/401', [], $response); }
[ "public", "function", "serve401", "(", ")", "{", "$", "response", "=", "new", "Response", "(", ")", ";", "$", "response", "->", "setStatusCode", "(", "Response", "::", "HTTP_UNAUTHORIZED", ")", ";", "return", "$", "this", "->", "render", "(", "'Errors/401'", ",", "[", "]", ",", "$", "response", ")", ";", "}" ]
Affichage page 401
[ "Affichage", "page", "401" ]
b5e9109c244a29a72403ae6a58633ab96a67c660
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Controller/Controller.php#L147-L153
19,185
forxer/tao
src/Tao/Controller/Controller.php
Controller.serve404
public function serve404() { $response = new Response(); $response->setStatusCode(Response::HTTP_NOT_FOUND); return $this->render('Errors/404', [], $response); }
php
public function serve404() { $response = new Response(); $response->setStatusCode(Response::HTTP_NOT_FOUND); return $this->render('Errors/404', [], $response); }
[ "public", "function", "serve404", "(", ")", "{", "$", "response", "=", "new", "Response", "(", ")", ";", "$", "response", "->", "setStatusCode", "(", "Response", "::", "HTTP_NOT_FOUND", ")", ";", "return", "$", "this", "->", "render", "(", "'Errors/404'", ",", "[", "]", ",", "$", "response", ")", ";", "}" ]
Affichage page 404
[ "Affichage", "page", "404" ]
b5e9109c244a29a72403ae6a58633ab96a67c660
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Controller/Controller.php#L158-L164
19,186
forxer/tao
src/Tao/Controller/Controller.php
Controller.serve503
public function serve503() { $response = new Response(); $response->setStatusCode(Response::HTTP_SERVICE_UNAVAILABLE); $response->headers->set('Retry-After', 3600); return $this->render('Errors/503', [], $response); }
php
public function serve503() { $response = new Response(); $response->setStatusCode(Response::HTTP_SERVICE_UNAVAILABLE); $response->headers->set('Retry-After', 3600); return $this->render('Errors/503', [], $response); }
[ "public", "function", "serve503", "(", ")", "{", "$", "response", "=", "new", "Response", "(", ")", ";", "$", "response", "->", "setStatusCode", "(", "Response", "::", "HTTP_SERVICE_UNAVAILABLE", ")", ";", "$", "response", "->", "headers", "->", "set", "(", "'Retry-After'", ",", "3600", ")", ";", "return", "$", "this", "->", "render", "(", "'Errors/503'", ",", "[", "]", ",", "$", "response", ")", ";", "}" ]
Affichage page 503
[ "Affichage", "page", "503" ]
b5e9109c244a29a72403ae6a58633ab96a67c660
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Controller/Controller.php#L169-L176
19,187
forxer/tao
src/Tao/Controller/Controller.php
Controller.removeTrailingSlash
public function removeTrailingSlash() { $pathInfo = $this->app['request']->getPathInfo(); $requestUri = $this->app['request']->getRequestUri(); $url = str_replace($pathInfo, rtrim($pathInfo, ' /'), $requestUri); return $this->redirect($url, Response::HTTP_MOVED_PERMANENTLY); }
php
public function removeTrailingSlash() { $pathInfo = $this->app['request']->getPathInfo(); $requestUri = $this->app['request']->getRequestUri(); $url = str_replace($pathInfo, rtrim($pathInfo, ' /'), $requestUri); return $this->redirect($url, Response::HTTP_MOVED_PERMANENTLY); }
[ "public", "function", "removeTrailingSlash", "(", ")", "{", "$", "pathInfo", "=", "$", "this", "->", "app", "[", "'request'", "]", "->", "getPathInfo", "(", ")", ";", "$", "requestUri", "=", "$", "this", "->", "app", "[", "'request'", "]", "->", "getRequestUri", "(", ")", ";", "$", "url", "=", "str_replace", "(", "$", "pathInfo", ",", "rtrim", "(", "$", "pathInfo", ",", "' /'", ")", ",", "$", "requestUri", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "url", ",", "Response", "::", "HTTP_MOVED_PERMANENTLY", ")", ";", "}" ]
Remove trailing slash and redirect permanent @return \Symfony\Component\HttpFoundation\RedirectResponse
[ "Remove", "trailing", "slash", "and", "redirect", "permanent" ]
b5e9109c244a29a72403ae6a58633ab96a67c660
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Controller/Controller.php#L183-L191
19,188
ClanCats/Core
src/classes/CCView/Builder/CCFTemplate.php
CCView_Builder_CCFTemplate.repair_expression
public function repair_expression( $exp ) { $commands = explode( ' ', $exp ); // filter empty ones $commands = array_filter( $commands, function( $value ) { return !is_null( $value ); }); // bracket starting command if ( in_array( $commands[0], $this->bracket_starting_commands ) ) { // each = foreach if ( $commands[0] == 'each' ) { $commands[0] = 'foreach'; } // loop special elseif ( $commands[0] == 'loop' ) { $commands[0] = 'for'; $commands[1] = '$i=0;$i<'.$commands[1].';$i++'; } // remove the opening duble point end($commands); $key = key($commands); if ( substr( $commands[$key], -1 ) == ':' ) { $commands[$key] = substr( $commands[$key], 0, -1 ); // is it now empty? if ( $commands[$key] == ' ' || empty( $commands[$key] ) ) { unset( $commands[$key] ); } } // do we have brackets? if ( substr( $commands[1], 0, 1 ) != '(' ) { // add starting bracket $commands[1] = '( '.$commands[1]; // add ending bracket end($commands); $key = key($commands); $commands[$key] .= ' )'; } $commands[] = ':'; } // bracket ending command elseif ( count( $commands == 1 ) && in_array( $commands[0], $this->bracket_ending_commands ) ) { // each = foreach if ( $commands[0] == 'endeach' ) { $commands[0] = 'endforeach'; } // loop special elseif ( $commands[0] == 'endloop' ) { $commands[0] = 'endfor'; } // check for semicolon if ( substr( $commands[0], 0, 1 ) != ';' ) { $commands[0] .= ';'; } } // bracket continue command elseif ( count( $commands == 1 ) && in_array( $commands[0], $this->bracket_continue_commands ) ) { // remove the opening duble point end($commands); $key = key($commands); if ( substr( $commands[$key], -1 ) == ':' ) { $commands[$key] = substr( $commands[$key], 0, -1 ); // is it now empty? if ( $commands[$key] == ' ' || empty( $commands[$key] ) ) { unset( $commands[$key] ); } } // add the double point $commands[] = ':'; } return implode( ' ', $commands ); }
php
public function repair_expression( $exp ) { $commands = explode( ' ', $exp ); // filter empty ones $commands = array_filter( $commands, function( $value ) { return !is_null( $value ); }); // bracket starting command if ( in_array( $commands[0], $this->bracket_starting_commands ) ) { // each = foreach if ( $commands[0] == 'each' ) { $commands[0] = 'foreach'; } // loop special elseif ( $commands[0] == 'loop' ) { $commands[0] = 'for'; $commands[1] = '$i=0;$i<'.$commands[1].';$i++'; } // remove the opening duble point end($commands); $key = key($commands); if ( substr( $commands[$key], -1 ) == ':' ) { $commands[$key] = substr( $commands[$key], 0, -1 ); // is it now empty? if ( $commands[$key] == ' ' || empty( $commands[$key] ) ) { unset( $commands[$key] ); } } // do we have brackets? if ( substr( $commands[1], 0, 1 ) != '(' ) { // add starting bracket $commands[1] = '( '.$commands[1]; // add ending bracket end($commands); $key = key($commands); $commands[$key] .= ' )'; } $commands[] = ':'; } // bracket ending command elseif ( count( $commands == 1 ) && in_array( $commands[0], $this->bracket_ending_commands ) ) { // each = foreach if ( $commands[0] == 'endeach' ) { $commands[0] = 'endforeach'; } // loop special elseif ( $commands[0] == 'endloop' ) { $commands[0] = 'endfor'; } // check for semicolon if ( substr( $commands[0], 0, 1 ) != ';' ) { $commands[0] .= ';'; } } // bracket continue command elseif ( count( $commands == 1 ) && in_array( $commands[0], $this->bracket_continue_commands ) ) { // remove the opening duble point end($commands); $key = key($commands); if ( substr( $commands[$key], -1 ) == ':' ) { $commands[$key] = substr( $commands[$key], 0, -1 ); // is it now empty? if ( $commands[$key] == ' ' || empty( $commands[$key] ) ) { unset( $commands[$key] ); } } // add the double point $commands[] = ':'; } return implode( ' ', $commands ); }
[ "public", "function", "repair_expression", "(", "$", "exp", ")", "{", "$", "commands", "=", "explode", "(", "' '", ",", "$", "exp", ")", ";", "// filter empty ones", "$", "commands", "=", "array_filter", "(", "$", "commands", ",", "function", "(", "$", "value", ")", "{", "return", "!", "is_null", "(", "$", "value", ")", ";", "}", ")", ";", "// bracket starting command", "if", "(", "in_array", "(", "$", "commands", "[", "0", "]", ",", "$", "this", "->", "bracket_starting_commands", ")", ")", "{", "// each = foreach", "if", "(", "$", "commands", "[", "0", "]", "==", "'each'", ")", "{", "$", "commands", "[", "0", "]", "=", "'foreach'", ";", "}", "// loop special", "elseif", "(", "$", "commands", "[", "0", "]", "==", "'loop'", ")", "{", "$", "commands", "[", "0", "]", "=", "'for'", ";", "$", "commands", "[", "1", "]", "=", "'$i=0;$i<'", ".", "$", "commands", "[", "1", "]", ".", "';$i++'", ";", "}", "// remove the opening duble point", "end", "(", "$", "commands", ")", ";", "$", "key", "=", "key", "(", "$", "commands", ")", ";", "if", "(", "substr", "(", "$", "commands", "[", "$", "key", "]", ",", "-", "1", ")", "==", "':'", ")", "{", "$", "commands", "[", "$", "key", "]", "=", "substr", "(", "$", "commands", "[", "$", "key", "]", ",", "0", ",", "-", "1", ")", ";", "// is it now empty?", "if", "(", "$", "commands", "[", "$", "key", "]", "==", "' '", "||", "empty", "(", "$", "commands", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "$", "commands", "[", "$", "key", "]", ")", ";", "}", "}", "// do we have brackets?", "if", "(", "substr", "(", "$", "commands", "[", "1", "]", ",", "0", ",", "1", ")", "!=", "'('", ")", "{", "// add starting bracket", "$", "commands", "[", "1", "]", "=", "'( '", ".", "$", "commands", "[", "1", "]", ";", "// add ending bracket", "end", "(", "$", "commands", ")", ";", "$", "key", "=", "key", "(", "$", "commands", ")", ";", "$", "commands", "[", "$", "key", "]", ".=", "' )'", ";", "}", "$", "commands", "[", "]", "=", "':'", ";", "}", "// bracket ending command", "elseif", "(", "count", "(", "$", "commands", "==", "1", ")", "&&", "in_array", "(", "$", "commands", "[", "0", "]", ",", "$", "this", "->", "bracket_ending_commands", ")", ")", "{", "// each = foreach", "if", "(", "$", "commands", "[", "0", "]", "==", "'endeach'", ")", "{", "$", "commands", "[", "0", "]", "=", "'endforeach'", ";", "}", "// loop special", "elseif", "(", "$", "commands", "[", "0", "]", "==", "'endloop'", ")", "{", "$", "commands", "[", "0", "]", "=", "'endfor'", ";", "}", "// check for semicolon", "if", "(", "substr", "(", "$", "commands", "[", "0", "]", ",", "0", ",", "1", ")", "!=", "';'", ")", "{", "$", "commands", "[", "0", "]", ".=", "';'", ";", "}", "}", "// bracket continue command", "elseif", "(", "count", "(", "$", "commands", "==", "1", ")", "&&", "in_array", "(", "$", "commands", "[", "0", "]", ",", "$", "this", "->", "bracket_continue_commands", ")", ")", "{", "// remove the opening duble point", "end", "(", "$", "commands", ")", ";", "$", "key", "=", "key", "(", "$", "commands", ")", ";", "if", "(", "substr", "(", "$", "commands", "[", "$", "key", "]", ",", "-", "1", ")", "==", "':'", ")", "{", "$", "commands", "[", "$", "key", "]", "=", "substr", "(", "$", "commands", "[", "$", "key", "]", ",", "0", ",", "-", "1", ")", ";", "// is it now empty?", "if", "(", "$", "commands", "[", "$", "key", "]", "==", "' '", "||", "empty", "(", "$", "commands", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "$", "commands", "[", "$", "key", "]", ")", ";", "}", "}", "// add the double point", "$", "commands", "[", "]", "=", "':'", ";", "}", "return", "implode", "(", "' '", ",", "$", "commands", ")", ";", "}" ]
Repair an expression
[ "Repair", "an", "expression" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCView/Builder/CCFTemplate.php#L102-L194
19,189
ClanCats/Core
src/classes/CCView/Builder/CCFTemplate.php
CCView_Builder_CCFTemplate.compile_phptag
private function compile_phptag( $view ) { // I hate this workaround $that = $this; return preg_replace_callback('/\{\%(.*?)\%\}/s', function( $match ) use( $that ) { $expression = trim( $match[1] ); // repair it $expression = $that->repair_expression( $expression ); return '<?php '.$expression.' ?>'; }, $view ); }
php
private function compile_phptag( $view ) { // I hate this workaround $that = $this; return preg_replace_callback('/\{\%(.*?)\%\}/s', function( $match ) use( $that ) { $expression = trim( $match[1] ); // repair it $expression = $that->repair_expression( $expression ); return '<?php '.$expression.' ?>'; }, $view ); }
[ "private", "function", "compile_phptag", "(", "$", "view", ")", "{", "// I hate this workaround", "$", "that", "=", "$", "this", ";", "return", "preg_replace_callback", "(", "'/\\{\\%(.*?)\\%\\}/s'", ",", "function", "(", "$", "match", ")", "use", "(", "$", "that", ")", "{", "$", "expression", "=", "trim", "(", "$", "match", "[", "1", "]", ")", ";", "// repair it ", "$", "expression", "=", "$", "that", "->", "repair_expression", "(", "$", "expression", ")", ";", "return", "'<?php '", ".", "$", "expression", ".", "' ?>'", ";", "}", ",", "$", "view", ")", ";", "}" ]
Search and replace for shortcuts of the php tag @param string $view @return void
[ "Search", "and", "replace", "for", "shortcuts", "of", "the", "php", "tag" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCView/Builder/CCFTemplate.php#L223-L237
19,190
ClanCats/Core
src/classes/CCView/Builder/CCFTemplate.php
CCView_Builder_CCFTemplate.compile_arrays
private function compile_arrays( $view ) { $tokens = token_get_all( $view ); $tags = array( 0 => '' ); $tag_index = 0; $in_tag = false; // parse all php tags out of the view foreach ( $tokens as $token ) { if ( is_array( $token ) ) { if ( $token[0] === T_OPEN_TAG ) { $in_tag = true; } if ( $in_tag && !in_array( $token[0], array( T_INLINE_HTML ) ) ) { $tags[$tag_index] .= $token[1]; } if ( $token[0] === T_CLOSE_TAG ) { $in_tag = false; $tag_index++; } } else { if ( $in_tag ) { $tags[$tag_index] .= $token; } } } // lets make the tags search keys $tags = array_flip( $tags ); // now search and replace var in the php sections foreach( $tags as $search => &$replace ) { $replace = preg_replace_callback('/(\$[a-zA-Z0-9\_\.\-\>\;]+)/s', function( $match ) { $var = $match[1]; if ( strpos( $var, '.' ) !== false ) { $buffer = ''; $length = strlen( $var ); $inside_arr = false; for( $i=0;$i<$length;$i++ ) { $char = $var[$i]; if ( $char == '.' && !$inside_arr ) { $buffer .= "['"; $inside_arr = true; } else { if ( $inside_arr && in_array( $char, array( ';', '-', ',' ) ) ) { $buffer .= "']"; $inside_arr = false; } if ( $char == '.' ) { $buffer .= "']['"; $inside_arr = true; } else { $buffer .= $char; } } } if ( $inside_arr ) { $buffer .= "']"; } $var = $buffer; } return $var; }, $search ); } return CCStr::replace( $view, $tags ); }
php
private function compile_arrays( $view ) { $tokens = token_get_all( $view ); $tags = array( 0 => '' ); $tag_index = 0; $in_tag = false; // parse all php tags out of the view foreach ( $tokens as $token ) { if ( is_array( $token ) ) { if ( $token[0] === T_OPEN_TAG ) { $in_tag = true; } if ( $in_tag && !in_array( $token[0], array( T_INLINE_HTML ) ) ) { $tags[$tag_index] .= $token[1]; } if ( $token[0] === T_CLOSE_TAG ) { $in_tag = false; $tag_index++; } } else { if ( $in_tag ) { $tags[$tag_index] .= $token; } } } // lets make the tags search keys $tags = array_flip( $tags ); // now search and replace var in the php sections foreach( $tags as $search => &$replace ) { $replace = preg_replace_callback('/(\$[a-zA-Z0-9\_\.\-\>\;]+)/s', function( $match ) { $var = $match[1]; if ( strpos( $var, '.' ) !== false ) { $buffer = ''; $length = strlen( $var ); $inside_arr = false; for( $i=0;$i<$length;$i++ ) { $char = $var[$i]; if ( $char == '.' && !$inside_arr ) { $buffer .= "['"; $inside_arr = true; } else { if ( $inside_arr && in_array( $char, array( ';', '-', ',' ) ) ) { $buffer .= "']"; $inside_arr = false; } if ( $char == '.' ) { $buffer .= "']['"; $inside_arr = true; } else { $buffer .= $char; } } } if ( $inside_arr ) { $buffer .= "']"; } $var = $buffer; } return $var; }, $search ); } return CCStr::replace( $view, $tags ); }
[ "private", "function", "compile_arrays", "(", "$", "view", ")", "{", "$", "tokens", "=", "token_get_all", "(", "$", "view", ")", ";", "$", "tags", "=", "array", "(", "0", "=>", "''", ")", ";", "$", "tag_index", "=", "0", ";", "$", "in_tag", "=", "false", ";", "// parse all php tags out of the view", "foreach", "(", "$", "tokens", "as", "$", "token", ")", "{", "if", "(", "is_array", "(", "$", "token", ")", ")", "{", "if", "(", "$", "token", "[", "0", "]", "===", "T_OPEN_TAG", ")", "{", "$", "in_tag", "=", "true", ";", "}", "if", "(", "$", "in_tag", "&&", "!", "in_array", "(", "$", "token", "[", "0", "]", ",", "array", "(", "T_INLINE_HTML", ")", ")", ")", "{", "$", "tags", "[", "$", "tag_index", "]", ".=", "$", "token", "[", "1", "]", ";", "}", "if", "(", "$", "token", "[", "0", "]", "===", "T_CLOSE_TAG", ")", "{", "$", "in_tag", "=", "false", ";", "$", "tag_index", "++", ";", "}", "}", "else", "{", "if", "(", "$", "in_tag", ")", "{", "$", "tags", "[", "$", "tag_index", "]", ".=", "$", "token", ";", "}", "}", "}", "// lets make the tags search keys", "$", "tags", "=", "array_flip", "(", "$", "tags", ")", ";", "// now search and replace var in the php sections", "foreach", "(", "$", "tags", "as", "$", "search", "=>", "&", "$", "replace", ")", "{", "$", "replace", "=", "preg_replace_callback", "(", "'/(\\$[a-zA-Z0-9\\_\\.\\-\\>\\;]+)/s'", ",", "function", "(", "$", "match", ")", "{", "$", "var", "=", "$", "match", "[", "1", "]", ";", "if", "(", "strpos", "(", "$", "var", ",", "'.'", ")", "!==", "false", ")", "{", "$", "buffer", "=", "''", ";", "$", "length", "=", "strlen", "(", "$", "var", ")", ";", "$", "inside_arr", "=", "false", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "length", ";", "$", "i", "++", ")", "{", "$", "char", "=", "$", "var", "[", "$", "i", "]", ";", "if", "(", "$", "char", "==", "'.'", "&&", "!", "$", "inside_arr", ")", "{", "$", "buffer", ".=", "\"['\"", ";", "$", "inside_arr", "=", "true", ";", "}", "else", "{", "if", "(", "$", "inside_arr", "&&", "in_array", "(", "$", "char", ",", "array", "(", "';'", ",", "'-'", ",", "','", ")", ")", ")", "{", "$", "buffer", ".=", "\"']\"", ";", "$", "inside_arr", "=", "false", ";", "}", "if", "(", "$", "char", "==", "'.'", ")", "{", "$", "buffer", ".=", "\"']['\"", ";", "$", "inside_arr", "=", "true", ";", "}", "else", "{", "$", "buffer", ".=", "$", "char", ";", "}", "}", "}", "if", "(", "$", "inside_arr", ")", "{", "$", "buffer", ".=", "\"']\"", ";", "}", "$", "var", "=", "$", "buffer", ";", "}", "return", "$", "var", ";", "}", ",", "$", "search", ")", ";", "}", "return", "CCStr", "::", "replace", "(", "$", "view", ",", "$", "tags", ")", ";", "}" ]
Search and replace vars with . array access @param string $view @return void
[ "Search", "and", "replace", "vars", "with", ".", "array", "access" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCView/Builder/CCFTemplate.php#L245-L342
19,191
anexia-it/anexia-laravel-encryption
src/DatabaseEncryption.php
DatabaseEncryption.performInsert
protected function performInsert(Builder $query) { $encryptedFields = static::getEncryptedFields(); if (count($encryptedFields) && !$this->getEncryptKey()) { throw new \RuntimeException("No encryption key specified"); } $originalAttributes = $this->attributes; foreach ($encryptedFields as $encryptedField) { if (isset($this->attributes[$encryptedField])) { $this->attributes[$encryptedField] = DB::raw(static::getEncryptionService()->getEncryptExpression($this->attributes[$encryptedField], static::getEncryptKey())); } } $inserted = parent::performInsert($query); // reset the attributes to the decrypted values foreach ($encryptedFields as $encryptedField) { if (isset($this->attributes[$encryptedField])) { $this->attributes[$encryptedField] = $originalAttributes[$encryptedField]; } } return $inserted; }
php
protected function performInsert(Builder $query) { $encryptedFields = static::getEncryptedFields(); if (count($encryptedFields) && !$this->getEncryptKey()) { throw new \RuntimeException("No encryption key specified"); } $originalAttributes = $this->attributes; foreach ($encryptedFields as $encryptedField) { if (isset($this->attributes[$encryptedField])) { $this->attributes[$encryptedField] = DB::raw(static::getEncryptionService()->getEncryptExpression($this->attributes[$encryptedField], static::getEncryptKey())); } } $inserted = parent::performInsert($query); // reset the attributes to the decrypted values foreach ($encryptedFields as $encryptedField) { if (isset($this->attributes[$encryptedField])) { $this->attributes[$encryptedField] = $originalAttributes[$encryptedField]; } } return $inserted; }
[ "protected", "function", "performInsert", "(", "Builder", "$", "query", ")", "{", "$", "encryptedFields", "=", "static", "::", "getEncryptedFields", "(", ")", ";", "if", "(", "count", "(", "$", "encryptedFields", ")", "&&", "!", "$", "this", "->", "getEncryptKey", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"No encryption key specified\"", ")", ";", "}", "$", "originalAttributes", "=", "$", "this", "->", "attributes", ";", "foreach", "(", "$", "encryptedFields", "as", "$", "encryptedField", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "attributes", "[", "$", "encryptedField", "]", ")", ")", "{", "$", "this", "->", "attributes", "[", "$", "encryptedField", "]", "=", "DB", "::", "raw", "(", "static", "::", "getEncryptionService", "(", ")", "->", "getEncryptExpression", "(", "$", "this", "->", "attributes", "[", "$", "encryptedField", "]", ",", "static", "::", "getEncryptKey", "(", ")", ")", ")", ";", "}", "}", "$", "inserted", "=", "parent", "::", "performInsert", "(", "$", "query", ")", ";", "// reset the attributes to the decrypted values", "foreach", "(", "$", "encryptedFields", "as", "$", "encryptedField", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "attributes", "[", "$", "encryptedField", "]", ")", ")", "{", "$", "this", "->", "attributes", "[", "$", "encryptedField", "]", "=", "$", "originalAttributes", "[", "$", "encryptedField", "]", ";", "}", "}", "return", "$", "inserted", ";", "}" ]
Perform insert with encryption @param Builder $query @return bool
[ "Perform", "insert", "with", "encryption" ]
b7c72d99916ebca2d2cf2dbab1d4c0f84e383081
https://github.com/anexia-it/anexia-laravel-encryption/blob/b7c72d99916ebca2d2cf2dbab1d4c0f84e383081/src/DatabaseEncryption.php#L59-L80
19,192
anexia-it/anexia-laravel-encryption
src/DatabaseEncryption.php
DatabaseEncryption.newBaseQueryBuilder
protected function newBaseQueryBuilder() { $connection = $this->getConnection(); return new DatabaseEncryptionQueryBuilder( $connection, $connection->getQueryGrammar(), $connection->getPostProcessor() ); }
php
protected function newBaseQueryBuilder() { $connection = $this->getConnection(); return new DatabaseEncryptionQueryBuilder( $connection, $connection->getQueryGrammar(), $connection->getPostProcessor() ); }
[ "protected", "function", "newBaseQueryBuilder", "(", ")", "{", "$", "connection", "=", "$", "this", "->", "getConnection", "(", ")", ";", "return", "new", "DatabaseEncryptionQueryBuilder", "(", "$", "connection", ",", "$", "connection", "->", "getQueryGrammar", "(", ")", ",", "$", "connection", "->", "getPostProcessor", "(", ")", ")", ";", "}" ]
Get a new query builder instance for the connection. Use the package's DatabaseEncryptionQueryBuilder. @return \Illuminate\Database\Query\Builder
[ "Get", "a", "new", "query", "builder", "instance", "for", "the", "connection", ".", "Use", "the", "package", "s", "DatabaseEncryptionQueryBuilder", "." ]
b7c72d99916ebca2d2cf2dbab1d4c0f84e383081
https://github.com/anexia-it/anexia-laravel-encryption/blob/b7c72d99916ebca2d2cf2dbab1d4c0f84e383081/src/DatabaseEncryption.php#L116-L123
19,193
ClanCats/Core
src/classes/CCOrbit.php
CCOrbit.installed_ships
public static function installed_ships() { $ships = static::$data->get( 'installed', array() ); foreach ( $ships as $key => $ship ) { $ships[$key] = CCROOT.$ship; } return $ships; }
php
public static function installed_ships() { $ships = static::$data->get( 'installed', array() ); foreach ( $ships as $key => $ship ) { $ships[$key] = CCROOT.$ship; } return $ships; }
[ "public", "static", "function", "installed_ships", "(", ")", "{", "$", "ships", "=", "static", "::", "$", "data", "->", "get", "(", "'installed'", ",", "array", "(", ")", ")", ";", "foreach", "(", "$", "ships", "as", "$", "key", "=>", "$", "ship", ")", "{", "$", "ships", "[", "$", "key", "]", "=", "CCROOT", ".", "$", "ship", ";", "}", "return", "$", "ships", ";", "}" ]
return all installed ships
[ "return", "all", "installed", "ships" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCOrbit.php#L85-L95
19,194
ClanCats/Core
src/classes/CCOrbit.php
CCOrbit.enter
public static function enter( $path ) { if ( !is_array( $path ) ) { $path = array( $path ); } foreach( $path as $ship ) { // load ship at path $ship = CCOrbit_Ship::create( $ship ); if ( array_key_exists( $ship->name, static::$ships ) ) { throw new CCException( "CCOrbit::enter - {$ship->name} ship already entered." ); } if ( $ship->wake !== false ) { $ship->event( $ship->wake ); } CCProfiler::check( "CCOrbit - ship {$ship->name} launched." ); // add to our loaded ships static::$ships[$ship->name] = $ship; } }
php
public static function enter( $path ) { if ( !is_array( $path ) ) { $path = array( $path ); } foreach( $path as $ship ) { // load ship at path $ship = CCOrbit_Ship::create( $ship ); if ( array_key_exists( $ship->name, static::$ships ) ) { throw new CCException( "CCOrbit::enter - {$ship->name} ship already entered." ); } if ( $ship->wake !== false ) { $ship->event( $ship->wake ); } CCProfiler::check( "CCOrbit - ship {$ship->name} launched." ); // add to our loaded ships static::$ships[$ship->name] = $ship; } }
[ "public", "static", "function", "enter", "(", "$", "path", ")", "{", "if", "(", "!", "is_array", "(", "$", "path", ")", ")", "{", "$", "path", "=", "array", "(", "$", "path", ")", ";", "}", "foreach", "(", "$", "path", "as", "$", "ship", ")", "{", "// load ship at path", "$", "ship", "=", "CCOrbit_Ship", "::", "create", "(", "$", "ship", ")", ";", "if", "(", "array_key_exists", "(", "$", "ship", "->", "name", ",", "static", "::", "$", "ships", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCOrbit::enter - {$ship->name} ship already entered.\"", ")", ";", "}", "if", "(", "$", "ship", "->", "wake", "!==", "false", ")", "{", "$", "ship", "->", "event", "(", "$", "ship", "->", "wake", ")", ";", "}", "CCProfiler", "::", "check", "(", "\"CCOrbit - ship {$ship->name} launched.\"", ")", ";", "// add to our loaded ships", "static", "::", "$", "ships", "[", "$", "ship", "->", "name", "]", "=", "$", "ship", ";", "}", "}" ]
Add a ship this loads the ship loader file @param string $path @return bool
[ "Add", "a", "ship", "this", "loads", "the", "ship", "loader", "file" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCOrbit.php#L162-L188
19,195
xinix-technology/norm
src/Norm/Model.php
Model.setId
public function setId($givenId) { if (!isset($this->id)) { $this->id = $givenId; } return $this->id; }
php
public function setId($givenId) { if (!isset($this->id)) { $this->id = $givenId; } return $this->id; }
[ "public", "function", "setId", "(", "$", "givenId", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "id", ")", ")", "{", "$", "this", "->", "id", "=", "$", "givenId", ";", "}", "return", "$", "this", "->", "id", ";", "}" ]
Set id of model. @return int|string
[ "Set", "id", "of", "model", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Model.php#L131-L137
19,196
xinix-technology/norm
src/Norm/Model.php
Model.dump
public function dump() { $attributes = array(); if ($this->id) { $attributes['$id'] = $this->id; } foreach ($this->attributes as $key => $value) { $schema = $this->schema($key); if (! empty($schema['transient'])) { continue; } $attributes[$key] = $value; } return $attributes; }
php
public function dump() { $attributes = array(); if ($this->id) { $attributes['$id'] = $this->id; } foreach ($this->attributes as $key => $value) { $schema = $this->schema($key); if (! empty($schema['transient'])) { continue; } $attributes[$key] = $value; } return $attributes; }
[ "public", "function", "dump", "(", ")", "{", "$", "attributes", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "id", ")", "{", "$", "attributes", "[", "'$id'", "]", "=", "$", "this", "->", "id", ";", "}", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "schema", "=", "$", "this", "->", "schema", "(", "$", "key", ")", ";", "if", "(", "!", "empty", "(", "$", "schema", "[", "'transient'", "]", ")", ")", "{", "continue", ";", "}", "$", "attributes", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "attributes", ";", "}" ]
Dump attributes raw data. @method dump @return array
[ "Dump", "attributes", "raw", "data", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Model.php#L180-L199
19,197
xinix-technology/norm
src/Norm/Model.php
Model.add
public function add($key, $value) { if (! isset($this->attributes[$key])) { $this->attributes[$key] = array(); } $this->attributes[$key][] = $value; return $this; }
php
public function add($key, $value) { if (! isset($this->attributes[$key])) { $this->attributes[$key] = array(); } $this->attributes[$key][] = $value; return $this; }
[ "public", "function", "add", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "attributes", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "attributes", "[", "$", "key", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "attributes", "[", "$", "key", "]", "[", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Add an attributes data. @method add @param string $key @param mixed $value
[ "Add", "an", "attributes", "data", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Model.php#L209-L218
19,198
xinix-technology/norm
src/Norm/Model.php
Model.clear
public function clear($key = null) { if (func_num_args() === 0) { $this->attributes = array(); } elseif ($key === '$id') { throw new Exception('[Norm/Model] Restricting clear for $id.'); } else { unset($this->attributes[$key]); } return $this; }
php
public function clear($key = null) { if (func_num_args() === 0) { $this->attributes = array(); } elseif ($key === '$id') { throw new Exception('[Norm/Model] Restricting clear for $id.'); } else { unset($this->attributes[$key]); } return $this; }
[ "public", "function", "clear", "(", "$", "key", "=", "null", ")", "{", "if", "(", "func_num_args", "(", ")", "===", "0", ")", "{", "$", "this", "->", "attributes", "=", "array", "(", ")", ";", "}", "elseif", "(", "$", "key", "===", "'$id'", ")", "{", "throw", "new", "Exception", "(", "'[Norm/Model] Restricting clear for $id.'", ")", ";", "}", "else", "{", "unset", "(", "$", "this", "->", "attributes", "[", "$", "key", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Clear attributes value. @method clear @param string $key @return \Norm\Model
[ "Clear", "attributes", "value", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Model.php#L252-L263
19,199
xinix-technology/norm
src/Norm/Model.php
Model.sync
public function sync($attributes) { if (isset($attributes['$id'])) { $this->state = static::STATE_ATTACHED; $this->id = $attributes['$id']; } else { foreach ($this->schema() as $key => $field) { if ($field->has('default')) { $attributes[$key] = $field['default']; } } $this->state = static::STATE_DETACHED; } $this->set($attributes); $this->populateOld(); }
php
public function sync($attributes) { if (isset($attributes['$id'])) { $this->state = static::STATE_ATTACHED; $this->id = $attributes['$id']; } else { foreach ($this->schema() as $key => $field) { if ($field->has('default')) { $attributes[$key] = $field['default']; } } $this->state = static::STATE_DETACHED; } $this->set($attributes); $this->populateOld(); }
[ "public", "function", "sync", "(", "$", "attributes", ")", "{", "if", "(", "isset", "(", "$", "attributes", "[", "'$id'", "]", ")", ")", "{", "$", "this", "->", "state", "=", "static", "::", "STATE_ATTACHED", ";", "$", "this", "->", "id", "=", "$", "attributes", "[", "'$id'", "]", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "schema", "(", ")", "as", "$", "key", "=>", "$", "field", ")", "{", "if", "(", "$", "field", "->", "has", "(", "'default'", ")", ")", "{", "$", "attributes", "[", "$", "key", "]", "=", "$", "field", "[", "'default'", "]", ";", "}", "}", "$", "this", "->", "state", "=", "static", "::", "STATE_DETACHED", ";", "}", "$", "this", "->", "set", "(", "$", "attributes", ")", ";", "$", "this", "->", "populateOld", "(", ")", ";", "}" ]
Sync the existing attributes with new values. After update or insert, this method used to modify the existing attributes. @param array $attributes @return void
[ "Sync", "the", "existing", "attributes", "with", "new", "values", ".", "After", "update", "or", "insert", "this", "method", "used", "to", "modify", "the", "existing", "attributes", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Model.php#L272-L289