id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
8,300
robertasproniu/tic-tac-toe-agent
src/Board.php
Board.isFull
public function isFull() { return (bool) (pow($this->size, 2) == count(array_filter(array_reduce($this->getBoard(), 'array_merge', [])))); }
php
public function isFull() { return (bool) (pow($this->size, 2) == count(array_filter(array_reduce($this->getBoard(), 'array_merge', [])))); }
[ "public", "function", "isFull", "(", ")", "{", "return", "(", "bool", ")", "(", "pow", "(", "$", "this", "->", "size", ",", "2", ")", "==", "count", "(", "array_filter", "(", "array_reduce", "(", "$", "this", "->", "getBoard", "(", ")", ",", "'array_merge'", ",", "[", "]", ")", ")", ")", ")", ";", "}" ]
Check if board is full @return bool
[ "Check", "if", "board", "is", "full" ]
00bc8e31e3c9770f2ee24d97d82e40dff20e3e98
https://github.com/robertasproniu/tic-tac-toe-agent/blob/00bc8e31e3c9770f2ee24d97d82e40dff20e3e98/src/Board.php#L126-L129
8,301
xloit/xloit-bridge-zend-filter
src/File/RenameUpload.php
RenameUpload.setEnableFileDispersion
public function setEnableFileDispersion($enableFileDispersion) { $this->enableFileDispersion = (bool) $enableFileDispersion; if ($enableFileDispersion) { $this->setAllowCreateFolders(true); $this->setTransliterateFilename(true); } return $this; }
php
public function setEnableFileDispersion($enableFileDispersion) { $this->enableFileDispersion = (bool) $enableFileDispersion; if ($enableFileDispersion) { $this->setAllowCreateFolders(true); $this->setTransliterateFilename(true); } return $this; }
[ "public", "function", "setEnableFileDispersion", "(", "$", "enableFileDispersion", ")", "{", "$", "this", "->", "enableFileDispersion", "=", "(", "bool", ")", "$", "enableFileDispersion", ";", "if", "(", "$", "enableFileDispersion", ")", "{", "$", "this", "->", "setAllowCreateFolders", "(", "true", ")", ";", "$", "this", "->", "setTransliterateFilename", "(", "true", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set enable files dispersion. @param bool $enableFileDispersion @return $this
[ "Set", "enable", "files", "dispersion", "." ]
2bce36194cd8636484f1b06ad13f33d953f477e0
https://github.com/xloit/xloit-bridge-zend-filter/blob/2bce36194cd8636484f1b06ad13f33d953f477e0/src/File/RenameUpload.php#L81-L91
8,302
xloit/xloit-bridge-zend-filter
src/File/RenameUpload.php
RenameUpload.createFolders
protected function createFolders() { $dir = null; $target = $this->getTargetDirectory(); /** @noinspection IsEmptyFunctionUsageInspection */ if (!empty($target)) { $dir = rtrim($target, '/') . DIRECTORY_SEPARATOR; $this->setTarget($dir); } if ($dir !== null && !is_dir($dir) && $this->isAllowCreateFolders()) { /** @noinspection NotOptimalIfConditionsInspection */ /** @noinspection PhpUsageOfSilenceOperatorInspection */ if (!@mkdir($dir, 0777, true) && !is_dir($dir)) { throw new Exception\NoSuchDirectoryException( sprintf('Directory %s does not exists.', $dir) ); } } }
php
protected function createFolders() { $dir = null; $target = $this->getTargetDirectory(); /** @noinspection IsEmptyFunctionUsageInspection */ if (!empty($target)) { $dir = rtrim($target, '/') . DIRECTORY_SEPARATOR; $this->setTarget($dir); } if ($dir !== null && !is_dir($dir) && $this->isAllowCreateFolders()) { /** @noinspection NotOptimalIfConditionsInspection */ /** @noinspection PhpUsageOfSilenceOperatorInspection */ if (!@mkdir($dir, 0777, true) && !is_dir($dir)) { throw new Exception\NoSuchDirectoryException( sprintf('Directory %s does not exists.', $dir) ); } } }
[ "protected", "function", "createFolders", "(", ")", "{", "$", "dir", "=", "null", ";", "$", "target", "=", "$", "this", "->", "getTargetDirectory", "(", ")", ";", "/** @noinspection IsEmptyFunctionUsageInspection */", "if", "(", "!", "empty", "(", "$", "target", ")", ")", "{", "$", "dir", "=", "rtrim", "(", "$", "target", ",", "'/'", ")", ".", "DIRECTORY_SEPARATOR", ";", "$", "this", "->", "setTarget", "(", "$", "dir", ")", ";", "}", "if", "(", "$", "dir", "!==", "null", "&&", "!", "is_dir", "(", "$", "dir", ")", "&&", "$", "this", "->", "isAllowCreateFolders", "(", ")", ")", "{", "/** @noinspection NotOptimalIfConditionsInspection */", "/** @noinspection PhpUsageOfSilenceOperatorInspection */", "if", "(", "!", "@", "mkdir", "(", "$", "dir", ",", "0777", ",", "true", ")", "&&", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "throw", "new", "Exception", "\\", "NoSuchDirectoryException", "(", "sprintf", "(", "'Directory %s does not exists.'", ",", "$", "dir", ")", ")", ";", "}", "}", "}" ]
Create destination folder on the fly. @return void @throws \Xloit\Bridge\Zend\Filter\Exception\NoSuchDirectoryException
[ "Create", "destination", "folder", "on", "the", "fly", "." ]
2bce36194cd8636484f1b06ad13f33d953f477e0
https://github.com/xloit/xloit-bridge-zend-filter/blob/2bce36194cd8636484f1b06ad13f33d953f477e0/src/File/RenameUpload.php#L128-L148
8,303
xloit/xloit-bridge-zend-filter
src/File/RenameUpload.php
RenameUpload.fixCaseInsensitiveFilename
protected function fixCaseInsensitiveFilename($finalTarget) { $targetFile = basename($finalTarget); if ($this->isCaseInsensitiveFilename()) { $finalTarget = str_replace( $targetFile, StringUtils::lower($targetFile), $finalTarget ); } return $finalTarget; }
php
protected function fixCaseInsensitiveFilename($finalTarget) { $targetFile = basename($finalTarget); if ($this->isCaseInsensitiveFilename()) { $finalTarget = str_replace( $targetFile, StringUtils::lower($targetFile), $finalTarget ); } return $finalTarget; }
[ "protected", "function", "fixCaseInsensitiveFilename", "(", "$", "finalTarget", ")", "{", "$", "targetFile", "=", "basename", "(", "$", "finalTarget", ")", ";", "if", "(", "$", "this", "->", "isCaseInsensitiveFilename", "(", ")", ")", "{", "$", "finalTarget", "=", "str_replace", "(", "$", "targetFile", ",", "StringUtils", "::", "lower", "(", "$", "targetFile", ")", ",", "$", "finalTarget", ")", ";", "}", "return", "$", "finalTarget", ";", "}" ]
Fix case-insensitive filename. @param string $finalTarget @return string
[ "Fix", "case", "-", "insensitive", "filename", "." ]
2bce36194cd8636484f1b06ad13f33d953f477e0
https://github.com/xloit/xloit-bridge-zend-filter/blob/2bce36194cd8636484f1b06ad13f33d953f477e0/src/File/RenameUpload.php#L205-L216
8,304
xloit/xloit-bridge-zend-filter
src/File/RenameUpload.php
RenameUpload.transliterateFilename
protected function transliterateFilename($finalTarget) { $targetFile = basename($finalTarget); if ($this->isTransliterateFilename()) { $filename = pathinfo($targetFile)['filename']; $finalTarget = str_replace( $filename, StringUtils::slug($filename), $finalTarget ); } return $finalTarget; }
php
protected function transliterateFilename($finalTarget) { $targetFile = basename($finalTarget); if ($this->isTransliterateFilename()) { $filename = pathinfo($targetFile)['filename']; $finalTarget = str_replace( $filename, StringUtils::slug($filename), $finalTarget ); } return $finalTarget; }
[ "protected", "function", "transliterateFilename", "(", "$", "finalTarget", ")", "{", "$", "targetFile", "=", "basename", "(", "$", "finalTarget", ")", ";", "if", "(", "$", "this", "->", "isTransliterateFilename", "(", ")", ")", "{", "$", "filename", "=", "pathinfo", "(", "$", "targetFile", ")", "[", "'filename'", "]", ";", "$", "finalTarget", "=", "str_replace", "(", "$", "filename", ",", "StringUtils", "::", "slug", "(", "$", "filename", ")", ",", "$", "finalTarget", ")", ";", "}", "return", "$", "finalTarget", ";", "}" ]
Transliterate filename. @param string $finalTarget @return string
[ "Transliterate", "filename", "." ]
2bce36194cd8636484f1b06ad13f33d953f477e0
https://github.com/xloit/xloit-bridge-zend-filter/blob/2bce36194cd8636484f1b06ad13f33d953f477e0/src/File/RenameUpload.php#L250-L261
8,305
xloit/xloit-bridge-zend-filter
src/File/RenameUpload.php
RenameUpload.fileDispersion
protected function fileDispersion($finalTarget) { if (strpos($finalTarget, DIRECTORY_SEPARATOR . 'original_image' . DIRECTORY_SEPARATOR) !== false) { return $finalTarget; } if ($this->isFileDispersionEnabled()) { $file = pathinfo($finalTarget, PATHINFO_BASENAME); $dispersionPath = $this->getDispersionPath($file); $directory = pathinfo($finalTarget, PATHINFO_DIRNAME) . $dispersionPath; $finalTarget = $directory . $file; $this->setTargetDirectory($directory); $this->createFolders(); } return $finalTarget; }
php
protected function fileDispersion($finalTarget) { if (strpos($finalTarget, DIRECTORY_SEPARATOR . 'original_image' . DIRECTORY_SEPARATOR) !== false) { return $finalTarget; } if ($this->isFileDispersionEnabled()) { $file = pathinfo($finalTarget, PATHINFO_BASENAME); $dispersionPath = $this->getDispersionPath($file); $directory = pathinfo($finalTarget, PATHINFO_DIRNAME) . $dispersionPath; $finalTarget = $directory . $file; $this->setTargetDirectory($directory); $this->createFolders(); } return $finalTarget; }
[ "protected", "function", "fileDispersion", "(", "$", "finalTarget", ")", "{", "if", "(", "strpos", "(", "$", "finalTarget", ",", "DIRECTORY_SEPARATOR", ".", "'original_image'", ".", "DIRECTORY_SEPARATOR", ")", "!==", "false", ")", "{", "return", "$", "finalTarget", ";", "}", "if", "(", "$", "this", "->", "isFileDispersionEnabled", "(", ")", ")", "{", "$", "file", "=", "pathinfo", "(", "$", "finalTarget", ",", "PATHINFO_BASENAME", ")", ";", "$", "dispersionPath", "=", "$", "this", "->", "getDispersionPath", "(", "$", "file", ")", ";", "$", "directory", "=", "pathinfo", "(", "$", "finalTarget", ",", "PATHINFO_DIRNAME", ")", ".", "$", "dispersionPath", ";", "$", "finalTarget", "=", "$", "directory", ".", "$", "file", ";", "$", "this", "->", "setTargetDirectory", "(", "$", "directory", ")", ";", "$", "this", "->", "createFolders", "(", ")", ";", "}", "return", "$", "finalTarget", ";", "}" ]
Process file dispersion. @param string $finalTarget @return string @throws \Xloit\Bridge\Zend\Filter\Exception\NoSuchDirectoryException
[ "Process", "file", "dispersion", "." ]
2bce36194cd8636484f1b06ad13f33d953f477e0
https://github.com/xloit/xloit-bridge-zend-filter/blob/2bce36194cd8636484f1b06ad13f33d953f477e0/src/File/RenameUpload.php#L299-L315
8,306
xloit/xloit-bridge-zend-filter
src/File/RenameUpload.php
RenameUpload.getDispersionPath
private function getDispersionPath($fileName) { $char = 0; $dispersionPath = DIRECTORY_SEPARATOR . 'original_image' . DIRECTORY_SEPARATOR; while ($char < 2 && $char < strlen($fileName)) { /** @noinspection IsEmptyFunctionUsageInspection */ if (empty($dispersionPath)) { $dispersionPath = DIRECTORY_SEPARATOR . ('.' === $fileName[$char] ? '_' : $fileName[$char]); } else { $dispersionPath = $this->addDirectorySeparator($dispersionPath) . ('.' === $fileName[$char] ? '_' : $fileName[$char]); } $char++; } return $dispersionPath . DIRECTORY_SEPARATOR; }
php
private function getDispersionPath($fileName) { $char = 0; $dispersionPath = DIRECTORY_SEPARATOR . 'original_image' . DIRECTORY_SEPARATOR; while ($char < 2 && $char < strlen($fileName)) { /** @noinspection IsEmptyFunctionUsageInspection */ if (empty($dispersionPath)) { $dispersionPath = DIRECTORY_SEPARATOR . ('.' === $fileName[$char] ? '_' : $fileName[$char]); } else { $dispersionPath = $this->addDirectorySeparator($dispersionPath) . ('.' === $fileName[$char] ? '_' : $fileName[$char]); } $char++; } return $dispersionPath . DIRECTORY_SEPARATOR; }
[ "private", "function", "getDispersionPath", "(", "$", "fileName", ")", "{", "$", "char", "=", "0", ";", "$", "dispersionPath", "=", "DIRECTORY_SEPARATOR", ".", "'original_image'", ".", "DIRECTORY_SEPARATOR", ";", "while", "(", "$", "char", "<", "2", "&&", "$", "char", "<", "strlen", "(", "$", "fileName", ")", ")", "{", "/** @noinspection IsEmptyFunctionUsageInspection */", "if", "(", "empty", "(", "$", "dispersionPath", ")", ")", "{", "$", "dispersionPath", "=", "DIRECTORY_SEPARATOR", ".", "(", "'.'", "===", "$", "fileName", "[", "$", "char", "]", "?", "'_'", ":", "$", "fileName", "[", "$", "char", "]", ")", ";", "}", "else", "{", "$", "dispersionPath", "=", "$", "this", "->", "addDirectorySeparator", "(", "$", "dispersionPath", ")", ".", "(", "'.'", "===", "$", "fileName", "[", "$", "char", "]", "?", "'_'", ":", "$", "fileName", "[", "$", "char", "]", ")", ";", "}", "$", "char", "++", ";", "}", "return", "$", "dispersionPath", ".", "DIRECTORY_SEPARATOR", ";", "}" ]
Get dispersion path. @param string $fileName @return string
[ "Get", "dispersion", "path", "." ]
2bce36194cd8636484f1b06ad13f33d953f477e0
https://github.com/xloit/xloit-bridge-zend-filter/blob/2bce36194cd8636484f1b06ad13f33d953f477e0/src/File/RenameUpload.php#L334-L352
8,307
tlumx/tlumx-router
src/Result.php
Result.createSuccess
public static function createSuccess( string $routeName, array $routeParams = [], array $routeAllowedMethods = [], array $routeMiddlewares = [], array $routeHandler = [] ):self { $result = new self(); $result->routeName = $routeName; $result->routeParams = $routeParams; $result->routeAllowedMethods = $routeAllowedMethods; $result->routeMiddlewares = $routeMiddlewares; $result->routeHandler = $routeHandler; $result->status = $result::ROUTE_FOUND; return $result; }
php
public static function createSuccess( string $routeName, array $routeParams = [], array $routeAllowedMethods = [], array $routeMiddlewares = [], array $routeHandler = [] ):self { $result = new self(); $result->routeName = $routeName; $result->routeParams = $routeParams; $result->routeAllowedMethods = $routeAllowedMethods; $result->routeMiddlewares = $routeMiddlewares; $result->routeHandler = $routeHandler; $result->status = $result::ROUTE_FOUND; return $result; }
[ "public", "static", "function", "createSuccess", "(", "string", "$", "routeName", ",", "array", "$", "routeParams", "=", "[", "]", ",", "array", "$", "routeAllowedMethods", "=", "[", "]", ",", "array", "$", "routeMiddlewares", "=", "[", "]", ",", "array", "$", "routeHandler", "=", "[", "]", ")", ":", "self", "{", "$", "result", "=", "new", "self", "(", ")", ";", "$", "result", "->", "routeName", "=", "$", "routeName", ";", "$", "result", "->", "routeParams", "=", "$", "routeParams", ";", "$", "result", "->", "routeAllowedMethods", "=", "$", "routeAllowedMethods", ";", "$", "result", "->", "routeMiddlewares", "=", "$", "routeMiddlewares", ";", "$", "result", "->", "routeHandler", "=", "$", "routeHandler", ";", "$", "result", "->", "status", "=", "$", "result", "::", "ROUTE_FOUND", ";", "return", "$", "result", ";", "}" ]
Create an instance if matching was success @param string $routeName @param array $routeParams @param array $routeAllowedMethods @param array $routeMiddlewares @param array $routeHandler @return self
[ "Create", "an", "instance", "if", "matching", "was", "success" ]
bf0c2a1e217198fe5d804298ffa423c4d9b72a9f
https://github.com/tlumx/tlumx-router/blob/bf0c2a1e217198fe5d804298ffa423c4d9b72a9f/src/Result.php#L83-L98
8,308
tlumx/tlumx-router
src/Result.php
Result.createMethodNotAllowed
public static function createMethodNotAllowed(array $routeAllowedMethods):self { $result = new self(); $result->routeAllowedMethods = $routeAllowedMethods; $result->status = $result::ROUTE_METHOD_NOT_ALLOWED; return $result; }
php
public static function createMethodNotAllowed(array $routeAllowedMethods):self { $result = new self(); $result->routeAllowedMethods = $routeAllowedMethods; $result->status = $result::ROUTE_METHOD_NOT_ALLOWED; return $result; }
[ "public", "static", "function", "createMethodNotAllowed", "(", "array", "$", "routeAllowedMethods", ")", ":", "self", "{", "$", "result", "=", "new", "self", "(", ")", ";", "$", "result", "->", "routeAllowedMethods", "=", "$", "routeAllowedMethods", ";", "$", "result", "->", "status", "=", "$", "result", "::", "ROUTE_METHOD_NOT_ALLOWED", ";", "return", "$", "result", ";", "}" ]
Create an instance if method not allowed @param array $routeAllowedMethods @return self
[ "Create", "an", "instance", "if", "method", "not", "allowed" ]
bf0c2a1e217198fe5d804298ffa423c4d9b72a9f
https://github.com/tlumx/tlumx-router/blob/bf0c2a1e217198fe5d804298ffa423c4d9b72a9f/src/Result.php#L118-L124
8,309
open-orchestra/open-orchestra-bbcode-bundle
BBcodeBundle/Definition/BBcodeDefinition.php
BBcodeDefinition.getPreviewHtml
public function getPreviewHtml(BBcodeElementNodeInterface $el) { if (!$this->hasValidInputs($el)) { return $el->getAsBBCode(); } $html = $this->getReplacementText(); if ($this->usesOption()) { $options = $el->getAttribute(); if (count($options) == 1) { $vals = array_values($options); $html = str_ireplace('{option}', reset($vals), $html); } else { foreach ($options as $key => $val) { $html = str_ireplace('{' . $key . '}', $val, $html); } } } $content = $this->getPreviewContent($el); $html = str_ireplace('{param}', $content, $html); return $html; }
php
public function getPreviewHtml(BBcodeElementNodeInterface $el) { if (!$this->hasValidInputs($el)) { return $el->getAsBBCode(); } $html = $this->getReplacementText(); if ($this->usesOption()) { $options = $el->getAttribute(); if (count($options) == 1) { $vals = array_values($options); $html = str_ireplace('{option}', reset($vals), $html); } else { foreach ($options as $key => $val) { $html = str_ireplace('{' . $key . '}', $val, $html); } } } $content = $this->getPreviewContent($el); $html = str_ireplace('{param}', $content, $html); return $html; }
[ "public", "function", "getPreviewHtml", "(", "BBcodeElementNodeInterface", "$", "el", ")", "{", "if", "(", "!", "$", "this", "->", "hasValidInputs", "(", "$", "el", ")", ")", "{", "return", "$", "el", "->", "getAsBBCode", "(", ")", ";", "}", "$", "html", "=", "$", "this", "->", "getReplacementText", "(", ")", ";", "if", "(", "$", "this", "->", "usesOption", "(", ")", ")", "{", "$", "options", "=", "$", "el", "->", "getAttribute", "(", ")", ";", "if", "(", "count", "(", "$", "options", ")", "==", "1", ")", "{", "$", "vals", "=", "array_values", "(", "$", "options", ")", ";", "$", "html", "=", "str_ireplace", "(", "'{option}'", ",", "reset", "(", "$", "vals", ")", ",", "$", "html", ")", ";", "}", "else", "{", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "html", "=", "str_ireplace", "(", "'{'", ".", "$", "key", ".", "'}'", ",", "$", "val", ",", "$", "html", ")", ";", "}", "}", "}", "$", "content", "=", "$", "this", "->", "getPreviewContent", "(", "$", "el", ")", ";", "$", "html", "=", "str_ireplace", "(", "'{param}'", ",", "$", "content", ",", "$", "html", ")", ";", "return", "$", "html", ";", "}" ]
Get the html representation of the node, in a preview context @param BBcodeElementNode $el @return string
[ "Get", "the", "html", "representation", "of", "the", "node", "in", "a", "preview", "context" ]
4c3ccd668c9b6d2f5c0c8bac384da0c2cd08ad54
https://github.com/open-orchestra/open-orchestra-bbcode-bundle/blob/4c3ccd668c9b6d2f5c0c8bac384da0c2cd08ad54/BBcodeBundle/Definition/BBcodeDefinition.php#L58-L82
8,310
liftkit/database
src/Connection/Connection.php
Connection.query
public function query ($query, $data = array(), $entity = null) { if ($this->cache->isCached($query)) { return $this->cache->getCachedResult($query); } else { try { $statement = $this->database->prepare((string) $query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL)); $result = $statement->execute($data); $this->lastQuery = $statement->queryString; $this->lastStatement = $statement; if (! $result) { throw new DatabaseException(implode(': ', $statement->errorInfo()) . PHP_EOL . PHP_EOL . $query); } } catch (PDOException $e) { throw new DatabaseException($e->getMessage() . PHP_EOL . PHP_EOL . $query); } $databaseResult = $this->createResult($statement, $entity); if ($query instanceof DatabaseQuery && $databaseResult instanceof DatabaseResult) { $this->cache->cacheQuery($query, $databaseResult); } if ($query instanceof DatabaseQuery) { $this->cache->refreshCache($query); } if ($databaseResult instanceof DatabaseResult) { return $databaseResult; } else if ($query instanceof DatabaseQuery && $query->getType() == DatabaseQuery::QUERY_TYPE_INSERT) { return $this->insertId($query->getTable()); } else { return $databaseResult; } } }
php
public function query ($query, $data = array(), $entity = null) { if ($this->cache->isCached($query)) { return $this->cache->getCachedResult($query); } else { try { $statement = $this->database->prepare((string) $query, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL)); $result = $statement->execute($data); $this->lastQuery = $statement->queryString; $this->lastStatement = $statement; if (! $result) { throw new DatabaseException(implode(': ', $statement->errorInfo()) . PHP_EOL . PHP_EOL . $query); } } catch (PDOException $e) { throw new DatabaseException($e->getMessage() . PHP_EOL . PHP_EOL . $query); } $databaseResult = $this->createResult($statement, $entity); if ($query instanceof DatabaseQuery && $databaseResult instanceof DatabaseResult) { $this->cache->cacheQuery($query, $databaseResult); } if ($query instanceof DatabaseQuery) { $this->cache->refreshCache($query); } if ($databaseResult instanceof DatabaseResult) { return $databaseResult; } else if ($query instanceof DatabaseQuery && $query->getType() == DatabaseQuery::QUERY_TYPE_INSERT) { return $this->insertId($query->getTable()); } else { return $databaseResult; } } }
[ "public", "function", "query", "(", "$", "query", ",", "$", "data", "=", "array", "(", ")", ",", "$", "entity", "=", "null", ")", "{", "if", "(", "$", "this", "->", "cache", "->", "isCached", "(", "$", "query", ")", ")", "{", "return", "$", "this", "->", "cache", "->", "getCachedResult", "(", "$", "query", ")", ";", "}", "else", "{", "try", "{", "$", "statement", "=", "$", "this", "->", "database", "->", "prepare", "(", "(", "string", ")", "$", "query", ",", "array", "(", "PDO", "::", "ATTR_CURSOR", "=>", "PDO", "::", "CURSOR_SCROLL", ")", ")", ";", "$", "result", "=", "$", "statement", "->", "execute", "(", "$", "data", ")", ";", "$", "this", "->", "lastQuery", "=", "$", "statement", "->", "queryString", ";", "$", "this", "->", "lastStatement", "=", "$", "statement", ";", "if", "(", "!", "$", "result", ")", "{", "throw", "new", "DatabaseException", "(", "implode", "(", "': '", ",", "$", "statement", "->", "errorInfo", "(", ")", ")", ".", "PHP_EOL", ".", "PHP_EOL", ".", "$", "query", ")", ";", "}", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "throw", "new", "DatabaseException", "(", "$", "e", "->", "getMessage", "(", ")", ".", "PHP_EOL", ".", "PHP_EOL", ".", "$", "query", ")", ";", "}", "$", "databaseResult", "=", "$", "this", "->", "createResult", "(", "$", "statement", ",", "$", "entity", ")", ";", "if", "(", "$", "query", "instanceof", "DatabaseQuery", "&&", "$", "databaseResult", "instanceof", "DatabaseResult", ")", "{", "$", "this", "->", "cache", "->", "cacheQuery", "(", "$", "query", ",", "$", "databaseResult", ")", ";", "}", "if", "(", "$", "query", "instanceof", "DatabaseQuery", ")", "{", "$", "this", "->", "cache", "->", "refreshCache", "(", "$", "query", ")", ";", "}", "if", "(", "$", "databaseResult", "instanceof", "DatabaseResult", ")", "{", "return", "$", "databaseResult", ";", "}", "else", "if", "(", "$", "query", "instanceof", "DatabaseQuery", "&&", "$", "query", "->", "getType", "(", ")", "==", "DatabaseQuery", "::", "QUERY_TYPE_INSERT", ")", "{", "return", "$", "this", "->", "insertId", "(", "$", "query", "->", "getTable", "(", ")", ")", ";", "}", "else", "{", "return", "$", "databaseResult", ";", "}", "}", "}" ]
query function. @access public @todo implement cache @param string $query @param array $data (default: array()) @param string|callable $entity (default: null) @return DatabaseResult
[ "query", "function", "." ]
752099ef8c71be0c187c9d6eea172b9afd723629
https://github.com/liftkit/database/blob/752099ef8c71be0c187c9d6eea172b9afd723629/src/Connection/Connection.php#L104-L143
8,311
liftkit/database
src/Connection/Connection.php
Connection.quote
public function quote ($string) { if (is_null($string)) { return 'NULL'; } else if (is_int($string) || is_float($string)) { return $string; } else if ($string instanceof Raw || $string instanceof DatabaseQuery) { return (string) $string; } else { return $this->database->quote($string); } }
php
public function quote ($string) { if (is_null($string)) { return 'NULL'; } else if (is_int($string) || is_float($string)) { return $string; } else if ($string instanceof Raw || $string instanceof DatabaseQuery) { return (string) $string; } else { return $this->database->quote($string); } }
[ "public", "function", "quote", "(", "$", "string", ")", "{", "if", "(", "is_null", "(", "$", "string", ")", ")", "{", "return", "'NULL'", ";", "}", "else", "if", "(", "is_int", "(", "$", "string", ")", "||", "is_float", "(", "$", "string", ")", ")", "{", "return", "$", "string", ";", "}", "else", "if", "(", "$", "string", "instanceof", "Raw", "||", "$", "string", "instanceof", "DatabaseQuery", ")", "{", "return", "(", "string", ")", "$", "string", ";", "}", "else", "{", "return", "$", "this", "->", "database", "->", "quote", "(", "$", "string", ")", ";", "}", "}" ]
quote function. @access public riptq @param mixed $string @return string
[ "quote", "function", "." ]
752099ef8c71be0c187c9d6eea172b9afd723629
https://github.com/liftkit/database/blob/752099ef8c71be0c187c9d6eea172b9afd723629/src/Connection/Connection.php#L222-L236
8,312
liftkit/database
src/Connection/Connection.php
Connection.insertId
public function insertId ($name = null) { if ($name === null) { return $this->database->lastInsertId(); } else { return $this->database->lastInsertId($name); } }
php
public function insertId ($name = null) { if ($name === null) { return $this->database->lastInsertId(); } else { return $this->database->lastInsertId($name); } }
[ "public", "function", "insertId", "(", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "return", "$", "this", "->", "database", "->", "lastInsertId", "(", ")", ";", "}", "else", "{", "return", "$", "this", "->", "database", "->", "lastInsertId", "(", "$", "name", ")", ";", "}", "}" ]
lastId function. @access public @return int
[ "lastId", "function", "." ]
752099ef8c71be0c187c9d6eea172b9afd723629
https://github.com/liftkit/database/blob/752099ef8c71be0c187c9d6eea172b9afd723629/src/Connection/Connection.php#L245-L252
8,313
heyday/heystack-ecommerce-core
src/Transaction/Transaction.php
Transaction.saveState
public function saveState() { $this->stateService->setByKey( self::IDENTIFIER, [ $this->total, $this->status, $this->updateRequested ] ); }
php
public function saveState() { $this->stateService->setByKey( self::IDENTIFIER, [ $this->total, $this->status, $this->updateRequested ] ); }
[ "public", "function", "saveState", "(", ")", "{", "$", "this", "->", "stateService", "->", "setByKey", "(", "self", "::", "IDENTIFIER", ",", "[", "$", "this", "->", "total", ",", "$", "this", "->", "status", ",", "$", "this", "->", "updateRequested", "]", ")", ";", "}" ]
Saves the state of the Transaction object @return void
[ "Saves", "the", "state", "of", "the", "Transaction", "object" ]
b56c83839cd3396da6bc881d843fcb4f28b74685
https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Transaction/Transaction.php#L96-L106
8,314
heyday/heystack-ecommerce-core
src/Transaction/Transaction.php
Transaction.restoreState
public function restoreState() { if ($data = $this->stateService->getByKey(self::IDENTIFIER)) { list($this->total, $this->status, $this->updateRequested) = $data; } }
php
public function restoreState() { if ($data = $this->stateService->getByKey(self::IDENTIFIER)) { list($this->total, $this->status, $this->updateRequested) = $data; } }
[ "public", "function", "restoreState", "(", ")", "{", "if", "(", "$", "data", "=", "$", "this", "->", "stateService", "->", "getByKey", "(", "self", "::", "IDENTIFIER", ")", ")", "{", "list", "(", "$", "this", "->", "total", ",", "$", "this", "->", "status", ",", "$", "this", "->", "updateRequested", ")", "=", "$", "data", ";", "}", "}" ]
Restores the state of the Transaction object @return void
[ "Restores", "the", "state", "of", "the", "Transaction", "object" ]
b56c83839cd3396da6bc881d843fcb4f28b74685
https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Transaction/Transaction.php#L112-L117
8,315
heyday/heystack-ecommerce-core
src/Transaction/Transaction.php
Transaction.addModifier
public function addModifier(TransactionModifierInterface $modifier) { $this->modifiers[$modifier->getIdentifier()->getFull()] = $modifier; if ($modifier instanceof HasTransactionInterface) { $modifier->setTransaction($this); } }
php
public function addModifier(TransactionModifierInterface $modifier) { $this->modifiers[$modifier->getIdentifier()->getFull()] = $modifier; if ($modifier instanceof HasTransactionInterface) { $modifier->setTransaction($this); } }
[ "public", "function", "addModifier", "(", "TransactionModifierInterface", "$", "modifier", ")", "{", "$", "this", "->", "modifiers", "[", "$", "modifier", "->", "getIdentifier", "(", ")", "->", "getFull", "(", ")", "]", "=", "$", "modifier", ";", "if", "(", "$", "modifier", "instanceof", "HasTransactionInterface", ")", "{", "$", "modifier", "->", "setTransaction", "(", "$", "this", ")", ";", "}", "}" ]
Add a TransactionModifier to the Transaction @param \Heystack\Ecommerce\Transaction\Interfaces\TransactionModifierInterface $modifier @throws \InvalidArgumentException @return void
[ "Add", "a", "TransactionModifier", "to", "the", "Transaction" ]
b56c83839cd3396da6bc881d843fcb4f28b74685
https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Transaction/Transaction.php#L125-L132
8,316
heyday/heystack-ecommerce-core
src/Transaction/Transaction.php
Transaction.getModifier
public function getModifier($identifier) { $modifiers = $this->getModifiers(); return isset($modifiers[$identifier]) ? $modifiers[$identifier] : null; }
php
public function getModifier($identifier) { $modifiers = $this->getModifiers(); return isset($modifiers[$identifier]) ? $modifiers[$identifier] : null; }
[ "public", "function", "getModifier", "(", "$", "identifier", ")", "{", "$", "modifiers", "=", "$", "this", "->", "getModifiers", "(", ")", ";", "return", "isset", "(", "$", "modifiers", "[", "$", "identifier", "]", ")", "?", "$", "modifiers", "[", "$", "identifier", "]", ":", "null", ";", "}" ]
Returns a TransactionModifier based on the identifier @param string $identifier @return \Heystack\Ecommerce\Transaction\Interfaces\TransactionModifierInterface|null
[ "Returns", "a", "TransactionModifier", "based", "on", "the", "identifier" ]
b56c83839cd3396da6bc881d843fcb4f28b74685
https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Transaction/Transaction.php#L139-L143
8,317
heyday/heystack-ecommerce-core
src/Transaction/Transaction.php
Transaction.getModifiersByType
public function getModifiersByType($type) { $modifiers = []; foreach ($this->modifiers as $modifier) { if ($modifier->getType() === $type) { $modifiers[$modifier->getIdentifier()->getFull()] = $modifier; } } return $modifiers; }
php
public function getModifiersByType($type) { $modifiers = []; foreach ($this->modifiers as $modifier) { if ($modifier->getType() === $type) { $modifiers[$modifier->getIdentifier()->getFull()] = $modifier; } } return $modifiers; }
[ "public", "function", "getModifiersByType", "(", "$", "type", ")", "{", "$", "modifiers", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "modifiers", "as", "$", "modifier", ")", "{", "if", "(", "$", "modifier", "->", "getType", "(", ")", "===", "$", "type", ")", "{", "$", "modifiers", "[", "$", "modifier", "->", "getIdentifier", "(", ")", "->", "getFull", "(", ")", "]", "=", "$", "modifier", ";", "}", "}", "return", "$", "modifiers", ";", "}" ]
Returns modifiers on the transaction by TranactionModifierType @param string $type @throws \InvalidArgumentException @return \Heystack\Ecommerce\Transaction\Interfaces\TransactionModifierInterface[]
[ "Returns", "modifiers", "on", "the", "transaction", "by", "TranactionModifierType" ]
b56c83839cd3396da6bc881d843fcb4f28b74685
https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Transaction/Transaction.php#L160-L171
8,318
heyday/heystack-ecommerce-core
src/Transaction/Transaction.php
Transaction.getTotal
public function getTotal() { if ($this->updateRequested) { $this->total = $this->getTotalWithExclusions([]); $this->updateRequested = false; $this->saveState(); } return $this->total; }
php
public function getTotal() { if ($this->updateRequested) { $this->total = $this->getTotalWithExclusions([]); $this->updateRequested = false; $this->saveState(); } return $this->total; }
[ "public", "function", "getTotal", "(", ")", "{", "if", "(", "$", "this", "->", "updateRequested", ")", "{", "$", "this", "->", "total", "=", "$", "this", "->", "getTotalWithExclusions", "(", "[", "]", ")", ";", "$", "this", "->", "updateRequested", "=", "false", ";", "$", "this", "->", "saveState", "(", ")", ";", "}", "return", "$", "this", "->", "total", ";", "}" ]
Returns the aggregate total of the TransactionModifers held by the Transaction object @return \SebastianBergmann\Money\Money
[ "Returns", "the", "aggregate", "total", "of", "the", "TransactionModifers", "held", "by", "the", "Transaction", "object" ]
b56c83839cd3396da6bc881d843fcb4f28b74685
https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Transaction/Transaction.php#L201-L210
8,319
heyday/heystack-ecommerce-core
src/Transaction/Transaction.php
Transaction.getStorableData
public function getStorableData() { return [ 'id' => 'Transaction', 'flat' => [ 'Total' => \Heystack\Ecommerce\convertMoneyToString($this->total), 'Status' => $this->status, 'Currency' => $this->currencyService->getActiveCurrencyCode() ], 'related' => [] ]; }
php
public function getStorableData() { return [ 'id' => 'Transaction', 'flat' => [ 'Total' => \Heystack\Ecommerce\convertMoneyToString($this->total), 'Status' => $this->status, 'Currency' => $this->currencyService->getActiveCurrencyCode() ], 'related' => [] ]; }
[ "public", "function", "getStorableData", "(", ")", "{", "return", "[", "'id'", "=>", "'Transaction'", ",", "'flat'", "=>", "[", "'Total'", "=>", "\\", "Heystack", "\\", "Ecommerce", "\\", "convertMoneyToString", "(", "$", "this", "->", "total", ")", ",", "'Status'", "=>", "$", "this", "->", "status", ",", "'Currency'", "=>", "$", "this", "->", "currencyService", "->", "getActiveCurrencyCode", "(", ")", "]", ",", "'related'", "=>", "[", "]", "]", ";", "}" ]
Get the data to store @return array The data to store
[ "Get", "the", "data", "to", "store" ]
b56c83839cd3396da6bc881d843fcb4f28b74685
https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Transaction/Transaction.php#L337-L349
8,320
heyday/heystack-ecommerce-core
src/Transaction/Transaction.php
Transaction.setStatus
public function setStatus($status) { if ($this->isValidStatus($status)) { $this->status = $status; $this->saveState(); } else { throw new \InvalidArgumentException( sprintf("Status '%s' is not a valid status", $status) ); } }
php
public function setStatus($status) { if ($this->isValidStatus($status)) { $this->status = $status; $this->saveState(); } else { throw new \InvalidArgumentException( sprintf("Status '%s' is not a valid status", $status) ); } }
[ "public", "function", "setStatus", "(", "$", "status", ")", "{", "if", "(", "$", "this", "->", "isValidStatus", "(", "$", "status", ")", ")", "{", "$", "this", "->", "status", "=", "$", "status", ";", "$", "this", "->", "saveState", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"Status '%s' is not a valid status\"", ",", "$", "status", ")", ")", ";", "}", "}" ]
Sets the status of the transaction @param string $status the status of the transaction @throws \InvalidArgumentException @return void
[ "Sets", "the", "status", "of", "the", "transaction" ]
b56c83839cd3396da6bc881d843fcb4f28b74685
https://github.com/heyday/heystack-ecommerce-core/blob/b56c83839cd3396da6bc881d843fcb4f28b74685/src/Transaction/Transaction.php#L368-L378
8,321
yii2module/yii2-tool
src/console/controllers/OpenServerController.php
OpenServerController.actionUpdate
public function actionUpdate() { $collection = \App::$domain->tool->openServer->update(); $hosts = ArrayHelper::getColumn($collection, 'host'); Output::items($hosts, count($collection) . ' hosts'); Output::line(); }
php
public function actionUpdate() { $collection = \App::$domain->tool->openServer->update(); $hosts = ArrayHelper::getColumn($collection, 'host'); Output::items($hosts, count($collection) . ' hosts'); Output::line(); }
[ "public", "function", "actionUpdate", "(", ")", "{", "$", "collection", "=", "\\", "App", "::", "$", "domain", "->", "tool", "->", "openServer", "->", "update", "(", ")", ";", "$", "hosts", "=", "ArrayHelper", "::", "getColumn", "(", "$", "collection", ",", "'host'", ")", ";", "Output", "::", "items", "(", "$", "hosts", ",", "count", "(", "$", "collection", ")", ".", "' hosts'", ")", ";", "Output", "::", "line", "(", ")", ";", "}" ]
Update domains config
[ "Update", "domains", "config" ]
c2efd7bc8550590f0afbf44ae66243f462766593
https://github.com/yii2module/yii2-tool/blob/c2efd7bc8550590f0afbf44ae66243f462766593/src/console/controllers/OpenServerController.php#L19-L25
8,322
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Compress/Bz2.php
Bz2.setBlocksize
public function setBlocksize($blocksize) { if (($blocksize < 0) || ($blocksize > 9)) { throw new Exception\InvalidArgumentException('Blocksize must be between 0 and 9'); } $this->options['blocksize'] = (int) $blocksize; return $this; }
php
public function setBlocksize($blocksize) { if (($blocksize < 0) || ($blocksize > 9)) { throw new Exception\InvalidArgumentException('Blocksize must be between 0 and 9'); } $this->options['blocksize'] = (int) $blocksize; return $this; }
[ "public", "function", "setBlocksize", "(", "$", "blocksize", ")", "{", "if", "(", "(", "$", "blocksize", "<", "0", ")", "||", "(", "$", "blocksize", ">", "9", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Blocksize must be between 0 and 9'", ")", ";", "}", "$", "this", "->", "options", "[", "'blocksize'", "]", "=", "(", "int", ")", "$", "blocksize", ";", "return", "$", "this", ";", "}" ]
Sets a new blocksize @param int $blocksize @throws Exception\InvalidArgumentException @return self
[ "Sets", "a", "new", "blocksize" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Compress/Bz2.php#L64-L72
8,323
michaelKaefer/group
src/Factory/GroupFactory.php
GroupFactory.createFromFileGroup
public static function createFromFileGroup($filename) { if (!file_exists($filename)) { throw new \InvalidArgumentException('Invalid file name provided.'); } if (!function_exists('posix_getgrgid')) { throw new PosixNotAvailableException( 'Could not retrieve information about the operating system group because POSIX functions ' . 'are not available to your PHP executable.' ); } if (false === $gid = \filegroup($filename)) { throw new \Exception('Could not get the group of the file "' . $filename . '".'); } return new Group($gid); }
php
public static function createFromFileGroup($filename) { if (!file_exists($filename)) { throw new \InvalidArgumentException('Invalid file name provided.'); } if (!function_exists('posix_getgrgid')) { throw new PosixNotAvailableException( 'Could not retrieve information about the operating system group because POSIX functions ' . 'are not available to your PHP executable.' ); } if (false === $gid = \filegroup($filename)) { throw new \Exception('Could not get the group of the file "' . $filename . '".'); } return new Group($gid); }
[ "public", "static", "function", "createFromFileGroup", "(", "$", "filename", ")", "{", "if", "(", "!", "file_exists", "(", "$", "filename", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid file name provided.'", ")", ";", "}", "if", "(", "!", "function_exists", "(", "'posix_getgrgid'", ")", ")", "{", "throw", "new", "PosixNotAvailableException", "(", "'Could not retrieve information about the operating system group because POSIX functions '", ".", "'are not available to your PHP executable.'", ")", ";", "}", "if", "(", "false", "===", "$", "gid", "=", "\\", "filegroup", "(", "$", "filename", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Could not get the group of the file \"'", ".", "$", "filename", ".", "'\".'", ")", ";", "}", "return", "new", "Group", "(", "$", "gid", ")", ";", "}" ]
Factory method to get the group of a file. @param string $filename @return Group @throws PosixNotAvailableException @throws \Exception
[ "Factory", "method", "to", "get", "the", "group", "of", "a", "file", "." ]
ac47f9582c1ebae115a54c0806912b67c6be6462
https://github.com/michaelKaefer/group/blob/ac47f9582c1ebae115a54c0806912b67c6be6462/src/Factory/GroupFactory.php#L80-L95
8,324
ciims/cii
models/CiiSettingsModel.php
CiiSettingsModel.set
private function set($name, $value) { if (property_exists($this, $name)) { $this->$name = $value; $this->attributes[$name] = $value; return true; } return false; }
php
private function set($name, $value) { if (property_exists($this, $name)) { $this->$name = $value; $this->attributes[$name] = $value; return true; } return false; }
[ "private", "function", "set", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "$", "name", ")", ")", "{", "$", "this", "->", "$", "name", "=", "$", "value", ";", "$", "this", "->", "attributes", "[", "$", "name", "]", "=", "$", "value", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Generic setter Since @protected properties exists, we can't take advantage of __set(), so we have to roll our own @param string $name The name of the varliable @param mixed $value The value to set
[ "Generic", "setter", "Since" ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/models/CiiSettingsModel.php#L89-L99
8,325
ciims/cii
models/CiiSettingsModel.php
CiiSettingsModel.populate
public function populate($data = array(), $direct = false) { if (!$direct) $data = Cii::get($data, get_class($this)); foreach ($data as $attribute=>$value) $this->set($attribute, $value); return true; }
php
public function populate($data = array(), $direct = false) { if (!$direct) $data = Cii::get($data, get_class($this)); foreach ($data as $attribute=>$value) $this->set($attribute, $value); return true; }
[ "public", "function", "populate", "(", "$", "data", "=", "array", "(", ")", ",", "$", "direct", "=", "false", ")", "{", "if", "(", "!", "$", "direct", ")", "$", "data", "=", "Cii", "::", "get", "(", "$", "data", ",", "get_class", "(", "$", "this", ")", ")", ";", "foreach", "(", "$", "data", "as", "$", "attribute", "=>", "$", "value", ")", "$", "this", "->", "set", "(", "$", "attribute", ",", "$", "value", ")", ";", "return", "true", ";", "}" ]
Provides a generic method for populating data @param array $data $_POST data @param bool $direct If the data should be accessed directly rather than by getting it through the class name @return bool
[ "Provides", "a", "generic", "method", "for", "populating", "data" ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/models/CiiSettingsModel.php#L116-L125
8,326
ciims/cii
models/CiiSettingsModel.php
CiiSettingsModel.password
public function password($attribute, $params) { $this->attributes[$attribute] = $this->$attribute = Cii::encrypt($this->$attribute); return true; }
php
public function password($attribute, $params) { $this->attributes[$attribute] = $this->$attribute = Cii::encrypt($this->$attribute); return true; }
[ "public", "function", "password", "(", "$", "attribute", ",", "$", "params", ")", "{", "$", "this", "->", "attributes", "[", "$", "attribute", "]", "=", "$", "this", "->", "$", "attribute", "=", "Cii", "::", "encrypt", "(", "$", "this", "->", "$", "attribute", ")", ";", "return", "true", ";", "}" ]
Validates passwords by encrypting them for storage @param mixed $attribute @param mixed $params @return boolean
[ "Validates", "passwords", "by", "encrypting", "them", "for", "storage" ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/models/CiiSettingsModel.php#L133-L137
8,327
ciims/cii
models/CiiSettingsModel.php
CiiSettingsModel.afterSave
protected function afterSave() { if($this->hasEventHandler('onAfterSave')) $this->onAfterSave(new CEvent($this)); // Store new config values in cache foreach($this->attributes as $key=>$value) Yii::app()->cache->set('settings_'.$key, $value); return true; }
php
protected function afterSave() { if($this->hasEventHandler('onAfterSave')) $this->onAfterSave(new CEvent($this)); // Store new config values in cache foreach($this->attributes as $key=>$value) Yii::app()->cache->set('settings_'.$key, $value); return true; }
[ "protected", "function", "afterSave", "(", ")", "{", "if", "(", "$", "this", "->", "hasEventHandler", "(", "'onAfterSave'", ")", ")", "$", "this", "->", "onAfterSave", "(", "new", "CEvent", "(", "$", "this", ")", ")", ";", "// Store new config values in cache", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "key", "=>", "$", "value", ")", "Yii", "::", "app", "(", ")", "->", "cache", "->", "set", "(", "'settings_'", ".", "$", "key", ",", "$", "value", ")", ";", "return", "true", ";", "}" ]
Allow for afterSave events @return bool If afterSave passed
[ "Allow", "for", "afterSave", "events" ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/models/CiiSettingsModel.php#L159-L169
8,328
ciims/cii
models/CiiSettingsModel.php
CiiSettingsModel.getStringValidator
public function getStringValidator($attribute=NULL, $validators=NULL) { if ($attribute == NULL && $validators == NULL) return array(); $v = array(); if ($validators == NULL && $attribute !== NULL) $validators = $this->getValidators($attribute); $validators = array_values($validators); foreach ($validators as $validator) { $ve = strtolower(str_replace('Validator', '', substr(get_class($validator), 1, strlen(get_class($validator))))); if ($ve == 'inline') $v[] = $validator->method; else $v[] = $ve; } return $v; }
php
public function getStringValidator($attribute=NULL, $validators=NULL) { if ($attribute == NULL && $validators == NULL) return array(); $v = array(); if ($validators == NULL && $attribute !== NULL) $validators = $this->getValidators($attribute); $validators = array_values($validators); foreach ($validators as $validator) { $ve = strtolower(str_replace('Validator', '', substr(get_class($validator), 1, strlen(get_class($validator))))); if ($ve == 'inline') $v[] = $validator->method; else $v[] = $ve; } return $v; }
[ "public", "function", "getStringValidator", "(", "$", "attribute", "=", "NULL", ",", "$", "validators", "=", "NULL", ")", "{", "if", "(", "$", "attribute", "==", "NULL", "&&", "$", "validators", "==", "NULL", ")", "return", "array", "(", ")", ";", "$", "v", "=", "array", "(", ")", ";", "if", "(", "$", "validators", "==", "NULL", "&&", "$", "attribute", "!==", "NULL", ")", "$", "validators", "=", "$", "this", "->", "getValidators", "(", "$", "attribute", ")", ";", "$", "validators", "=", "array_values", "(", "$", "validators", ")", ";", "foreach", "(", "$", "validators", "as", "$", "validator", ")", "{", "$", "ve", "=", "strtolower", "(", "str_replace", "(", "'Validator'", ",", "''", ",", "substr", "(", "get_class", "(", "$", "validator", ")", ",", "1", ",", "strlen", "(", "get_class", "(", "$", "validator", ")", ")", ")", ")", ")", ";", "if", "(", "$", "ve", "==", "'inline'", ")", "$", "v", "[", "]", "=", "$", "validator", "->", "method", ";", "else", "$", "v", "[", "]", "=", "$", "ve", ";", "}", "return", "$", "v", ";", "}" ]
Gets the validator types as strings to be used for the form parser @param string $attribute The property name we want to work with @param CValidator $validators Often times we may already have the validator, so if this is provided, it will be used instead of fetching the validators for the property @return array The validators as clean strings (required, boolean, string, url, number...etc)
[ "Gets", "the", "validator", "types", "as", "strings", "to", "be", "used", "for", "the", "form", "parser" ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/models/CiiSettingsModel.php#L178-L199
8,329
ciims/cii
models/CiiSettingsModel.php
CiiSettingsModel.save
public function save($runValidation=true) { if ($this->beforeSave()) { // If we want to run validation AND the validation failed, give up if ($this->beforeValidate()) { if ($runValidation && !$this->validate()) return false; } else return false; $this->afterValidate(); $connection = Yii::app()->db; $transaction = $connection->beginTransaction(); try { foreach($this->attributes as $key=>$value) { $command = $connection->createCommand('INSERT INTO `configuration` VALUES (:key, :value, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE value = :value2, updated = UTC_TIMESTAMP()'); $command->bindParam(':key', $key); $command->bindParam(':value', $value); $command->bindParam(':value2', $value); $command->execute(); Yii::app()->cache->delete('settings_'.$key); } } catch (Exception $e) { $transaciton->rollBack(); return false; } $transaction->commit(); $this->afterSave(); // Return the commit response return true; } }
php
public function save($runValidation=true) { if ($this->beforeSave()) { // If we want to run validation AND the validation failed, give up if ($this->beforeValidate()) { if ($runValidation && !$this->validate()) return false; } else return false; $this->afterValidate(); $connection = Yii::app()->db; $transaction = $connection->beginTransaction(); try { foreach($this->attributes as $key=>$value) { $command = $connection->createCommand('INSERT INTO `configuration` VALUES (:key, :value, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE value = :value2, updated = UTC_TIMESTAMP()'); $command->bindParam(':key', $key); $command->bindParam(':value', $value); $command->bindParam(':value2', $value); $command->execute(); Yii::app()->cache->delete('settings_'.$key); } } catch (Exception $e) { $transaciton->rollBack(); return false; } $transaction->commit(); $this->afterSave(); // Return the commit response return true; } }
[ "public", "function", "save", "(", "$", "runValidation", "=", "true", ")", "{", "if", "(", "$", "this", "->", "beforeSave", "(", ")", ")", "{", "// If we want to run validation AND the validation failed, give up", "if", "(", "$", "this", "->", "beforeValidate", "(", ")", ")", "{", "if", "(", "$", "runValidation", "&&", "!", "$", "this", "->", "validate", "(", ")", ")", "return", "false", ";", "}", "else", "return", "false", ";", "$", "this", "->", "afterValidate", "(", ")", ";", "$", "connection", "=", "Yii", "::", "app", "(", ")", "->", "db", ";", "$", "transaction", "=", "$", "connection", "->", "beginTransaction", "(", ")", ";", "try", "{", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "command", "=", "$", "connection", "->", "createCommand", "(", "'INSERT INTO `configuration` VALUES (:key, :value, UTC_TIMESTAMP(), UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE value = :value2, updated = UTC_TIMESTAMP()'", ")", ";", "$", "command", "->", "bindParam", "(", "':key'", ",", "$", "key", ")", ";", "$", "command", "->", "bindParam", "(", "':value'", ",", "$", "value", ")", ";", "$", "command", "->", "bindParam", "(", "':value2'", ",", "$", "value", ")", ";", "$", "command", "->", "execute", "(", ")", ";", "Yii", "::", "app", "(", ")", "->", "cache", "->", "delete", "(", "'settings_'", ".", "$", "key", ")", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "transaciton", "->", "rollBack", "(", ")", ";", "return", "false", ";", "}", "$", "transaction", "->", "commit", "(", ")", ";", "$", "this", "->", "afterSave", "(", ")", ";", "// Return the commit response", "return", "true", ";", "}", "}" ]
Save function for Configuration Everything should be wrapped inside of a transaction - if there is an error saving any of the items then there was an error saving all of them and we should abort @return boolean|null Whether or not the save succedded or not
[ "Save", "function", "for", "Configuration", "Everything", "should", "be", "wrapped", "inside", "of", "a", "transaction", "-", "if", "there", "is", "an", "error", "saving", "any", "of", "the", "items", "then", "there", "was", "an", "error", "saving", "all", "of", "them", "and", "we", "should", "abort" ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/models/CiiSettingsModel.php#L223-L263
8,330
tekkla/core-html
Core/Html/Bootstrap/Buttongroups/ButtonToolbar.php
ButtonToolbar.&
public function &addButtongroup(ButtonGroup $buttongroup) { $uniqeid = uniqid('btntoolbar_btngrp_'); $this->groups[$uniqeid] = $buttongroup; return $this->groups[$uniqeid]; }
php
public function &addButtongroup(ButtonGroup $buttongroup) { $uniqeid = uniqid('btntoolbar_btngrp_'); $this->groups[$uniqeid] = $buttongroup; return $this->groups[$uniqeid]; }
[ "public", "function", "&", "addButtongroup", "(", "ButtonGroup", "$", "buttongroup", ")", "{", "$", "uniqeid", "=", "uniqid", "(", "'btntoolbar_btngrp_'", ")", ";", "$", "this", "->", "groups", "[", "$", "uniqeid", "]", "=", "$", "buttongroup", ";", "return", "$", "this", "->", "groups", "[", "$", "uniqeid", "]", ";", "}" ]
Adds a ButtonGroup object to the groups list and returns reference to it. @return Core\Html\Bootstrap\Buttongroups\ButtonGroup
[ "Adds", "a", "ButtonGroup", "object", "to", "the", "groups", "list", "and", "returns", "reference", "to", "it", "." ]
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Bootstrap/Buttongroups/ButtonToolbar.php#L33-L39
8,331
rozaverta/cmf
core/Controllers/Controller.php
Controller.getName
public function getName(): string { if( !$this->name ) { $name = $this->getModule()->getKey(); if( preg_match('/Controllers\\\\(.*?)$/', static::class, $e ) ) { $name .= '::' . preg_replace_callback( '/[A-Z]/', static function( $m ) { return '_' . lcfirst( $m[0] ); }, lcfirst( $e[1] ) ); $name = str_replace( '\\', ':', $name ); } $this->name = strtolower( $name ); } return $this->name; }
php
public function getName(): string { if( !$this->name ) { $name = $this->getModule()->getKey(); if( preg_match('/Controllers\\\\(.*?)$/', static::class, $e ) ) { $name .= '::' . preg_replace_callback( '/[A-Z]/', static function( $m ) { return '_' . lcfirst( $m[0] ); }, lcfirst( $e[1] ) ); $name = str_replace( '\\', ':', $name ); } $this->name = strtolower( $name ); } return $this->name; }
[ "public", "function", "getName", "(", ")", ":", "string", "{", "if", "(", "!", "$", "this", "->", "name", ")", "{", "$", "name", "=", "$", "this", "->", "getModule", "(", ")", "->", "getKey", "(", ")", ";", "if", "(", "preg_match", "(", "'/Controllers\\\\\\\\(.*?)$/'", ",", "static", "::", "class", ",", "$", "e", ")", ")", "{", "$", "name", ".=", "'::'", ".", "preg_replace_callback", "(", "'/[A-Z]/'", ",", "static", "function", "(", "$", "m", ")", "{", "return", "'_'", ".", "lcfirst", "(", "$", "m", "[", "0", "]", ")", ";", "}", ",", "lcfirst", "(", "$", "e", "[", "1", "]", ")", ")", ";", "$", "name", "=", "str_replace", "(", "'\\\\'", ",", "':'", ",", "$", "name", ")", ";", "}", "$", "this", "->", "name", "=", "strtolower", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "name", ";", "}" ]
Get controller name @return string
[ "Get", "controller", "name" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Controllers/Controller.php#L75-L89
8,332
rozaverta/cmf
core/Controllers/Controller.php
Controller.supportPortalMethod
public function supportPortalMethod( $name, $method ) { if( $name instanceof Module ) { $name = $name->getKey(); } return $this->module->support($name) && method_exists($this, $method); }
php
public function supportPortalMethod( $name, $method ) { if( $name instanceof Module ) { $name = $name->getKey(); } return $this->module->support($name) && method_exists($this, $method); }
[ "public", "function", "supportPortalMethod", "(", "$", "name", ",", "$", "method", ")", "{", "if", "(", "$", "name", "instanceof", "Module", ")", "{", "$", "name", "=", "$", "name", "->", "getKey", "(", ")", ";", "}", "return", "$", "this", "->", "module", "->", "support", "(", "$", "name", ")", "&&", "method_exists", "(", "$", "this", ",", "$", "method", ")", ";", "}" ]
Check support method for other module @param string | Module $name @param string $method @return bool
[ "Check", "support", "method", "for", "other", "module" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Controllers/Controller.php#L132-L140
8,333
tonjoo/tiga-framework
src/View/View.php
View.sendResponse
public function sendResponse() { if ($this->response instanceof SymfonyResponse) { $this->response->sendContent(); } if ($this->templatefile !== false) { echo $this->template->render($this->templatefile, $this->templatefileParameters); } }
php
public function sendResponse() { if ($this->response instanceof SymfonyResponse) { $this->response->sendContent(); } if ($this->templatefile !== false) { echo $this->template->render($this->templatefile, $this->templatefileParameters); } }
[ "public", "function", "sendResponse", "(", ")", "{", "if", "(", "$", "this", "->", "response", "instanceof", "SymfonyResponse", ")", "{", "$", "this", "->", "response", "->", "sendContent", "(", ")", ";", "}", "if", "(", "$", "this", "->", "templatefile", "!==", "false", ")", "{", "echo", "$", "this", "->", "template", "->", "render", "(", "$", "this", "->", "templatefile", ",", "$", "this", "->", "templatefileParameters", ")", ";", "}", "}" ]
Send content back.
[ "Send", "content", "back", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/View/View.php#L96-L104
8,334
agalbourdin/agl-core
src/Data/Validation.php
Validation.isRegex
public static function isRegex($pValue, $pExpr) { if (is_array($pValue)) { foreach ($pValue as $value) { if (! preg_match($pExpr, $value)) { return false; } } } else { if (! preg_match($pExpr, $pValue)) { return false; } } return true; }
php
public static function isRegex($pValue, $pExpr) { if (is_array($pValue)) { foreach ($pValue as $value) { if (! preg_match($pExpr, $value)) { return false; } } } else { if (! preg_match($pExpr, $pValue)) { return false; } } return true; }
[ "public", "static", "function", "isRegex", "(", "$", "pValue", ",", "$", "pExpr", ")", "{", "if", "(", "is_array", "(", "$", "pValue", ")", ")", "{", "foreach", "(", "$", "pValue", "as", "$", "value", ")", "{", "if", "(", "!", "preg_match", "(", "$", "pExpr", ",", "$", "value", ")", ")", "{", "return", "false", ";", "}", "}", "}", "else", "{", "if", "(", "!", "preg_match", "(", "$", "pExpr", ",", "$", "pValue", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Regex validation. @param array|string $pValue @param $pExpr PCRE expression @return bool
[ "Regex", "validation", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Data/Validation.php#L186-L201
8,335
remote-office/libx
src/External/Bag/Api/BagClient.php
BagClient.numberindication
public function numberindication($zipcode, $number) { // Concat url $url = self::API_URL . '/nummeraanduidingen'; // Create a REST request $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_GET); $parameters = []; $parameters['postcode'] = $zipcode; $parameters['huisnummer'] = $number; $request->setParameters($parameters); // Create a REST response $response = new \LibX\Net\Rest\Response(); // Make the call $data = $this->call($request, $response); $indications = $data->_embedded->nummeraanduidingen; foreach($indications as $indication) { } }
php
public function numberindication($zipcode, $number) { // Concat url $url = self::API_URL . '/nummeraanduidingen'; // Create a REST request $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_GET); $parameters = []; $parameters['postcode'] = $zipcode; $parameters['huisnummer'] = $number; $request->setParameters($parameters); // Create a REST response $response = new \LibX\Net\Rest\Response(); // Make the call $data = $this->call($request, $response); $indications = $data->_embedded->nummeraanduidingen; foreach($indications as $indication) { } }
[ "public", "function", "numberindication", "(", "$", "zipcode", ",", "$", "number", ")", "{", "// Concat url", "$", "url", "=", "self", "::", "API_URL", ".", "'/nummeraanduidingen'", ";", "// Create a REST request", "$", "request", "=", "new", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Request", "(", "$", "url", ",", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Request", "::", "REQUEST_METHOD_GET", ")", ";", "$", "parameters", "=", "[", "]", ";", "$", "parameters", "[", "'postcode'", "]", "=", "$", "zipcode", ";", "$", "parameters", "[", "'huisnummer'", "]", "=", "$", "number", ";", "$", "request", "->", "setParameters", "(", "$", "parameters", ")", ";", "// Create a REST response", "$", "response", "=", "new", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Response", "(", ")", ";", "// Make the call", "$", "data", "=", "$", "this", "->", "call", "(", "$", "request", ",", "$", "response", ")", ";", "$", "indications", "=", "$", "data", "->", "_embedded", "->", "nummeraanduidingen", ";", "foreach", "(", "$", "indications", "as", "$", "indication", ")", "{", "}", "}" ]
Retrieve number indications @param string $zipcode @param integer $number @return NULL
[ "Retrieve", "number", "indications" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/External/Bag/Api/BagClient.php#L40-L66
8,336
remote-office/libx
src/External/Bag/Api/BagClient.php
BagClient.search
public function search($type, Polygon $polygon) { // Concat url $url = self::API_URL . '/' . $type; $data = new \StdClass(); $data->geometrie = new \StdClass(); $data->geometrie->contains = new \StdClass(); $data->geometrie->contains->type = 'Point'; // Polygon?? $data->geometrie->contains->coordinates = []; $points = $polygon->getPoints(); foreach($points as $point) $data->geometrie->contains->coordinates[] = [$point->getX(), $point->getY()]; // Create a REST request $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_POST); $request->setData(json_encode($data)); // Create a REST response $response = new \LibX\Net\Rest\Response(); // Not working at the moment return; // Make the call $data = $this->call($request, $response); }
php
public function search($type, Polygon $polygon) { // Concat url $url = self::API_URL . '/' . $type; $data = new \StdClass(); $data->geometrie = new \StdClass(); $data->geometrie->contains = new \StdClass(); $data->geometrie->contains->type = 'Point'; // Polygon?? $data->geometrie->contains->coordinates = []; $points = $polygon->getPoints(); foreach($points as $point) $data->geometrie->contains->coordinates[] = [$point->getX(), $point->getY()]; // Create a REST request $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_POST); $request->setData(json_encode($data)); // Create a REST response $response = new \LibX\Net\Rest\Response(); // Not working at the moment return; // Make the call $data = $this->call($request, $response); }
[ "public", "function", "search", "(", "$", "type", ",", "Polygon", "$", "polygon", ")", "{", "// Concat url", "$", "url", "=", "self", "::", "API_URL", ".", "'/'", ".", "$", "type", ";", "$", "data", "=", "new", "\\", "StdClass", "(", ")", ";", "$", "data", "->", "geometrie", "=", "new", "\\", "StdClass", "(", ")", ";", "$", "data", "->", "geometrie", "->", "contains", "=", "new", "\\", "StdClass", "(", ")", ";", "$", "data", "->", "geometrie", "->", "contains", "->", "type", "=", "'Point'", ";", "// Polygon??", "$", "data", "->", "geometrie", "->", "contains", "->", "coordinates", "=", "[", "]", ";", "$", "points", "=", "$", "polygon", "->", "getPoints", "(", ")", ";", "foreach", "(", "$", "points", "as", "$", "point", ")", "$", "data", "->", "geometrie", "->", "contains", "->", "coordinates", "[", "]", "=", "[", "$", "point", "->", "getX", "(", ")", ",", "$", "point", "->", "getY", "(", ")", "]", ";", "// Create a REST request", "$", "request", "=", "new", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Request", "(", "$", "url", ",", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Request", "::", "REQUEST_METHOD_POST", ")", ";", "$", "request", "->", "setData", "(", "json_encode", "(", "$", "data", ")", ")", ";", "// Create a REST response", "$", "response", "=", "new", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Response", "(", ")", ";", "// Not working at the moment", "return", ";", "// Make the call", "$", "data", "=", "$", "this", "->", "call", "(", "$", "request", ",", "$", "response", ")", ";", "}" ]
Search BAG data @param string $type @param Polygon $polygon @return NULL
[ "Search", "BAG", "data" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/External/Bag/Api/BagClient.php#L75-L103
8,337
remote-office/libx
src/External/Bag/Api/BagClient.php
BagClient.details
public function details($type, $id) { // Concat url $url = self::API_URL . '/' . $type . '/' . $id; // Create a REST request $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_GET); // Create a REST response $response = new \LibX\Net\Rest\Response(); // Make the call $data = $this->call($request, $response); //return $data->_embedded; return $data; }
php
public function details($type, $id) { // Concat url $url = self::API_URL . '/' . $type . '/' . $id; // Create a REST request $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_GET); // Create a REST response $response = new \LibX\Net\Rest\Response(); // Make the call $data = $this->call($request, $response); //return $data->_embedded; return $data; }
[ "public", "function", "details", "(", "$", "type", ",", "$", "id", ")", "{", "// Concat url", "$", "url", "=", "self", "::", "API_URL", ".", "'/'", ".", "$", "type", ".", "'/'", ".", "$", "id", ";", "// Create a REST request", "$", "request", "=", "new", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Request", "(", "$", "url", ",", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Request", "::", "REQUEST_METHOD_GET", ")", ";", "// Create a REST response", "$", "response", "=", "new", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Response", "(", ")", ";", "// Make the call", "$", "data", "=", "$", "this", "->", "call", "(", "$", "request", ",", "$", "response", ")", ";", "//return $data->_embedded;", "return", "$", "data", ";", "}" ]
Retrieve BAG details @param string $type @param string $id
[ "Retrieve", "BAG", "details" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/External/Bag/Api/BagClient.php#L111-L127
8,338
remote-office/libx
src/External/Bag/Api/BagClient.php
BagClient.geo
public function geo($type, $id) { // Concat url $url = self::API_URL . '/' . $type . '/' . $id; // Create a REST request $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_GET); // Create a REST response $response = new \LibX\Net\Rest\Response(); // Make the call $data = $this->call($request, $response); // Init $coordinates = null; // Get geo data if(isset($data->_embedded->geometrie)) { $geo = $data->_embedded->geometrie; if($geo->type === 'Point') { $longitude = $geo->coordinates[0]; $latitude = $geo->coordinates[1]; $coordinates = new Coordinates($latitude, $longitude); } elseif($geo->type === 'Polygon') { $points = new PointStack(); foreach($geo->coordinates[0] as $coordinates) { $longitude = $coordinates[0]; $latitude = $coordinates[1]; $points->push(new Coordinates($latitude, $longitude)); } $coordinates = new Polygon($points); } } return $coordinates; }
php
public function geo($type, $id) { // Concat url $url = self::API_URL . '/' . $type . '/' . $id; // Create a REST request $request = new \LibX\Net\Rest\Request($url, \LibX\Net\Rest\Request::REQUEST_METHOD_GET); // Create a REST response $response = new \LibX\Net\Rest\Response(); // Make the call $data = $this->call($request, $response); // Init $coordinates = null; // Get geo data if(isset($data->_embedded->geometrie)) { $geo = $data->_embedded->geometrie; if($geo->type === 'Point') { $longitude = $geo->coordinates[0]; $latitude = $geo->coordinates[1]; $coordinates = new Coordinates($latitude, $longitude); } elseif($geo->type === 'Polygon') { $points = new PointStack(); foreach($geo->coordinates[0] as $coordinates) { $longitude = $coordinates[0]; $latitude = $coordinates[1]; $points->push(new Coordinates($latitude, $longitude)); } $coordinates = new Polygon($points); } } return $coordinates; }
[ "public", "function", "geo", "(", "$", "type", ",", "$", "id", ")", "{", "// Concat url", "$", "url", "=", "self", "::", "API_URL", ".", "'/'", ".", "$", "type", ".", "'/'", ".", "$", "id", ";", "// Create a REST request", "$", "request", "=", "new", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Request", "(", "$", "url", ",", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Request", "::", "REQUEST_METHOD_GET", ")", ";", "// Create a REST response", "$", "response", "=", "new", "\\", "LibX", "\\", "Net", "\\", "Rest", "\\", "Response", "(", ")", ";", "// Make the call", "$", "data", "=", "$", "this", "->", "call", "(", "$", "request", ",", "$", "response", ")", ";", "// Init", "$", "coordinates", "=", "null", ";", "// Get geo data", "if", "(", "isset", "(", "$", "data", "->", "_embedded", "->", "geometrie", ")", ")", "{", "$", "geo", "=", "$", "data", "->", "_embedded", "->", "geometrie", ";", "if", "(", "$", "geo", "->", "type", "===", "'Point'", ")", "{", "$", "longitude", "=", "$", "geo", "->", "coordinates", "[", "0", "]", ";", "$", "latitude", "=", "$", "geo", "->", "coordinates", "[", "1", "]", ";", "$", "coordinates", "=", "new", "Coordinates", "(", "$", "latitude", ",", "$", "longitude", ")", ";", "}", "elseif", "(", "$", "geo", "->", "type", "===", "'Polygon'", ")", "{", "$", "points", "=", "new", "PointStack", "(", ")", ";", "foreach", "(", "$", "geo", "->", "coordinates", "[", "0", "]", "as", "$", "coordinates", ")", "{", "$", "longitude", "=", "$", "coordinates", "[", "0", "]", ";", "$", "latitude", "=", "$", "coordinates", "[", "1", "]", ";", "$", "points", "->", "push", "(", "new", "Coordinates", "(", "$", "latitude", ",", "$", "longitude", ")", ")", ";", "}", "$", "coordinates", "=", "new", "Polygon", "(", "$", "points", ")", ";", "}", "}", "return", "$", "coordinates", ";", "}" ]
Retrieve BAG geo data @param string $type @param string $id @return NULL|\LibX\Util\Coordinates
[ "Retrieve", "BAG", "geo", "data" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/External/Bag/Api/BagClient.php#L136-L182
8,339
kevindierkx/elicit
src/Query/Processors/Processor.php
Processor.processRequest
protected function processRequest(Builder $query, $results) { // Here we validate the results being returned to be associative. // When they are not we wrap them in an array making it easier for // elicit to them parse as a model. if (array_keys($results) !== range(0, count($results) - 1)) { return [$results]; } // Here we return the results directly, assuming the items in // the array are a collection. return $results; }
php
protected function processRequest(Builder $query, $results) { // Here we validate the results being returned to be associative. // When they are not we wrap them in an array making it easier for // elicit to them parse as a model. if (array_keys($results) !== range(0, count($results) - 1)) { return [$results]; } // Here we return the results directly, assuming the items in // the array are a collection. return $results; }
[ "protected", "function", "processRequest", "(", "Builder", "$", "query", ",", "$", "results", ")", "{", "// Here we validate the results being returned to be associative.", "// When they are not we wrap them in an array making it easier for", "// elicit to them parse as a model.", "if", "(", "array_keys", "(", "$", "results", ")", "!==", "range", "(", "0", ",", "count", "(", "$", "results", ")", "-", "1", ")", ")", "{", "return", "[", "$", "results", "]", ";", "}", "// Here we return the results directly, assuming the items in", "// the array are a collection.", "return", "$", "results", ";", "}" ]
Process the results of an API request. @param \Kevindierkx\Elicit\Query\Builder $query @param array $results @return array
[ "Process", "the", "results", "of", "an", "API", "request", "." ]
c277942f5f5f63b175bc37e9d392faa946888f65
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/Query/Processors/Processor.php#L14-L26
8,340
bytic/inflector
src/Traits/InflectionClassifyTrait.php
InflectionClassifyTrait.doClassify
protected function doClassify($string) { $partsNamespace = explode('\\', $string); $return = []; foreach ($partsNamespace as $partNamespace) { $parts = explode("-", $partNamespace); $parts = array_map([$this, "camelize"], $parts); $return[] = implode("_", $parts); } return implode('\\', $return); }
php
protected function doClassify($string) { $partsNamespace = explode('\\', $string); $return = []; foreach ($partsNamespace as $partNamespace) { $parts = explode("-", $partNamespace); $parts = array_map([$this, "camelize"], $parts); $return[] = implode("_", $parts); } return implode('\\', $return); }
[ "protected", "function", "doClassify", "(", "$", "string", ")", "{", "$", "partsNamespace", "=", "explode", "(", "'\\\\'", ",", "$", "string", ")", ";", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "partsNamespace", "as", "$", "partNamespace", ")", "{", "$", "parts", "=", "explode", "(", "\"-\"", ",", "$", "partNamespace", ")", ";", "$", "parts", "=", "array_map", "(", "[", "$", "this", ",", "\"camelize\"", "]", ",", "$", "parts", ")", ";", "$", "return", "[", "]", "=", "implode", "(", "\"_\"", ",", "$", "parts", ")", ";", "}", "return", "implode", "(", "'\\\\'", ",", "$", "return", ")", ";", "}" ]
Converts lowercase string to underscored camelize class format @param string $string @return string
[ "Converts", "lowercase", "string", "to", "underscored", "camelize", "class", "format" ]
9521a88ab1226ef9dfa6f5aae2faae3516d5ea83
https://github.com/bytic/inflector/blob/9521a88ab1226ef9dfa6f5aae2faae3516d5ea83/src/Traits/InflectionClassifyTrait.php#L20-L31
8,341
hschulz/data-structures
src/Tree/AbstractTreeNode.php
AbstractTreeNode.addChild
public function addChild(TreeNodeInterface $node): void { $this->children[] = $node; $this->isLeaf = false; }
php
public function addChild(TreeNodeInterface $node): void { $this->children[] = $node; $this->isLeaf = false; }
[ "public", "function", "addChild", "(", "TreeNodeInterface", "$", "node", ")", ":", "void", "{", "$", "this", "->", "children", "[", "]", "=", "$", "node", ";", "$", "this", "->", "isLeaf", "=", "false", ";", "}" ]
Adds the given tree node to this nodes child list. @param TreeNodeInterface $node The node to be inserted @return void
[ "Adds", "the", "given", "tree", "node", "to", "this", "nodes", "child", "list", "." ]
b563be1ecde746fe32dd8bcbf72cbbf4ea522075
https://github.com/hschulz/data-structures/blob/b563be1ecde746fe32dd8bcbf72cbbf4ea522075/src/Tree/AbstractTreeNode.php#L40-L44
8,342
hschulz/data-structures
src/Tree/AbstractTreeNode.php
AbstractTreeNode.getSumChildCount
public function getSumChildCount(): int { $count = count($this->children); foreach ($this->children as $node) { $count += $node->getChildCount(); } return $count; }
php
public function getSumChildCount(): int { $count = count($this->children); foreach ($this->children as $node) { $count += $node->getChildCount(); } return $count; }
[ "public", "function", "getSumChildCount", "(", ")", ":", "int", "{", "$", "count", "=", "count", "(", "$", "this", "->", "children", ")", ";", "foreach", "(", "$", "this", "->", "children", "as", "$", "node", ")", "{", "$", "count", "+=", "$", "node", "->", "getChildCount", "(", ")", ";", "}", "return", "$", "count", ";", "}" ]
Returns the total sum of all children and their children. @return int The total sum of all children
[ "Returns", "the", "total", "sum", "of", "all", "children", "and", "their", "children", "." ]
b563be1ecde746fe32dd8bcbf72cbbf4ea522075
https://github.com/hschulz/data-structures/blob/b563be1ecde746fe32dd8bcbf72cbbf4ea522075/src/Tree/AbstractTreeNode.php#L61-L70
8,343
cityware/city-parallel-jobs
src/Storage/Results/Results.php
Results.addResult
public function addResult($child, $result) { if (!$result instanceof Result\ResultInterface) { throw new RuntimeException('Result type must be implements ResultInterface'); } $this->results[$child - 1] = $result; }
php
public function addResult($child, $result) { if (!$result instanceof Result\ResultInterface) { throw new RuntimeException('Result type must be implements ResultInterface'); } $this->results[$child - 1] = $result; }
[ "public", "function", "addResult", "(", "$", "child", ",", "$", "result", ")", "{", "if", "(", "!", "$", "result", "instanceof", "Result", "\\", "ResultInterface", ")", "{", "throw", "new", "RuntimeException", "(", "'Result type must be implements ResultInterface'", ")", ";", "}", "$", "this", "->", "results", "[", "$", "child", "-", "1", "]", "=", "$", "result", ";", "}" ]
add a result object
[ "add", "a", "result", "object" ]
587d3cea9c765a3bb32d9642fed30a8b12cc6aa2
https://github.com/cityware/city-parallel-jobs/blob/587d3cea9c765a3bb32d9642fed30a8b12cc6aa2/src/Storage/Results/Results.php#L28-L33
8,344
garkavenkov/db-connector
src/DBConfig.php
DBConfig.initiate
public static function initiate(array $params) { try { // Check whether $params is an array or not if (!is_array($params)) { throw new \Exception('Parameters need to be as an associative array'); } // Initiate database hostname. if (isset($params['db_hostname'])) { self::$db_params['db_hostname'] = $params['db_hostname']; } else { throw new \Exception('Database host need to be set!'); } // Initiate database driver. if (isset($params['db_driver'])) { self::$db_params['db_driver'] = $params['db_driver']; } else { throw new \Exception('Database driver need to be set!'); } // Initiate database port if (isset($params['db_port'])) { self::$db_params['db_port'] = ":" . $params['db_port']; } else { self::$db_params['db_port'] = ""; } // Initiate database schema if (isset($params['db_schema'])) { self::$db_params['db_schema']= $params['db_schema']; } else { throw new \Exception('Database name need to be set!'); } // Initiate database username if (isset($params['db_username'])) { self::$db_params['db_username'] = $params['db_username']; } else { self::$db_params['db_username'] = ""; } // Initiate database password if (isset($params['db_password'])) { self::$db_params['db_password'] = $params['db_password']; } else { self::$db_params['db_password'] = ""; } } catch (\Exception $e) { die($e->getMessage()); } }
php
public static function initiate(array $params) { try { // Check whether $params is an array or not if (!is_array($params)) { throw new \Exception('Parameters need to be as an associative array'); } // Initiate database hostname. if (isset($params['db_hostname'])) { self::$db_params['db_hostname'] = $params['db_hostname']; } else { throw new \Exception('Database host need to be set!'); } // Initiate database driver. if (isset($params['db_driver'])) { self::$db_params['db_driver'] = $params['db_driver']; } else { throw new \Exception('Database driver need to be set!'); } // Initiate database port if (isset($params['db_port'])) { self::$db_params['db_port'] = ":" . $params['db_port']; } else { self::$db_params['db_port'] = ""; } // Initiate database schema if (isset($params['db_schema'])) { self::$db_params['db_schema']= $params['db_schema']; } else { throw new \Exception('Database name need to be set!'); } // Initiate database username if (isset($params['db_username'])) { self::$db_params['db_username'] = $params['db_username']; } else { self::$db_params['db_username'] = ""; } // Initiate database password if (isset($params['db_password'])) { self::$db_params['db_password'] = $params['db_password']; } else { self::$db_params['db_password'] = ""; } } catch (\Exception $e) { die($e->getMessage()); } }
[ "public", "static", "function", "initiate", "(", "array", "$", "params", ")", "{", "try", "{", "// Check whether $params is an array or not", "if", "(", "!", "is_array", "(", "$", "params", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Parameters need to be as an associative array'", ")", ";", "}", "// Initiate database hostname.", "if", "(", "isset", "(", "$", "params", "[", "'db_hostname'", "]", ")", ")", "{", "self", "::", "$", "db_params", "[", "'db_hostname'", "]", "=", "$", "params", "[", "'db_hostname'", "]", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Database host need to be set!'", ")", ";", "}", "// Initiate database driver.", "if", "(", "isset", "(", "$", "params", "[", "'db_driver'", "]", ")", ")", "{", "self", "::", "$", "db_params", "[", "'db_driver'", "]", "=", "$", "params", "[", "'db_driver'", "]", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Database driver need to be set!'", ")", ";", "}", "// Initiate database port", "if", "(", "isset", "(", "$", "params", "[", "'db_port'", "]", ")", ")", "{", "self", "::", "$", "db_params", "[", "'db_port'", "]", "=", "\":\"", ".", "$", "params", "[", "'db_port'", "]", ";", "}", "else", "{", "self", "::", "$", "db_params", "[", "'db_port'", "]", "=", "\"\"", ";", "}", "// Initiate database schema", "if", "(", "isset", "(", "$", "params", "[", "'db_schema'", "]", ")", ")", "{", "self", "::", "$", "db_params", "[", "'db_schema'", "]", "=", "$", "params", "[", "'db_schema'", "]", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Database name need to be set!'", ")", ";", "}", "// Initiate database username", "if", "(", "isset", "(", "$", "params", "[", "'db_username'", "]", ")", ")", "{", "self", "::", "$", "db_params", "[", "'db_username'", "]", "=", "$", "params", "[", "'db_username'", "]", ";", "}", "else", "{", "self", "::", "$", "db_params", "[", "'db_username'", "]", "=", "\"\"", ";", "}", "// Initiate database password", "if", "(", "isset", "(", "$", "params", "[", "'db_password'", "]", ")", ")", "{", "self", "::", "$", "db_params", "[", "'db_password'", "]", "=", "$", "params", "[", "'db_password'", "]", ";", "}", "else", "{", "self", "::", "$", "db_params", "[", "'db_password'", "]", "=", "\"\"", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "die", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Initiates database configuration parameters @param array $params Database configuration parameters @return void
[ "Initiates", "database", "configuration", "parameters" ]
afe80d80b3377ef1fbeecd370bbf46568ae699ba
https://github.com/garkavenkov/db-connector/blob/afe80d80b3377ef1fbeecd370bbf46568ae699ba/src/DBConfig.php#L26-L78
8,345
garkavenkov/db-connector
src/DBConfig.php
DBConfig.get
public static function get($param) { if (isset(self::$db_params[$param])) { return self::$db_params[$param]; } return false; }
php
public static function get($param) { if (isset(self::$db_params[$param])) { return self::$db_params[$param]; } return false; }
[ "public", "static", "function", "get", "(", "$", "param", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "db_params", "[", "$", "param", "]", ")", ")", "{", "return", "self", "::", "$", "db_params", "[", "$", "param", "]", ";", "}", "return", "false", ";", "}" ]
Returns parameter's value if exists, otherwise returns null @param string $param Parameter's name @return mixed Parameter's value
[ "Returns", "parameter", "s", "value", "if", "exists", "otherwise", "returns", "null" ]
afe80d80b3377ef1fbeecd370bbf46568ae699ba
https://github.com/garkavenkov/db-connector/blob/afe80d80b3377ef1fbeecd370bbf46568ae699ba/src/DBConfig.php#L164-L170
8,346
as3io/parameters
src/Parameters.php
Parameters.exists
public function exists($path) { $keys = $this->explode($path); $parameters = $this->parameters; foreach ($keys as $key) { if (!is_array($parameters)) { return false; } if (array_key_exists($key, $parameters)) { $parameters = $parameters[$key]; } else { return false; } } return true; }
php
public function exists($path) { $keys = $this->explode($path); $parameters = $this->parameters; foreach ($keys as $key) { if (!is_array($parameters)) { return false; } if (array_key_exists($key, $parameters)) { $parameters = $parameters[$key]; } else { return false; } } return true; }
[ "public", "function", "exists", "(", "$", "path", ")", "{", "$", "keys", "=", "$", "this", "->", "explode", "(", "$", "path", ")", ";", "$", "parameters", "=", "$", "this", "->", "parameters", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "is_array", "(", "$", "parameters", ")", ")", "{", "return", "false", ";", "}", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "parameters", ")", ")", "{", "$", "parameters", "=", "$", "parameters", "[", "$", "key", "]", ";", "}", "else", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Determines if a parameter exists, regardless of null value. @param string $path @return bool
[ "Determines", "if", "a", "parameter", "exists", "regardless", "of", "null", "value", "." ]
45c518232aa6770182ff777d3f6e808e2bad28cb
https://github.com/as3io/parameters/blob/45c518232aa6770182ff777d3f6e808e2bad28cb/src/Parameters.php#L94-L110
8,347
as3io/parameters
src/Parameters.php
Parameters.getAsInstance
public function getAsInstance($path) { if (empty($path)) { return static::create([], $this->separator); } $value = $this->getAsArray($path); if (!is_array($value)) { throw new \InvalidArgumentException('You cannot return a Parameter instance on a non-array value.'); } return static::create($this->getAsArray($path), $this->separator); }
php
public function getAsInstance($path) { if (empty($path)) { return static::create([], $this->separator); } $value = $this->getAsArray($path); if (!is_array($value)) { throw new \InvalidArgumentException('You cannot return a Parameter instance on a non-array value.'); } return static::create($this->getAsArray($path), $this->separator); }
[ "public", "function", "getAsInstance", "(", "$", "path", ")", "{", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "return", "static", "::", "create", "(", "[", "]", ",", "$", "this", "->", "separator", ")", ";", "}", "$", "value", "=", "$", "this", "->", "getAsArray", "(", "$", "path", ")", ";", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You cannot return a Parameter instance on a non-array value.'", ")", ";", "}", "return", "static", "::", "create", "(", "$", "this", "->", "getAsArray", "(", "$", "path", ")", ",", "$", "this", "->", "separator", ")", ";", "}" ]
Gets a value based on a path, and returns it as a Parameters instance. @param string $path The parameter path, such as 'foo' or 'foo.bar' @return self
[ "Gets", "a", "value", "based", "on", "a", "path", "and", "returns", "it", "as", "a", "Parameters", "instance", "." ]
45c518232aa6770182ff777d3f6e808e2bad28cb
https://github.com/as3io/parameters/blob/45c518232aa6770182ff777d3f6e808e2bad28cb/src/Parameters.php#L151-L161
8,348
as3io/parameters
src/Parameters.php
Parameters.set
public function set($path, $value) { $keys = $this->explode($path); $parameters = &$this->parameters; while (count($keys) > 0) { if (count($keys) === 1) { if (!is_array($parameters)) { $parameters = []; } $parameters[array_shift($keys)] = $value; } else { $key = array_shift($keys); if (!isset($parameters[$key])) { $parameters[$key] = []; } $parameters = &$parameters[$key]; } } return $this; }
php
public function set($path, $value) { $keys = $this->explode($path); $parameters = &$this->parameters; while (count($keys) > 0) { if (count($keys) === 1) { if (!is_array($parameters)) { $parameters = []; } $parameters[array_shift($keys)] = $value; } else { $key = array_shift($keys); if (!isset($parameters[$key])) { $parameters[$key] = []; } $parameters = &$parameters[$key]; } } return $this; }
[ "public", "function", "set", "(", "$", "path", ",", "$", "value", ")", "{", "$", "keys", "=", "$", "this", "->", "explode", "(", "$", "path", ")", ";", "$", "parameters", "=", "&", "$", "this", "->", "parameters", ";", "while", "(", "count", "(", "$", "keys", ")", ">", "0", ")", "{", "if", "(", "count", "(", "$", "keys", ")", "===", "1", ")", "{", "if", "(", "!", "is_array", "(", "$", "parameters", ")", ")", "{", "$", "parameters", "=", "[", "]", ";", "}", "$", "parameters", "[", "array_shift", "(", "$", "keys", ")", "]", "=", "$", "value", ";", "}", "else", "{", "$", "key", "=", "array_shift", "(", "$", "keys", ")", ";", "if", "(", "!", "isset", "(", "$", "parameters", "[", "$", "key", "]", ")", ")", "{", "$", "parameters", "[", "$", "key", "]", "=", "[", "]", ";", "}", "$", "parameters", "=", "&", "$", "parameters", "[", "$", "key", "]", ";", "}", "}", "return", "$", "this", ";", "}" ]
Sets a value to a key path. @param string $path @param mixed $value @return self
[ "Sets", "a", "value", "to", "a", "key", "path", "." ]
45c518232aa6770182ff777d3f6e808e2bad28cb
https://github.com/as3io/parameters/blob/45c518232aa6770182ff777d3f6e808e2bad28cb/src/Parameters.php#L284-L304
8,349
as3io/parameters
src/Parameters.php
Parameters.castObjectsAsArrays
private function castObjectsAsArrays(array $parameters) { foreach ($parameters as $key => $value) { if (is_object($value)) { $value = (array) $value; $parameters[$key] = $value; } if (is_array($value)) { $parameters[$key] = $this->castObjectsAsArrays($value); } } return $parameters; }
php
private function castObjectsAsArrays(array $parameters) { foreach ($parameters as $key => $value) { if (is_object($value)) { $value = (array) $value; $parameters[$key] = $value; } if (is_array($value)) { $parameters[$key] = $this->castObjectsAsArrays($value); } } return $parameters; }
[ "private", "function", "castObjectsAsArrays", "(", "array", "$", "parameters", ")", "{", "foreach", "(", "$", "parameters", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "value", "=", "(", "array", ")", "$", "value", ";", "$", "parameters", "[", "$", "key", "]", "=", "$", "value", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "parameters", "[", "$", "key", "]", "=", "$", "this", "->", "castObjectsAsArrays", "(", "$", "value", ")", ";", "}", "}", "return", "$", "parameters", ";", "}" ]
Ensures any object values are cast as arrays. Is recursive. @param array $parameters @return array
[ "Ensures", "any", "object", "values", "are", "cast", "as", "arrays", ".", "Is", "recursive", "." ]
45c518232aa6770182ff777d3f6e808e2bad28cb
https://github.com/as3io/parameters/blob/45c518232aa6770182ff777d3f6e808e2bad28cb/src/Parameters.php#L365-L377
8,350
Silvestra/Silvestra
src/Silvestra/Bundle/SiteBundle/Doctrine/ORM/EventListener/SiteListener.php
SiteListener.deleteDoctrineCache
public function deleteDoctrineCache(SiteEvent $event) { if ($cacheImpl = $this->em->getConfiguration()->getResultCacheImpl()) { $cacheImpl->delete(SiteInterface::SITE); } }
php
public function deleteDoctrineCache(SiteEvent $event) { if ($cacheImpl = $this->em->getConfiguration()->getResultCacheImpl()) { $cacheImpl->delete(SiteInterface::SITE); } }
[ "public", "function", "deleteDoctrineCache", "(", "SiteEvent", "$", "event", ")", "{", "if", "(", "$", "cacheImpl", "=", "$", "this", "->", "em", "->", "getConfiguration", "(", ")", "->", "getResultCacheImpl", "(", ")", ")", "{", "$", "cacheImpl", "->", "delete", "(", "SiteInterface", "::", "SITE", ")", ";", "}", "}" ]
Delete doctrine cache. @param SiteEvent $event
[ "Delete", "doctrine", "cache", "." ]
b7367601b01495ae3c492b42042f804dee13ab06
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Bundle/SiteBundle/Doctrine/ORM/EventListener/SiteListener.php#L56-L61
8,351
Gelembjuk/logger
src/Gelembjuk/Logger/FileLogger.php
FileLogger.log
public function log($level, $message, array $context = array()) { $group = ''; if (isset($context['group'])) { $group = $context['group']; } if ($this->groupfilter == '' || $group == '' && $this->groupfilter != 'all') { return false; } $logallowed = false; if ($this->groupfilter == 'all') { $logallowed = true; } else { foreach (explode('|',$group) as $f) { if (preg_match('!\\|'.preg_quote($f).'\\|!','|'.$this->groupfilter.'|')) { // do log if any path of the filter is allowed to log $logallowed = true; break; } } } if (!$logallowed) { return false; } if (!$this->extraFilter($level,$context)) { return false; } // add log entry to the file if (is_array($message) || is_object($message)) { $message = print_r($message,true); } $logfilehandle = @fopen($this->logfile,'a'); if (!$logfilehandle) { return false; } fwrite($logfilehandle, $this->formatLogLine($message) . "\n"); if (isset($context['extrainfo'])) { // log this too fwrite($logfilehandle, "\t" . $context['extrainfo'] . "\n"); } if ($level == LogLevel::ERROR || $level == LogLevel::CRITICAL || $level == LogLevel::EMERGENCY) { // maybe logging of trace is needed if (isset($context['exception']) && $context['exception'] instanceof \Exception) { if ($this->forcelogtrace || $context['forcelogtrace'] === true) { fwrite($logfilehandle, $context['exception']->getTraceAsString() . "\n"); } } } fclose($logfilehandle); return true; }
php
public function log($level, $message, array $context = array()) { $group = ''; if (isset($context['group'])) { $group = $context['group']; } if ($this->groupfilter == '' || $group == '' && $this->groupfilter != 'all') { return false; } $logallowed = false; if ($this->groupfilter == 'all') { $logallowed = true; } else { foreach (explode('|',$group) as $f) { if (preg_match('!\\|'.preg_quote($f).'\\|!','|'.$this->groupfilter.'|')) { // do log if any path of the filter is allowed to log $logallowed = true; break; } } } if (!$logallowed) { return false; } if (!$this->extraFilter($level,$context)) { return false; } // add log entry to the file if (is_array($message) || is_object($message)) { $message = print_r($message,true); } $logfilehandle = @fopen($this->logfile,'a'); if (!$logfilehandle) { return false; } fwrite($logfilehandle, $this->formatLogLine($message) . "\n"); if (isset($context['extrainfo'])) { // log this too fwrite($logfilehandle, "\t" . $context['extrainfo'] . "\n"); } if ($level == LogLevel::ERROR || $level == LogLevel::CRITICAL || $level == LogLevel::EMERGENCY) { // maybe logging of trace is needed if (isset($context['exception']) && $context['exception'] instanceof \Exception) { if ($this->forcelogtrace || $context['forcelogtrace'] === true) { fwrite($logfilehandle, $context['exception']->getTraceAsString() . "\n"); } } } fclose($logfilehandle); return true; }
[ "public", "function", "log", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "$", "group", "=", "''", ";", "if", "(", "isset", "(", "$", "context", "[", "'group'", "]", ")", ")", "{", "$", "group", "=", "$", "context", "[", "'group'", "]", ";", "}", "if", "(", "$", "this", "->", "groupfilter", "==", "''", "||", "$", "group", "==", "''", "&&", "$", "this", "->", "groupfilter", "!=", "'all'", ")", "{", "return", "false", ";", "}", "$", "logallowed", "=", "false", ";", "if", "(", "$", "this", "->", "groupfilter", "==", "'all'", ")", "{", "$", "logallowed", "=", "true", ";", "}", "else", "{", "foreach", "(", "explode", "(", "'|'", ",", "$", "group", ")", "as", "$", "f", ")", "{", "if", "(", "preg_match", "(", "'!\\\\|'", ".", "preg_quote", "(", "$", "f", ")", ".", "'\\\\|!'", ",", "'|'", ".", "$", "this", "->", "groupfilter", ".", "'|'", ")", ")", "{", "// do log if any path of the filter is allowed to log", "$", "logallowed", "=", "true", ";", "break", ";", "}", "}", "}", "if", "(", "!", "$", "logallowed", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "extraFilter", "(", "$", "level", ",", "$", "context", ")", ")", "{", "return", "false", ";", "}", "// add log entry to the file", "if", "(", "is_array", "(", "$", "message", ")", "||", "is_object", "(", "$", "message", ")", ")", "{", "$", "message", "=", "print_r", "(", "$", "message", ",", "true", ")", ";", "}", "$", "logfilehandle", "=", "@", "fopen", "(", "$", "this", "->", "logfile", ",", "'a'", ")", ";", "if", "(", "!", "$", "logfilehandle", ")", "{", "return", "false", ";", "}", "fwrite", "(", "$", "logfilehandle", ",", "$", "this", "->", "formatLogLine", "(", "$", "message", ")", ".", "\"\\n\"", ")", ";", "if", "(", "isset", "(", "$", "context", "[", "'extrainfo'", "]", ")", ")", "{", "// log this too", "fwrite", "(", "$", "logfilehandle", ",", "\"\\t\"", ".", "$", "context", "[", "'extrainfo'", "]", ".", "\"\\n\"", ")", ";", "}", "if", "(", "$", "level", "==", "LogLevel", "::", "ERROR", "||", "$", "level", "==", "LogLevel", "::", "CRITICAL", "||", "$", "level", "==", "LogLevel", "::", "EMERGENCY", ")", "{", "// maybe logging of trace is needed", "if", "(", "isset", "(", "$", "context", "[", "'exception'", "]", ")", "&&", "$", "context", "[", "'exception'", "]", "instanceof", "\\", "Exception", ")", "{", "if", "(", "$", "this", "->", "forcelogtrace", "||", "$", "context", "[", "'forcelogtrace'", "]", "===", "true", ")", "{", "fwrite", "(", "$", "logfilehandle", ",", "$", "context", "[", "'exception'", "]", "->", "getTraceAsString", "(", ")", ".", "\"\\n\"", ")", ";", "}", "}", "}", "fclose", "(", "$", "logfilehandle", ")", ";", "return", "true", ";", "}" ]
The log function. It is not usually called directly. Usually it is better to call other functions from Psr\Log like debug, error, alert etc @param int $level This is message level number. Is inherited from Psr\Log @param string|array|object $message A log message. Can me array or object @param array $context Contains information about the message. A group of event. It is used to filter messages. Can have other information, like exception @return boolean to know if a message was logged or not
[ "The", "log", "function", ".", "It", "is", "not", "usually", "called", "directly", ".", "Usually", "it", "is", "better", "to", "call", "other", "functions", "from", "Psr", "\\", "Log", "like", "debug", "error", "alert", "etc" ]
ab7aa3c27f5190908bbd4d11451fd7332d9f920d
https://github.com/Gelembjuk/logger/blob/ab7aa3c27f5190908bbd4d11451fd7332d9f920d/src/Gelembjuk/Logger/FileLogger.php#L106-L174
8,352
pletfix/core
src/Application.php
Application.run
public static function run() { self::init(); /* * Register routes. */ call_user_func(function () { /** @noinspection PhpIncludeInspection */ require self::$basePath . '/boot/routes.php'; if (file_exists(self::$basePath . '/.manifest/plugins/routes.php')) { /** @noinspection PhpIncludeInspection */ include self::$basePath . '/.manifest/plugins/routes.php'; } }); /* * Dispatch the HTTP request and send the response to the browser. */ /** @var \Core\Services\Contracts\Router $router */ $router = DI::getInstance()->get('router'); $request = DI::getInstance()->get('request'); $response = $router->dispatch($request); $response->send(); }
php
public static function run() { self::init(); /* * Register routes. */ call_user_func(function () { /** @noinspection PhpIncludeInspection */ require self::$basePath . '/boot/routes.php'; if (file_exists(self::$basePath . '/.manifest/plugins/routes.php')) { /** @noinspection PhpIncludeInspection */ include self::$basePath . '/.manifest/plugins/routes.php'; } }); /* * Dispatch the HTTP request and send the response to the browser. */ /** @var \Core\Services\Contracts\Router $router */ $router = DI::getInstance()->get('router'); $request = DI::getInstance()->get('request'); $response = $router->dispatch($request); $response->send(); }
[ "public", "static", "function", "run", "(", ")", "{", "self", "::", "init", "(", ")", ";", "/*\n * Register routes.\n */", "call_user_func", "(", "function", "(", ")", "{", "/** @noinspection PhpIncludeInspection */", "require", "self", "::", "$", "basePath", ".", "'/boot/routes.php'", ";", "if", "(", "file_exists", "(", "self", "::", "$", "basePath", ".", "'/.manifest/plugins/routes.php'", ")", ")", "{", "/** @noinspection PhpIncludeInspection */", "include", "self", "::", "$", "basePath", ".", "'/.manifest/plugins/routes.php'", ";", "}", "}", ")", ";", "/*\n * Dispatch the HTTP request and send the response to the browser.\n */", "/** @var \\Core\\Services\\Contracts\\Router $router */", "$", "router", "=", "DI", "::", "getInstance", "(", ")", "->", "get", "(", "'router'", ")", ";", "$", "request", "=", "DI", "::", "getInstance", "(", ")", "->", "get", "(", "'request'", ")", ";", "$", "response", "=", "$", "router", "->", "dispatch", "(", "$", "request", ")", ";", "$", "response", "->", "send", "(", ")", ";", "}" ]
Start the application.
[ "Start", "the", "application", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Application.php#L66-L90
8,353
pletfix/core
src/Application.php
Application.console
public static function console() { self::init(); /* * Get the command line parameters. */ $argv = $_SERVER['argv']; array_shift($argv); // strip the application name ("console") /* * Dispatch the command line request. */ /** @var \Core\Services\Contracts\Command|false $command */ $command = DI::getInstance()->get('command-factory')->command($argv); $status = $command->run(); return $status; }
php
public static function console() { self::init(); /* * Get the command line parameters. */ $argv = $_SERVER['argv']; array_shift($argv); // strip the application name ("console") /* * Dispatch the command line request. */ /** @var \Core\Services\Contracts\Command|false $command */ $command = DI::getInstance()->get('command-factory')->command($argv); $status = $command->run(); return $status; }
[ "public", "static", "function", "console", "(", ")", "{", "self", "::", "init", "(", ")", ";", "/*\n * Get the command line parameters.\n */", "$", "argv", "=", "$", "_SERVER", "[", "'argv'", "]", ";", "array_shift", "(", "$", "argv", ")", ";", "// strip the application name (\"console\")", "/*\n * Dispatch the command line request.\n */", "/** @var \\Core\\Services\\Contracts\\Command|false $command */", "$", "command", "=", "DI", "::", "getInstance", "(", ")", "->", "get", "(", "'command-factory'", ")", "->", "command", "(", "$", "argv", ")", ";", "$", "status", "=", "$", "command", "->", "run", "(", ")", ";", "return", "$", "status", ";", "}" ]
Start a console. @return int Exit Status
[ "Start", "a", "console", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Application.php#L97-L115
8,354
ddehart/dilmun
src/Nabu/Autoloader.php
Autoloader.registerPackages
public function registerPackages($package, $path) { $this->updateLog("info", "Preparing package {$package} for registration with path {$path}."); $package = trim($package, "\\"); $package = $package . "\\"; $path = rtrim($path, DIRECTORY_SEPARATOR); $path = $path . "/"; $path_registered = $this->registrationExists($package, $path); if (!$path_registered) { $this->packages[$package][] = $path; $this->updateLog("info", "Registered index {$package} as {$path}"); } }
php
public function registerPackages($package, $path) { $this->updateLog("info", "Preparing package {$package} for registration with path {$path}."); $package = trim($package, "\\"); $package = $package . "\\"; $path = rtrim($path, DIRECTORY_SEPARATOR); $path = $path . "/"; $path_registered = $this->registrationExists($package, $path); if (!$path_registered) { $this->packages[$package][] = $path; $this->updateLog("info", "Registered index {$package} as {$path}"); } }
[ "public", "function", "registerPackages", "(", "$", "package", ",", "$", "path", ")", "{", "$", "this", "->", "updateLog", "(", "\"info\"", ",", "\"Preparing package {$package} for registration with path {$path}.\"", ")", ";", "$", "package", "=", "trim", "(", "$", "package", ",", "\"\\\\\"", ")", ";", "$", "package", "=", "$", "package", ".", "\"\\\\\"", ";", "$", "path", "=", "rtrim", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", ";", "$", "path", "=", "$", "path", ".", "\"/\"", ";", "$", "path_registered", "=", "$", "this", "->", "registrationExists", "(", "$", "package", ",", "$", "path", ")", ";", "if", "(", "!", "$", "path_registered", ")", "{", "$", "this", "->", "packages", "[", "$", "package", "]", "[", "]", "=", "$", "path", ";", "$", "this", "->", "updateLog", "(", "\"info\"", ",", "\"Registered index {$package} as {$path}\"", ")", ";", "}", "}" ]
Registers a given package with an associated path. Duplicate package/path combinations will not be re-registered. @param string $package The name of the package to be registered @param string $path The path to be associated with the registered package @return void
[ "Registers", "a", "given", "package", "with", "an", "associated", "path", "." ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Nabu/Autoloader.php#L39-L56
8,355
ddehart/dilmun
src/Nabu/Autoloader.php
Autoloader.includeClass
protected function includeClass($class) { $this->updateLog("info", "Setting up {$class} class for inclusion."); $class_bits = explode("\\", $class); $package = ""; $package_stack = array(); foreach ($class_bits as $bit) { $package = $package . $bit . "\\"; $package_registered = $this->packageRegistered($package); if ($package_registered) { $package_stack[] = $package; } } $this->loadPackageStack($class, $package_stack); }
php
protected function includeClass($class) { $this->updateLog("info", "Setting up {$class} class for inclusion."); $class_bits = explode("\\", $class); $package = ""; $package_stack = array(); foreach ($class_bits as $bit) { $package = $package . $bit . "\\"; $package_registered = $this->packageRegistered($package); if ($package_registered) { $package_stack[] = $package; } } $this->loadPackageStack($class, $package_stack); }
[ "protected", "function", "includeClass", "(", "$", "class", ")", "{", "$", "this", "->", "updateLog", "(", "\"info\"", ",", "\"Setting up {$class} class for inclusion.\"", ")", ";", "$", "class_bits", "=", "explode", "(", "\"\\\\\"", ",", "$", "class", ")", ";", "$", "package", "=", "\"\"", ";", "$", "package_stack", "=", "array", "(", ")", ";", "foreach", "(", "$", "class_bits", "as", "$", "bit", ")", "{", "$", "package", "=", "$", "package", ".", "$", "bit", ".", "\"\\\\\"", ";", "$", "package_registered", "=", "$", "this", "->", "packageRegistered", "(", "$", "package", ")", ";", "if", "(", "$", "package_registered", ")", "{", "$", "package_stack", "[", "]", "=", "$", "package", ";", "}", "}", "$", "this", "->", "loadPackageStack", "(", "$", "class", ",", "$", "package_stack", ")", ";", "}" ]
Includes the file corresponding with the class name to be autoloaded @param string $class Class name as defined by PHP autoloading @return void
[ "Includes", "the", "file", "corresponding", "with", "the", "class", "name", "to", "be", "autoloaded" ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Nabu/Autoloader.php#L75-L95
8,356
ddehart/dilmun
src/Nabu/Autoloader.php
Autoloader.loadPackageStack
protected function loadPackageStack($class, array $package_stack) { foreach ($package_stack as $package) { $package_length = strlen($package); $class_path = substr($class, $package_length); $this->updateLog("debug", "Found class path {$class_path} in {$class} given {$package}"); $package_loaded = $this->loadPackage($package, $class_path); if ($package_loaded) { $this->updateLog("info", "Loaded {$class_path} using package {$package}"); return true; } } $this->updateLog("alert", "No files found for {$class} in registered packages!"); return false; }
php
protected function loadPackageStack($class, array $package_stack) { foreach ($package_stack as $package) { $package_length = strlen($package); $class_path = substr($class, $package_length); $this->updateLog("debug", "Found class path {$class_path} in {$class} given {$package}"); $package_loaded = $this->loadPackage($package, $class_path); if ($package_loaded) { $this->updateLog("info", "Loaded {$class_path} using package {$package}"); return true; } } $this->updateLog("alert", "No files found for {$class} in registered packages!"); return false; }
[ "protected", "function", "loadPackageStack", "(", "$", "class", ",", "array", "$", "package_stack", ")", "{", "foreach", "(", "$", "package_stack", "as", "$", "package", ")", "{", "$", "package_length", "=", "strlen", "(", "$", "package", ")", ";", "$", "class_path", "=", "substr", "(", "$", "class", ",", "$", "package_length", ")", ";", "$", "this", "->", "updateLog", "(", "\"debug\"", ",", "\"Found class path {$class_path} in {$class} given {$package}\"", ")", ";", "$", "package_loaded", "=", "$", "this", "->", "loadPackage", "(", "$", "package", ",", "$", "class_path", ")", ";", "if", "(", "$", "package_loaded", ")", "{", "$", "this", "->", "updateLog", "(", "\"info\"", ",", "\"Loaded {$class_path} using package {$package}\"", ")", ";", "return", "true", ";", "}", "}", "$", "this", "->", "updateLog", "(", "\"alert\"", ",", "\"No files found for {$class} in registered packages!\"", ")", ";", "return", "false", ";", "}" ]
Attempts to load a class from a stack of packages @param string $class The fully-qualified class name @param array $package_stack A stack of packages for loading @return bool Returns true if the class was successfully loaded from the package stack Returns false if the class could not be loaded from the package stack
[ "Attempts", "to", "load", "a", "class", "from", "a", "stack", "of", "packages" ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Nabu/Autoloader.php#L106-L126
8,357
ddehart/dilmun
src/Nabu/Autoloader.php
Autoloader.loadPackage
protected function loadPackage($package_name, $class_name) { $this->updateLog("info", "Working on loading {$class_name} from {$package_name}"); $file_required = false; foreach ($this->packages[$package_name] as $path) { $converted_class = str_replace('\\', DIRECTORY_SEPARATOR, $class_name); $class_path = $path . $converted_class . ".php"; $this->updateLog("debug", "Class file path is {$class_path}"); $file_required = $this->requireFile($class_path); } return $file_required; }
php
protected function loadPackage($package_name, $class_name) { $this->updateLog("info", "Working on loading {$class_name} from {$package_name}"); $file_required = false; foreach ($this->packages[$package_name] as $path) { $converted_class = str_replace('\\', DIRECTORY_SEPARATOR, $class_name); $class_path = $path . $converted_class . ".php"; $this->updateLog("debug", "Class file path is {$class_path}"); $file_required = $this->requireFile($class_path); } return $file_required; }
[ "protected", "function", "loadPackage", "(", "$", "package_name", ",", "$", "class_name", ")", "{", "$", "this", "->", "updateLog", "(", "\"info\"", ",", "\"Working on loading {$class_name} from {$package_name}\"", ")", ";", "$", "file_required", "=", "false", ";", "foreach", "(", "$", "this", "->", "packages", "[", "$", "package_name", "]", "as", "$", "path", ")", "{", "$", "converted_class", "=", "str_replace", "(", "'\\\\'", ",", "DIRECTORY_SEPARATOR", ",", "$", "class_name", ")", ";", "$", "class_path", "=", "$", "path", ".", "$", "converted_class", ".", "\".php\"", ";", "$", "this", "->", "updateLog", "(", "\"debug\"", ",", "\"Class file path is {$class_path}\"", ")", ";", "$", "file_required", "=", "$", "this", "->", "requireFile", "(", "$", "class_path", ")", ";", "}", "return", "$", "file_required", ";", "}" ]
Loads a package based on registered paths associated with the package. @param string $package_name The name of the package in Vendor\Package format @param string $class_name The full, relative name of the class with the vendor and package names stripped @return bool The path to the class on success; otherwise false
[ "Loads", "a", "package", "based", "on", "registered", "paths", "associated", "with", "the", "package", "." ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Nabu/Autoloader.php#L136-L152
8,358
ddehart/dilmun
src/Nabu/Autoloader.php
Autoloader.packageRegistered
private function packageRegistered($package) { $package_registered = array_key_exists($package, $this->packages); if ($package_registered) { $this->updateLog("info", "Package {$package} is registered"); } else { $this->updateLog("info", "Package {$package} is not registered"); } return $package_registered; }
php
private function packageRegistered($package) { $package_registered = array_key_exists($package, $this->packages); if ($package_registered) { $this->updateLog("info", "Package {$package} is registered"); } else { $this->updateLog("info", "Package {$package} is not registered"); } return $package_registered; }
[ "private", "function", "packageRegistered", "(", "$", "package", ")", "{", "$", "package_registered", "=", "array_key_exists", "(", "$", "package", ",", "$", "this", "->", "packages", ")", ";", "if", "(", "$", "package_registered", ")", "{", "$", "this", "->", "updateLog", "(", "\"info\"", ",", "\"Package {$package} is registered\"", ")", ";", "}", "else", "{", "$", "this", "->", "updateLog", "(", "\"info\"", ",", "\"Package {$package} is not registered\"", ")", ";", "}", "return", "$", "package_registered", ";", "}" ]
Determines whether a given package is registered with the Autoloader @param string $package The package to check @return bool Returns true if the given package is registered Returns false if the given package is not registered
[ "Determines", "whether", "a", "given", "package", "is", "registered", "with", "the", "Autoloader" ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Nabu/Autoloader.php#L162-L173
8,359
ddehart/dilmun
src/Nabu/Autoloader.php
Autoloader.requireFile
private function requireFile($path) { if (file_exists($path)) { $this->updateLog("debug", "File {$path} exists; requiring file"); /** @noinspection PhpIncludeInspection */ require $path; $this->updateLog("info", "Completed loading {$path}"); return true; } else { $this->updateLog("debug", "File {$path} does not exist"); return false; } }
php
private function requireFile($path) { if (file_exists($path)) { $this->updateLog("debug", "File {$path} exists; requiring file"); /** @noinspection PhpIncludeInspection */ require $path; $this->updateLog("info", "Completed loading {$path}"); return true; } else { $this->updateLog("debug", "File {$path} does not exist"); return false; } }
[ "private", "function", "requireFile", "(", "$", "path", ")", "{", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "$", "this", "->", "updateLog", "(", "\"debug\"", ",", "\"File {$path} exists; requiring file\"", ")", ";", "/** @noinspection PhpIncludeInspection */", "require", "$", "path", ";", "$", "this", "->", "updateLog", "(", "\"info\"", ",", "\"Completed loading {$path}\"", ")", ";", "return", "true", ";", "}", "else", "{", "$", "this", "->", "updateLog", "(", "\"debug\"", ",", "\"File {$path} does not exist\"", ")", ";", "return", "false", ";", "}", "}" ]
Requires a file only if it existss @param string $path The path to the file for requiring @return bool Returns true if the file at the given path exists Returns false if the file at the given path does not exist
[ "Requires", "a", "file", "only", "if", "it", "existss" ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Nabu/Autoloader.php#L211-L227
8,360
znframework/package-language
Delete.php
Delete.all
public function all($app = NULL) : Bool { if( ! is_string($app) ) { if( $app === NULL ) { $MLFiles = Filesystem::getFiles($this->appdir, 'ml'); } elseif( is_array($app) ) { $MLFiles = $app; } else { return false; } $allMLFiles = []; if( ! empty($MLFiles) ) foreach( $MLFiles as $file ) { $removeExtension = str_replace($this->extension, '', $file); $this->all($removeExtension); } return true; } else { $createFile = $this->_langFile($app); if( is_file($createFile) ) { return unlink($createFile); } return false; } }
php
public function all($app = NULL) : Bool { if( ! is_string($app) ) { if( $app === NULL ) { $MLFiles = Filesystem::getFiles($this->appdir, 'ml'); } elseif( is_array($app) ) { $MLFiles = $app; } else { return false; } $allMLFiles = []; if( ! empty($MLFiles) ) foreach( $MLFiles as $file ) { $removeExtension = str_replace($this->extension, '', $file); $this->all($removeExtension); } return true; } else { $createFile = $this->_langFile($app); if( is_file($createFile) ) { return unlink($createFile); } return false; } }
[ "public", "function", "all", "(", "$", "app", "=", "NULL", ")", ":", "Bool", "{", "if", "(", "!", "is_string", "(", "$", "app", ")", ")", "{", "if", "(", "$", "app", "===", "NULL", ")", "{", "$", "MLFiles", "=", "Filesystem", "::", "getFiles", "(", "$", "this", "->", "appdir", ",", "'ml'", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "app", ")", ")", "{", "$", "MLFiles", "=", "$", "app", ";", "}", "else", "{", "return", "false", ";", "}", "$", "allMLFiles", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "MLFiles", ")", ")", "foreach", "(", "$", "MLFiles", "as", "$", "file", ")", "{", "$", "removeExtension", "=", "str_replace", "(", "$", "this", "->", "extension", ",", "''", ",", "$", "file", ")", ";", "$", "this", "->", "all", "(", "$", "removeExtension", ")", ";", "}", "return", "true", ";", "}", "else", "{", "$", "createFile", "=", "$", "this", "->", "_langFile", "(", "$", "app", ")", ";", "if", "(", "is_file", "(", "$", "createFile", ")", ")", "{", "return", "unlink", "(", "$", "createFile", ")", ";", "}", "return", "false", ";", "}", "}" ]
Delete all langauges keys @param string $app @return bool
[ "Delete", "all", "langauges", "keys" ]
f0fe3b9ec2ba1a69838da9af58ced5398ea9fb09
https://github.com/znframework/package-language/blob/f0fe3b9ec2ba1a69838da9af58ced5398ea9fb09/Delete.php#L62-L100
8,361
mszewcz/php-light-framework
src/Db/MySQL/AbstractMySQL.php
AbstractMySQL.getMicrotime
protected function getMicrotime(): float { list ($uSec, $sec) = \explode(' ', \microtime()); return ((float)$uSec + (float)$sec); }
php
protected function getMicrotime(): float { list ($uSec, $sec) = \explode(' ', \microtime()); return ((float)$uSec + (float)$sec); }
[ "protected", "function", "getMicrotime", "(", ")", ":", "float", "{", "list", "(", "$", "uSec", ",", "$", "sec", ")", "=", "\\", "explode", "(", "' '", ",", "\\", "microtime", "(", ")", ")", ";", "return", "(", "(", "float", ")", "$", "uSec", "+", "(", "float", ")", "$", "sec", ")", ";", "}" ]
Returns current server time in milliseconds. @return float
[ "Returns", "current", "server", "time", "in", "milliseconds", "." ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Db/MySQL/AbstractMySQL.php#L62-L66
8,362
mszewcz/php-light-framework
src/Db/MySQL/AbstractMySQL.php
AbstractMySQL.setError
protected function setError(int $errorType = 0, string $className = ''): void { $errorMessage = ''; if ($errorType == self::E_NO_CONNECTION) { $errorMessage = \sprintf( 'FATAL ERROR (%s): Cannot establish connection to database server.', $this->currentLink->connect_errno ); } elseif ($errorType == self::E_NO_DB_SELECTED) { $errorMessage = \sprintf( 'FATAL ERROR (%s): Cannot select database \'%s\'.', $this->currentLink->errno, $this->selectedDB ); } elseif ($errorType == self::E_NO_SQL) { $errorMessage = \sprintf( 'FATAL ERROR (%s): Query was empty.', $this->currentLink->errno ); } elseif ($errorType == self::E_ENGINE_ERROR) { $errorMessage = \sprintf( 'FATAL ERROR (%s): %s: %s', $this->currentLink->errno, $this->currentLink->error, $this->currentQuery ); } if ($this->logHandler !== null) { $this->logHandler->logError($errorMessage, $className); } if ($this->errorLevel == 'print') { $errorText = \sprintf('%s%s%s%s', $errorMessage, Tags::CRLF, Tags::br(), Tags::CRLF); echo filter_var($errorText, FILTER_DEFAULT); } if ($this->errorLevel == 'exception') { $this->closeConnection(); throw new RuntimeException($errorMessage); } }
php
protected function setError(int $errorType = 0, string $className = ''): void { $errorMessage = ''; if ($errorType == self::E_NO_CONNECTION) { $errorMessage = \sprintf( 'FATAL ERROR (%s): Cannot establish connection to database server.', $this->currentLink->connect_errno ); } elseif ($errorType == self::E_NO_DB_SELECTED) { $errorMessage = \sprintf( 'FATAL ERROR (%s): Cannot select database \'%s\'.', $this->currentLink->errno, $this->selectedDB ); } elseif ($errorType == self::E_NO_SQL) { $errorMessage = \sprintf( 'FATAL ERROR (%s): Query was empty.', $this->currentLink->errno ); } elseif ($errorType == self::E_ENGINE_ERROR) { $errorMessage = \sprintf( 'FATAL ERROR (%s): %s: %s', $this->currentLink->errno, $this->currentLink->error, $this->currentQuery ); } if ($this->logHandler !== null) { $this->logHandler->logError($errorMessage, $className); } if ($this->errorLevel == 'print') { $errorText = \sprintf('%s%s%s%s', $errorMessage, Tags::CRLF, Tags::br(), Tags::CRLF); echo filter_var($errorText, FILTER_DEFAULT); } if ($this->errorLevel == 'exception') { $this->closeConnection(); throw new RuntimeException($errorMessage); } }
[ "protected", "function", "setError", "(", "int", "$", "errorType", "=", "0", ",", "string", "$", "className", "=", "''", ")", ":", "void", "{", "$", "errorMessage", "=", "''", ";", "if", "(", "$", "errorType", "==", "self", "::", "E_NO_CONNECTION", ")", "{", "$", "errorMessage", "=", "\\", "sprintf", "(", "'FATAL ERROR (%s): Cannot establish connection to database server.'", ",", "$", "this", "->", "currentLink", "->", "connect_errno", ")", ";", "}", "elseif", "(", "$", "errorType", "==", "self", "::", "E_NO_DB_SELECTED", ")", "{", "$", "errorMessage", "=", "\\", "sprintf", "(", "'FATAL ERROR (%s): Cannot select database \\'%s\\'.'", ",", "$", "this", "->", "currentLink", "->", "errno", ",", "$", "this", "->", "selectedDB", ")", ";", "}", "elseif", "(", "$", "errorType", "==", "self", "::", "E_NO_SQL", ")", "{", "$", "errorMessage", "=", "\\", "sprintf", "(", "'FATAL ERROR (%s): Query was empty.'", ",", "$", "this", "->", "currentLink", "->", "errno", ")", ";", "}", "elseif", "(", "$", "errorType", "==", "self", "::", "E_ENGINE_ERROR", ")", "{", "$", "errorMessage", "=", "\\", "sprintf", "(", "'FATAL ERROR (%s): %s: %s'", ",", "$", "this", "->", "currentLink", "->", "errno", ",", "$", "this", "->", "currentLink", "->", "error", ",", "$", "this", "->", "currentQuery", ")", ";", "}", "if", "(", "$", "this", "->", "logHandler", "!==", "null", ")", "{", "$", "this", "->", "logHandler", "->", "logError", "(", "$", "errorMessage", ",", "$", "className", ")", ";", "}", "if", "(", "$", "this", "->", "errorLevel", "==", "'print'", ")", "{", "$", "errorText", "=", "\\", "sprintf", "(", "'%s%s%s%s'", ",", "$", "errorMessage", ",", "Tags", "::", "CRLF", ",", "Tags", "::", "br", "(", ")", ",", "Tags", "::", "CRLF", ")", ";", "echo", "filter_var", "(", "$", "errorText", ",", "FILTER_DEFAULT", ")", ";", "}", "if", "(", "$", "this", "->", "errorLevel", "==", "'exception'", ")", "{", "$", "this", "->", "closeConnection", "(", ")", ";", "throw", "new", "RuntimeException", "(", "$", "errorMessage", ")", ";", "}", "}" ]
Handles class errors. @param int $errorType @param string $className
[ "Handles", "class", "errors", "." ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Db/MySQL/AbstractMySQL.php#L74-L114
8,363
e-commerce-passaro/site
src/Site/Site.php
Site.toArray
public function toArray() { return array( 'id' => $this->getId(), 'nome' => $this->getNome(), 'logo' => $this->getLogo(), 'intro' => $this->getIntro(), 'copyright' => $this->getCopyright() ); }
php
public function toArray() { return array( 'id' => $this->getId(), 'nome' => $this->getNome(), 'logo' => $this->getLogo(), 'intro' => $this->getIntro(), 'copyright' => $this->getCopyright() ); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array", "(", "'id'", "=>", "$", "this", "->", "getId", "(", ")", ",", "'nome'", "=>", "$", "this", "->", "getNome", "(", ")", ",", "'logo'", "=>", "$", "this", "->", "getLogo", "(", ")", ",", "'intro'", "=>", "$", "this", "->", "getIntro", "(", ")", ",", "'copyright'", "=>", "$", "this", "->", "getCopyright", "(", ")", ")", ";", "}" ]
Obtem a estrutura da entity Site em formato array @return array
[ "Obtem", "a", "estrutura", "da", "entity", "Site", "em", "formato", "array" ]
384e58cf0d3d6a56edb73b458f8bff38ec370822
https://github.com/e-commerce-passaro/site/blob/384e58cf0d3d6a56edb73b458f8bff38ec370822/src/Site/Site.php#L114-L123
8,364
headzoo/core
src/Headzoo/Core/ConfigurableCallable.php
ConfigurableCallable.invoke
public function invoke() { $args = func_get_args(); $retries = 0; $exception = null; $return = null; /** @noinspection PhpUnusedLocalVariableInspection */ $sc = SmartCallable::factory("restore_error_handler"); set_error_handler(function($type, $message, $file, $line) { throw PHPException::factory( $message, $type, $file, $line ); }); do { try { $exception = null; $return = call_user_func_array($this->callback, $args); } catch (Exception $exception) { $this->logger->error($exception->getMessage()); } $action = $this->matchesCondition($return, $exception); if ("retry" == $action) { $retries++; } } while("retry" == $action && ($retries < $this->max_retries || -1 === $this->max_retries)); if ($exception && "return" !== $action) { throw $exception; } if ($this->filter) { $return = call_user_func($this->filter, $return); } return $return; }
php
public function invoke() { $args = func_get_args(); $retries = 0; $exception = null; $return = null; /** @noinspection PhpUnusedLocalVariableInspection */ $sc = SmartCallable::factory("restore_error_handler"); set_error_handler(function($type, $message, $file, $line) { throw PHPException::factory( $message, $type, $file, $line ); }); do { try { $exception = null; $return = call_user_func_array($this->callback, $args); } catch (Exception $exception) { $this->logger->error($exception->getMessage()); } $action = $this->matchesCondition($return, $exception); if ("retry" == $action) { $retries++; } } while("retry" == $action && ($retries < $this->max_retries || -1 === $this->max_retries)); if ($exception && "return" !== $action) { throw $exception; } if ($this->filter) { $return = call_user_func($this->filter, $return); } return $return; }
[ "public", "function", "invoke", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "retries", "=", "0", ";", "$", "exception", "=", "null", ";", "$", "return", "=", "null", ";", "/** @noinspection PhpUnusedLocalVariableInspection */", "$", "sc", "=", "SmartCallable", "::", "factory", "(", "\"restore_error_handler\"", ")", ";", "set_error_handler", "(", "function", "(", "$", "type", ",", "$", "message", ",", "$", "file", ",", "$", "line", ")", "{", "throw", "PHPException", "::", "factory", "(", "$", "message", ",", "$", "type", ",", "$", "file", ",", "$", "line", ")", ";", "}", ")", ";", "do", "{", "try", "{", "$", "exception", "=", "null", ";", "$", "return", "=", "call_user_func_array", "(", "$", "this", "->", "callback", ",", "$", "args", ")", ";", "}", "catch", "(", "Exception", "$", "exception", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "$", "exception", "->", "getMessage", "(", ")", ")", ";", "}", "$", "action", "=", "$", "this", "->", "matchesCondition", "(", "$", "return", ",", "$", "exception", ")", ";", "if", "(", "\"retry\"", "==", "$", "action", ")", "{", "$", "retries", "++", ";", "}", "}", "while", "(", "\"retry\"", "==", "$", "action", "&&", "(", "$", "retries", "<", "$", "this", "->", "max_retries", "||", "-", "1", "===", "$", "this", "->", "max_retries", ")", ")", ";", "if", "(", "$", "exception", "&&", "\"return\"", "!==", "$", "action", ")", "{", "throw", "$", "exception", ";", "}", "if", "(", "$", "this", "->", "filter", ")", "{", "$", "return", "=", "call_user_func", "(", "$", "this", "->", "filter", ",", "$", "return", ")", ";", "}", "return", "$", "return", ";", "}" ]
Calls the function
[ "Calls", "the", "function" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ConfigurableCallable.php#L406-L445
8,365
headzoo/core
src/Headzoo/Core/ConfigurableCallable.php
ConfigurableCallable.matchesCondition
protected function matchesCondition($return, $exception = null) { $matched = false; foreach($this->conditions as $expression) { if ("isExceptionOf" === $expression["compare"]) { $matched = Comparator::isInstanceOf($exception, $expression["value"]); } else { $matched = Comparator::$expression["compare"]($return, $expression["value"]); } if ($matched) { $matched = $expression["action"]; break; } } return $matched; }
php
protected function matchesCondition($return, $exception = null) { $matched = false; foreach($this->conditions as $expression) { if ("isExceptionOf" === $expression["compare"]) { $matched = Comparator::isInstanceOf($exception, $expression["value"]); } else { $matched = Comparator::$expression["compare"]($return, $expression["value"]); } if ($matched) { $matched = $expression["action"]; break; } } return $matched; }
[ "protected", "function", "matchesCondition", "(", "$", "return", ",", "$", "exception", "=", "null", ")", "{", "$", "matched", "=", "false", ";", "foreach", "(", "$", "this", "->", "conditions", "as", "$", "expression", ")", "{", "if", "(", "\"isExceptionOf\"", "===", "$", "expression", "[", "\"compare\"", "]", ")", "{", "$", "matched", "=", "Comparator", "::", "isInstanceOf", "(", "$", "exception", ",", "$", "expression", "[", "\"value\"", "]", ")", ";", "}", "else", "{", "$", "matched", "=", "Comparator", "::", "$", "expression", "[", "\"compare\"", "]", "(", "$", "return", ",", "$", "expression", "[", "\"value\"", "]", ")", ";", "}", "if", "(", "$", "matched", ")", "{", "$", "matched", "=", "$", "expression", "[", "\"action\"", "]", ";", "break", ";", "}", "}", "return", "$", "matched", ";", "}" ]
Returns which condition the value matches @param mixed $return The callable return value or thrown exception @param Exception $exception Any exception that was thrown @return null|string
[ "Returns", "which", "condition", "the", "value", "matches" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/ConfigurableCallable.php#L455-L471
8,366
BlackBoxRepo/PandoContactInfoBundle
Model/RegionTrait.php
RegionTrait.getRegionZonesByTypeName
private function getRegionZonesByTypeName($typeName) { return $this->getRegionZones()->filter( function($regionZone) use ($typeName) { return $regionZone->getType()->getName() === $typeName; } ); }
php
private function getRegionZonesByTypeName($typeName) { return $this->getRegionZones()->filter( function($regionZone) use ($typeName) { return $regionZone->getType()->getName() === $typeName; } ); }
[ "private", "function", "getRegionZonesByTypeName", "(", "$", "typeName", ")", "{", "return", "$", "this", "->", "getRegionZones", "(", ")", "->", "filter", "(", "function", "(", "$", "regionZone", ")", "use", "(", "$", "typeName", ")", "{", "return", "$", "regionZone", "->", "getType", "(", ")", "->", "getName", "(", ")", "===", "$", "typeName", ";", "}", ")", ";", "}" ]
Returns all the RegionZones of given type that the Region is attached to @return ArrayCollection<RegionZone>
[ "Returns", "all", "the", "RegionZones", "of", "given", "type", "that", "the", "Region", "is", "attached", "to" ]
7f47f249943f7d4a39afc8068bd8b743c048b7ac
https://github.com/BlackBoxRepo/PandoContactInfoBundle/blob/7f47f249943f7d4a39afc8068bd8b743c048b7ac/Model/RegionTrait.php#L110-L117
8,367
fortifi/sdk
api/Property/Responses/Definitions/PropertyDefinitionResponse.php
PropertyDefinitionResponse.hydrate
public function hydrate($data) { parent::hydrate($data); $this->values = ValueAs::arr($this->values); }
php
public function hydrate($data) { parent::hydrate($data); $this->values = ValueAs::arr($this->values); }
[ "public", "function", "hydrate", "(", "$", "data", ")", "{", "parent", "::", "hydrate", "(", "$", "data", ")", ";", "$", "this", "->", "values", "=", "ValueAs", "::", "arr", "(", "$", "this", "->", "values", ")", ";", "}" ]
Hydrate the public properties @param $data
[ "Hydrate", "the", "public", "properties" ]
4d0471c72c7954271c692d32265fd42f698392e4
https://github.com/fortifi/sdk/blob/4d0471c72c7954271c692d32265fd42f698392e4/api/Property/Responses/Definitions/PropertyDefinitionResponse.php#L30-L34
8,368
zicht/z-plugin-solr
solr/Plugin.php
Plugin.call
protected function call(Container $container, $id, ...$args) { $ret = $container->resolve($id); if (is_array($ret) && $ret[0] instanceof \Closure && is_bool($ret[1])) { return ($ret[1]) ? $ret[0]($container, ...$args) : $ret[0](...$args); } return null; }
php
protected function call(Container $container, $id, ...$args) { $ret = $container->resolve($id); if (is_array($ret) && $ret[0] instanceof \Closure && is_bool($ret[1])) { return ($ret[1]) ? $ret[0]($container, ...$args) : $ret[0](...$args); } return null; }
[ "protected", "function", "call", "(", "Container", "$", "container", ",", "$", "id", ",", "...", "$", "args", ")", "{", "$", "ret", "=", "$", "container", "->", "resolve", "(", "$", "id", ")", ";", "if", "(", "is_array", "(", "$", "ret", ")", "&&", "$", "ret", "[", "0", "]", "instanceof", "\\", "Closure", "&&", "is_bool", "(", "$", "ret", "[", "1", "]", ")", ")", "{", "return", "(", "$", "ret", "[", "1", "]", ")", "?", "$", "ret", "[", "0", "]", "(", "$", "container", ",", "...", "$", "args", ")", ":", "$", "ret", "[", "0", "]", "(", "...", "$", "args", ")", ";", "}", "return", "null", ";", "}" ]
Small helper for calling declared methods with arguments. @param Container $container @param array|string $id @param mixed ...$args @return mixed
[ "Small", "helper", "for", "calling", "declared", "methods", "with", "arguments", "." ]
dcc6586801317b720550f662a7523c68147fa7e6
https://github.com/zicht/z-plugin-solr/blob/dcc6586801317b720550f662a7523c68147fa7e6/solr/Plugin.php#L50-L59
8,369
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation.forge
public static function forge($fieldset = 'default') { if (is_string($fieldset)) { ($set = \Fieldset::instance($fieldset)) and $fieldset = $set; } if ($fieldset instanceof Fieldset) { if ($fieldset->validation(false) != null) { throw new \DomainException('Form instance already exists, cannot be recreated. Use instance() instead of forge() to retrieve the existing instance.'); } } return new static($fieldset); }
php
public static function forge($fieldset = 'default') { if (is_string($fieldset)) { ($set = \Fieldset::instance($fieldset)) and $fieldset = $set; } if ($fieldset instanceof Fieldset) { if ($fieldset->validation(false) != null) { throw new \DomainException('Form instance already exists, cannot be recreated. Use instance() instead of forge() to retrieve the existing instance.'); } } return new static($fieldset); }
[ "public", "static", "function", "forge", "(", "$", "fieldset", "=", "'default'", ")", "{", "if", "(", "is_string", "(", "$", "fieldset", ")", ")", "{", "(", "$", "set", "=", "\\", "Fieldset", "::", "instance", "(", "$", "fieldset", ")", ")", "and", "$", "fieldset", "=", "$", "set", ";", "}", "if", "(", "$", "fieldset", "instanceof", "Fieldset", ")", "{", "if", "(", "$", "fieldset", "->", "validation", "(", "false", ")", "!=", "null", ")", "{", "throw", "new", "\\", "DomainException", "(", "'Form instance already exists, cannot be recreated. Use instance() instead of forge() to retrieve the existing instance.'", ")", ";", "}", "}", "return", "new", "static", "(", "$", "fieldset", ")", ";", "}" ]
Gets a new instance of the Validation class. @param string The name or instance of the Fieldset to link to @return Validation
[ "Gets", "a", "new", "instance", "of", "the", "Validation", "class", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L46-L62
8,370
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation.set_message
public function set_message($rule, $message) { if ($message !== null) { $this->error_messages[$rule] = $message; } else { unset($this->error_messages[$rule]); } return $this; }
php
public function set_message($rule, $message) { if ($message !== null) { $this->error_messages[$rule] = $message; } else { unset($this->error_messages[$rule]); } return $this; }
[ "public", "function", "set_message", "(", "$", "rule", ",", "$", "message", ")", "{", "if", "(", "$", "message", "!==", "null", ")", "{", "$", "this", "->", "error_messages", "[", "$", "rule", "]", "=", "$", "message", ";", "}", "else", "{", "unset", "(", "$", "this", "->", "error_messages", "[", "$", "rule", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
This will overwrite lang file messages for this validation instance @param string @param string @return Validation this, to allow chaining
[ "This", "will", "overwrite", "lang", "file", "messages", "for", "this", "validation", "instance" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L218-L230
8,371
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation.get_message
public function get_message($rule) { if ( ! array_key_exists($rule, $this->error_messages)) { return false; } return $this->error_messages[$rule]; }
php
public function get_message($rule) { if ( ! array_key_exists($rule, $this->error_messages)) { return false; } return $this->error_messages[$rule]; }
[ "public", "function", "get_message", "(", "$", "rule", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "rule", ",", "$", "this", "->", "error_messages", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "error_messages", "[", "$", "rule", "]", ";", "}" ]
Fetches a specific error message for this validation instance @param string @return string
[ "Fetches", "a", "specific", "error", "message", "for", "this", "validation", "instance" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L238-L246
8,372
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation._find_rule
protected function _find_rule($callback) { // Rules are validated and only accepted when given as an array consisting of // array(callback, params) or just callbacks in an array. if (is_string($callback)) { $callback_method = '_validation_'.$callback; foreach ($this->callables as $callback_class) { if (method_exists($callback_class, $callback_method)) { return array($callback => array($callback_class, $callback_method)); } } } // when no callable function was found, try regular callbacks if (is_callable($callback)) { if ($callback instanceof \Closure) { $callback_name = 'closure'; } elseif (is_array($callback)) { $callback_name = preg_replace('#^([a-z_]*\\\\)*#i', '', is_object($callback[0]) ? get_class($callback[0]) : $callback[0]).':'.$callback[1]; } else { $callback_name = preg_replace('#^([a-z_]*\\\\)*#i', '', str_replace('::', ':', $callback)); } return array($callback_name => $callback); } elseif (is_array($callback) and is_callable(reset($callback))) { return $callback; } else { $string = ! is_array($callback) ? $callback : (is_object(@$callback[0]) ? get_class(@$callback[0]).'->'.@$callback[1] : @$callback[0].'::'.@$callback[1]); \Error::notice('Invalid rule "'.$string.'" passed to Validation, not used.'); return false; } }
php
protected function _find_rule($callback) { // Rules are validated and only accepted when given as an array consisting of // array(callback, params) or just callbacks in an array. if (is_string($callback)) { $callback_method = '_validation_'.$callback; foreach ($this->callables as $callback_class) { if (method_exists($callback_class, $callback_method)) { return array($callback => array($callback_class, $callback_method)); } } } // when no callable function was found, try regular callbacks if (is_callable($callback)) { if ($callback instanceof \Closure) { $callback_name = 'closure'; } elseif (is_array($callback)) { $callback_name = preg_replace('#^([a-z_]*\\\\)*#i', '', is_object($callback[0]) ? get_class($callback[0]) : $callback[0]).':'.$callback[1]; } else { $callback_name = preg_replace('#^([a-z_]*\\\\)*#i', '', str_replace('::', ':', $callback)); } return array($callback_name => $callback); } elseif (is_array($callback) and is_callable(reset($callback))) { return $callback; } else { $string = ! is_array($callback) ? $callback : (is_object(@$callback[0]) ? get_class(@$callback[0]).'->'.@$callback[1] : @$callback[0].'::'.@$callback[1]); \Error::notice('Invalid rule "'.$string.'" passed to Validation, not used.'); return false; } }
[ "protected", "function", "_find_rule", "(", "$", "callback", ")", "{", "// Rules are validated and only accepted when given as an array consisting of", "// array(callback, params) or just callbacks in an array.", "if", "(", "is_string", "(", "$", "callback", ")", ")", "{", "$", "callback_method", "=", "'_validation_'", ".", "$", "callback", ";", "foreach", "(", "$", "this", "->", "callables", "as", "$", "callback_class", ")", "{", "if", "(", "method_exists", "(", "$", "callback_class", ",", "$", "callback_method", ")", ")", "{", "return", "array", "(", "$", "callback", "=>", "array", "(", "$", "callback_class", ",", "$", "callback_method", ")", ")", ";", "}", "}", "}", "// when no callable function was found, try regular callbacks", "if", "(", "is_callable", "(", "$", "callback", ")", ")", "{", "if", "(", "$", "callback", "instanceof", "\\", "Closure", ")", "{", "$", "callback_name", "=", "'closure'", ";", "}", "elseif", "(", "is_array", "(", "$", "callback", ")", ")", "{", "$", "callback_name", "=", "preg_replace", "(", "'#^([a-z_]*\\\\\\\\)*#i'", ",", "''", ",", "is_object", "(", "$", "callback", "[", "0", "]", ")", "?", "get_class", "(", "$", "callback", "[", "0", "]", ")", ":", "$", "callback", "[", "0", "]", ")", ".", "':'", ".", "$", "callback", "[", "1", "]", ";", "}", "else", "{", "$", "callback_name", "=", "preg_replace", "(", "'#^([a-z_]*\\\\\\\\)*#i'", ",", "''", ",", "str_replace", "(", "'::'", ",", "':'", ",", "$", "callback", ")", ")", ";", "}", "return", "array", "(", "$", "callback_name", "=>", "$", "callback", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "callback", ")", "and", "is_callable", "(", "reset", "(", "$", "callback", ")", ")", ")", "{", "return", "$", "callback", ";", "}", "else", "{", "$", "string", "=", "!", "is_array", "(", "$", "callback", ")", "?", "$", "callback", ":", "(", "is_object", "(", "@", "$", "callback", "[", "0", "]", ")", "?", "get_class", "(", "@", "$", "callback", "[", "0", "]", ")", ".", "'->'", ".", "@", "$", "callback", "[", "1", "]", ":", "@", "$", "callback", "[", "0", "]", ".", "'::'", ".", "@", "$", "callback", "[", "1", "]", ")", ";", "\\", "Error", "::", "notice", "(", "'Invalid rule \"'", ".", "$", "string", ".", "'\" passed to Validation, not used.'", ")", ";", "return", "false", ";", "}", "}" ]
Takes the rule input and formats it into a name & callback @param string|array short rule to be called on Validation callables array or full callback @return array|bool rule array or false when it fails to find something callable
[ "Takes", "the", "rule", "input", "and", "formats", "it", "into", "a", "name", "&", "callback" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L408-L456
8,373
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation.input
public function input($key = null, $default = null) { if ($key === null) { return $this->input; } // key transformation from form array to dot notation if (strpos($key,'[') !== false) { $key = str_replace(array('[', ']'),array('.', ''),$key); } // if we don't have this key if ( ! array_key_exists($key, $this->input)) { // it might be in dot-notation if (strpos($key,'.') !== false) { // check the input first if (($result = \Arr::get($this->input, $key, null)) !== null) { $this->input[$key] = $result; } else { $this->input[$key] = $this->global_input_fallback ? \Arr::get(\Input::param(), $key, $default) : $default; } } else { // do a fallback to global input if needed, or use the provided default $this->input[$key] = $this->global_input_fallback ? \Input::param($key, $default) : $default; } } return $this->input[$key]; }
php
public function input($key = null, $default = null) { if ($key === null) { return $this->input; } // key transformation from form array to dot notation if (strpos($key,'[') !== false) { $key = str_replace(array('[', ']'),array('.', ''),$key); } // if we don't have this key if ( ! array_key_exists($key, $this->input)) { // it might be in dot-notation if (strpos($key,'.') !== false) { // check the input first if (($result = \Arr::get($this->input, $key, null)) !== null) { $this->input[$key] = $result; } else { $this->input[$key] = $this->global_input_fallback ? \Arr::get(\Input::param(), $key, $default) : $default; } } else { // do a fallback to global input if needed, or use the provided default $this->input[$key] = $this->global_input_fallback ? \Input::param($key, $default) : $default; } } return $this->input[$key]; }
[ "public", "function", "input", "(", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "$", "key", "===", "null", ")", "{", "return", "$", "this", "->", "input", ";", "}", "// key transformation from form array to dot notation", "if", "(", "strpos", "(", "$", "key", ",", "'['", ")", "!==", "false", ")", "{", "$", "key", "=", "str_replace", "(", "array", "(", "'['", ",", "']'", ")", ",", "array", "(", "'.'", ",", "''", ")", ",", "$", "key", ")", ";", "}", "// if we don't have this key", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "input", ")", ")", "{", "// it might be in dot-notation", "if", "(", "strpos", "(", "$", "key", ",", "'.'", ")", "!==", "false", ")", "{", "// check the input first", "if", "(", "(", "$", "result", "=", "\\", "Arr", "::", "get", "(", "$", "this", "->", "input", ",", "$", "key", ",", "null", ")", ")", "!==", "null", ")", "{", "$", "this", "->", "input", "[", "$", "key", "]", "=", "$", "result", ";", "}", "else", "{", "$", "this", "->", "input", "[", "$", "key", "]", "=", "$", "this", "->", "global_input_fallback", "?", "\\", "Arr", "::", "get", "(", "\\", "Input", "::", "param", "(", ")", ",", "$", "key", ",", "$", "default", ")", ":", "$", "default", ";", "}", "}", "else", "{", "// do a fallback to global input if needed, or use the provided default", "$", "this", "->", "input", "[", "$", "key", "]", "=", "$", "this", "->", "global_input_fallback", "?", "\\", "Input", "::", "param", "(", "$", "key", ",", "$", "default", ")", ":", "$", "default", ";", "}", "}", "return", "$", "this", "->", "input", "[", "$", "key", "]", ";", "}" ]
Fetches the input value from either post or given input @param string @param mixed @return mixed|array the input value or full input values array
[ "Fetches", "the", "input", "value", "from", "either", "post", "or", "given", "input" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L495-L532
8,374
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation.error_message
public function error_message($field = null, $default = false) { if ($field === null) { $messages = array(); foreach ($this->error() as $field => $e) { $messages[$field] = $e->get_message(); } return $messages; } return array_key_exists($field, $this->errors) ? $this->errors[$field]->get_message() : $default; }
php
public function error_message($field = null, $default = false) { if ($field === null) { $messages = array(); foreach ($this->error() as $field => $e) { $messages[$field] = $e->get_message(); } return $messages; } return array_key_exists($field, $this->errors) ? $this->errors[$field]->get_message() : $default; }
[ "public", "function", "error_message", "(", "$", "field", "=", "null", ",", "$", "default", "=", "false", ")", "{", "if", "(", "$", "field", "===", "null", ")", "{", "$", "messages", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "error", "(", ")", "as", "$", "field", "=>", "$", "e", ")", "{", "$", "messages", "[", "$", "field", "]", "=", "$", "e", "->", "get_message", "(", ")", ";", "}", "return", "$", "messages", ";", "}", "return", "array_key_exists", "(", "$", "field", ",", "$", "this", "->", "errors", ")", "?", "$", "this", "->", "errors", "[", "$", "field", "]", "->", "get_message", "(", ")", ":", "$", "default", ";", "}" ]
Return error message Return specific error message or all error messages thrown during validation @param string fieldname @param mixed value to return when not validated @return string|array the error message or full array of error messages
[ "Return", "error", "message" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L581-L594
8,375
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation._validation_match_value
public function _validation_match_value($val, $compare, $strict = false) { // first try direct match if ($this->_empty($val) || $val === $compare || ( ! $strict && $val == $compare)) { return true; } // allow multiple input for comparison if (is_array($compare)) { foreach($compare as $c) { if ($val === $c || ( ! $strict && $val == $c)) { return true; } } } // all is lost, return failure return false; }
php
public function _validation_match_value($val, $compare, $strict = false) { // first try direct match if ($this->_empty($val) || $val === $compare || ( ! $strict && $val == $compare)) { return true; } // allow multiple input for comparison if (is_array($compare)) { foreach($compare as $c) { if ($val === $c || ( ! $strict && $val == $c)) { return true; } } } // all is lost, return failure return false; }
[ "public", "function", "_validation_match_value", "(", "$", "val", ",", "$", "compare", ",", "$", "strict", "=", "false", ")", "{", "// first try direct match", "if", "(", "$", "this", "->", "_empty", "(", "$", "val", ")", "||", "$", "val", "===", "$", "compare", "||", "(", "!", "$", "strict", "&&", "$", "val", "==", "$", "compare", ")", ")", "{", "return", "true", ";", "}", "// allow multiple input for comparison", "if", "(", "is_array", "(", "$", "compare", ")", ")", "{", "foreach", "(", "$", "compare", "as", "$", "c", ")", "{", "if", "(", "$", "val", "===", "$", "c", "||", "(", "!", "$", "strict", "&&", "$", "val", "==", "$", "c", ")", ")", "{", "return", "true", ";", "}", "}", "}", "// all is lost, return failure", "return", "false", ";", "}" ]
Match value against comparison input @param mixed @param mixed @param bool whether to do type comparison @return bool
[ "Match", "value", "against", "comparison", "input" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L717-L739
8,376
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation._validation_match_collection
public function _validation_match_collection($val, $collection = array()) { if ( ! is_array($collection)) { $collection = func_get_args(); array_shift($collection); } return in_array($val, $collection); }
php
public function _validation_match_collection($val, $collection = array()) { if ( ! is_array($collection)) { $collection = func_get_args(); array_shift($collection); } return in_array($val, $collection); }
[ "public", "function", "_validation_match_collection", "(", "$", "val", ",", "$", "collection", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "collection", ")", ")", "{", "$", "collection", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "collection", ")", ";", "}", "return", "in_array", "(", "$", "val", ",", "$", "collection", ")", ";", "}" ]
Match against an array of values @param string @param array @return bool
[ "Match", "against", "an", "array", "of", "values" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L779-L788
8,377
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation._validation_min_length
public function _validation_min_length($val, $length) { return $this->_empty($val) || \Str::length($val) >= $length; }
php
public function _validation_min_length($val, $length) { return $this->_empty($val) || \Str::length($val) >= $length; }
[ "public", "function", "_validation_min_length", "(", "$", "val", ",", "$", "length", ")", "{", "return", "$", "this", "->", "_empty", "(", "$", "val", ")", "||", "\\", "Str", "::", "length", "(", "$", "val", ")", ">=", "$", "length", ";", "}" ]
Minimum string length @param string @param int @return bool
[ "Minimum", "string", "length" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L797-L800
8,378
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation._validation_max_length
public function _validation_max_length($val, $length) { return $this->_empty($val) || \Str::length($val) <= $length; }
php
public function _validation_max_length($val, $length) { return $this->_empty($val) || \Str::length($val) <= $length; }
[ "public", "function", "_validation_max_length", "(", "$", "val", ",", "$", "length", ")", "{", "return", "$", "this", "->", "_empty", "(", "$", "val", ")", "||", "\\", "Str", "::", "length", "(", "$", "val", ")", "<=", "$", "length", ";", "}" ]
Maximum string length @param string @param int @return bool
[ "Maximum", "string", "length" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L809-L812
8,379
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation._validation_exact_length
public function _validation_exact_length($val, $length) { return $this->_empty($val) || \Str::length($val) == $length; }
php
public function _validation_exact_length($val, $length) { return $this->_empty($val) || \Str::length($val) == $length; }
[ "public", "function", "_validation_exact_length", "(", "$", "val", ",", "$", "length", ")", "{", "return", "$", "this", "->", "_empty", "(", "$", "val", ")", "||", "\\", "Str", "::", "length", "(", "$", "val", ")", "==", "$", "length", ";", "}" ]
Exact string length @param string @param int @return bool
[ "Exact", "string", "length" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L821-L824
8,380
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation._validation_numeric_min
public function _validation_numeric_min($val, $min_val) { return $this->_empty($val) || floatval($val) >= floatval($min_val); }
php
public function _validation_numeric_min($val, $min_val) { return $this->_empty($val) || floatval($val) >= floatval($min_val); }
[ "public", "function", "_validation_numeric_min", "(", "$", "val", ",", "$", "min_val", ")", "{", "return", "$", "this", "->", "_empty", "(", "$", "val", ")", "||", "floatval", "(", "$", "val", ")", ">=", "floatval", "(", "$", "min_val", ")", ";", "}" ]
Checks whether numeric input has a minimum value @param string|float|int @param float|int @return bool
[ "Checks", "whether", "numeric", "input", "has", "a", "minimum", "value" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L967-L970
8,381
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation._validation_numeric_max
public function _validation_numeric_max($val, $max_val) { return $this->_empty($val) || floatval($val) <= floatval($max_val); }
php
public function _validation_numeric_max($val, $max_val) { return $this->_empty($val) || floatval($val) <= floatval($max_val); }
[ "public", "function", "_validation_numeric_max", "(", "$", "val", ",", "$", "max_val", ")", "{", "return", "$", "this", "->", "_empty", "(", "$", "val", ")", "||", "floatval", "(", "$", "val", ")", "<=", "floatval", "(", "$", "max_val", ")", ";", "}" ]
Checks whether numeric input has a maximum value @param string|float|int @param float|int @return bool
[ "Checks", "whether", "numeric", "input", "has", "a", "maximum", "value" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L979-L982
8,382
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation._validation_numeric_between
public function _validation_numeric_between($val, $min_val, $max_val) { return $this->_empty($val) or (floatval($val) >= floatval($min_val) and floatval($val) <= floatval($max_val)); }
php
public function _validation_numeric_between($val, $min_val, $max_val) { return $this->_empty($val) or (floatval($val) >= floatval($min_val) and floatval($val) <= floatval($max_val)); }
[ "public", "function", "_validation_numeric_between", "(", "$", "val", ",", "$", "min_val", ",", "$", "max_val", ")", "{", "return", "$", "this", "->", "_empty", "(", "$", "val", ")", "or", "(", "floatval", "(", "$", "val", ")", ">=", "floatval", "(", "$", "min_val", ")", "and", "floatval", "(", "$", "val", ")", "<=", "floatval", "(", "$", "max_val", ")", ")", ";", "}" ]
Checks whether numeric input is between a minimum and a maximum value @param string|float|int @param float|int @param float|int @return bool
[ "Checks", "whether", "numeric", "input", "is", "between", "a", "minimum", "and", "a", "maximum", "value" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L992-L995
8,383
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation._validation_required_with
public function _validation_required_with($val, $field) { if ( ! $this->_empty($this->input($field)) and $this->_empty($val)) { $validating = $this->active_field(); throw new \Validation_Error($validating, $val, array('required_with' => array($this->field($field))), array($this->field($field)->label)); } return true; }
php
public function _validation_required_with($val, $field) { if ( ! $this->_empty($this->input($field)) and $this->_empty($val)) { $validating = $this->active_field(); throw new \Validation_Error($validating, $val, array('required_with' => array($this->field($field))), array($this->field($field)->label)); } return true; }
[ "public", "function", "_validation_required_with", "(", "$", "val", ",", "$", "field", ")", "{", "if", "(", "!", "$", "this", "->", "_empty", "(", "$", "this", "->", "input", "(", "$", "field", ")", ")", "and", "$", "this", "->", "_empty", "(", "$", "val", ")", ")", "{", "$", "validating", "=", "$", "this", "->", "active_field", "(", ")", ";", "throw", "new", "\\", "Validation_Error", "(", "$", "validating", ",", "$", "val", ",", "array", "(", "'required_with'", "=>", "array", "(", "$", "this", "->", "field", "(", "$", "field", ")", ")", ")", ",", "array", "(", "$", "this", "->", "field", "(", "$", "field", ")", "->", "label", ")", ")", ";", "}", "return", "true", ";", "}" ]
Conditionally requires completion of current field based on completion of another field @param mixed @param string @return bool
[ "Conditionally", "requires", "completion", "of", "current", "field", "based", "on", "completion", "of", "another", "field" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L1004-L1013
8,384
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/validation.php
Validation._validation_valid_date
public function _validation_valid_date($val, $format = null, $strict = true) { if ($this->_empty($val)) { return true; } if ($format) { $parsed = date_parse_from_format($format, $val); } else { $parsed = date_parse($val); } if (\Arr::get($parsed, 'error_count', 1) + ($strict ? \Arr::get($parsed, 'warning_count', 1) : 0) === 0) { if ($format) { return date($format, mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $parsed['month'], $parsed['day'], $parsed['year'])); } else { return true; } } else { return false; } }
php
public function _validation_valid_date($val, $format = null, $strict = true) { if ($this->_empty($val)) { return true; } if ($format) { $parsed = date_parse_from_format($format, $val); } else { $parsed = date_parse($val); } if (\Arr::get($parsed, 'error_count', 1) + ($strict ? \Arr::get($parsed, 'warning_count', 1) : 0) === 0) { if ($format) { return date($format, mktime($parsed['hour'], $parsed['minute'], $parsed['second'], $parsed['month'], $parsed['day'], $parsed['year'])); } else { return true; } } else { return false; } }
[ "public", "function", "_validation_valid_date", "(", "$", "val", ",", "$", "format", "=", "null", ",", "$", "strict", "=", "true", ")", "{", "if", "(", "$", "this", "->", "_empty", "(", "$", "val", ")", ")", "{", "return", "true", ";", "}", "if", "(", "$", "format", ")", "{", "$", "parsed", "=", "date_parse_from_format", "(", "$", "format", ",", "$", "val", ")", ";", "}", "else", "{", "$", "parsed", "=", "date_parse", "(", "$", "val", ")", ";", "}", "if", "(", "\\", "Arr", "::", "get", "(", "$", "parsed", ",", "'error_count'", ",", "1", ")", "+", "(", "$", "strict", "?", "\\", "Arr", "::", "get", "(", "$", "parsed", ",", "'warning_count'", ",", "1", ")", ":", "0", ")", "===", "0", ")", "{", "if", "(", "$", "format", ")", "{", "return", "date", "(", "$", "format", ",", "mktime", "(", "$", "parsed", "[", "'hour'", "]", ",", "$", "parsed", "[", "'minute'", "]", ",", "$", "parsed", "[", "'second'", "]", ",", "$", "parsed", "[", "'month'", "]", ",", "$", "parsed", "[", "'day'", "]", ",", "$", "parsed", "[", "'year'", "]", ")", ")", ";", "}", "else", "{", "return", "true", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}" ]
Checks whether string input is valid date format. When a format is passed it will make sure the date will be in that specific format if validated @param string @param string The format used at the time of a validation @param bool Whether validation checks strict @return bool
[ "Checks", "whether", "string", "input", "is", "valid", "date", "format", ".", "When", "a", "format", "is", "passed", "it", "will", "make", "sure", "the", "date", "will", "be", "in", "that", "specific", "format", "if", "validated" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/validation.php#L1024-L1055
8,385
subcosm-probe/primitives
src/Traits/Stash/StorageTrait.php
StorageTrait.storeToStash
protected function storeToStash($key, $value) { $this->items[$key] = $this->sanitizeStashStorageItem($value, $key); }
php
protected function storeToStash($key, $value) { $this->items[$key] = $this->sanitizeStashStorageItem($value, $key); }
[ "protected", "function", "storeToStash", "(", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "items", "[", "$", "key", "]", "=", "$", "this", "->", "sanitizeStashStorageItem", "(", "$", "value", ",", "$", "key", ")", ";", "}" ]
stores the provided value to the provided key at the stash storage. @param $key @param $value
[ "stores", "the", "provided", "value", "to", "the", "provided", "key", "at", "the", "stash", "storage", "." ]
3b21293e88e9c08185237ff9ac707e4be6031776
https://github.com/subcosm-probe/primitives/blob/3b21293e88e9c08185237ff9ac707e4be6031776/src/Traits/Stash/StorageTrait.php#L35-L38
8,386
subcosm-probe/primitives
src/Traits/Stash/StorageTrait.php
StorageTrait.storeToStashFromArray
protected function storeToStashFromArray(array $items) { $items = $this->mapStashStorageItems($items, null); $this->items = array_replace($this->items, $items); }
php
protected function storeToStashFromArray(array $items) { $items = $this->mapStashStorageItems($items, null); $this->items = array_replace($this->items, $items); }
[ "protected", "function", "storeToStashFromArray", "(", "array", "$", "items", ")", "{", "$", "items", "=", "$", "this", "->", "mapStashStorageItems", "(", "$", "items", ",", "null", ")", ";", "$", "this", "->", "items", "=", "array_replace", "(", "$", "this", "->", "items", ",", "$", "items", ")", ";", "}" ]
stores the provided items to the stash storage, replaces existing items. @param array $items
[ "stores", "the", "provided", "items", "to", "the", "stash", "storage", "replaces", "existing", "items", "." ]
3b21293e88e9c08185237ff9ac707e4be6031776
https://github.com/subcosm-probe/primitives/blob/3b21293e88e9c08185237ff9ac707e4be6031776/src/Traits/Stash/StorageTrait.php#L45-L50
8,387
subcosm-probe/primitives
src/Traits/Stash/StorageTrait.php
StorageTrait.mapStashStorageItems
private function mapStashStorageItems($item, $key) { if ( is_array($item) ) { foreach ( $item as $currentKey => $currentValue ) { $item[$currentKey] = $this->{__FUNCTION__}($currentValue, $currentKey); } return $item; } return $this->sanitizeStashStorageItem($item, $key); }
php
private function mapStashStorageItems($item, $key) { if ( is_array($item) ) { foreach ( $item as $currentKey => $currentValue ) { $item[$currentKey] = $this->{__FUNCTION__}($currentValue, $currentKey); } return $item; } return $this->sanitizeStashStorageItem($item, $key); }
[ "private", "function", "mapStashStorageItems", "(", "$", "item", ",", "$", "key", ")", "{", "if", "(", "is_array", "(", "$", "item", ")", ")", "{", "foreach", "(", "$", "item", "as", "$", "currentKey", "=>", "$", "currentValue", ")", "{", "$", "item", "[", "$", "currentKey", "]", "=", "$", "this", "->", "{", "__FUNCTION__", "}", "(", "$", "currentValue", ",", "$", "currentKey", ")", ";", "}", "return", "$", "item", ";", "}", "return", "$", "this", "->", "sanitizeStashStorageItem", "(", "$", "item", ",", "$", "key", ")", ";", "}" ]
stash storage item mapper. @param $item @param $key @return mixed @throws StashException
[ "stash", "storage", "item", "mapper", "." ]
3b21293e88e9c08185237ff9ac707e4be6031776
https://github.com/subcosm-probe/primitives/blob/3b21293e88e9c08185237ff9ac707e4be6031776/src/Traits/Stash/StorageTrait.php#L102-L113
8,388
subcosm-probe/primitives
src/Traits/Stash/StorageTrait.php
StorageTrait.sanitizeStashStorageItem
private function sanitizeStashStorageItem($item, $key) { if ( is_object($item) && ! ( $item instanceof \JsonSerializable ) ) { throw new StashException( 'Can not stash value of key `'.$key.'`, provided object does not implement JsonSerializable' ); } return $item; }
php
private function sanitizeStashStorageItem($item, $key) { if ( is_object($item) && ! ( $item instanceof \JsonSerializable ) ) { throw new StashException( 'Can not stash value of key `'.$key.'`, provided object does not implement JsonSerializable' ); } return $item; }
[ "private", "function", "sanitizeStashStorageItem", "(", "$", "item", ",", "$", "key", ")", "{", "if", "(", "is_object", "(", "$", "item", ")", "&&", "!", "(", "$", "item", "instanceof", "\\", "JsonSerializable", ")", ")", "{", "throw", "new", "StashException", "(", "'Can not stash value of key `'", ".", "$", "key", ".", "'`, provided object does not implement JsonSerializable'", ")", ";", "}", "return", "$", "item", ";", "}" ]
value sanitizer for stash items. @param $item @param $key @return mixed @throws StashException
[ "value", "sanitizer", "for", "stash", "items", "." ]
3b21293e88e9c08185237ff9ac707e4be6031776
https://github.com/subcosm-probe/primitives/blob/3b21293e88e9c08185237ff9ac707e4be6031776/src/Traits/Stash/StorageTrait.php#L123-L132
8,389
pgraham/opal
src/CompanionGenerator.php
CompanionGenerator.generate
public function generate($defClass) { list($className, $refClass) = $this->getClassInfo($defClass); $companionName = $this->getCompanionName($className); $companionNameParts = explode('\\', $companionName); $companionClass = array_pop($companionNameParts); $companionNs = implode('\\', $companionNameParts); $companionNsPath = $this->nsToPath($companionNs); $outDir = $this->target->getPath()->pathJoin($companionNsPath); $outPath = $outDir->pathJoin($companionClass . '.php'); $psr4Prefix = $this->target->getPrefix()->rtrim('\\'); if (!empty($psr4Prefix)) { $companionNs = $psr4Prefix->join($companionNs, '\\'); } $values = $this->director->getValuesFor($refClass); $values['companionNs'] = $companionNs; $values['companionClass'] = $companionClass; $values['model'] = $className; $values['modelStr'] = str_replace('\\', '\\\\', $className); $resolved = $this->template->forValues($values); if (!file_exists($outDir)) { mkdir($outDir, 0755, true); } $file = new SplFileObject($outPath, 'w'); $file->fwrite($resolved); return $companionNs->join($companionClass, '\\')->__toString(); }
php
public function generate($defClass) { list($className, $refClass) = $this->getClassInfo($defClass); $companionName = $this->getCompanionName($className); $companionNameParts = explode('\\', $companionName); $companionClass = array_pop($companionNameParts); $companionNs = implode('\\', $companionNameParts); $companionNsPath = $this->nsToPath($companionNs); $outDir = $this->target->getPath()->pathJoin($companionNsPath); $outPath = $outDir->pathJoin($companionClass . '.php'); $psr4Prefix = $this->target->getPrefix()->rtrim('\\'); if (!empty($psr4Prefix)) { $companionNs = $psr4Prefix->join($companionNs, '\\'); } $values = $this->director->getValuesFor($refClass); $values['companionNs'] = $companionNs; $values['companionClass'] = $companionClass; $values['model'] = $className; $values['modelStr'] = str_replace('\\', '\\\\', $className); $resolved = $this->template->forValues($values); if (!file_exists($outDir)) { mkdir($outDir, 0755, true); } $file = new SplFileObject($outPath, 'w'); $file->fwrite($resolved); return $companionNs->join($companionClass, '\\')->__toString(); }
[ "public", "function", "generate", "(", "$", "defClass", ")", "{", "list", "(", "$", "className", ",", "$", "refClass", ")", "=", "$", "this", "->", "getClassInfo", "(", "$", "defClass", ")", ";", "$", "companionName", "=", "$", "this", "->", "getCompanionName", "(", "$", "className", ")", ";", "$", "companionNameParts", "=", "explode", "(", "'\\\\'", ",", "$", "companionName", ")", ";", "$", "companionClass", "=", "array_pop", "(", "$", "companionNameParts", ")", ";", "$", "companionNs", "=", "implode", "(", "'\\\\'", ",", "$", "companionNameParts", ")", ";", "$", "companionNsPath", "=", "$", "this", "->", "nsToPath", "(", "$", "companionNs", ")", ";", "$", "outDir", "=", "$", "this", "->", "target", "->", "getPath", "(", ")", "->", "pathJoin", "(", "$", "companionNsPath", ")", ";", "$", "outPath", "=", "$", "outDir", "->", "pathJoin", "(", "$", "companionClass", ".", "'.php'", ")", ";", "$", "psr4Prefix", "=", "$", "this", "->", "target", "->", "getPrefix", "(", ")", "->", "rtrim", "(", "'\\\\'", ")", ";", "if", "(", "!", "empty", "(", "$", "psr4Prefix", ")", ")", "{", "$", "companionNs", "=", "$", "psr4Prefix", "->", "join", "(", "$", "companionNs", ",", "'\\\\'", ")", ";", "}", "$", "values", "=", "$", "this", "->", "director", "->", "getValuesFor", "(", "$", "refClass", ")", ";", "$", "values", "[", "'companionNs'", "]", "=", "$", "companionNs", ";", "$", "values", "[", "'companionClass'", "]", "=", "$", "companionClass", ";", "$", "values", "[", "'model'", "]", "=", "$", "className", ";", "$", "values", "[", "'modelStr'", "]", "=", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "className", ")", ";", "$", "resolved", "=", "$", "this", "->", "template", "->", "forValues", "(", "$", "values", ")", ";", "if", "(", "!", "file_exists", "(", "$", "outDir", ")", ")", "{", "mkdir", "(", "$", "outDir", ",", "0755", ",", "true", ")", ";", "}", "$", "file", "=", "new", "SplFileObject", "(", "$", "outPath", ",", "'w'", ")", ";", "$", "file", "->", "fwrite", "(", "$", "resolved", ")", ";", "return", "$", "companionNs", "->", "join", "(", "$", "companionClass", ",", "'\\\\'", ")", "->", "__toString", "(", ")", ";", "}" ]
Generate a companion for the given class. @param string|object|ReflectionClass $defClass Either the name of a class, an instance of a class or a ReflectionClass instance.
[ "Generate", "a", "companion", "for", "the", "given", "class", "." ]
73139069567b223423472c81c2f8ed645a3adafc
https://github.com/pgraham/opal/blob/73139069567b223423472c81c2f8ed645a3adafc/src/CompanionGenerator.php#L64-L97
8,390
mobileka/mosaic-array
src/Mobileka/MosaicArray/MosaicArray.php
MosaicArray.hasIntersections
public function hasIntersections(array $array, $strict = false, $returnIntersection = false) { foreach ($this->target as $element) { if (in_array($element, $array, $strict)) { return $returnIntersection ? $element : true; } } return false; }
php
public function hasIntersections(array $array, $strict = false, $returnIntersection = false) { foreach ($this->target as $element) { if (in_array($element, $array, $strict)) { return $returnIntersection ? $element : true; } } return false; }
[ "public", "function", "hasIntersections", "(", "array", "$", "array", ",", "$", "strict", "=", "false", ",", "$", "returnIntersection", "=", "false", ")", "{", "foreach", "(", "$", "this", "->", "target", "as", "$", "element", ")", "{", "if", "(", "in_array", "(", "$", "element", ",", "$", "array", ",", "$", "strict", ")", ")", "{", "return", "$", "returnIntersection", "?", "$", "element", ":", "true", ";", "}", "}", "return", "false", ";", "}" ]
Determine if two arrays have at least a single matching element @param array $array @param bool $strict @param bool $returnIntersection @return mixed
[ "Determine", "if", "two", "arrays", "have", "at", "least", "a", "single", "matching", "element" ]
7f850df9030ed484d6526f3f130ce659d19a84f1
https://github.com/mobileka/mosaic-array/blob/7f850df9030ed484d6526f3f130ce659d19a84f1/src/Mobileka/MosaicArray/MosaicArray.php#L86-L95
8,391
mobileka/mosaic-array
src/Mobileka/MosaicArray/MosaicArray.php
MosaicArray.find
public function find($defaultResult = null) { foreach ($this->target as $value) { if ($value) { return $value; } } return $defaultResult; }
php
public function find($defaultResult = null) { foreach ($this->target as $value) { if ($value) { return $value; } } return $defaultResult; }
[ "public", "function", "find", "(", "$", "defaultResult", "=", "null", ")", "{", "foreach", "(", "$", "this", "->", "target", "as", "$", "value", ")", "{", "if", "(", "$", "value", ")", "{", "return", "$", "value", ";", "}", "}", "return", "$", "defaultResult", ";", "}" ]
Return the first truthy element of the target array. If none of them is truthy, return a defaultResult. @param mixed $defaultResult @return mixed
[ "Return", "the", "first", "truthy", "element", "of", "the", "target", "array", ".", "If", "none", "of", "them", "is", "truthy", "return", "a", "defaultResult", "." ]
7f850df9030ed484d6526f3f130ce659d19a84f1
https://github.com/mobileka/mosaic-array/blob/7f850df9030ed484d6526f3f130ce659d19a84f1/src/Mobileka/MosaicArray/MosaicArray.php#L104-L113
8,392
mobileka/mosaic-array
src/Mobileka/MosaicArray/MosaicArray.php
MosaicArray.pregKeys
public function pregKeys($pattern, $defaultResult = null, $flags = 0) { $result = preg_grep($pattern, array_keys($this->target), $flags); return $result ? array_values($result) : $defaultResult; }
php
public function pregKeys($pattern, $defaultResult = null, $flags = 0) { $result = preg_grep($pattern, array_keys($this->target), $flags); return $result ? array_values($result) : $defaultResult; }
[ "public", "function", "pregKeys", "(", "$", "pattern", ",", "$", "defaultResult", "=", "null", ",", "$", "flags", "=", "0", ")", "{", "$", "result", "=", "preg_grep", "(", "$", "pattern", ",", "array_keys", "(", "$", "this", "->", "target", ")", ",", "$", "flags", ")", ";", "return", "$", "result", "?", "array_values", "(", "$", "result", ")", ":", "$", "defaultResult", ";", "}" ]
Get an array of target array's keys matching a regular expression If nothing found, return a defaultResult @param string $pattern @param mixed $defaultResult @param mixed $flags @return mixed
[ "Get", "an", "array", "of", "target", "array", "s", "keys", "matching", "a", "regular", "expression", "If", "nothing", "found", "return", "a", "defaultResult" ]
7f850df9030ed484d6526f3f130ce659d19a84f1
https://github.com/mobileka/mosaic-array/blob/7f850df9030ed484d6526f3f130ce659d19a84f1/src/Mobileka/MosaicArray/MosaicArray.php#L124-L129
8,393
mobileka/mosaic-array
src/Mobileka/MosaicArray/MosaicArray.php
MosaicArray.pregValues
public function pregValues($pattern, $defaultResult = null, $flags = 0) { $result = preg_grep($pattern, array_values($this->target), $flags); return $result ? array_values($result) : $defaultResult; }
php
public function pregValues($pattern, $defaultResult = null, $flags = 0) { $result = preg_grep($pattern, array_values($this->target), $flags); return $result ? array_values($result) : $defaultResult; }
[ "public", "function", "pregValues", "(", "$", "pattern", ",", "$", "defaultResult", "=", "null", ",", "$", "flags", "=", "0", ")", "{", "$", "result", "=", "preg_grep", "(", "$", "pattern", ",", "array_values", "(", "$", "this", "->", "target", ")", ",", "$", "flags", ")", ";", "return", "$", "result", "?", "array_values", "(", "$", "result", ")", ":", "$", "defaultResult", ";", "}" ]
Get values from an array by a key matching a regular expression If nothing found, return a defaultResult @param string $pattern @param mixed $defaultResult @param mixed $flags @return mixed
[ "Get", "values", "from", "an", "array", "by", "a", "key", "matching", "a", "regular", "expression", "If", "nothing", "found", "return", "a", "defaultResult" ]
7f850df9030ed484d6526f3f130ce659d19a84f1
https://github.com/mobileka/mosaic-array/blob/7f850df9030ed484d6526f3f130ce659d19a84f1/src/Mobileka/MosaicArray/MosaicArray.php#L140-L145
8,394
mobileka/mosaic-array
src/Mobileka/MosaicArray/MosaicArray.php
MosaicArray.except
public function except(array $keys) { return $keys ? array_diff_key($this->target, array_flip($keys)) : $this->target; }
php
public function except(array $keys) { return $keys ? array_diff_key($this->target, array_flip($keys)) : $this->target; }
[ "public", "function", "except", "(", "array", "$", "keys", ")", "{", "return", "$", "keys", "?", "array_diff_key", "(", "$", "this", "->", "target", ",", "array_flip", "(", "$", "keys", ")", ")", ":", "$", "this", "->", "target", ";", "}" ]
Exclude specified keys form a given array @param array $keys @return array
[ "Exclude", "specified", "keys", "form", "a", "given", "array" ]
7f850df9030ed484d6526f3f130ce659d19a84f1
https://github.com/mobileka/mosaic-array/blob/7f850df9030ed484d6526f3f130ce659d19a84f1/src/Mobileka/MosaicArray/MosaicArray.php#L153-L156
8,395
mobileka/mosaic-array
src/Mobileka/MosaicArray/MosaicArray.php
MosaicArray.excludeByRule
public function excludeByRule(Closure $rule) { $result = $this->target; foreach ($result as $key => $value) { if ($rule($key, $value)) { unset($result[$key]); } } return $result; }
php
public function excludeByRule(Closure $rule) { $result = $this->target; foreach ($result as $key => $value) { if ($rule($key, $value)) { unset($result[$key]); } } return $result; }
[ "public", "function", "excludeByRule", "(", "Closure", "$", "rule", ")", "{", "$", "result", "=", "$", "this", "->", "target", ";", "foreach", "(", "$", "result", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "rule", "(", "$", "key", ",", "$", "value", ")", ")", "{", "unset", "(", "$", "result", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Exclude an item from an array if its value meets a rule @param \Closure $rule @return array
[ "Exclude", "an", "item", "from", "an", "array", "if", "its", "value", "meets", "a", "rule" ]
7f850df9030ed484d6526f3f130ce659d19a84f1
https://github.com/mobileka/mosaic-array/blob/7f850df9030ed484d6526f3f130ce659d19a84f1/src/Mobileka/MosaicArray/MosaicArray.php#L226-L237
8,396
mobileka/mosaic-array
src/Mobileka/MosaicArray/MosaicArray.php
MosaicArray.offsetGet
public function offsetGet($offset) { return isset($this->target[$offset]) ? $this->target[$offset] : null; }
php
public function offsetGet($offset) { return isset($this->target[$offset]) ? $this->target[$offset] : null; }
[ "public", "function", "offsetGet", "(", "$", "offset", ")", "{", "return", "isset", "(", "$", "this", "->", "target", "[", "$", "offset", "]", ")", "?", "$", "this", "->", "target", "[", "$", "offset", "]", ":", "null", ";", "}" ]
Implementation of the offsetGet method of the ArrayAccess interface @param mixed $offset @return mixed
[ "Implementation", "of", "the", "offsetGet", "method", "of", "the", "ArrayAccess", "interface" ]
7f850df9030ed484d6526f3f130ce659d19a84f1
https://github.com/mobileka/mosaic-array/blob/7f850df9030ed484d6526f3f130ce659d19a84f1/src/Mobileka/MosaicArray/MosaicArray.php#L293-L296
8,397
hametuha/hametwoo
src/Hametuha/HametWoo/Pattern/Tab.php
Tab.endpoint_title
public function endpoint_title( $title ) { global $wp_query; if ( isset( $wp_query->query_vars[ $this->endpoint ] ) && ! is_admin() && is_main_query() && in_the_loop() && is_account_page() ) { /** * hametwoo_tab_title * * Filter for Tab title. * * @package hametwoo * @since 0.8.0 * @param string $title Original Title * @param string $endpoint Endpoint name. * @param string $class_name The instance which fires this filter. * * @return string */ $title = apply_filters( 'hametwoo_tab_title', $this->get_title(), $this->endpoint, get_called_class() ); } return $title; }
php
public function endpoint_title( $title ) { global $wp_query; if ( isset( $wp_query->query_vars[ $this->endpoint ] ) && ! is_admin() && is_main_query() && in_the_loop() && is_account_page() ) { /** * hametwoo_tab_title * * Filter for Tab title. * * @package hametwoo * @since 0.8.0 * @param string $title Original Title * @param string $endpoint Endpoint name. * @param string $class_name The instance which fires this filter. * * @return string */ $title = apply_filters( 'hametwoo_tab_title', $this->get_title(), $this->endpoint, get_called_class() ); } return $title; }
[ "public", "function", "endpoint_title", "(", "$", "title", ")", "{", "global", "$", "wp_query", ";", "if", "(", "isset", "(", "$", "wp_query", "->", "query_vars", "[", "$", "this", "->", "endpoint", "]", ")", "&&", "!", "is_admin", "(", ")", "&&", "is_main_query", "(", ")", "&&", "in_the_loop", "(", ")", "&&", "is_account_page", "(", ")", ")", "{", "/**\n\t\t\t * hametwoo_tab_title\n\t\t\t *\n\t\t\t * Filter for Tab title.\n\t\t\t *\n\t\t\t * @package hametwoo\n\t\t\t * @since 0.8.0\n\t\t\t * @param string $title Original Title\n\t\t\t * @param string $endpoint Endpoint name.\n\t\t\t * @param string $class_name The instance which fires this filter.\n\t\t\t *\n\t\t\t * @return string\n\t\t\t */", "$", "title", "=", "apply_filters", "(", "'hametwoo_tab_title'", ",", "$", "this", "->", "get_title", "(", ")", ",", "$", "this", "->", "endpoint", ",", "get_called_class", "(", ")", ")", ";", "}", "return", "$", "title", ";", "}" ]
Change title for tab @since 0.8.0 @package hametwoo @param string $title Title for this setting page. @return string
[ "Change", "title", "for", "tab" ]
bcd5948ea53d6ca2181873a9f9d0d221c346592e
https://github.com/hametuha/hametwoo/blob/bcd5948ea53d6ca2181873a9f9d0d221c346592e/src/Hametuha/HametWoo/Pattern/Tab.php#L54-L74
8,398
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/email/classes/email/driver/mandrill.php
Email_Driver_Mandrill.build_rcpt
protected function build_rcpt($list = 'to') { return array_map(function ($item) use ($list) { $item['type'] = $list; return $item; }, $this->{$list}); }
php
protected function build_rcpt($list = 'to') { return array_map(function ($item) use ($list) { $item['type'] = $list; return $item; }, $this->{$list}); }
[ "protected", "function", "build_rcpt", "(", "$", "list", "=", "'to'", ")", "{", "return", "array_map", "(", "function", "(", "$", "item", ")", "use", "(", "$", "list", ")", "{", "$", "item", "[", "'type'", "]", "=", "$", "list", ";", "return", "$", "item", ";", "}", ",", "$", "this", "->", "{", "$", "list", "}", ")", ";", "}" ]
Add type to recipient list @param string $list to, cc, bcc @return array
[ "Add", "type", "to", "recipient", "list" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/email/classes/email/driver/mandrill.php#L186-L194
8,399
indigophp-archive/codeception-fuel-module
fuel/fuel/packages/email/classes/email/driver/mandrill.php
Email_Driver_Mandrill.get_merge_vars
public function get_merge_vars($key = null, $rcpt = null) { if (is_null($rcpt)) { return \Arr::get($this->merge_vars, $key); } elseif (isset($this->rcpt_merge_vars[$rcpt])) { return \Arr::get($this->rcpt_merge_vars[$rcpt], $key); } }
php
public function get_merge_vars($key = null, $rcpt = null) { if (is_null($rcpt)) { return \Arr::get($this->merge_vars, $key); } elseif (isset($this->rcpt_merge_vars[$rcpt])) { return \Arr::get($this->rcpt_merge_vars[$rcpt], $key); } }
[ "public", "function", "get_merge_vars", "(", "$", "key", "=", "null", ",", "$", "rcpt", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "rcpt", ")", ")", "{", "return", "\\", "Arr", "::", "get", "(", "$", "this", "->", "merge_vars", ",", "$", "key", ")", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "rcpt_merge_vars", "[", "$", "rcpt", "]", ")", ")", "{", "return", "\\", "Arr", "::", "get", "(", "$", "this", "->", "rcpt_merge_vars", "[", "$", "rcpt", "]", ",", "$", "key", ")", ";", "}", "}" ]
Get merge vars @param mixed $key Null for all, string for specific @param mixed $rcpt Null for global, string for recipient @return array
[ "Get", "merge", "vars" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/email/classes/email/driver/mandrill.php#L220-L230