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
partition
stringclasses
1 value
quazardous/ImageStack
src/ImageStack/ImageOptimizer/AbstractExternalImageOptimizer.php
AbstractExternalImageOptimizer.getTempnam
protected function getTempnam($variation, $extention) { $prefix = $this->getOption('tempnam_prefix', 'eio') . $variation; // tempnam() does not handle extension while (true) { $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $prefix . substr(md5(uniqid().rand()), 0, 8) . '.' . $extention; if (!is_file($filename)) { return $filename; } } }
php
protected function getTempnam($variation, $extention) { $prefix = $this->getOption('tempnam_prefix', 'eio') . $variation; // tempnam() does not handle extension while (true) { $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $prefix . substr(md5(uniqid().rand()), 0, 8) . '.' . $extention; if (!is_file($filename)) { return $filename; } } }
[ "protected", "function", "getTempnam", "(", "$", "variation", ",", "$", "extention", ")", "{", "$", "prefix", "=", "$", "this", "->", "getOption", "(", "'tempnam_prefix'", ",", "'eio'", ")", ".", "$", "variation", ";", "// tempnam() does not handle extension", ...
Get a non existing tempname. @param string $variation @return string
[ "Get", "a", "non", "existing", "tempname", "." ]
bca5632edfc7703300407984bbaefb3c91c1560c
https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/ImageOptimizer/AbstractExternalImageOptimizer.php#L39-L48
train
milejko/mmi
src/Mmi/Filter/NumberFormat.php
NumberFormat.filter
public function filter($value) { $value = number_format($value, $this->getDigits(), $this->getSeparator(), $this->getThousands()); if ($this->getTrimZeros() && strpos($value, $this->getSeparator())) { $tmp = rtrim($value, '0'); //iteracja po brakujących zerach for ($i = 0, $missing = $this->getTrimLeaveZeros() - ($this->getDigits() - (strlen($value) - strlen($tmp))); $i < $missing; $i++) { $tmp .= '0'; } $value = rtrim($tmp, '.,'); } return str_replace('-', '- ', $value); }
php
public function filter($value) { $value = number_format($value, $this->getDigits(), $this->getSeparator(), $this->getThousands()); if ($this->getTrimZeros() && strpos($value, $this->getSeparator())) { $tmp = rtrim($value, '0'); //iteracja po brakujących zerach for ($i = 0, $missing = $this->getTrimLeaveZeros() - ($this->getDigits() - (strlen($value) - strlen($tmp))); $i < $missing; $i++) { $tmp .= '0'; } $value = rtrim($tmp, '.,'); } return str_replace('-', '- ', $value); }
[ "public", "function", "filter", "(", "$", "value", ")", "{", "$", "value", "=", "number_format", "(", "$", "value", ",", "$", "this", "->", "getDigits", "(", ")", ",", "$", "this", "->", "getSeparator", "(", ")", ",", "$", "this", "->", "getThousands...
Filtruje zmienne numeryczne @param mixed $value wartość @throws \Mmi\App\KernelException jeśli filtrowanie $value nie jest możliwe @return mixed
[ "Filtruje", "zmienne", "numeryczne" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Filter/NumberFormat.php#L50-L62
train
quazardous/ImageStack
src/ImageStack/Image.php
Image.get_type_from_mime_type
public static function get_type_from_mime_type($mimeType) { $types = [ 'image/jpeg' => 'jpg', 'image/png' => 'png', 'image/gif' => 'gif', ]; if (isset($types[$mimeType])) return $types[$mimeType]; throw new ImageException(sprintf('Unsupported MIME type: %s', $mimeType), ImageException::UNSUPPORTED_MIME_TYPE); }
php
public static function get_type_from_mime_type($mimeType) { $types = [ 'image/jpeg' => 'jpg', 'image/png' => 'png', 'image/gif' => 'gif', ]; if (isset($types[$mimeType])) return $types[$mimeType]; throw new ImageException(sprintf('Unsupported MIME type: %s', $mimeType), ImageException::UNSUPPORTED_MIME_TYPE); }
[ "public", "static", "function", "get_type_from_mime_type", "(", "$", "mimeType", ")", "{", "$", "types", "=", "[", "'image/jpeg'", "=>", "'jpg'", ",", "'image/png'", "=>", "'png'", ",", "'image/gif'", "=>", "'gif'", ",", "]", ";", "if", "(", "isset", "(", ...
Get the image short type from the MIME type. @param string $mimeType @return string
[ "Get", "the", "image", "short", "type", "from", "the", "MIME", "type", "." ]
bca5632edfc7703300407984bbaefb3c91c1560c
https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/Image.php#L211-L219
train
peakphp/framework
src/Config/Cache/FileCache.php
FileCache.setCacheFileContent
protected function setCacheFileContent($key, $content, $ttl = 0) { $result = true; $filepath = $this->getCacheFilePath($key); $content = serialize($content); if (file_put_contents($filepath, $content) === false) { $result = false; } if ($result !== false) { $ttl = $ttl + time(); touch($filepath, $ttl); } return $result; }
php
protected function setCacheFileContent($key, $content, $ttl = 0) { $result = true; $filepath = $this->getCacheFilePath($key); $content = serialize($content); if (file_put_contents($filepath, $content) === false) { $result = false; } if ($result !== false) { $ttl = $ttl + time(); touch($filepath, $ttl); } return $result; }
[ "protected", "function", "setCacheFileContent", "(", "$", "key", ",", "$", "content", ",", "$", "ttl", "=", "0", ")", "{", "$", "result", "=", "true", ";", "$", "filepath", "=", "$", "this", "->", "getCacheFilePath", "(", "$", "key", ")", ";", "$", ...
Save cache key file content @param mixed $key @param mixed $content @param null|int|\DateInterval $ttl @return bool
[ "Save", "cache", "key", "file", "content" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Config/Cache/FileCache.php#L284-L299
train
honeybee/honeybee
src/Infrastructure/Workflow/Guard.php
Guard.accept
public function accept(StatefulSubjectInterface $subject) { $execution_context = $subject->getExecutionContext(); $parameters = $execution_context->getParameters(); if (is_array($parameters)) { $params = $parameters; } elseif (is_object($parameters) && is_callable(array($parameters, 'toArray'))) { $params = $parameters->toArray(); } else { throw new RuntimeError( 'The $subject->getExecutionContext()->getParameters() must return array or object with toArray method.' ); } $transition_acceptable = $this->expression_service->evaluate( $this->options->get('expression'), array_merge( $params, [ 'subject' => $subject, 'current_user' => $this->environment->getUser(), ] ) ); return (bool)$transition_acceptable; }
php
public function accept(StatefulSubjectInterface $subject) { $execution_context = $subject->getExecutionContext(); $parameters = $execution_context->getParameters(); if (is_array($parameters)) { $params = $parameters; } elseif (is_object($parameters) && is_callable(array($parameters, 'toArray'))) { $params = $parameters->toArray(); } else { throw new RuntimeError( 'The $subject->getExecutionContext()->getParameters() must return array or object with toArray method.' ); } $transition_acceptable = $this->expression_service->evaluate( $this->options->get('expression'), array_merge( $params, [ 'subject' => $subject, 'current_user' => $this->environment->getUser(), ] ) ); return (bool)$transition_acceptable; }
[ "public", "function", "accept", "(", "StatefulSubjectInterface", "$", "subject", ")", "{", "$", "execution_context", "=", "$", "subject", "->", "getExecutionContext", "(", ")", ";", "$", "parameters", "=", "$", "execution_context", "->", "getParameters", "(", ")...
Evaluates the configured expression for the given subject. The expression may use the current user as "current_user" and the subject as "subject". @param StatefulSubjectInterface $subject @return boolean true if transition is acceptable
[ "Evaluates", "the", "configured", "expression", "for", "the", "given", "subject", ".", "The", "expression", "may", "use", "the", "current", "user", "as", "current_user", "and", "the", "subject", "as", "subject", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Workflow/Guard.php#L60-L87
train
icewind1991/Streams
src/HashWrapper.php
HashWrapper.wrap
public static function wrap($source, $hash, $callback) { $context = [ 'hash' => $hash, 'callback' => $callback, ]; return self::wrapSource($source, $context); }
php
public static function wrap($source, $hash, $callback) { $context = [ 'hash' => $hash, 'callback' => $callback, ]; return self::wrapSource($source, $context); }
[ "public", "static", "function", "wrap", "(", "$", "source", ",", "$", "hash", ",", "$", "callback", ")", "{", "$", "context", "=", "[", "'hash'", "=>", "$", "hash", ",", "'callback'", "=>", "$", "callback", ",", "]", ";", "return", "self", "::", "w...
Wraps a stream to make it seekable @param resource $source @param string $hash @param callable $callback @return resource|bool @throws \BadMethodCallException
[ "Wraps", "a", "stream", "to", "make", "it", "seekable" ]
6c91d3e390736d9c8c27527f9c5667bc21dca571
https://github.com/icewind1991/Streams/blob/6c91d3e390736d9c8c27527f9c5667bc21dca571/src/HashWrapper.php#L49-L55
train
milejko/mmi
src/Mmi/Ldap/LdapClient.php
LdapClient.findUser
public function findUser($filter = '*', $limit = 100, array $searchFields = ['mail', 'cn', 'uid', 'sAMAccountname'], $dn = null) { //brak możliwości zalogowania if (!$this->authenticate($this->_config->user, $this->_config->password)) { throw new LdapException('Unable to find users due to "' . $this->_config->user . '" is not authorized'); } try { //budowanie filtra $searchString = '(|'; foreach ($searchFields as $field) { $searchString .= '(' . $field . '=' . $filter . ')'; } $searchString .= ')'; //odpowiedź z LDAP'a $rawResource = ldap_search($this->_getActiveServer(), $dn ? : 'dc=' . implode(',dc=', explode('.', $this->_config->domain)), $searchString); } catch (\Exception $e) { //puste return new LdapUserCollection; } //konwersja do obiektów return new LdapUserCollection(ldap_get_entries($this->_getActiveServer(), $rawResource), $limit); }
php
public function findUser($filter = '*', $limit = 100, array $searchFields = ['mail', 'cn', 'uid', 'sAMAccountname'], $dn = null) { //brak możliwości zalogowania if (!$this->authenticate($this->_config->user, $this->_config->password)) { throw new LdapException('Unable to find users due to "' . $this->_config->user . '" is not authorized'); } try { //budowanie filtra $searchString = '(|'; foreach ($searchFields as $field) { $searchString .= '(' . $field . '=' . $filter . ')'; } $searchString .= ')'; //odpowiedź z LDAP'a $rawResource = ldap_search($this->_getActiveServer(), $dn ? : 'dc=' . implode(',dc=', explode('.', $this->_config->domain)), $searchString); } catch (\Exception $e) { //puste return new LdapUserCollection; } //konwersja do obiektów return new LdapUserCollection(ldap_get_entries($this->_getActiveServer(), $rawResource), $limit); }
[ "public", "function", "findUser", "(", "$", "filter", "=", "'*'", ",", "$", "limit", "=", "100", ",", "array", "$", "searchFields", "=", "[", "'mail'", ",", "'cn'", ",", "'uid'", ",", "'sAMAccountname'", "]", ",", "$", "dn", "=", "null", ")", "{", ...
Znajduje po filtrze @param string $filter @param integer $limit @param string $dn opcjonalny dn @return \Mmi\LdapUserCollection
[ "Znajduje", "po", "filtrze" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Ldap/LdapClient.php#L79-L100
train
milejko/mmi
src/Mmi/Mvc/ViewHelper/HeadStyle.php
HeadStyle._filterCssFile
protected function _filterCssFile($fileName) { try { //pobranie kontentu $content = file_get_contents(BASE_PATH . '/web/' . $fileName); } catch (\Exception $e) { return '/* CSS file not found: ' . $fileName . ' */'; } //lokalizacja zasobów z uwzględnieniem baseUrl $location = $this->view->baseUrl . '/' . trim(dirname($fileName), '/') . '/'; //usuwanie nowych linii i tabów return preg_replace(['/\r\n/', '/\n/', '/\t/'], '', str_replace(['url(\'', 'url("'], ['url(\'' . $location, 'url("' . $location], $content)); }
php
protected function _filterCssFile($fileName) { try { //pobranie kontentu $content = file_get_contents(BASE_PATH . '/web/' . $fileName); } catch (\Exception $e) { return '/* CSS file not found: ' . $fileName . ' */'; } //lokalizacja zasobów z uwzględnieniem baseUrl $location = $this->view->baseUrl . '/' . trim(dirname($fileName), '/') . '/'; //usuwanie nowych linii i tabów return preg_replace(['/\r\n/', '/\n/', '/\t/'], '', str_replace(['url(\'', 'url("'], ['url(\'' . $location, 'url("' . $location], $content)); }
[ "protected", "function", "_filterCssFile", "(", "$", "fileName", ")", "{", "try", "{", "//pobranie kontentu", "$", "content", "=", "file_get_contents", "(", "BASE_PATH", ".", "'/web/'", ".", "$", "fileName", ")", ";", "}", "catch", "(", "\\", "Exception", "$...
Zwraca wyfiltrowany CSS @param string $fileName @return string
[ "Zwraca", "wyfiltrowany", "CSS" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadStyle.php#L176-L188
train
milejko/mmi
src/Mmi/Http/ResponseTypes.php
ResponseTypes.getMessageByCode
public static function getMessageByCode($code) { return isset(self::$_httpCodes[$code]) ? self::$_httpCodes[$code] : null; }
php
public static function getMessageByCode($code) { return isset(self::$_httpCodes[$code]) ? self::$_httpCodes[$code] : null; }
[ "public", "static", "function", "getMessageByCode", "(", "$", "code", ")", "{", "return", "isset", "(", "self", "::", "$", "_httpCodes", "[", "$", "code", "]", ")", "?", "self", "::", "$", "_httpCodes", "[", "$", "code", "]", ":", "null", ";", "}" ]
Pobiera komunikat HTTP po kodzie @param integer $code @return string
[ "Pobiera", "komunikat", "HTTP", "po", "kodzie" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Http/ResponseTypes.php#L134-L137
train
milejko/mmi
src/Mmi/Http/ResponseTypes.php
ResponseTypes.getExtensionByType
public static function getExtensionByType($type) { return empty($foundExtensions = array_keys(self::$_contentTypes, $type)) ? null : $foundExtensions[0]; }
php
public static function getExtensionByType($type) { return empty($foundExtensions = array_keys(self::$_contentTypes, $type)) ? null : $foundExtensions[0]; }
[ "public", "static", "function", "getExtensionByType", "(", "$", "type", ")", "{", "return", "empty", "(", "$", "foundExtensions", "=", "array_keys", "(", "self", "::", "$", "_contentTypes", ",", "$", "type", ")", ")", "?", "null", ":", "$", "foundExtension...
Znajduje rozszerzenie po typie mime @param string $type @return string
[ "Znajduje", "rozszerzenie", "po", "typie", "mime" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Http/ResponseTypes.php#L144-L147
train
milejko/mmi
src/Mmi/Http/ResponseTypes.php
ResponseTypes.searchType
public static function searchType($search) { //typ podany explicit if (self::getExtensionByType($search)) { return $search; } //typ znaleziony na podstawie rozszerzenia if (isset(self::$_contentTypes[$search])) { return self::$_contentTypes[$search]; } //typ nieodnaleziony throw new HttpException('Type not found'); }
php
public static function searchType($search) { //typ podany explicit if (self::getExtensionByType($search)) { return $search; } //typ znaleziony na podstawie rozszerzenia if (isset(self::$_contentTypes[$search])) { return self::$_contentTypes[$search]; } //typ nieodnaleziony throw new HttpException('Type not found'); }
[ "public", "static", "function", "searchType", "(", "$", "search", ")", "{", "//typ podany explicit", "if", "(", "self", "::", "getExtensionByType", "(", "$", "search", ")", ")", "{", "return", "$", "search", ";", "}", "//typ znaleziony na podstawie rozszerzenia", ...
Zwraca typ mime @param string $search typ lub rozszerzenie @return string @throws HttpException
[ "Zwraca", "typ", "mime" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Http/ResponseTypes.php#L155-L167
train
peakphp/framework
src/Common/Reflection/Annotations.php
Annotations.setClass
protected function setClass($class): void { // @todo fix logic about storing the classname $this->className = $class; if (is_object($class)) { $this->className = get_class($class); } $this->class = new ReflectionClass($class); }
php
protected function setClass($class): void { // @todo fix logic about storing the classname $this->className = $class; if (is_object($class)) { $this->className = get_class($class); } $this->class = new ReflectionClass($class); }
[ "protected", "function", "setClass", "(", "$", "class", ")", ":", "void", "{", "// @todo fix logic about storing the classname", "$", "this", "->", "className", "=", "$", "class", ";", "if", "(", "is_object", "(", "$", "class", ")", ")", "{", "$", "this", ...
Set the class name we want and load ReflectionClass @param mixed $class @throws ReflectionException
[ "Set", "the", "class", "name", "we", "want", "and", "load", "ReflectionClass" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Reflection/Annotations.php#L48-L56
train
peakphp/framework
src/Common/Reflection/Annotations.php
Annotations.getMethod
public function getMethod(string $methodName, $tags = '*'): array { try { $method = new ReflectionMethod($this->className, $methodName); } catch (ReflectionException $e) { return []; } return $this->parse($method->getDocComment(), $tags); }
php
public function getMethod(string $methodName, $tags = '*'): array { try { $method = new ReflectionMethod($this->className, $methodName); } catch (ReflectionException $e) { return []; } return $this->parse($method->getDocComment(), $tags); }
[ "public", "function", "getMethod", "(", "string", "$", "methodName", ",", "$", "tags", "=", "'*'", ")", ":", "array", "{", "try", "{", "$", "method", "=", "new", "ReflectionMethod", "(", "$", "this", "->", "className", ",", "$", "methodName", ")", ";",...
Get a methods annotation tags @param string $methodName @param string|array $tags Tag(s) to retrieve, by default($tags = '*'), it look for every tags @return array
[ "Get", "a", "methods", "annotation", "tags" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Reflection/Annotations.php#L65-L74
train
peakphp/framework
src/Common/Reflection/Annotations.php
Annotations.getAllMethods
public function getAllMethods($tags = '*'): array { $a = []; /** @var ReflectionMethod $m */ foreach ($this->class->getMethods() as $m) { $comment = $m->getDocComment(); $a = array_merge($a, [$m->name => $this->parse($comment, $tags)]); } return $a; }
php
public function getAllMethods($tags = '*'): array { $a = []; /** @var ReflectionMethod $m */ foreach ($this->class->getMethods() as $m) { $comment = $m->getDocComment(); $a = array_merge($a, [$m->name => $this->parse($comment, $tags)]); } return $a; }
[ "public", "function", "getAllMethods", "(", "$", "tags", "=", "'*'", ")", ":", "array", "{", "$", "a", "=", "[", "]", ";", "/** @var ReflectionMethod $m */", "foreach", "(", "$", "this", "->", "class", "->", "getMethods", "(", ")", "as", "$", "m", ")",...
Get all methods annotations tags @param mixed $tags Tag(s) to retrieve, by default($tags = '*'), it look for every tags @return array
[ "Get", "all", "methods", "annotations", "tags" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Reflection/Annotations.php#L82-L91
train
peakphp/framework
src/Common/Reflection/Annotations.php
Annotations.parse
public static function parse($string, $tags = '*'): array { //in case we don't have any tag to detect or an empty doc comment, we skip this method if (empty($tags) || empty($string)) { return []; } //check what is the type of $tags (array|string|wildcard) if (is_array($tags)) { $tags = '('.implode('|', $tags).')'; } elseif ($tags === '*') { $tags = '[a-zA-Z0-9]'; } else { $tags = '('.$tags.')'; } //find @[tag] [params...] $regex = '#\* @(?P<tag>'.$tags.'+)\s+((?P<data>[\s"a-zA-Z0-9\-$\\._/-^]+)){1,}#si'; preg_match_all($regex, $string, $matches, PREG_SET_ORDER); $final = []; if (isset($matches)) { $i = 0; foreach ($matches as $v) { $final[$i] = array('tag' => $v['tag'], 'data' => []); //detect here if we got a param with quote or not //since space is the separator between params, if a param need space(s), //it must be surrounded by " to be detected as 1 param $regex = '#(("(?<param>([^"]{1,}))")|(?<param2>([^"\s]{1,})))#i'; preg_match_all($regex, trim($v['data']), $matches_params, PREG_SET_ORDER); if (!empty($matches_params)) { foreach ($matches_params as $v) { if (!empty($v['param']) && !isset($v['param2'])) { $final[$i]['data'][] = $v['param']; } elseif (isset($v['param2']) && !empty($v['param2'])) { $final[$i]['data'][] = $v['param2']; } } } ++$i; } } return $final; }
php
public static function parse($string, $tags = '*'): array { //in case we don't have any tag to detect or an empty doc comment, we skip this method if (empty($tags) || empty($string)) { return []; } //check what is the type of $tags (array|string|wildcard) if (is_array($tags)) { $tags = '('.implode('|', $tags).')'; } elseif ($tags === '*') { $tags = '[a-zA-Z0-9]'; } else { $tags = '('.$tags.')'; } //find @[tag] [params...] $regex = '#\* @(?P<tag>'.$tags.'+)\s+((?P<data>[\s"a-zA-Z0-9\-$\\._/-^]+)){1,}#si'; preg_match_all($regex, $string, $matches, PREG_SET_ORDER); $final = []; if (isset($matches)) { $i = 0; foreach ($matches as $v) { $final[$i] = array('tag' => $v['tag'], 'data' => []); //detect here if we got a param with quote or not //since space is the separator between params, if a param need space(s), //it must be surrounded by " to be detected as 1 param $regex = '#(("(?<param>([^"]{1,}))")|(?<param2>([^"\s]{1,})))#i'; preg_match_all($regex, trim($v['data']), $matches_params, PREG_SET_ORDER); if (!empty($matches_params)) { foreach ($matches_params as $v) { if (!empty($v['param']) && !isset($v['param2'])) { $final[$i]['data'][] = $v['param']; } elseif (isset($v['param2']) && !empty($v['param2'])) { $final[$i]['data'][] = $v['param2']; } } } ++$i; } } return $final; }
[ "public", "static", "function", "parse", "(", "$", "string", ",", "$", "tags", "=", "'*'", ")", ":", "array", "{", "//in case we don't have any tag to detect or an empty doc comment, we skip this method", "if", "(", "empty", "(", "$", "tags", ")", "||", "empty", "...
Parse a doc comment string with annotations tag previously specified @param string $string Docblock string to parse @param string|array $tags Tag(s) to retrieve, by default($tags = '*'), it look for every tags @return array
[ "Parse", "a", "doc", "comment", "string", "with", "annotations", "tag", "previously", "specified" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Reflection/Annotations.php#L112-L160
train
quazardous/ImageStack
src/ImageStack/ImageManipulator/ThumbnailerImageManipulator.php
ThumbnailerImageManipulator.addThumbnailRule
public function addThumbnailRule(ThumbnailRuleInterface $thumbnailRule) { if ($thumbnailRule instanceof ImagineAwareInterface) { // not very LSP but handy if (!$thumbnailRule->getImagine()) { $thumbnailRule->setImagine($this->getImagine(), $this->getImagineOptions()); } } $this->thumbnailRules[] = $thumbnailRule; }
php
public function addThumbnailRule(ThumbnailRuleInterface $thumbnailRule) { if ($thumbnailRule instanceof ImagineAwareInterface) { // not very LSP but handy if (!$thumbnailRule->getImagine()) { $thumbnailRule->setImagine($this->getImagine(), $this->getImagineOptions()); } } $this->thumbnailRules[] = $thumbnailRule; }
[ "public", "function", "addThumbnailRule", "(", "ThumbnailRuleInterface", "$", "thumbnailRule", ")", "{", "if", "(", "$", "thumbnailRule", "instanceof", "ImagineAwareInterface", ")", "{", "// not very LSP but handy", "if", "(", "!", "$", "thumbnailRule", "->", "getImag...
Add a thumbnail rule. @param ThumbnailRuleInterface $thumbnailRule
[ "Add", "a", "thumbnail", "rule", "." ]
bca5632edfc7703300407984bbaefb3c91c1560c
https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/ImageManipulator/ThumbnailerImageManipulator.php#L52-L61
train
quazardous/ImageStack
src/ImageStack/ImageManipulator/ThumbnailerImageManipulator.php
ThumbnailerImageManipulator._manipulateImage
protected function _manipulateImage(ImageWithImagineInterface $image, ImagePathInterface $path) { foreach ($this->thumbnailRules as $thumbnailRule) { if ($thumbnailRule->thumbnailImage($image, $path)) { // successfully return at first match return; } } // default is to throw an error if no match. // End with an always matching rule to bypass. throw new ImageManipulatorException(sprintf('Cannot manipulate image: %s', $path->getPath()), ImageManipulatorException::CANNOT_MANIPULATE_IMAGE); }
php
protected function _manipulateImage(ImageWithImagineInterface $image, ImagePathInterface $path) { foreach ($this->thumbnailRules as $thumbnailRule) { if ($thumbnailRule->thumbnailImage($image, $path)) { // successfully return at first match return; } } // default is to throw an error if no match. // End with an always matching rule to bypass. throw new ImageManipulatorException(sprintf('Cannot manipulate image: %s', $path->getPath()), ImageManipulatorException::CANNOT_MANIPULATE_IMAGE); }
[ "protected", "function", "_manipulateImage", "(", "ImageWithImagineInterface", "$", "image", ",", "ImagePathInterface", "$", "path", ")", "{", "foreach", "(", "$", "this", "->", "thumbnailRules", "as", "$", "thumbnailRule", ")", "{", "if", "(", "$", "thumbnailRu...
Ensure use of ImageWithImagineInterface. @param ImageWithImagineInterface $image @param ImagePathInterface $path
[ "Ensure", "use", "of", "ImageWithImagineInterface", "." ]
bca5632edfc7703300407984bbaefb3c91c1560c
https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/ImageManipulator/ThumbnailerImageManipulator.php#L78-L89
train
milejko/mmi
src/Mmi/Db/Adapter/PdoAbstract.php
PdoAbstract.lastInsertId
public function lastInsertId($name = null) { //łączy jeśli niepołączony if (!$this->_connected) { $this->connect(); } return $this->_upstreamPdo->lastInsertId($name); }
php
public function lastInsertId($name = null) { //łączy jeśli niepołączony if (!$this->_connected) { $this->connect(); } return $this->_upstreamPdo->lastInsertId($name); }
[ "public", "function", "lastInsertId", "(", "$", "name", "=", "null", ")", "{", "//łączy jeśli niepołączony", "if", "(", "!", "$", "this", "->", "_connected", ")", "{", "$", "this", "->", "connect", "(", ")", ";", "}", "return", "$", "this", "->", "_ups...
Zwraca ostatnio wstawione ID @param string $name opcjonalnie nazwa serii (ważne w PostgreSQL) @return mixed
[ "Zwraca", "ostatnio", "wstawione", "ID" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Db/Adapter/PdoAbstract.php#L249-L256
train
milejko/mmi
src/Mmi/Db/Adapter/PdoAbstract.php
PdoAbstract.prepareLimit
public function prepareLimit($limit = null, $offset = null) { //wyjście jeśli brak limitu if (!($limit > 0)) { return; } //limit z offsetem if ($offset > 0) { return 'LIMIT ' . intval($offset) . ', ' . intval($limit); } //sam limit return 'LIMIT ' . intval($limit); }
php
public function prepareLimit($limit = null, $offset = null) { //wyjście jeśli brak limitu if (!($limit > 0)) { return; } //limit z offsetem if ($offset > 0) { return 'LIMIT ' . intval($offset) . ', ' . intval($limit); } //sam limit return 'LIMIT ' . intval($limit); }
[ "public", "function", "prepareLimit", "(", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "//wyjście jeśli brak limitu", "if", "(", "!", "(", "$", "limit", ">", "0", ")", ")", "{", "return", ";", "}", "//limit z offsetem", "if", ...
Tworzy warunek limit @param int $limit @param int $offset @return string
[ "Tworzy", "warunek", "limit" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Db/Adapter/PdoAbstract.php#L446-L458
train
milejko/mmi
src/Mmi/Db/Adapter/PdoAbstract.php
PdoAbstract._associateTableMeta
protected function _associateTableMeta(array $meta) { $associativeMeta = []; foreach ($meta as $column) { //przekształcanie odpowiedzi do standardowej postaci $associativeMeta[$column['name']] = [ 'dataType' => $column['dataType'], 'maxLength' => $column['maxLength'], 'null' => ($column['null'] == 'YES') ? true : false, 'default' => $column['default'] ]; } return $associativeMeta; }
php
protected function _associateTableMeta(array $meta) { $associativeMeta = []; foreach ($meta as $column) { //przekształcanie odpowiedzi do standardowej postaci $associativeMeta[$column['name']] = [ 'dataType' => $column['dataType'], 'maxLength' => $column['maxLength'], 'null' => ($column['null'] == 'YES') ? true : false, 'default' => $column['default'] ]; } return $associativeMeta; }
[ "protected", "function", "_associateTableMeta", "(", "array", "$", "meta", ")", "{", "$", "associativeMeta", "=", "[", "]", ";", "foreach", "(", "$", "meta", "as", "$", "column", ")", "{", "//przekształcanie odpowiedzi do standardowej postaci", "$", "associativeMe...
Konwertuje do tabeli asocjacyjnej meta dane tabel @param array $meta meta data @return array
[ "Konwertuje", "do", "tabeli", "asocjacyjnej", "meta", "dane", "tabel" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Db/Adapter/PdoAbstract.php#L485-L498
train
icewind1991/Streams
src/IteratorDirectory.php
IteratorDirectory.wrap
public static function wrap($source) { if ($source instanceof \Iterator) { $options = [ 'iterator' => $source ]; } else if (is_array($source)) { $options = [ 'array' => $source ]; } else { throw new \BadMethodCallException('$source should be an Iterator or array'); } return self::wrapSource(self::NO_SOURCE_DIR, $options); }
php
public static function wrap($source) { if ($source instanceof \Iterator) { $options = [ 'iterator' => $source ]; } else if (is_array($source)) { $options = [ 'array' => $source ]; } else { throw new \BadMethodCallException('$source should be an Iterator or array'); } return self::wrapSource(self::NO_SOURCE_DIR, $options); }
[ "public", "static", "function", "wrap", "(", "$", "source", ")", "{", "if", "(", "$", "source", "instanceof", "\\", "Iterator", ")", "{", "$", "options", "=", "[", "'iterator'", "=>", "$", "source", "]", ";", "}", "else", "if", "(", "is_array", "(", ...
Creates a directory handle from the provided array or iterator @param \Iterator | array $source @return resource|bool @throws \BadMethodCallException
[ "Creates", "a", "directory", "handle", "from", "the", "provided", "array", "or", "iterator" ]
6c91d3e390736d9c8c27527f9c5667bc21dca571
https://github.com/icewind1991/Streams/blob/6c91d3e390736d9c8c27527f9c5667bc21dca571/src/IteratorDirectory.php#L99-L112
train
sebastienheyd/hidden-captcha
src/HiddenCaptcha.php
HiddenCaptcha.render
public static function render($mustBeEmptyField = '_username') { $ts = time(); $random = Str::random(16); // Generate the token $token = [ 'timestamp' => $ts, 'session_id' => session()->getId(), 'ip' => request()->ip(), 'user_agent' => request()->header('User-Agent'), 'random_field_name' => $random, 'must_be_empty' => $mustBeEmptyField, ]; // Encrypt the token $token = Crypt::encrypt(serialize($token)); return (string) view('hiddenCaptcha::captcha', compact('mustBeEmptyField', 'ts', 'random', 'token')); }
php
public static function render($mustBeEmptyField = '_username') { $ts = time(); $random = Str::random(16); // Generate the token $token = [ 'timestamp' => $ts, 'session_id' => session()->getId(), 'ip' => request()->ip(), 'user_agent' => request()->header('User-Agent'), 'random_field_name' => $random, 'must_be_empty' => $mustBeEmptyField, ]; // Encrypt the token $token = Crypt::encrypt(serialize($token)); return (string) view('hiddenCaptcha::captcha', compact('mustBeEmptyField', 'ts', 'random', 'token')); }
[ "public", "static", "function", "render", "(", "$", "mustBeEmptyField", "=", "'_username'", ")", "{", "$", "ts", "=", "time", "(", ")", ";", "$", "random", "=", "Str", "::", "random", "(", "16", ")", ";", "// Generate the token", "$", "token", "=", "["...
Set the hidden captcha tags to put in your form. @param string $mustBeEmptyField @return string
[ "Set", "the", "hidden", "captcha", "tags", "to", "put", "in", "your", "form", "." ]
d6fc154f00703975194f8d667dccb519cc7f911b
https://github.com/sebastienheyd/hidden-captcha/blob/d6fc154f00703975194f8d667dccb519cc7f911b/src/HiddenCaptcha.php#L18-L37
train
sebastienheyd/hidden-captcha
src/HiddenCaptcha.php
HiddenCaptcha.check
public static function check(Validator $validator, $minLimit = 0, $maxLimit = 1200) { $formData = $validator->getData(); // Check post values if (!isset($formData['_captcha']) || !($token = self::getToken($formData['_captcha']))) { return false; } // Hidden "must be empty" field check if (!array_key_exists($token['must_be_empty'], $formData) || !empty($formData[$token['must_be_empty']])) { return false; } // Check time limits $now = time(); if ($now - $token['timestamp'] < $minLimit || $now - $token['timestamp'] > $maxLimit) { return false; } // Check the random posted field if (empty($formData[$token['random_field_name']])) { return false; } // Check if the random field value is similar to the token value $randomField = $formData[$token['random_field_name']]; if (!ctype_digit($randomField) || $token['timestamp'] != $randomField) { return false; } // Everything is ok, return true return true; }
php
public static function check(Validator $validator, $minLimit = 0, $maxLimit = 1200) { $formData = $validator->getData(); // Check post values if (!isset($formData['_captcha']) || !($token = self::getToken($formData['_captcha']))) { return false; } // Hidden "must be empty" field check if (!array_key_exists($token['must_be_empty'], $formData) || !empty($formData[$token['must_be_empty']])) { return false; } // Check time limits $now = time(); if ($now - $token['timestamp'] < $minLimit || $now - $token['timestamp'] > $maxLimit) { return false; } // Check the random posted field if (empty($formData[$token['random_field_name']])) { return false; } // Check if the random field value is similar to the token value $randomField = $formData[$token['random_field_name']]; if (!ctype_digit($randomField) || $token['timestamp'] != $randomField) { return false; } // Everything is ok, return true return true; }
[ "public", "static", "function", "check", "(", "Validator", "$", "validator", ",", "$", "minLimit", "=", "0", ",", "$", "maxLimit", "=", "1200", ")", "{", "$", "formData", "=", "$", "validator", "->", "getData", "(", ")", ";", "// Check post values", "if"...
Check the hidden captcha values. @param Validator $validator @param int $minLimit @param int $maxLimit @return bool
[ "Check", "the", "hidden", "captcha", "values", "." ]
d6fc154f00703975194f8d667dccb519cc7f911b
https://github.com/sebastienheyd/hidden-captcha/blob/d6fc154f00703975194f8d667dccb519cc7f911b/src/HiddenCaptcha.php#L48-L81
train
sebastienheyd/hidden-captcha
src/HiddenCaptcha.php
HiddenCaptcha.getToken
private static function getToken($captcha) { // Get the token values try { $token = Crypt::decrypt($captcha); } catch (\Exception $exception) { return false; } $token = @unserialize($token); // Token is null or unserializable if (!$token || !is_array($token) || empty($token)) { return false; } // Check token values if (empty($token['session_id']) || empty($token['ip']) || empty($token['user_agent']) || $token['session_id'] !== session()->getId() || $token['ip'] !== request()->ip() || $token['user_agent'] !== request()->header('User-Agent') ) { return false; } return $token; }
php
private static function getToken($captcha) { // Get the token values try { $token = Crypt::decrypt($captcha); } catch (\Exception $exception) { return false; } $token = @unserialize($token); // Token is null or unserializable if (!$token || !is_array($token) || empty($token)) { return false; } // Check token values if (empty($token['session_id']) || empty($token['ip']) || empty($token['user_agent']) || $token['session_id'] !== session()->getId() || $token['ip'] !== request()->ip() || $token['user_agent'] !== request()->header('User-Agent') ) { return false; } return $token; }
[ "private", "static", "function", "getToken", "(", "$", "captcha", ")", "{", "// Get the token values", "try", "{", "$", "token", "=", "Crypt", "::", "decrypt", "(", "$", "captcha", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{...
Get and check the token values. @param string $captcha @return string|bool
[ "Get", "and", "check", "the", "token", "values", "." ]
d6fc154f00703975194f8d667dccb519cc7f911b
https://github.com/sebastienheyd/hidden-captcha/blob/d6fc154f00703975194f8d667dccb519cc7f911b/src/HiddenCaptcha.php#L90-L118
train
milejko/mmi
src/Mmi/Mvc/Structure.php
Structure._parseActions
private static function _parseActions(array &$components, $controllerPath, $moduleName, $controllerName) { //łapanie nazw akcji w kodzie if (preg_match_all('/function ([a-zA-Z0-9]+Action)\(/', file_get_contents($controllerPath), $actions)) { foreach ($actions[1] as $action) { $components[$moduleName][$controllerName][substr($action, 0, -6)] = 1; } } }
php
private static function _parseActions(array &$components, $controllerPath, $moduleName, $controllerName) { //łapanie nazw akcji w kodzie if (preg_match_all('/function ([a-zA-Z0-9]+Action)\(/', file_get_contents($controllerPath), $actions)) { foreach ($actions[1] as $action) { $components[$moduleName][$controllerName][substr($action, 0, -6)] = 1; } } }
[ "private", "static", "function", "_parseActions", "(", "array", "&", "$", "components", ",", "$", "controllerPath", ",", "$", "moduleName", ",", "$", "controllerName", ")", "{", "//łapanie nazw akcji w kodzie", "if", "(", "preg_match_all", "(", "'/function ([a-zA-Z0...
Parsowanie akcji w kontrolerze @param array $components @param string $controllerPath @param string $moduleName @param string $controllerName
[ "Parsowanie", "akcji", "w", "kontrolerze" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/Structure.php#L130-L138
train
peakphp/framework
src/Common/Traits/ArrayMergeRecursiveDistinct.php
ArrayMergeRecursiveDistinct.arrayMergeRecursiveDistinct
protected function arrayMergeRecursiveDistinct(array $a, array $b, bool $mergeNumericKeys = false): array { $merged = $a; foreach($b as $key => $value) { if (!$mergeNumericKeys && is_numeric($key)) { $merged[] = $value; continue; } if (is_array($value) && array_key_exists($key, $merged) && is_array($merged[$key])) { $merged[$key] = $this->arrayMergeRecursiveDistinct($merged[$key], $value); } else { $merged[$key] = $value; } } return $merged; }
php
protected function arrayMergeRecursiveDistinct(array $a, array $b, bool $mergeNumericKeys = false): array { $merged = $a; foreach($b as $key => $value) { if (!$mergeNumericKeys && is_numeric($key)) { $merged[] = $value; continue; } if (is_array($value) && array_key_exists($key, $merged) && is_array($merged[$key])) { $merged[$key] = $this->arrayMergeRecursiveDistinct($merged[$key], $value); } else { $merged[$key] = $value; } } return $merged; }
[ "protected", "function", "arrayMergeRecursiveDistinct", "(", "array", "$", "a", ",", "array", "$", "b", ",", "bool", "$", "mergeNumericKeys", "=", "false", ")", ":", "array", "{", "$", "merged", "=", "$", "a", ";", "foreach", "(", "$", "b", "as", "$", ...
Merge 2 arrays recursively overwriting the keys in the first array if such key already exists @param array $a @param array $b @param bool $mergeNumericKeys add instead overwritten when index key is numeric @return array
[ "Merge", "2", "arrays", "recursively", "overwriting", "the", "keys", "in", "the", "first", "array", "if", "such", "key", "already", "exists" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Traits/ArrayMergeRecursiveDistinct.php#L20-L37
train
milejko/mmi
src/Mmi/Mvc/ViewHelper/HeadLink.php
HeadLink.appendStylesheet
public function appendStylesheet($href, $media = null, $conditional = '') { return $this->_setStylesheet($href, $media, false, $conditional); }
php
public function appendStylesheet($href, $media = null, $conditional = '') { return $this->_setStylesheet($href, $media, false, $conditional); }
[ "public", "function", "appendStylesheet", "(", "$", "href", ",", "$", "media", "=", "null", ",", "$", "conditional", "=", "''", ")", "{", "return", "$", "this", "->", "_setStylesheet", "(", "$", "href", ",", "$", "media", ",", "false", ",", "$", "con...
Dodaje styl CSS na koniec stosu @param string $href adres @param string $media media @param string $conditional warunek np. ie6 @return \Mmi\Mvc\ViewHelper\HeadLink
[ "Dodaje", "styl", "CSS", "na", "koniec", "stosu" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadLink.php#L91-L94
train
milejko/mmi
src/Mmi/Mvc/ViewHelper/HeadLink.php
HeadLink.appendAlternate
public function appendAlternate($href, $type, $title, $media = null, $conditional = '') { return $this->_setAlternate($href, $type, $title, $media, true, $conditional); }
php
public function appendAlternate($href, $type, $title, $media = null, $conditional = '') { return $this->_setAlternate($href, $type, $title, $media, true, $conditional); }
[ "public", "function", "appendAlternate", "(", "$", "href", ",", "$", "type", ",", "$", "title", ",", "$", "media", "=", "null", ",", "$", "conditional", "=", "''", ")", "{", "return", "$", "this", "->", "_setAlternate", "(", "$", "href", ",", "$", ...
Dodaje alternate na koniec stosu @param string $href adres @param string $type typ @param string $title tytuł @param string $media media @param string $conditional warunek np. ie6 @return \Mmi\Mvc\ViewHelper\HeadLink
[ "Dodaje", "alternate", "na", "koniec", "stosu" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadLink.php#L116-L119
train
milejko/mmi
src/Mmi/Mvc/ViewHelper/HeadLink.php
HeadLink._setStylesheet
protected function _setStylesheet($href, $media = null, $prepend = false, $conditional = '') { //obliczanie timestampa $ts = $this->_getLocationTimestamp($href); //określanie parametrów $params = ['rel' => 'stylesheet', 'type' => 'text/css', 'href' => $ts > 0 ? $this->_getPublicSrc($href) : $href, 'ts' => $ts]; if ($media) { $params['media'] = $media; } return $this->headLink($params, $prepend, $conditional); }
php
protected function _setStylesheet($href, $media = null, $prepend = false, $conditional = '') { //obliczanie timestampa $ts = $this->_getLocationTimestamp($href); //określanie parametrów $params = ['rel' => 'stylesheet', 'type' => 'text/css', 'href' => $ts > 0 ? $this->_getPublicSrc($href) : $href, 'ts' => $ts]; if ($media) { $params['media'] = $media; } return $this->headLink($params, $prepend, $conditional); }
[ "protected", "function", "_setStylesheet", "(", "$", "href", ",", "$", "media", "=", "null", ",", "$", "prepend", "=", "false", ",", "$", "conditional", "=", "''", ")", "{", "//obliczanie timestampa", "$", "ts", "=", "$", "this", "->", "_getLocationTimesta...
Dodaje styl CSS do stosu @param string $href adres @param string $media media @param boolean $prepend dodaj na początku stosu @param string $conditional warunek np. ie6 @return \Mmi\Mvc\ViewHelper\HeadLink
[ "Dodaje", "styl", "CSS", "do", "stosu" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadLink.php#L163-L173
train
milejko/mmi
src/Mmi/Mvc/ViewHelper/HeadLink.php
HeadLink._setAlternate
protected function _setAlternate($href, $type, $title, $media = null, $prepend = false, $conditional = '') { //określanie parametrów $params = ['rel' => 'alternate', 'type' => $type, 'title' => $title, 'href' => $href]; if ($media) { $params['media'] = $media; } return $this->headLink($params, $prepend, $conditional); }
php
protected function _setAlternate($href, $type, $title, $media = null, $prepend = false, $conditional = '') { //określanie parametrów $params = ['rel' => 'alternate', 'type' => $type, 'title' => $title, 'href' => $href]; if ($media) { $params['media'] = $media; } return $this->headLink($params, $prepend, $conditional); }
[ "protected", "function", "_setAlternate", "(", "$", "href", ",", "$", "type", ",", "$", "title", ",", "$", "media", "=", "null", ",", "$", "prepend", "=", "false", ",", "$", "conditional", "=", "''", ")", "{", "//określanie parametrów", "$", "params", ...
Dodaje alternate do stosu @param string $href adres @param string $type typ @param string $title tytuł @param string $media media @param boolean $prepend dodaj na początku stosu @param string $conditional warunek np. ie6 @return \Mmi\Mvc\ViewHelper\HeadLink
[ "Dodaje", "alternate", "do", "stosu" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadLink.php#L196-L204
train
milejko/mmi
src/Mmi/Orm/DbConnector.php
DbConnector.resetTableStructures
public static final function resetTableStructures() { //usunięcie struktrur z cache foreach (self::getAdapter()->tableList() as $tableName) { static::$_cache->remove('mmi-orm-structure-' . self::getAdapter()->getConfig()->name . '-' . $tableName); } //usunięcie lokalnie zapisanych struktur self::$_tableStructure = []; return true; }
php
public static final function resetTableStructures() { //usunięcie struktrur z cache foreach (self::getAdapter()->tableList() as $tableName) { static::$_cache->remove('mmi-orm-structure-' . self::getAdapter()->getConfig()->name . '-' . $tableName); } //usunięcie lokalnie zapisanych struktur self::$_tableStructure = []; return true; }
[ "public", "static", "final", "function", "resetTableStructures", "(", ")", "{", "//usunięcie struktrur z cache", "foreach", "(", "self", "::", "getAdapter", "(", ")", "->", "tableList", "(", ")", "as", "$", "tableName", ")", "{", "static", "::", "$", "_cache",...
Resetuje struktury tabel i usuwa cache @return boolean
[ "Resetuje", "struktury", "tabel", "i", "usuwa", "cache" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/DbConnector.php#L125-L134
train
milejko/mmi
src/Mmi/DataObject.php
DataObject.setParams
public function setParams(array $data = [], $reset = false) { if ($reset) { $this->_data = $data; } foreach ($data as $key => $value) { $this->__set($key, $value); } return $this; }
php
public function setParams(array $data = [], $reset = false) { if ($reset) { $this->_data = $data; } foreach ($data as $key => $value) { $this->__set($key, $value); } return $this; }
[ "public", "function", "setParams", "(", "array", "$", "data", "=", "[", "]", ",", "$", "reset", "=", "false", ")", "{", "if", "(", "$", "reset", ")", "{", "$", "this", "->", "_data", "=", "$", "data", ";", "}", "foreach", "(", "$", "data", "as"...
Ustawia wszystkie zmienne @param array $data parametry @param bool $reset usuwa wcześniej istniejące parametry @return \Mmi\DataObject
[ "Ustawia", "wszystkie", "zmienne" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/DataObject.php#L76-L85
train
honeybee/honeybee
src/Infrastructure/Config/Settings.php
Settings.toArray
public function toArray() { $data = array(); foreach ($this as $key => $value) { if (is_object($value)) { if (!is_callable(array($value, 'toArray'))) { throw new RuntimeException('Object does not implement toArray() method on key: ' . $key); } $data[$key] = $value->toArray(); } else { $data[$key] = $value; } } return $data; }
php
public function toArray() { $data = array(); foreach ($this as $key => $value) { if (is_object($value)) { if (!is_callable(array($value, 'toArray'))) { throw new RuntimeException('Object does not implement toArray() method on key: ' . $key); } $data[$key] = $value->toArray(); } else { $data[$key] = $value; } } return $data; }
[ "public", "function", "toArray", "(", ")", "{", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "if", "(", "!", "...
Returns the data as an associative array. @return array with all data @throws BadValueException when no toArray method is available on an object value
[ "Returns", "the", "data", "as", "an", "associative", "array", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Config/Settings.php#L130-L146
train
honeybee/honeybee
src/Infrastructure/Config/Settings.php
Settings.offsetSet
public function offsetSet($key, $data) { if (!$this->allow_modification) { throw new RuntimeException('Attempting to write to an immutable array'); } if (isset($data) && is_array($data)) { $data = new static($data); } return parent::offsetSet($key, $data); }
php
public function offsetSet($key, $data) { if (!$this->allow_modification) { throw new RuntimeException('Attempting to write to an immutable array'); } if (isset($data) && is_array($data)) { $data = new static($data); } return parent::offsetSet($key, $data); }
[ "public", "function", "offsetSet", "(", "$", "key", ",", "$", "data", ")", "{", "if", "(", "!", "$", "this", "->", "allow_modification", ")", "{", "throw", "new", "RuntimeException", "(", "'Attempting to write to an immutable array'", ")", ";", "}", "if", "(...
Sets the given data on the specified key. @param mixed $key name of key to set @param mixed $data data to set for the given key @return void @throws RuntimeException on write attempt when modification is forbidden
[ "Sets", "the", "given", "data", "on", "the", "specified", "key", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Config/Settings.php#L180-L191
train
honeybee/honeybee
src/Infrastructure/Config/Settings.php
Settings.offsetUnset
public function offsetUnset($key) { if (!$this->allow_modification) { throw new RuntimeException('Attempting to unset key on an immutable array'); } if ($this->offsetExists($key)) { parent::offsetUnset($key); } }
php
public function offsetUnset($key) { if (!$this->allow_modification) { throw new RuntimeException('Attempting to unset key on an immutable array'); } if ($this->offsetExists($key)) { parent::offsetUnset($key); } }
[ "public", "function", "offsetUnset", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "allow_modification", ")", "{", "throw", "new", "RuntimeException", "(", "'Attempting to unset key on an immutable array'", ")", ";", "}", "if", "(", "$", "this"...
Unsets the value of the given key. @param mixed key key to remove @return void @throws RuntimeException on write attempt when modification is forbidden
[ "Unsets", "the", "value", "of", "the", "given", "key", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Config/Settings.php#L246-L255
train
honeybee/honeybee
src/Infrastructure/Workflow/XmlStateMachineBuilder.php
XmlStateMachineBuilder.parseStateMachineDefitions
protected function parseStateMachineDefitions() { $defs = $this->getOption('state_machine_definition'); if ($defs instanceof ImmutableOptionsInterface) { return $defs->toArray(); } elseif (is_array($defs)) { return $defs; } if (!is_string($defs)) { throw new RuntimeError( 'Option "state_machine_definition" must be a path to an xml file ' . 'or already parsed definitions provided as an array.' ); } $parser = new StateMachineDefinitionParser(); return $parser->parse($defs); }
php
protected function parseStateMachineDefitions() { $defs = $this->getOption('state_machine_definition'); if ($defs instanceof ImmutableOptionsInterface) { return $defs->toArray(); } elseif (is_array($defs)) { return $defs; } if (!is_string($defs)) { throw new RuntimeError( 'Option "state_machine_definition" must be a path to an xml file ' . 'or already parsed definitions provided as an array.' ); } $parser = new StateMachineDefinitionParser(); return $parser->parse($defs); }
[ "protected", "function", "parseStateMachineDefitions", "(", ")", "{", "$", "defs", "=", "$", "this", "->", "getOption", "(", "'state_machine_definition'", ")", ";", "if", "(", "$", "defs", "instanceof", "ImmutableOptionsInterface", ")", "{", "return", "$", "defs...
Parses the configured state machine definition file and returns all parsed state machine definitions. @return array An assoc array with name of a state machine as key and the state machine def as value.
[ "Parses", "the", "configured", "state", "machine", "definition", "file", "and", "returns", "all", "parsed", "state", "machine", "definitions", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Workflow/XmlStateMachineBuilder.php#L41-L59
train
honeybee/honeybee
src/Infrastructure/Workflow/XmlStateMachineBuilder.php
XmlStateMachineBuilder.createState
protected function createState(array $state_definition) { $state_implementor = isset($state_definition['class']) ? $state_definition['class'] : State::CLASS; $this->loadStateImplementor($state_implementor); $state = $this->service_locator->make( $state_implementor, [ ':name' => $state_definition['name'], ':type' => $state_definition['type'], ':options' => $state_definition['options'], ] ); if (!$state instanceof StateInterface) { throw new RuntimeError( sprintf( 'Configured implementor "%s" for state "%s" must implement: %s', $state_implementor, $state_definition['name'], StateInterface::CLASS ) ); } return $state; }
php
protected function createState(array $state_definition) { $state_implementor = isset($state_definition['class']) ? $state_definition['class'] : State::CLASS; $this->loadStateImplementor($state_implementor); $state = $this->service_locator->make( $state_implementor, [ ':name' => $state_definition['name'], ':type' => $state_definition['type'], ':options' => $state_definition['options'], ] ); if (!$state instanceof StateInterface) { throw new RuntimeError( sprintf( 'Configured implementor "%s" for state "%s" must implement: %s', $state_implementor, $state_definition['name'], StateInterface::CLASS ) ); } return $state; }
[ "protected", "function", "createState", "(", "array", "$", "state_definition", ")", "{", "$", "state_implementor", "=", "isset", "(", "$", "state_definition", "[", "'class'", "]", ")", "?", "$", "state_definition", "[", "'class'", "]", ":", "State", "::", "C...
Creates a concrete StateInterface instance based on the given state definition. @param array $state_definition @return StateInterface
[ "Creates", "a", "concrete", "StateInterface", "instance", "based", "on", "the", "given", "state", "definition", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Workflow/XmlStateMachineBuilder.php#L68-L94
train
honeybee/honeybee
src/Infrastructure/Workflow/XmlStateMachineBuilder.php
XmlStateMachineBuilder.createTransition
protected function createTransition($state_name, array $transition_definition) { $target = $transition_definition['outgoing_state_name']; $guard_definition = $transition_definition['guard']; $guard = null; if ($guard_definition) { $guard = $this->service_locator->make( $guard_definition['class'], [ ':options' => $guard_definition['options'], ] ); if (!$guard instanceof GuardInterface) { throw new RuntimeError( sprintf( "Given transition guard '%s' must implement: %s", $guard_definition['class'], GuardInterface::CLASS ) ); } } return new Transition($state_name, $target, $guard); }
php
protected function createTransition($state_name, array $transition_definition) { $target = $transition_definition['outgoing_state_name']; $guard_definition = $transition_definition['guard']; $guard = null; if ($guard_definition) { $guard = $this->service_locator->make( $guard_definition['class'], [ ':options' => $guard_definition['options'], ] ); if (!$guard instanceof GuardInterface) { throw new RuntimeError( sprintf( "Given transition guard '%s' must implement: %s", $guard_definition['class'], GuardInterface::CLASS ) ); } } return new Transition($state_name, $target, $guard); }
[ "protected", "function", "createTransition", "(", "$", "state_name", ",", "array", "$", "transition_definition", ")", "{", "$", "target", "=", "$", "transition_definition", "[", "'outgoing_state_name'", "]", ";", "$", "guard_definition", "=", "$", "transition_defini...
Creates a state transition from the given transition definition. @param string $state_name @param array $transition_definition @return Workflux\Transition\TransitionInterface
[ "Creates", "a", "state", "transition", "from", "the", "given", "transition", "definition", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Workflow/XmlStateMachineBuilder.php#L104-L130
train
honeybee/honeybee
src/Infrastructure/Workflow/XmlStateMachineBuilder.php
XmlStateMachineBuilder.setStateMachineName
public function setStateMachineName($state_machine_name) { $name_regex = '/^[a-zA-Z0-9_\.\-]+$/'; if (!preg_match($name_regex, $state_machine_name)) { throw new VerificationError( 'Only valid characters for state machine names are [a-zA-Z.-_]. Given: ' . $state_machine_name ); } $this->state_machine_name = $state_machine_name; return $this; }
php
public function setStateMachineName($state_machine_name) { $name_regex = '/^[a-zA-Z0-9_\.\-]+$/'; if (!preg_match($name_regex, $state_machine_name)) { throw new VerificationError( 'Only valid characters for state machine names are [a-zA-Z.-_]. Given: ' . $state_machine_name ); } $this->state_machine_name = $state_machine_name; return $this; }
[ "public", "function", "setStateMachineName", "(", "$", "state_machine_name", ")", "{", "$", "name_regex", "=", "'/^[a-zA-Z0-9_\\.\\-]+$/'", ";", "if", "(", "!", "preg_match", "(", "$", "name_regex", ",", "$", "state_machine_name", ")", ")", "{", "throw", "new", ...
Sets the state machine's name. @param string $state_machine_name @return Workflux\Builder\StateMachineBuilderInterface
[ "Sets", "the", "state", "machine", "s", "name", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Workflow/XmlStateMachineBuilder.php#L139-L152
train
milejko/mmi
src/Mmi/Model/Dto.php
Dto.setFromArray
public final function setFromArray(array $data) { //iteracja po danych foreach ($data as $key => $value) { //własność nie istnieje if (!property_exists($this, $key)) { continue; } $this->{$key} = is_string($value) ? trim($value) : $value; } //iteracja po zamiennikach foreach ($this->_replacementFields as $recordKey => $dtoKey) { if (!is_array($dtoKey)) { $dtoKey = [$dtoKey]; } //obsługa wielu zastąpień z jednego klucza rekordu foreach ($dtoKey as $dKey) { //własność nie istnieje if (!property_exists($this, $dKey)) { continue; } if (!array_key_exists($recordKey, $data)) { continue; } $this->$dKey = trim($data[$recordKey]); } } return $this; }
php
public final function setFromArray(array $data) { //iteracja po danych foreach ($data as $key => $value) { //własność nie istnieje if (!property_exists($this, $key)) { continue; } $this->{$key} = is_string($value) ? trim($value) : $value; } //iteracja po zamiennikach foreach ($this->_replacementFields as $recordKey => $dtoKey) { if (!is_array($dtoKey)) { $dtoKey = [$dtoKey]; } //obsługa wielu zastąpień z jednego klucza rekordu foreach ($dtoKey as $dKey) { //własność nie istnieje if (!property_exists($this, $dKey)) { continue; } if (!array_key_exists($recordKey, $data)) { continue; } $this->$dKey = trim($data[$recordKey]); } } return $this; }
[ "public", "final", "function", "setFromArray", "(", "array", "$", "data", ")", "{", "//iteracja po danych", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "//własność nie istnieje", "if", "(", "!", "property_exists", "(", "$", ...
Ustawia obiekt DTO na podstawie tabeli @param array $data @return \Mmi\Model\Api\Dto
[ "Ustawia", "obiekt", "DTO", "na", "podstawie", "tabeli" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Model/Dto.php#L57-L85
train
milejko/mmi
src/Mmi/App/Bootstrap.php
Bootstrap._setupLocalCache
protected function _setupLocalCache() { //brak konfiguracji cache if (!\App\Registry::$config->localCache) { \App\Registry::$config->localCache = new \Mmi\Cache\CacheConfig; \App\Registry::$config->localCache->active = 0; } //ustawienie bufora systemowy aplikacji FrontController::getInstance()->setLocalCache(new \Mmi\Cache\Cache(\App\Registry::$config->localCache)); //wstrzyknięcie cache do ORM \Mmi\Orm\DbConnector::setCache(FrontController::getInstance()->getLocalCache()); return $this; }
php
protected function _setupLocalCache() { //brak konfiguracji cache if (!\App\Registry::$config->localCache) { \App\Registry::$config->localCache = new \Mmi\Cache\CacheConfig; \App\Registry::$config->localCache->active = 0; } //ustawienie bufora systemowy aplikacji FrontController::getInstance()->setLocalCache(new \Mmi\Cache\Cache(\App\Registry::$config->localCache)); //wstrzyknięcie cache do ORM \Mmi\Orm\DbConnector::setCache(FrontController::getInstance()->getLocalCache()); return $this; }
[ "protected", "function", "_setupLocalCache", "(", ")", "{", "//brak konfiguracji cache", "if", "(", "!", "\\", "App", "\\", "Registry", "::", "$", "config", "->", "localCache", ")", "{", "\\", "App", "\\", "Registry", "::", "$", "config", "->", "localCache",...
Inicjalizacja bufora FrontControllera @return \Mmi\App\Bootstrap
[ "Inicjalizacja", "bufora", "FrontControllera" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/App/Bootstrap.php#L145-L157
train
milejko/mmi
src/Mmi/App/Bootstrap.php
Bootstrap._setupFrontController
protected function _setupFrontController(\Mmi\Mvc\Router $router, \Mmi\Mvc\View $view) { //inicjalizacja frontu $frontController = FrontController::getInstance(); //wczytywanie struktury frontu z cache if (null === ($frontStructure = FrontController::getInstance()->getLocalCache()->load($cacheKey = 'mmi-structure'))) { FrontController::getInstance()->getLocalCache()->save($frontStructure = \Mmi\Mvc\Structure::getStructure(), $cacheKey, 0); } //konfiguracja frontu FrontController::getInstance()->setStructure($frontStructure) //ustawienie routera ->setRouter($router) //ustawienie widoku ->setView($view) //włączenie (lub nie) debugera ->getResponse()->setDebug(\App\Registry::$config->debug); //rejestracja pluginów foreach (\App\Registry::$config->plugins as $plugin) { $frontController->registerPlugin(new $plugin()); } return $this; }
php
protected function _setupFrontController(\Mmi\Mvc\Router $router, \Mmi\Mvc\View $view) { //inicjalizacja frontu $frontController = FrontController::getInstance(); //wczytywanie struktury frontu z cache if (null === ($frontStructure = FrontController::getInstance()->getLocalCache()->load($cacheKey = 'mmi-structure'))) { FrontController::getInstance()->getLocalCache()->save($frontStructure = \Mmi\Mvc\Structure::getStructure(), $cacheKey, 0); } //konfiguracja frontu FrontController::getInstance()->setStructure($frontStructure) //ustawienie routera ->setRouter($router) //ustawienie widoku ->setView($view) //włączenie (lub nie) debugera ->getResponse()->setDebug(\App\Registry::$config->debug); //rejestracja pluginów foreach (\App\Registry::$config->plugins as $plugin) { $frontController->registerPlugin(new $plugin()); } return $this; }
[ "protected", "function", "_setupFrontController", "(", "\\", "Mmi", "\\", "Mvc", "\\", "Router", "$", "router", ",", "\\", "Mmi", "\\", "Mvc", "\\", "View", "$", "view", ")", "{", "//inicjalizacja frontu", "$", "frontController", "=", "FrontController", "::", ...
Ustawianie front controllera @param \Mmi\Mvc\Router $router @param \Mmi\Mvc\View $view @return \Mmi\App\Bootstrap
[ "Ustawianie", "front", "controllera" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/App/Bootstrap.php#L204-L225
train
milejko/mmi
src/Mmi/Cache/Cache.php
Cache.remove
public function remove($key) { //bufor nieaktywny if (!$this->isActive()) { return true; } //usunięcie z rejestru $this->getRegistry()->unsetOption($key); //usunięcie handlerem return (bool)$this->_handler->delete($key); }
php
public function remove($key) { //bufor nieaktywny if (!$this->isActive()) { return true; } //usunięcie z rejestru $this->getRegistry()->unsetOption($key); //usunięcie handlerem return (bool)$this->_handler->delete($key); }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "//bufor nieaktywny", "if", "(", "!", "$", "this", "->", "isActive", "(", ")", ")", "{", "return", "true", ";", "}", "//usunięcie z rejestru", "$", "this", "->", "getRegistry", "(", ")", "->", ...
Usuwanie danych z bufora na podstawie klucza @param string $key klucz @return boolean @throws CacheException
[ "Usuwanie", "danych", "z", "bufora", "na", "podstawie", "klucza" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Cache/Cache.php#L114-L124
train
milejko/mmi
src/Mmi/Cache/Cache.php
Cache.flush
public function flush() { //bufor nieaktywny if (!$this->isActive()) { return; } //czyszczenie rejestru $this->getRegistry()->setOptions([], true); //czyszczenie do handler $this->_handler->deleteAll(); }
php
public function flush() { //bufor nieaktywny if (!$this->isActive()) { return; } //czyszczenie rejestru $this->getRegistry()->setOptions([], true); //czyszczenie do handler $this->_handler->deleteAll(); }
[ "public", "function", "flush", "(", ")", "{", "//bufor nieaktywny", "if", "(", "!", "$", "this", "->", "isActive", "(", ")", ")", "{", "return", ";", "}", "//czyszczenie rejestru", "$", "this", "->", "getRegistry", "(", ")", "->", "setOptions", "(", "[",...
Usuwa wszystkie dane z bufora
[ "Usuwa", "wszystkie", "dane", "z", "bufora" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Cache/Cache.php#L129-L139
train
honeybee/honeybee
src/Entity.php
Entity.getScopeKey
public function getScopeKey() { $parent_attribute = $this->getType()->getParentAttribute(); $scope_key_pieces = []; if ($parent_attribute) { $scope_key_pieces[] = $this->getRoot()->getType()->getScopeKey(); if ($workflow_state = $this->getRoot()->getWorkflowState()) { $scope_key_pieces[] = $workflow_state; } $scope_key_pieces[] = $parent_attribute->getPath(); $scope_key_pieces[] = $this->getType()->getPrefix(); } else { $scope_key_pieces[] = $this->getType()->getScopeKey(); if ($workflow_state = $this->getWorkflowState()) { $scope_key_pieces[] = $workflow_state; } } return implode(self::SCOPE_KEY_SEPARATOR, $scope_key_pieces); }
php
public function getScopeKey() { $parent_attribute = $this->getType()->getParentAttribute(); $scope_key_pieces = []; if ($parent_attribute) { $scope_key_pieces[] = $this->getRoot()->getType()->getScopeKey(); if ($workflow_state = $this->getRoot()->getWorkflowState()) { $scope_key_pieces[] = $workflow_state; } $scope_key_pieces[] = $parent_attribute->getPath(); $scope_key_pieces[] = $this->getType()->getPrefix(); } else { $scope_key_pieces[] = $this->getType()->getScopeKey(); if ($workflow_state = $this->getWorkflowState()) { $scope_key_pieces[] = $workflow_state; } } return implode(self::SCOPE_KEY_SEPARATOR, $scope_key_pieces); }
[ "public", "function", "getScopeKey", "(", ")", "{", "$", "parent_attribute", "=", "$", "this", "->", "getType", "(", ")", "->", "getParentAttribute", "(", ")", ";", "$", "scope_key_pieces", "=", "[", "]", ";", "if", "(", "$", "parent_attribute", ")", "{"...
Return the 'honeybee' scope that adresses the current entity. @return string
[ "Return", "the", "honeybee", "scope", "that", "adresses", "the", "current", "entity", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Entity.php#L42-L62
train
honeybee/honeybee
src/Common/Util/StringToolkit.php
StringToolkit.getAsString
public static function getAsString($var) { if ($var instanceof Exception) { return (string)$var; } elseif (is_object($var)) { return self::getObjectAsString($var); } elseif (is_array($var)) { return print_r($var, true); } elseif (is_resource($var)) { return (string)sprintf('resource(type=%s)', get_resource_type($var)); } elseif (true === $var) { return 'true'; } elseif (false === $var) { return 'false'; } elseif (null === $var) { return 'null'; } return (string)$var; }
php
public static function getAsString($var) { if ($var instanceof Exception) { return (string)$var; } elseif (is_object($var)) { return self::getObjectAsString($var); } elseif (is_array($var)) { return print_r($var, true); } elseif (is_resource($var)) { return (string)sprintf('resource(type=%s)', get_resource_type($var)); } elseif (true === $var) { return 'true'; } elseif (false === $var) { return 'false'; } elseif (null === $var) { return 'null'; } return (string)$var; }
[ "public", "static", "function", "getAsString", "(", "$", "var", ")", "{", "if", "(", "$", "var", "instanceof", "Exception", ")", "{", "return", "(", "string", ")", "$", "var", ";", "}", "elseif", "(", "is_object", "(", "$", "var", ")", ")", "{", "r...
Returns a string representation for the given argument. Specifically handles known scalars or types like exceptions and entities. @param mixed $var object, array or string to create textual representation for @return string for the given argument
[ "Returns", "a", "string", "representation", "for", "the", "given", "argument", ".", "Specifically", "handles", "known", "scalars", "or", "types", "like", "exceptions", "and", "entities", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Common/Util/StringToolkit.php#L113-L132
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getMinHostHex
public function getMinHostHex() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_HEX, $quad); }, $this->quads )); } return $this->minHostCalculation(self::FORMAT_HEX); }
php
public function getMinHostHex() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_HEX, $quad); }, $this->quads )); } return $this->minHostCalculation(self::FORMAT_HEX); }
[ "public", "function", "getMinHostHex", "(", ")", "{", "if", "(", "$", "this", "->", "network_size", "===", "32", "||", "$", "this", "->", "network_size", "===", "31", ")", "{", "return", "implode", "(", "''", ",", "array_map", "(", "function", "(", "$"...
Get minimum host IP address as hex @return string min host portion as hex
[ "Get", "minimum", "host", "IP", "address", "as", "hex" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L218-L229
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getMinHostBinary
public function getMinHostBinary() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_BINARY, $quad); }, $this->quads )); } return $this->minHostCalculation(self::FORMAT_BINARY); }
php
public function getMinHostBinary() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_BINARY, $quad); }, $this->quads )); } return $this->minHostCalculation(self::FORMAT_BINARY); }
[ "public", "function", "getMinHostBinary", "(", ")", "{", "if", "(", "$", "this", "->", "network_size", "===", "32", "||", "$", "this", "->", "network_size", "===", "31", ")", "{", "return", "implode", "(", "''", ",", "array_map", "(", "function", "(", ...
Get minimum host IP address as binary @return string min host portion as binary
[ "Get", "minimum", "host", "IP", "address", "as", "binary" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L236-L247
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getMaxHostHex
public function getMaxHostHex() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_HEX, $quad); }, $this->quads )); } return $this->maxHostCalculation(self::FORMAT_HEX); }
php
public function getMaxHostHex() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_HEX, $quad); }, $this->quads )); } return $this->maxHostCalculation(self::FORMAT_HEX); }
[ "public", "function", "getMaxHostHex", "(", ")", "{", "if", "(", "$", "this", "->", "network_size", "===", "32", "||", "$", "this", "->", "network_size", "===", "31", ")", "{", "return", "implode", "(", "''", ",", "array_map", "(", "function", "(", "$"...
Get maximum host IP address as hex @return string max host portion as hex
[ "Get", "maximum", "host", "IP", "address", "as", "hex" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L280-L291
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getMaxHostBinary
public function getMaxHostBinary() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_BINARY, $quad); }, $this->quads )); } return $this->maxHostCalculation(self::FORMAT_BINARY); }
php
public function getMaxHostBinary() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_BINARY, $quad); }, $this->quads )); } return $this->maxHostCalculation(self::FORMAT_BINARY); }
[ "public", "function", "getMaxHostBinary", "(", ")", "{", "if", "(", "$", "this", "->", "network_size", "===", "32", "||", "$", "this", "->", "network_size", "===", "31", ")", "{", "return", "implode", "(", "''", ",", "array_map", "(", "function", "(", ...
Get maximum host IP address as binary @return string man host portion as binary
[ "Get", "maximum", "host", "IP", "address", "as", "binary" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L298-L309
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getAllIPAddresses
public function getAllIPAddresses() { list($start_ip, $end_ip) = $this->getIPAddressRangeAsInts(); for ($ip = $start_ip; $ip <= $end_ip; $ip++) { yield long2ip($ip); } }
php
public function getAllIPAddresses() { list($start_ip, $end_ip) = $this->getIPAddressRangeAsInts(); for ($ip = $start_ip; $ip <= $end_ip; $ip++) { yield long2ip($ip); } }
[ "public", "function", "getAllIPAddresses", "(", ")", "{", "list", "(", "$", "start_ip", ",", "$", "end_ip", ")", "=", "$", "this", "->", "getIPAddressRangeAsInts", "(", ")", ";", "for", "(", "$", "ip", "=", "$", "start_ip", ";", "$", "ip", "<=", "$",...
Get all IP addresses @return \Generator|string[]
[ "Get", "all", "IP", "addresses" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L436-L443
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getAllHostIPAddresses
public function getAllHostIPAddresses() { list($start_ip, $end_ip) = $this->getIPAddressRangeAsInts(); if ($this->getNetworkSize() < 31) { $start_ip += 1; $end_ip -= 1; } for ($ip = $start_ip; $ip <= $end_ip; $ip++) { yield long2ip($ip); } }
php
public function getAllHostIPAddresses() { list($start_ip, $end_ip) = $this->getIPAddressRangeAsInts(); if ($this->getNetworkSize() < 31) { $start_ip += 1; $end_ip -= 1; } for ($ip = $start_ip; $ip <= $end_ip; $ip++) { yield long2ip($ip); } }
[ "public", "function", "getAllHostIPAddresses", "(", ")", "{", "list", "(", "$", "start_ip", ",", "$", "end_ip", ")", "=", "$", "this", "->", "getIPAddressRangeAsInts", "(", ")", ";", "if", "(", "$", "this", "->", "getNetworkSize", "(", ")", "<", "31", ...
Get all host IP addresses Removes broadcast and network address if they exist. @return \Generator|string[] @throws \RuntimeException if there is an error in the IP address range calculation
[ "Get", "all", "host", "IP", "addresses", "Removes", "broadcast", "and", "network", "address", "if", "they", "exist", "." ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L453-L465
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.isIPAddressInSubnet
public function isIPAddressInSubnet($ip_address_string) { $ip_address = ip2long($ip_address_string); list($start_ip, $end_ip) = $this->getIPAddressRangeAsInts(); return $ip_address >= $start_ip && $ip_address <= $end_ip ? true : false; }
php
public function isIPAddressInSubnet($ip_address_string) { $ip_address = ip2long($ip_address_string); list($start_ip, $end_ip) = $this->getIPAddressRangeAsInts(); return $ip_address >= $start_ip && $ip_address <= $end_ip ? true : false; }
[ "public", "function", "isIPAddressInSubnet", "(", "$", "ip_address_string", ")", "{", "$", "ip_address", "=", "ip2long", "(", "$", "ip_address_string", ")", ";", "list", "(", "$", "start_ip", ",", "$", "end_ip", ")", "=", "$", "this", "->", "getIPAddressRang...
Is the IP address in the subnet? @param string $ip_address_string @return bool
[ "Is", "the", "IP", "address", "in", "the", "subnet?" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L474-L482
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getSubnetJsonReport
public function getSubnetJsonReport() { $json = $this->report->createJsonReport($this); if ($json === false) { throw new \RuntimeException('JSON report failure: ' . json_last_error_msg()); } return $json; }
php
public function getSubnetJsonReport() { $json = $this->report->createJsonReport($this); if ($json === false) { throw new \RuntimeException('JSON report failure: ' . json_last_error_msg()); } return $json; }
[ "public", "function", "getSubnetJsonReport", "(", ")", "{", "$", "json", "=", "$", "this", "->", "report", "->", "createJsonReport", "(", "$", "this", ")", ";", "if", "(", "$", "json", "===", "false", ")", "{", "throw", "new", "\\", "RuntimeException", ...
Get subnet calculations as a JSON string @return string JSON string of subnet calculations @throws \RuntimeException if there is a JSON encode error
[ "Get", "subnet", "calculations", "as", "a", "JSON", "string" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L501-L510
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.ipAddressCalculation
private function ipAddressCalculation($format, $separator = '') { return implode($separator, array_map( function ($quad) use ($format) { return sprintf($format, $quad); }, $this->quads )); }
php
private function ipAddressCalculation($format, $separator = '') { return implode($separator, array_map( function ($quad) use ($format) { return sprintf($format, $quad); }, $this->quads )); }
[ "private", "function", "ipAddressCalculation", "(", "$", "format", ",", "$", "separator", "=", "''", ")", "{", "return", "implode", "(", "$", "separator", ",", "array_map", "(", "function", "(", "$", "quad", ")", "use", "(", "$", "format", ")", "{", "r...
Calculate IP address for formatting @param string $format sprintf format to determine if decimal, hex or binary @param string $separator implode separator for formatting quads vs hex and binary @return string formatted IP address
[ "Calculate", "IP", "address", "for", "formatting" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L578-L586
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.hostCalculation
private function hostCalculation($format, $separator = '') { $network_quads = [ sprintf("$format", $this->quads[0] & ~($this->subnet_mask >> 24)), sprintf("$format", $this->quads[1] & ~($this->subnet_mask >> 16)), sprintf("$format", $this->quads[2] & ~($this->subnet_mask >> 8)), sprintf("$format", $this->quads[3] & ~($this->subnet_mask >> 0)), ]; return implode($separator, $network_quads); }
php
private function hostCalculation($format, $separator = '') { $network_quads = [ sprintf("$format", $this->quads[0] & ~($this->subnet_mask >> 24)), sprintf("$format", $this->quads[1] & ~($this->subnet_mask >> 16)), sprintf("$format", $this->quads[2] & ~($this->subnet_mask >> 8)), sprintf("$format", $this->quads[3] & ~($this->subnet_mask >> 0)), ]; return implode($separator, $network_quads); }
[ "private", "function", "hostCalculation", "(", "$", "format", ",", "$", "separator", "=", "''", ")", "{", "$", "network_quads", "=", "[", "sprintf", "(", "\"$format\"", ",", "$", "this", "->", "quads", "[", "0", "]", "&", "~", "(", "$", "this", "->",...
Calculate host portion for formatting @param string $format sprintf format to determine if decimal, hex or binary @param string $separator implode separator for formatting quads vs hex and binary @return string formatted subnet mask
[ "Calculate", "host", "portion", "for", "formatting" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L636-L646
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.maxHostCalculation
private function maxHostCalculation($format, $separator = '') { $network_quads = $this->getNetworkPortionQuads(); $number_ip_addresses = $this->getNumberIPAddresses(); $network_range_quads = [ sprintf($format, ($network_quads[0] & ($this->subnet_mask >> 24)) + ((($number_ip_addresses - 1) >> 24) & 0xFF)), sprintf($format, ($network_quads[1] & ($this->subnet_mask >> 16)) + ((($number_ip_addresses - 1) >> 16) & 0xFF)), sprintf($format, ($network_quads[2] & ($this->subnet_mask >> 8)) + ((($number_ip_addresses - 1) >> 8) & 0xFF)), sprintf($format, ($network_quads[3] & ($this->subnet_mask >> 0)) + ((($number_ip_addresses - 1) >> 0) & 0xFE)), ]; return implode($separator, $network_range_quads); }
php
private function maxHostCalculation($format, $separator = '') { $network_quads = $this->getNetworkPortionQuads(); $number_ip_addresses = $this->getNumberIPAddresses(); $network_range_quads = [ sprintf($format, ($network_quads[0] & ($this->subnet_mask >> 24)) + ((($number_ip_addresses - 1) >> 24) & 0xFF)), sprintf($format, ($network_quads[1] & ($this->subnet_mask >> 16)) + ((($number_ip_addresses - 1) >> 16) & 0xFF)), sprintf($format, ($network_quads[2] & ($this->subnet_mask >> 8)) + ((($number_ip_addresses - 1) >> 8) & 0xFF)), sprintf($format, ($network_quads[3] & ($this->subnet_mask >> 0)) + ((($number_ip_addresses - 1) >> 0) & 0xFE)), ]; return implode($separator, $network_range_quads); }
[ "private", "function", "maxHostCalculation", "(", "$", "format", ",", "$", "separator", "=", "''", ")", "{", "$", "network_quads", "=", "$", "this", "->", "getNetworkPortionQuads", "(", ")", ";", "$", "number_ip_addresses", "=", "$", "this", "->", "getNumber...
Calculate max host for formatting @param string $format sprintf format to determine if decimal, hex or binary @param string $separator implode separator for formatting quads vs hex and binary @return string formatted max host
[ "Calculate", "max", "host", "for", "formatting" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L676-L689
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getIPAddressRangeAsInts
private function getIPAddressRangeAsInts() { list($start_ip, $end_ip) = $this->getIPAddressRange(); $start_ip = ip2long($start_ip); $end_ip = ip2long($end_ip); if ($start_ip === false || $end_ip === false) { throw new \RuntimeException('IP address range calculation failed: ' . print_r($this->getIPAddressRange(), true)); } return [$start_ip, $end_ip]; }
php
private function getIPAddressRangeAsInts() { list($start_ip, $end_ip) = $this->getIPAddressRange(); $start_ip = ip2long($start_ip); $end_ip = ip2long($end_ip); if ($start_ip === false || $end_ip === false) { throw new \RuntimeException('IP address range calculation failed: ' . print_r($this->getIPAddressRange(), true)); } return [$start_ip, $end_ip]; }
[ "private", "function", "getIPAddressRangeAsInts", "(", ")", "{", "list", "(", "$", "start_ip", ",", "$", "end_ip", ")", "=", "$", "this", "->", "getIPAddressRange", "(", ")", ";", "$", "start_ip", "=", "ip2long", "(", "$", "start_ip", ")", ";", "$", "e...
Get the start and end of the IP address range as ints @return array [start IP, end IP]
[ "Get", "the", "start", "and", "end", "of", "the", "IP", "address", "range", "as", "ints" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L714-L725
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetReport.php
SubnetReport.createArrayReport
public function createArrayReport(SubnetCalculator $sub) { return [ 'ip_address_with_network_size' => $sub->getIPAddress() . '/' . $sub->getNetworkSize(), 'ip_address' => [ 'quads' => $sub->getIPAddress(), 'hex' => $sub->getIPAddressHex(), 'binary' => $sub->getIPAddressBinary() ], 'subnet_mask' => [ 'quads' => $sub->getSubnetMask(), 'hex' => $sub->getSubnetMaskHex(), 'binary' => $sub->getSubnetMaskBinary() ], 'network_portion' => [ 'quads' => $sub->getNetworkPortion(), 'hex' => $sub->getNetworkPortionHex(), 'binary' => $sub->getNetworkPortionBinary() ], 'host_portion' => [ 'quads' => $sub->getHostPortion(), 'hex' => $sub->getHostPortionHex(), 'binary' => $sub->getHostPortionBinary() ], 'network_size' => $sub->getNetworkSize(), 'number_of_ip_addresses' => $sub->getNumberIPAddresses(), 'number_of_addressable_hosts' => $sub->getNumberAddressableHosts(), 'ip_address_range' => $sub->getIPAddressRange(), 'broadcast_address' => $sub->getBroadcastAddress(), 'min_host' => $sub->getMinHost(), 'max_host' => $sub->getMaxHost(), ]; }
php
public function createArrayReport(SubnetCalculator $sub) { return [ 'ip_address_with_network_size' => $sub->getIPAddress() . '/' . $sub->getNetworkSize(), 'ip_address' => [ 'quads' => $sub->getIPAddress(), 'hex' => $sub->getIPAddressHex(), 'binary' => $sub->getIPAddressBinary() ], 'subnet_mask' => [ 'quads' => $sub->getSubnetMask(), 'hex' => $sub->getSubnetMaskHex(), 'binary' => $sub->getSubnetMaskBinary() ], 'network_portion' => [ 'quads' => $sub->getNetworkPortion(), 'hex' => $sub->getNetworkPortionHex(), 'binary' => $sub->getNetworkPortionBinary() ], 'host_portion' => [ 'quads' => $sub->getHostPortion(), 'hex' => $sub->getHostPortionHex(), 'binary' => $sub->getHostPortionBinary() ], 'network_size' => $sub->getNetworkSize(), 'number_of_ip_addresses' => $sub->getNumberIPAddresses(), 'number_of_addressable_hosts' => $sub->getNumberAddressableHosts(), 'ip_address_range' => $sub->getIPAddressRange(), 'broadcast_address' => $sub->getBroadcastAddress(), 'min_host' => $sub->getMinHost(), 'max_host' => $sub->getMaxHost(), ]; }
[ "public", "function", "createArrayReport", "(", "SubnetCalculator", "$", "sub", ")", "{", "return", "[", "'ip_address_with_network_size'", "=>", "$", "sub", "->", "getIPAddress", "(", ")", ".", "'/'", ".", "$", "sub", "->", "getNetworkSize", "(", ")", ",", "...
Get subnet calculations as an associated array Contains IP address, subnet mask, network portion and host portion. Each of the above is provided in dotted quads, hexadecimal, and binary notation. Also contains number of IP addresses and number of addressable hosts, IP address range, and broadcast address. @param SubnetCalculator $sub @return array of subnet calculations
[ "Get", "subnet", "calculations", "as", "an", "associated", "array", "Contains", "IP", "address", "subnet", "mask", "network", "portion", "and", "host", "portion", ".", "Each", "of", "the", "above", "is", "provided", "in", "dotted", "quads", "hexadecimal", "and...
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetReport.php#L23-L55
train
markrogoyski/ipv4-subnet-calculator-php
src/SubnetReport.php
SubnetReport.createPrintableReport
public function createPrintableReport(SubnetCalculator $sub) { $string = sprintf("%-18s %15s %8s %32s\n", "{$sub->getIPAddress()}/{$sub->getNetworkSize()}", 'Quads', 'Hex', 'Binary'); $string .= sprintf("%-18s %15s %8s %32s\n", '------------------', '---------------', '--------', '--------------------------------'); $string .= sprintf("%-18s %15s %8s %32s\n", 'IP Address:', $sub->getIPAddress(), $sub->getIPAddressHex(), $sub->getIPAddressBinary()); $string .= sprintf("%-18s %15s %8s %32s\n", 'Subnet Mask:', $sub->getSubnetMask(), $sub->getSubnetMaskHex(), $sub->getSubnetMaskBinary()); $string .= sprintf("%-18s %15s %8s %32s\n", 'Network Portion:', $sub->getNetworkPortion(), $sub->getNetworkPortionHex(), $sub->getNetworkPortionBinary()); $string .= sprintf("%-18s %15s %8s %32s\n", 'Host Portion:', $sub->getHostPortion(), $sub->getHostPortionHex(), $sub->getHostPortionBinary()); $string .= \PHP_EOL; $string .= sprintf("%-28s %d\n", 'Number of IP Addresses:', $sub->getNumberIPAddresses()); $string .= sprintf("%-28s %d\n", 'Number of Addressable Hosts:', $sub->getNumberAddressableHosts()); $string .= sprintf("%-28s %s\n", 'IP Address Range:', implode(' - ', $sub->getIPAddressRange())); $string .= sprintf("%-28s %s\n", 'Broadcast Address:', $sub->getBroadcastAddress()); $string .= sprintf("%-28s %s\n", 'Min Host:', $sub->getMinHost()); $string .= sprintf("%-28s %s\n", 'Max Host:', $sub->getMaxHost()); return $string; }
php
public function createPrintableReport(SubnetCalculator $sub) { $string = sprintf("%-18s %15s %8s %32s\n", "{$sub->getIPAddress()}/{$sub->getNetworkSize()}", 'Quads', 'Hex', 'Binary'); $string .= sprintf("%-18s %15s %8s %32s\n", '------------------', '---------------', '--------', '--------------------------------'); $string .= sprintf("%-18s %15s %8s %32s\n", 'IP Address:', $sub->getIPAddress(), $sub->getIPAddressHex(), $sub->getIPAddressBinary()); $string .= sprintf("%-18s %15s %8s %32s\n", 'Subnet Mask:', $sub->getSubnetMask(), $sub->getSubnetMaskHex(), $sub->getSubnetMaskBinary()); $string .= sprintf("%-18s %15s %8s %32s\n", 'Network Portion:', $sub->getNetworkPortion(), $sub->getNetworkPortionHex(), $sub->getNetworkPortionBinary()); $string .= sprintf("%-18s %15s %8s %32s\n", 'Host Portion:', $sub->getHostPortion(), $sub->getHostPortionHex(), $sub->getHostPortionBinary()); $string .= \PHP_EOL; $string .= sprintf("%-28s %d\n", 'Number of IP Addresses:', $sub->getNumberIPAddresses()); $string .= sprintf("%-28s %d\n", 'Number of Addressable Hosts:', $sub->getNumberAddressableHosts()); $string .= sprintf("%-28s %s\n", 'IP Address Range:', implode(' - ', $sub->getIPAddressRange())); $string .= sprintf("%-28s %s\n", 'Broadcast Address:', $sub->getBroadcastAddress()); $string .= sprintf("%-28s %s\n", 'Min Host:', $sub->getMinHost()); $string .= sprintf("%-28s %s\n", 'Max Host:', $sub->getMaxHost()); return $string; }
[ "public", "function", "createPrintableReport", "(", "SubnetCalculator", "$", "sub", ")", "{", "$", "string", "=", "sprintf", "(", "\"%-18s %15s %8s %32s\\n\"", ",", "\"{$sub->getIPAddress()}/{$sub->getNetworkSize()}\"", ",", "'Quads'", ",", "'Hex'", ",", "'Binary'", ")"...
Print a report of subnet calculations Contains IP address, subnet mask, network portion and host portion. Each of the above is provided in dotted quads, hexadecimal, and binary notation. Also contains number of IP addresses and number of addressable hosts, IP address range, and broadcast address. @param SubnetCalculator $sub @return string report of subnet calculations
[ "Print", "a", "report", "of", "subnet", "calculations", "Contains", "IP", "address", "subnet", "mask", "network", "portion", "and", "host", "portion", ".", "Each", "of", "the", "above", "is", "provided", "in", "dotted", "quads", "hexadecimal", "and", "binary",...
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetReport.php#L95-L112
train
novaway/BehatCommonContext
src/Context/FormContext.php
FormContext.iFillInFieldWithoutLoosingFocus
public function iFillInFieldWithoutLoosingFocus($field, $value) { $driver = $this->getSession()->getDriver(); if ('Behat\Mink\Driver\Selenium2Driver' != get_class($driver)) { $field = $this->fixStepArgument($field); $value = $this->fixStepArgument($value); $this->getSession()->getPage()->fillField($field, $value); } else { if (null === ($locator = $this->getSession()->getPage()->findField($field))) { throw new \Exception(sprintf('Field "%s" not found.', $field)); } if (!($element = $driver->getWebDriverSession()->element('xpath', $locator->getXpath()))) { throw new \Exception(sprintf('Field "%s" not found.', $field)); } $element->postValue(['value' => [$value]]); } }
php
public function iFillInFieldWithoutLoosingFocus($field, $value) { $driver = $this->getSession()->getDriver(); if ('Behat\Mink\Driver\Selenium2Driver' != get_class($driver)) { $field = $this->fixStepArgument($field); $value = $this->fixStepArgument($value); $this->getSession()->getPage()->fillField($field, $value); } else { if (null === ($locator = $this->getSession()->getPage()->findField($field))) { throw new \Exception(sprintf('Field "%s" not found.', $field)); } if (!($element = $driver->getWebDriverSession()->element('xpath', $locator->getXpath()))) { throw new \Exception(sprintf('Field "%s" not found.', $field)); } $element->postValue(['value' => [$value]]); } }
[ "public", "function", "iFillInFieldWithoutLoosingFocus", "(", "$", "field", ",", "$", "value", ")", "{", "$", "driver", "=", "$", "this", "->", "getSession", "(", ")", "->", "getDriver", "(", ")", ";", "if", "(", "'Behat\\Mink\\Driver\\Selenium2Driver'", "!=",...
Fills in form field with specified id|name|label|value without unfocus field @When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)" without loosing focus$/ @When /^(?:|I )fill in "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)" without loosing focus$/
[ "Fills", "in", "form", "field", "with", "specified", "id|name|label|value", "without", "unfocus", "field" ]
b5349bd6a36c0e0ca71465a5349f8d68c1d1e102
https://github.com/novaway/BehatCommonContext/blob/b5349bd6a36c0e0ca71465a5349f8d68c1d1e102/src/Context/FormContext.php#L13-L32
train
novaway/BehatCommonContext
src/Context/Select2Context.php
Select2Context.iFillInSelect2Field
public function iFillInSelect2Field($field, $value) { $page = $this->getSession()->getPage(); $this->openField($page, $field); $this->selectValue($page, $field, $value, $this->timeout); }
php
public function iFillInSelect2Field($field, $value) { $page = $this->getSession()->getPage(); $this->openField($page, $field); $this->selectValue($page, $field, $value, $this->timeout); }
[ "public", "function", "iFillInSelect2Field", "(", "$", "field", ",", "$", "value", ")", "{", "$", "page", "=", "$", "this", "->", "getSession", "(", ")", "->", "getPage", "(", ")", ";", "$", "this", "->", "openField", "(", "$", "page", ",", "$", "f...
Fills in Select2 field with specified @When /^(?:|I )fill in select2 "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/ @When /^(?:|I )fill in select2 "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)"$/
[ "Fills", "in", "Select2", "field", "with", "specified" ]
b5349bd6a36c0e0ca71465a5349f8d68c1d1e102
https://github.com/novaway/BehatCommonContext/blob/b5349bd6a36c0e0ca71465a5349f8d68c1d1e102/src/Context/Select2Context.php#L30-L36
train
novaway/BehatCommonContext
src/Context/Select2Context.php
Select2Context.iFillInSelect2FieldWaitUntilResultsAreLoaded
public function iFillInSelect2FieldWaitUntilResultsAreLoaded($field, $value, $time) { $page = $this->getSession()->getPage(); $this->openField($page, $field); $this->selectValue($page, $field, $value, $time); }
php
public function iFillInSelect2FieldWaitUntilResultsAreLoaded($field, $value, $time) { $page = $this->getSession()->getPage(); $this->openField($page, $field); $this->selectValue($page, $field, $value, $time); }
[ "public", "function", "iFillInSelect2FieldWaitUntilResultsAreLoaded", "(", "$", "field", ",", "$", "value", ",", "$", "time", ")", "{", "$", "page", "=", "$", "this", "->", "getSession", "(", ")", "->", "getPage", "(", ")", ";", "$", "this", "->", "openF...
Fills in Select2 field with specified and wait for results @When /^(?:|I )fill in select2 "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)" and wait (?P<time>(?:[^"]|\\")*) seconds until results are loaded$/ @When /^(?:|I )fill in select2 "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)" and wait (?P<time>(?:[^"]|\\")*) seconds until results are loaded$/
[ "Fills", "in", "Select2", "field", "with", "specified", "and", "wait", "for", "results" ]
b5349bd6a36c0e0ca71465a5349f8d68c1d1e102
https://github.com/novaway/BehatCommonContext/blob/b5349bd6a36c0e0ca71465a5349f8d68c1d1e102/src/Context/Select2Context.php#L44-L50
train
novaway/BehatCommonContext
src/Context/Select2Context.php
Select2Context.iFillInSelect2InputWithAndSelect
public function iFillInSelect2InputWithAndSelect($field, $value, $entry) { $page = $this->getSession()->getPage(); $this->openField($page, $field); $this->fillSearchField($page, $field, $value); $this->selectValue($page, $field, $entry, $this->timeout); }
php
public function iFillInSelect2InputWithAndSelect($field, $value, $entry) { $page = $this->getSession()->getPage(); $this->openField($page, $field); $this->fillSearchField($page, $field, $value); $this->selectValue($page, $field, $entry, $this->timeout); }
[ "public", "function", "iFillInSelect2InputWithAndSelect", "(", "$", "field", ",", "$", "value", ",", "$", "entry", ")", "{", "$", "page", "=", "$", "this", "->", "getSession", "(", ")", "->", "getPage", "(", ")", ";", "$", "this", "->", "openField", "(...
Fill Select2 input field and select a value @When /^(?:|I )fill in select2 input "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)" and select "(?P<entry>(?:[^"]|\\")*)"$/
[ "Fill", "Select2", "input", "field", "and", "select", "a", "value" ]
b5349bd6a36c0e0ca71465a5349f8d68c1d1e102
https://github.com/novaway/BehatCommonContext/blob/b5349bd6a36c0e0ca71465a5349f8d68c1d1e102/src/Context/Select2Context.php#L70-L77
train
novaway/BehatCommonContext
src/Context/Select2Context.php
Select2Context.waitForLoadingResults
private function waitForLoadingResults($time) { for ($i = 0; $i < $time; $i++) { if (!$this->getSession()->getPage()->find('css', '.select2-results__option.loading-results')) { return; } sleep(1); } }
php
private function waitForLoadingResults($time) { for ($i = 0; $i < $time; $i++) { if (!$this->getSession()->getPage()->find('css', '.select2-results__option.loading-results')) { return; } sleep(1); } }
[ "private", "function", "waitForLoadingResults", "(", "$", "time", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "time", ";", "$", "i", "++", ")", "{", "if", "(", "!", "$", "this", "->", "getSession", "(", ")", "->", "getPag...
Wait the end of fetching Select2 results @param int $time Time to wait in seconds
[ "Wait", "the", "end", "of", "fetching", "Select2", "results" ]
b5349bd6a36c0e0ca71465a5349f8d68c1d1e102
https://github.com/novaway/BehatCommonContext/blob/b5349bd6a36c0e0ca71465a5349f8d68c1d1e102/src/Context/Select2Context.php#L175-L184
train
novaway/BehatCommonContext
src/Context/FormstoneContext.php
FormstoneContext.selectValue
private function selectValue($component, $field, $value) { $page = $this->getSession()->getPage(); $this->openComponent($page, $component, $field); $this->selectComponentValue($page, $component, $field, $value); }
php
private function selectValue($component, $field, $value) { $page = $this->getSession()->getPage(); $this->openComponent($page, $component, $field); $this->selectComponentValue($page, $component, $field, $value); }
[ "private", "function", "selectValue", "(", "$", "component", ",", "$", "field", ",", "$", "value", ")", "{", "$", "page", "=", "$", "this", "->", "getSession", "(", ")", "->", "getPage", "(", ")", ";", "$", "this", "->", "openComponent", "(", "$", ...
Select value in component @param string $component @param string $field @param string $value @throws \Exception
[ "Select", "value", "in", "component" ]
b5349bd6a36c0e0ca71465a5349f8d68c1d1e102
https://github.com/novaway/BehatCommonContext/blob/b5349bd6a36c0e0ca71465a5349f8d68c1d1e102/src/Context/FormstoneContext.php#L43-L49
train
novaway/BehatCommonContext
src/Context/FormstoneContext.php
FormstoneContext.openComponent
private function openComponent(DocumentElement $page, $component, $field) { $select = $page->find('css', sprintf('#%s', $field)); if (!$select) { throw new \Exception(sprintf('No select "%s" found', $field)); } $fieldName = sprintf('.fs-%1$s .fs-%1$s-selected', $component); $choices = $select->getParent()->find('css', $fieldName); if (!$choices) { throw new \Exception(sprintf('No field "%s" found', $field)); } $choices->press(); }
php
private function openComponent(DocumentElement $page, $component, $field) { $select = $page->find('css', sprintf('#%s', $field)); if (!$select) { throw new \Exception(sprintf('No select "%s" found', $field)); } $fieldName = sprintf('.fs-%1$s .fs-%1$s-selected', $component); $choices = $select->getParent()->find('css', $fieldName); if (!$choices) { throw new \Exception(sprintf('No field "%s" found', $field)); } $choices->press(); }
[ "private", "function", "openComponent", "(", "DocumentElement", "$", "page", ",", "$", "component", ",", "$", "field", ")", "{", "$", "select", "=", "$", "page", "->", "find", "(", "'css'", ",", "sprintf", "(", "'#%s'", ",", "$", "field", ")", ")", "...
Open component choice list @param DocumentElement $page @param string $component @param string $field @throws \Exception
[ "Open", "component", "choice", "list" ]
b5349bd6a36c0e0ca71465a5349f8d68c1d1e102
https://github.com/novaway/BehatCommonContext/blob/b5349bd6a36c0e0ca71465a5349f8d68c1d1e102/src/Context/FormstoneContext.php#L59-L73
train
graphaware/neo4j-php-ogm
src/Metadata/NodeEntityMetadata.php
NodeEntityMetadata.getNonLazyRelationships
public function getNonLazyRelationships() { $rels = []; foreach ($this->relationships as $relationship) { if (!$relationship->isLazy()) { $rels[] = $relationship; } } return $rels; }
php
public function getNonLazyRelationships() { $rels = []; foreach ($this->relationships as $relationship) { if (!$relationship->isLazy()) { $rels[] = $relationship; } } return $rels; }
[ "public", "function", "getNonLazyRelationships", "(", ")", "{", "$", "rels", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "relationships", "as", "$", "relationship", ")", "{", "if", "(", "!", "$", "relationship", "->", "isLazy", "(", ")", ")"...
Returns non-lazy relationships. Note that currently relationships that are not of type "collection" are considered non-lazy. @return RelationshipMetadata[]
[ "Returns", "non", "-", "lazy", "relationships", ".", "Note", "that", "currently", "relationships", "that", "are", "not", "of", "type", "collection", "are", "considered", "non", "-", "lazy", "." ]
390c0413582933ffae9597edfa57d6df6c570b03
https://github.com/graphaware/neo4j-php-ogm/blob/390c0413582933ffae9597edfa57d6df6c570b03/src/Metadata/NodeEntityMetadata.php#L142-L152
train
graphaware/neo4j-php-ogm
src/Persister/EntityPersister.php
EntityPersister.refresh
public function refresh($id, $entity) { $label = $this->classMetadata->getLabel(); $query = sprintf('MATCH (n:%s) WHERE id(n) = {%s} RETURN n', $label, 'id'); $result = $this->entityManager->getDatabaseDriver()->run($query, ['id' => $id]); if ($result->size() > 0) { $node = $result->firstRecord()->nodeValue('n'); $this->entityManager->getEntityHydrator($this->className)->refresh($node, $entity); } }
php
public function refresh($id, $entity) { $label = $this->classMetadata->getLabel(); $query = sprintf('MATCH (n:%s) WHERE id(n) = {%s} RETURN n', $label, 'id'); $result = $this->entityManager->getDatabaseDriver()->run($query, ['id' => $id]); if ($result->size() > 0) { $node = $result->firstRecord()->nodeValue('n'); $this->entityManager->getEntityHydrator($this->className)->refresh($node, $entity); } }
[ "public", "function", "refresh", "(", "$", "id", ",", "$", "entity", ")", "{", "$", "label", "=", "$", "this", "->", "classMetadata", "->", "getLabel", "(", ")", ";", "$", "query", "=", "sprintf", "(", "'MATCH (n:%s) WHERE id(n) = {%s} RETURN n'", ",", "$"...
Refreshes a managed entity. @param int $id @param object $entity The entity to refresh
[ "Refreshes", "a", "managed", "entity", "." ]
390c0413582933ffae9597edfa57d6df6c570b03
https://github.com/graphaware/neo4j-php-ogm/blob/390c0413582933ffae9597edfa57d6df6c570b03/src/Persister/EntityPersister.php#L142-L152
train
graphaware/neo4j-php-ogm
src/UnitOfWork.php
UnitOfWork.getOriginalEntityState
public function getOriginalEntityState($id) { if (isset($this->entityStateReferences[$id])) { return $this->entityStateReferences[$id]; } return null; }
php
public function getOriginalEntityState($id) { if (isset($this->entityStateReferences[$id])) { return $this->entityStateReferences[$id]; } return null; }
[ "public", "function", "getOriginalEntityState", "(", "$", "id", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "entityStateReferences", "[", "$", "id", "]", ")", ")", "{", "return", "$", "this", "->", "entityStateReferences", "[", "$", "id", "]", ...
Get the original state of an entity when it was loaded from the database. @param int $id @return object|null
[ "Get", "the", "original", "state", "of", "an", "entity", "when", "it", "was", "loaded", "from", "the", "database", "." ]
390c0413582933ffae9597edfa57d6df6c570b03
https://github.com/graphaware/neo4j-php-ogm/blob/390c0413582933ffae9597edfa57d6df6c570b03/src/UnitOfWork.php#L791-L798
train
BabDev/Transifex-API
src/Connector/Projects.php
Projects.buildProjectRequest
private function buildProjectRequest(array $options): array { $data = []; // Valid options to check $validOptions = [ 'long_description', 'private', 'homepage', 'trans_instructions', 'tags', 'maintainers', 'team', 'auto_join', 'license', 'fill_up_resources', 'repository_url', 'organization', 'archived', 'type', ]; // Loop through the valid options and if we have them, add them to the request data foreach ($validOptions as $option) { if (isset($options[$option])) { $data[$option] = $options[$option]; } } // Set the license if present if (isset($options['license'])) { $this->checkLicense($options['license']); $data['license'] = $options['license']; } return $data; }
php
private function buildProjectRequest(array $options): array { $data = []; // Valid options to check $validOptions = [ 'long_description', 'private', 'homepage', 'trans_instructions', 'tags', 'maintainers', 'team', 'auto_join', 'license', 'fill_up_resources', 'repository_url', 'organization', 'archived', 'type', ]; // Loop through the valid options and if we have them, add them to the request data foreach ($validOptions as $option) { if (isset($options[$option])) { $data[$option] = $options[$option]; } } // Set the license if present if (isset($options['license'])) { $this->checkLicense($options['license']); $data['license'] = $options['license']; } return $data; }
[ "private", "function", "buildProjectRequest", "(", "array", "$", "options", ")", ":", "array", "{", "$", "data", "=", "[", "]", ";", "// Valid options to check", "$", "validOptions", "=", "[", "'long_description'", ",", "'private'", ",", "'homepage'", ",", "'t...
Build the data array to send with create and update requests. @param array $options Optional additional params to send with the request @return array
[ "Build", "the", "data", "array", "to", "send", "with", "create", "and", "update", "requests", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Projects.php#L22-L58
train
BabDev/Transifex-API
src/Connector/Projects.php
Projects.checkLicense
private function checkLicense(string $license): void { $accepted = ['proprietary', 'permissive_open_source', 'other_open_source']; // Ensure the license option is an allowed value if (!\in_array($license, $accepted)) { throw new \InvalidArgumentException( \sprintf( 'The license %s is not valid, accepted license values are %s', $license, \implode(', ', $accepted) ) ); } }
php
private function checkLicense(string $license): void { $accepted = ['proprietary', 'permissive_open_source', 'other_open_source']; // Ensure the license option is an allowed value if (!\in_array($license, $accepted)) { throw new \InvalidArgumentException( \sprintf( 'The license %s is not valid, accepted license values are %s', $license, \implode(', ', $accepted) ) ); } }
[ "private", "function", "checkLicense", "(", "string", "$", "license", ")", ":", "void", "{", "$", "accepted", "=", "[", "'proprietary'", ",", "'permissive_open_source'", ",", "'other_open_source'", "]", ";", "// Ensure the license option is an allowed value", "if", "(...
Checks that a license is an accepted value. @param string $license The license to check @throws \InvalidArgumentException
[ "Checks", "that", "a", "license", "is", "an", "accepted", "value", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Projects.php#L67-L81
train
BabDev/Transifex-API
src/Connector/Projects.php
Projects.getOrganizationProjects
public function getOrganizationProjects(string $organization): ResponseInterface { // This API endpoint uses the newer `api.transifex.com` subdomain, only change if the default www was given $currentBaseUri = $this->getOption('base_uri'); if (!$currentBaseUri || $currentBaseUri === 'https://www.transifex.com') { $this->setOption('base_uri', 'https://api.transifex.com'); } try { return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/organizations/$organization/projects/"))); } finally { $this->setOption('base_uri', $currentBaseUri); } }
php
public function getOrganizationProjects(string $organization): ResponseInterface { // This API endpoint uses the newer `api.transifex.com` subdomain, only change if the default www was given $currentBaseUri = $this->getOption('base_uri'); if (!$currentBaseUri || $currentBaseUri === 'https://www.transifex.com') { $this->setOption('base_uri', 'https://api.transifex.com'); } try { return $this->client->sendRequest($this->createRequest('GET', $this->createUri("/organizations/$organization/projects/"))); } finally { $this->setOption('base_uri', $currentBaseUri); } }
[ "public", "function", "getOrganizationProjects", "(", "string", "$", "organization", ")", ":", "ResponseInterface", "{", "// This API endpoint uses the newer `api.transifex.com` subdomain, only change if the default www was given", "$", "currentBaseUri", "=", "$", "this", "->", "...
Get a list of projects belonging to an organization. @return ResponseInterface
[ "Get", "a", "list", "of", "projects", "belonging", "to", "an", "organization", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/Connector/Projects.php#L147-L161
train
QoboLtd/cakephp-search
src/Widgets/Reports/BaseReportGraphs.php
BaseReportGraphs.setContainerId
public function setContainerId(array $data = []) : void { $config = empty($data) ? $this->getConfig() : $data; $this->containerId = self::GRAPH_PREFIX . $config['slug']; }
php
public function setContainerId(array $data = []) : void { $config = empty($data) ? $this->getConfig() : $data; $this->containerId = self::GRAPH_PREFIX . $config['slug']; }
[ "public", "function", "setContainerId", "(", "array", "$", "data", "=", "[", "]", ")", ":", "void", "{", "$", "config", "=", "empty", "(", "$", "data", ")", "?", "$", "this", "->", "getConfig", "(", ")", ":", "$", "data", ";", "$", "this", "->", ...
setContainerId method. Sets the placeholder unique identifier for the widget. @param mixed[] $data of the config. @return void
[ "setContainerId", "method", ".", "Sets", "the", "placeholder", "unique", "identifier", "for", "the", "widget", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Widgets/Reports/BaseReportGraphs.php#L71-L76
train
QoboLtd/cakephp-search
src/Widgets/Reports/BaseReportGraphs.php
BaseReportGraphs.validate
public function validate(array $data = []) : array { $validated = false; $errors = []; if (empty($this->requiredFields)) { $errors[] = "Missing requiredFields in the report object"; } foreach ($this->requiredFields as $field) { if (!isset($data['info'][$field])) { $errors[] = "Required field [$field] must be set"; } if (empty($data['info'][$field])) { $errors[] = "Required Field [$field] cannot be empty"; } } if (empty($errors)) { $validated = true; $this->errors = []; } else { $this->errors = $errors; } return ['status' => $validated, 'messages' => $errors]; }
php
public function validate(array $data = []) : array { $validated = false; $errors = []; if (empty($this->requiredFields)) { $errors[] = "Missing requiredFields in the report object"; } foreach ($this->requiredFields as $field) { if (!isset($data['info'][$field])) { $errors[] = "Required field [$field] must be set"; } if (empty($data['info'][$field])) { $errors[] = "Required Field [$field] cannot be empty"; } } if (empty($errors)) { $validated = true; $this->errors = []; } else { $this->errors = $errors; } return ['status' => $validated, 'messages' => $errors]; }
[ "public", "function", "validate", "(", "array", "$", "data", "=", "[", "]", ")", ":", "array", "{", "$", "validated", "=", "false", ";", "$", "errors", "=", "[", "]", ";", "if", "(", "empty", "(", "$", "this", "->", "requiredFields", ")", ")", "{...
validate method. Checks all the required fields of the report if any. @param array $data with report configuration @return mixed[] result of validation
[ "validate", "method", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Widgets/Reports/BaseReportGraphs.php#L147-L174
train
QoboLtd/cakephp-search
src/Widgets/Reports/BaseReportGraphs.php
BaseReportGraphs.getChartColors
public function getChartColors(int $count, string $myString, bool $shade = true) : array { $grad = []; // Generate first color if ($shade && $count > 0) { $color = substr(dechex(crc32($myString)), 0, 6); list($r, $g, $b) = array_map(function ($n) { return hexdec($n); }, str_split($color, 2)); // Generate second color $color2 = substr(dechex(crc32($myString . ' ')), 0, 6); list($r2, $g2, $b2) = array_map(function ($n) { return hexdec($n); }, str_split($color2, 2)); $rl = ( $r2 - $r) / $count - 1; $gl = ( $g2 - $g) / $count - 1; $bl = ( $b2 - $b) / $count - 1; // Create a shade from the first color to the second for ($i = 0; $i < $count; $i++) { $grad[] = '#' . str_pad(dechex($r + $rl * $i), 2, "0", 0) . str_pad(dechex($g + $gl * $i), 2, "0", 0) . str_pad(dechex($b + $bl * $i), 2, "0", 0); } return $grad; } $my_palette = Configure::read("Widget.colors"); for ($i = 0; $i < $count; $i++) { $grad[] = $my_palette[(crc32($myString) + $i) % count($my_palette)]; } return $grad; }
php
public function getChartColors(int $count, string $myString, bool $shade = true) : array { $grad = []; // Generate first color if ($shade && $count > 0) { $color = substr(dechex(crc32($myString)), 0, 6); list($r, $g, $b) = array_map(function ($n) { return hexdec($n); }, str_split($color, 2)); // Generate second color $color2 = substr(dechex(crc32($myString . ' ')), 0, 6); list($r2, $g2, $b2) = array_map(function ($n) { return hexdec($n); }, str_split($color2, 2)); $rl = ( $r2 - $r) / $count - 1; $gl = ( $g2 - $g) / $count - 1; $bl = ( $b2 - $b) / $count - 1; // Create a shade from the first color to the second for ($i = 0; $i < $count; $i++) { $grad[] = '#' . str_pad(dechex($r + $rl * $i), 2, "0", 0) . str_pad(dechex($g + $gl * $i), 2, "0", 0) . str_pad(dechex($b + $bl * $i), 2, "0", 0); } return $grad; } $my_palette = Configure::read("Widget.colors"); for ($i = 0; $i < $count; $i++) { $grad[] = $my_palette[(crc32($myString) + $i) % count($my_palette)]; } return $grad; }
[ "public", "function", "getChartColors", "(", "int", "$", "count", ",", "string", "$", "myString", ",", "bool", "$", "shade", "=", "true", ")", ":", "array", "{", "$", "grad", "=", "[", "]", ";", "// Generate first color", "if", "(", "$", "shade", "&&",...
Generate an array whit the colors for the chars. @param int $count How many element in the array. @param string $myString The color have to be calculated on a fix string to be constant in every refresh. @param bool $shade Shade the default color with another generated one. If false, the colors will be from a pre-set palette. @return string[]
[ "Generate", "an", "array", "whit", "the", "colors", "for", "the", "chars", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Widgets/Reports/BaseReportGraphs.php#L199-L235
train
aimeos/ai-client-jsonapi
client/jsonapi/src/Client/JsonApi/Subscription/Standard.php
Standard.delete
public function delete( ServerRequestInterface $request, ResponseInterface $response ) { $view = $this->getView(); try { $cntl = \Aimeos\Controller\Frontend::create( $this->getContext(), 'subscription' ); $view->items = $cntl->cancel( $view->param( 'id' ) ); $view->total = 1; $status = 200; } catch( \Aimeos\Controller\Frontend\Exception $e ) { $status = 403; $view->errors = $this->getErrorDetails( $e, 'controller/frontend' ); } catch( \Aimeos\MShop\Exception $e ) { $status = 404; $view->errors = $this->getErrorDetails( $e, 'mshop' ); } catch( \Exception $e ) { $status = 500; $view->errors = $this->getErrorDetails( $e ); } return $this->render( $response, $view, $status ); }
php
public function delete( ServerRequestInterface $request, ResponseInterface $response ) { $view = $this->getView(); try { $cntl = \Aimeos\Controller\Frontend::create( $this->getContext(), 'subscription' ); $view->items = $cntl->cancel( $view->param( 'id' ) ); $view->total = 1; $status = 200; } catch( \Aimeos\Controller\Frontend\Exception $e ) { $status = 403; $view->errors = $this->getErrorDetails( $e, 'controller/frontend' ); } catch( \Aimeos\MShop\Exception $e ) { $status = 404; $view->errors = $this->getErrorDetails( $e, 'mshop' ); } catch( \Exception $e ) { $status = 500; $view->errors = $this->getErrorDetails( $e ); } return $this->render( $response, $view, $status ); }
[ "public", "function", "delete", "(", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ")", "{", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "try", "{", "$", "cntl", "=", "\\", "Aimeos", "\\", "Contro...
Cancels the subscription @param \Psr\Http\Message\ServerRequestInterface $request Request object @param \Psr\Http\Message\ResponseInterface $response Response object @return \Psr\Http\Message\ResponseInterface Modified response object
[ "Cancels", "the", "subscription" ]
b0dfb018ae0a1f7196b18322e28a1b3224aa9045
https://github.com/aimeos/ai-client-jsonapi/blob/b0dfb018ae0a1f7196b18322e28a1b3224aa9045/client/jsonapi/src/Client/JsonApi/Subscription/Standard.php#L34-L64
train
mmoreram/ControllerExtraBundle
ControllerExtraBundle.php
ControllerExtraBundle.registerAnnotations
private function registerAnnotations(array $annotations) { $kernel = $this ->container ->get('kernel'); foreach ($annotations as $annotation) { AnnotationRegistry::registerFile($kernel ->locateResource($annotation) ); } }
php
private function registerAnnotations(array $annotations) { $kernel = $this ->container ->get('kernel'); foreach ($annotations as $annotation) { AnnotationRegistry::registerFile($kernel ->locateResource($annotation) ); } }
[ "private", "function", "registerAnnotations", "(", "array", "$", "annotations", ")", "{", "$", "kernel", "=", "$", "this", "->", "container", "->", "get", "(", "'kernel'", ")", ";", "foreach", "(", "$", "annotations", "as", "$", "annotation", ")", "{", "...
Register annotations. @param string[] Annotations
[ "Register", "annotations", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/ControllerExtraBundle.php#L81-L92
train
BabDev/Transifex-API
src/ApiConnector.php
ApiConnector.createAuthorizationHeader
protected function createAuthorizationHeader(): string { $username = $this->getOption('api.username'); $password = $this->getOption('api.password'); // The API requires HTTP Basic Authentication, we can't proceed without credentials if ($username === null || $password === null) { throw new \InvalidArgumentException('Missing credentials for API authentication.'); } return 'Basic ' . \base64_encode("$username:$password"); }
php
protected function createAuthorizationHeader(): string { $username = $this->getOption('api.username'); $password = $this->getOption('api.password'); // The API requires HTTP Basic Authentication, we can't proceed without credentials if ($username === null || $password === null) { throw new \InvalidArgumentException('Missing credentials for API authentication.'); } return 'Basic ' . \base64_encode("$username:$password"); }
[ "protected", "function", "createAuthorizationHeader", "(", ")", ":", "string", "{", "$", "username", "=", "$", "this", "->", "getOption", "(", "'api.username'", ")", ";", "$", "password", "=", "$", "this", "->", "getOption", "(", "'api.password'", ")", ";", ...
Creates the Authorization header for the request @return string @throws \InvalidArgumentException if credentials are not set
[ "Creates", "the", "Authorization", "header", "for", "the", "request" ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/ApiConnector.php#L81-L92
train
BabDev/Transifex-API
src/ApiConnector.php
ApiConnector.createRequest
protected function createRequest(string $method, UriInterface $uri): RequestInterface { $request = $this->requestFactory->createRequest($method, $uri); return $request->withHeader('Authorization', $this->createAuthorizationHeader()); }
php
protected function createRequest(string $method, UriInterface $uri): RequestInterface { $request = $this->requestFactory->createRequest($method, $uri); return $request->withHeader('Authorization', $this->createAuthorizationHeader()); }
[ "protected", "function", "createRequest", "(", "string", "$", "method", ",", "UriInterface", "$", "uri", ")", ":", "RequestInterface", "{", "$", "request", "=", "$", "this", "->", "requestFactory", "->", "createRequest", "(", "$", "method", ",", "$", "uri", ...
Create a Request object for the given URI This method will also set the Authorization header for the request @param string $method @param UriInterface $uri @return RequestInterface
[ "Create", "a", "Request", "object", "for", "the", "given", "URI" ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/ApiConnector.php#L104-L109
train
BabDev/Transifex-API
src/ApiConnector.php
ApiConnector.createUri
protected function createUri(string $path): UriInterface { $baseUrl = $this->getOption('base_uri', 'https://www.transifex.com'); return $this->uriFactory->createUri($baseUrl . $path); }
php
protected function createUri(string $path): UriInterface { $baseUrl = $this->getOption('base_uri', 'https://www.transifex.com'); return $this->uriFactory->createUri($baseUrl . $path); }
[ "protected", "function", "createUri", "(", "string", "$", "path", ")", ":", "UriInterface", "{", "$", "baseUrl", "=", "$", "this", "->", "getOption", "(", "'base_uri'", ",", "'https://www.transifex.com'", ")", ";", "return", "$", "this", "->", "uriFactory", ...
Create a Uri object for the path @param string $path @return UriInterface
[ "Create", "a", "Uri", "object", "for", "the", "path" ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/ApiConnector.php#L118-L123
train
BabDev/Transifex-API
src/ApiConnector.php
ApiConnector.updateResource
protected function updateResource(UriInterface $uri, string $content, string $type): ResponseInterface { // Verify the content type is allowed if (!\in_array($type, ['string', 'file'])) { throw new \InvalidArgumentException('The content type must be specified as file or string.'); } $request = $this->createRequest('PUT', $uri); $request = $request->withHeader('Content-Type', 'application/json'); if ($type == 'file') { if (!\file_exists($content)) { throw new \InvalidArgumentException( \sprintf('The specified file, "%s", does not exist.', $content) ); } $request = $request->withBody($this->streamFactory->createStreamFromFile($content)); } else { $data = [ 'content' => $content, ]; $request = $request->withBody($this->streamFactory->createStream(\json_encode($data))); } return $this->client->sendRequest($request); }
php
protected function updateResource(UriInterface $uri, string $content, string $type): ResponseInterface { // Verify the content type is allowed if (!\in_array($type, ['string', 'file'])) { throw new \InvalidArgumentException('The content type must be specified as file or string.'); } $request = $this->createRequest('PUT', $uri); $request = $request->withHeader('Content-Type', 'application/json'); if ($type == 'file') { if (!\file_exists($content)) { throw new \InvalidArgumentException( \sprintf('The specified file, "%s", does not exist.', $content) ); } $request = $request->withBody($this->streamFactory->createStreamFromFile($content)); } else { $data = [ 'content' => $content, ]; $request = $request->withBody($this->streamFactory->createStream(\json_encode($data))); } return $this->client->sendRequest($request); }
[ "protected", "function", "updateResource", "(", "UriInterface", "$", "uri", ",", "string", "$", "content", ",", "string", "$", "type", ")", ":", "ResponseInterface", "{", "// Verify the content type is allowed", "if", "(", "!", "\\", "in_array", "(", "$", "type"...
Update an API endpoint with resource content. @param UriInterface $uri URI object representing the API path to request @param string $content The content of the resource, this can either be a string of data or a file path @param string $type The type of content in the $content variable, this should be either string or file @return ResponseInterface @throws \InvalidArgumentException
[ "Update", "an", "API", "endpoint", "with", "resource", "content", "." ]
9e0ccd7980127db88f7c55a36afbd2a49d9e8436
https://github.com/BabDev/Transifex-API/blob/9e0ccd7980127db88f7c55a36afbd2a49d9e8436/src/ApiConnector.php#L164-L191
train
mitchdav/st-george-ipg
src/Client.php
Client.purchase
public function purchase($amount, $cardNumber, $month, $year, $cvc = NULL, $clientReference = NULL, $comment = NULL, $description = NULL, $cardHolderName = NULL, $taxAmount = NULL) { $request = Request::createFromClient($this); $request->setTransactionType(Request::TRANSACTION_TYPE_PURCHASE) ->setTotalAmount($amount) ->setCardData($cardNumber) ->setCardExpiryDate($month, $year) ->setCVC2($cvc) ->setClientReference($clientReference) ->setComment($comment) ->setMerchantDescription($description) ->setMerchantCardHolderName($cardHolderName) ->setTaxAmount($taxAmount); return $request; }
php
public function purchase($amount, $cardNumber, $month, $year, $cvc = NULL, $clientReference = NULL, $comment = NULL, $description = NULL, $cardHolderName = NULL, $taxAmount = NULL) { $request = Request::createFromClient($this); $request->setTransactionType(Request::TRANSACTION_TYPE_PURCHASE) ->setTotalAmount($amount) ->setCardData($cardNumber) ->setCardExpiryDate($month, $year) ->setCVC2($cvc) ->setClientReference($clientReference) ->setComment($comment) ->setMerchantDescription($description) ->setMerchantCardHolderName($cardHolderName) ->setTaxAmount($taxAmount); return $request; }
[ "public", "function", "purchase", "(", "$", "amount", ",", "$", "cardNumber", ",", "$", "month", ",", "$", "year", ",", "$", "cvc", "=", "NULL", ",", "$", "clientReference", "=", "NULL", ",", "$", "comment", "=", "NULL", ",", "$", "description", "=",...
Create a purchase request. @param $amount @param $cardNumber @param $month @param $year @param null $cvc @param null $clientReference @param null $comment @param null $description @param null $cardHolderName @param null $taxAmount @return \StGeorgeIPG\Request
[ "Create", "a", "purchase", "request", "." ]
2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc
https://github.com/mitchdav/st-george-ipg/blob/2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc/src/Client.php#L157-L173
train
mitchdav/st-george-ipg
src/Client.php
Client.refund
public function refund($amount, $originalTransactionReference, $clientReference = NULL, $comment = NULL, $description = NULL, $cardHolderName = NULL, $taxAmount = NULL) { $request = Request::createFromClient($this); $request->setTransactionType(Request::TRANSACTION_TYPE_REFUND) ->setTotalAmount($amount) ->setOriginalTransactionReference($originalTransactionReference) ->setClientReference($clientReference) ->setComment($comment) ->setMerchantDescription($description) ->setMerchantCardHolderName($cardHolderName) ->setTaxAmount($taxAmount); return $request; }
php
public function refund($amount, $originalTransactionReference, $clientReference = NULL, $comment = NULL, $description = NULL, $cardHolderName = NULL, $taxAmount = NULL) { $request = Request::createFromClient($this); $request->setTransactionType(Request::TRANSACTION_TYPE_REFUND) ->setTotalAmount($amount) ->setOriginalTransactionReference($originalTransactionReference) ->setClientReference($clientReference) ->setComment($comment) ->setMerchantDescription($description) ->setMerchantCardHolderName($cardHolderName) ->setTaxAmount($taxAmount); return $request; }
[ "public", "function", "refund", "(", "$", "amount", ",", "$", "originalTransactionReference", ",", "$", "clientReference", "=", "NULL", ",", "$", "comment", "=", "NULL", ",", "$", "description", "=", "NULL", ",", "$", "cardHolderName", "=", "NULL", ",", "$...
Create a refund request. @param $amount @param $originalTransactionReference @param null $clientReference @param null $comment @param null $description @param null $cardHolderName @param null $taxAmount @return \StGeorgeIPG\Request
[ "Create", "a", "refund", "request", "." ]
2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc
https://github.com/mitchdav/st-george-ipg/blob/2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc/src/Client.php#L188-L202
train
mitchdav/st-george-ipg
src/Client.php
Client.completion
public function completion($amount, $originalTransactionReference, $authorisationNumber, $clientReference = NULL, $comment = NULL, $description = NULL, $cardHolderName = NULL, $taxAmount = NULL) { $request = Request::createFromClient($this); $request->setTransactionType(Request::TRANSACTION_TYPE_COMPLETION) ->setTotalAmount($amount) ->setOriginalTransactionReference($originalTransactionReference) ->setAuthorisationNumber($authorisationNumber) ->setClientReference($clientReference) ->setComment($comment) ->setMerchantDescription($description) ->setMerchantCardHolderName($cardHolderName) ->setTaxAmount($taxAmount); return $request; }
php
public function completion($amount, $originalTransactionReference, $authorisationNumber, $clientReference = NULL, $comment = NULL, $description = NULL, $cardHolderName = NULL, $taxAmount = NULL) { $request = Request::createFromClient($this); $request->setTransactionType(Request::TRANSACTION_TYPE_COMPLETION) ->setTotalAmount($amount) ->setOriginalTransactionReference($originalTransactionReference) ->setAuthorisationNumber($authorisationNumber) ->setClientReference($clientReference) ->setComment($comment) ->setMerchantDescription($description) ->setMerchantCardHolderName($cardHolderName) ->setTaxAmount($taxAmount); return $request; }
[ "public", "function", "completion", "(", "$", "amount", ",", "$", "originalTransactionReference", ",", "$", "authorisationNumber", ",", "$", "clientReference", "=", "NULL", ",", "$", "comment", "=", "NULL", ",", "$", "description", "=", "NULL", ",", "$", "ca...
Create a completion request. @param $amount @param $originalTransactionReference @param $authorisationNumber @param null $clientReference @param null $comment @param null $description @param null $cardHolderName @param null $taxAmount @return \StGeorgeIPG\Request
[ "Create", "a", "completion", "request", "." ]
2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc
https://github.com/mitchdav/st-george-ipg/blob/2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc/src/Client.php#L252-L267
train
mitchdav/st-george-ipg
src/Client.php
Client.status
public function status($transactionReference) { $request = Request::createFromClient($this, FALSE); $request->setTransactionType(Request::TRANSACTION_TYPE_STATUS) ->setTransactionReference($transactionReference); return $request; }
php
public function status($transactionReference) { $request = Request::createFromClient($this, FALSE); $request->setTransactionType(Request::TRANSACTION_TYPE_STATUS) ->setTransactionReference($transactionReference); return $request; }
[ "public", "function", "status", "(", "$", "transactionReference", ")", "{", "$", "request", "=", "Request", "::", "createFromClient", "(", "$", "this", ",", "FALSE", ")", ";", "$", "request", "->", "setTransactionType", "(", "Request", "::", "TRANSACTION_TYPE_...
Create a status request. @param $transactionReference @return \StGeorgeIPG\Request
[ "Create", "a", "status", "request", "." ]
2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc
https://github.com/mitchdav/st-george-ipg/blob/2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc/src/Client.php#L276-L284
train
mitchdav/st-george-ipg
src/Client.php
Client.getResponse
public function getResponse(Request $request, $maxTries = 3) { $request->validate(); $response = $this->getProvider() ->getResponse($request, $canSafelyTryAgain); if ($canSafelyTryAgain) { if ($response->getTransactionReference() !== NULL) { if ($maxTries > 0) { $response = $this->getResponse($this->status($response->getTransactionReference()), $maxTries - 1); } else { throw new TransactionFailedException($request, $response, $maxTries); } } else { if ($maxTries > 0) { return $this->getResponse($request, $maxTries - 1); } else { throw new TransactionFailedException($request, $response, $maxTries); } } } else { if ($response->isCodeInProgress()) { if ($maxTries > 0) { if ($request->isTransactionTypeStatus()) { $response = $this->getResponse($request, $maxTries - 1); } else { $response = $this->getResponse($this->status($response->getTransactionReference()), $maxTries - 1); } } else { throw new TransactionInProgressException($request, $response, $maxTries); } } } return $response; }
php
public function getResponse(Request $request, $maxTries = 3) { $request->validate(); $response = $this->getProvider() ->getResponse($request, $canSafelyTryAgain); if ($canSafelyTryAgain) { if ($response->getTransactionReference() !== NULL) { if ($maxTries > 0) { $response = $this->getResponse($this->status($response->getTransactionReference()), $maxTries - 1); } else { throw new TransactionFailedException($request, $response, $maxTries); } } else { if ($maxTries > 0) { return $this->getResponse($request, $maxTries - 1); } else { throw new TransactionFailedException($request, $response, $maxTries); } } } else { if ($response->isCodeInProgress()) { if ($maxTries > 0) { if ($request->isTransactionTypeStatus()) { $response = $this->getResponse($request, $maxTries - 1); } else { $response = $this->getResponse($this->status($response->getTransactionReference()), $maxTries - 1); } } else { throw new TransactionInProgressException($request, $response, $maxTries); } } } return $response; }
[ "public", "function", "getResponse", "(", "Request", "$", "request", ",", "$", "maxTries", "=", "3", ")", "{", "$", "request", "->", "validate", "(", ")", ";", "$", "response", "=", "$", "this", "->", "getProvider", "(", ")", "->", "getResponse", "(", ...
Get a response for the given request, following the flow diagram provided by St.George. @param \StGeorgeIPG\Request $request @param integer $maxTries @return \StGeorgeIPG\Response @throws \StGeorgeIPG\Exceptions\TransactionFailedException @throws \StGeorgeIPG\Exceptions\TransactionInProgressException
[ "Get", "a", "response", "for", "the", "given", "request", "following", "the", "flow", "diagram", "provided", "by", "St", ".", "George", "." ]
2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc
https://github.com/mitchdav/st-george-ipg/blob/2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc/src/Client.php#L296-L332
train
mitchdav/st-george-ipg
src/Client.php
Client.execute
public function execute(Request $request, $maxTries = 3) { try { $response = $this->getResponse($request, $maxTries); return $this->validateResponse($response); } catch (TransactionInProgressException $ex) { throw new TransactionInProgressException($ex->getRequest(), $ex->getResponse(), $maxTries); // Throw a new exception with the correct maximum tries. } }
php
public function execute(Request $request, $maxTries = 3) { try { $response = $this->getResponse($request, $maxTries); return $this->validateResponse($response); } catch (TransactionInProgressException $ex) { throw new TransactionInProgressException($ex->getRequest(), $ex->getResponse(), $maxTries); // Throw a new exception with the correct maximum tries. } }
[ "public", "function", "execute", "(", "Request", "$", "request", ",", "$", "maxTries", "=", "3", ")", "{", "try", "{", "$", "response", "=", "$", "this", "->", "getResponse", "(", "$", "request", ",", "$", "maxTries", ")", ";", "return", "$", "this",...
Get the response, and then pass it to the validator. @param \StGeorgeIPG\Request $request @param integer $maxTries @return \StGeorgeIPG\Response @throws \StGeorgeIPG\Exceptions\TransactionInProgressException
[ "Get", "the", "response", "and", "then", "pass", "it", "to", "the", "validator", "." ]
2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc
https://github.com/mitchdav/st-george-ipg/blob/2ed1a458d9bb24b3e8c554c20ba4ea75ed6548bc/src/Client.php#L344-L353
train
mmoreram/ControllerExtraBundle
Resolver/FormAnnotationResolver.php
FormAnnotationResolver.getBuiltObject
private function getBuiltObject( Request $request, FormFactoryInterface $formFactory, CreateForm $annotation, string $parameterClass, AbstractType $type ) { /** * Checks if parameter typehinting is AbstractType * In this case, form type as defined method parameter. */ if (AbstractType::class == $parameterClass) { return $type; } $entity = $request->attributes->get($annotation->getEntity()); /** * Creates form object from type. */ $form = $formFactory->create(get_class($type), $entity); /** * Handling request if needed. */ if ($annotation->getHandleRequest()) { $form->handleRequest($request); if ($annotation->getValidate()) { $request->attributes->set( $annotation->getValidate(), ($form->isSubmitted() && $form->isValid()) ); } } /** * Checks if parameter typehinting is Form * In this case, inject form as defined method parameter. */ if (in_array( $parameterClass, [ Form::class, FormInterface::class, ] )) { return $form; } /** * Checks if parameter typehinting is FormView * In this case, inject form's view as defined method parameter. */ if (FormView::class == $parameterClass) { return $form->createView(); } }
php
private function getBuiltObject( Request $request, FormFactoryInterface $formFactory, CreateForm $annotation, string $parameterClass, AbstractType $type ) { /** * Checks if parameter typehinting is AbstractType * In this case, form type as defined method parameter. */ if (AbstractType::class == $parameterClass) { return $type; } $entity = $request->attributes->get($annotation->getEntity()); /** * Creates form object from type. */ $form = $formFactory->create(get_class($type), $entity); /** * Handling request if needed. */ if ($annotation->getHandleRequest()) { $form->handleRequest($request); if ($annotation->getValidate()) { $request->attributes->set( $annotation->getValidate(), ($form->isSubmitted() && $form->isValid()) ); } } /** * Checks if parameter typehinting is Form * In this case, inject form as defined method parameter. */ if (in_array( $parameterClass, [ Form::class, FormInterface::class, ] )) { return $form; } /** * Checks if parameter typehinting is FormView * In this case, inject form's view as defined method parameter. */ if (FormView::class == $parameterClass) { return $form->createView(); } }
[ "private", "function", "getBuiltObject", "(", "Request", "$", "request", ",", "FormFactoryInterface", "$", "formFactory", ",", "CreateForm", "$", "annotation", ",", "string", "$", "parameterClass", ",", "AbstractType", "$", "type", ")", "{", "/**\n * Checks ...
Built and return desired object. @param Request $request @param FormFactoryInterface $formFactory @param CreateForm $annotation @param string $parameterClass @param AbstractType $type @return mixed
[ "Built", "and", "return", "desired", "object", "." ]
b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3
https://github.com/mmoreram/ControllerExtraBundle/blob/b5841b6ca8f0022a2d88fdfbf743f0b76c4644e3/Resolver/FormAnnotationResolver.php#L141-L197
train
QoboLtd/cakephp-search
src/Model/Table/WidgetsTable.php
WidgetsTable.getWidgets
public function getWidgets(): array { // get widgets through Event broadcast $event = new Event((string)EventName::MODEL_DASHBOARDS_GET_WIDGETS(), $this); $this->getEventManager()->dispatch($event); if (empty($event->getResult())) { return []; } // assembling all widgets in one $result = []; foreach ((array)$event->getResult() as $widget) { if (empty($widget['data'])) { continue; } $instance = WidgetFactory::create($widget['type']); foreach ($widget['data'] as $data) { array_push($result, [ 'type' => $widget['type'], 'title' => $instance->getTitle(), 'icon' => $instance->getIcon(), 'color' => $instance->getColor(), 'data' => $data ]); } } return $result; }
php
public function getWidgets(): array { // get widgets through Event broadcast $event = new Event((string)EventName::MODEL_DASHBOARDS_GET_WIDGETS(), $this); $this->getEventManager()->dispatch($event); if (empty($event->getResult())) { return []; } // assembling all widgets in one $result = []; foreach ((array)$event->getResult() as $widget) { if (empty($widget['data'])) { continue; } $instance = WidgetFactory::create($widget['type']); foreach ($widget['data'] as $data) { array_push($result, [ 'type' => $widget['type'], 'title' => $instance->getTitle(), 'icon' => $instance->getIcon(), 'color' => $instance->getColor(), 'data' => $data ]); } } return $result; }
[ "public", "function", "getWidgets", "(", ")", ":", "array", "{", "// get widgets through Event broadcast", "$", "event", "=", "new", "Event", "(", "(", "string", ")", "EventName", "::", "MODEL_DASHBOARDS_GET_WIDGETS", "(", ")", ",", "$", "this", ")", ";", "$",...
getWidgets method. @return mixed[] $result containing all widgets
[ "getWidgets", "method", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Model/Table/WidgetsTable.php#L123-L154
train
QoboLtd/cakephp-search
src/Model/Table/WidgetsTable.php
WidgetsTable.saveDashboardWidgets
public function saveDashboardWidgets(string $dashboardId, array $widgets = []): bool { $result = false; if (empty($widgets)) { return $result; } foreach ($widgets as $item) { $widget = [ 'dashboard_id' => $dashboardId, 'widget_id' => $item['id'], 'widget_type' => $item['type'], 'widget_options' => json_encode($item), 'row' => 0, 'column' => 0, ]; $entity = $this->newEntity(); $entity = $this->patchEntity($entity, $widget); if ($this->save($entity)) { $result = true; } } return $result; }
php
public function saveDashboardWidgets(string $dashboardId, array $widgets = []): bool { $result = false; if (empty($widgets)) { return $result; } foreach ($widgets as $item) { $widget = [ 'dashboard_id' => $dashboardId, 'widget_id' => $item['id'], 'widget_type' => $item['type'], 'widget_options' => json_encode($item), 'row' => 0, 'column' => 0, ]; $entity = $this->newEntity(); $entity = $this->patchEntity($entity, $widget); if ($this->save($entity)) { $result = true; } } return $result; }
[ "public", "function", "saveDashboardWidgets", "(", "string", "$", "dashboardId", ",", "array", "$", "widgets", "=", "[", "]", ")", ":", "bool", "{", "$", "result", "=", "false", ";", "if", "(", "empty", "(", "$", "widgets", ")", ")", "{", "return", "...
Save Dashboard Widgets @param string $dashboardId of the instance @param mixed[] $widgets of the dashboard @return bool $result of the save operation.
[ "Save", "Dashboard", "Widgets" ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Model/Table/WidgetsTable.php#L200-L227
train
rinvex/cortex-pages
src/Http/Controllers/Adminarea/PagesMediaController.php
PagesMediaController.index
public function index(Page $page, MediaDataTable $mediaDataTable) { return $mediaDataTable->with([ 'resource' => $page, 'tabs' => 'adminarea.pages.tabs', 'id' => "adminarea-pages-{$page->getRouteKey()}-media-table", 'url' => route('adminarea.pages.media.store', ['page' => $page]), ])->render('cortex/foundation::adminarea.pages.datatable-dropzone'); }
php
public function index(Page $page, MediaDataTable $mediaDataTable) { return $mediaDataTable->with([ 'resource' => $page, 'tabs' => 'adminarea.pages.tabs', 'id' => "adminarea-pages-{$page->getRouteKey()}-media-table", 'url' => route('adminarea.pages.media.store', ['page' => $page]), ])->render('cortex/foundation::adminarea.pages.datatable-dropzone'); }
[ "public", "function", "index", "(", "Page", "$", "page", ",", "MediaDataTable", "$", "mediaDataTable", ")", "{", "return", "$", "mediaDataTable", "->", "with", "(", "[", "'resource'", "=>", "$", "page", ",", "'tabs'", "=>", "'adminarea.pages.tabs'", ",", "'i...
List all page media. @param \Cortex\Foundation\DataTables\MediaDataTable $mediaDataTable @param \Cortex\Pages\Models\Page $page @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
[ "List", "all", "page", "media", "." ]
7229fedb34d352fda0e721f950c55074f0fb0dce
https://github.com/rinvex/cortex-pages/blob/7229fedb34d352fda0e721f950c55074f0fb0dce/src/Http/Controllers/Adminarea/PagesMediaController.php#L48-L56
train
rinvex/cortex-pages
src/Http/Controllers/Adminarea/PagesMediaController.php
PagesMediaController.store
public function store(ImageFormRequest $request, Page $page): void { $page->addMediaFromRequest('file') ->sanitizingFileName(function ($fileName) { return md5($fileName).'.'.pathinfo($fileName, PATHINFO_EXTENSION); }) ->toMediaCollection('default', config('cortex.pages.media.disk')); }
php
public function store(ImageFormRequest $request, Page $page): void { $page->addMediaFromRequest('file') ->sanitizingFileName(function ($fileName) { return md5($fileName).'.'.pathinfo($fileName, PATHINFO_EXTENSION); }) ->toMediaCollection('default', config('cortex.pages.media.disk')); }
[ "public", "function", "store", "(", "ImageFormRequest", "$", "request", ",", "Page", "$", "page", ")", ":", "void", "{", "$", "page", "->", "addMediaFromRequest", "(", "'file'", ")", "->", "sanitizingFileName", "(", "function", "(", "$", "fileName", ")", "...
Store new page media. @param \Cortex\Foundation\Http\Requests\ImageFormRequest $request @param \Cortex\Pages\Models\Page $page @return void
[ "Store", "new", "page", "media", "." ]
7229fedb34d352fda0e721f950c55074f0fb0dce
https://github.com/rinvex/cortex-pages/blob/7229fedb34d352fda0e721f950c55074f0fb0dce/src/Http/Controllers/Adminarea/PagesMediaController.php#L66-L73
train
rinvex/cortex-pages
src/Http/Controllers/Adminarea/PagesMediaController.php
PagesMediaController.destroy
public function destroy(Page $page, Media $media) { $page->media()->where($media->getKeyName(), $media->getKey())->first()->delete(); return intend([ 'url' => route('adminarea.pages.media.index', ['page' => $page]), 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])], ]); }
php
public function destroy(Page $page, Media $media) { $page->media()->where($media->getKeyName(), $media->getKey())->first()->delete(); return intend([ 'url' => route('adminarea.pages.media.index', ['page' => $page]), 'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/foundation::common.media'), 'identifier' => $media->getRouteKey()])], ]); }
[ "public", "function", "destroy", "(", "Page", "$", "page", ",", "Media", "$", "media", ")", "{", "$", "page", "->", "media", "(", ")", "->", "where", "(", "$", "media", "->", "getKeyName", "(", ")", ",", "$", "media", "->", "getKey", "(", ")", ")...
Destroy given page media. @param \Cortex\Pages\Models\Page $page @param \Spatie\MediaLibrary\Models\Media $media @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
[ "Destroy", "given", "page", "media", "." ]
7229fedb34d352fda0e721f950c55074f0fb0dce
https://github.com/rinvex/cortex-pages/blob/7229fedb34d352fda0e721f950c55074f0fb0dce/src/Http/Controllers/Adminarea/PagesMediaController.php#L83-L91
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.execute
public function execute(array $data) : QueryInterface { $data = Validator::validateData($this->table, $data, $this->user); // initialize query $query = $this->table->find('all'); $where = $this->getWhereClause($data); $group = $this->getGroupByClause($data); $select = $this->getSelectClause($data); $order = [$this->table->aliasField($data['sort_by_field']) => $data['sort_by_order']]; $joins = $this->byAssociations($data); // set joins and append to where and select parameters foreach ($joins as $name => $params) { $query->leftJoinWith($name); if (!empty($params['where'])) { $where = array_merge($where, $params['where']); } if (!empty($params['select'])) { $select = array_merge($select, $params['select']); } } $select = !empty($group) ? $group : $select; if (!empty($group)) { $select = $group; $select[static::GROUP_BY_FIELD] = $query->func()->count($group[0]); } // add query clauses $query->select($select)->where([$data['aggregator'] => $where])->order($order)->group($group); return $query; }
php
public function execute(array $data) : QueryInterface { $data = Validator::validateData($this->table, $data, $this->user); // initialize query $query = $this->table->find('all'); $where = $this->getWhereClause($data); $group = $this->getGroupByClause($data); $select = $this->getSelectClause($data); $order = [$this->table->aliasField($data['sort_by_field']) => $data['sort_by_order']]; $joins = $this->byAssociations($data); // set joins and append to where and select parameters foreach ($joins as $name => $params) { $query->leftJoinWith($name); if (!empty($params['where'])) { $where = array_merge($where, $params['where']); } if (!empty($params['select'])) { $select = array_merge($select, $params['select']); } } $select = !empty($group) ? $group : $select; if (!empty($group)) { $select = $group; $select[static::GROUP_BY_FIELD] = $query->func()->count($group[0]); } // add query clauses $query->select($select)->where([$data['aggregator'] => $where])->order($order)->group($group); return $query; }
[ "public", "function", "execute", "(", "array", "$", "data", ")", ":", "QueryInterface", "{", "$", "data", "=", "Validator", "::", "validateData", "(", "$", "this", "->", "table", ",", "$", "data", ",", "$", "this", "->", "user", ")", ";", "// initializ...
Search method. @param mixed[] $data Request data @return \Cake\Datasource\QueryInterface
[ "Search", "method", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L97-L133
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.create
public function create(array $searchData): string { $searchData = Validator::validateData($this->table, $searchData, $this->user); // pre-save search return $this->preSave($searchData); }
php
public function create(array $searchData): string { $searchData = Validator::validateData($this->table, $searchData, $this->user); // pre-save search return $this->preSave($searchData); }
[ "public", "function", "create", "(", "array", "$", "searchData", ")", ":", "string", "{", "$", "searchData", "=", "Validator", "::", "validateData", "(", "$", "this", "->", "table", ",", "$", "searchData", ",", "$", "this", "->", "user", ")", ";", "// ...
Create search. @param mixed[] $searchData Request data @return string
[ "Create", "search", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L141-L147
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.update
public function update(array $searchData, string $id) { /** * @var \Search\Model\Entity\SavedSearch */ $entity = $this->searchTable->get($id); $entity = $this->normalize($entity, $entity->get('content'), $searchData); return $this->searchTable->save($entity); }
php
public function update(array $searchData, string $id) { /** * @var \Search\Model\Entity\SavedSearch */ $entity = $this->searchTable->get($id); $entity = $this->normalize($entity, $entity->get('content'), $searchData); return $this->searchTable->save($entity); }
[ "public", "function", "update", "(", "array", "$", "searchData", ",", "string", "$", "id", ")", "{", "/**\n * @var \\Search\\Model\\Entity\\SavedSearch\n */", "$", "entity", "=", "$", "this", "->", "searchTable", "->", "get", "(", "$", "id", ")", ...
Update search. @param mixed[] $searchData Request data @param string $id Existing search id @return \Cake\Datasource\EntityInterface|false
[ "Update", "search", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L156-L165
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.get
public function get(string $id): SavedSearch { $id = !empty($id) ? $id : $this->create([]); /** * @var \Search\Model\Entity\SavedSearch */ $entity = $this->searchTable->get($id); $entity = $this->normalize($entity, $entity->get('content'), $entity->get('content')); return $entity; }
php
public function get(string $id): SavedSearch { $id = !empty($id) ? $id : $this->create([]); /** * @var \Search\Model\Entity\SavedSearch */ $entity = $this->searchTable->get($id); $entity = $this->normalize($entity, $entity->get('content'), $entity->get('content')); return $entity; }
[ "public", "function", "get", "(", "string", "$", "id", ")", ":", "SavedSearch", "{", "$", "id", "=", "!", "empty", "(", "$", "id", ")", "?", "$", "id", ":", "$", "this", "->", "create", "(", "[", "]", ")", ";", "/**\n * @var \\Search\\Model\\...
Get search. @param string $id Existing search id @return \Search\Model\Entity\SavedSearch
[ "Get", "search", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L173-L183
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.reset
public function reset(SavedSearch $entity) : ?SavedSearch { $content = $entity->get('content'); // for backward compatibility $saved = isset($content['saved']) ? $content['saved'] : $content; $entity = $this->normalize($entity, $saved, $saved); return $this->searchTable->save($entity) ? $entity : null; }
php
public function reset(SavedSearch $entity) : ?SavedSearch { $content = $entity->get('content'); // for backward compatibility $saved = isset($content['saved']) ? $content['saved'] : $content; $entity = $this->normalize($entity, $saved, $saved); return $this->searchTable->save($entity) ? $entity : null; }
[ "public", "function", "reset", "(", "SavedSearch", "$", "entity", ")", ":", "?", "SavedSearch", "{", "$", "content", "=", "$", "entity", "->", "get", "(", "'content'", ")", ";", "// for backward compatibility", "$", "saved", "=", "isset", "(", "$", "conten...
Reset search. @param \Search\Model\Entity\SavedSearch $entity Search entity @return \Search\Model\Entity\SavedSearch|null
[ "Reset", "search", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L191-L200
train
QoboLtd/cakephp-search
src/Utility/Search.php
Search.prepareData
public function prepareData(ServerRequest $request): array { $result = $request->getData(); $event = new Event((string)EventName::MODEL_SEARCH_CHILD_ITEMS(), $this, [ 'criteria' => $result ]); EventManager::instance()->dispatch($event); $result = $event->result ? $event->result : $result; $value = Hash::get($result, 'criteria.query'); // advanced search if (!$value) { return $result; } // basic search query, converted to search criteria $result['aggregator'] = 'OR'; $basicSearch = new BasicSearch($this->table, $this->user); $result['criteria'] = $basicSearch->getCriteria($value); return $result; }
php
public function prepareData(ServerRequest $request): array { $result = $request->getData(); $event = new Event((string)EventName::MODEL_SEARCH_CHILD_ITEMS(), $this, [ 'criteria' => $result ]); EventManager::instance()->dispatch($event); $result = $event->result ? $event->result : $result; $value = Hash::get($result, 'criteria.query'); // advanced search if (!$value) { return $result; } // basic search query, converted to search criteria $result['aggregator'] = 'OR'; $basicSearch = new BasicSearch($this->table, $this->user); $result['criteria'] = $basicSearch->getCriteria($value); return $result; }
[ "public", "function", "prepareData", "(", "ServerRequest", "$", "request", ")", ":", "array", "{", "$", "result", "=", "$", "request", "->", "getData", "(", ")", ";", "$", "event", "=", "new", "Event", "(", "(", "string", ")", "EventName", "::", "MODEL...
Prepare search data from request data. @param \Cake\Http\ServerRequest $request Request object @return mixed[]
[ "Prepare", "search", "data", "from", "request", "data", "." ]
095a0e822781ac11eade0c03c7729b693daa1ba8
https://github.com/QoboLtd/cakephp-search/blob/095a0e822781ac11eade0c03c7729b693daa1ba8/src/Utility/Search.php#L208-L232
train