repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
SpoonX/SxBootstrap
src/SxBootstrap/View/Helper/Bootstrap/NavigationMenu.php
NavigationMenu.renderDropDownMenu
public function renderDropDownMenu($container = null, array $options = array()) { $menu = $this->getNavigationMenu()->renderMenu($container, $options); $query = new Query($menu, strtolower(mb_detect_encoding($menu))); $uls = $query->execute('li>ul'); /** @var \DOMElement $ul */ foreach ($uls as $key => $ul) { $caret = $uls->getDocument()->createDocumentFragment(); $caret->appendXML('<b class="caret" />'); $index = $key+1; $this->addCss('dropdown-menu', $ul); $ul->setAttribute('role', 'menu'); $ul->setAttribute('aria-labelledby', "drop{$index}"); $li = $ul->parentNode; $this->addCss('dropdown', $li); $a = $li->firstChild; $this->addCss('dropdown-toggle', $a); $a->setAttribute('role', 'button'); $a->setAttribute('data-toggle', 'dropdown'); $a->setAttribute('href', '#'); $a->setAttribute('id', "drop{$index}"); $a->appendChild($caret); } return preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\s*~i', '', $uls->getDocument()->saveHTML()); }
php
public function renderDropDownMenu($container = null, array $options = array()) { $menu = $this->getNavigationMenu()->renderMenu($container, $options); $query = new Query($menu, strtolower(mb_detect_encoding($menu))); $uls = $query->execute('li>ul'); /** @var \DOMElement $ul */ foreach ($uls as $key => $ul) { $caret = $uls->getDocument()->createDocumentFragment(); $caret->appendXML('<b class="caret" />'); $index = $key+1; $this->addCss('dropdown-menu', $ul); $ul->setAttribute('role', 'menu'); $ul->setAttribute('aria-labelledby', "drop{$index}"); $li = $ul->parentNode; $this->addCss('dropdown', $li); $a = $li->firstChild; $this->addCss('dropdown-toggle', $a); $a->setAttribute('role', 'button'); $a->setAttribute('data-toggle', 'dropdown'); $a->setAttribute('href', '#'); $a->setAttribute('id', "drop{$index}"); $a->appendChild($caret); } return preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\s*~i', '', $uls->getDocument()->saveHTML()); }
[ "public", "function", "renderDropDownMenu", "(", "$", "container", "=", "null", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "menu", "=", "$", "this", "->", "getNavigationMenu", "(", ")", "->", "renderMenu", "(", "$", "container", ",", "$", "options", ")", ";", "$", "query", "=", "new", "Query", "(", "$", "menu", ",", "strtolower", "(", "mb_detect_encoding", "(", "$", "menu", ")", ")", ")", ";", "$", "uls", "=", "$", "query", "->", "execute", "(", "'li>ul'", ")", ";", "/** @var \\DOMElement $ul */", "foreach", "(", "$", "uls", "as", "$", "key", "=>", "$", "ul", ")", "{", "$", "caret", "=", "$", "uls", "->", "getDocument", "(", ")", "->", "createDocumentFragment", "(", ")", ";", "$", "caret", "->", "appendXML", "(", "'<b class=\"caret\" />'", ")", ";", "$", "index", "=", "$", "key", "+", "1", ";", "$", "this", "->", "addCss", "(", "'dropdown-menu'", ",", "$", "ul", ")", ";", "$", "ul", "->", "setAttribute", "(", "'role'", ",", "'menu'", ")", ";", "$", "ul", "->", "setAttribute", "(", "'aria-labelledby'", ",", "\"drop{$index}\"", ")", ";", "$", "li", "=", "$", "ul", "->", "parentNode", ";", "$", "this", "->", "addCss", "(", "'dropdown'", ",", "$", "li", ")", ";", "$", "a", "=", "$", "li", "->", "firstChild", ";", "$", "this", "->", "addCss", "(", "'dropdown-toggle'", ",", "$", "a", ")", ";", "$", "a", "->", "setAttribute", "(", "'role'", ",", "'button'", ")", ";", "$", "a", "->", "setAttribute", "(", "'data-toggle'", ",", "'dropdown'", ")", ";", "$", "a", "->", "setAttribute", "(", "'href'", ",", "'#'", ")", ";", "$", "a", "->", "setAttribute", "(", "'id'", ",", "\"drop{$index}\"", ")", ";", "$", "a", "->", "appendChild", "(", "$", "caret", ")", ";", "}", "return", "preg_replace", "(", "'~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\\s*~i'", ",", "''", ",", "$", "uls", "->", "getDocument", "(", ")", "->", "saveHTML", "(", ")", ")", ";", "}" ]
Render a dropdown menu @param string|\SpiffyNavigation\Container|null $container @param array $options @return string
[ "Render", "a", "dropdown", "menu" ]
768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6
https://github.com/SpoonX/SxBootstrap/blob/768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6/src/SxBootstrap/View/Helper/Bootstrap/NavigationMenu.php#L37-L66
train
SpoonX/SxBootstrap
src/SxBootstrap/View/Helper/Bootstrap/NavigationMenu.php
NavigationMenu.addCss
protected function addCss($css, \DOMElement $el) { $el->setAttribute( 'class', $el->getAttribute('class') ? $el->getAttribute('class') . ' ' . $css : $css ); return $el; }
php
protected function addCss($css, \DOMElement $el) { $el->setAttribute( 'class', $el->getAttribute('class') ? $el->getAttribute('class') . ' ' . $css : $css ); return $el; }
[ "protected", "function", "addCss", "(", "$", "css", ",", "\\", "DOMElement", "$", "el", ")", "{", "$", "el", "->", "setAttribute", "(", "'class'", ",", "$", "el", "->", "getAttribute", "(", "'class'", ")", "?", "$", "el", "->", "getAttribute", "(", "'class'", ")", ".", "' '", ".", "$", "css", ":", "$", "css", ")", ";", "return", "$", "el", ";", "}" ]
Add css to a DomElement @param $css @param \DOMElement $el @return \DOMElement
[ "Add", "css", "to", "a", "DomElement" ]
768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6
https://github.com/SpoonX/SxBootstrap/blob/768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6/src/SxBootstrap/View/Helper/Bootstrap/NavigationMenu.php#L75-L85
train
Nextpertise/PdoBulk
src/PdoBulk/PdoBulk.php
PdoBulk.flushQueue
public function flushQueue($table, $onduplicate = null) { if (gettype($table) != 'string') { throw new Exception('First parameter should be string, ' . gettype($table) . ' given.'); } if (isset($this->queue[$table]) && $this->queue[$table]) { // Define query $query = "INSERT INTO `" . $table . "` (`" . implode("`,`", array_keys($this->queue[$table][0])) . "`) VALUES "; // Count number of parameters in element $prefixOuter = ''; $rowPlaces = ''; foreach ($this->queue[$table] as $entry) { $prefixInner = ''; $rowPlaces .= $prefixOuter . '('; foreach ($entry as $column) { if (is_object($column) && $column instanceof PdoBulkSubquery) { $rowPlaces .= $prefixInner . '(' . $column->getQuery() . ')'; } else { $rowPlaces .= $prefixInner . '?'; } $prefixInner = ','; } $rowPlaces .= ')'; $prefixOuter = ','; } $query .= $rowPlaces; if ($onduplicate && gettype($onduplicate) == 'string') { $query .= ' ' . $onduplicate; } $stmt = $this->getPdo()->prepare($query); // Prepare binding values for execution $values = array(); foreach ($this->queue[$table] as $entry) { foreach ($entry as $column_name => $column_value) { if (is_object($column_value) && $column_value instanceof PdoBulkSubquery) { unset($entry[$column_name]); } } $values = array_merge($values, array_values($entry)); } $stmt->execute($values); $this->queue[$table] = array(); return true; } else { return false; } }
php
public function flushQueue($table, $onduplicate = null) { if (gettype($table) != 'string') { throw new Exception('First parameter should be string, ' . gettype($table) . ' given.'); } if (isset($this->queue[$table]) && $this->queue[$table]) { // Define query $query = "INSERT INTO `" . $table . "` (`" . implode("`,`", array_keys($this->queue[$table][0])) . "`) VALUES "; // Count number of parameters in element $prefixOuter = ''; $rowPlaces = ''; foreach ($this->queue[$table] as $entry) { $prefixInner = ''; $rowPlaces .= $prefixOuter . '('; foreach ($entry as $column) { if (is_object($column) && $column instanceof PdoBulkSubquery) { $rowPlaces .= $prefixInner . '(' . $column->getQuery() . ')'; } else { $rowPlaces .= $prefixInner . '?'; } $prefixInner = ','; } $rowPlaces .= ')'; $prefixOuter = ','; } $query .= $rowPlaces; if ($onduplicate && gettype($onduplicate) == 'string') { $query .= ' ' . $onduplicate; } $stmt = $this->getPdo()->prepare($query); // Prepare binding values for execution $values = array(); foreach ($this->queue[$table] as $entry) { foreach ($entry as $column_name => $column_value) { if (is_object($column_value) && $column_value instanceof PdoBulkSubquery) { unset($entry[$column_name]); } } $values = array_merge($values, array_values($entry)); } $stmt->execute($values); $this->queue[$table] = array(); return true; } else { return false; } }
[ "public", "function", "flushQueue", "(", "$", "table", ",", "$", "onduplicate", "=", "null", ")", "{", "if", "(", "gettype", "(", "$", "table", ")", "!=", "'string'", ")", "{", "throw", "new", "Exception", "(", "'First parameter should be string, '", ".", "gettype", "(", "$", "table", ")", ".", "' given.'", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "queue", "[", "$", "table", "]", ")", "&&", "$", "this", "->", "queue", "[", "$", "table", "]", ")", "{", "// Define query", "$", "query", "=", "\"INSERT INTO `\"", ".", "$", "table", ".", "\"` (`\"", ".", "implode", "(", "\"`,`\"", ",", "array_keys", "(", "$", "this", "->", "queue", "[", "$", "table", "]", "[", "0", "]", ")", ")", ".", "\"`) VALUES \"", ";", "// Count number of parameters in element", "$", "prefixOuter", "=", "''", ";", "$", "rowPlaces", "=", "''", ";", "foreach", "(", "$", "this", "->", "queue", "[", "$", "table", "]", "as", "$", "entry", ")", "{", "$", "prefixInner", "=", "''", ";", "$", "rowPlaces", ".=", "$", "prefixOuter", ".", "'('", ";", "foreach", "(", "$", "entry", "as", "$", "column", ")", "{", "if", "(", "is_object", "(", "$", "column", ")", "&&", "$", "column", "instanceof", "PdoBulkSubquery", ")", "{", "$", "rowPlaces", ".=", "$", "prefixInner", ".", "'('", ".", "$", "column", "->", "getQuery", "(", ")", ".", "')'", ";", "}", "else", "{", "$", "rowPlaces", ".=", "$", "prefixInner", ".", "'?'", ";", "}", "$", "prefixInner", "=", "','", ";", "}", "$", "rowPlaces", ".=", "')'", ";", "$", "prefixOuter", "=", "','", ";", "}", "$", "query", ".=", "$", "rowPlaces", ";", "if", "(", "$", "onduplicate", "&&", "gettype", "(", "$", "onduplicate", ")", "==", "'string'", ")", "{", "$", "query", ".=", "' '", ".", "$", "onduplicate", ";", "}", "$", "stmt", "=", "$", "this", "->", "getPdo", "(", ")", "->", "prepare", "(", "$", "query", ")", ";", "// Prepare binding values for execution", "$", "values", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "queue", "[", "$", "table", "]", "as", "$", "entry", ")", "{", "foreach", "(", "$", "entry", "as", "$", "column_name", "=>", "$", "column_value", ")", "{", "if", "(", "is_object", "(", "$", "column_value", ")", "&&", "$", "column_value", "instanceof", "PdoBulkSubquery", ")", "{", "unset", "(", "$", "entry", "[", "$", "column_name", "]", ")", ";", "}", "}", "$", "values", "=", "array_merge", "(", "$", "values", ",", "array_values", "(", "$", "entry", ")", ")", ";", "}", "$", "stmt", "->", "execute", "(", "$", "values", ")", ";", "$", "this", "->", "queue", "[", "$", "table", "]", "=", "array", "(", ")", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Bulk insert logic
[ "Bulk", "insert", "logic" ]
21426f998fe292c11c356e75ffa6f716e2c507c7
https://github.com/Nextpertise/PdoBulk/blob/21426f998fe292c11c356e75ffa6f716e2c507c7/src/PdoBulk/PdoBulk.php#L31-L81
train
chilimatic/chilimatic-framework
lib/cache/engine/Memcached.php
Memcached.deleteFromList
public function deleteFromList($key_array = array()) { if (empty($key_array)) return false; foreach ($key_array as $key_del) { if (empty($this->cacheListing)) break; foreach ($this->cacheListing as $key) { if (mb_strpos(mb_strtolower($key), mb_strtolower($key_del)) !== false) $this->delete($key); } } return true; }
php
public function deleteFromList($key_array = array()) { if (empty($key_array)) return false; foreach ($key_array as $key_del) { if (empty($this->cacheListing)) break; foreach ($this->cacheListing as $key) { if (mb_strpos(mb_strtolower($key), mb_strtolower($key_del)) !== false) $this->delete($key); } } return true; }
[ "public", "function", "deleteFromList", "(", "$", "key_array", "=", "array", "(", ")", ")", "{", "if", "(", "empty", "(", "$", "key_array", ")", ")", "return", "false", ";", "foreach", "(", "$", "key_array", "as", "$", "key_del", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "cacheListing", ")", ")", "break", ";", "foreach", "(", "$", "this", "->", "cacheListing", "as", "$", "key", ")", "{", "if", "(", "mb_strpos", "(", "mb_strtolower", "(", "$", "key", ")", ",", "mb_strtolower", "(", "$", "key_del", ")", ")", "!==", "false", ")", "$", "this", "->", "delete", "(", "$", "key", ")", ";", "}", "}", "return", "true", ";", "}" ]
delete memcached values based on an input array @param array $key_array @return bool
[ "delete", "memcached", "values", "based", "on", "an", "input", "array" ]
8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/cache/engine/Memcached.php#L256-L269
train
gbprod/doctrine-specification
src/DoctrineSpecification/Handler.php
Handler.handle
public function handle(Specification $spec) { $factory = $this->registry->getFactory($spec); return $factory->create($spec, $this->qb); }
php
public function handle(Specification $spec) { $factory = $this->registry->getFactory($spec); return $factory->create($spec, $this->qb); }
[ "public", "function", "handle", "(", "Specification", "$", "spec", ")", "{", "$", "factory", "=", "$", "this", "->", "registry", "->", "getFactory", "(", "$", "spec", ")", ";", "return", "$", "factory", "->", "create", "(", "$", "spec", ",", "$", "this", "->", "qb", ")", ";", "}" ]
handle specification for queryfactory @param Specification $spec @return Base
[ "handle", "specification", "for", "queryfactory" ]
348e8ec31547f4949a193d21b3a1d5cdb48b23cb
https://github.com/gbprod/doctrine-specification/blob/348e8ec31547f4949a193d21b3a1d5cdb48b23cb/src/DoctrineSpecification/Handler.php#L56-L61
train
WolfMicrosystems/ldap
src/WMS/Library/Ldap/Enum/AbstractEnum.php
AbstractEnum.isValid
public static function isValid($value) { if (__CLASS__ === get_called_class()) { throw new \RuntimeException('Cannot call isValid() on ' . __CLASS__); } $reflectionClass = new \ReflectionClass(get_called_class()); $validValues = $reflectionClass->getConstants(); if (static::isBitFlag()) { $bitFlagAllOn = 0; foreach ($validValues as $validValue) { $bitFlagAllOn |= $validValue; } return ($value | $bitFlagAllOn) === $bitFlagAllOn; } return in_array($value, $validValues, true); }
php
public static function isValid($value) { if (__CLASS__ === get_called_class()) { throw new \RuntimeException('Cannot call isValid() on ' . __CLASS__); } $reflectionClass = new \ReflectionClass(get_called_class()); $validValues = $reflectionClass->getConstants(); if (static::isBitFlag()) { $bitFlagAllOn = 0; foreach ($validValues as $validValue) { $bitFlagAllOn |= $validValue; } return ($value | $bitFlagAllOn) === $bitFlagAllOn; } return in_array($value, $validValues, true); }
[ "public", "static", "function", "isValid", "(", "$", "value", ")", "{", "if", "(", "__CLASS__", "===", "get_called_class", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Cannot call isValid() on '", ".", "__CLASS__", ")", ";", "}", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "get_called_class", "(", ")", ")", ";", "$", "validValues", "=", "$", "reflectionClass", "->", "getConstants", "(", ")", ";", "if", "(", "static", "::", "isBitFlag", "(", ")", ")", "{", "$", "bitFlagAllOn", "=", "0", ";", "foreach", "(", "$", "validValues", "as", "$", "validValue", ")", "{", "$", "bitFlagAllOn", "|=", "$", "validValue", ";", "}", "return", "(", "$", "value", "|", "$", "bitFlagAllOn", ")", "===", "$", "bitFlagAllOn", ";", "}", "return", "in_array", "(", "$", "value", ",", "$", "validValues", ",", "true", ")", ";", "}" ]
Checks if the value is valid according to the enumeration. @param mixed $value @return bool @throws \RuntimeException
[ "Checks", "if", "the", "value", "is", "valid", "according", "to", "the", "enumeration", "." ]
872bbdc6127a41f0c51f2aa73425b8063a5c8148
https://github.com/WolfMicrosystems/ldap/blob/872bbdc6127a41f0c51f2aa73425b8063a5c8148/src/WMS/Library/Ldap/Enum/AbstractEnum.php#L28-L48
train
spiral/views
src/ViewSource.php
ViewSource.withCode
public function withCode(string $code): ViewSource { $context = clone $this; $context->code = $code; return $context; }
php
public function withCode(string $code): ViewSource { $context = clone $this; $context->code = $code; return $context; }
[ "public", "function", "withCode", "(", "string", "$", "code", ")", ":", "ViewSource", "{", "$", "context", "=", "clone", "$", "this", ";", "$", "context", "->", "code", "=", "$", "code", ";", "return", "$", "context", ";", "}" ]
Get source copy with redefined code. @param string $code @return self
[ "Get", "source", "copy", "with", "redefined", "code", "." ]
0e35697204dfffabf71546d20e89f14b50414a9a
https://github.com/spiral/views/blob/0e35697204dfffabf71546d20e89f14b50414a9a/src/ViewSource.php#L87-L93
train
g4code/http
src/Response.php
Response.setRedirect
public function setRedirect($url, $code = 302) { $this->canSendHeaders(true); $this->setHeader('Location', $url, true) ->setHttpResponseCode($code); return $this; }
php
public function setRedirect($url, $code = 302) { $this->canSendHeaders(true); $this->setHeader('Location', $url, true) ->setHttpResponseCode($code); return $this; }
[ "public", "function", "setRedirect", "(", "$", "url", ",", "$", "code", "=", "302", ")", "{", "$", "this", "->", "canSendHeaders", "(", "true", ")", ";", "$", "this", "->", "setHeader", "(", "'Location'", ",", "$", "url", ",", "true", ")", "->", "setHttpResponseCode", "(", "$", "code", ")", ";", "return", "$", "this", ";", "}" ]
Set redirect URL Sets Location header and response code. Forces replacement of any prior redirects. @param string $url @param int $code @return \G4\Http\Response
[ "Set", "redirect", "URL" ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L146-L153
train
g4code/http
src/Response.php
Response.sendHeaders
public function sendHeaders() { // Only check if we can send headers if we have headers to send if (count($this->_headersRaw) || count($this->_headers) || (200 != $this->_httpResponseCode)) { $this->canSendHeaders(true); } elseif (200 == $this->_httpResponseCode) { // Haven't changed the response code, and we have no headers return $this; } $httpCodeSent = false; foreach ($this->_headersRaw as $header) { if (!$httpCodeSent && $this->_httpResponseCode) { header($header, true, $this->_httpResponseCode); $httpCodeSent = true; } else { header($header); } } foreach ($this->_headers as $header) { if (!$httpCodeSent && $this->_httpResponseCode) { header($header['name'] . ': ' . $header['value'], $header['replace'], $this->_httpResponseCode); $httpCodeSent = true; } else { header($header['name'] . ': ' . $header['value'], $header['replace']); } } if (!$httpCodeSent) { header('HTTP/1.1 ' . $this->_httpResponseCode); $httpCodeSent = true; } return $this; }
php
public function sendHeaders() { // Only check if we can send headers if we have headers to send if (count($this->_headersRaw) || count($this->_headers) || (200 != $this->_httpResponseCode)) { $this->canSendHeaders(true); } elseif (200 == $this->_httpResponseCode) { // Haven't changed the response code, and we have no headers return $this; } $httpCodeSent = false; foreach ($this->_headersRaw as $header) { if (!$httpCodeSent && $this->_httpResponseCode) { header($header, true, $this->_httpResponseCode); $httpCodeSent = true; } else { header($header); } } foreach ($this->_headers as $header) { if (!$httpCodeSent && $this->_httpResponseCode) { header($header['name'] . ': ' . $header['value'], $header['replace'], $this->_httpResponseCode); $httpCodeSent = true; } else { header($header['name'] . ': ' . $header['value'], $header['replace']); } } if (!$httpCodeSent) { header('HTTP/1.1 ' . $this->_httpResponseCode); $httpCodeSent = true; } return $this; }
[ "public", "function", "sendHeaders", "(", ")", "{", "// Only check if we can send headers if we have headers to send", "if", "(", "count", "(", "$", "this", "->", "_headersRaw", ")", "||", "count", "(", "$", "this", "->", "_headers", ")", "||", "(", "200", "!=", "$", "this", "->", "_httpResponseCode", ")", ")", "{", "$", "this", "->", "canSendHeaders", "(", "true", ")", ";", "}", "elseif", "(", "200", "==", "$", "this", "->", "_httpResponseCode", ")", "{", "// Haven't changed the response code, and we have no headers", "return", "$", "this", ";", "}", "$", "httpCodeSent", "=", "false", ";", "foreach", "(", "$", "this", "->", "_headersRaw", "as", "$", "header", ")", "{", "if", "(", "!", "$", "httpCodeSent", "&&", "$", "this", "->", "_httpResponseCode", ")", "{", "header", "(", "$", "header", ",", "true", ",", "$", "this", "->", "_httpResponseCode", ")", ";", "$", "httpCodeSent", "=", "true", ";", "}", "else", "{", "header", "(", "$", "header", ")", ";", "}", "}", "foreach", "(", "$", "this", "->", "_headers", "as", "$", "header", ")", "{", "if", "(", "!", "$", "httpCodeSent", "&&", "$", "this", "->", "_httpResponseCode", ")", "{", "header", "(", "$", "header", "[", "'name'", "]", ".", "': '", ".", "$", "header", "[", "'value'", "]", ",", "$", "header", "[", "'replace'", "]", ",", "$", "this", "->", "_httpResponseCode", ")", ";", "$", "httpCodeSent", "=", "true", ";", "}", "else", "{", "header", "(", "$", "header", "[", "'name'", "]", ".", "': '", ".", "$", "header", "[", "'value'", "]", ",", "$", "header", "[", "'replace'", "]", ")", ";", "}", "}", "if", "(", "!", "$", "httpCodeSent", ")", "{", "header", "(", "'HTTP/1.1 '", ".", "$", "this", "->", "_httpResponseCode", ")", ";", "$", "httpCodeSent", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Send all headers Sends any headers specified. If an {@link setHttpResponseCode() HTTP response code} has been specified, it is sent with the first header. @return \G4\Http\Response
[ "Send", "all", "headers" ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L289-L325
train
g4code/http
src/Response.php
Response.setBody
public function setBody($content, $name = null) { if ((null === $name) || !is_string($name)) { $this->_body = array('default' => (string) $content); } else { $this->_body[$name] = (string) $content; } return $this; }
php
public function setBody($content, $name = null) { if ((null === $name) || !is_string($name)) { $this->_body = array('default' => (string) $content); } else { $this->_body[$name] = (string) $content; } return $this; }
[ "public", "function", "setBody", "(", "$", "content", ",", "$", "name", "=", "null", ")", "{", "if", "(", "(", "null", "===", "$", "name", ")", "||", "!", "is_string", "(", "$", "name", ")", ")", "{", "$", "this", "->", "_body", "=", "array", "(", "'default'", "=>", "(", "string", ")", "$", "content", ")", ";", "}", "else", "{", "$", "this", "->", "_body", "[", "$", "name", "]", "=", "(", "string", ")", "$", "content", ";", "}", "return", "$", "this", ";", "}" ]
Set body content If $name is not passed, or is not a string, resets the entire body and sets the 'default' key to $content. If $name is a string, sets the named segment in the body array to $content. @param string $content @param null|string $name @return \G4\Http\Response
[ "Set", "body", "content" ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L340-L349
train
g4code/http
src/Response.php
Response.appendBody
public function appendBody($content, $name = null) { if ((null === $name) || !is_string($name)) { if (isset($this->_body['default'])) { $this->_body['default'] .= (string) $content; } else { return $this->append('default', $content); } } elseif (isset($this->_body[$name])) { $this->_body[$name] .= (string) $content; } else { return $this->append($name, $content); } return $this; }
php
public function appendBody($content, $name = null) { if ((null === $name) || !is_string($name)) { if (isset($this->_body['default'])) { $this->_body['default'] .= (string) $content; } else { return $this->append('default', $content); } } elseif (isset($this->_body[$name])) { $this->_body[$name] .= (string) $content; } else { return $this->append($name, $content); } return $this; }
[ "public", "function", "appendBody", "(", "$", "content", ",", "$", "name", "=", "null", ")", "{", "if", "(", "(", "null", "===", "$", "name", ")", "||", "!", "is_string", "(", "$", "name", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_body", "[", "'default'", "]", ")", ")", "{", "$", "this", "->", "_body", "[", "'default'", "]", ".=", "(", "string", ")", "$", "content", ";", "}", "else", "{", "return", "$", "this", "->", "append", "(", "'default'", ",", "$", "content", ")", ";", "}", "}", "elseif", "(", "isset", "(", "$", "this", "->", "_body", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "_body", "[", "$", "name", "]", ".=", "(", "string", ")", "$", "content", ";", "}", "else", "{", "return", "$", "this", "->", "append", "(", "$", "name", ",", "$", "content", ")", ";", "}", "return", "$", "this", ";", "}" ]
Append content to the body content @param string $content @param null|string $name @return \G4\Http\Response
[ "Append", "content", "to", "the", "body", "content" ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L358-L373
train
g4code/http
src/Response.php
Response.clearBody
public function clearBody($name = null) { if (null !== $name) { $name = (string) $name; if (isset($this->_body[$name])) { unset($this->_body[$name]); return true; } return false; } $this->_body = array(); return true; }
php
public function clearBody($name = null) { if (null !== $name) { $name = (string) $name; if (isset($this->_body[$name])) { unset($this->_body[$name]); return true; } return false; } $this->_body = array(); return true; }
[ "public", "function", "clearBody", "(", "$", "name", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "name", ")", "{", "$", "name", "=", "(", "string", ")", "$", "name", ";", "if", "(", "isset", "(", "$", "this", "->", "_body", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "_body", "[", "$", "name", "]", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "$", "this", "->", "_body", "=", "array", "(", ")", ";", "return", "true", ";", "}" ]
Clear body array With no arguments, clears the entire body array. Given a $name, clears just that named segment; if no segment matching $name exists, returns false to indicate an error. @param string $name Named segment to clear @return boolean
[ "Clear", "body", "array" ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L385-L399
train
g4code/http
src/Response.php
Response.append
public function append($name, $content) { if (!is_string($name)) { throw new \Exception('Invalid body segment key ("' . gettype($name) . '")'); } if (isset($this->_body[$name])) { unset($this->_body[$name]); } $this->_body[$name] = (string) $content; return $this; }
php
public function append($name, $content) { if (!is_string($name)) { throw new \Exception('Invalid body segment key ("' . gettype($name) . '")'); } if (isset($this->_body[$name])) { unset($this->_body[$name]); } $this->_body[$name] = (string) $content; return $this; }
[ "public", "function", "append", "(", "$", "name", ",", "$", "content", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Invalid body segment key (\"'", ".", "gettype", "(", "$", "name", ")", ".", "'\")'", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_body", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "_body", "[", "$", "name", "]", ")", ";", "}", "$", "this", "->", "_body", "[", "$", "name", "]", "=", "(", "string", ")", "$", "content", ";", "return", "$", "this", ";", "}" ]
Append a named body segment to the body content array If segment already exists, replaces with $content and places at end of array. @param string $name @param string $content @return \G4\Http\Response
[ "Append", "a", "named", "body", "segment", "to", "the", "body", "content", "array" ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L437-L449
train
g4code/http
src/Response.php
Response.insert
public function insert($name, $content, $parent = null, $before = false) { if (!is_string($name)) { throw new \Exception('Invalid body segment key ("' . gettype($name) . '")'); } if ((null !== $parent) && !is_string($parent)) { throw new \Exception('Invalid body segment parent key ("' . gettype($parent) . '")'); } if (isset($this->_body[$name])) { unset($this->_body[$name]); } if ((null === $parent) || !isset($this->_body[$parent])) { return $this->append($name, $content); } $ins = array($name => (string) $content); $keys = array_keys($this->_body); $loc = array_search($parent, $keys); if (!$before) { // Increment location if not inserting before ++$loc; } if (0 === $loc) { // If location of key is 0, we're prepending $this->_body = $ins + $this->_body; } elseif ($loc >= (count($this->_body))) { // If location of key is maximal, we're appending $this->_body = $this->_body + $ins; } else { // Otherwise, insert at location specified $pre = array_slice($this->_body, 0, $loc); $post = array_slice($this->_body, $loc); $this->_body = $pre + $ins + $post; } return $this; }
php
public function insert($name, $content, $parent = null, $before = false) { if (!is_string($name)) { throw new \Exception('Invalid body segment key ("' . gettype($name) . '")'); } if ((null !== $parent) && !is_string($parent)) { throw new \Exception('Invalid body segment parent key ("' . gettype($parent) . '")'); } if (isset($this->_body[$name])) { unset($this->_body[$name]); } if ((null === $parent) || !isset($this->_body[$parent])) { return $this->append($name, $content); } $ins = array($name => (string) $content); $keys = array_keys($this->_body); $loc = array_search($parent, $keys); if (!$before) { // Increment location if not inserting before ++$loc; } if (0 === $loc) { // If location of key is 0, we're prepending $this->_body = $ins + $this->_body; } elseif ($loc >= (count($this->_body))) { // If location of key is maximal, we're appending $this->_body = $this->_body + $ins; } else { // Otherwise, insert at location specified $pre = array_slice($this->_body, 0, $loc); $post = array_slice($this->_body, $loc); $this->_body = $pre + $ins + $post; } return $this; }
[ "public", "function", "insert", "(", "$", "name", ",", "$", "content", ",", "$", "parent", "=", "null", ",", "$", "before", "=", "false", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Invalid body segment key (\"'", ".", "gettype", "(", "$", "name", ")", ".", "'\")'", ")", ";", "}", "if", "(", "(", "null", "!==", "$", "parent", ")", "&&", "!", "is_string", "(", "$", "parent", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Invalid body segment parent key (\"'", ".", "gettype", "(", "$", "parent", ")", ".", "'\")'", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_body", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "_body", "[", "$", "name", "]", ")", ";", "}", "if", "(", "(", "null", "===", "$", "parent", ")", "||", "!", "isset", "(", "$", "this", "->", "_body", "[", "$", "parent", "]", ")", ")", "{", "return", "$", "this", "->", "append", "(", "$", "name", ",", "$", "content", ")", ";", "}", "$", "ins", "=", "array", "(", "$", "name", "=>", "(", "string", ")", "$", "content", ")", ";", "$", "keys", "=", "array_keys", "(", "$", "this", "->", "_body", ")", ";", "$", "loc", "=", "array_search", "(", "$", "parent", ",", "$", "keys", ")", ";", "if", "(", "!", "$", "before", ")", "{", "// Increment location if not inserting before", "++", "$", "loc", ";", "}", "if", "(", "0", "===", "$", "loc", ")", "{", "// If location of key is 0, we're prepending", "$", "this", "->", "_body", "=", "$", "ins", "+", "$", "this", "->", "_body", ";", "}", "elseif", "(", "$", "loc", ">=", "(", "count", "(", "$", "this", "->", "_body", ")", ")", ")", "{", "// If location of key is maximal, we're appending", "$", "this", "->", "_body", "=", "$", "this", "->", "_body", "+", "$", "ins", ";", "}", "else", "{", "// Otherwise, insert at location specified", "$", "pre", "=", "array_slice", "(", "$", "this", "->", "_body", ",", "0", ",", "$", "loc", ")", ";", "$", "post", "=", "array_slice", "(", "$", "this", "->", "_body", ",", "$", "loc", ")", ";", "$", "this", "->", "_body", "=", "$", "pre", "+", "$", "ins", "+", "$", "post", ";", "}", "return", "$", "this", ";", "}" ]
Insert a named segment into the body content array @param string $name @param string $content @param string $parent @param boolean $before Whether to insert the new segment before or after the parent. Defaults to false (after) @return \G4\Http\Response
[ "Insert", "a", "named", "segment", "into", "the", "body", "content", "array" ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L487-L527
train
g4code/http
src/Response.php
Response.hasExceptionOfType
public function hasExceptionOfType($type) { foreach ($this->_exceptions as $e) { if ($e instanceof $type) { return true; } } return false; }
php
public function hasExceptionOfType($type) { foreach ($this->_exceptions as $e) { if ($e instanceof $type) { return true; } } return false; }
[ "public", "function", "hasExceptionOfType", "(", "$", "type", ")", "{", "foreach", "(", "$", "this", "->", "_exceptions", "as", "$", "e", ")", "{", "if", "(", "$", "e", "instanceof", "$", "type", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Does the response object contain an exception of a given type? @param string $type @return boolean
[ "Does", "the", "response", "object", "contain", "an", "exception", "of", "a", "given", "type?" ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L578-L587
train
g4code/http
src/Response.php
Response.hasExceptionOfMessage
public function hasExceptionOfMessage($message) { foreach ($this->_exceptions as $e) { if ($message == $e->getMessage()) { return true; } } return false; }
php
public function hasExceptionOfMessage($message) { foreach ($this->_exceptions as $e) { if ($message == $e->getMessage()) { return true; } } return false; }
[ "public", "function", "hasExceptionOfMessage", "(", "$", "message", ")", "{", "foreach", "(", "$", "this", "->", "_exceptions", "as", "$", "e", ")", "{", "if", "(", "$", "message", "==", "$", "e", "->", "getMessage", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Does the response object contain an exception with a given message? @param string $message @return boolean
[ "Does", "the", "response", "object", "contain", "an", "exception", "with", "a", "given", "message?" ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L595-L604
train
g4code/http
src/Response.php
Response.hasExceptionOfCode
public function hasExceptionOfCode($code) { $code = (int) $code; foreach ($this->_exceptions as $e) { if ($code == $e->getCode()) { return true; } } return false; }
php
public function hasExceptionOfCode($code) { $code = (int) $code; foreach ($this->_exceptions as $e) { if ($code == $e->getCode()) { return true; } } return false; }
[ "public", "function", "hasExceptionOfCode", "(", "$", "code", ")", "{", "$", "code", "=", "(", "int", ")", "$", "code", ";", "foreach", "(", "$", "this", "->", "_exceptions", "as", "$", "e", ")", "{", "if", "(", "$", "code", "==", "$", "e", "->", "getCode", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Does the response object contain an exception with a given code? @param int $code @return boolean
[ "Does", "the", "response", "object", "contain", "an", "exception", "with", "a", "given", "code?" ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L612-L622
train
g4code/http
src/Response.php
Response.getExceptionByType
public function getExceptionByType($type) { $exceptions = array(); foreach ($this->_exceptions as $e) { if ($e instanceof $type) { $exceptions[] = $e; } } if (empty($exceptions)) { $exceptions = false; } return $exceptions; }
php
public function getExceptionByType($type) { $exceptions = array(); foreach ($this->_exceptions as $e) { if ($e instanceof $type) { $exceptions[] = $e; } } if (empty($exceptions)) { $exceptions = false; } return $exceptions; }
[ "public", "function", "getExceptionByType", "(", "$", "type", ")", "{", "$", "exceptions", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_exceptions", "as", "$", "e", ")", "{", "if", "(", "$", "e", "instanceof", "$", "type", ")", "{", "$", "exceptions", "[", "]", "=", "$", "e", ";", "}", "}", "if", "(", "empty", "(", "$", "exceptions", ")", ")", "{", "$", "exceptions", "=", "false", ";", "}", "return", "$", "exceptions", ";", "}" ]
Retrieve all exceptions of a given type @param string $type @return false|array
[ "Retrieve", "all", "exceptions", "of", "a", "given", "type" ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L630-L644
train
g4code/http
src/Response.php
Response.getExceptionByMessage
public function getExceptionByMessage($message) { $exceptions = array(); foreach ($this->_exceptions as $e) { if ($message == $e->getMessage()) { $exceptions[] = $e; } } if (empty($exceptions)) { $exceptions = false; } return $exceptions; }
php
public function getExceptionByMessage($message) { $exceptions = array(); foreach ($this->_exceptions as $e) { if ($message == $e->getMessage()) { $exceptions[] = $e; } } if (empty($exceptions)) { $exceptions = false; } return $exceptions; }
[ "public", "function", "getExceptionByMessage", "(", "$", "message", ")", "{", "$", "exceptions", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_exceptions", "as", "$", "e", ")", "{", "if", "(", "$", "message", "==", "$", "e", "->", "getMessage", "(", ")", ")", "{", "$", "exceptions", "[", "]", "=", "$", "e", ";", "}", "}", "if", "(", "empty", "(", "$", "exceptions", ")", ")", "{", "$", "exceptions", "=", "false", ";", "}", "return", "$", "exceptions", ";", "}" ]
Retrieve all exceptions of a given message @param string $message @return false|array
[ "Retrieve", "all", "exceptions", "of", "a", "given", "message" ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L652-L666
train
g4code/http
src/Response.php
Response.getExceptionByCode
public function getExceptionByCode($code) { $code = (int) $code; $exceptions = array(); foreach ($this->_exceptions as $e) { if ($code == $e->getCode()) { $exceptions[] = $e; } } if (empty($exceptions)) { $exceptions = false; } return $exceptions; }
php
public function getExceptionByCode($code) { $code = (int) $code; $exceptions = array(); foreach ($this->_exceptions as $e) { if ($code == $e->getCode()) { $exceptions[] = $e; } } if (empty($exceptions)) { $exceptions = false; } return $exceptions; }
[ "public", "function", "getExceptionByCode", "(", "$", "code", ")", "{", "$", "code", "=", "(", "int", ")", "$", "code", ";", "$", "exceptions", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_exceptions", "as", "$", "e", ")", "{", "if", "(", "$", "code", "==", "$", "e", "->", "getCode", "(", ")", ")", "{", "$", "exceptions", "[", "]", "=", "$", "e", ";", "}", "}", "if", "(", "empty", "(", "$", "exceptions", ")", ")", "{", "$", "exceptions", "=", "false", ";", "}", "return", "$", "exceptions", ";", "}" ]
Retrieve all exceptions of a given code @param mixed $code @return void
[ "Retrieve", "all", "exceptions", "of", "a", "given", "code" ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L674-L689
train
g4code/http
src/Response.php
Response.sendResponse
public function sendResponse() { $this->sendHeaders(); if ($this->isException() && $this->renderExceptions()) { $exceptions = ''; foreach ($this->getException() as $e) { $exceptions .= $e->__toString() . "\n"; } echo $exceptions; return; } $this->outputBody(); }
php
public function sendResponse() { $this->sendHeaders(); if ($this->isException() && $this->renderExceptions()) { $exceptions = ''; foreach ($this->getException() as $e) { $exceptions .= $e->__toString() . "\n"; } echo $exceptions; return; } $this->outputBody(); }
[ "public", "function", "sendResponse", "(", ")", "{", "$", "this", "->", "sendHeaders", "(", ")", ";", "if", "(", "$", "this", "->", "isException", "(", ")", "&&", "$", "this", "->", "renderExceptions", "(", ")", ")", "{", "$", "exceptions", "=", "''", ";", "foreach", "(", "$", "this", "->", "getException", "(", ")", "as", "$", "e", ")", "{", "$", "exceptions", ".=", "$", "e", "->", "__toString", "(", ")", ".", "\"\\n\"", ";", "}", "echo", "$", "exceptions", ";", "return", ";", "}", "$", "this", "->", "outputBody", "(", ")", ";", "}" ]
Send the response, including all headers, rendering exceptions if so requested. @return void
[ "Send", "the", "response", "including", "all", "headers", "rendering", "exceptions", "if", "so", "requested", "." ]
270a6b30d49a3656aea6d85e400f18293427926e
https://github.com/g4code/http/blob/270a6b30d49a3656aea6d85e400f18293427926e/src/Response.php#L716-L732
train
Fuzzyma/contao-eloquent-bundle
Traits/ContaoFilesModelTrait.php
ContaoFilesModelTrait.getContaoFile
private function getContaoFile($uuid) { $uuid = StringUtil::deserialize($uuid); if (is_array($uuid)) return FilesModel::findMultipleByUuids($uuid); return FilesModel::findByUuid($uuid); }
php
private function getContaoFile($uuid) { $uuid = StringUtil::deserialize($uuid); if (is_array($uuid)) return FilesModel::findMultipleByUuids($uuid); return FilesModel::findByUuid($uuid); }
[ "private", "function", "getContaoFile", "(", "$", "uuid", ")", "{", "$", "uuid", "=", "StringUtil", "::", "deserialize", "(", "$", "uuid", ")", ";", "if", "(", "is_array", "(", "$", "uuid", ")", ")", "return", "FilesModel", "::", "findMultipleByUuids", "(", "$", "uuid", ")", ";", "return", "FilesModel", "::", "findByUuid", "(", "$", "uuid", ")", ";", "}" ]
Always return a contao file model since its more suitable when working with contao
[ "Always", "return", "a", "contao", "file", "model", "since", "its", "more", "suitable", "when", "working", "with", "contao" ]
d5af2a3f48807db278ec3c92df463171f9514179
https://github.com/Fuzzyma/contao-eloquent-bundle/blob/d5af2a3f48807db278ec3c92df463171f9514179/Traits/ContaoFilesModelTrait.php#L19-L25
train
Fuzzyma/contao-eloquent-bundle
Traits/ContaoFilesModelTrait.php
ContaoFilesModelTrait.setContaoFile
private function setContaoFile($file) { if (is_array($file)) { return serialize(array_map([__CLASS__, 'setContaoFile'], $file)); } if ($file instanceof FilesModel) { return $file->uuid; } if (Validator::isStringUuid($file)) { return StringUtil::uuidToBin($file); } return $file; }
php
private function setContaoFile($file) { if (is_array($file)) { return serialize(array_map([__CLASS__, 'setContaoFile'], $file)); } if ($file instanceof FilesModel) { return $file->uuid; } if (Validator::isStringUuid($file)) { return StringUtil::uuidToBin($file); } return $file; }
[ "private", "function", "setContaoFile", "(", "$", "file", ")", "{", "if", "(", "is_array", "(", "$", "file", ")", ")", "{", "return", "serialize", "(", "array_map", "(", "[", "__CLASS__", ",", "'setContaoFile'", "]", ",", "$", "file", ")", ")", ";", "}", "if", "(", "$", "file", "instanceof", "FilesModel", ")", "{", "return", "$", "file", "->", "uuid", ";", "}", "if", "(", "Validator", "::", "isStringUuid", "(", "$", "file", ")", ")", "{", "return", "StringUtil", "::", "uuidToBin", "(", "$", "file", ")", ";", "}", "return", "$", "file", ";", "}" ]
we check if its a file model and extract the uuid. If its a string we convert it.
[ "we", "check", "if", "its", "a", "file", "model", "and", "extract", "the", "uuid", ".", "If", "its", "a", "string", "we", "convert", "it", "." ]
d5af2a3f48807db278ec3c92df463171f9514179
https://github.com/Fuzzyma/contao-eloquent-bundle/blob/d5af2a3f48807db278ec3c92df463171f9514179/Traits/ContaoFilesModelTrait.php#L28-L41
train
octris/sqlbuilder
libs/Sqlbuilder.php
Sqlbuilder.resolveSnippet
public function resolveSnippet($name, array &$parameters) { $name = strtoupper($name); if (isset($this->clauses[$name])) { $snippet = $this->clauses[$name]->resolveClauses($parameters); } elseif (isset($this->snippets[$name])) { $snippet = $this->snippets[$name]; } else { $snippet = ''; } return $snippet; }
php
public function resolveSnippet($name, array &$parameters) { $name = strtoupper($name); if (isset($this->clauses[$name])) { $snippet = $this->clauses[$name]->resolveClauses($parameters); } elseif (isset($this->snippets[$name])) { $snippet = $this->snippets[$name]; } else { $snippet = ''; } return $snippet; }
[ "public", "function", "resolveSnippet", "(", "$", "name", ",", "array", "&", "$", "parameters", ")", "{", "$", "name", "=", "strtoupper", "(", "$", "name", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "clauses", "[", "$", "name", "]", ")", ")", "{", "$", "snippet", "=", "$", "this", "->", "clauses", "[", "$", "name", "]", "->", "resolveClauses", "(", "$", "parameters", ")", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "snippets", "[", "$", "name", "]", ")", ")", "{", "$", "snippet", "=", "$", "this", "->", "snippets", "[", "$", "name", "]", ";", "}", "else", "{", "$", "snippet", "=", "''", ";", "}", "return", "$", "snippet", ";", "}" ]
Resolve template snippet. @param string $name Name of snippet to resolve. @param array $parameters Parameters for resolving snippet. @return array Array of resolved template snippet and parameters.
[ "Resolve", "template", "snippet", "." ]
d22a494fd4814b3245fce20b4076eec1b382ffd3
https://github.com/octris/sqlbuilder/blob/d22a494fd4814b3245fce20b4076eec1b382ffd3/libs/Sqlbuilder.php#L60-L73
train
octris/sqlbuilder
libs/Sqlbuilder.php
Sqlbuilder.resolveParameter
public function resolveParameter($idx, $type, $name) { return $this->dialect->resolveParameter($idx, $type, $name); }
php
public function resolveParameter($idx, $type, $name) { return $this->dialect->resolveParameter($idx, $type, $name); }
[ "public", "function", "resolveParameter", "(", "$", "idx", ",", "$", "type", ",", "$", "name", ")", "{", "return", "$", "this", "->", "dialect", "->", "resolveParameter", "(", "$", "idx", ",", "$", "type", ",", "$", "name", ")", ";", "}" ]
Resolve query parameter. @param int $idx Position of the parameter in the query. @param string $type Type of the parameter. @param string $name Name of the parameter.
[ "Resolve", "query", "parameter", "." ]
d22a494fd4814b3245fce20b4076eec1b382ffd3
https://github.com/octris/sqlbuilder/blob/d22a494fd4814b3245fce20b4076eec1b382ffd3/libs/Sqlbuilder.php#L82-L85
train
octris/sqlbuilder
libs/Sqlbuilder.php
Sqlbuilder.addClause
protected function addClause($name, $sql, array $parameters, $joiner, $prefix = '', $postfix = '', $is_inclusive = false) { $name = strtoupper($name); if (!isset($this->clauses[$name])) { $this->clauses[$name] = new \Octris\Sqlbuilder\Clauses($joiner, $prefix, $postfix); } $this->clauses[$name]->addClause($sql, $parameters, $is_inclusive); }
php
protected function addClause($name, $sql, array $parameters, $joiner, $prefix = '', $postfix = '', $is_inclusive = false) { $name = strtoupper($name); if (!isset($this->clauses[$name])) { $this->clauses[$name] = new \Octris\Sqlbuilder\Clauses($joiner, $prefix, $postfix); } $this->clauses[$name]->addClause($sql, $parameters, $is_inclusive); }
[ "protected", "function", "addClause", "(", "$", "name", ",", "$", "sql", ",", "array", "$", "parameters", ",", "$", "joiner", ",", "$", "prefix", "=", "''", ",", "$", "postfix", "=", "''", ",", "$", "is_inclusive", "=", "false", ")", "{", "$", "name", "=", "strtoupper", "(", "$", "name", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "clauses", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "clauses", "[", "$", "name", "]", "=", "new", "\\", "Octris", "\\", "Sqlbuilder", "\\", "Clauses", "(", "$", "joiner", ",", "$", "prefix", ",", "$", "postfix", ")", ";", "}", "$", "this", "->", "clauses", "[", "$", "name", "]", "->", "addClause", "(", "$", "sql", ",", "$", "parameters", ",", "$", "is_inclusive", ")", ";", "}" ]
Add clause. @param string $name Name of clause to add. @param string $sql SQL snippet of clause. @param array $parameters Parameters for clause. @param string $joiner String to use for joining multiple clauses of the same name. @param string $prefix Optional prefix string for joined clauses. @param string $postfix Optional postfix string for joined clauses. @param bool $is_inclusive Optional clause mode.
[ "Add", "clause", "." ]
d22a494fd4814b3245fce20b4076eec1b382ffd3
https://github.com/octris/sqlbuilder/blob/d22a494fd4814b3245fce20b4076eec1b382ffd3/libs/Sqlbuilder.php#L125-L134
train
octris/sqlbuilder
libs/Sqlbuilder.php
Sqlbuilder.addPaging
public function addPaging($limit, $page = 1) { $this->addClause('PAGING', $this->dialect->getLimitString($limit, ($page - 1) * $limit), [], '', '', "\n", false); return $this; }
php
public function addPaging($limit, $page = 1) { $this->addClause('PAGING', $this->dialect->getLimitString($limit, ($page - 1) * $limit), [], '', '', "\n", false); return $this; }
[ "public", "function", "addPaging", "(", "$", "limit", ",", "$", "page", "=", "1", ")", "{", "$", "this", "->", "addClause", "(", "'PAGING'", ",", "$", "this", "->", "dialect", "->", "getLimitString", "(", "$", "limit", ",", "(", "$", "page", "-", "1", ")", "*", "$", "limit", ")", ",", "[", "]", ",", "''", ",", "''", ",", "\"\\n\"", ",", "false", ")", ";", "return", "$", "this", ";", "}" ]
Add paging. @param int $limit Limit rows to return. @param int $page Optional page to start querying at. @return \Octris\Sqlbuilder This instance for method chaining.
[ "Add", "paging", "." ]
d22a494fd4814b3245fce20b4076eec1b382ffd3
https://github.com/octris/sqlbuilder/blob/d22a494fd4814b3245fce20b4076eec1b382ffd3/libs/Sqlbuilder.php#L295-L300
train
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.requestPdo
public function requestPdo($request, $param = null) { $this->result = $this->tableGateway->requestPdo($request, $param); return $this->result; }
php
public function requestPdo($request, $param = null) { $this->result = $this->tableGateway->requestPdo($request, $param); return $this->result; }
[ "public", "function", "requestPdo", "(", "$", "request", ",", "$", "param", "=", "null", ")", "{", "$", "this", "->", "result", "=", "$", "this", "->", "tableGateway", "->", "requestPdo", "(", "$", "request", ",", "$", "param", ")", ";", "return", "$", "this", "->", "result", ";", "}" ]
Excecute request directly by PDO. @param string $request @param array $param @return \Dal\Db\ResultSet\ResultSet
[ "Excecute", "request", "directly", "by", "PDO", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L74-L79
train
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.selectWith
public function selectWith(\Zend\Db\Sql\Select $select) { if ($this->usePaginator === true) { return $this->initPaginator($select); } $this->result = $this->tableGateway->selectWith($select); return $this->result; }
php
public function selectWith(\Zend\Db\Sql\Select $select) { if ($this->usePaginator === true) { return $this->initPaginator($select); } $this->result = $this->tableGateway->selectWith($select); return $this->result; }
[ "public", "function", "selectWith", "(", "\\", "Zend", "\\", "Db", "\\", "Sql", "\\", "Select", "$", "select", ")", "{", "if", "(", "$", "this", "->", "usePaginator", "===", "true", ")", "{", "return", "$", "this", "->", "initPaginator", "(", "$", "select", ")", ";", "}", "$", "this", "->", "result", "=", "$", "this", "->", "tableGateway", "->", "selectWith", "(", "$", "select", ")", ";", "return", "$", "this", "->", "result", ";", "}" ]
Select request. @param \Zend\Db\Sql\Select @return \Zend\Db\ResultSet\ResultSet
[ "Select", "request", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L143-L152
train
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.fetchAll
public function fetchAll() { if ($this->usePaginator === true) { return $this->initPaginator($this->tableGateway->getSql()->select()); } $this->result = $this->tableGateway->select(); return $this->result; }
php
public function fetchAll() { if ($this->usePaginator === true) { return $this->initPaginator($this->tableGateway->getSql()->select()); } $this->result = $this->tableGateway->select(); return $this->result; }
[ "public", "function", "fetchAll", "(", ")", "{", "if", "(", "$", "this", "->", "usePaginator", "===", "true", ")", "{", "return", "$", "this", "->", "initPaginator", "(", "$", "this", "->", "tableGateway", "->", "getSql", "(", ")", "->", "select", "(", ")", ")", ";", "}", "$", "this", "->", "result", "=", "$", "this", "->", "tableGateway", "->", "select", "(", ")", ";", "return", "$", "this", "->", "result", ";", "}" ]
Fetch All. @return \Zend\Db\ResultSet\ResultSet
[ "Fetch", "All", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L159-L167
train
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.deleteWith
public function deleteWith(\Zend\Db\Sql\Delete $delete) { return $this->tableGateway->deleteWith($delete); }
php
public function deleteWith(\Zend\Db\Sql\Delete $delete) { return $this->tableGateway->deleteWith($delete); }
[ "public", "function", "deleteWith", "(", "\\", "Zend", "\\", "Db", "\\", "Sql", "\\", "Delete", "$", "delete", ")", "{", "return", "$", "this", "->", "tableGateway", "->", "deleteWith", "(", "$", "delete", ")", ";", "}" ]
Delete request. @param \Zend\Db\Sql\Delete @return int
[ "Delete", "request", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L176-L179
train
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.insertWith
public function insertWith(\Zend\Db\Sql\Insert $insert) { return $this->tableGateway->insertWith($insert); }
php
public function insertWith(\Zend\Db\Sql\Insert $insert) { return $this->tableGateway->insertWith($insert); }
[ "public", "function", "insertWith", "(", "\\", "Zend", "\\", "Db", "\\", "Sql", "\\", "Insert", "$", "insert", ")", "{", "return", "$", "this", "->", "tableGateway", "->", "insertWith", "(", "$", "insert", ")", ";", "}" ]
Insert request. @param \Zend\Db\Sql\Insert @return int
[ "Insert", "request", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L188-L191
train
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.updateWith
public function updateWith(\Zend\Db\Sql\Update $update) { return $this->tableGateway->updateWith($update); }
php
public function updateWith(\Zend\Db\Sql\Update $update) { return $this->tableGateway->updateWith($update); }
[ "public", "function", "updateWith", "(", "\\", "Zend", "\\", "Db", "\\", "Sql", "\\", "Update", "$", "update", ")", "{", "return", "$", "this", "->", "tableGateway", "->", "updateWith", "(", "$", "update", ")", ";", "}" ]
Update request. @param \Zend\Db\Sql\Update @return int
[ "Update", "request", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L200-L203
train
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.fetchRow
public function fetchRow($column, $value) { $where = array($column, $value); return $this->tableGateway->select($where)->current(); }
php
public function fetchRow($column, $value) { $where = array($column, $value); return $this->tableGateway->select($where)->current(); }
[ "public", "function", "fetchRow", "(", "$", "column", ",", "$", "value", ")", "{", "$", "where", "=", "array", "(", "$", "column", ",", "$", "value", ")", ";", "return", "$", "this", "->", "tableGateway", "->", "select", "(", "$", "where", ")", "->", "current", "(", ")", ";", "}" ]
Get row. @param string $column @param multitype $value @return \Dal\Model\AbstractModel
[ "Get", "row", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L213-L218
train
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.delete
public function delete(AbstractModel $model) { $array = $model->toArrayCurrent(); if (empty($array)) { throw new \Exception('Error : delete used an empty model'); } return $this->tableGateway->delete($array); }
php
public function delete(AbstractModel $model) { $array = $model->toArrayCurrent(); if (empty($array)) { throw new \Exception('Error : delete used an empty model'); } return $this->tableGateway->delete($array); }
[ "public", "function", "delete", "(", "AbstractModel", "$", "model", ")", "{", "$", "array", "=", "$", "model", "->", "toArrayCurrent", "(", ")", ";", "if", "(", "empty", "(", "$", "array", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Error : delete used an empty model'", ")", ";", "}", "return", "$", "this", "->", "tableGateway", "->", "delete", "(", "$", "array", ")", ";", "}" ]
Delete full modele. @param \Dal\Model\AbstractModel $model @return bool
[ "Delete", "full", "modele", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L272-L281
train
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.usePaginator
public function usePaginator($options) { if ($options === null) { $this->usePaginator = false; return $this; } $this->usePaginator = true; $this->paginatorOptions['s'] = (isset($options['s'])) ? $options['s'] : null; $this->paginatorOptions['d'] = (isset($options['d'])) ? $options['d'] : null; $this->paginatorOptions['c'] = (isset($options['c'])) ? $options['c'] : null; $this->paginatorOptions['n'] = (isset($options['n'])) ? $options['n'] : (isset($options['p']) ? 10 : null ); $this->paginatorOptions['o'] = (isset($options['o'])) ? $options['o'] : []; $this->paginatorOptions['p'] = (isset($options['p'])) ? $options['p'] : (isset($options['n']) ? 1 : null ); return $this; }
php
public function usePaginator($options) { if ($options === null) { $this->usePaginator = false; return $this; } $this->usePaginator = true; $this->paginatorOptions['s'] = (isset($options['s'])) ? $options['s'] : null; $this->paginatorOptions['d'] = (isset($options['d'])) ? $options['d'] : null; $this->paginatorOptions['c'] = (isset($options['c'])) ? $options['c'] : null; $this->paginatorOptions['n'] = (isset($options['n'])) ? $options['n'] : (isset($options['p']) ? 10 : null ); $this->paginatorOptions['o'] = (isset($options['o'])) ? $options['o'] : []; $this->paginatorOptions['p'] = (isset($options['p'])) ? $options['p'] : (isset($options['n']) ? 1 : null ); return $this; }
[ "public", "function", "usePaginator", "(", "$", "options", ")", "{", "if", "(", "$", "options", "===", "null", ")", "{", "$", "this", "->", "usePaginator", "=", "false", ";", "return", "$", "this", ";", "}", "$", "this", "->", "usePaginator", "=", "true", ";", "$", "this", "->", "paginatorOptions", "[", "'s'", "]", "=", "(", "isset", "(", "$", "options", "[", "'s'", "]", ")", ")", "?", "$", "options", "[", "'s'", "]", ":", "null", ";", "$", "this", "->", "paginatorOptions", "[", "'d'", "]", "=", "(", "isset", "(", "$", "options", "[", "'d'", "]", ")", ")", "?", "$", "options", "[", "'d'", "]", ":", "null", ";", "$", "this", "->", "paginatorOptions", "[", "'c'", "]", "=", "(", "isset", "(", "$", "options", "[", "'c'", "]", ")", ")", "?", "$", "options", "[", "'c'", "]", ":", "null", ";", "$", "this", "->", "paginatorOptions", "[", "'n'", "]", "=", "(", "isset", "(", "$", "options", "[", "'n'", "]", ")", ")", "?", "$", "options", "[", "'n'", "]", ":", "(", "isset", "(", "$", "options", "[", "'p'", "]", ")", "?", "10", ":", "null", ")", ";", "$", "this", "->", "paginatorOptions", "[", "'o'", "]", "=", "(", "isset", "(", "$", "options", "[", "'o'", "]", ")", ")", "?", "$", "options", "[", "'o'", "]", ":", "[", "]", ";", "$", "this", "->", "paginatorOptions", "[", "'p'", "]", "=", "(", "isset", "(", "$", "options", "[", "'p'", "]", ")", ")", "?", "$", "options", "[", "'p'", "]", ":", "(", "isset", "(", "$", "options", "[", "'n'", "]", ")", "?", "1", ":", "null", ")", ";", "return", "$", "this", ";", "}" ]
Set the mapper options and enable the mapper. @param array $options @return AbstractMapper
[ "Set", "the", "mapper", "options", "and", "enable", "the", "mapper", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L290-L308
train
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.initPaginator
protected function initPaginator($select) { $this->usePaginator = false; $this->paginator = new Paginator( $select, $this->tableGateway->getAdapter(), $this->tableGateway->getResultSetPrototype()); if (isset($this->paginatorOptions['n'])) { $this->paginator->setN($this->paginatorOptions['n']); } if (isset($this->paginatorOptions['p'])) { $this->paginator->setP($this->paginatorOptions['p']); } if (isset($this->paginatorOptions['c'])) { $this->paginator->setC($this->paginatorOptions['c']); } if (isset($this->paginatorOptions['s'])) { $this->paginator->setS($this->paginatorOptions['s']); } if (isset($this->paginatorOptions['d'])) { $this->paginator->setD($this->paginatorOptions['d']); } if (isset($this->paginatorOptions['o'])) { $this->paginator->setO($this->paginatorOptions['o']); } return $this->paginator->getItems(); }
php
protected function initPaginator($select) { $this->usePaginator = false; $this->paginator = new Paginator( $select, $this->tableGateway->getAdapter(), $this->tableGateway->getResultSetPrototype()); if (isset($this->paginatorOptions['n'])) { $this->paginator->setN($this->paginatorOptions['n']); } if (isset($this->paginatorOptions['p'])) { $this->paginator->setP($this->paginatorOptions['p']); } if (isset($this->paginatorOptions['c'])) { $this->paginator->setC($this->paginatorOptions['c']); } if (isset($this->paginatorOptions['s'])) { $this->paginator->setS($this->paginatorOptions['s']); } if (isset($this->paginatorOptions['d'])) { $this->paginator->setD($this->paginatorOptions['d']); } if (isset($this->paginatorOptions['o'])) { $this->paginator->setO($this->paginatorOptions['o']); } return $this->paginator->getItems(); }
[ "protected", "function", "initPaginator", "(", "$", "select", ")", "{", "$", "this", "->", "usePaginator", "=", "false", ";", "$", "this", "->", "paginator", "=", "new", "Paginator", "(", "$", "select", ",", "$", "this", "->", "tableGateway", "->", "getAdapter", "(", ")", ",", "$", "this", "->", "tableGateway", "->", "getResultSetPrototype", "(", ")", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "paginatorOptions", "[", "'n'", "]", ")", ")", "{", "$", "this", "->", "paginator", "->", "setN", "(", "$", "this", "->", "paginatorOptions", "[", "'n'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "paginatorOptions", "[", "'p'", "]", ")", ")", "{", "$", "this", "->", "paginator", "->", "setP", "(", "$", "this", "->", "paginatorOptions", "[", "'p'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "paginatorOptions", "[", "'c'", "]", ")", ")", "{", "$", "this", "->", "paginator", "->", "setC", "(", "$", "this", "->", "paginatorOptions", "[", "'c'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "paginatorOptions", "[", "'s'", "]", ")", ")", "{", "$", "this", "->", "paginator", "->", "setS", "(", "$", "this", "->", "paginatorOptions", "[", "'s'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "paginatorOptions", "[", "'d'", "]", ")", ")", "{", "$", "this", "->", "paginator", "->", "setD", "(", "$", "this", "->", "paginatorOptions", "[", "'d'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "paginatorOptions", "[", "'o'", "]", ")", ")", "{", "$", "this", "->", "paginator", "->", "setO", "(", "$", "this", "->", "paginatorOptions", "[", "'o'", "]", ")", ";", "}", "return", "$", "this", "->", "paginator", "->", "getItems", "(", ")", ";", "}" ]
Init the paginator with a select object. @param \Zend\Db\Sql\Select|array $select @return mixed
[ "Init", "the", "paginator", "with", "a", "select", "object", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L317-L346
train
buse974/Dal
src/Dal/Mapper/AbstractMapper.php
AbstractMapper.printSql
public function printSql(\Zend\Db\Sql\SqlInterface $request) { return $request->getSqlString($this->tableGateway->getAdapter()->getPlatform()); }
php
public function printSql(\Zend\Db\Sql\SqlInterface $request) { return $request->getSqlString($this->tableGateway->getAdapter()->getPlatform()); }
[ "public", "function", "printSql", "(", "\\", "Zend", "\\", "Db", "\\", "Sql", "\\", "SqlInterface", "$", "request", ")", "{", "return", "$", "request", "->", "getSqlString", "(", "$", "this", "->", "tableGateway", "->", "getAdapter", "(", ")", "->", "getPlatform", "(", ")", ")", ";", "}" ]
Return request sql. @param \Zend\Db\Sql\SqlInterface $request @return string
[ "Return", "request", "sql", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Mapper/AbstractMapper.php#L371-L374
train
phpalchemy/phpalchemy
Alchemy/Component/ClassLoader/ClassLoader.php
ClassLoader.register
public function register($namespace, $includePath) { if (array_key_exists($namespace, $this->includePaths)) { throw new \Exception("Error: Namespace '$namespace' is already registered!"); } $this->includePaths[$namespace] = rtrim($includePath, DS) . DS; }
php
public function register($namespace, $includePath) { if (array_key_exists($namespace, $this->includePaths)) { throw new \Exception("Error: Namespace '$namespace' is already registered!"); } $this->includePaths[$namespace] = rtrim($includePath, DS) . DS; }
[ "public", "function", "register", "(", "$", "namespace", ",", "$", "includePath", ")", "{", "if", "(", "array_key_exists", "(", "$", "namespace", ",", "$", "this", "->", "includePaths", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Error: Namespace '$namespace' is already registered!\"", ")", ";", "}", "$", "this", "->", "includePaths", "[", "$", "namespace", "]", "=", "rtrim", "(", "$", "includePath", ",", "DS", ")", ".", "DS", ";", "}" ]
Register a determinated namespace and its include path to find it. @param string $namespace namespace of a class given @param string $includePath path where the class exists
[ "Register", "a", "determinated", "namespace", "and", "its", "include", "path", "to", "find", "it", "." ]
5b7e9b13acfda38c61b2da2639e8a56f298dc32e
https://github.com/phpalchemy/phpalchemy/blob/5b7e9b13acfda38c61b2da2639e8a56f298dc32e/Alchemy/Component/ClassLoader/ClassLoader.php#L70-L77
train
phpalchemy/phpalchemy
Alchemy/Component/ClassLoader/ClassLoader.php
ClassLoader.registerClass
public function registerClass($className, $includeFile) { if (array_key_exists($className, $this->includePaths)) { throw new \Exception("Error: Class '$className' is already registered!"); } $this->includePaths[$className] = $includeFile; }
php
public function registerClass($className, $includeFile) { if (array_key_exists($className, $this->includePaths)) { throw new \Exception("Error: Class '$className' is already registered!"); } $this->includePaths[$className] = $includeFile; }
[ "public", "function", "registerClass", "(", "$", "className", ",", "$", "includeFile", ")", "{", "if", "(", "array_key_exists", "(", "$", "className", ",", "$", "this", "->", "includePaths", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Error: Class '$className' is already registered!\"", ")", ";", "}", "$", "this", "->", "includePaths", "[", "$", "className", "]", "=", "$", "includeFile", ";", "}" ]
Register a determinated class to autoloader Example: $classLoader = ClassLoader::getInstance(); $classLoader->registerClass('MyClass', '/classes/class.myclass.php'); This is useful when we want to add autoloading to a class without naming convention and therefore the class name is different of class file, or the class have not not namespaces, etc.
[ "Register", "a", "determinated", "class", "to", "autoloader" ]
5b7e9b13acfda38c61b2da2639e8a56f298dc32e
https://github.com/phpalchemy/phpalchemy/blob/5b7e9b13acfda38c61b2da2639e8a56f298dc32e/Alchemy/Component/ClassLoader/ClassLoader.php#L90-L97
train
honeylex/honeylex
app/lib/Console/Scaffold/SkeletonGenerator.php
SkeletonGenerator.createFolders
protected function createFolders() { foreach ($this->getFolderStructure() as $folder) { $newFolder = $this->twigStringRenderer->renderToString($folder, $this->data); $this->fs->mkdir($this->targetPath.DIRECTORY_SEPARATOR.$newFolder, self::DIRECTORY_MODE); $msg = '[mkdir] '.$this->targetPath.DIRECTORY_SEPARATOR.$newFolder; if ($this->reportingEnabled) { $this->report[] =$msg; } } }
php
protected function createFolders() { foreach ($this->getFolderStructure() as $folder) { $newFolder = $this->twigStringRenderer->renderToString($folder, $this->data); $this->fs->mkdir($this->targetPath.DIRECTORY_SEPARATOR.$newFolder, self::DIRECTORY_MODE); $msg = '[mkdir] '.$this->targetPath.DIRECTORY_SEPARATOR.$newFolder; if ($this->reportingEnabled) { $this->report[] =$msg; } } }
[ "protected", "function", "createFolders", "(", ")", "{", "foreach", "(", "$", "this", "->", "getFolderStructure", "(", ")", "as", "$", "folder", ")", "{", "$", "newFolder", "=", "$", "this", "->", "twigStringRenderer", "->", "renderToString", "(", "$", "folder", ",", "$", "this", "->", "data", ")", ";", "$", "this", "->", "fs", "->", "mkdir", "(", "$", "this", "->", "targetPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "newFolder", ",", "self", "::", "DIRECTORY_MODE", ")", ";", "$", "msg", "=", "'[mkdir] '", ".", "$", "this", "->", "targetPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "newFolder", ";", "if", "(", "$", "this", "->", "reportingEnabled", ")", "{", "$", "this", "->", "report", "[", "]", "=", "$", "msg", ";", "}", "}", "}" ]
Creates all folders specified by getFolderStructure within the target location.
[ "Creates", "all", "folders", "specified", "by", "getFolderStructure", "within", "the", "target", "location", "." ]
ad0a177ec365793a2c3813b948a1750c77ef00c1
https://github.com/honeylex/honeylex/blob/ad0a177ec365793a2c3813b948a1750c77ef00c1/app/lib/Console/Scaffold/SkeletonGenerator.php#L120-L131
train
honeylex/honeylex
app/lib/Console/Scaffold/SkeletonGenerator.php
SkeletonGenerator.copyFiles
protected function copyFiles() { $skeletonFinder = new SkeletonFinder($this->lookupPaths); $sourcePath = $skeletonFinder->findByName($this->skeletonName)->getRealpath(); $finder = $this->getFinderForFilesToCopy($sourcePath); foreach ($finder as $file) { $targetFilePath = $this->targetPath.DIRECTORY_SEPARATOR.$file->getRelativePathname(); $targetFilePath = $this->twigStringRenderer->renderToString($targetFilePath, $this->data); $this->fs->copy($file->getRealpath(), $targetFilePath, $this->overwriteEnabled); $msg = '[copy] '.$file->getRealpath().' => '.$targetFilePath; if ($this->reportingEnabled) { $this->report[] = $msg; } } }
php
protected function copyFiles() { $skeletonFinder = new SkeletonFinder($this->lookupPaths); $sourcePath = $skeletonFinder->findByName($this->skeletonName)->getRealpath(); $finder = $this->getFinderForFilesToCopy($sourcePath); foreach ($finder as $file) { $targetFilePath = $this->targetPath.DIRECTORY_SEPARATOR.$file->getRelativePathname(); $targetFilePath = $this->twigStringRenderer->renderToString($targetFilePath, $this->data); $this->fs->copy($file->getRealpath(), $targetFilePath, $this->overwriteEnabled); $msg = '[copy] '.$file->getRealpath().' => '.$targetFilePath; if ($this->reportingEnabled) { $this->report[] = $msg; } } }
[ "protected", "function", "copyFiles", "(", ")", "{", "$", "skeletonFinder", "=", "new", "SkeletonFinder", "(", "$", "this", "->", "lookupPaths", ")", ";", "$", "sourcePath", "=", "$", "skeletonFinder", "->", "findByName", "(", "$", "this", "->", "skeletonName", ")", "->", "getRealpath", "(", ")", ";", "$", "finder", "=", "$", "this", "->", "getFinderForFilesToCopy", "(", "$", "sourcePath", ")", ";", "foreach", "(", "$", "finder", "as", "$", "file", ")", "{", "$", "targetFilePath", "=", "$", "this", "->", "targetPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "file", "->", "getRelativePathname", "(", ")", ";", "$", "targetFilePath", "=", "$", "this", "->", "twigStringRenderer", "->", "renderToString", "(", "$", "targetFilePath", ",", "$", "this", "->", "data", ")", ";", "$", "this", "->", "fs", "->", "copy", "(", "$", "file", "->", "getRealpath", "(", ")", ",", "$", "targetFilePath", ",", "$", "this", "->", "overwriteEnabled", ")", ";", "$", "msg", "=", "'[copy] '", ".", "$", "file", "->", "getRealpath", "(", ")", ".", "' => '", ".", "$", "targetFilePath", ";", "if", "(", "$", "this", "->", "reportingEnabled", ")", "{", "$", "this", "->", "report", "[", "]", "=", "$", "msg", ";", "}", "}", "}" ]
Copies all files from the source location to the target location.
[ "Copies", "all", "files", "from", "the", "source", "location", "to", "the", "target", "location", "." ]
ad0a177ec365793a2c3813b948a1750c77ef00c1
https://github.com/honeylex/honeylex/blob/ad0a177ec365793a2c3813b948a1750c77ef00c1/app/lib/Console/Scaffold/SkeletonGenerator.php#L136-L155
train
honeylex/honeylex
app/lib/Console/Scaffold/SkeletonGenerator.php
SkeletonGenerator.renderTemplates
protected function renderTemplates() { $finder = new Finder; $finder->files()->name('*'.self::TEMPLATE_FILENAME_EXTENSION)->in($this->targetPath); $twigRenderer = TwigRenderer::create( [ 'twig_extensions' => [ new ProjectExtension($this->configProvider) ], 'twig_options' => [ 'autoescape' => false, 'cache' => false, 'debug' => true, 'strict_variables' => true ], 'template_paths' => [ $this->targetPath ] ] ); foreach ($finder as $template) { $targetFilePath = $template->getPath().DIRECTORY_SEPARATOR. $template->getBasename(self::TEMPLATE_FILENAME_EXTENSION); if (!file_exists($targetFilePath) || (is_readable($targetFilePath) && $this->overwriteEnabled)) { $twigRenderer->renderToFile( $template->getRelativePathname(), $targetFilePath, $this->data ); } $msg = '[render] '.$template->getRelativePathname().' => '.$targetFilePath; if ($this->reportingEnabled) { $this->report[] = $msg; } } $this->fs->remove($finder); }
php
protected function renderTemplates() { $finder = new Finder; $finder->files()->name('*'.self::TEMPLATE_FILENAME_EXTENSION)->in($this->targetPath); $twigRenderer = TwigRenderer::create( [ 'twig_extensions' => [ new ProjectExtension($this->configProvider) ], 'twig_options' => [ 'autoescape' => false, 'cache' => false, 'debug' => true, 'strict_variables' => true ], 'template_paths' => [ $this->targetPath ] ] ); foreach ($finder as $template) { $targetFilePath = $template->getPath().DIRECTORY_SEPARATOR. $template->getBasename(self::TEMPLATE_FILENAME_EXTENSION); if (!file_exists($targetFilePath) || (is_readable($targetFilePath) && $this->overwriteEnabled)) { $twigRenderer->renderToFile( $template->getRelativePathname(), $targetFilePath, $this->data ); } $msg = '[render] '.$template->getRelativePathname().' => '.$targetFilePath; if ($this->reportingEnabled) { $this->report[] = $msg; } } $this->fs->remove($finder); }
[ "protected", "function", "renderTemplates", "(", ")", "{", "$", "finder", "=", "new", "Finder", ";", "$", "finder", "->", "files", "(", ")", "->", "name", "(", "'*'", ".", "self", "::", "TEMPLATE_FILENAME_EXTENSION", ")", "->", "in", "(", "$", "this", "->", "targetPath", ")", ";", "$", "twigRenderer", "=", "TwigRenderer", "::", "create", "(", "[", "'twig_extensions'", "=>", "[", "new", "ProjectExtension", "(", "$", "this", "->", "configProvider", ")", "]", ",", "'twig_options'", "=>", "[", "'autoescape'", "=>", "false", ",", "'cache'", "=>", "false", ",", "'debug'", "=>", "true", ",", "'strict_variables'", "=>", "true", "]", ",", "'template_paths'", "=>", "[", "$", "this", "->", "targetPath", "]", "]", ")", ";", "foreach", "(", "$", "finder", "as", "$", "template", ")", "{", "$", "targetFilePath", "=", "$", "template", "->", "getPath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "template", "->", "getBasename", "(", "self", "::", "TEMPLATE_FILENAME_EXTENSION", ")", ";", "if", "(", "!", "file_exists", "(", "$", "targetFilePath", ")", "||", "(", "is_readable", "(", "$", "targetFilePath", ")", "&&", "$", "this", "->", "overwriteEnabled", ")", ")", "{", "$", "twigRenderer", "->", "renderToFile", "(", "$", "template", "->", "getRelativePathname", "(", ")", ",", "$", "targetFilePath", ",", "$", "this", "->", "data", ")", ";", "}", "$", "msg", "=", "'[render] '", ".", "$", "template", "->", "getRelativePathname", "(", ")", ".", "' => '", ".", "$", "targetFilePath", ";", "if", "(", "$", "this", "->", "reportingEnabled", ")", "{", "$", "this", "->", "report", "[", "]", "=", "$", "msg", ";", "}", "}", "$", "this", "->", "fs", "->", "remove", "(", "$", "finder", ")", ";", "}" ]
Renders all files within the target location whose extension is ".tmpl.twig" onto a file that has the same name without that extension. After the rendering all the ".tmpl.twig" files will be deleted in the target location.
[ "Renders", "all", "files", "within", "the", "target", "location", "whose", "extension", "is", ".", "tmpl", ".", "twig", "onto", "a", "file", "that", "has", "the", "same", "name", "without", "that", "extension", ".", "After", "the", "rendering", "all", "the", ".", "tmpl", ".", "twig", "files", "will", "be", "deleted", "in", "the", "target", "location", "." ]
ad0a177ec365793a2c3813b948a1750c77ef00c1
https://github.com/honeylex/honeylex/blob/ad0a177ec365793a2c3813b948a1750c77ef00c1/app/lib/Console/Scaffold/SkeletonGenerator.php#L176-L217
train
bluetree-service/data
src/Calculation/Math.php
Math.end
public static function end($edition, $used, $start, $timeNow) { if (!$used) { return 0; } $end = $edition / ($used / ($timeNow - $start)); $end += $timeNow; return $end; }
php
public static function end($edition, $used, $start, $timeNow) { if (!$used) { return 0; } $end = $edition / ($used / ($timeNow - $start)); $end += $timeNow; return $end; }
[ "public", "static", "function", "end", "(", "$", "edition", ",", "$", "used", ",", "$", "start", ",", "$", "timeNow", ")", "{", "if", "(", "!", "$", "used", ")", "{", "return", "0", ";", "}", "$", "end", "=", "$", "edition", "/", "(", "$", "used", "/", "(", "$", "timeNow", "-", "$", "start", ")", ")", ";", "$", "end", "+=", "$", "timeNow", ";", "return", "$", "end", ";", "}" ]
Estimate time to end, by given current usage value and max value @param float $edition maximum number of value @param float $used how many was used @param integer $start start time in unix timestamp @param integer $timeNow current unix timestamp @return integer estimated end time in unix timestamp
[ "Estimate", "time", "to", "end", "by", "given", "current", "usage", "value", "and", "max", "value" ]
a8df78ee4f7b97b862f989d3effc75f022fd75cb
https://github.com/bluetree-service/data/blob/a8df78ee4f7b97b862f989d3effc75f022fd75cb/src/Calculation/Math.php#L71-L81
train
3ev/wordpress-core
src/Tev/Field/Model/AuthorField.php
AuthorField.getValue
public function getValue() { $val = $this->base['value']; if (is_array($val)) { if (isset($val['ID'])) { return $this->authorFactory->create($val['ID']); } else { $authors = array(); foreach ($val as $a) { $authors[] = $this->authorFactory->create($a['ID']); } return $authors; } } else { if (isset($this->base['multiple']) && $this->base['multiple']) { return array(); } else { return null; } } }
php
public function getValue() { $val = $this->base['value']; if (is_array($val)) { if (isset($val['ID'])) { return $this->authorFactory->create($val['ID']); } else { $authors = array(); foreach ($val as $a) { $authors[] = $this->authorFactory->create($a['ID']); } return $authors; } } else { if (isset($this->base['multiple']) && $this->base['multiple']) { return array(); } else { return null; } } }
[ "public", "function", "getValue", "(", ")", "{", "$", "val", "=", "$", "this", "->", "base", "[", "'value'", "]", ";", "if", "(", "is_array", "(", "$", "val", ")", ")", "{", "if", "(", "isset", "(", "$", "val", "[", "'ID'", "]", ")", ")", "{", "return", "$", "this", "->", "authorFactory", "->", "create", "(", "$", "val", "[", "'ID'", "]", ")", ";", "}", "else", "{", "$", "authors", "=", "array", "(", ")", ";", "foreach", "(", "$", "val", "as", "$", "a", ")", "{", "$", "authors", "[", "]", "=", "$", "this", "->", "authorFactory", "->", "create", "(", "$", "a", "[", "'ID'", "]", ")", ";", "}", "return", "$", "authors", ";", "}", "}", "else", "{", "if", "(", "isset", "(", "$", "this", "->", "base", "[", "'multiple'", "]", ")", "&&", "$", "this", "->", "base", "[", "'multiple'", "]", ")", "{", "return", "array", "(", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}", "}" ]
Get a single author object or array of author objects. If no authors are configured, returned will result will be an empty array if this is a mutli-select, or null if not. @return \Tev\Author\Model\Author|\Tev\Author\Model\Author[]|null
[ "Get", "a", "single", "author", "object", "or", "array", "of", "author", "objects", "." ]
da674fbec5bf3d5bd2a2141680a4c141113eb6b0
https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Field/Model/AuthorField.php#L43-L66
train
deweller/php-cliopts
src/CLIOpts/Help/ConsoleFormat.php
ConsoleFormat.applyformatToText
public static function applyformatToText() { $args = func_get_args(); $count = func_num_args(); $text = $args[$count - 1]; if ($count == 1) { return $text; } $mode_texts = array_slice($args, 0, $count - 1); return self::buildEscapeCodes($mode_texts).$text.self::buildEscapeCodes('plain'); }
php
public static function applyformatToText() { $args = func_get_args(); $count = func_num_args(); $text = $args[$count - 1]; if ($count == 1) { return $text; } $mode_texts = array_slice($args, 0, $count - 1); return self::buildEscapeCodes($mode_texts).$text.self::buildEscapeCodes('plain'); }
[ "public", "static", "function", "applyformatToText", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "count", "=", "func_num_args", "(", ")", ";", "$", "text", "=", "$", "args", "[", "$", "count", "-", "1", "]", ";", "if", "(", "$", "count", "==", "1", ")", "{", "return", "$", "text", ";", "}", "$", "mode_texts", "=", "array_slice", "(", "$", "args", ",", "0", ",", "$", "count", "-", "1", ")", ";", "return", "self", "::", "buildEscapeCodes", "(", "$", "mode_texts", ")", ".", "$", "text", ".", "self", "::", "buildEscapeCodes", "(", "'plain'", ")", ";", "}" ]
Applies one or more console formatting codes to text @param string $mode A mode like bold or black. This can be repeated numerous times. @param string $text the text to be formatted @return string a formatted version of $text
[ "Applies", "one", "or", "more", "console", "formatting", "codes", "to", "text" ]
1923f3a7ad24062c6279c725579ff3af15141dec
https://github.com/deweller/php-cliopts/blob/1923f3a7ad24062c6279c725579ff3af15141dec/src/CLIOpts/Help/ConsoleFormat.php#L57-L67
train
deweller/php-cliopts
src/CLIOpts/Help/ConsoleFormat.php
ConsoleFormat.buildEscapeCodes
protected static function buildEscapeCodes($mode_texts) { if (!is_array($mode_texts)) { $mode_texts = array($mode_texts); } $code_text = ''; foreach ($mode_texts as $mode) { $constant_name = 'self::CONSOLE_'.strtoupper($mode); if (defined($constant_name)) { $code_text .= (strlen($code_text) ? ';': '').constant($constant_name); } } return chr(27)."[0;".$code_text."m"; }
php
protected static function buildEscapeCodes($mode_texts) { if (!is_array($mode_texts)) { $mode_texts = array($mode_texts); } $code_text = ''; foreach ($mode_texts as $mode) { $constant_name = 'self::CONSOLE_'.strtoupper($mode); if (defined($constant_name)) { $code_text .= (strlen($code_text) ? ';': '').constant($constant_name); } } return chr(27)."[0;".$code_text."m"; }
[ "protected", "static", "function", "buildEscapeCodes", "(", "$", "mode_texts", ")", "{", "if", "(", "!", "is_array", "(", "$", "mode_texts", ")", ")", "{", "$", "mode_texts", "=", "array", "(", "$", "mode_texts", ")", ";", "}", "$", "code_text", "=", "''", ";", "foreach", "(", "$", "mode_texts", "as", "$", "mode", ")", "{", "$", "constant_name", "=", "'self::CONSOLE_'", ".", "strtoupper", "(", "$", "mode", ")", ";", "if", "(", "defined", "(", "$", "constant_name", ")", ")", "{", "$", "code_text", ".=", "(", "strlen", "(", "$", "code_text", ")", "?", "';'", ":", "''", ")", ".", "constant", "(", "$", "constant_name", ")", ";", "}", "}", "return", "chr", "(", "27", ")", ".", "\"[0;\"", ".", "$", "code_text", ".", "\"m\"", ";", "}" ]
builds ANSI escape codes @param mixed $mode_texts An array of mode texts like bold or white. Can also be a single string. @return string ANSI escape code to activate the modes
[ "builds", "ANSI", "escape", "codes" ]
1923f3a7ad24062c6279c725579ff3af15141dec
https://github.com/deweller/php-cliopts/blob/1923f3a7ad24062c6279c725579ff3af15141dec/src/CLIOpts/Help/ConsoleFormat.php#L82-L94
train
newestindustry/ginger-rest
src/Ginger/Url.php
Url.getParameter
public function getParameter($key) { if(isset($this->queryParts[$key])) { return $this->queryParts[$key]; } else { return false; } }
php
public function getParameter($key) { if(isset($this->queryParts[$key])) { return $this->queryParts[$key]; } else { return false; } }
[ "public", "function", "getParameter", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "queryParts", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "queryParts", "[", "$", "key", "]", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
getParameter function. @access public @param mixed $key @return void
[ "getParameter", "function", "." ]
482b77dc122a60ab0bf143a3c4a1e67168985c83
https://github.com/newestindustry/ginger-rest/blob/482b77dc122a60ab0bf143a3c4a1e67168985c83/src/Ginger/Url.php#L127-L134
train
newup/core
src/Filesystem/Generators/PathTreeArrayFormat.php
PathTreeArrayFormat.getPathForTreeGenerator
private function getPathForTreeGenerator($pathKey, $path) { // If the $path is an array, it most likely already contains // the information we need, such as if the target is a file or directory. if (is_array($path) && array_key_exists('type', $path) && array_key_exists('path', $path)) { return $path; } // At this point, the key should contain at least one ']' character. if (!Str::contains($pathKey, ']')) { throw new InvalidArgumentException('Missing key options. Supplied key was ' . $pathKey); } // Since we did not get handed the information we wanted, we have to figure it out // by looking at the path key. $keyParts = explode(']', $pathKey); $formattingOptions = array_pop($keyParts); $type = 'file'; if (Str::contains('d', $formattingOptions)) { $type = 'dir'; } return [ 'path' => $path, 'type' => $type ]; }
php
private function getPathForTreeGenerator($pathKey, $path) { // If the $path is an array, it most likely already contains // the information we need, such as if the target is a file or directory. if (is_array($path) && array_key_exists('type', $path) && array_key_exists('path', $path)) { return $path; } // At this point, the key should contain at least one ']' character. if (!Str::contains($pathKey, ']')) { throw new InvalidArgumentException('Missing key options. Supplied key was ' . $pathKey); } // Since we did not get handed the information we wanted, we have to figure it out // by looking at the path key. $keyParts = explode(']', $pathKey); $formattingOptions = array_pop($keyParts); $type = 'file'; if (Str::contains('d', $formattingOptions)) { $type = 'dir'; } return [ 'path' => $path, 'type' => $type ]; }
[ "private", "function", "getPathForTreeGenerator", "(", "$", "pathKey", ",", "$", "path", ")", "{", "// If the $path is an array, it most likely already contains", "// the information we need, such as if the target is a file or directory.", "if", "(", "is_array", "(", "$", "path", ")", "&&", "array_key_exists", "(", "'type'", ",", "$", "path", ")", "&&", "array_key_exists", "(", "'path'", ",", "$", "path", ")", ")", "{", "return", "$", "path", ";", "}", "// At this point, the key should contain at least one ']' character.", "if", "(", "!", "Str", "::", "contains", "(", "$", "pathKey", ",", "']'", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Missing key options. Supplied key was '", ".", "$", "pathKey", ")", ";", "}", "// Since we did not get handed the information we wanted, we have to figure it out", "// by looking at the path key.", "$", "keyParts", "=", "explode", "(", "']'", ",", "$", "pathKey", ")", ";", "$", "formattingOptions", "=", "array_pop", "(", "$", "keyParts", ")", ";", "$", "type", "=", "'file'", ";", "if", "(", "Str", "::", "contains", "(", "'d'", ",", "$", "formattingOptions", ")", ")", "{", "$", "type", "=", "'dir'", ";", "}", "return", "[", "'path'", "=>", "$", "path", ",", "'type'", "=>", "$", "type", "]", ";", "}" ]
Converts the key and path into an array that various tree generators expect. This function does NOT process the path using any renderers. @param $pathKey @param $path @return mixed @throws InvalidArgumentException
[ "Converts", "the", "key", "and", "path", "into", "an", "array", "that", "various", "tree", "generators", "expect", "." ]
54128903e7775e67d63284d958b46862c8df71f9
https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Filesystem/Generators/PathTreeArrayFormat.php#L22-L49
train
andyburton/Sonic-Framework
src/Memcached.php
Memcached.create
public function create ($exclude = array (), $cache = FALSE) { // If we're not caching or there is no memcached object just call parent if ($cache === FALSE || !($this->memcached instanceof \Memcached)) { return parent::create ($exclude); } // Call parent method $parent = parent::create ($exclude); if ($parent === FALSE) { return FALSE; } // Cache $this->memcached->set ($this->getMemcachedID (), $this->getCacheAttributes (), $cache); // Return return $parent; }
php
public function create ($exclude = array (), $cache = FALSE) { // If we're not caching or there is no memcached object just call parent if ($cache === FALSE || !($this->memcached instanceof \Memcached)) { return parent::create ($exclude); } // Call parent method $parent = parent::create ($exclude); if ($parent === FALSE) { return FALSE; } // Cache $this->memcached->set ($this->getMemcachedID (), $this->getCacheAttributes (), $cache); // Return return $parent; }
[ "public", "function", "create", "(", "$", "exclude", "=", "array", "(", ")", ",", "$", "cache", "=", "FALSE", ")", "{", "// If we're not caching or there is no memcached object just call parent", "if", "(", "$", "cache", "===", "FALSE", "||", "!", "(", "$", "this", "->", "memcached", "instanceof", "\\", "Memcached", ")", ")", "{", "return", "parent", "::", "create", "(", "$", "exclude", ")", ";", "}", "// Call parent method", "$", "parent", "=", "parent", "::", "create", "(", "$", "exclude", ")", ";", "if", "(", "$", "parent", "===", "FALSE", ")", "{", "return", "FALSE", ";", "}", "// Cache", "$", "this", "->", "memcached", "->", "set", "(", "$", "this", "->", "getMemcachedID", "(", ")", ",", "$", "this", "->", "getCacheAttributes", "(", ")", ",", "$", "cache", ")", ";", "// Return", "return", "$", "parent", ";", "}" ]
Create object in the database and set in memcached @param array $exclude Attributes not to set @param integer|boolean $cache Number of seconds to cache the object for 0 = cache never expires, FALSE = do not cache @return boolean
[ "Create", "object", "in", "the", "database", "and", "set", "in", "memcached" ]
a5999448a0abab4d542413002a780ede391e7374
https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Memcached.php#L28-L55
train
andyburton/Sonic-Framework
src/Memcached.php
Memcached.read
public function read ($pkValue = FALSE, $cache = FALSE) { // If we're not caching or there is no memcached object just call parent if ($cache === FALSE || !($this->memcached instanceof \Memcached)) { return parent::read ($pkValue); } // If there is a key value passed set it if ($pkValue !== FALSE) { $this->iset (static::$pk, $pkValue); } // Load memcached object attributres $obj = $this->memcached->get ($this->getMemcachedID ()); // If the object is not cached, load and cache it if ($obj === FALSE) { // Read object if (parent::read ($pkValue) === FALSE) { return FALSE; } // Cache object attributes $this->memcached->set ($this->getMemcachedID (), $this->getCacheAttributes (), $cache); } // Set object attributes from the cache else { $this->setCacheAttributes ($obj); } // Return return TRUE; }
php
public function read ($pkValue = FALSE, $cache = FALSE) { // If we're not caching or there is no memcached object just call parent if ($cache === FALSE || !($this->memcached instanceof \Memcached)) { return parent::read ($pkValue); } // If there is a key value passed set it if ($pkValue !== FALSE) { $this->iset (static::$pk, $pkValue); } // Load memcached object attributres $obj = $this->memcached->get ($this->getMemcachedID ()); // If the object is not cached, load and cache it if ($obj === FALSE) { // Read object if (parent::read ($pkValue) === FALSE) { return FALSE; } // Cache object attributes $this->memcached->set ($this->getMemcachedID (), $this->getCacheAttributes (), $cache); } // Set object attributes from the cache else { $this->setCacheAttributes ($obj); } // Return return TRUE; }
[ "public", "function", "read", "(", "$", "pkValue", "=", "FALSE", ",", "$", "cache", "=", "FALSE", ")", "{", "// If we're not caching or there is no memcached object just call parent", "if", "(", "$", "cache", "===", "FALSE", "||", "!", "(", "$", "this", "->", "memcached", "instanceof", "\\", "Memcached", ")", ")", "{", "return", "parent", "::", "read", "(", "$", "pkValue", ")", ";", "}", "// If there is a key value passed set it", "if", "(", "$", "pkValue", "!==", "FALSE", ")", "{", "$", "this", "->", "iset", "(", "static", "::", "$", "pk", ",", "$", "pkValue", ")", ";", "}", "// Load memcached object attributres", "$", "obj", "=", "$", "this", "->", "memcached", "->", "get", "(", "$", "this", "->", "getMemcachedID", "(", ")", ")", ";", "// If the object is not cached, load and cache it", "if", "(", "$", "obj", "===", "FALSE", ")", "{", "// Read object", "if", "(", "parent", "::", "read", "(", "$", "pkValue", ")", "===", "FALSE", ")", "{", "return", "FALSE", ";", "}", "// Cache object attributes", "$", "this", "->", "memcached", "->", "set", "(", "$", "this", "->", "getMemcachedID", "(", ")", ",", "$", "this", "->", "getCacheAttributes", "(", ")", ",", "$", "cache", ")", ";", "}", "// Set object attributes from the cache", "else", "{", "$", "this", "->", "setCacheAttributes", "(", "$", "obj", ")", ";", "}", "// Return", "return", "TRUE", ";", "}" ]
Read an object from memcached if it exists, otherwise load the object from the database and then cache it @param mixed $pkValue Primary key value @param integer|boolean $cache Number of seconds to cache the object for 0 = cache never expires, FALSE = do not cache @return boolean
[ "Read", "an", "object", "from", "memcached", "if", "it", "exists", "otherwise", "load", "the", "object", "from", "the", "database", "and", "then", "cache", "it" ]
a5999448a0abab4d542413002a780ede391e7374
https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Memcached.php#L67-L117
train
andyburton/Sonic-Framework
src/Memcached.php
Memcached.delete
public function delete ($pkValue = FALSE) { // If there is no key value passed set it if ($pkValue === FALSE) { $pkValue = $this->iget (static::$pk); } // Call parent method $parent = parent::delete ($pkValue); if ($parent === FALSE) { return FALSE; } // If there is a memcached object delete from the cache if ($this->memcached instanceof \Memcached) { $this->memcached->delete (static::_getMemcachedID ($pkValue)); } // Return return $parent; }
php
public function delete ($pkValue = FALSE) { // If there is no key value passed set it if ($pkValue === FALSE) { $pkValue = $this->iget (static::$pk); } // Call parent method $parent = parent::delete ($pkValue); if ($parent === FALSE) { return FALSE; } // If there is a memcached object delete from the cache if ($this->memcached instanceof \Memcached) { $this->memcached->delete (static::_getMemcachedID ($pkValue)); } // Return return $parent; }
[ "public", "function", "delete", "(", "$", "pkValue", "=", "FALSE", ")", "{", "// If there is no key value passed set it", "if", "(", "$", "pkValue", "===", "FALSE", ")", "{", "$", "pkValue", "=", "$", "this", "->", "iget", "(", "static", "::", "$", "pk", ")", ";", "}", "// Call parent method", "$", "parent", "=", "parent", "::", "delete", "(", "$", "pkValue", ")", ";", "if", "(", "$", "parent", "===", "FALSE", ")", "{", "return", "FALSE", ";", "}", "// If there is a memcached object delete from the cache", "if", "(", "$", "this", "->", "memcached", "instanceof", "\\", "Memcached", ")", "{", "$", "this", "->", "memcached", "->", "delete", "(", "static", "::", "_getMemcachedID", "(", "$", "pkValue", ")", ")", ";", "}", "// Return", "return", "$", "parent", ";", "}" ]
Delete an object in the database and memcached @param mixed $pkValue Primary key value @return boolean
[ "Delete", "an", "object", "in", "the", "database", "and", "memcached" ]
a5999448a0abab4d542413002a780ede391e7374
https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Memcached.php#L165-L195
train
andyburton/Sonic-Framework
src/Memcached.php
Memcached.getCacheAttributes
private function getCacheAttributes () { $attributes = array (); foreach (array_keys (self::$attributes) as $name) { $attributes[$name] = $this->iget ($name); } return $attributes; }
php
private function getCacheAttributes () { $attributes = array (); foreach (array_keys (self::$attributes) as $name) { $attributes[$name] = $this->iget ($name); } return $attributes; }
[ "private", "function", "getCacheAttributes", "(", ")", "{", "$", "attributes", "=", "array", "(", ")", ";", "foreach", "(", "array_keys", "(", "self", "::", "$", "attributes", ")", "as", "$", "name", ")", "{", "$", "attributes", "[", "$", "name", "]", "=", "$", "this", "->", "iget", "(", "$", "name", ")", ";", "}", "return", "$", "attributes", ";", "}" ]
Return object attributes to cache @return array
[ "Return", "object", "attributes", "to", "cache" ]
a5999448a0abab4d542413002a780ede391e7374
https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Memcached.php#L225-L237
train
andyburton/Sonic-Framework
src/Memcached.php
Memcached.setCacheAttributes
private function setCacheAttributes ($arr) { foreach ($arr as $name => $val) { $this->iset ($name, $val, FALSE); } }
php
private function setCacheAttributes ($arr) { foreach ($arr as $name => $val) { $this->iset ($name, $val, FALSE); } }
[ "private", "function", "setCacheAttributes", "(", "$", "arr", ")", "{", "foreach", "(", "$", "arr", "as", "$", "name", "=>", "$", "val", ")", "{", "$", "this", "->", "iset", "(", "$", "name", ",", "$", "val", ",", "FALSE", ")", ";", "}", "}" ]
Set object attributes from cache @return array
[ "Set", "object", "attributes", "from", "cache" ]
a5999448a0abab4d542413002a780ede391e7374
https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Memcached.php#L245-L253
train
kmfk/slowdb
src/Database.php
Database.getCollection
public function getCollection($name) { $name = strtolower($name); if ($this->collections->containsKey($name)) { return $this->collections->get($name); } $this->collections->set($name, $this->createCollection($name)); return $this->collections->get($name); }
php
public function getCollection($name) { $name = strtolower($name); if ($this->collections->containsKey($name)) { return $this->collections->get($name); } $this->collections->set($name, $this->createCollection($name)); return $this->collections->get($name); }
[ "public", "function", "getCollection", "(", "$", "name", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "if", "(", "$", "this", "->", "collections", "->", "containsKey", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "collections", "->", "get", "(", "$", "name", ")", ";", "}", "$", "this", "->", "collections", "->", "set", "(", "$", "name", ",", "$", "this", "->", "createCollection", "(", "$", "name", ")", ")", ";", "return", "$", "this", "->", "collections", "->", "get", "(", "$", "name", ")", ";", "}" ]
Gets a Collection by name Collections are idempotent, we create a collection if it does not exist or return existing collections @param string $name The name of the Collection @return Collection
[ "Gets", "a", "Collection", "by", "name" ]
7461771b8ddc0c9887e2ee69a76ff5ffc763974c
https://github.com/kmfk/slowdb/blob/7461771b8ddc0c9887e2ee69a76ff5ffc763974c/src/Database.php#L67-L78
train
kmfk/slowdb
src/Database.php
Database.all
public function all() { $results = []; foreach ($this->collections as $collection) { $results[] = array_merge(['name' => $collection->name], $collection->info()); } return $results; }
php
public function all() { $results = []; foreach ($this->collections as $collection) { $results[] = array_merge(['name' => $collection->name], $collection->info()); } return $results; }
[ "public", "function", "all", "(", ")", "{", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "collections", "as", "$", "collection", ")", "{", "$", "results", "[", "]", "=", "array_merge", "(", "[", "'name'", "=>", "$", "collection", "->", "name", "]", ",", "$", "collection", "->", "info", "(", ")", ")", ";", "}", "return", "$", "results", ";", "}" ]
Lists the available Collections by name @return array
[ "Lists", "the", "available", "Collections", "by", "name" ]
7461771b8ddc0c9887e2ee69a76ff5ffc763974c
https://github.com/kmfk/slowdb/blob/7461771b8ddc0c9887e2ee69a76ff5ffc763974c/src/Database.php#L85-L93
train
kmfk/slowdb
src/Database.php
Database.drop
public function drop($collection) { if (!$this->collections->containsKey($collection)) { return false; } $this->collections->get($collection)->drop(); $this->collections->remove($collection); return true; }
php
public function drop($collection) { if (!$this->collections->containsKey($collection)) { return false; } $this->collections->get($collection)->drop(); $this->collections->remove($collection); return true; }
[ "public", "function", "drop", "(", "$", "collection", ")", "{", "if", "(", "!", "$", "this", "->", "collections", "->", "containsKey", "(", "$", "collection", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "collections", "->", "get", "(", "$", "collection", ")", "->", "drop", "(", ")", ";", "$", "this", "->", "collections", "->", "remove", "(", "$", "collection", ")", ";", "return", "true", ";", "}" ]
Drops a Collection - removing all data @param string $collection The name of the Collection to drop
[ "Drops", "a", "Collection", "-", "removing", "all", "data" ]
7461771b8ddc0c9887e2ee69a76ff5ffc763974c
https://github.com/kmfk/slowdb/blob/7461771b8ddc0c9887e2ee69a76ff5ffc763974c/src/Database.php#L100-L110
train
kmfk/slowdb
src/Database.php
Database.loadCollections
private function loadCollections() { $collections = new ArrayCollection(); $finder = new Finder(); $finder->files()->name('*.dat')->in($this->filepath); foreach ($finder as $file) { $name = $file->getBasename('.dat'); $collections->set($name, $this->createCollection($name)); } return $collections; }
php
private function loadCollections() { $collections = new ArrayCollection(); $finder = new Finder(); $finder->files()->name('*.dat')->in($this->filepath); foreach ($finder as $file) { $name = $file->getBasename('.dat'); $collections->set($name, $this->createCollection($name)); } return $collections; }
[ "private", "function", "loadCollections", "(", ")", "{", "$", "collections", "=", "new", "ArrayCollection", "(", ")", ";", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "files", "(", ")", "->", "name", "(", "'*.dat'", ")", "->", "in", "(", "$", "this", "->", "filepath", ")", ";", "foreach", "(", "$", "finder", "as", "$", "file", ")", "{", "$", "name", "=", "$", "file", "->", "getBasename", "(", "'.dat'", ")", ";", "$", "collections", "->", "set", "(", "$", "name", ",", "$", "this", "->", "createCollection", "(", "$", "name", ")", ")", ";", "}", "return", "$", "collections", ";", "}" ]
Loads the collections for the Database @return ArrayCollection
[ "Loads", "the", "collections", "for", "the", "Database" ]
7461771b8ddc0c9887e2ee69a76ff5ffc763974c
https://github.com/kmfk/slowdb/blob/7461771b8ddc0c9887e2ee69a76ff5ffc763974c/src/Database.php#L127-L140
train
samsonos/php_core
src/loader/ContainerManager.php
ContainerManager.collectXmlMetadata
public function collectXmlMetadata(array $metadataCollection) : array { // If config path is exists if (file_exists($this->configPath)) { // Init resolver $xmlConfigurator = new XmlResolver(new CollectionClassResolver([ Scope::class, Name::class, ClassName::class, \samsonframework\containercollection\attribute\Service::class ]), new CollectionPropertyResolver([ ClassName::class, Value::class ]), new CollectionMethodResolver([], new CollectionParameterResolver([ ClassName::class, Value::class, ArrayValue::class, \samsonframework\containercollection\attribute\Service::class ]))); // Collect new metadata $xmlCollector = new XmlMetadataCollector($xmlConfigurator); return $xmlCollector->collect(file_get_contents($this->configPath), $metadataCollection); } return $metadataCollection; }
php
public function collectXmlMetadata(array $metadataCollection) : array { // If config path is exists if (file_exists($this->configPath)) { // Init resolver $xmlConfigurator = new XmlResolver(new CollectionClassResolver([ Scope::class, Name::class, ClassName::class, \samsonframework\containercollection\attribute\Service::class ]), new CollectionPropertyResolver([ ClassName::class, Value::class ]), new CollectionMethodResolver([], new CollectionParameterResolver([ ClassName::class, Value::class, ArrayValue::class, \samsonframework\containercollection\attribute\Service::class ]))); // Collect new metadata $xmlCollector = new XmlMetadataCollector($xmlConfigurator); return $xmlCollector->collect(file_get_contents($this->configPath), $metadataCollection); } return $metadataCollection; }
[ "public", "function", "collectXmlMetadata", "(", "array", "$", "metadataCollection", ")", ":", "array", "{", "// If config path is exists", "if", "(", "file_exists", "(", "$", "this", "->", "configPath", ")", ")", "{", "// Init resolver", "$", "xmlConfigurator", "=", "new", "XmlResolver", "(", "new", "CollectionClassResolver", "(", "[", "Scope", "::", "class", ",", "Name", "::", "class", ",", "ClassName", "::", "class", ",", "\\", "samsonframework", "\\", "containercollection", "\\", "attribute", "\\", "Service", "::", "class", "]", ")", ",", "new", "CollectionPropertyResolver", "(", "[", "ClassName", "::", "class", ",", "Value", "::", "class", "]", ")", ",", "new", "CollectionMethodResolver", "(", "[", "]", ",", "new", "CollectionParameterResolver", "(", "[", "ClassName", "::", "class", ",", "Value", "::", "class", ",", "ArrayValue", "::", "class", ",", "\\", "samsonframework", "\\", "containercollection", "\\", "attribute", "\\", "Service", "::", "class", "]", ")", ")", ")", ";", "// Collect new metadata", "$", "xmlCollector", "=", "new", "XmlMetadataCollector", "(", "$", "xmlConfigurator", ")", ";", "return", "$", "xmlCollector", "->", "collect", "(", "file_get_contents", "(", "$", "this", "->", "configPath", ")", ",", "$", "metadataCollection", ")", ";", "}", "return", "$", "metadataCollection", ";", "}" ]
Get xml metadata collection @param array $metadataCollection @return array @throws \Exception
[ "Get", "xml", "metadata", "collection" ]
15f30528e2efab9e9cf16e9aad3899edced49de1
https://github.com/samsonos/php_core/blob/15f30528e2efab9e9cf16e9aad3899edced49de1/src/loader/ContainerManager.php#L79-L103
train
samsonos/php_core
src/loader/ContainerManager.php
ContainerManager.getDefaultPropertyValue
public function getDefaultPropertyValue($className, $propertyName) { $reflection = new \ReflectionClass($className); $values = $reflection->getDefaultProperties(); return $values[$propertyName] ?? null; }
php
public function getDefaultPropertyValue($className, $propertyName) { $reflection = new \ReflectionClass($className); $values = $reflection->getDefaultProperties(); return $values[$propertyName] ?? null; }
[ "public", "function", "getDefaultPropertyValue", "(", "$", "className", ",", "$", "propertyName", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "className", ")", ";", "$", "values", "=", "$", "reflection", "->", "getDefaultProperties", "(", ")", ";", "return", "$", "values", "[", "$", "propertyName", "]", "??", "null", ";", "}" ]
Get default property value by property name @param $className @param $propertyName @return null
[ "Get", "default", "property", "value", "by", "property", "name" ]
15f30528e2efab9e9cf16e9aad3899edced49de1
https://github.com/samsonos/php_core/blob/15f30528e2efab9e9cf16e9aad3899edced49de1/src/loader/ContainerManager.php#L112-L117
train
samsonos/php_core
src/loader/ContainerManager.php
ContainerManager.createMetadata
public function createMetadata($class, $name, $path, $scope = 'module') : ClassMetadata { $metadata = new ClassMetadata(); $class = ltrim($class, '\\'); $name = strtolower(ltrim($name, '\\')); $metadata->className = $class; $metadata->name = str_replace(['\\', '/'], '_', $name ?? $class); $metadata->scopes[] = Builder::SCOPE_SERVICES; $metadata->scopes[] = $scope; // TODO: Now we need to remove and change constructors $metadata->methodsMetadata['__construct'] = new MethodMetadata($metadata); // Iterate constructor arguments to preserve arguments order and inject dependencies foreach ((new \ReflectionMethod($class, '__construct'))->getParameters() as $parameter) { if ($parameter->getName() === 'path') { $metadata->methodsMetadata['__construct']->dependencies['path'] = $path; } elseif ($parameter->getName() === 'resources') { $metadata->methodsMetadata['__construct']->dependencies['resources'] = ResourceMap::class; } elseif ($parameter->getName() === 'system') { $metadata->methodsMetadata['__construct']->dependencies['system'] = Core::class; } elseif (!$parameter->isOptional()) { $metadata->methodsMetadata['__construct']->dependencies[$parameter->getName()] = ''; } } return $metadata; }
php
public function createMetadata($class, $name, $path, $scope = 'module') : ClassMetadata { $metadata = new ClassMetadata(); $class = ltrim($class, '\\'); $name = strtolower(ltrim($name, '\\')); $metadata->className = $class; $metadata->name = str_replace(['\\', '/'], '_', $name ?? $class); $metadata->scopes[] = Builder::SCOPE_SERVICES; $metadata->scopes[] = $scope; // TODO: Now we need to remove and change constructors $metadata->methodsMetadata['__construct'] = new MethodMetadata($metadata); // Iterate constructor arguments to preserve arguments order and inject dependencies foreach ((new \ReflectionMethod($class, '__construct'))->getParameters() as $parameter) { if ($parameter->getName() === 'path') { $metadata->methodsMetadata['__construct']->dependencies['path'] = $path; } elseif ($parameter->getName() === 'resources') { $metadata->methodsMetadata['__construct']->dependencies['resources'] = ResourceMap::class; } elseif ($parameter->getName() === 'system') { $metadata->methodsMetadata['__construct']->dependencies['system'] = Core::class; } elseif (!$parameter->isOptional()) { $metadata->methodsMetadata['__construct']->dependencies[$parameter->getName()] = ''; } } return $metadata; }
[ "public", "function", "createMetadata", "(", "$", "class", ",", "$", "name", ",", "$", "path", ",", "$", "scope", "=", "'module'", ")", ":", "ClassMetadata", "{", "$", "metadata", "=", "new", "ClassMetadata", "(", ")", ";", "$", "class", "=", "ltrim", "(", "$", "class", ",", "'\\\\'", ")", ";", "$", "name", "=", "strtolower", "(", "ltrim", "(", "$", "name", ",", "'\\\\'", ")", ")", ";", "$", "metadata", "->", "className", "=", "$", "class", ";", "$", "metadata", "->", "name", "=", "str_replace", "(", "[", "'\\\\'", ",", "'/'", "]", ",", "'_'", ",", "$", "name", "??", "$", "class", ")", ";", "$", "metadata", "->", "scopes", "[", "]", "=", "Builder", "::", "SCOPE_SERVICES", ";", "$", "metadata", "->", "scopes", "[", "]", "=", "$", "scope", ";", "// TODO: Now we need to remove and change constructors", "$", "metadata", "->", "methodsMetadata", "[", "'__construct'", "]", "=", "new", "MethodMetadata", "(", "$", "metadata", ")", ";", "// Iterate constructor arguments to preserve arguments order and inject dependencies", "foreach", "(", "(", "new", "\\", "ReflectionMethod", "(", "$", "class", ",", "'__construct'", ")", ")", "->", "getParameters", "(", ")", "as", "$", "parameter", ")", "{", "if", "(", "$", "parameter", "->", "getName", "(", ")", "===", "'path'", ")", "{", "$", "metadata", "->", "methodsMetadata", "[", "'__construct'", "]", "->", "dependencies", "[", "'path'", "]", "=", "$", "path", ";", "}", "elseif", "(", "$", "parameter", "->", "getName", "(", ")", "===", "'resources'", ")", "{", "$", "metadata", "->", "methodsMetadata", "[", "'__construct'", "]", "->", "dependencies", "[", "'resources'", "]", "=", "ResourceMap", "::", "class", ";", "}", "elseif", "(", "$", "parameter", "->", "getName", "(", ")", "===", "'system'", ")", "{", "$", "metadata", "->", "methodsMetadata", "[", "'__construct'", "]", "->", "dependencies", "[", "'system'", "]", "=", "Core", "::", "class", ";", "}", "elseif", "(", "!", "$", "parameter", "->", "isOptional", "(", ")", ")", "{", "$", "metadata", "->", "methodsMetadata", "[", "'__construct'", "]", "->", "dependencies", "[", "$", "parameter", "->", "getName", "(", ")", "]", "=", "''", ";", "}", "}", "return", "$", "metadata", ";", "}" ]
Create metadata for module @param $class @param $name @param $path @param string $scope @return ClassMetadata
[ "Create", "metadata", "for", "module" ]
15f30528e2efab9e9cf16e9aad3899edced49de1
https://github.com/samsonos/php_core/blob/15f30528e2efab9e9cf16e9aad3899edced49de1/src/loader/ContainerManager.php#L128-L154
train
samsonos/php_core
src/loader/ContainerManager.php
ContainerManager.collectAnnotationMetadata
public function collectAnnotationMetadata($classes, $metadataCollection) { // Load annotation and parse classes new Injectable(); new InjectArgument(['var' => 'type']); new Service(['value' => '']); $reader = new AnnotationReader(); $resolver = new AnnotationResolver( new AnnotationClassResolver($reader), new AnnotationPropertyResolver($reader), new AnnotationMethodResolver($reader) ); $annotationCollector = new AnnotationMetadataCollector($resolver); // Rewrite collection by entity name return $annotationCollector->collect($classes, $metadataCollection); }
php
public function collectAnnotationMetadata($classes, $metadataCollection) { // Load annotation and parse classes new Injectable(); new InjectArgument(['var' => 'type']); new Service(['value' => '']); $reader = new AnnotationReader(); $resolver = new AnnotationResolver( new AnnotationClassResolver($reader), new AnnotationPropertyResolver($reader), new AnnotationMethodResolver($reader) ); $annotationCollector = new AnnotationMetadataCollector($resolver); // Rewrite collection by entity name return $annotationCollector->collect($classes, $metadataCollection); }
[ "public", "function", "collectAnnotationMetadata", "(", "$", "classes", ",", "$", "metadataCollection", ")", "{", "// Load annotation and parse classes", "new", "Injectable", "(", ")", ";", "new", "InjectArgument", "(", "[", "'var'", "=>", "'type'", "]", ")", ";", "new", "Service", "(", "[", "'value'", "=>", "''", "]", ")", ";", "$", "reader", "=", "new", "AnnotationReader", "(", ")", ";", "$", "resolver", "=", "new", "AnnotationResolver", "(", "new", "AnnotationClassResolver", "(", "$", "reader", ")", ",", "new", "AnnotationPropertyResolver", "(", "$", "reader", ")", ",", "new", "AnnotationMethodResolver", "(", "$", "reader", ")", ")", ";", "$", "annotationCollector", "=", "new", "AnnotationMetadataCollector", "(", "$", "resolver", ")", ";", "// Rewrite collection by entity name", "return", "$", "annotationCollector", "->", "collect", "(", "$", "classes", ",", "$", "metadataCollection", ")", ";", "}" ]
Get annotation metadata @param $classes @param $metadataCollection @return array|\samsonframework\container\metadata\ClassMetadata[]
[ "Get", "annotation", "metadata" ]
15f30528e2efab9e9cf16e9aad3899edced49de1
https://github.com/samsonos/php_core/blob/15f30528e2efab9e9cf16e9aad3899edced49de1/src/loader/ContainerManager.php#L269-L287
train
danhanly/signalert
src/Signalert/Resolver.php
Resolver.getRenderer
public function getRenderer() { // Attempt to retrieve the renderer config $config = new Config($this->configDirectory); $rendererClass = $config->getRenderer(); // Validate Renderer Class $reflection = new ReflectionClass($rendererClass); // Ensure class is built with the correct interface if (false === $reflection->implementsInterface('Signalert\Renderer\RendererInterface')) { throw new SignalertResolverException; } // If it all checks out, resolve the class and instantiate return $reflection->newInstance(); }
php
public function getRenderer() { // Attempt to retrieve the renderer config $config = new Config($this->configDirectory); $rendererClass = $config->getRenderer(); // Validate Renderer Class $reflection = new ReflectionClass($rendererClass); // Ensure class is built with the correct interface if (false === $reflection->implementsInterface('Signalert\Renderer\RendererInterface')) { throw new SignalertResolverException; } // If it all checks out, resolve the class and instantiate return $reflection->newInstance(); }
[ "public", "function", "getRenderer", "(", ")", "{", "// Attempt to retrieve the renderer config", "$", "config", "=", "new", "Config", "(", "$", "this", "->", "configDirectory", ")", ";", "$", "rendererClass", "=", "$", "config", "->", "getRenderer", "(", ")", ";", "// Validate Renderer Class", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "rendererClass", ")", ";", "// Ensure class is built with the correct interface", "if", "(", "false", "===", "$", "reflection", "->", "implementsInterface", "(", "'Signalert\\Renderer\\RendererInterface'", ")", ")", "{", "throw", "new", "SignalertResolverException", ";", "}", "// If it all checks out, resolve the class and instantiate", "return", "$", "reflection", "->", "newInstance", "(", ")", ";", "}" ]
Returns a valid renderer class @return RendererInterface @throws Exception\SignalertInvalidRendererException @throws SignalertResolverException
[ "Returns", "a", "valid", "renderer", "class" ]
21ee50e3fc0352306a2966b555984b5c9eada582
https://github.com/danhanly/signalert/blob/21ee50e3fc0352306a2966b555984b5c9eada582/src/Signalert/Resolver.php#L32-L45
train
danhanly/signalert
src/Signalert/Resolver.php
Resolver.getDriver
public function getDriver() { // Attempt to retrieve the driver config $config = new Config($this->configDirectory); $driverClass = $config->getDriver(); // Validate Driver Class $reflection = new ReflectionClass($driverClass); // Ensure class is built with the correct interface if (false === $reflection->implementsInterface('Signalert\Storage\DriverInterface')) { throw new SignalertResolverException; } // If it all checks out, resolve the class and instantiate return $reflection->newInstance(); }
php
public function getDriver() { // Attempt to retrieve the driver config $config = new Config($this->configDirectory); $driverClass = $config->getDriver(); // Validate Driver Class $reflection = new ReflectionClass($driverClass); // Ensure class is built with the correct interface if (false === $reflection->implementsInterface('Signalert\Storage\DriverInterface')) { throw new SignalertResolverException; } // If it all checks out, resolve the class and instantiate return $reflection->newInstance(); }
[ "public", "function", "getDriver", "(", ")", "{", "// Attempt to retrieve the driver config", "$", "config", "=", "new", "Config", "(", "$", "this", "->", "configDirectory", ")", ";", "$", "driverClass", "=", "$", "config", "->", "getDriver", "(", ")", ";", "// Validate Driver Class", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "driverClass", ")", ";", "// Ensure class is built with the correct interface", "if", "(", "false", "===", "$", "reflection", "->", "implementsInterface", "(", "'Signalert\\Storage\\DriverInterface'", ")", ")", "{", "throw", "new", "SignalertResolverException", ";", "}", "// If it all checks out, resolve the class and instantiate", "return", "$", "reflection", "->", "newInstance", "(", ")", ";", "}" ]
Returns a valid driver class @return DriverInterface @throws SignalertResolverException
[ "Returns", "a", "valid", "driver", "class" ]
21ee50e3fc0352306a2966b555984b5c9eada582
https://github.com/danhanly/signalert/blob/21ee50e3fc0352306a2966b555984b5c9eada582/src/Signalert/Resolver.php#L53-L67
train
skillberto/SonataExtendedAdminBundle
Controller/CRUDController.php
CRUDController.activateAction
public function activateAction() { $object = $this->getObject(); if (method_exists($object, 'setActive') && method_exists($object, 'getActive')) { $object->setActive(($object->getActive()==1) ? 0 : 1); } $this->admin->update($object); return new RedirectResponse($this->admin->generateUrl('list')); }
php
public function activateAction() { $object = $this->getObject(); if (method_exists($object, 'setActive') && method_exists($object, 'getActive')) { $object->setActive(($object->getActive()==1) ? 0 : 1); } $this->admin->update($object); return new RedirectResponse($this->admin->generateUrl('list')); }
[ "public", "function", "activateAction", "(", ")", "{", "$", "object", "=", "$", "this", "->", "getObject", "(", ")", ";", "if", "(", "method_exists", "(", "$", "object", ",", "'setActive'", ")", "&&", "method_exists", "(", "$", "object", ",", "'getActive'", ")", ")", "{", "$", "object", "->", "setActive", "(", "(", "$", "object", "->", "getActive", "(", ")", "==", "1", ")", "?", "0", ":", "1", ")", ";", "}", "$", "this", "->", "admin", "->", "update", "(", "$", "object", ")", ";", "return", "new", "RedirectResponse", "(", "$", "this", "->", "admin", "->", "generateUrl", "(", "'list'", ")", ")", ";", "}" ]
Activate or inactivate the object @throws Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @return Symfony\Component\HttpFoundation\RedirectResponse
[ "Activate", "or", "inactivate", "the", "object" ]
5ca04cab25181e78b7ee4e866ae0567bd074fa41
https://github.com/skillberto/SonataExtendedAdminBundle/blob/5ca04cab25181e78b7ee4e866ae0567bd074fa41/Controller/CRUDController.php#L23-L34
train
oliwierptak/Everon1
src/Everon/Helper/Asserts/IsArray.php
IsArray.assertIsArray
public function assertIsArray($value, $message='%s must be an Array', $exception='Asserts') { if (isset($value) === false || is_array($value) === false) { $this->throwException($exception, $message, $value); } }
php
public function assertIsArray($value, $message='%s must be an Array', $exception='Asserts') { if (isset($value) === false || is_array($value) === false) { $this->throwException($exception, $message, $value); } }
[ "public", "function", "assertIsArray", "(", "$", "value", ",", "$", "message", "=", "'%s must be an Array'", ",", "$", "exception", "=", "'Asserts'", ")", "{", "if", "(", "isset", "(", "$", "value", ")", "===", "false", "||", "is_array", "(", "$", "value", ")", "===", "false", ")", "{", "$", "this", "->", "throwException", "(", "$", "exception", ",", "$", "message", ",", "$", "value", ")", ";", "}", "}" ]
Verifies that the specified condition is array. The assertion fails if the condition is not array. @param mixed $value @param string $message @param string $exception @throws \Everon\Exception\Asserts
[ "Verifies", "that", "the", "specified", "condition", "is", "array", ".", "The", "assertion", "fails", "if", "the", "condition", "is", "not", "array", "." ]
ac93793d1fa517a8394db5f00062f1925dc218a3
https://github.com/oliwierptak/Everon1/blob/ac93793d1fa517a8394db5f00062f1925dc218a3/src/Everon/Helper/Asserts/IsArray.php#L23-L28
train
RowlandOti/ooglee-blogmodule
src/OoGlee/Application/Entities/Post/Category/CategoryResponse.php
PostResponse.make
public function make(ICategory $category) { //$category->setResponse($this->response->view('admin.categorys.view', compact('category'))); $category->setResponse($this->response->view(\OogleeBConfig::get('config.category_view.view'), compact('category'))); }
php
public function make(ICategory $category) { //$category->setResponse($this->response->view('admin.categorys.view', compact('category'))); $category->setResponse($this->response->view(\OogleeBConfig::get('config.category_view.view'), compact('category'))); }
[ "public", "function", "make", "(", "ICategory", "$", "category", ")", "{", "//$category->setResponse($this->response->view('admin.categorys.view', compact('category')));\r", "$", "category", "->", "setResponse", "(", "$", "this", "->", "response", "->", "view", "(", "\\", "OogleeBConfig", "::", "get", "(", "'config.category_view.view'", ")", ",", "compact", "(", "'category'", ")", ")", ")", ";", "}" ]
Make the category response. @param ICategory $category
[ "Make", "the", "category", "response", "." ]
d9c0fe4745bb09f8b94047b0cda4fd7438cde16a
https://github.com/RowlandOti/ooglee-blogmodule/blob/d9c0fe4745bb09f8b94047b0cda4fd7438cde16a/src/OoGlee/Application/Entities/Post/Category/CategoryResponse.php#L40-L44
train
alphacomm/alpharpc
src/AlphaRPC/Manager/WorkerHandler/Worker.php
Worker.addAction
public function addAction($action) { if ($action instanceof Action) { $action = $action->getName(); } $this->actionList[] = $action; $this->valid = null; return $this; }
php
public function addAction($action) { if ($action instanceof Action) { $action = $action->getName(); } $this->actionList[] = $action; $this->valid = null; return $this; }
[ "public", "function", "addAction", "(", "$", "action", ")", "{", "if", "(", "$", "action", "instanceof", "Action", ")", "{", "$", "action", "=", "$", "action", "->", "getName", "(", ")", ";", "}", "$", "this", "->", "actionList", "[", "]", "=", "$", "action", ";", "$", "this", "->", "valid", "=", "null", ";", "return", "$", "this", ";", "}" ]
Adds a action name to the list of actions the worker listens to. @param Action $action @return Worker
[ "Adds", "a", "action", "name", "to", "the", "list", "of", "actions", "the", "worker", "listens", "to", "." ]
cf162854500554c4ba8d39f2675de35a49c30ed0
https://github.com/alphacomm/alpharpc/blob/cf162854500554c4ba8d39f2675de35a49c30ed0/src/AlphaRPC/Manager/WorkerHandler/Worker.php#L126-L135
train
Synapse-Cmf/synapse-cmf
src/Synapse/Cmf/Framework/Media/Image/Entity/Image.php
Image.getFormattedImage
public function getFormattedImage($format) { $formatName = $format instanceof FormatInterface ? $format->getName() : $format ; return $this->formattedImages ->filter(function (FormattedImageInterface $formattedImage) use ($formatName) { return ($format = $formattedImage->getFormat()) && $format->getName() == $formatName ; }) ->first() ?: null // first() returns "false" if collection empty ; }
php
public function getFormattedImage($format) { $formatName = $format instanceof FormatInterface ? $format->getName() : $format ; return $this->formattedImages ->filter(function (FormattedImageInterface $formattedImage) use ($formatName) { return ($format = $formattedImage->getFormat()) && $format->getName() == $formatName ; }) ->first() ?: null // first() returns "false" if collection empty ; }
[ "public", "function", "getFormattedImage", "(", "$", "format", ")", "{", "$", "formatName", "=", "$", "format", "instanceof", "FormatInterface", "?", "$", "format", "->", "getName", "(", ")", ":", "$", "format", ";", "return", "$", "this", "->", "formattedImages", "->", "filter", "(", "function", "(", "FormattedImageInterface", "$", "formattedImage", ")", "use", "(", "$", "formatName", ")", "{", "return", "(", "$", "format", "=", "$", "formattedImage", "->", "getFormat", "(", ")", ")", "&&", "$", "format", "->", "getName", "(", ")", "==", "$", "formatName", ";", "}", ")", "->", "first", "(", ")", "?", ":", "null", "// first() returns \"false\" if collection empty", ";", "}" ]
Returns image formatted for given format name or FormatInterface object. @param string|FormatInterface $format @return FormattedImageInterface|null
[ "Returns", "image", "formatted", "for", "given", "format", "name", "or", "FormatInterface", "object", "." ]
d8122a4150a83d5607289724425cf35c56a5e880
https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Cmf/Framework/Media/Image/Entity/Image.php#L213-L228
train
Synapse-Cmf/synapse-cmf
src/Synapse/Cmf/Framework/Media/Image/Entity/Image.php
Image.getFormatWebPath
public function getFormatWebPath($format = null) { if (!$format = $format ?: $this->defaultFormat) { return $this->getWebPath(); } return ($formattedImage = $this->getFormattedImage($format)) ? $formattedImage->getWebPath() : $this->getWebPath() ; }
php
public function getFormatWebPath($format = null) { if (!$format = $format ?: $this->defaultFormat) { return $this->getWebPath(); } return ($formattedImage = $this->getFormattedImage($format)) ? $formattedImage->getWebPath() : $this->getWebPath() ; }
[ "public", "function", "getFormatWebPath", "(", "$", "format", "=", "null", ")", "{", "if", "(", "!", "$", "format", "=", "$", "format", "?", ":", "$", "this", "->", "defaultFormat", ")", "{", "return", "$", "this", "->", "getWebPath", "(", ")", ";", "}", "return", "(", "$", "formattedImage", "=", "$", "this", "->", "getFormattedImage", "(", "$", "format", ")", ")", "?", "$", "formattedImage", "->", "getWebPath", "(", ")", ":", "$", "this", "->", "getWebPath", "(", ")", ";", "}" ]
Returns requested format web path, or original one, if format doesnt exists. @param string|FormatInterface $format @return string
[ "Returns", "requested", "format", "web", "path", "or", "original", "one", "if", "format", "doesnt", "exists", "." ]
d8122a4150a83d5607289724425cf35c56a5e880
https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Cmf/Framework/Media/Image/Entity/Image.php#L237-L247
train
nasumilu/geometry
src/MultiSurface.php
MultiSurface.getArea
public function getArea(): float { $event = new MeasurementOpEvent($this); $this->fireOperationEvent(MeasurementOpEvent::AREA_EVENT, $event); return $event->getResults(); }
php
public function getArea(): float { $event = new MeasurementOpEvent($this); $this->fireOperationEvent(MeasurementOpEvent::AREA_EVENT, $event); return $event->getResults(); }
[ "public", "function", "getArea", "(", ")", ":", "float", "{", "$", "event", "=", "new", "MeasurementOpEvent", "(", "$", "this", ")", ";", "$", "this", "->", "fireOperationEvent", "(", "MeasurementOpEvent", "::", "AREA_EVENT", ",", "$", "event", ")", ";", "return", "$", "event", "->", "getResults", "(", ")", ";", "}" ]
Gets the area of this MultiSurface, as measured in the spatial reference system of this Surface. @return float
[ "Gets", "the", "area", "of", "this", "MultiSurface", "as", "measured", "in", "the", "spatial", "reference", "system", "of", "this", "Surface", "." ]
000fafe3e61f1d0682952ad236b7486dded65eae
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/MultiSurface.php#L65-L69
train
nasumilu/geometry
src/MultiSurface.php
MultiSurface.getPointOnSurface
public function getPointOnSurface(): Point { $event = new ProcessOpEvent($this); $this->fireOperationEvent(ProcessOpEvent::POINT_ON_SURFACE_EVENT, $event); return $event->getResults(); }
php
public function getPointOnSurface(): Point { $event = new ProcessOpEvent($this); $this->fireOperationEvent(ProcessOpEvent::POINT_ON_SURFACE_EVENT, $event); return $event->getResults(); }
[ "public", "function", "getPointOnSurface", "(", ")", ":", "Point", "{", "$", "event", "=", "new", "ProcessOpEvent", "(", "$", "this", ")", ";", "$", "this", "->", "fireOperationEvent", "(", "ProcessOpEvent", "::", "POINT_ON_SURFACE_EVENT", ",", "$", "event", ")", ";", "return", "$", "event", "->", "getResults", "(", ")", ";", "}" ]
Gets a Point guaranteed to be on the MultiSurface. @return \Nasumilu\Geometry\Geometry
[ "Gets", "a", "Point", "guaranteed", "to", "be", "on", "the", "MultiSurface", "." ]
000fafe3e61f1d0682952ad236b7486dded65eae
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/MultiSurface.php#L88-L92
train
siriusphp/filtration
src/Filtrator.php
Filtrator.add
function add($selector, $callbackOrFilterName = null, $options = null, $recursive = false, $priority = 0) { /** * $selector is actually an array with filters * * @example $filtrator->add(array( * 'title' => array('trim', array('truncate', '{"limit":100}')) * 'description' => array('trim') * )); */ if (is_array($selector)) { foreach ($selector as $key => $filters) { $this->add($key, $filters); } return $this; } if (! is_string($selector)) { throw new \InvalidArgumentException('The data selector for filtering must be a string'); } if (is_string($callbackOrFilterName)) { // rule was supplied like 'trim' or 'trim | nullify' if (strpos($callbackOrFilterName, ' | ') !== false) { return $this->add($selector, explode(' | ', $callbackOrFilterName)); } // rule was supplied like this 'trim(limit=10)(true)(10)' if (strpos($callbackOrFilterName, '(') !== false) { list ($callbackOrFilterName, $options, $recursive, $priority) = $this->parseRule($callbackOrFilterName); } } /** * The $callbackOrFilterName is an array of filters * * @example $filtrator->add('title', array( * 'trim', * array('truncate', '{"limit":100}') * )); */ if (is_array($callbackOrFilterName) && ! is_callable($callbackOrFilterName)) { foreach ($callbackOrFilterName as $filter) { // $filter is something like array('truncate', '{"limit":100}') if (is_array($filter) && ! is_callable($filter)) { $args = $filter; array_unshift($args, $selector); call_user_func_array(array( $this, 'add' ), $args); } elseif (is_string($filter) || is_callable($filter)) { $this->add($selector, $filter); } } return $this; } $filter = $this->filterFactory->createFilter($callbackOrFilterName, $options, $recursive); if (! array_key_exists($selector, $this->filters)) { $this->filters[$selector] = new FilterSet(); } /* @var $filterSet FilterSet */ $filterSet = $this->filters[$selector]; $filterSet->insert($filter, $priority); return $this; }
php
function add($selector, $callbackOrFilterName = null, $options = null, $recursive = false, $priority = 0) { /** * $selector is actually an array with filters * * @example $filtrator->add(array( * 'title' => array('trim', array('truncate', '{"limit":100}')) * 'description' => array('trim') * )); */ if (is_array($selector)) { foreach ($selector as $key => $filters) { $this->add($key, $filters); } return $this; } if (! is_string($selector)) { throw new \InvalidArgumentException('The data selector for filtering must be a string'); } if (is_string($callbackOrFilterName)) { // rule was supplied like 'trim' or 'trim | nullify' if (strpos($callbackOrFilterName, ' | ') !== false) { return $this->add($selector, explode(' | ', $callbackOrFilterName)); } // rule was supplied like this 'trim(limit=10)(true)(10)' if (strpos($callbackOrFilterName, '(') !== false) { list ($callbackOrFilterName, $options, $recursive, $priority) = $this->parseRule($callbackOrFilterName); } } /** * The $callbackOrFilterName is an array of filters * * @example $filtrator->add('title', array( * 'trim', * array('truncate', '{"limit":100}') * )); */ if (is_array($callbackOrFilterName) && ! is_callable($callbackOrFilterName)) { foreach ($callbackOrFilterName as $filter) { // $filter is something like array('truncate', '{"limit":100}') if (is_array($filter) && ! is_callable($filter)) { $args = $filter; array_unshift($args, $selector); call_user_func_array(array( $this, 'add' ), $args); } elseif (is_string($filter) || is_callable($filter)) { $this->add($selector, $filter); } } return $this; } $filter = $this->filterFactory->createFilter($callbackOrFilterName, $options, $recursive); if (! array_key_exists($selector, $this->filters)) { $this->filters[$selector] = new FilterSet(); } /* @var $filterSet FilterSet */ $filterSet = $this->filters[$selector]; $filterSet->insert($filter, $priority); return $this; }
[ "function", "add", "(", "$", "selector", ",", "$", "callbackOrFilterName", "=", "null", ",", "$", "options", "=", "null", ",", "$", "recursive", "=", "false", ",", "$", "priority", "=", "0", ")", "{", "/**\n * $selector is actually an array with filters\n *\n * @example $filtrator->add(array(\n * 'title' => array('trim', array('truncate', '{\"limit\":100}'))\n * 'description' => array('trim')\n * ));\n */", "if", "(", "is_array", "(", "$", "selector", ")", ")", "{", "foreach", "(", "$", "selector", "as", "$", "key", "=>", "$", "filters", ")", "{", "$", "this", "->", "add", "(", "$", "key", ",", "$", "filters", ")", ";", "}", "return", "$", "this", ";", "}", "if", "(", "!", "is_string", "(", "$", "selector", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The data selector for filtering must be a string'", ")", ";", "}", "if", "(", "is_string", "(", "$", "callbackOrFilterName", ")", ")", "{", "// rule was supplied like 'trim' or 'trim | nullify'", "if", "(", "strpos", "(", "$", "callbackOrFilterName", ",", "' | '", ")", "!==", "false", ")", "{", "return", "$", "this", "->", "add", "(", "$", "selector", ",", "explode", "(", "' | '", ",", "$", "callbackOrFilterName", ")", ")", ";", "}", "// rule was supplied like this 'trim(limit=10)(true)(10)'", "if", "(", "strpos", "(", "$", "callbackOrFilterName", ",", "'('", ")", "!==", "false", ")", "{", "list", "(", "$", "callbackOrFilterName", ",", "$", "options", ",", "$", "recursive", ",", "$", "priority", ")", "=", "$", "this", "->", "parseRule", "(", "$", "callbackOrFilterName", ")", ";", "}", "}", "/**\n * The $callbackOrFilterName is an array of filters\n *\n * @example $filtrator->add('title', array(\n * 'trim',\n * array('truncate', '{\"limit\":100}')\n * ));\n */", "if", "(", "is_array", "(", "$", "callbackOrFilterName", ")", "&&", "!", "is_callable", "(", "$", "callbackOrFilterName", ")", ")", "{", "foreach", "(", "$", "callbackOrFilterName", "as", "$", "filter", ")", "{", "// $filter is something like array('truncate', '{\"limit\":100}')", "if", "(", "is_array", "(", "$", "filter", ")", "&&", "!", "is_callable", "(", "$", "filter", ")", ")", "{", "$", "args", "=", "$", "filter", ";", "array_unshift", "(", "$", "args", ",", "$", "selector", ")", ";", "call_user_func_array", "(", "array", "(", "$", "this", ",", "'add'", ")", ",", "$", "args", ")", ";", "}", "elseif", "(", "is_string", "(", "$", "filter", ")", "||", "is_callable", "(", "$", "filter", ")", ")", "{", "$", "this", "->", "add", "(", "$", "selector", ",", "$", "filter", ")", ";", "}", "}", "return", "$", "this", ";", "}", "$", "filter", "=", "$", "this", "->", "filterFactory", "->", "createFilter", "(", "$", "callbackOrFilterName", ",", "$", "options", ",", "$", "recursive", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "selector", ",", "$", "this", "->", "filters", ")", ")", "{", "$", "this", "->", "filters", "[", "$", "selector", "]", "=", "new", "FilterSet", "(", ")", ";", "}", "/* @var $filterSet FilterSet */", "$", "filterSet", "=", "$", "this", "->", "filters", "[", "$", "selector", "]", ";", "$", "filterSet", "->", "insert", "(", "$", "filter", ",", "$", "priority", ")", ";", "return", "$", "this", ";", "}" ]
Add a filter to the filters stack @example // normal callback $filtrator->add('title', '\strip_tags'); // anonymous function $filtrator->add('title', function($value){ return $value . '!!!'; }); // filter class from the library registered on the $filtersMap $filtrator->add('title', 'normalizedate', array('format' => 'm/d/Y')); // custom class $filtrator->add('title', '\MyApp\Filters\CustomFilter'); // multiple filters as once with different ways to pass options $filtrator->add('title', array( array('truncate', 'limit=10', true, 10), array('censor', array('words' => array('faggy', 'idiot')) )); // multiple fitlers as a single string $filtrator->add('title', 'stringtrim(side=left)(true)(10) | truncate(limit=100)'); @param string|array $selector @param mixed $callbackOrFilterName @param array|null $options @param bool $recursive @param integer $priority @throws \InvalidArgumentException @internal param $ callable|filter class name|\Sirius\Filtration\Filter\AbstractFilter $callbackOrFilterName* callable|filter class name|\Sirius\Filtration\Filter\AbstractFilter $callbackOrFilterName @internal param array|string $params @return self
[ "Add", "a", "filter", "to", "the", "filters", "stack" ]
9f96592484f6d326e8bb8d5957be604a1622d08f
https://github.com/siriusphp/filtration/blob/9f96592484f6d326e8bb8d5957be604a1622d08f/src/Filtrator.php#L58-L124
train
siriusphp/filtration
src/Filtrator.php
Filtrator.remove
function remove($selector, $callbackOrName = true) { if (array_key_exists($selector, $this->filters)) { if ($callbackOrName === true) { unset($this->filters[$selector]); } else { if (! is_object($callbackOrName)) { $filter = $this->filterFactory->createFilter($callbackOrName); } else { $filter = $callbackOrName; } /* @var $filterSet FilterSet */ $filterSet = $this->filters[$selector]; $filterSet->remove($filter); } } return $this; }
php
function remove($selector, $callbackOrName = true) { if (array_key_exists($selector, $this->filters)) { if ($callbackOrName === true) { unset($this->filters[$selector]); } else { if (! is_object($callbackOrName)) { $filter = $this->filterFactory->createFilter($callbackOrName); } else { $filter = $callbackOrName; } /* @var $filterSet FilterSet */ $filterSet = $this->filters[$selector]; $filterSet->remove($filter); } } return $this; }
[ "function", "remove", "(", "$", "selector", ",", "$", "callbackOrName", "=", "true", ")", "{", "if", "(", "array_key_exists", "(", "$", "selector", ",", "$", "this", "->", "filters", ")", ")", "{", "if", "(", "$", "callbackOrName", "===", "true", ")", "{", "unset", "(", "$", "this", "->", "filters", "[", "$", "selector", "]", ")", ";", "}", "else", "{", "if", "(", "!", "is_object", "(", "$", "callbackOrName", ")", ")", "{", "$", "filter", "=", "$", "this", "->", "filterFactory", "->", "createFilter", "(", "$", "callbackOrName", ")", ";", "}", "else", "{", "$", "filter", "=", "$", "callbackOrName", ";", "}", "/* @var $filterSet FilterSet */", "$", "filterSet", "=", "$", "this", "->", "filters", "[", "$", "selector", "]", ";", "$", "filterSet", "->", "remove", "(", "$", "filter", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Remove a filter from the stack @param string $selector @param bool|callable|string|TRUE $callbackOrName @throws \InvalidArgumentException @return \Sirius\Filtration\Filtrator
[ "Remove", "a", "filter", "from", "the", "stack" ]
9f96592484f6d326e8bb8d5957be604a1622d08f
https://github.com/siriusphp/filtration/blob/9f96592484f6d326e8bb8d5957be604a1622d08f/src/Filtrator.php#L183-L200
train
siriusphp/filtration
src/Filtrator.php
Filtrator.filter
function filter($data = array()) { if (! is_array($data)) { return $data; } // first apply the filters to the ROOT if (isset($this->filters[self::SELECTOR_ROOT])) { /* @var $rootFilters FilterSet */ $rootFilters = $this->filters[self::SELECTOR_ROOT]; $data = $rootFilters->applyFilters($data); } foreach ($data as $key => $value) { $data[$key] = $this->filterItem($data, $key); } return $data; }
php
function filter($data = array()) { if (! is_array($data)) { return $data; } // first apply the filters to the ROOT if (isset($this->filters[self::SELECTOR_ROOT])) { /* @var $rootFilters FilterSet */ $rootFilters = $this->filters[self::SELECTOR_ROOT]; $data = $rootFilters->applyFilters($data); } foreach ($data as $key => $value) { $data[$key] = $this->filterItem($data, $key); } return $data; }
[ "function", "filter", "(", "$", "data", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "return", "$", "data", ";", "}", "// first apply the filters to the ROOT", "if", "(", "isset", "(", "$", "this", "->", "filters", "[", "self", "::", "SELECTOR_ROOT", "]", ")", ")", "{", "/* @var $rootFilters FilterSet */", "$", "rootFilters", "=", "$", "this", "->", "filters", "[", "self", "::", "SELECTOR_ROOT", "]", ";", "$", "data", "=", "$", "rootFilters", "->", "applyFilters", "(", "$", "data", ")", ";", "}", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "filterItem", "(", "$", "data", ",", "$", "key", ")", ";", "}", "return", "$", "data", ";", "}" ]
Apply filters to an array @param array $data @return array
[ "Apply", "filters", "to", "an", "array" ]
9f96592484f6d326e8bb8d5957be604a1622d08f
https://github.com/siriusphp/filtration/blob/9f96592484f6d326e8bb8d5957be604a1622d08f/src/Filtrator.php#L218-L233
train
siriusphp/filtration
src/Filtrator.php
Filtrator.filterItem
function filterItem($data, $valueIdentifier) { $value = Utils::arrayGetByPath($data, $valueIdentifier); $value = $this->applyFilters($value, $valueIdentifier, $data); if (is_array($value)) { foreach (array_keys($value) as $k) { $value[$k] = $this->filterItem($data, "{$valueIdentifier}[{$k}]"); } } return $value; }
php
function filterItem($data, $valueIdentifier) { $value = Utils::arrayGetByPath($data, $valueIdentifier); $value = $this->applyFilters($value, $valueIdentifier, $data); if (is_array($value)) { foreach (array_keys($value) as $k) { $value[$k] = $this->filterItem($data, "{$valueIdentifier}[{$k}]"); } } return $value; }
[ "function", "filterItem", "(", "$", "data", ",", "$", "valueIdentifier", ")", "{", "$", "value", "=", "Utils", "::", "arrayGetByPath", "(", "$", "data", ",", "$", "valueIdentifier", ")", ";", "$", "value", "=", "$", "this", "->", "applyFilters", "(", "$", "value", ",", "$", "valueIdentifier", ",", "$", "data", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "array_keys", "(", "$", "value", ")", "as", "$", "k", ")", "{", "$", "value", "[", "$", "k", "]", "=", "$", "this", "->", "filterItem", "(", "$", "data", ",", "\"{$valueIdentifier}[{$k}]\"", ")", ";", "}", "}", "return", "$", "value", ";", "}" ]
Apply filters on a single item in the array @param array $data @param string $valueIdentifier @return mixed
[ "Apply", "filters", "on", "a", "single", "item", "in", "the", "array" ]
9f96592484f6d326e8bb8d5957be604a1622d08f
https://github.com/siriusphp/filtration/blob/9f96592484f6d326e8bb8d5957be604a1622d08f/src/Filtrator.php#L242-L252
train
siriusphp/filtration
src/Filtrator.php
Filtrator.applyFilters
function applyFilters($value, $valueIdentifier, $context) { foreach ($this->filters as $selector => $filterSet) { /* @var $filterSet FilterSet */ if ($selector != self::SELECTOR_ROOT && $this->itemMatchesSelector($valueIdentifier, $selector)) { $value = $filterSet->applyFilters($value, $valueIdentifier, $context); } } return $value; }
php
function applyFilters($value, $valueIdentifier, $context) { foreach ($this->filters as $selector => $filterSet) { /* @var $filterSet FilterSet */ if ($selector != self::SELECTOR_ROOT && $this->itemMatchesSelector($valueIdentifier, $selector)) { $value = $filterSet->applyFilters($value, $valueIdentifier, $context); } } return $value; }
[ "function", "applyFilters", "(", "$", "value", ",", "$", "valueIdentifier", ",", "$", "context", ")", "{", "foreach", "(", "$", "this", "->", "filters", "as", "$", "selector", "=>", "$", "filterSet", ")", "{", "/* @var $filterSet FilterSet */", "if", "(", "$", "selector", "!=", "self", "::", "SELECTOR_ROOT", "&&", "$", "this", "->", "itemMatchesSelector", "(", "$", "valueIdentifier", ",", "$", "selector", ")", ")", "{", "$", "value", "=", "$", "filterSet", "->", "applyFilters", "(", "$", "value", ",", "$", "valueIdentifier", ",", "$", "context", ")", ";", "}", "}", "return", "$", "value", ";", "}" ]
Apply filters to a single value @param mixed $value value of the item @param string $valueIdentifier array element path (eg: 'key' or 'key[0][subkey]') @param mixed $context @return mixed
[ "Apply", "filters", "to", "a", "single", "value" ]
9f96592484f6d326e8bb8d5957be604a1622d08f
https://github.com/siriusphp/filtration/blob/9f96592484f6d326e8bb8d5957be604a1622d08f/src/Filtrator.php#L264-L273
train
siriusphp/filtration
src/Filtrator.php
Filtrator.itemMatchesSelector
protected function itemMatchesSelector($item, $selector) { // the selector is a simple path identifier // NOT something like key[*][subkey] if (strpos($selector, '*') === false) { return $item === $selector; } $regex = '/' . str_replace('*', '[^\]]+', str_replace(array( '[', ']' ), array( '\[', '\]' ), $selector)) . '/'; return preg_match($regex, $item); }
php
protected function itemMatchesSelector($item, $selector) { // the selector is a simple path identifier // NOT something like key[*][subkey] if (strpos($selector, '*') === false) { return $item === $selector; } $regex = '/' . str_replace('*', '[^\]]+', str_replace(array( '[', ']' ), array( '\[', '\]' ), $selector)) . '/'; return preg_match($regex, $item); }
[ "protected", "function", "itemMatchesSelector", "(", "$", "item", ",", "$", "selector", ")", "{", "// the selector is a simple path identifier", "// NOT something like key[*][subkey]", "if", "(", "strpos", "(", "$", "selector", ",", "'*'", ")", "===", "false", ")", "{", "return", "$", "item", "===", "$", "selector", ";", "}", "$", "regex", "=", "'/'", ".", "str_replace", "(", "'*'", ",", "'[^\\]]+'", ",", "str_replace", "(", "array", "(", "'['", ",", "']'", ")", ",", "array", "(", "'\\['", ",", "'\\]'", ")", ",", "$", "selector", ")", ")", ".", "'/'", ";", "return", "preg_match", "(", "$", "regex", ",", "$", "item", ")", ";", "}" ]
Checks if an item matches a selector @example $this->('key[subkey]', 'key[*]') -> true; $this->('key[subkey]', 'subkey') -> false; @param string $item @param string $selector @return boolean number
[ "Checks", "if", "an", "item", "matches", "a", "selector" ]
9f96592484f6d326e8bb8d5957be604a1622d08f
https://github.com/siriusphp/filtration/blob/9f96592484f6d326e8bb8d5957be604a1622d08f/src/Filtrator.php#L285-L300
train
scarwu/Pack
src/Pack/HTML.php
HTML.get
public function get($html = null) { if (null === $html) { if (file_exists($this->_path)) { $html = file_get_contents($this->_path); } } $this->_path = null; return $this->parse($html); }
php
public function get($html = null) { if (null === $html) { if (file_exists($this->_path)) { $html = file_get_contents($this->_path); } } $this->_path = null; return $this->parse($html); }
[ "public", "function", "get", "(", "$", "html", "=", "null", ")", "{", "if", "(", "null", "===", "$", "html", ")", "{", "if", "(", "file_exists", "(", "$", "this", "->", "_path", ")", ")", "{", "$", "html", "=", "file_get_contents", "(", "$", "this", "->", "_path", ")", ";", "}", "}", "$", "this", "->", "_path", "=", "null", ";", "return", "$", "this", "->", "parse", "(", "$", "html", ")", ";", "}" ]
Get Packed HTML @param string @param string
[ "Get", "Packed", "HTML" ]
284e3273b18ac963f597893059c0b0d34fa15695
https://github.com/scarwu/Pack/blob/284e3273b18ac963f597893059c0b0d34fa15695/src/Pack/HTML.php#L41-L52
train
Etenil/assegai
src/assegai/modules/mail/services/ses/utilities/hadoopstep.class.php
CFHadoopStep.run_hive_script
public static function run_hive_script($script, $args = null) { if (!$args) $args = array(); $args = is_array($args) ? $args : array($args); $args = array_merge(array('--run-hive-script', '--args', '-f', $script), $args); return self::hive_pig_script('hive', $args); }
php
public static function run_hive_script($script, $args = null) { if (!$args) $args = array(); $args = is_array($args) ? $args : array($args); $args = array_merge(array('--run-hive-script', '--args', '-f', $script), $args); return self::hive_pig_script('hive', $args); }
[ "public", "static", "function", "run_hive_script", "(", "$", "script", ",", "$", "args", "=", "null", ")", "{", "if", "(", "!", "$", "args", ")", "$", "args", "=", "array", "(", ")", ";", "$", "args", "=", "is_array", "(", "$", "args", ")", "?", "$", "args", ":", "array", "(", "$", "args", ")", ";", "$", "args", "=", "array_merge", "(", "array", "(", "'--run-hive-script'", ",", "'--args'", ",", "'-f'", ",", "$", "script", ")", ",", "$", "args", ")", ";", "return", "self", "::", "hive_pig_script", "(", "'hive'", ",", "$", "args", ")", ";", "}" ]
Step that runs a Hive script on your job flow. @param string $script (Required) The script to run with `script-runner.jar`. @param array $args (Optional) An indexed array of arguments to pass to the script. @return array A standard array that is intended to be passed into a <CFStepConfig> object. @link http://hive.apache.org Apache Hive
[ "Step", "that", "runs", "a", "Hive", "script", "on", "your", "job", "flow", "." ]
d43cce1a88f1c332f60dd0a4374b17764852af9e
https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/mail/services/ses/utilities/hadoopstep.class.php#L62-L69
train
Etenil/assegai
src/assegai/modules/mail/services/ses/utilities/hadoopstep.class.php
CFHadoopStep.run_pig_script
public static function run_pig_script($script, $args = null) { if (!$args) $args = array(); $args = is_array($args) ? $args : array($args); $args = array_merge(array('--run-pig-script', '--args', '-f', $script), $args); return self::hive_pig_script('pig', $args); }
php
public static function run_pig_script($script, $args = null) { if (!$args) $args = array(); $args = is_array($args) ? $args : array($args); $args = array_merge(array('--run-pig-script', '--args', '-f', $script), $args); return self::hive_pig_script('pig', $args); }
[ "public", "static", "function", "run_pig_script", "(", "$", "script", ",", "$", "args", "=", "null", ")", "{", "if", "(", "!", "$", "args", ")", "$", "args", "=", "array", "(", ")", ";", "$", "args", "=", "is_array", "(", "$", "args", ")", "?", "$", "args", ":", "array", "(", "$", "args", ")", ";", "$", "args", "=", "array_merge", "(", "array", "(", "'--run-pig-script'", ",", "'--args'", ",", "'-f'", ",", "$", "script", ")", ",", "$", "args", ")", ";", "return", "self", "::", "hive_pig_script", "(", "'pig'", ",", "$", "args", ")", ";", "}" ]
Step that runs a Pig script on your job flow. @param string $script (Required) The script to run with `script-runner.jar`. @param array $args (Optional) An indexed array of arguments to pass to the script. @return array A standard array that is intended to be passed into a <CFStepConfig> object. @link http://pig.apache.org Apache Pig
[ "Step", "that", "runs", "a", "Pig", "script", "on", "your", "job", "flow", "." ]
d43cce1a88f1c332f60dd0a4374b17764852af9e
https://github.com/Etenil/assegai/blob/d43cce1a88f1c332f60dd0a4374b17764852af9e/src/assegai/modules/mail/services/ses/utilities/hadoopstep.class.php#L90-L97
train
lrezek/Arachnid
src/LRezek/Arachnid/Meta/Reflection.php
Reflection.normalizeProperty
public static function normalizeProperty($property) { //Remove an underscore, so you can do get_date() if(substr($property,0,1) == '_') { $property = substr($property, 1); } $property = lcfirst($property); // //Deal with famil-'ies', make it 'family' // if ('ies' == substr($property, -3)) { // $property = substr($property, 0, -3) . 'y'; // } // // //Deal with 'friends', make it 'friend' // if (preg_match('/[^s]s$/', $property)) // { // $property = substr($property, 0, -1); // } return $property; }
php
public static function normalizeProperty($property) { //Remove an underscore, so you can do get_date() if(substr($property,0,1) == '_') { $property = substr($property, 1); } $property = lcfirst($property); // //Deal with famil-'ies', make it 'family' // if ('ies' == substr($property, -3)) { // $property = substr($property, 0, -3) . 'y'; // } // // //Deal with 'friends', make it 'friend' // if (preg_match('/[^s]s$/', $property)) // { // $property = substr($property, 0, -1); // } return $property; }
[ "public", "static", "function", "normalizeProperty", "(", "$", "property", ")", "{", "//Remove an underscore, so you can do get_date()", "if", "(", "substr", "(", "$", "property", ",", "0", ",", "1", ")", "==", "'_'", ")", "{", "$", "property", "=", "substr", "(", "$", "property", ",", "1", ")", ";", "}", "$", "property", "=", "lcfirst", "(", "$", "property", ")", ";", "// //Deal with famil-'ies', make it 'family'", "// if ('ies' == substr($property, -3)) {", "// $property = substr($property, 0, -3) . 'y';", "// }", "//", "// //Deal with 'friends', make it 'friend'", "// if (preg_match('/[^s]s$/', $property))", "// {", "// $property = substr($property, 0, -1);", "// }", "return", "$", "property", ";", "}" ]
Normalizes a property name, by making it lowercase and stripping off "ies" or "s" @param string $property Property name to sigularize. @return string Singularized property name.
[ "Normalizes", "a", "property", "name", "by", "making", "it", "lowercase", "and", "stripping", "off", "ies", "or", "s" ]
fbfc2c6f9d1dbfeef6f677813c12c570d5ea750a
https://github.com/lrezek/Arachnid/blob/fbfc2c6f9d1dbfeef6f677813c12c570d5ea750a/src/LRezek/Arachnid/Meta/Reflection.php#L38-L60
train
composer-synchronizer/composer-synchronizer
src/Helpers.php
Helpers.copy
public static function copy(string $source, string $dest, bool $override = false): void { if (is_file($source)) { self::copyFile($source, $dest, $override); return; } if ( ! is_dir($source)) { Helpers::consoleMessage("File or directory '%s' not found.", [$source]); return; } $sourceHandle = opendir($source); if ( ! $sourceHandle) { throw new SynchronizerException('Failed to copy directory: failed to open source ' . $source); } while ($file = readdir($sourceHandle)) { if (in_array($file, ['.', '..'], true)) { continue; } if (is_dir($source . '/' . $file)) { if ( ! file_exists($dest . '/' . $file)) { self::createDirectory($dest); } $file .= '/'; self::copy($source . $file, $dest . $file, $override); } else { $dest = rtrim($dest, '/') . '/'; $source = rtrim($source, '/') . '/'; self::copyFile($source . $file, $dest . $file, $override); } } }
php
public static function copy(string $source, string $dest, bool $override = false): void { if (is_file($source)) { self::copyFile($source, $dest, $override); return; } if ( ! is_dir($source)) { Helpers::consoleMessage("File or directory '%s' not found.", [$source]); return; } $sourceHandle = opendir($source); if ( ! $sourceHandle) { throw new SynchronizerException('Failed to copy directory: failed to open source ' . $source); } while ($file = readdir($sourceHandle)) { if (in_array($file, ['.', '..'], true)) { continue; } if (is_dir($source . '/' . $file)) { if ( ! file_exists($dest . '/' . $file)) { self::createDirectory($dest); } $file .= '/'; self::copy($source . $file, $dest . $file, $override); } else { $dest = rtrim($dest, '/') . '/'; $source = rtrim($source, '/') . '/'; self::copyFile($source . $file, $dest . $file, $override); } } }
[ "public", "static", "function", "copy", "(", "string", "$", "source", ",", "string", "$", "dest", ",", "bool", "$", "override", "=", "false", ")", ":", "void", "{", "if", "(", "is_file", "(", "$", "source", ")", ")", "{", "self", "::", "copyFile", "(", "$", "source", ",", "$", "dest", ",", "$", "override", ")", ";", "return", ";", "}", "if", "(", "!", "is_dir", "(", "$", "source", ")", ")", "{", "Helpers", "::", "consoleMessage", "(", "\"File or directory '%s' not found.\"", ",", "[", "$", "source", "]", ")", ";", "return", ";", "}", "$", "sourceHandle", "=", "opendir", "(", "$", "source", ")", ";", "if", "(", "!", "$", "sourceHandle", ")", "{", "throw", "new", "SynchronizerException", "(", "'Failed to copy directory: failed to open source '", ".", "$", "source", ")", ";", "}", "while", "(", "$", "file", "=", "readdir", "(", "$", "sourceHandle", ")", ")", "{", "if", "(", "in_array", "(", "$", "file", ",", "[", "'.'", ",", "'..'", "]", ",", "true", ")", ")", "{", "continue", ";", "}", "if", "(", "is_dir", "(", "$", "source", ".", "'/'", ".", "$", "file", ")", ")", "{", "if", "(", "!", "file_exists", "(", "$", "dest", ".", "'/'", ".", "$", "file", ")", ")", "{", "self", "::", "createDirectory", "(", "$", "dest", ")", ";", "}", "$", "file", ".=", "'/'", ";", "self", "::", "copy", "(", "$", "source", ".", "$", "file", ",", "$", "dest", ".", "$", "file", ",", "$", "override", ")", ";", "}", "else", "{", "$", "dest", "=", "rtrim", "(", "$", "dest", ",", "'/'", ")", ".", "'/'", ";", "$", "source", "=", "rtrim", "(", "$", "source", ",", "'/'", ")", ".", "'/'", ";", "self", "::", "copyFile", "(", "$", "source", ".", "$", "file", ",", "$", "dest", ".", "$", "file", ",", "$", "override", ")", ";", "}", "}", "}" ]
Copies files recursively and automatically creates nested directories
[ "Copies", "files", "recursively", "and", "automatically", "creates", "nested", "directories" ]
ca1c2f4dd05e0142148c030dba63b5081edb2bc3
https://github.com/composer-synchronizer/composer-synchronizer/blob/ca1c2f4dd05e0142148c030dba63b5081edb2bc3/src/Helpers.php#L78-L115
train
Dhii/output-renderer-abstract
src/CaptureOutputCapableTrait.php
CaptureOutputCapableTrait._captureOutput
protected function _captureOutput(callable $callable, $args = null) { // Default if (is_null($args)) { $args = []; } ob_start(); $this->_invokeCallable($callable, $args); $output = ob_get_clean(); return $output; }
php
protected function _captureOutput(callable $callable, $args = null) { // Default if (is_null($args)) { $args = []; } ob_start(); $this->_invokeCallable($callable, $args); $output = ob_get_clean(); return $output; }
[ "protected", "function", "_captureOutput", "(", "callable", "$", "callable", ",", "$", "args", "=", "null", ")", "{", "// Default", "if", "(", "is_null", "(", "$", "args", ")", ")", "{", "$", "args", "=", "[", "]", ";", "}", "ob_start", "(", ")", ";", "$", "this", "->", "_invokeCallable", "(", "$", "callable", ",", "$", "args", ")", ";", "$", "output", "=", "ob_get_clean", "(", ")", ";", "return", "$", "output", ";", "}" ]
Invokes the given callable, and returns the output as a string. @since [*next-version*] @param callable $callable The callable that may produce output. @param array|stdClass|Traversable|null $args The arguments to invoke the callable with. Defaults to empty array. @throws InvalidArgumentException If the callable or the args list are invalid. @throws RootException If a problem occurs. @return string The output.
[ "Invokes", "the", "given", "callable", "and", "returns", "the", "output", "as", "a", "string", "." ]
0f6e5eed940025332dd1986d6c771e10f7197b1a
https://github.com/Dhii/output-renderer-abstract/blob/0f6e5eed940025332dd1986d6c771e10f7197b1a/src/CaptureOutputCapableTrait.php#L32-L44
train
diasbruno/stc
lib/stc/DataValidator.php
DataValidator.walker
private function walker($keys, &$arr) { if (count($keys) == 0) { return true; } $current = array_shift($keys); return (is_array($arr) ? array_key_exists($current, $arr) : false) && ((is_array($arr[$current])) ? $this->walker($keys, $arr[$current]) : (count($keys) > 0 ? false : true)); }
php
private function walker($keys, &$arr) { if (count($keys) == 0) { return true; } $current = array_shift($keys); return (is_array($arr) ? array_key_exists($current, $arr) : false) && ((is_array($arr[$current])) ? $this->walker($keys, $arr[$current]) : (count($keys) > 0 ? false : true)); }
[ "private", "function", "walker", "(", "$", "keys", ",", "&", "$", "arr", ")", "{", "if", "(", "count", "(", "$", "keys", ")", "==", "0", ")", "{", "return", "true", ";", "}", "$", "current", "=", "array_shift", "(", "$", "keys", ")", ";", "return", "(", "is_array", "(", "$", "arr", ")", "?", "array_key_exists", "(", "$", "current", ",", "$", "arr", ")", ":", "false", ")", "&&", "(", "(", "is_array", "(", "$", "arr", "[", "$", "current", "]", ")", ")", "?", "$", "this", "->", "walker", "(", "$", "keys", ",", "$", "arr", "[", "$", "current", "]", ")", ":", "(", "count", "(", "$", "keys", ")", ">", "0", "?", "false", ":", "true", ")", ")", ";", "}" ]
Recursive walker to check. @param $keys array | List of keys. @param $arr array | A hash list to check. @return bool
[ "Recursive", "walker", "to", "check", "." ]
43f62c3b28167bff76274f954e235413a9e9c707
https://github.com/diasbruno/stc/blob/43f62c3b28167bff76274f954e235413a9e9c707/lib/stc/DataValidator.php#L33-L47
train
diasbruno/stc
lib/stc/DataValidator.php
DataValidator.validate
public function validate(&$arr) { if (count($this->list) == 0) { return true; } $ok = true; foreach ($this->list as $key => $value) { $list = explode('.', $value); $ok = $ok && $this->walker($list, $arr); } return $ok; }
php
public function validate(&$arr) { if (count($this->list) == 0) { return true; } $ok = true; foreach ($this->list as $key => $value) { $list = explode('.', $value); $ok = $ok && $this->walker($list, $arr); } return $ok; }
[ "public", "function", "validate", "(", "&", "$", "arr", ")", "{", "if", "(", "count", "(", "$", "this", "->", "list", ")", "==", "0", ")", "{", "return", "true", ";", "}", "$", "ok", "=", "true", ";", "foreach", "(", "$", "this", "->", "list", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "list", "=", "explode", "(", "'.'", ",", "$", "value", ")", ";", "$", "ok", "=", "$", "ok", "&&", "$", "this", "->", "walker", "(", "$", "list", ",", "$", "arr", ")", ";", "}", "return", "$", "ok", ";", "}" ]
Tries to validate a hash list. @param $arr array | The array to check. @return bool
[ "Tries", "to", "validate", "a", "hash", "list", "." ]
43f62c3b28167bff76274f954e235413a9e9c707
https://github.com/diasbruno/stc/blob/43f62c3b28167bff76274f954e235413a9e9c707/lib/stc/DataValidator.php#L54-L68
train
opis/events
src/EventDispatcher.php
EventDispatcher.handle
public function handle(string $event, callable $callback, int $priority = 0): Route { return $this->collection->createRoute($event, $callback)->set('priority', $priority); }
php
public function handle(string $event, callable $callback, int $priority = 0): Route { return $this->collection->createRoute($event, $callback)->set('priority', $priority); }
[ "public", "function", "handle", "(", "string", "$", "event", ",", "callable", "$", "callback", ",", "int", "$", "priority", "=", "0", ")", ":", "Route", "{", "return", "$", "this", "->", "collection", "->", "createRoute", "(", "$", "event", ",", "$", "callback", ")", "->", "set", "(", "'priority'", ",", "$", "priority", ")", ";", "}" ]
Handle an event @param string $event Event's name @param callable $callback Callback @param int $priority (optional) Event's priority @return Route
[ "Handle", "an", "event" ]
97f34bd0334975580ee915661c79880061c1bf1a
https://github.com/opis/events/blob/97f34bd0334975580ee915661c79880061c1bf1a/src/EventDispatcher.php#L54-L57
train
opis/events
src/EventDispatcher.php
EventDispatcher.emit
public function emit(string $name, bool $cancelable = false): Event { return $this->dispatch(new Event($name, $cancelable)); }
php
public function emit(string $name, bool $cancelable = false): Event { return $this->dispatch(new Event($name, $cancelable)); }
[ "public", "function", "emit", "(", "string", "$", "name", ",", "bool", "$", "cancelable", "=", "false", ")", ":", "Event", "{", "return", "$", "this", "->", "dispatch", "(", "new", "Event", "(", "$", "name", ",", "$", "cancelable", ")", ")", ";", "}" ]
Emits an event @param string $name Event's name @param boolean $cancelable (optional) Cancelable event @return Event
[ "Emits", "an", "event" ]
97f34bd0334975580ee915661c79880061c1bf1a
https://github.com/opis/events/blob/97f34bd0334975580ee915661c79880061c1bf1a/src/EventDispatcher.php#L67-L70
train
schpill/thin
src/Facebook.php
Facebook.getFacebookHelper
public function getFacebookHelper() { $redirectHelper = new FacebookRedirectLoginHelper( $this->getRedirectUrl(), $this->appId, $this->appSecret ); $redirectHelper->disableSessionStatusCheck(); return $redirectHelper; }
php
public function getFacebookHelper() { $redirectHelper = new FacebookRedirectLoginHelper( $this->getRedirectUrl(), $this->appId, $this->appSecret ); $redirectHelper->disableSessionStatusCheck(); return $redirectHelper; }
[ "public", "function", "getFacebookHelper", "(", ")", "{", "$", "redirectHelper", "=", "new", "FacebookRedirectLoginHelper", "(", "$", "this", "->", "getRedirectUrl", "(", ")", ",", "$", "this", "->", "appId", ",", "$", "this", "->", "appSecret", ")", ";", "$", "redirectHelper", "->", "disableSessionStatusCheck", "(", ")", ";", "return", "$", "redirectHelper", ";", "}" ]
Get Facebook Redirect Login Helper. @return FacebookRedirectLoginHelper
[ "Get", "Facebook", "Redirect", "Login", "Helper", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Facebook.php#L114-L125
train
schpill/thin
src/Facebook.php
Facebook.getLoginUrl
public function getLoginUrl($scope = array(), $version = null) { $scope = $this->getScope($scope); return $this->getFacebookHelper()->getLoginUrl($scope, $version); }
php
public function getLoginUrl($scope = array(), $version = null) { $scope = $this->getScope($scope); return $this->getFacebookHelper()->getLoginUrl($scope, $version); }
[ "public", "function", "getLoginUrl", "(", "$", "scope", "=", "array", "(", ")", ",", "$", "version", "=", "null", ")", "{", "$", "scope", "=", "$", "this", "->", "getScope", "(", "$", "scope", ")", ";", "return", "$", "this", "->", "getFacebookHelper", "(", ")", "->", "getLoginUrl", "(", "$", "scope", ",", "$", "version", ")", ";", "}" ]
Get Login Url. @param array $scope @param null $version @return string
[ "Get", "Login", "Url", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Facebook.php#L207-L212
train
schpill/thin
src/Facebook.php
Facebook.getCallback
public function getCallback() { $token = $this->getAccessToken(); if ( ! empty($token)) { $this->putSessionToken($token); return true; } return false; }
php
public function getCallback() { $token = $this->getAccessToken(); if ( ! empty($token)) { $this->putSessionToken($token); return true; } return false; }
[ "public", "function", "getCallback", "(", ")", "{", "$", "token", "=", "$", "this", "->", "getAccessToken", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "token", ")", ")", "{", "$", "this", "->", "putSessionToken", "(", "$", "token", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Get callback from facebook. @return boolean
[ "Get", "callback", "from", "facebook", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Facebook.php#L304-L314
train
schpill/thin
src/Facebook.php
Facebook.api
public function api($method, $path, $parameters = null, $version = null, $etag = null) { $session = new FacebookSession($this->getAccessToken()); $request = with(new FacebookRequest($session, $method, $path, $parameters, $version, $etag)) ->execute() ->getGraphObject(GraphUser::className()); return $request; }
php
public function api($method, $path, $parameters = null, $version = null, $etag = null) { $session = new FacebookSession($this->getAccessToken()); $request = with(new FacebookRequest($session, $method, $path, $parameters, $version, $etag)) ->execute() ->getGraphObject(GraphUser::className()); return $request; }
[ "public", "function", "api", "(", "$", "method", ",", "$", "path", ",", "$", "parameters", "=", "null", ",", "$", "version", "=", "null", ",", "$", "etag", "=", "null", ")", "{", "$", "session", "=", "new", "FacebookSession", "(", "$", "this", "->", "getAccessToken", "(", ")", ")", ";", "$", "request", "=", "with", "(", "new", "FacebookRequest", "(", "$", "session", ",", "$", "method", ",", "$", "path", ",", "$", "parameters", ",", "$", "version", ",", "$", "etag", ")", ")", "->", "execute", "(", ")", "->", "getGraphObject", "(", "GraphUser", "::", "className", "(", ")", ")", ";", "return", "$", "request", ";", "}" ]
Facebook API Call. @param string $method The request method. @param string $path The end points path. @param mixed $parameters Parameters. @param string $version The specified version of Api. @param mixed $etag @return mixed
[ "Facebook", "API", "Call", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Facebook.php#L357-L366
train
schpill/thin
src/Facebook.php
Facebook.get
public function get($path, $parameters = null, $version = null, $etag = null) { return $this->api('GET', $path, $parameters, $version, $etag); }
php
public function get($path, $parameters = null, $version = null, $etag = null) { return $this->api('GET', $path, $parameters, $version, $etag); }
[ "public", "function", "get", "(", "$", "path", ",", "$", "parameters", "=", "null", ",", "$", "version", "=", "null", ",", "$", "etag", "=", "null", ")", "{", "return", "$", "this", "->", "api", "(", "'GET'", ",", "$", "path", ",", "$", "parameters", ",", "$", "version", ",", "$", "etag", ")", ";", "}" ]
Facebook API Request with "GET" method. @param string $path @param string|null|mixed $parameters @param string|null|mixed $version @param string|null|mixed $etag @return mixed
[ "Facebook", "API", "Request", "with", "GET", "method", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Facebook.php#L377-L380
train
schpill/thin
src/Facebook.php
Facebook.post
public function post($path, $parameters = null, $version = null, $etag = null) { return $this->api('POST', $path, $parameters, $version, $etag); }
php
public function post($path, $parameters = null, $version = null, $etag = null) { return $this->api('POST', $path, $parameters, $version, $etag); }
[ "public", "function", "post", "(", "$", "path", ",", "$", "parameters", "=", "null", ",", "$", "version", "=", "null", ",", "$", "etag", "=", "null", ")", "{", "return", "$", "this", "->", "api", "(", "'POST'", ",", "$", "path", ",", "$", "parameters", ",", "$", "version", ",", "$", "etag", ")", ";", "}" ]
Facebook API Request with "POST" method. @param string $path @param string|null|mixed $parameters @param string|null|mixed $version @param string|null|mixed $etag @return mixed
[ "Facebook", "API", "Request", "with", "POST", "method", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Facebook.php#L391-L394
train
schpill/thin
src/Facebook.php
Facebook.delete
public function delete($path, $parameters = null, $version = null, $etag = null) { return $this->api('DELETE', $path, $parameters, $version, $etag); }
php
public function delete($path, $parameters = null, $version = null, $etag = null) { return $this->api('DELETE', $path, $parameters, $version, $etag); }
[ "public", "function", "delete", "(", "$", "path", ",", "$", "parameters", "=", "null", ",", "$", "version", "=", "null", ",", "$", "etag", "=", "null", ")", "{", "return", "$", "this", "->", "api", "(", "'DELETE'", ",", "$", "path", ",", "$", "parameters", ",", "$", "version", ",", "$", "etag", ")", ";", "}" ]
Facebook API Request with "DELETE" method. @param string $path @param string|null|mixed $parameters @param string|null|mixed $version @param string|null|mixed $etag @return mixed
[ "Facebook", "API", "Request", "with", "DELETE", "method", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Facebook.php#L405-L408
train
schpill/thin
src/Facebook.php
Facebook.put
public function put($path, $parameters = null, $version = null, $etag = null) { return $this->api('PUT', $path, $parameters, $version, $etag); }
php
public function put($path, $parameters = null, $version = null, $etag = null) { return $this->api('PUT', $path, $parameters, $version, $etag); }
[ "public", "function", "put", "(", "$", "path", ",", "$", "parameters", "=", "null", ",", "$", "version", "=", "null", ",", "$", "etag", "=", "null", ")", "{", "return", "$", "this", "->", "api", "(", "'PUT'", ",", "$", "path", ",", "$", "parameters", ",", "$", "version", ",", "$", "etag", ")", ";", "}" ]
Facebook API Request with "PUT" method. @param string $path @param string|null|mixed $parameters @param string|null|mixed $version @param string|null|mixed $etag @return mixed
[ "Facebook", "API", "Request", "with", "PUT", "method", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Facebook.php#L419-L422
train
schpill/thin
src/Facebook.php
Facebook.patch
public function patch($path, $parameters = null, $version = null, $etag = null) { return $this->api('PATCH', $path, $parameters, $version, $etag); }
php
public function patch($path, $parameters = null, $version = null, $etag = null) { return $this->api('PATCH', $path, $parameters, $version, $etag); }
[ "public", "function", "patch", "(", "$", "path", ",", "$", "parameters", "=", "null", ",", "$", "version", "=", "null", ",", "$", "etag", "=", "null", ")", "{", "return", "$", "this", "->", "api", "(", "'PATCH'", ",", "$", "path", ",", "$", "parameters", ",", "$", "version", ",", "$", "etag", ")", ";", "}" ]
Facebook API Request with "PATCH" method. @param string $path @param string|null|mixed $parameters @param string|null|mixed $version @param string|null|mixed $etag @return mixed
[ "Facebook", "API", "Request", "with", "PATCH", "method", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Facebook.php#L433-L436
train
schpill/thin
src/Facebook.php
Facebook.getProfile
public function getProfile($parameters = [], $version = null, $etag = null) { return $this->get('/me', $parameters, $version, $etag); }
php
public function getProfile($parameters = [], $version = null, $etag = null) { return $this->get('/me', $parameters, $version, $etag); }
[ "public", "function", "getProfile", "(", "$", "parameters", "=", "[", "]", ",", "$", "version", "=", "null", ",", "$", "etag", "=", "null", ")", "{", "return", "$", "this", "->", "get", "(", "'/me'", ",", "$", "parameters", ",", "$", "version", ",", "$", "etag", ")", ";", "}" ]
Get user profile. @param array $parameters @param null $version @param null $etag @return mixed
[ "Get", "user", "profile", "." ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Facebook.php#L446-L449
train
infusephp/auth
src/Libs/Strategy/TraditionalStrategy.php
TraditionalStrategy.verifyPassword
public function verifyPassword(UserInterface $user, $password) { if (!$password) { return false; } $hashedPassword = $user->getHashedPassword(); if (!$hashedPassword) { return false; } return password_verify($password, $hashedPassword); }
php
public function verifyPassword(UserInterface $user, $password) { if (!$password) { return false; } $hashedPassword = $user->getHashedPassword(); if (!$hashedPassword) { return false; } return password_verify($password, $hashedPassword); }
[ "public", "function", "verifyPassword", "(", "UserInterface", "$", "user", ",", "$", "password", ")", "{", "if", "(", "!", "$", "password", ")", "{", "return", "false", ";", "}", "$", "hashedPassword", "=", "$", "user", "->", "getHashedPassword", "(", ")", ";", "if", "(", "!", "$", "hashedPassword", ")", "{", "return", "false", ";", "}", "return", "password_verify", "(", "$", "password", ",", "$", "hashedPassword", ")", ";", "}" ]
Checks if a given password matches the user's password. @param UserInterface $user @param string $password @return bool
[ "Checks", "if", "a", "given", "password", "matches", "the", "user", "s", "password", "." ]
720280b4b2635572f331afe8d082e3e88cf54eb7
https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/Strategy/TraditionalStrategy.php#L142-L154
train
infusephp/auth
src/Libs/Strategy/TraditionalStrategy.php
TraditionalStrategy.getRateLimiter
function getRateLimiter() { if ($this->rateLimiter) { return $this->rateLimiter; } $app = $this->auth->getApp(); $class = $app['config']->get('auth.loginRateLimiter', NullRateLimiter::class); $this->rateLimiter = new $class(); if (method_exists($this->rateLimiter, 'setApp')) { $this->rateLimiter->setApp($app); } return $this->rateLimiter; }
php
function getRateLimiter() { if ($this->rateLimiter) { return $this->rateLimiter; } $app = $this->auth->getApp(); $class = $app['config']->get('auth.loginRateLimiter', NullRateLimiter::class); $this->rateLimiter = new $class(); if (method_exists($this->rateLimiter, 'setApp')) { $this->rateLimiter->setApp($app); } return $this->rateLimiter; }
[ "function", "getRateLimiter", "(", ")", "{", "if", "(", "$", "this", "->", "rateLimiter", ")", "{", "return", "$", "this", "->", "rateLimiter", ";", "}", "$", "app", "=", "$", "this", "->", "auth", "->", "getApp", "(", ")", ";", "$", "class", "=", "$", "app", "[", "'config'", "]", "->", "get", "(", "'auth.loginRateLimiter'", ",", "NullRateLimiter", "::", "class", ")", ";", "$", "this", "->", "rateLimiter", "=", "new", "$", "class", "(", ")", ";", "if", "(", "method_exists", "(", "$", "this", "->", "rateLimiter", ",", "'setApp'", ")", ")", "{", "$", "this", "->", "rateLimiter", "->", "setApp", "(", "$", "app", ")", ";", "}", "return", "$", "this", "->", "rateLimiter", ";", "}" ]
Gets the login rate limiter. @return \Infuse\Auth\Interfaces\LoginRateLimiterInterface
[ "Gets", "the", "login", "rate", "limiter", "." ]
720280b4b2635572f331afe8d082e3e88cf54eb7
https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/Strategy/TraditionalStrategy.php#L161-L176
train