id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
237,300
promaker/Base
Repository/ARepository.php
ARepository.setLimit
public function setLimit($limit) { if (!isset($this->_persistence) || !($this->_persistence instanceof IPersistance)) { throw new Exception("Repository Exception : No existe la interfaz de la persistencia o no implementa la interfaz IPersistance."); } $this->_persistence->setLimit($limit); return $this; }
php
public function setLimit($limit) { if (!isset($this->_persistence) || !($this->_persistence instanceof IPersistance)) { throw new Exception("Repository Exception : No existe la interfaz de la persistencia o no implementa la interfaz IPersistance."); } $this->_persistence->setLimit($limit); return $this; }
[ "public", "function", "setLimit", "(", "$", "limit", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_persistence", ")", "||", "!", "(", "$", "this", "->", "_persistence", "instanceof", "IPersistance", ")", ")", "{", "throw", "new", "Exception", "(", "\"Repository Exception : No existe la interfaz de la persistencia o no implementa la interfaz IPersistance.\"", ")", ";", "}", "$", "this", "->", "_persistence", "->", "setLimit", "(", "$", "limit", ")", ";", "return", "$", "this", ";", "}" ]
Setea el limite para efectuar en las operaciones de lectura @param Int $limit @return self
[ "Setea", "el", "limite", "para", "efectuar", "en", "las", "operaciones", "de", "lectura" ]
042c1a53f0fafdb79a854252ad3f0b4c7e8ab716
https://github.com/promaker/Base/blob/042c1a53f0fafdb79a854252ad3f0b4c7e8ab716/Repository/ARepository.php#L70-L79
237,301
deasilworks/cms
src/CEF/Data/Manager/PageDataManager.php
PageDataManager.setPage
public function setPage(PageDataModel $pageModel) { $pageModel ->setModified(new \DateTime()) ->setEntityManager($this) ->save(); return true; }
php
public function setPage(PageDataModel $pageModel) { $pageModel ->setModified(new \DateTime()) ->setEntityManager($this) ->save(); return true; }
[ "public", "function", "setPage", "(", "PageDataModel", "$", "pageModel", ")", "{", "$", "pageModel", "->", "setModified", "(", "new", "\\", "DateTime", "(", ")", ")", "->", "setEntityManager", "(", "$", "this", ")", "->", "save", "(", ")", ";", "return", "true", ";", "}" ]
Set Page. @ApiAction() @param PageDataModel $pageModel @return bool
[ "Set", "Page", "." ]
759d05a4e79656b62ff26ea55834f64c61fd1fd4
https://github.com/deasilworks/cms/blob/759d05a4e79656b62ff26ea55834f64c61fd1fd4/src/CEF/Data/Manager/PageDataManager.php#L86-L94
237,302
deasilworks/cms
src/CEF/Data/Manager/PageDataManager.php
PageDataManager.getPage
public function getPage($stub) { $this->logger->addNotice(print_r($this->cfg->getAll(), 1)); $stmtManager = $this->getStatementManager(Simple::class); /** @var Select $stmtBuilder */ $stmtBuilder = $stmtManager->getStatementBuilder(Select::class); /** @var PageCollection $collection */ $collection = $stmtManager->setStatement($stmtBuilder->setWhere(['stub = :stub'])) ->setArguments(['stub' => $stub]) ->execute(); /** @var PageDataModel $c */ $c = $collection->current(); return $c; }
php
public function getPage($stub) { $this->logger->addNotice(print_r($this->cfg->getAll(), 1)); $stmtManager = $this->getStatementManager(Simple::class); /** @var Select $stmtBuilder */ $stmtBuilder = $stmtManager->getStatementBuilder(Select::class); /** @var PageCollection $collection */ $collection = $stmtManager->setStatement($stmtBuilder->setWhere(['stub = :stub'])) ->setArguments(['stub' => $stub]) ->execute(); /** @var PageDataModel $c */ $c = $collection->current(); return $c; }
[ "public", "function", "getPage", "(", "$", "stub", ")", "{", "$", "this", "->", "logger", "->", "addNotice", "(", "print_r", "(", "$", "this", "->", "cfg", "->", "getAll", "(", ")", ",", "1", ")", ")", ";", "$", "stmtManager", "=", "$", "this", "->", "getStatementManager", "(", "Simple", "::", "class", ")", ";", "/** @var Select $stmtBuilder */", "$", "stmtBuilder", "=", "$", "stmtManager", "->", "getStatementBuilder", "(", "Select", "::", "class", ")", ";", "/** @var PageCollection $collection */", "$", "collection", "=", "$", "stmtManager", "->", "setStatement", "(", "$", "stmtBuilder", "->", "setWhere", "(", "[", "'stub = :stub'", "]", ")", ")", "->", "setArguments", "(", "[", "'stub'", "=>", "$", "stub", "]", ")", "->", "execute", "(", ")", ";", "/** @var PageDataModel $c */", "$", "c", "=", "$", "collection", "->", "current", "(", ")", ";", "return", "$", "c", ";", "}" ]
Get Page. @ApiAction() @param string $stub the url friendly name of the page. @return PageDataModel
[ "Get", "Page", "." ]
759d05a4e79656b62ff26ea55834f64c61fd1fd4
https://github.com/deasilworks/cms/blob/759d05a4e79656b62ff26ea55834f64c61fd1fd4/src/CEF/Data/Manager/PageDataManager.php#L105-L123
237,303
deasilworks/cms
src/CEF/Data/Manager/PageDataManager.php
PageDataManager.getPages
public function getPages(ECParams $params) { $stmtManager = $this->getStatementManager(Simple::class); /** @var Select $stmtBuilder */ $stmtBuilder = $stmtManager->getStatementBuilder(Select::class); /** @var PageCollection $collection */ $collection = $stmtManager->setStatement($stmtBuilder->setColumns(['stub'])) ->execute(); return $collection->setEcParams($params); }
php
public function getPages(ECParams $params) { $stmtManager = $this->getStatementManager(Simple::class); /** @var Select $stmtBuilder */ $stmtBuilder = $stmtManager->getStatementBuilder(Select::class); /** @var PageCollection $collection */ $collection = $stmtManager->setStatement($stmtBuilder->setColumns(['stub'])) ->execute(); return $collection->setEcParams($params); }
[ "public", "function", "getPages", "(", "ECParams", "$", "params", ")", "{", "$", "stmtManager", "=", "$", "this", "->", "getStatementManager", "(", "Simple", "::", "class", ")", ";", "/** @var Select $stmtBuilder */", "$", "stmtBuilder", "=", "$", "stmtManager", "->", "getStatementBuilder", "(", "Select", "::", "class", ")", ";", "/** @var PageCollection $collection */", "$", "collection", "=", "$", "stmtManager", "->", "setStatement", "(", "$", "stmtBuilder", "->", "setColumns", "(", "[", "'stub'", "]", ")", ")", "->", "execute", "(", ")", ";", "return", "$", "collection", "->", "setEcParams", "(", "$", "params", ")", ";", "}" ]
Get all Pages. @ApiAction() @return PageCollection
[ "Get", "all", "Pages", "." ]
759d05a4e79656b62ff26ea55834f64c61fd1fd4
https://github.com/deasilworks/cms/blob/759d05a4e79656b62ff26ea55834f64c61fd1fd4/src/CEF/Data/Manager/PageDataManager.php#L132-L144
237,304
philliphq/phillip
src/Phillip/Coverage.php
Coverage.output
public function output() { $data = [ 'classes' => [], 'files' => [], ]; foreach ($this->processed as $type => $classes) { foreach ($classes as $name => $values) { $covered = $values['covered']; $total = $values['total']; $pct = (((int) $covered / (int) $total) * 100); $covered = str_pad((string) $covered, 7, ' ', STR_PAD_LEFT); $total = str_pad((string) $total, 5, ' ', STR_PAD_LEFT); $percentage = number_format($pct, 2).'%'; $percentage = str_pad((string) $percentage, 10, ' ', STR_PAD_LEFT); if ($pct < 25) { $covered = $this->output->red($covered); $total = $this->output->red($total); $percentage = $this->output->red($percentage); } if ($pct < 75) { $covered = $this->output->black->yellow($covered); $total = $this->output->black->yellow($total); $percentage = $this->output->black->yellow($percentage); } if ($pct >= 75) { $covered = $this->output->green($covered); $total = $this->output->green($total); $percentage = $this->output->green($percentage); } $data[$type][] = [$name, $covered, $total, $percentage]; } } $out = []; if (count($data['classes']) > 0) { array_unshift($data['classes'], ['Class', 'Covered', 'Lines', 'Percentage']); $out[] = new Table($data['classes'], [ 'headerColor' => Graphite::YELLOW, 'columnSeparator' => '', 'headerSeparator' => '', 'cellPadding' => 1, ]); } if (count($data['files']) > 0) { array_unshift($data['files'], ['File', 'Covered', 'Lines', 'Percentage']); $out[] = new Table($data['files'], [ 'headerColor' => Graphite::YELLOW, 'columnSeparator' => '', 'headerSeparator' => '', 'cellPadding' => 1, ]); } return $this->output->render(implode("\n\n", $out)); }
php
public function output() { $data = [ 'classes' => [], 'files' => [], ]; foreach ($this->processed as $type => $classes) { foreach ($classes as $name => $values) { $covered = $values['covered']; $total = $values['total']; $pct = (((int) $covered / (int) $total) * 100); $covered = str_pad((string) $covered, 7, ' ', STR_PAD_LEFT); $total = str_pad((string) $total, 5, ' ', STR_PAD_LEFT); $percentage = number_format($pct, 2).'%'; $percentage = str_pad((string) $percentage, 10, ' ', STR_PAD_LEFT); if ($pct < 25) { $covered = $this->output->red($covered); $total = $this->output->red($total); $percentage = $this->output->red($percentage); } if ($pct < 75) { $covered = $this->output->black->yellow($covered); $total = $this->output->black->yellow($total); $percentage = $this->output->black->yellow($percentage); } if ($pct >= 75) { $covered = $this->output->green($covered); $total = $this->output->green($total); $percentage = $this->output->green($percentage); } $data[$type][] = [$name, $covered, $total, $percentage]; } } $out = []; if (count($data['classes']) > 0) { array_unshift($data['classes'], ['Class', 'Covered', 'Lines', 'Percentage']); $out[] = new Table($data['classes'], [ 'headerColor' => Graphite::YELLOW, 'columnSeparator' => '', 'headerSeparator' => '', 'cellPadding' => 1, ]); } if (count($data['files']) > 0) { array_unshift($data['files'], ['File', 'Covered', 'Lines', 'Percentage']); $out[] = new Table($data['files'], [ 'headerColor' => Graphite::YELLOW, 'columnSeparator' => '', 'headerSeparator' => '', 'cellPadding' => 1, ]); } return $this->output->render(implode("\n\n", $out)); }
[ "public", "function", "output", "(", ")", "{", "$", "data", "=", "[", "'classes'", "=>", "[", "]", ",", "'files'", "=>", "[", "]", ",", "]", ";", "foreach", "(", "$", "this", "->", "processed", "as", "$", "type", "=>", "$", "classes", ")", "{", "foreach", "(", "$", "classes", "as", "$", "name", "=>", "$", "values", ")", "{", "$", "covered", "=", "$", "values", "[", "'covered'", "]", ";", "$", "total", "=", "$", "values", "[", "'total'", "]", ";", "$", "pct", "=", "(", "(", "(", "int", ")", "$", "covered", "/", "(", "int", ")", "$", "total", ")", "*", "100", ")", ";", "$", "covered", "=", "str_pad", "(", "(", "string", ")", "$", "covered", ",", "7", ",", "' '", ",", "STR_PAD_LEFT", ")", ";", "$", "total", "=", "str_pad", "(", "(", "string", ")", "$", "total", ",", "5", ",", "' '", ",", "STR_PAD_LEFT", ")", ";", "$", "percentage", "=", "number_format", "(", "$", "pct", ",", "2", ")", ".", "'%'", ";", "$", "percentage", "=", "str_pad", "(", "(", "string", ")", "$", "percentage", ",", "10", ",", "' '", ",", "STR_PAD_LEFT", ")", ";", "if", "(", "$", "pct", "<", "25", ")", "{", "$", "covered", "=", "$", "this", "->", "output", "->", "red", "(", "$", "covered", ")", ";", "$", "total", "=", "$", "this", "->", "output", "->", "red", "(", "$", "total", ")", ";", "$", "percentage", "=", "$", "this", "->", "output", "->", "red", "(", "$", "percentage", ")", ";", "}", "if", "(", "$", "pct", "<", "75", ")", "{", "$", "covered", "=", "$", "this", "->", "output", "->", "black", "->", "yellow", "(", "$", "covered", ")", ";", "$", "total", "=", "$", "this", "->", "output", "->", "black", "->", "yellow", "(", "$", "total", ")", ";", "$", "percentage", "=", "$", "this", "->", "output", "->", "black", "->", "yellow", "(", "$", "percentage", ")", ";", "}", "if", "(", "$", "pct", ">=", "75", ")", "{", "$", "covered", "=", "$", "this", "->", "output", "->", "green", "(", "$", "covered", ")", ";", "$", "total", "=", "$", "this", "->", "output", "->", "green", "(", "$", "total", ")", ";", "$", "percentage", "=", "$", "this", "->", "output", "->", "green", "(", "$", "percentage", ")", ";", "}", "$", "data", "[", "$", "type", "]", "[", "]", "=", "[", "$", "name", ",", "$", "covered", ",", "$", "total", ",", "$", "percentage", "]", ";", "}", "}", "$", "out", "=", "[", "]", ";", "if", "(", "count", "(", "$", "data", "[", "'classes'", "]", ")", ">", "0", ")", "{", "array_unshift", "(", "$", "data", "[", "'classes'", "]", ",", "[", "'Class'", ",", "'Covered'", ",", "'Lines'", ",", "'Percentage'", "]", ")", ";", "$", "out", "[", "]", "=", "new", "Table", "(", "$", "data", "[", "'classes'", "]", ",", "[", "'headerColor'", "=>", "Graphite", "::", "YELLOW", ",", "'columnSeparator'", "=>", "''", ",", "'headerSeparator'", "=>", "''", ",", "'cellPadding'", "=>", "1", ",", "]", ")", ";", "}", "if", "(", "count", "(", "$", "data", "[", "'files'", "]", ")", ">", "0", ")", "{", "array_unshift", "(", "$", "data", "[", "'files'", "]", ",", "[", "'File'", ",", "'Covered'", ",", "'Lines'", ",", "'Percentage'", "]", ")", ";", "$", "out", "[", "]", "=", "new", "Table", "(", "$", "data", "[", "'files'", "]", ",", "[", "'headerColor'", "=>", "Graphite", "::", "YELLOW", ",", "'columnSeparator'", "=>", "''", ",", "'headerSeparator'", "=>", "''", ",", "'cellPadding'", "=>", "1", ",", "]", ")", ";", "}", "return", "$", "this", "->", "output", "->", "render", "(", "implode", "(", "\"\\n\\n\"", ",", "$", "out", ")", ")", ";", "}" ]
Output the coverage tables. @return string The rendered tables
[ "Output", "the", "coverage", "tables", "." ]
42dac9d0f52fb77b49054b15b8baecca031151dc
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Coverage.php#L106-L169
237,305
philliphq/phillip
src/Phillip/Coverage.php
Coverage.isCovered
private function isCovered($file) { return in_array($file, $this->includedFiles) && !in_array($file, $this->excludedFiles) && isset($this->covered[$file]); }
php
private function isCovered($file) { return in_array($file, $this->includedFiles) && !in_array($file, $this->excludedFiles) && isset($this->covered[$file]); }
[ "private", "function", "isCovered", "(", "$", "file", ")", "{", "return", "in_array", "(", "$", "file", ",", "$", "this", "->", "includedFiles", ")", "&&", "!", "in_array", "(", "$", "file", ",", "$", "this", "->", "excludedFiles", ")", "&&", "isset", "(", "$", "this", "->", "covered", "[", "$", "file", "]", ")", ";", "}" ]
Check if a file should be included in coverage calculations. @param string $file The filename @return bool
[ "Check", "if", "a", "file", "should", "be", "included", "in", "coverage", "calculations", "." ]
42dac9d0f52fb77b49054b15b8baecca031151dc
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Coverage.php#L261-L266
237,306
philliphq/phillip
src/Phillip/Coverage.php
Coverage.processRawData
private function processRawData() { // Get the raw data from Xdebug $data = xdebug_get_code_coverage(); // Create an array for storing processed coverage data $processed = [ 'classes' => [], 'files' => [], ]; // Loop through each of the files in the coverage data foreach ($data as $file => $lines) { // Check if this file is covered if ($this->isCovered($file)) { // Filter out dead code from the results $filter = function ($value, $line = null) { return $value !== self::DEAD; }; $executable = array_filter($lines, $filter); // Filter out unused code to get the lines covered $object = $this; $filter = function ($value, $line) use ($object, $file) { if (in_array($line, $object->covered[$file])) { return $value === 1; } }; $covered = array_filter($lines, $filter, ARRAY_FILTER_USE_BOTH); // Store the counts for this file $coverage = [ 'covered' => count($covered), 'total' => count($executable), ]; // If a classname exists in the file, // store the counts against it if ($class = $this->getClassForFile($file)) { $processed['classes'][$class] = $coverage; continue; } // If no class has been found, store the counts // directly against the file name $name = str_replace($this->runner->pwd.'/', '', $file); $processed['files'][$name] = $coverage; } } // Store the processed data return $this->processed = $processed; }
php
private function processRawData() { // Get the raw data from Xdebug $data = xdebug_get_code_coverage(); // Create an array for storing processed coverage data $processed = [ 'classes' => [], 'files' => [], ]; // Loop through each of the files in the coverage data foreach ($data as $file => $lines) { // Check if this file is covered if ($this->isCovered($file)) { // Filter out dead code from the results $filter = function ($value, $line = null) { return $value !== self::DEAD; }; $executable = array_filter($lines, $filter); // Filter out unused code to get the lines covered $object = $this; $filter = function ($value, $line) use ($object, $file) { if (in_array($line, $object->covered[$file])) { return $value === 1; } }; $covered = array_filter($lines, $filter, ARRAY_FILTER_USE_BOTH); // Store the counts for this file $coverage = [ 'covered' => count($covered), 'total' => count($executable), ]; // If a classname exists in the file, // store the counts against it if ($class = $this->getClassForFile($file)) { $processed['classes'][$class] = $coverage; continue; } // If no class has been found, store the counts // directly against the file name $name = str_replace($this->runner->pwd.'/', '', $file); $processed['files'][$name] = $coverage; } } // Store the processed data return $this->processed = $processed; }
[ "private", "function", "processRawData", "(", ")", "{", "// Get the raw data from Xdebug", "$", "data", "=", "xdebug_get_code_coverage", "(", ")", ";", "// Create an array for storing processed coverage data", "$", "processed", "=", "[", "'classes'", "=>", "[", "]", ",", "'files'", "=>", "[", "]", ",", "]", ";", "// Loop through each of the files in the coverage data", "foreach", "(", "$", "data", "as", "$", "file", "=>", "$", "lines", ")", "{", "// Check if this file is covered", "if", "(", "$", "this", "->", "isCovered", "(", "$", "file", ")", ")", "{", "// Filter out dead code from the results", "$", "filter", "=", "function", "(", "$", "value", ",", "$", "line", "=", "null", ")", "{", "return", "$", "value", "!==", "self", "::", "DEAD", ";", "}", ";", "$", "executable", "=", "array_filter", "(", "$", "lines", ",", "$", "filter", ")", ";", "// Filter out unused code to get the lines covered", "$", "object", "=", "$", "this", ";", "$", "filter", "=", "function", "(", "$", "value", ",", "$", "line", ")", "use", "(", "$", "object", ",", "$", "file", ")", "{", "if", "(", "in_array", "(", "$", "line", ",", "$", "object", "->", "covered", "[", "$", "file", "]", ")", ")", "{", "return", "$", "value", "===", "1", ";", "}", "}", ";", "$", "covered", "=", "array_filter", "(", "$", "lines", ",", "$", "filter", ",", "ARRAY_FILTER_USE_BOTH", ")", ";", "// Store the counts for this file", "$", "coverage", "=", "[", "'covered'", "=>", "count", "(", "$", "covered", ")", ",", "'total'", "=>", "count", "(", "$", "executable", ")", ",", "]", ";", "// If a classname exists in the file,", "// store the counts against it", "if", "(", "$", "class", "=", "$", "this", "->", "getClassForFile", "(", "$", "file", ")", ")", "{", "$", "processed", "[", "'classes'", "]", "[", "$", "class", "]", "=", "$", "coverage", ";", "continue", ";", "}", "// If no class has been found, store the counts", "// directly against the file name", "$", "name", "=", "str_replace", "(", "$", "this", "->", "runner", "->", "pwd", ".", "'/'", ",", "''", ",", "$", "file", ")", ";", "$", "processed", "[", "'files'", "]", "[", "$", "name", "]", "=", "$", "coverage", ";", "}", "}", "// Store the processed data", "return", "$", "this", "->", "processed", "=", "$", "processed", ";", "}" ]
Process the raw coverage data. @return array
[ "Process", "the", "raw", "coverage", "data", "." ]
42dac9d0f52fb77b49054b15b8baecca031151dc
https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Coverage.php#L354-L407
237,307
sgoendoer/sonic
src/Identity/UOID.php
UOID.createUOID
public static function createUOID($gid = NULL, $id = NULL) { if($gid == NULL) $gid = Sonic::getContextGlobalID(); if($id == NULL) $id = Random::getUniqueRandom(); $uoid = $gid . UOID::SEPARATOR . $id; return $uoid; }
php
public static function createUOID($gid = NULL, $id = NULL) { if($gid == NULL) $gid = Sonic::getContextGlobalID(); if($id == NULL) $id = Random::getUniqueRandom(); $uoid = $gid . UOID::SEPARATOR . $id; return $uoid; }
[ "public", "static", "function", "createUOID", "(", "$", "gid", "=", "NULL", ",", "$", "id", "=", "NULL", ")", "{", "if", "(", "$", "gid", "==", "NULL", ")", "$", "gid", "=", "Sonic", "::", "getContextGlobalID", "(", ")", ";", "if", "(", "$", "id", "==", "NULL", ")", "$", "id", "=", "Random", "::", "getUniqueRandom", "(", ")", ";", "$", "uoid", "=", "$", "gid", ".", "UOID", "::", "SEPARATOR", ".", "$", "id", ";", "return", "$", "uoid", ";", "}" ]
Creates a new UOID for the current Sonic context @param $gid String The global id part of the UOID @param $id String The local id part of the UOID @return A UOID
[ "Creates", "a", "new", "UOID", "for", "the", "current", "Sonic", "context" ]
2c32ebd78607dc3e8558f10a0b7bf881d37fc168
https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Identity/UOID.php#L26-L37
237,308
sgoendoer/sonic
src/Identity/UOID.php
UOID.isValid
public static function isValid($uoid) { $uoid = explode(UOID::SEPARATOR, $uoid); if(count($uoid) != 2) return false; // check GID if(!GID::isValid($uoid[0])) return false; // check id if(!preg_match("/^[a-zA-Z0-9]+$/", $uoid[1]) || strlen($uoid[1]) != 16) { return false; } return true; }
php
public static function isValid($uoid) { $uoid = explode(UOID::SEPARATOR, $uoid); if(count($uoid) != 2) return false; // check GID if(!GID::isValid($uoid[0])) return false; // check id if(!preg_match("/^[a-zA-Z0-9]+$/", $uoid[1]) || strlen($uoid[1]) != 16) { return false; } return true; }
[ "public", "static", "function", "isValid", "(", "$", "uoid", ")", "{", "$", "uoid", "=", "explode", "(", "UOID", "::", "SEPARATOR", ",", "$", "uoid", ")", ";", "if", "(", "count", "(", "$", "uoid", ")", "!=", "2", ")", "return", "false", ";", "// check GID\r", "if", "(", "!", "GID", "::", "isValid", "(", "$", "uoid", "[", "0", "]", ")", ")", "return", "false", ";", "// check id\r", "if", "(", "!", "preg_match", "(", "\"/^[a-zA-Z0-9]+$/\"", ",", "$", "uoid", "[", "1", "]", ")", "||", "strlen", "(", "$", "uoid", "[", "1", "]", ")", "!=", "16", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Verifies, if a given UOID is valid @param $uoid String The UOID to verify @return true, of the UOID is valid, else false
[ "Verifies", "if", "a", "given", "UOID", "is", "valid" ]
2c32ebd78607dc3e8558f10a0b7bf881d37fc168
https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Identity/UOID.php#L46-L64
237,309
agentmedia/phine-news
src/News/Modules/Backend/ArticleListForm.php
ArticleListForm.AddArticlePageSelector
private function AddArticlePageSelector() { $name = 'ArticlePage'; $this->articlePageSelector = new PageSelector($name, Trans($this->Label($name)), $this->articleList->GetArticlePage()); $this->articlePageSelector->SetSite($this->Page()->GetSite()); $this->Elements()->AddElement($name, $this->articlePageSelector); }
php
private function AddArticlePageSelector() { $name = 'ArticlePage'; $this->articlePageSelector = new PageSelector($name, Trans($this->Label($name)), $this->articleList->GetArticlePage()); $this->articlePageSelector->SetSite($this->Page()->GetSite()); $this->Elements()->AddElement($name, $this->articlePageSelector); }
[ "private", "function", "AddArticlePageSelector", "(", ")", "{", "$", "name", "=", "'ArticlePage'", ";", "$", "this", "->", "articlePageSelector", "=", "new", "PageSelector", "(", "$", "name", ",", "Trans", "(", "$", "this", "->", "Label", "(", "$", "name", ")", ")", ",", "$", "this", "->", "articleList", "->", "GetArticlePage", "(", ")", ")", ";", "$", "this", "->", "articlePageSelector", "->", "SetSite", "(", "$", "this", "->", "Page", "(", ")", "->", "GetSite", "(", ")", ")", ";", "$", "this", "->", "Elements", "(", ")", "->", "AddElement", "(", "$", "name", ",", "$", "this", "->", "articlePageSelector", ")", ";", "}" ]
Adds the article page selector element
[ "Adds", "the", "article", "page", "selector", "element" ]
51abc830fecd1325f0b7d28391ecd924cdc7c945
https://github.com/agentmedia/phine-news/blob/51abc830fecd1325f0b7d28391ecd924cdc7c945/src/News/Modules/Backend/ArticleListForm.php#L106-L114
237,310
agentmedia/phine-news
src/News/Modules/Backend/ArticleListForm.php
ArticleListForm.SaveElement
protected function SaveElement() { $this->articleList->SetArticlePage($this->articlePageSelector->GetPage()); $archiveCat = explode('-', $this->Value('ArchiveCategory')); $this->CleanPageArticleLists(); if (count($archiveCat) == 1) { $this->SaveArchivePage($archiveCat[0]); } else if (count($archiveCat) == 2) { $this->SaveCategoryPage($archiveCat[1]); } return $this->articleList; }
php
protected function SaveElement() { $this->articleList->SetArticlePage($this->articlePageSelector->GetPage()); $archiveCat = explode('-', $this->Value('ArchiveCategory')); $this->CleanPageArticleLists(); if (count($archiveCat) == 1) { $this->SaveArchivePage($archiveCat[0]); } else if (count($archiveCat) == 2) { $this->SaveCategoryPage($archiveCat[1]); } return $this->articleList; }
[ "protected", "function", "SaveElement", "(", ")", "{", "$", "this", "->", "articleList", "->", "SetArticlePage", "(", "$", "this", "->", "articlePageSelector", "->", "GetPage", "(", ")", ")", ";", "$", "archiveCat", "=", "explode", "(", "'-'", ",", "$", "this", "->", "Value", "(", "'ArchiveCategory'", ")", ")", ";", "$", "this", "->", "CleanPageArticleLists", "(", ")", ";", "if", "(", "count", "(", "$", "archiveCat", ")", "==", "1", ")", "{", "$", "this", "->", "SaveArchivePage", "(", "$", "archiveCat", "[", "0", "]", ")", ";", "}", "else", "if", "(", "count", "(", "$", "archiveCat", ")", "==", "2", ")", "{", "$", "this", "->", "SaveCategoryPage", "(", "$", "archiveCat", "[", "1", "]", ")", ";", "}", "return", "$", "this", "->", "articleList", ";", "}" ]
Saves article list and attaches current page to chosen archive or category
[ "Saves", "article", "list", "and", "attaches", "current", "page", "to", "chosen", "archive", "or", "category" ]
51abc830fecd1325f0b7d28391ecd924cdc7c945
https://github.com/agentmedia/phine-news/blob/51abc830fecd1325f0b7d28391ecd924cdc7c945/src/News/Modules/Backend/ArticleListForm.php#L139-L151
237,311
agentmedia/phine-news
src/News/Modules/Backend/ArticleListForm.php
ArticleListForm.SaveArchivePage
private function SaveArchivePage($archiveID) { $archive = Archive::Schema()->ByID($archiveID); if ($archive) { $archive->SetPage($this->Page()); $archive->Save(); } }
php
private function SaveArchivePage($archiveID) { $archive = Archive::Schema()->ByID($archiveID); if ($archive) { $archive->SetPage($this->Page()); $archive->Save(); } }
[ "private", "function", "SaveArchivePage", "(", "$", "archiveID", ")", "{", "$", "archive", "=", "Archive", "::", "Schema", "(", ")", "->", "ByID", "(", "$", "archiveID", ")", ";", "if", "(", "$", "archive", ")", "{", "$", "archive", "->", "SetPage", "(", "$", "this", "->", "Page", "(", ")", ")", ";", "$", "archive", "->", "Save", "(", ")", ";", "}", "}" ]
Sets the current page to the chosen archive, if no category chosen @param int $archiveID The id of the archive
[ "Sets", "the", "current", "page", "to", "the", "chosen", "archive", "if", "no", "category", "chosen" ]
51abc830fecd1325f0b7d28391ecd924cdc7c945
https://github.com/agentmedia/phine-news/blob/51abc830fecd1325f0b7d28391ecd924cdc7c945/src/News/Modules/Backend/ArticleListForm.php#L174-L181
237,312
agentmedia/phine-news
src/News/Modules/Backend/ArticleListForm.php
ArticleListForm.SaveCategoryPage
private function SaveCategoryPage($categoryID) { $category = Category::Schema()->ByID($categoryID); if ($category) { $category->SetPage($this->Page()); $category->Save(); } }
php
private function SaveCategoryPage($categoryID) { $category = Category::Schema()->ByID($categoryID); if ($category) { $category->SetPage($this->Page()); $category->Save(); } }
[ "private", "function", "SaveCategoryPage", "(", "$", "categoryID", ")", "{", "$", "category", "=", "Category", "::", "Schema", "(", ")", "->", "ByID", "(", "$", "categoryID", ")", ";", "if", "(", "$", "category", ")", "{", "$", "category", "->", "SetPage", "(", "$", "this", "->", "Page", "(", ")", ")", ";", "$", "category", "->", "Save", "(", ")", ";", "}", "}" ]
Sets the current page tor the chosen category, if no archive chosen @param int $categoryID The id of the category
[ "Sets", "the", "current", "page", "tor", "the", "chosen", "category", "if", "no", "archive", "chosen" ]
51abc830fecd1325f0b7d28391ecd924cdc7c945
https://github.com/agentmedia/phine-news/blob/51abc830fecd1325f0b7d28391ecd924cdc7c945/src/News/Modules/Backend/ArticleListForm.php#L187-L194
237,313
Stratadox/HydrationMapping
src/Property/Relationship/HasManyEmbedded.php
HasManyEmbedded.inProperty
public static function inProperty( string $name, DeserializesCollections $collection, Deserializes $item, string $key = 'key' ): MapsProperty { return new self($name, $collection, $item, $key); }
php
public static function inProperty( string $name, DeserializesCollections $collection, Deserializes $item, string $key = 'key' ): MapsProperty { return new self($name, $collection, $item, $key); }
[ "public", "static", "function", "inProperty", "(", "string", "$", "name", ",", "DeserializesCollections", "$", "collection", ",", "Deserializes", "$", "item", ",", "string", "$", "key", "=", "'key'", ")", ":", "MapsProperty", "{", "return", "new", "self", "(", "$", "name", ",", "$", "collection", ",", "$", "item", ",", "$", "key", ")", ";", "}" ]
Creates a new embedded has-many mapping. @param string $name The name of the property. @param DeserializesCollections $collection The deserializer for the collection. @param Deserializes $item The deserializer for the individual items. @param string $key The array key to assign to the scalars, used by the deserializer for individual items. @return MapsProperty The embedded has-many mapping.
[ "Creates", "a", "new", "embedded", "has", "-", "many", "mapping", "." ]
b145deaaf76ab8c8060f0cba1a8c6f73da375982
https://github.com/Stratadox/HydrationMapping/blob/b145deaaf76ab8c8060f0cba1a8c6f73da375982/src/Property/Relationship/HasManyEmbedded.php#L53-L60
237,314
rseyferth/chickenwire
src/ChickenWire/Application.php
Application._configure
protected function _configure() { // Create my settings object $this->config = new Core\Configuration(); // Define some paths define("CHICKENWIRE_PATH", dirname(__FILE__)); define("APP_PATH", APP_ROOT . "/Application"); define("CONFIG_PATH", APP_PATH . "/Config"); define("CONTROLLER_PATH", APP_PATH . "/Controllers"); define("LAYOUT_PATH", APP_PATH . "/Layouts"); define("MODEL_PATH", APP_PATH . "/Models"); define("VIEW_PATH", APP_PATH . "/Views"); define("PUBLIC_PATH", APP_PATH . "/Public"); define("MODULE_PATH", APP_ROOT . "/Modules"); define("MODEL_NS", $this->config->applicationNamespace . "\\Models"); // Include all php files in the config directory $dh = opendir(CONFIG_PATH); $configFiles = scandir(CONFIG_PATH, SCANDIR_SORT_ASCENDING); foreach ($configFiles as $file) { // PHP? if (preg_match("/\.php$/", $file)) { // Load it $this->config->load(CONFIG_PATH . '/' . $file); } } // Initalize database configuration $dbConnections = $this->config->allFor("database"); $environment = $this->config->environment; \ActiveRecord\Config::initialize(function($config) use ($dbConnections, $environment) { // Set model path $config->setModelDirectory(MODEL_PATH); // Apply connections $config->setConnections($dbConnections); // Set default to my environment $config->setDefaultConnection($environment); }); // Set the timezone if ($this->config->timezone == '') { throw new \Exception("You need to specify the timezone in the Application configuration.", 1); } date_default_timezone_set($this->config->timezone); // Set self closing slash \HtmlObject\Traits\Tag::$useSelfClosingSlash = $this->config->htmlSelfClosingSlash; // Set the webPath $this->config->webPath = rtrim($this->config->webPath, ' /'); }
php
protected function _configure() { // Create my settings object $this->config = new Core\Configuration(); // Define some paths define("CHICKENWIRE_PATH", dirname(__FILE__)); define("APP_PATH", APP_ROOT . "/Application"); define("CONFIG_PATH", APP_PATH . "/Config"); define("CONTROLLER_PATH", APP_PATH . "/Controllers"); define("LAYOUT_PATH", APP_PATH . "/Layouts"); define("MODEL_PATH", APP_PATH . "/Models"); define("VIEW_PATH", APP_PATH . "/Views"); define("PUBLIC_PATH", APP_PATH . "/Public"); define("MODULE_PATH", APP_ROOT . "/Modules"); define("MODEL_NS", $this->config->applicationNamespace . "\\Models"); // Include all php files in the config directory $dh = opendir(CONFIG_PATH); $configFiles = scandir(CONFIG_PATH, SCANDIR_SORT_ASCENDING); foreach ($configFiles as $file) { // PHP? if (preg_match("/\.php$/", $file)) { // Load it $this->config->load(CONFIG_PATH . '/' . $file); } } // Initalize database configuration $dbConnections = $this->config->allFor("database"); $environment = $this->config->environment; \ActiveRecord\Config::initialize(function($config) use ($dbConnections, $environment) { // Set model path $config->setModelDirectory(MODEL_PATH); // Apply connections $config->setConnections($dbConnections); // Set default to my environment $config->setDefaultConnection($environment); }); // Set the timezone if ($this->config->timezone == '') { throw new \Exception("You need to specify the timezone in the Application configuration.", 1); } date_default_timezone_set($this->config->timezone); // Set self closing slash \HtmlObject\Traits\Tag::$useSelfClosingSlash = $this->config->htmlSelfClosingSlash; // Set the webPath $this->config->webPath = rtrim($this->config->webPath, ' /'); }
[ "protected", "function", "_configure", "(", ")", "{", "// Create my settings object", "$", "this", "->", "config", "=", "new", "Core", "\\", "Configuration", "(", ")", ";", "// Define some paths", "define", "(", "\"CHICKENWIRE_PATH\"", ",", "dirname", "(", "__FILE__", ")", ")", ";", "define", "(", "\"APP_PATH\"", ",", "APP_ROOT", ".", "\"/Application\"", ")", ";", "define", "(", "\"CONFIG_PATH\"", ",", "APP_PATH", ".", "\"/Config\"", ")", ";", "define", "(", "\"CONTROLLER_PATH\"", ",", "APP_PATH", ".", "\"/Controllers\"", ")", ";", "define", "(", "\"LAYOUT_PATH\"", ",", "APP_PATH", ".", "\"/Layouts\"", ")", ";", "define", "(", "\"MODEL_PATH\"", ",", "APP_PATH", ".", "\"/Models\"", ")", ";", "define", "(", "\"VIEW_PATH\"", ",", "APP_PATH", ".", "\"/Views\"", ")", ";", "define", "(", "\"PUBLIC_PATH\"", ",", "APP_PATH", ".", "\"/Public\"", ")", ";", "define", "(", "\"MODULE_PATH\"", ",", "APP_ROOT", ".", "\"/Modules\"", ")", ";", "define", "(", "\"MODEL_NS\"", ",", "$", "this", "->", "config", "->", "applicationNamespace", ".", "\"\\\\Models\"", ")", ";", "// Include all php files in the config directory", "$", "dh", "=", "opendir", "(", "CONFIG_PATH", ")", ";", "$", "configFiles", "=", "scandir", "(", "CONFIG_PATH", ",", "SCANDIR_SORT_ASCENDING", ")", ";", "foreach", "(", "$", "configFiles", "as", "$", "file", ")", "{", "// PHP?", "if", "(", "preg_match", "(", "\"/\\.php$/\"", ",", "$", "file", ")", ")", "{", "// Load it", "$", "this", "->", "config", "->", "load", "(", "CONFIG_PATH", ".", "'/'", ".", "$", "file", ")", ";", "}", "}", "// Initalize database configuration", "$", "dbConnections", "=", "$", "this", "->", "config", "->", "allFor", "(", "\"database\"", ")", ";", "$", "environment", "=", "$", "this", "->", "config", "->", "environment", ";", "\\", "ActiveRecord", "\\", "Config", "::", "initialize", "(", "function", "(", "$", "config", ")", "use", "(", "$", "dbConnections", ",", "$", "environment", ")", "{", "// Set model path", "$", "config", "->", "setModelDirectory", "(", "MODEL_PATH", ")", ";", "// Apply connections", "$", "config", "->", "setConnections", "(", "$", "dbConnections", ")", ";", "// Set default to my environment", "$", "config", "->", "setDefaultConnection", "(", "$", "environment", ")", ";", "}", ")", ";", "// Set the timezone", "if", "(", "$", "this", "->", "config", "->", "timezone", "==", "''", ")", "{", "throw", "new", "\\", "Exception", "(", "\"You need to specify the timezone in the Application configuration.\"", ",", "1", ")", ";", "}", "date_default_timezone_set", "(", "$", "this", "->", "config", "->", "timezone", ")", ";", "// Set self closing slash", "\\", "HtmlObject", "\\", "Traits", "\\", "Tag", "::", "$", "useSelfClosingSlash", "=", "$", "this", "->", "config", "->", "htmlSelfClosingSlash", ";", "// Set the webPath", "$", "this", "->", "config", "->", "webPath", "=", "rtrim", "(", "$", "this", "->", "config", "->", "webPath", ",", "' /'", ")", ";", "}" ]
Load and apply configuration files @return void @ignore
[ "Load", "and", "apply", "configuration", "files" ]
74921f0a0d489366602e25df43eda894719e43d3
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Application.php#L361-L422
237,315
rseyferth/chickenwire
src/ChickenWire/Application.php
Application._loadModules
protected function _loadModules() { // Check module directories $dh = opendir(MODULE_PATH); while (false !== ($filename = readdir($dh))) { // Directory? if (is_dir(MODULE_PATH . "/" . $filename) && !preg_match('/^\./', $filename)) { // Load the module Module::load($filename); } } }
php
protected function _loadModules() { // Check module directories $dh = opendir(MODULE_PATH); while (false !== ($filename = readdir($dh))) { // Directory? if (is_dir(MODULE_PATH . "/" . $filename) && !preg_match('/^\./', $filename)) { // Load the module Module::load($filename); } } }
[ "protected", "function", "_loadModules", "(", ")", "{", "// Check module directories", "$", "dh", "=", "opendir", "(", "MODULE_PATH", ")", ";", "while", "(", "false", "!==", "(", "$", "filename", "=", "readdir", "(", "$", "dh", ")", ")", ")", "{", "// Directory?", "if", "(", "is_dir", "(", "MODULE_PATH", ".", "\"/\"", ".", "$", "filename", ")", "&&", "!", "preg_match", "(", "'/^\\./'", ",", "$", "filename", ")", ")", "{", "// Load the module", "Module", "::", "load", "(", "$", "filename", ")", ";", "}", "}", "}" ]
Load all modules in the Modules directory @return void @ignore
[ "Load", "all", "modules", "in", "the", "Modules", "directory" ]
74921f0a0d489366602e25df43eda894719e43d3
https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Application.php#L429-L446
237,316
Aurora-Framework/Helper
src/Helper/ArrayTrait.php
ArrayTrait.set
public function set($path = null, $value = null) { if ($path === null) { $this->data = $value; return $this; } $at =& $this->data; $keys = explode(".", $path); $keyCount = count($keys); for ($i=0; $i < $keyCount; $i++) { if (($keyCount-1) === $i) { if (is_array($at)) { $at[$keys[$i]] = $value; } else { throw new \RuntimeException("Can not set value at this path ($path) because is not array."); } } else { $key = $keys[$i]; if (!isset($at[$key])) { $at[$key] = []; } $at =& $at[$key]; } } return $this; }
php
public function set($path = null, $value = null) { if ($path === null) { $this->data = $value; return $this; } $at =& $this->data; $keys = explode(".", $path); $keyCount = count($keys); for ($i=0; $i < $keyCount; $i++) { if (($keyCount-1) === $i) { if (is_array($at)) { $at[$keys[$i]] = $value; } else { throw new \RuntimeException("Can not set value at this path ($path) because is not array."); } } else { $key = $keys[$i]; if (!isset($at[$key])) { $at[$key] = []; } $at =& $at[$key]; } } return $this; }
[ "public", "function", "set", "(", "$", "path", "=", "null", ",", "$", "value", "=", "null", ")", "{", "if", "(", "$", "path", "===", "null", ")", "{", "$", "this", "->", "data", "=", "$", "value", ";", "return", "$", "this", ";", "}", "$", "at", "=", "&", "$", "this", "->", "data", ";", "$", "keys", "=", "explode", "(", "\".\"", ",", "$", "path", ")", ";", "$", "keyCount", "=", "count", "(", "$", "keys", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "keyCount", ";", "$", "i", "++", ")", "{", "if", "(", "(", "$", "keyCount", "-", "1", ")", "===", "$", "i", ")", "{", "if", "(", "is_array", "(", "$", "at", ")", ")", "{", "$", "at", "[", "$", "keys", "[", "$", "i", "]", "]", "=", "$", "value", ";", "}", "else", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Can not set value at this path ($path) because is not array.\"", ")", ";", "}", "}", "else", "{", "$", "key", "=", "$", "keys", "[", "$", "i", "]", ";", "if", "(", "!", "isset", "(", "$", "at", "[", "$", "key", "]", ")", ")", "{", "$", "at", "[", "$", "key", "]", "=", "[", "]", ";", "}", "$", "at", "=", "&", "$", "at", "[", "$", "key", "]", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set new key for data, this can also ovewrite existing data @access public @param string $key Key identifier @param mixed $value Value assigned for key
[ "Set", "new", "key", "for", "data", "this", "can", "also", "ovewrite", "existing", "data" ]
1d0fa09d641d994cf7d8136f4aff220342419804
https://github.com/Aurora-Framework/Helper/blob/1d0fa09d641d994cf7d8136f4aff220342419804/src/Helper/ArrayTrait.php#L183-L211
237,317
Aurora-Framework/Helper
src/Helper/ArrayTrait.php
ArrayTrait.get
public function get($key = null, $default = null) { $return = $this->data; if ($key !== null) { $keys = explode('.', $key); foreach ($keys as $key) { if (isset($return[(string) $key])) { $return = $return[$key]; } else { $return = $default; break; } } } return $return; }
php
public function get($key = null, $default = null) { $return = $this->data; if ($key !== null) { $keys = explode('.', $key); foreach ($keys as $key) { if (isset($return[(string) $key])) { $return = $return[$key]; } else { $return = $default; break; } } } return $return; }
[ "public", "function", "get", "(", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "$", "return", "=", "$", "this", "->", "data", ";", "if", "(", "$", "key", "!==", "null", ")", "{", "$", "keys", "=", "explode", "(", "'.'", ",", "$", "key", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "return", "[", "(", "string", ")", "$", "key", "]", ")", ")", "{", "$", "return", "=", "$", "return", "[", "$", "key", "]", ";", "}", "else", "{", "$", "return", "=", "$", "default", ";", "break", ";", "}", "}", "}", "return", "$", "return", ";", "}" ]
Get value assigned for key @access public @param string|int $key Identifier for $data @return mixed|null Value given for key
[ "Get", "value", "assigned", "for", "key" ]
1d0fa09d641d994cf7d8136f4aff220342419804
https://github.com/Aurora-Framework/Helper/blob/1d0fa09d641d994cf7d8136f4aff220342419804/src/Helper/ArrayTrait.php#L260-L278
237,318
bugotech/phar
src/Maker.php
Maker.makePhar
protected function makePhar() { $phar = new Phar($this->filePhar, 0, $this->alias); $phar->setSignatureAlgorithm(\Phar::SHA1); $phar->startBuffering(); // Adicionar arquivos $this->addFiles($phar); // Adicionar arquivo bin $this->addBinFile($phar); // Adicionar Stup $this->addStub($phar); // Adicionar licenca $this->addLicence($phar); // Adicionar arquivo de update //$this->addUpdateFile($phar); // Finalizar phar. $phar->stopBuffering(); unset($phar); }
php
protected function makePhar() { $phar = new Phar($this->filePhar, 0, $this->alias); $phar->setSignatureAlgorithm(\Phar::SHA1); $phar->startBuffering(); // Adicionar arquivos $this->addFiles($phar); // Adicionar arquivo bin $this->addBinFile($phar); // Adicionar Stup $this->addStub($phar); // Adicionar licenca $this->addLicence($phar); // Adicionar arquivo de update //$this->addUpdateFile($phar); // Finalizar phar. $phar->stopBuffering(); unset($phar); }
[ "protected", "function", "makePhar", "(", ")", "{", "$", "phar", "=", "new", "Phar", "(", "$", "this", "->", "filePhar", ",", "0", ",", "$", "this", "->", "alias", ")", ";", "$", "phar", "->", "setSignatureAlgorithm", "(", "\\", "Phar", "::", "SHA1", ")", ";", "$", "phar", "->", "startBuffering", "(", ")", ";", "// Adicionar arquivos", "$", "this", "->", "addFiles", "(", "$", "phar", ")", ";", "// Adicionar arquivo bin", "$", "this", "->", "addBinFile", "(", "$", "phar", ")", ";", "// Adicionar Stup", "$", "this", "->", "addStub", "(", "$", "phar", ")", ";", "// Adicionar licenca", "$", "this", "->", "addLicence", "(", "$", "phar", ")", ";", "// Adicionar arquivo de update", "//$this->addUpdateFile($phar);", "// Finalizar phar.", "$", "phar", "->", "stopBuffering", "(", ")", ";", "unset", "(", "$", "phar", ")", ";", "}" ]
Gerar arquivo PHAR.
[ "Gerar", "arquivo", "PHAR", "." ]
96f226d2c4bb1787fd41a3c67fe64b10de22b7af
https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L96-L120
237,319
bugotech/phar
src/Maker.php
Maker.makeBat
protected function makeBat() { $content = $this->files->get(__DIR__ . '/../stubs/bat.stub'); $content = str_replace('DubbyAlias', $this->alias, $content); $this->files->put($this->fileBat, $content); }
php
protected function makeBat() { $content = $this->files->get(__DIR__ . '/../stubs/bat.stub'); $content = str_replace('DubbyAlias', $this->alias, $content); $this->files->put($this->fileBat, $content); }
[ "protected", "function", "makeBat", "(", ")", "{", "$", "content", "=", "$", "this", "->", "files", "->", "get", "(", "__DIR__", ".", "'/../stubs/bat.stub'", ")", ";", "$", "content", "=", "str_replace", "(", "'DubbyAlias'", ",", "$", "this", "->", "alias", ",", "$", "content", ")", ";", "$", "this", "->", "files", "->", "put", "(", "$", "this", "->", "fileBat", ",", "$", "content", ")", ";", "}" ]
Gerar arquivo BAT.
[ "Gerar", "arquivo", "BAT", "." ]
96f226d2c4bb1787fd41a3c67fe64b10de22b7af
https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L125-L130
237,320
bugotech/phar
src/Maker.php
Maker.resetPhar
protected function resetPhar() { if ($this->files->exists($this->filePhar)) { $this->files->delete($this->filePhar); } if ($this->files->exists($this->fileBat)) { $this->files->delete($this->fileBat); } }
php
protected function resetPhar() { if ($this->files->exists($this->filePhar)) { $this->files->delete($this->filePhar); } if ($this->files->exists($this->fileBat)) { $this->files->delete($this->fileBat); } }
[ "protected", "function", "resetPhar", "(", ")", "{", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "this", "->", "filePhar", ")", ")", "{", "$", "this", "->", "files", "->", "delete", "(", "$", "this", "->", "filePhar", ")", ";", "}", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "this", "->", "fileBat", ")", ")", "{", "$", "this", "->", "files", "->", "delete", "(", "$", "this", "->", "fileBat", ")", ";", "}", "}" ]
Reiniciar arquivos compilados.
[ "Reiniciar", "arquivos", "compilados", "." ]
96f226d2c4bb1787fd41a3c67fe64b10de22b7af
https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L135-L144
237,321
bugotech/phar
src/Maker.php
Maker.setName
public function setName($name) { $this->name = $name; $this->alias = $name . '.phar'; $this->filePhar = $this->files->combine($this->pathBase, $this->alias); $this->fileBat = $this->files->combine($this->pathBase, $name . '.bat'); }
php
public function setName($name) { $this->name = $name; $this->alias = $name . '.phar'; $this->filePhar = $this->files->combine($this->pathBase, $this->alias); $this->fileBat = $this->files->combine($this->pathBase, $name . '.bat'); }
[ "public", "function", "setName", "(", "$", "name", ")", "{", "$", "this", "->", "name", "=", "$", "name", ";", "$", "this", "->", "alias", "=", "$", "name", ".", "'.phar'", ";", "$", "this", "->", "filePhar", "=", "$", "this", "->", "files", "->", "combine", "(", "$", "this", "->", "pathBase", ",", "$", "this", "->", "alias", ")", ";", "$", "this", "->", "fileBat", "=", "$", "this", "->", "files", "->", "combine", "(", "$", "this", "->", "pathBase", ",", "$", "name", ".", "'.bat'", ")", ";", "}" ]
Set name app. @param string $name
[ "Set", "name", "app", "." ]
96f226d2c4bb1787fd41a3c67fe64b10de22b7af
https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L150-L156
237,322
bugotech/phar
src/Maker.php
Maker.addFiles
public function addFiles(Phar $phar) { $finder = new Finder(); $finder->files() ->ignoreVCS(true) ->name('*.php') ->name('*.stub') ->exclude('Tests') ->exclude('tests') ->exclude('/storage') ->exclude('/config') ->exclude('/build') ->in($this->pathBase); foreach ($finder as $file) { $this->addFile($phar, $file); } }
php
public function addFiles(Phar $phar) { $finder = new Finder(); $finder->files() ->ignoreVCS(true) ->name('*.php') ->name('*.stub') ->exclude('Tests') ->exclude('tests') ->exclude('/storage') ->exclude('/config') ->exclude('/build') ->in($this->pathBase); foreach ($finder as $file) { $this->addFile($phar, $file); } }
[ "public", "function", "addFiles", "(", "Phar", "$", "phar", ")", "{", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "files", "(", ")", "->", "ignoreVCS", "(", "true", ")", "->", "name", "(", "'*.php'", ")", "->", "name", "(", "'*.stub'", ")", "->", "exclude", "(", "'Tests'", ")", "->", "exclude", "(", "'tests'", ")", "->", "exclude", "(", "'/storage'", ")", "->", "exclude", "(", "'/config'", ")", "->", "exclude", "(", "'/build'", ")", "->", "in", "(", "$", "this", "->", "pathBase", ")", ";", "foreach", "(", "$", "finder", "as", "$", "file", ")", "{", "$", "this", "->", "addFile", "(", "$", "phar", ",", "$", "file", ")", ";", "}", "}" ]
Adicionar arquivos. @param Phar $phar
[ "Adicionar", "arquivos", "." ]
96f226d2c4bb1787fd41a3c67fe64b10de22b7af
https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L189-L205
237,323
bugotech/phar
src/Maker.php
Maker.addFile
private function addFile(Phar $phar, SplFileInfo $file, $strip = false) { // Forçar tirar espaços de PHP. $strip = ($file->getExtension() == 'php') ? true : $strip; $this->fireEvent($file->getRealPath()); $path = str_replace($this->pathBase, '', $file->getRealPath()); $content = $this->files->get($file); // Tratar espacos? if ($strip) { $content = $this->stripWhitespace($content); } // Eh arquivo de licenca? if ('LICENSE' === basename($file)) { $content = "\n" . $content . "\n"; } // Tratar parametros foreach ($this->params as $pk => $pv) { $pk = sprintf('@%s@', $pk); $content = str_replace($pk, $pv, $content); } $phar->addFromString($path, $content); }
php
private function addFile(Phar $phar, SplFileInfo $file, $strip = false) { // Forçar tirar espaços de PHP. $strip = ($file->getExtension() == 'php') ? true : $strip; $this->fireEvent($file->getRealPath()); $path = str_replace($this->pathBase, '', $file->getRealPath()); $content = $this->files->get($file); // Tratar espacos? if ($strip) { $content = $this->stripWhitespace($content); } // Eh arquivo de licenca? if ('LICENSE' === basename($file)) { $content = "\n" . $content . "\n"; } // Tratar parametros foreach ($this->params as $pk => $pv) { $pk = sprintf('@%s@', $pk); $content = str_replace($pk, $pv, $content); } $phar->addFromString($path, $content); }
[ "private", "function", "addFile", "(", "Phar", "$", "phar", ",", "SplFileInfo", "$", "file", ",", "$", "strip", "=", "false", ")", "{", "// Forçar tirar espaços de PHP.", "$", "strip", "=", "(", "$", "file", "->", "getExtension", "(", ")", "==", "'php'", ")", "?", "true", ":", "$", "strip", ";", "$", "this", "->", "fireEvent", "(", "$", "file", "->", "getRealPath", "(", ")", ")", ";", "$", "path", "=", "str_replace", "(", "$", "this", "->", "pathBase", ",", "''", ",", "$", "file", "->", "getRealPath", "(", ")", ")", ";", "$", "content", "=", "$", "this", "->", "files", "->", "get", "(", "$", "file", ")", ";", "// Tratar espacos?", "if", "(", "$", "strip", ")", "{", "$", "content", "=", "$", "this", "->", "stripWhitespace", "(", "$", "content", ")", ";", "}", "// Eh arquivo de licenca?", "if", "(", "'LICENSE'", "===", "basename", "(", "$", "file", ")", ")", "{", "$", "content", "=", "\"\\n\"", ".", "$", "content", ".", "\"\\n\"", ";", "}", "// Tratar parametros", "foreach", "(", "$", "this", "->", "params", "as", "$", "pk", "=>", "$", "pv", ")", "{", "$", "pk", "=", "sprintf", "(", "'@%s@'", ",", "$", "pk", ")", ";", "$", "content", "=", "str_replace", "(", "$", "pk", ",", "$", "pv", ",", "$", "content", ")", ";", "}", "$", "phar", "->", "addFromString", "(", "$", "path", ",", "$", "content", ")", ";", "}" ]
Adicionar arquivo tratado no phar. @param Phar $phar @param SplFileInfo $file @param bool $strip
[ "Adicionar", "arquivo", "tratado", "no", "phar", "." ]
96f226d2c4bb1787fd41a3c67fe64b10de22b7af
https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L214-L240
237,324
bugotech/phar
src/Maker.php
Maker.addBinFile
protected function addBinFile(Phar $phar) { $fileBin = $this->files->combine($this->pathBase, $this->fileNameBin); if (! $this->files->exists($fileBin)) { return; } $this->fireEvent('BIN: file main'); $content = $this->files->get($fileBin); $content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content); $phar->addFromString('artisan', $content); }
php
protected function addBinFile(Phar $phar) { $fileBin = $this->files->combine($this->pathBase, $this->fileNameBin); if (! $this->files->exists($fileBin)) { return; } $this->fireEvent('BIN: file main'); $content = $this->files->get($fileBin); $content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content); $phar->addFromString('artisan', $content); }
[ "protected", "function", "addBinFile", "(", "Phar", "$", "phar", ")", "{", "$", "fileBin", "=", "$", "this", "->", "files", "->", "combine", "(", "$", "this", "->", "pathBase", ",", "$", "this", "->", "fileNameBin", ")", ";", "if", "(", "!", "$", "this", "->", "files", "->", "exists", "(", "$", "fileBin", ")", ")", "{", "return", ";", "}", "$", "this", "->", "fireEvent", "(", "'BIN: file main'", ")", ";", "$", "content", "=", "$", "this", "->", "files", "->", "get", "(", "$", "fileBin", ")", ";", "$", "content", "=", "preg_replace", "(", "'{^#!/usr/bin/env php\\s*}'", ",", "''", ",", "$", "content", ")", ";", "$", "phar", "->", "addFromString", "(", "'artisan'", ",", "$", "content", ")", ";", "}" ]
Adicionar arquivo BIN. @param Phar $phar
[ "Adicionar", "arquivo", "BIN", "." ]
96f226d2c4bb1787fd41a3c67fe64b10de22b7af
https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L246-L258
237,325
bugotech/phar
src/Maker.php
Maker.addStub
protected function addStub(Phar $phar) { $this->fireEvent('STUB'); // Add warning once the phar is older than 30 days $defineTime = ''; if (array_key_exists('package_version', $this->params)) { $warningTime = time() + 30 * 86400; $defineTime = "define('PHAR_DEV_WARNING_TIME', $warningTime);\n"; } $content = $this->files->get(__DIR__ . '/../stubs/compile.stub'); $content = str_replace('DubbyAlias', $this->alias, $content); $content = str_replace('DubbyDefineDateTime', $defineTime, $content); $phar->setStub($content); }
php
protected function addStub(Phar $phar) { $this->fireEvent('STUB'); // Add warning once the phar is older than 30 days $defineTime = ''; if (array_key_exists('package_version', $this->params)) { $warningTime = time() + 30 * 86400; $defineTime = "define('PHAR_DEV_WARNING_TIME', $warningTime);\n"; } $content = $this->files->get(__DIR__ . '/../stubs/compile.stub'); $content = str_replace('DubbyAlias', $this->alias, $content); $content = str_replace('DubbyDefineDateTime', $defineTime, $content); $phar->setStub($content); }
[ "protected", "function", "addStub", "(", "Phar", "$", "phar", ")", "{", "$", "this", "->", "fireEvent", "(", "'STUB'", ")", ";", "// Add warning once the phar is older than 30 days", "$", "defineTime", "=", "''", ";", "if", "(", "array_key_exists", "(", "'package_version'", ",", "$", "this", "->", "params", ")", ")", "{", "$", "warningTime", "=", "time", "(", ")", "+", "30", "*", "86400", ";", "$", "defineTime", "=", "\"define('PHAR_DEV_WARNING_TIME', $warningTime);\\n\"", ";", "}", "$", "content", "=", "$", "this", "->", "files", "->", "get", "(", "__DIR__", ".", "'/../stubs/compile.stub'", ")", ";", "$", "content", "=", "str_replace", "(", "'DubbyAlias'", ",", "$", "this", "->", "alias", ",", "$", "content", ")", ";", "$", "content", "=", "str_replace", "(", "'DubbyDefineDateTime'", ",", "$", "defineTime", ",", "$", "content", ")", ";", "$", "phar", "->", "setStub", "(", "$", "content", ")", ";", "}" ]
Adicionar Stub. @param Phar $phar
[ "Adicionar", "Stub", "." ]
96f226d2c4bb1787fd41a3c67fe64b10de22b7af
https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L264-L280
237,326
bugotech/phar
src/Maker.php
Maker.addLicence
protected function addLicence(Phar $phar) { $file = $this->files->combine($this->pathBase, 'LICENSE'); if (! $this->files->exists($file)) { return; } $this->fireEvent('LICENCE'); $this->addFile($phar, new SplFileInfo($file), false); }
php
protected function addLicence(Phar $phar) { $file = $this->files->combine($this->pathBase, 'LICENSE'); if (! $this->files->exists($file)) { return; } $this->fireEvent('LICENCE'); $this->addFile($phar, new SplFileInfo($file), false); }
[ "protected", "function", "addLicence", "(", "Phar", "$", "phar", ")", "{", "$", "file", "=", "$", "this", "->", "files", "->", "combine", "(", "$", "this", "->", "pathBase", ",", "'LICENSE'", ")", ";", "if", "(", "!", "$", "this", "->", "files", "->", "exists", "(", "$", "file", ")", ")", "{", "return", ";", "}", "$", "this", "->", "fireEvent", "(", "'LICENCE'", ")", ";", "$", "this", "->", "addFile", "(", "$", "phar", ",", "new", "SplFileInfo", "(", "$", "file", ")", ",", "false", ")", ";", "}" ]
Adicionar arquivo de licenca. @param Phar $phar
[ "Adicionar", "arquivo", "de", "licenca", "." ]
96f226d2c4bb1787fd41a3c67fe64b10de22b7af
https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L286-L295
237,327
bugotech/phar
src/Maker.php
Maker.addUpdateFile
protected function addUpdateFile(Phar $phar) { $file = $this->files->combine($this->pathBase, 'update.json'); if ($this->files->exists($file)) { $this->addFile($phar, new SplFileInfo($file), false); } }
php
protected function addUpdateFile(Phar $phar) { $file = $this->files->combine($this->pathBase, 'update.json'); if ($this->files->exists($file)) { $this->addFile($phar, new SplFileInfo($file), false); } }
[ "protected", "function", "addUpdateFile", "(", "Phar", "$", "phar", ")", "{", "$", "file", "=", "$", "this", "->", "files", "->", "combine", "(", "$", "this", "->", "pathBase", ",", "'update.json'", ")", ";", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "file", ")", ")", "{", "$", "this", "->", "addFile", "(", "$", "phar", ",", "new", "SplFileInfo", "(", "$", "file", ")", ",", "false", ")", ";", "}", "}" ]
Adicionar arquivo para update. @param Phar $phar
[ "Adicionar", "arquivo", "para", "update", "." ]
96f226d2c4bb1787fd41a3c67fe64b10de22b7af
https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L301-L307
237,328
bugotech/phar
src/Maker.php
Maker.stripWhitespace
private function stripWhitespace($source) { // Verificar se token_get_all existe if (! function_exists('token_get_all')) { return $source; } $output = ''; foreach (token_get_all($source) as $token) { if (is_string($token)) { $output .= $token; } elseif (in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) { $output .= str_repeat("\n", substr_count($token[1], "\n")); } elseif (T_WHITESPACE === $token[0]) { // reduce wide spaces $whitespace = preg_replace('{[ \t]+}', ' ', $token[1]); // normalize newlines to \n $whitespace = preg_replace('{(?:\r\n|\r|\n)}', "\n", $whitespace); // trim leading spaces $whitespace = preg_replace('{\n +}', "\n", $whitespace); $output .= $whitespace; } else { $output .= $token[1]; } } return $output; }
php
private function stripWhitespace($source) { // Verificar se token_get_all existe if (! function_exists('token_get_all')) { return $source; } $output = ''; foreach (token_get_all($source) as $token) { if (is_string($token)) { $output .= $token; } elseif (in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) { $output .= str_repeat("\n", substr_count($token[1], "\n")); } elseif (T_WHITESPACE === $token[0]) { // reduce wide spaces $whitespace = preg_replace('{[ \t]+}', ' ', $token[1]); // normalize newlines to \n $whitespace = preg_replace('{(?:\r\n|\r|\n)}', "\n", $whitespace); // trim leading spaces $whitespace = preg_replace('{\n +}', "\n", $whitespace); $output .= $whitespace; } else { $output .= $token[1]; } } return $output; }
[ "private", "function", "stripWhitespace", "(", "$", "source", ")", "{", "// Verificar se token_get_all existe", "if", "(", "!", "function_exists", "(", "'token_get_all'", ")", ")", "{", "return", "$", "source", ";", "}", "$", "output", "=", "''", ";", "foreach", "(", "token_get_all", "(", "$", "source", ")", "as", "$", "token", ")", "{", "if", "(", "is_string", "(", "$", "token", ")", ")", "{", "$", "output", ".=", "$", "token", ";", "}", "elseif", "(", "in_array", "(", "$", "token", "[", "0", "]", ",", "[", "T_COMMENT", ",", "T_DOC_COMMENT", "]", ")", ")", "{", "$", "output", ".=", "str_repeat", "(", "\"\\n\"", ",", "substr_count", "(", "$", "token", "[", "1", "]", ",", "\"\\n\"", ")", ")", ";", "}", "elseif", "(", "T_WHITESPACE", "===", "$", "token", "[", "0", "]", ")", "{", "// reduce wide spaces", "$", "whitespace", "=", "preg_replace", "(", "'{[ \\t]+}'", ",", "' '", ",", "$", "token", "[", "1", "]", ")", ";", "// normalize newlines to \\n", "$", "whitespace", "=", "preg_replace", "(", "'{(?:\\r\\n|\\r|\\n)}'", ",", "\"\\n\"", ",", "$", "whitespace", ")", ";", "// trim leading spaces", "$", "whitespace", "=", "preg_replace", "(", "'{\\n +}'", ",", "\"\\n\"", ",", "$", "whitespace", ")", ";", "$", "output", ".=", "$", "whitespace", ";", "}", "else", "{", "$", "output", ".=", "$", "token", "[", "1", "]", ";", "}", "}", "return", "$", "output", ";", "}" ]
Removes whitespace from a PHP source string while preserving line numbers. @param string $source A PHP string @return string The PHP string with the whitespace removed
[ "Removes", "whitespace", "from", "a", "PHP", "source", "string", "while", "preserving", "line", "numbers", "." ]
96f226d2c4bb1787fd41a3c67fe64b10de22b7af
https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L315-L342
237,329
frankfoerster/cakephp-filter
src/Model/Table/FiltersTable.php
FiltersTable.findFilterDataBySlug
public function findFilterDataBySlug(Query $query, array $options) { if (!isset($options['request']) || get_class($options['request']) !== ServerRequest::class) { user_error('The request query option must exist and must be of type Cake\Http\ServerRequest.'); } $encryptedFilterData = $this->_findEncryptedFilterData($query, $options['request'])->first(); if ($encryptedFilterData) { $encryptedFilterData = $encryptedFilterData->toArray(); return $this->_decodeFilterData($encryptedFilterData['filter_data']); } return []; }
php
public function findFilterDataBySlug(Query $query, array $options) { if (!isset($options['request']) || get_class($options['request']) !== ServerRequest::class) { user_error('The request query option must exist and must be of type Cake\Http\ServerRequest.'); } $encryptedFilterData = $this->_findEncryptedFilterData($query, $options['request'])->first(); if ($encryptedFilterData) { $encryptedFilterData = $encryptedFilterData->toArray(); return $this->_decodeFilterData($encryptedFilterData['filter_data']); } return []; }
[ "public", "function", "findFilterDataBySlug", "(", "Query", "$", "query", ",", "array", "$", "options", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'request'", "]", ")", "||", "get_class", "(", "$", "options", "[", "'request'", "]", ")", "!==", "ServerRequest", "::", "class", ")", "{", "user_error", "(", "'The request query option must exist and must be of type Cake\\Http\\ServerRequest.'", ")", ";", "}", "$", "encryptedFilterData", "=", "$", "this", "->", "_findEncryptedFilterData", "(", "$", "query", ",", "$", "options", "[", "'request'", "]", ")", "->", "first", "(", ")", ";", "if", "(", "$", "encryptedFilterData", ")", "{", "$", "encryptedFilterData", "=", "$", "encryptedFilterData", "->", "toArray", "(", ")", ";", "return", "$", "this", "->", "_decodeFilterData", "(", "$", "encryptedFilterData", "[", "'filter_data'", "]", ")", ";", "}", "return", "[", "]", ";", "}" ]
Find stored filter data for a given slug. @param Query $query @param array $options @return array
[ "Find", "stored", "filter", "data", "for", "a", "given", "slug", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Model/Table/FiltersTable.php#L70-L84
237,330
frankfoerster/cakephp-filter
src/Model/Table/FiltersTable.php
FiltersTable.createFilterForFilterData
public function createFilterForFilterData(ServerRequest $request, array $filterData) { $charlist = 'abcdefghikmnopqrstuvwxyz'; do { $slug = ''; for ($i = 0; $i < 14; $i++) { $slug .= substr($charlist, rand(0, 31), 1); } } while ($this->_slugExists($slug, $request)); $this->save(new Filter([ 'plugin' => $request->getParam('plugin'), 'controller' => $request->getParam('controller'), 'action' => $request->getParam('action'), 'slug' => $slug, 'filter_data' => $this->_encodeFilterData($filterData) ])); return $slug; }
php
public function createFilterForFilterData(ServerRequest $request, array $filterData) { $charlist = 'abcdefghikmnopqrstuvwxyz'; do { $slug = ''; for ($i = 0; $i < 14; $i++) { $slug .= substr($charlist, rand(0, 31), 1); } } while ($this->_slugExists($slug, $request)); $this->save(new Filter([ 'plugin' => $request->getParam('plugin'), 'controller' => $request->getParam('controller'), 'action' => $request->getParam('action'), 'slug' => $slug, 'filter_data' => $this->_encodeFilterData($filterData) ])); return $slug; }
[ "public", "function", "createFilterForFilterData", "(", "ServerRequest", "$", "request", ",", "array", "$", "filterData", ")", "{", "$", "charlist", "=", "'abcdefghikmnopqrstuvwxyz'", ";", "do", "{", "$", "slug", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "14", ";", "$", "i", "++", ")", "{", "$", "slug", ".=", "substr", "(", "$", "charlist", ",", "rand", "(", "0", ",", "31", ")", ",", "1", ")", ";", "}", "}", "while", "(", "$", "this", "->", "_slugExists", "(", "$", "slug", ",", "$", "request", ")", ")", ";", "$", "this", "->", "save", "(", "new", "Filter", "(", "[", "'plugin'", "=>", "$", "request", "->", "getParam", "(", "'plugin'", ")", ",", "'controller'", "=>", "$", "request", "->", "getParam", "(", "'controller'", ")", ",", "'action'", "=>", "$", "request", "->", "getParam", "(", "'action'", ")", ",", "'slug'", "=>", "$", "slug", ",", "'filter_data'", "=>", "$", "this", "->", "_encodeFilterData", "(", "$", "filterData", ")", "]", ")", ")", ";", "return", "$", "slug", ";", "}" ]
Create a new filter entry for the given request and filter data. @param ServerRequest $request @param array $filterData @return string The slug representing the given $filterData.
[ "Create", "a", "new", "filter", "entry", "for", "the", "given", "request", "and", "filter", "data", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Model/Table/FiltersTable.php#L93-L113
237,331
frankfoerster/cakephp-filter
src/Model/Table/FiltersTable.php
FiltersTable._pluginCondition
protected function _pluginCondition(ServerRequest $request) { if ($request->getParam('plugin') !== null) { return [$this->getAlias() . '.plugin' => $request->getParam('plugin')]; } return [$this->getAlias() . '.plugin IS NULL']; }
php
protected function _pluginCondition(ServerRequest $request) { if ($request->getParam('plugin') !== null) { return [$this->getAlias() . '.plugin' => $request->getParam('plugin')]; } return [$this->getAlias() . '.plugin IS NULL']; }
[ "protected", "function", "_pluginCondition", "(", "ServerRequest", "$", "request", ")", "{", "if", "(", "$", "request", "->", "getParam", "(", "'plugin'", ")", "!==", "null", ")", "{", "return", "[", "$", "this", "->", "getAlias", "(", ")", ".", "'.plugin'", "=>", "$", "request", "->", "getParam", "(", "'plugin'", ")", "]", ";", "}", "return", "[", "$", "this", "->", "getAlias", "(", ")", ".", "'.plugin IS NULL'", "]", ";", "}" ]
Get the plugin query condition for a given request. @param ServerRequest $request @return array
[ "Get", "the", "plugin", "query", "condition", "for", "a", "given", "request", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Model/Table/FiltersTable.php#L143-L150
237,332
frankfoerster/cakephp-filter
src/Model/Table/FiltersTable.php
FiltersTable._slugExists
protected function _slugExists($slug, ServerRequest $request) { $existingSlug = $this->find('all') ->select($this->getAlias() . '.slug') ->where([ $this->getAlias() . '.slug' => $slug, $this->getAlias() . '.controller' => $request->getParam('controller'), $this->getAlias() . '.action' => $request->getParam('action') ]) ->where($this->_pluginCondition($request)) ->enableHydration(false) ->first(); return $existingSlug !== null; }
php
protected function _slugExists($slug, ServerRequest $request) { $existingSlug = $this->find('all') ->select($this->getAlias() . '.slug') ->where([ $this->getAlias() . '.slug' => $slug, $this->getAlias() . '.controller' => $request->getParam('controller'), $this->getAlias() . '.action' => $request->getParam('action') ]) ->where($this->_pluginCondition($request)) ->enableHydration(false) ->first(); return $existingSlug !== null; }
[ "protected", "function", "_slugExists", "(", "$", "slug", ",", "ServerRequest", "$", "request", ")", "{", "$", "existingSlug", "=", "$", "this", "->", "find", "(", "'all'", ")", "->", "select", "(", "$", "this", "->", "getAlias", "(", ")", ".", "'.slug'", ")", "->", "where", "(", "[", "$", "this", "->", "getAlias", "(", ")", ".", "'.slug'", "=>", "$", "slug", ",", "$", "this", "->", "getAlias", "(", ")", ".", "'.controller'", "=>", "$", "request", "->", "getParam", "(", "'controller'", ")", ",", "$", "this", "->", "getAlias", "(", ")", ".", "'.action'", "=>", "$", "request", "->", "getParam", "(", "'action'", ")", "]", ")", "->", "where", "(", "$", "this", "->", "_pluginCondition", "(", "$", "request", ")", ")", "->", "enableHydration", "(", "false", ")", "->", "first", "(", ")", ";", "return", "$", "existingSlug", "!==", "null", ";", "}" ]
Check if a slug for the given request params already exists. @param string $slug @param ServerRequest $request @return bool
[ "Check", "if", "a", "slug", "for", "the", "given", "request", "params", "already", "exists", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Model/Table/FiltersTable.php#L159-L173
237,333
frankfoerster/cakephp-filter
src/Model/Table/FiltersTable.php
FiltersTable._findEncryptedFilterData
protected function _findEncryptedFilterData(Query $query, ServerRequest $request) { return $query ->select($this->getAlias() . '.filter_data') ->where([ $this->getAlias() . '.controller' => $request->getParam('controller'), $this->getAlias() . '.action' => $request->getParam('action'), $this->getAlias() . '.slug' => $request->getParam('sluggedFilter') ]) ->where($this->_pluginCondition($request)); }
php
protected function _findEncryptedFilterData(Query $query, ServerRequest $request) { return $query ->select($this->getAlias() . '.filter_data') ->where([ $this->getAlias() . '.controller' => $request->getParam('controller'), $this->getAlias() . '.action' => $request->getParam('action'), $this->getAlias() . '.slug' => $request->getParam('sluggedFilter') ]) ->where($this->_pluginCondition($request)); }
[ "protected", "function", "_findEncryptedFilterData", "(", "Query", "$", "query", ",", "ServerRequest", "$", "request", ")", "{", "return", "$", "query", "->", "select", "(", "$", "this", "->", "getAlias", "(", ")", ".", "'.filter_data'", ")", "->", "where", "(", "[", "$", "this", "->", "getAlias", "(", ")", ".", "'.controller'", "=>", "$", "request", "->", "getParam", "(", "'controller'", ")", ",", "$", "this", "->", "getAlias", "(", ")", ".", "'.action'", "=>", "$", "request", "->", "getParam", "(", "'action'", ")", ",", "$", "this", "->", "getAlias", "(", ")", ".", "'.slug'", "=>", "$", "request", "->", "getParam", "(", "'sluggedFilter'", ")", "]", ")", "->", "where", "(", "$", "this", "->", "_pluginCondition", "(", "$", "request", ")", ")", ";", "}" ]
Find encrypted filter data for the given request and the provided sluggedFilter. @param Query $query @param ServerRequest $request @return Query
[ "Find", "encrypted", "filter", "data", "for", "the", "given", "request", "and", "the", "provided", "sluggedFilter", "." ]
539ec2d5c01c9b00766a6db98b60f32832fa5dee
https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Model/Table/FiltersTable.php#L182-L192
237,334
nia-php/requestresponse-http
sources/HttpRequest.php
HttpRequest.determineMethod
private function determineMethod(array $server): string { $mapping = [ 'GET' => self::METHOD_GET, 'POST' => self::METHOD_POST, 'PUT' => self::METHOD_PUT, 'PATCH' => self::METHOD_PATCH, 'DELETE' => self::METHOD_DELETE, 'HEAD' => self::METHOD_HEAD, 'OPTIONS' => self::METHOD_OPTIONS, 'CONNECT' => self::METHOD_CONNECT, 'TRACE' => self::METHOD_TRACE ]; $method = $server['REQUEST_METHOD']; if (array_key_exists($method, $mapping)) { return $mapping[$method]; } return self::METHOD_GET; }
php
private function determineMethod(array $server): string { $mapping = [ 'GET' => self::METHOD_GET, 'POST' => self::METHOD_POST, 'PUT' => self::METHOD_PUT, 'PATCH' => self::METHOD_PATCH, 'DELETE' => self::METHOD_DELETE, 'HEAD' => self::METHOD_HEAD, 'OPTIONS' => self::METHOD_OPTIONS, 'CONNECT' => self::METHOD_CONNECT, 'TRACE' => self::METHOD_TRACE ]; $method = $server['REQUEST_METHOD']; if (array_key_exists($method, $mapping)) { return $mapping[$method]; } return self::METHOD_GET; }
[ "private", "function", "determineMethod", "(", "array", "$", "server", ")", ":", "string", "{", "$", "mapping", "=", "[", "'GET'", "=>", "self", "::", "METHOD_GET", ",", "'POST'", "=>", "self", "::", "METHOD_POST", ",", "'PUT'", "=>", "self", "::", "METHOD_PUT", ",", "'PATCH'", "=>", "self", "::", "METHOD_PATCH", ",", "'DELETE'", "=>", "self", "::", "METHOD_DELETE", ",", "'HEAD'", "=>", "self", "::", "METHOD_HEAD", ",", "'OPTIONS'", "=>", "self", "::", "METHOD_OPTIONS", ",", "'CONNECT'", "=>", "self", "::", "METHOD_CONNECT", ",", "'TRACE'", "=>", "self", "::", "METHOD_TRACE", "]", ";", "$", "method", "=", "$", "server", "[", "'REQUEST_METHOD'", "]", ";", "if", "(", "array_key_exists", "(", "$", "method", ",", "$", "mapping", ")", ")", "{", "return", "$", "mapping", "[", "$", "method", "]", ";", "}", "return", "self", "::", "METHOD_GET", ";", "}" ]
Determines the used method by using passed server configuration. @param string[] $server The server configuration. @return string The determined method.
[ "Determines", "the", "used", "method", "by", "using", "passed", "server", "configuration", "." ]
9c9c4c5344812aff9dc50f4c930051241af2f989
https://github.com/nia-php/requestresponse-http/blob/9c9c4c5344812aff9dc50f4c930051241af2f989/sources/HttpRequest.php#L345-L366
237,335
nia-php/requestresponse-http
sources/HttpRequest.php
HttpRequest.determineHeader
private function determineHeader(array $server): MapInterface { $header = new Map(); foreach ($server as $name => $value) { if (strpos($name, 'HTTP_') === 0) { $name = substr($name, 5); $name = explode('_', $name); $name = array_map('strtolower', $name); $name = array_map('ucfirst', $name); $name = implode('-', $name); $header->set($name, $value); } } return new ReadOnlyMap($header); }
php
private function determineHeader(array $server): MapInterface { $header = new Map(); foreach ($server as $name => $value) { if (strpos($name, 'HTTP_') === 0) { $name = substr($name, 5); $name = explode('_', $name); $name = array_map('strtolower', $name); $name = array_map('ucfirst', $name); $name = implode('-', $name); $header->set($name, $value); } } return new ReadOnlyMap($header); }
[ "private", "function", "determineHeader", "(", "array", "$", "server", ")", ":", "MapInterface", "{", "$", "header", "=", "new", "Map", "(", ")", ";", "foreach", "(", "$", "server", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "name", ",", "'HTTP_'", ")", "===", "0", ")", "{", "$", "name", "=", "substr", "(", "$", "name", ",", "5", ")", ";", "$", "name", "=", "explode", "(", "'_'", ",", "$", "name", ")", ";", "$", "name", "=", "array_map", "(", "'strtolower'", ",", "$", "name", ")", ";", "$", "name", "=", "array_map", "(", "'ucfirst'", ",", "$", "name", ")", ";", "$", "name", "=", "implode", "(", "'-'", ",", "$", "name", ")", ";", "$", "header", "->", "set", "(", "$", "name", ",", "$", "value", ")", ";", "}", "}", "return", "new", "ReadOnlyMap", "(", "$", "header", ")", ";", "}" ]
Determines the header by using passed server configuration. @param string[] $server The server configuration. @return MapInterface The determined header as a map.
[ "Determines", "the", "header", "by", "using", "passed", "server", "configuration", "." ]
9c9c4c5344812aff9dc50f4c930051241af2f989
https://github.com/nia-php/requestresponse-http/blob/9c9c4c5344812aff9dc50f4c930051241af2f989/sources/HttpRequest.php#L375-L392
237,336
nia-php/requestresponse-http
sources/HttpRequest.php
HttpRequest.determinePath
private function determinePath(array $server): string { $path = ''; if (strpos($server['SCRIPT_NAME'], 'index.php') !== false) { $path = str_replace('index.php', '', $server['SCRIPT_NAME']); } $parts = explode('?', $server['REQUEST_URI']); $length = 0; if ($path !== '' && strpos($parts[0], $path) === 0) { $length = strlen($path); } return '/' . ltrim(substr($parts[0], $length), '/'); }
php
private function determinePath(array $server): string { $path = ''; if (strpos($server['SCRIPT_NAME'], 'index.php') !== false) { $path = str_replace('index.php', '', $server['SCRIPT_NAME']); } $parts = explode('?', $server['REQUEST_URI']); $length = 0; if ($path !== '' && strpos($parts[0], $path) === 0) { $length = strlen($path); } return '/' . ltrim(substr($parts[0], $length), '/'); }
[ "private", "function", "determinePath", "(", "array", "$", "server", ")", ":", "string", "{", "$", "path", "=", "''", ";", "if", "(", "strpos", "(", "$", "server", "[", "'SCRIPT_NAME'", "]", ",", "'index.php'", ")", "!==", "false", ")", "{", "$", "path", "=", "str_replace", "(", "'index.php'", ",", "''", ",", "$", "server", "[", "'SCRIPT_NAME'", "]", ")", ";", "}", "$", "parts", "=", "explode", "(", "'?'", ",", "$", "server", "[", "'REQUEST_URI'", "]", ")", ";", "$", "length", "=", "0", ";", "if", "(", "$", "path", "!==", "''", "&&", "strpos", "(", "$", "parts", "[", "0", "]", ",", "$", "path", ")", "===", "0", ")", "{", "$", "length", "=", "strlen", "(", "$", "path", ")", ";", "}", "return", "'/'", ".", "ltrim", "(", "substr", "(", "$", "parts", "[", "0", "]", ",", "$", "length", ")", ",", "'/'", ")", ";", "}" ]
Determines the used path by using passed server configuration. @param string[] $server The server configuration. @return string The determined path.
[ "Determines", "the", "used", "path", "by", "using", "passed", "server", "configuration", "." ]
9c9c4c5344812aff9dc50f4c930051241af2f989
https://github.com/nia-php/requestresponse-http/blob/9c9c4c5344812aff9dc50f4c930051241af2f989/sources/HttpRequest.php#L401-L416
237,337
nia-php/requestresponse-http
sources/HttpRequest.php
HttpRequest.determineRemoteIpAddress
private function determineRemoteIpAddress(array $server): string { if (array_key_exists('HTTP_X_FORWARDED_FOR', $server) && filter_var($server['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)) { return $server['HTTP_X_FORWARDED_FOR']; } elseif (array_key_exists('HTTP_CLIENT_IP', $server) && filter_var($server['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP)) { return $server['HTTP_CLIENT_IP']; } elseif (array_key_exists('HTTP_TRUE_CLIENT_IP', $server) && filter_var($server['HTTP_TRUE_CLIENT_IP'], FILTER_VALIDATE_IP)) { return $server['HTTP_TRUE_CLIENT_IP']; } return $server['REMOTE_ADDR']; }
php
private function determineRemoteIpAddress(array $server): string { if (array_key_exists('HTTP_X_FORWARDED_FOR', $server) && filter_var($server['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)) { return $server['HTTP_X_FORWARDED_FOR']; } elseif (array_key_exists('HTTP_CLIENT_IP', $server) && filter_var($server['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP)) { return $server['HTTP_CLIENT_IP']; } elseif (array_key_exists('HTTP_TRUE_CLIENT_IP', $server) && filter_var($server['HTTP_TRUE_CLIENT_IP'], FILTER_VALIDATE_IP)) { return $server['HTTP_TRUE_CLIENT_IP']; } return $server['REMOTE_ADDR']; }
[ "private", "function", "determineRemoteIpAddress", "(", "array", "$", "server", ")", ":", "string", "{", "if", "(", "array_key_exists", "(", "'HTTP_X_FORWARDED_FOR'", ",", "$", "server", ")", "&&", "filter_var", "(", "$", "server", "[", "'HTTP_X_FORWARDED_FOR'", "]", ",", "FILTER_VALIDATE_IP", ")", ")", "{", "return", "$", "server", "[", "'HTTP_X_FORWARDED_FOR'", "]", ";", "}", "elseif", "(", "array_key_exists", "(", "'HTTP_CLIENT_IP'", ",", "$", "server", ")", "&&", "filter_var", "(", "$", "server", "[", "'HTTP_CLIENT_IP'", "]", ",", "FILTER_VALIDATE_IP", ")", ")", "{", "return", "$", "server", "[", "'HTTP_CLIENT_IP'", "]", ";", "}", "elseif", "(", "array_key_exists", "(", "'HTTP_TRUE_CLIENT_IP'", ",", "$", "server", ")", "&&", "filter_var", "(", "$", "server", "[", "'HTTP_TRUE_CLIENT_IP'", "]", ",", "FILTER_VALIDATE_IP", ")", ")", "{", "return", "$", "server", "[", "'HTTP_TRUE_CLIENT_IP'", "]", ";", "}", "return", "$", "server", "[", "'REMOTE_ADDR'", "]", ";", "}" ]
Determines the remote ip address by using passed server configuration. @param string[] $server The server configuration. @return string The determined remote ip address.
[ "Determines", "the", "remote", "ip", "address", "by", "using", "passed", "server", "configuration", "." ]
9c9c4c5344812aff9dc50f4c930051241af2f989
https://github.com/nia-php/requestresponse-http/blob/9c9c4c5344812aff9dc50f4c930051241af2f989/sources/HttpRequest.php#L425-L436
237,338
nia-php/requestresponse-http
sources/HttpRequest.php
HttpRequest.narrowArray
private function narrowArray(array $array, string $key = null) { if ($key) { $key .= '--'; } $result = []; foreach ($array as $index => $value) { if (is_array($value)) { $result = array_merge($result, $this->narrowArray($value, $key . $index)); } else { $result[$key . $index] = $value; } } return $result; }
php
private function narrowArray(array $array, string $key = null) { if ($key) { $key .= '--'; } $result = []; foreach ($array as $index => $value) { if (is_array($value)) { $result = array_merge($result, $this->narrowArray($value, $key . $index)); } else { $result[$key . $index] = $value; } } return $result; }
[ "private", "function", "narrowArray", "(", "array", "$", "array", ",", "string", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", ")", "{", "$", "key", ".=", "'--'", ";", "}", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "index", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "result", "=", "array_merge", "(", "$", "result", ",", "$", "this", "->", "narrowArray", "(", "$", "value", ",", "$", "key", ".", "$", "index", ")", ")", ";", "}", "else", "{", "$", "result", "[", "$", "key", ".", "$", "index", "]", "=", "$", "value", ";", "}", "}", "return", "$", "result", ";", "}" ]
Narrows PHP's native nested map into a non-nested map. @param mixed[] $array The nested map to narrow. @param string|null $key The parent key. @return string[] Narrowed map.
[ "Narrows", "PHP", "s", "native", "nested", "map", "into", "a", "non", "-", "nested", "map", "." ]
9c9c4c5344812aff9dc50f4c930051241af2f989
https://github.com/nia-php/requestresponse-http/blob/9c9c4c5344812aff9dc50f4c930051241af2f989/sources/HttpRequest.php#L459-L476
237,339
bishopb/vanilla
applications/dashboard/controllers/class.modulecontroller.php
ModuleController.Index
public function Index($Module, $AppFolder = '', $DeliveryType = '') { if (!$DeliveryType) $this->DeliveryType(DELIVERY_TYPE_VIEW); $ModuleClassExists = class_exists($Module); if ($ModuleClassExists) { // Make sure that the class implements Gdn_IModule $ReflectionClass = new ReflectionClass($Module); if ($ReflectionClass->implementsInterface("Gdn_IModule")) { // Set the proper application folder on this controller so that things render properly. if ($AppFolder) { $this->ApplicationFolder = $AppFolder; } else { $Filename = str_replace('\\', '/', substr($ReflectionClass->getFileName(), strlen(PATH_ROOT))); // Figure our the application folder for the module. $Parts = explode('/', trim($Filename, '/')); if ($Parts[0] == 'applications') { $this->ApplicationFolder = $Parts[1]; } } $ModuleInstance = new $Module($this); $ModuleInstance->Visible = TRUE; $WhiteList = array('Limit', 'Help'); foreach ($this->Request->Get() as $Key => $Value) { if (in_array($Key, $WhiteList)) { $ModuleInstance->$Key = $Value; } } $this->SetData('_Module', $ModuleInstance); $this->Render('Index', FALSE, 'dashboard'); return; } } throw NotFoundException($Module); }
php
public function Index($Module, $AppFolder = '', $DeliveryType = '') { if (!$DeliveryType) $this->DeliveryType(DELIVERY_TYPE_VIEW); $ModuleClassExists = class_exists($Module); if ($ModuleClassExists) { // Make sure that the class implements Gdn_IModule $ReflectionClass = new ReflectionClass($Module); if ($ReflectionClass->implementsInterface("Gdn_IModule")) { // Set the proper application folder on this controller so that things render properly. if ($AppFolder) { $this->ApplicationFolder = $AppFolder; } else { $Filename = str_replace('\\', '/', substr($ReflectionClass->getFileName(), strlen(PATH_ROOT))); // Figure our the application folder for the module. $Parts = explode('/', trim($Filename, '/')); if ($Parts[0] == 'applications') { $this->ApplicationFolder = $Parts[1]; } } $ModuleInstance = new $Module($this); $ModuleInstance->Visible = TRUE; $WhiteList = array('Limit', 'Help'); foreach ($this->Request->Get() as $Key => $Value) { if (in_array($Key, $WhiteList)) { $ModuleInstance->$Key = $Value; } } $this->SetData('_Module', $ModuleInstance); $this->Render('Index', FALSE, 'dashboard'); return; } } throw NotFoundException($Module); }
[ "public", "function", "Index", "(", "$", "Module", ",", "$", "AppFolder", "=", "''", ",", "$", "DeliveryType", "=", "''", ")", "{", "if", "(", "!", "$", "DeliveryType", ")", "$", "this", "->", "DeliveryType", "(", "DELIVERY_TYPE_VIEW", ")", ";", "$", "ModuleClassExists", "=", "class_exists", "(", "$", "Module", ")", ";", "if", "(", "$", "ModuleClassExists", ")", "{", "// Make sure that the class implements Gdn_IModule", "$", "ReflectionClass", "=", "new", "ReflectionClass", "(", "$", "Module", ")", ";", "if", "(", "$", "ReflectionClass", "->", "implementsInterface", "(", "\"Gdn_IModule\"", ")", ")", "{", "// Set the proper application folder on this controller so that things render properly.", "if", "(", "$", "AppFolder", ")", "{", "$", "this", "->", "ApplicationFolder", "=", "$", "AppFolder", ";", "}", "else", "{", "$", "Filename", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "substr", "(", "$", "ReflectionClass", "->", "getFileName", "(", ")", ",", "strlen", "(", "PATH_ROOT", ")", ")", ")", ";", "// Figure our the application folder for the module.", "$", "Parts", "=", "explode", "(", "'/'", ",", "trim", "(", "$", "Filename", ",", "'/'", ")", ")", ";", "if", "(", "$", "Parts", "[", "0", "]", "==", "'applications'", ")", "{", "$", "this", "->", "ApplicationFolder", "=", "$", "Parts", "[", "1", "]", ";", "}", "}", "$", "ModuleInstance", "=", "new", "$", "Module", "(", "$", "this", ")", ";", "$", "ModuleInstance", "->", "Visible", "=", "TRUE", ";", "$", "WhiteList", "=", "array", "(", "'Limit'", ",", "'Help'", ")", ";", "foreach", "(", "$", "this", "->", "Request", "->", "Get", "(", ")", "as", "$", "Key", "=>", "$", "Value", ")", "{", "if", "(", "in_array", "(", "$", "Key", ",", "$", "WhiteList", ")", ")", "{", "$", "ModuleInstance", "->", "$", "Key", "=", "$", "Value", ";", "}", "}", "$", "this", "->", "SetData", "(", "'_Module'", ",", "$", "ModuleInstance", ")", ";", "$", "this", "->", "Render", "(", "'Index'", ",", "FALSE", ",", "'dashboard'", ")", ";", "return", ";", "}", "}", "throw", "NotFoundException", "(", "$", "Module", ")", ";", "}" ]
Creates and renders an instance of a module.
[ "Creates", "and", "renders", "an", "instance", "of", "a", "module", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.modulecontroller.php#L17-L56
237,340
phlexible/tree-bundle
Pattern/PatternResolver.php
PatternResolver.replace
public function replace($patternName, Siteroot $siteroot, ElementVersion $elementVersion, $language) { if (!isset($this->patterns[$patternName])) { $pattern = '%p'; } else { $pattern = $this->patterns[$patternName]; } return $this->replacePattern($pattern, $siteroot, $elementVersion, $language); }
php
public function replace($patternName, Siteroot $siteroot, ElementVersion $elementVersion, $language) { if (!isset($this->patterns[$patternName])) { $pattern = '%p'; } else { $pattern = $this->patterns[$patternName]; } return $this->replacePattern($pattern, $siteroot, $elementVersion, $language); }
[ "public", "function", "replace", "(", "$", "patternName", ",", "Siteroot", "$", "siteroot", ",", "ElementVersion", "$", "elementVersion", ",", "$", "language", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "patterns", "[", "$", "patternName", "]", ")", ")", "{", "$", "pattern", "=", "'%p'", ";", "}", "else", "{", "$", "pattern", "=", "$", "this", "->", "patterns", "[", "$", "patternName", "]", ";", "}", "return", "$", "this", "->", "replacePattern", "(", "$", "pattern", ",", "$", "siteroot", ",", "$", "elementVersion", ",", "$", "language", ")", ";", "}" ]
Resolved page title by configured pattern. @param string $patternName @param Siteroot $siteroot @param ElementVersion $elementVersion @param string $language @return string
[ "Resolved", "page", "title", "by", "configured", "pattern", "." ]
0fd07efdf1edf2d0f74f71519c476d534457701c
https://github.com/phlexible/tree-bundle/blob/0fd07efdf1edf2d0f74f71519c476d534457701c/Pattern/PatternResolver.php#L57-L66
237,341
phlexible/tree-bundle
Pattern/PatternResolver.php
PatternResolver.replacePattern
public function replacePattern($pattern, Siteroot $siteroot, ElementVersion $elementVersion, $language) { $replace = [ '%s' => $siteroot->getTitle(), '%b' => $elementVersion->getBackendTitle($language), '%p' => $elementVersion->getPageTitle($language), '%n' => $elementVersion->getNavigationTitle($language), '%r' => $this->projectTitle, ]; return str_replace(array_keys($replace), array_values($replace), $pattern); }
php
public function replacePattern($pattern, Siteroot $siteroot, ElementVersion $elementVersion, $language) { $replace = [ '%s' => $siteroot->getTitle(), '%b' => $elementVersion->getBackendTitle($language), '%p' => $elementVersion->getPageTitle($language), '%n' => $elementVersion->getNavigationTitle($language), '%r' => $this->projectTitle, ]; return str_replace(array_keys($replace), array_values($replace), $pattern); }
[ "public", "function", "replacePattern", "(", "$", "pattern", ",", "Siteroot", "$", "siteroot", ",", "ElementVersion", "$", "elementVersion", ",", "$", "language", ")", "{", "$", "replace", "=", "[", "'%s'", "=>", "$", "siteroot", "->", "getTitle", "(", ")", ",", "'%b'", "=>", "$", "elementVersion", "->", "getBackendTitle", "(", "$", "language", ")", ",", "'%p'", "=>", "$", "elementVersion", "->", "getPageTitle", "(", "$", "language", ")", ",", "'%n'", "=>", "$", "elementVersion", "->", "getNavigationTitle", "(", "$", "language", ")", ",", "'%r'", "=>", "$", "this", "->", "projectTitle", ",", "]", ";", "return", "str_replace", "(", "array_keys", "(", "$", "replace", ")", ",", "array_values", "(", "$", "replace", ")", ",", "$", "pattern", ")", ";", "}" ]
Resolve page title by pattern. @param string $pattern @param Siteroot $siteroot @param ElementVersion $elementVersion @param string $language @return string
[ "Resolve", "page", "title", "by", "pattern", "." ]
0fd07efdf1edf2d0f74f71519c476d534457701c
https://github.com/phlexible/tree-bundle/blob/0fd07efdf1edf2d0f74f71519c476d534457701c/Pattern/PatternResolver.php#L78-L89
237,342
gbprod/elastica-extra-bundle
src/ElasticaExtraBundle/Handler/AddAliasHandler.php
AddAliasHandler.handle
public function handle(Client $client, $index, $alias, $replace = false) { $client ->getIndex($index) ->addAlias($alias, $replace) ; }
php
public function handle(Client $client, $index, $alias, $replace = false) { $client ->getIndex($index) ->addAlias($alias, $replace) ; }
[ "public", "function", "handle", "(", "Client", "$", "client", ",", "$", "index", ",", "$", "alias", ",", "$", "replace", "=", "false", ")", "{", "$", "client", "->", "getIndex", "(", "$", "index", ")", "->", "addAlias", "(", "$", "alias", ",", "$", "replace", ")", ";", "}" ]
Handle add alias command @param Client $client @param string $index @param string $alias @param bool $replace
[ "Handle", "add", "alias", "command" ]
7a3d925c79903a328a3d07fefe998c0056be7e59
https://github.com/gbprod/elastica-extra-bundle/blob/7a3d925c79903a328a3d07fefe998c0056be7e59/src/ElasticaExtraBundle/Handler/AddAliasHandler.php#L22-L28
237,343
Clastic/BackofficeBundle
Controller/NavigationController.php
NavigationController.getModuleSortCallback
private function getModuleSortCallback() { return function (ModuleInterface $left, ModuleInterface $right) { return strcmp($left->getName(), $right->getName()); }; }
php
private function getModuleSortCallback() { return function (ModuleInterface $left, ModuleInterface $right) { return strcmp($left->getName(), $right->getName()); }; }
[ "private", "function", "getModuleSortCallback", "(", ")", "{", "return", "function", "(", "ModuleInterface", "$", "left", ",", "ModuleInterface", "$", "right", ")", "{", "return", "strcmp", "(", "$", "left", "->", "getName", "(", ")", ",", "$", "right", "->", "getName", "(", ")", ")", ";", "}", ";", "}" ]
Callback to sort the Modules by name. @return callable
[ "Callback", "to", "sort", "the", "Modules", "by", "name", "." ]
f40b2589a56ef37507d22788c3e8faa996e71758
https://github.com/Clastic/BackofficeBundle/blob/f40b2589a56ef37507d22788c3e8faa996e71758/Controller/NavigationController.php#L46-L51
237,344
AthensFramework/Core
src/form/Form.php
Form.validate
protected function validate() { $this->isValid = true; foreach ($this->getWritableBearer()->getWritables() as $name => $writable) { if ($writable instanceof FieldInterface) { $writable->validate(); } } foreach ($this->getWritableBearer()->getWritables() as $name => $writable) { if (array_key_exists($name, $this->validators) === true) { foreach ($this->validators[$name] as $validator) { call_user_func_array($validator, [$writable, $this]); } } } foreach ($this->getWritableBearer()->getWritables() as $name => $writable) { if ($writable instanceof FieldInterface && $writable->isValid() === false) { $this->isValid = false; $this->addError("Please correct the indicated errors and resubmit the form."); break; } } foreach ($this->getWritableBearer()->getWritables() as $writable) { // Force validation on each subform via isValid() // If subform isn't valid and this form is not yet invalid, mark it as invalid if ($writable instanceof FormInterface) { if ($writable->isValid() === false && $this->isValid === true) { $this->isValid = false; $this->addError("Please correct the indicated errors and resubmit the form."); } } } if ($this->errors !== []) { $this->isValid = false; } }
php
protected function validate() { $this->isValid = true; foreach ($this->getWritableBearer()->getWritables() as $name => $writable) { if ($writable instanceof FieldInterface) { $writable->validate(); } } foreach ($this->getWritableBearer()->getWritables() as $name => $writable) { if (array_key_exists($name, $this->validators) === true) { foreach ($this->validators[$name] as $validator) { call_user_func_array($validator, [$writable, $this]); } } } foreach ($this->getWritableBearer()->getWritables() as $name => $writable) { if ($writable instanceof FieldInterface && $writable->isValid() === false) { $this->isValid = false; $this->addError("Please correct the indicated errors and resubmit the form."); break; } } foreach ($this->getWritableBearer()->getWritables() as $writable) { // Force validation on each subform via isValid() // If subform isn't valid and this form is not yet invalid, mark it as invalid if ($writable instanceof FormInterface) { if ($writable->isValid() === false && $this->isValid === true) { $this->isValid = false; $this->addError("Please correct the indicated errors and resubmit the form."); } } } if ($this->errors !== []) { $this->isValid = false; } }
[ "protected", "function", "validate", "(", ")", "{", "$", "this", "->", "isValid", "=", "true", ";", "foreach", "(", "$", "this", "->", "getWritableBearer", "(", ")", "->", "getWritables", "(", ")", "as", "$", "name", "=>", "$", "writable", ")", "{", "if", "(", "$", "writable", "instanceof", "FieldInterface", ")", "{", "$", "writable", "->", "validate", "(", ")", ";", "}", "}", "foreach", "(", "$", "this", "->", "getWritableBearer", "(", ")", "->", "getWritables", "(", ")", "as", "$", "name", "=>", "$", "writable", ")", "{", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "validators", ")", "===", "true", ")", "{", "foreach", "(", "$", "this", "->", "validators", "[", "$", "name", "]", "as", "$", "validator", ")", "{", "call_user_func_array", "(", "$", "validator", ",", "[", "$", "writable", ",", "$", "this", "]", ")", ";", "}", "}", "}", "foreach", "(", "$", "this", "->", "getWritableBearer", "(", ")", "->", "getWritables", "(", ")", "as", "$", "name", "=>", "$", "writable", ")", "{", "if", "(", "$", "writable", "instanceof", "FieldInterface", "&&", "$", "writable", "->", "isValid", "(", ")", "===", "false", ")", "{", "$", "this", "->", "isValid", "=", "false", ";", "$", "this", "->", "addError", "(", "\"Please correct the indicated errors and resubmit the form.\"", ")", ";", "break", ";", "}", "}", "foreach", "(", "$", "this", "->", "getWritableBearer", "(", ")", "->", "getWritables", "(", ")", "as", "$", "writable", ")", "{", "// Force validation on each subform via isValid()", "// If subform isn't valid and this form is not yet invalid, mark it as invalid", "if", "(", "$", "writable", "instanceof", "FormInterface", ")", "{", "if", "(", "$", "writable", "->", "isValid", "(", ")", "===", "false", "&&", "$", "this", "->", "isValid", "===", "true", ")", "{", "$", "this", "->", "isValid", "=", "false", ";", "$", "this", "->", "addError", "(", "\"Please correct the indicated errors and resubmit the form.\"", ")", ";", "}", "}", "}", "if", "(", "$", "this", "->", "errors", "!==", "[", "]", ")", "{", "$", "this", "->", "isValid", "=", "false", ";", "}", "}" ]
Determine whether the form is valid. Updates $this->isValid and $this->errors according to whether the form is valid and whether it has errors. @return void
[ "Determine", "whether", "the", "form", "is", "valid", "." ]
6237b914b9f6aef6b2fcac23094b657a86185340
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/form/Form.php#L28-L68
237,345
snowiow/cocurl
src/League.php
League.create
public static function create(array $data): League { $league = new League(); parent::fill($data, $league); return $league; }
php
public static function create(array $data): League { $league = new League(); parent::fill($data, $league); return $league; }
[ "public", "static", "function", "create", "(", "array", "$", "data", ")", ":", "League", "{", "$", "league", "=", "new", "League", "(", ")", ";", "parent", "::", "fill", "(", "$", "data", ",", "$", "league", ")", ";", "return", "$", "league", ";", "}" ]
Creates a league object with the given data @param array $data an associative array to fill up the members of the league class @return League a league object with the data given as it's members
[ "Creates", "a", "league", "object", "with", "the", "given", "data" ]
583df05bd3c8f24fd99f294da9906a3e4b1a9c7b
https://github.com/snowiow/cocurl/blob/583df05bd3c8f24fd99f294da9906a3e4b1a9c7b/src/League.php#L40-L45
237,346
oschildt/SmartFactory
src/SmartFactory/DatabaseWorkers/MySQL_DBWorker.php
MySQL_DBWorker.field_count
public function field_count() { if ($this->statement) { return $this->statement->field_count; } if (!$this->mysqli_result) { return false; } return $this->mysqli_result->field_count; }
php
public function field_count() { if ($this->statement) { return $this->statement->field_count; } if (!$this->mysqli_result) { return false; } return $this->mysqli_result->field_count; }
[ "public", "function", "field_count", "(", ")", "{", "if", "(", "$", "this", "->", "statement", ")", "{", "return", "$", "this", "->", "statement", "->", "field_count", ";", "}", "if", "(", "!", "$", "this", "->", "mysqli_result", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "mysqli_result", "->", "field_count", ";", "}" ]
Returns the number of the fields in the result of the last retrieving query. @return int|false Returns the number of the fields in the result of the last retrieving query. In the case of any error returns false. @author Oleg Schildt
[ "Returns", "the", "number", "of", "the", "fields", "in", "the", "result", "of", "the", "last", "retrieving", "query", "." ]
efd289961a720d5f3103a3c696e2beee16e9644d
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/DatabaseWorkers/MySQL_DBWorker.php#L1139-L1150
237,347
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php
PermissionsDataSourceDoctrine.hasPermissionForId
public function hasPermissionForId($id) { try { $em = $this->entityManager->getDoctrineEntityManager(); $permission = $em->getRepository('\\Zepi\\Core\\AccessControl\\Entity\\Permission')->find($id); if ($permission !== null) { return true; } return false; } catch (\Exception $e) { throw new Exception('Cannot check if there is a permission for the given id "' . $id . '".', 0, $e); } }
php
public function hasPermissionForId($id) { try { $em = $this->entityManager->getDoctrineEntityManager(); $permission = $em->getRepository('\\Zepi\\Core\\AccessControl\\Entity\\Permission')->find($id); if ($permission !== null) { return true; } return false; } catch (\Exception $e) { throw new Exception('Cannot check if there is a permission for the given id "' . $id . '".', 0, $e); } }
[ "public", "function", "hasPermissionForId", "(", "$", "id", ")", "{", "try", "{", "$", "em", "=", "$", "this", "->", "entityManager", "->", "getDoctrineEntityManager", "(", ")", ";", "$", "permission", "=", "$", "em", "->", "getRepository", "(", "'\\\\Zepi\\\\Core\\\\AccessControl\\\\Entity\\\\Permission'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "$", "permission", "!==", "null", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "'Cannot check if there is a permission for the given id \"'", ".", "$", "id", ".", "'\".'", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Returns true if there is a permission for the given id @access public @param integer $id @return boolean @throws \Zepi\Core\AccessControl\Exception Cannot check if there is a permission for the given id "{id}".
[ "Returns", "true", "if", "there", "is", "a", "permission", "for", "the", "given", "id" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php#L101-L115
237,348
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php
PermissionsDataSourceDoctrine.hasAccess
public function hasAccess($accessEntityUuid, $accessLevel) { // Do not check the database if we haven't all data if ($accessEntityUuid == '' || $accessLevel == '') { return false; } try { $queryBuilder = $this->entityManager->getQueryBuilder(); $queryBuilder->select($queryBuilder->expr()->count('p.id')) ->from('\\Zepi\\Core\\AccessControl\\Entity\\Permission', 'p') ->where('p.accessEntityUuid = :accessEntityUuid') ->andWhere('p.accessLevelKey = :accessLevel') ->setParameter('accessEntityUuid', $accessEntityUuid) ->setParameter('accessLevel', $accessLevel); $data = $queryBuilder->getQuery(); if ($data === false) { return false; } return ($data->getSingleScalarResult() > 0); } catch (\Exception $e) { throw new Exception('Cannot verify the permission for uuid "' . $accessEntityUuid . '" and access level "' . $accessLevel . '".', 0, $e); } }
php
public function hasAccess($accessEntityUuid, $accessLevel) { // Do not check the database if we haven't all data if ($accessEntityUuid == '' || $accessLevel == '') { return false; } try { $queryBuilder = $this->entityManager->getQueryBuilder(); $queryBuilder->select($queryBuilder->expr()->count('p.id')) ->from('\\Zepi\\Core\\AccessControl\\Entity\\Permission', 'p') ->where('p.accessEntityUuid = :accessEntityUuid') ->andWhere('p.accessLevelKey = :accessLevel') ->setParameter('accessEntityUuid', $accessEntityUuid) ->setParameter('accessLevel', $accessLevel); $data = $queryBuilder->getQuery(); if ($data === false) { return false; } return ($data->getSingleScalarResult() > 0); } catch (\Exception $e) { throw new Exception('Cannot verify the permission for uuid "' . $accessEntityUuid . '" and access level "' . $accessLevel . '".', 0, $e); } }
[ "public", "function", "hasAccess", "(", "$", "accessEntityUuid", ",", "$", "accessLevel", ")", "{", "// Do not check the database if we haven't all data", "if", "(", "$", "accessEntityUuid", "==", "''", "||", "$", "accessLevel", "==", "''", ")", "{", "return", "false", ";", "}", "try", "{", "$", "queryBuilder", "=", "$", "this", "->", "entityManager", "->", "getQueryBuilder", "(", ")", ";", "$", "queryBuilder", "->", "select", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "count", "(", "'p.id'", ")", ")", "->", "from", "(", "'\\\\Zepi\\\\Core\\\\AccessControl\\\\Entity\\\\Permission'", ",", "'p'", ")", "->", "where", "(", "'p.accessEntityUuid = :accessEntityUuid'", ")", "->", "andWhere", "(", "'p.accessLevelKey = :accessLevel'", ")", "->", "setParameter", "(", "'accessEntityUuid'", ",", "$", "accessEntityUuid", ")", "->", "setParameter", "(", "'accessLevel'", ",", "$", "accessLevel", ")", ";", "$", "data", "=", "$", "queryBuilder", "->", "getQuery", "(", ")", ";", "if", "(", "$", "data", "===", "false", ")", "{", "return", "false", ";", "}", "return", "(", "$", "data", "->", "getSingleScalarResult", "(", ")", ">", "0", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "'Cannot verify the permission for uuid \"'", ".", "$", "accessEntityUuid", ".", "'\" and access level \"'", ".", "$", "accessLevel", ".", "'\".'", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Returns true if the given access entity uuid has already access to the access level @access public @param string $accessEntityUuid @param string $accessLevel @return boolean @throws \Zepi\Core\AccessControl\Exception Cannot verifiy the permission for uuid "{uuid}" and access level {accessLevel}.
[ "Returns", "true", "if", "the", "given", "access", "entity", "uuid", "has", "already", "access", "to", "the", "access", "level" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php#L153-L178
237,349
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php
PermissionsDataSourceDoctrine.getPermissionsRawForUuid
public function getPermissionsRawForUuid($accessEntityUuid) { // Do not check the database if we haven't all data if ($accessEntityUuid == '') { return array(); } try { $em = $this->entityManager->getDoctrineEntityManager(); $permissions = $em->getRepository('\\Zepi\\Core\\AccessControl\\Entity\\Permission')->findBy(array( 'accessEntityUuid' => $accessEntityUuid )); $accessLevels = array(); foreach ($permissions as $permission) { $accessLevels[] = $permission->getAccessLevelKey(); } return $accessLevels; } catch (\Exception $e) { throw new Exception('Cannot load the permission for the given uuid "' . $accessEntityUuid . '".', 0, $e); } }
php
public function getPermissionsRawForUuid($accessEntityUuid) { // Do not check the database if we haven't all data if ($accessEntityUuid == '') { return array(); } try { $em = $this->entityManager->getDoctrineEntityManager(); $permissions = $em->getRepository('\\Zepi\\Core\\AccessControl\\Entity\\Permission')->findBy(array( 'accessEntityUuid' => $accessEntityUuid )); $accessLevels = array(); foreach ($permissions as $permission) { $accessLevels[] = $permission->getAccessLevelKey(); } return $accessLevels; } catch (\Exception $e) { throw new Exception('Cannot load the permission for the given uuid "' . $accessEntityUuid . '".', 0, $e); } }
[ "public", "function", "getPermissionsRawForUuid", "(", "$", "accessEntityUuid", ")", "{", "// Do not check the database if we haven't all data", "if", "(", "$", "accessEntityUuid", "==", "''", ")", "{", "return", "array", "(", ")", ";", "}", "try", "{", "$", "em", "=", "$", "this", "->", "entityManager", "->", "getDoctrineEntityManager", "(", ")", ";", "$", "permissions", "=", "$", "em", "->", "getRepository", "(", "'\\\\Zepi\\\\Core\\\\AccessControl\\\\Entity\\\\Permission'", ")", "->", "findBy", "(", "array", "(", "'accessEntityUuid'", "=>", "$", "accessEntityUuid", ")", ")", ";", "$", "accessLevels", "=", "array", "(", ")", ";", "foreach", "(", "$", "permissions", "as", "$", "permission", ")", "{", "$", "accessLevels", "[", "]", "=", "$", "permission", "->", "getAccessLevelKey", "(", ")", ";", "}", "return", "$", "accessLevels", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "'Cannot load the permission for the given uuid \"'", ".", "$", "accessEntityUuid", ".", "'\".'", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Returns an array with all granted access levels for the given access entity uuid whithout resolving the group access levels. @access public @param string $accessEntityUuid @return array|false @throws \Zepi\Core\AccessControl\Exception Cannot load the permission for the given uuid "{uuid}".
[ "Returns", "an", "array", "with", "all", "granted", "access", "levels", "for", "the", "given", "access", "entity", "uuid", "whithout", "resolving", "the", "group", "access", "levels", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php#L190-L212
237,350
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php
PermissionsDataSourceDoctrine.getPermissionsForUuid
public function getPermissionsForUuid($accessEntityUuid) { // Do not check the database if we haven't all data if ($accessEntityUuid == '') { return array(); } try { $accessLevels = $this->getPermissionsRawForUuid($accessEntityUuid); $accessLevels = $this->runtimeManager->executeFilter('\\Zepi\\Core\\AccessControl\\Filter\\PermissionsBackend\\ResolvePermissions', $accessLevels); return $accessLevels; } catch (\Exception $e) { throw new Exception('Cannot load the permission for the given uuid "' . $accessEntityUuid . '".', 0, $e); } }
php
public function getPermissionsForUuid($accessEntityUuid) { // Do not check the database if we haven't all data if ($accessEntityUuid == '') { return array(); } try { $accessLevels = $this->getPermissionsRawForUuid($accessEntityUuid); $accessLevels = $this->runtimeManager->executeFilter('\\Zepi\\Core\\AccessControl\\Filter\\PermissionsBackend\\ResolvePermissions', $accessLevels); return $accessLevels; } catch (\Exception $e) { throw new Exception('Cannot load the permission for the given uuid "' . $accessEntityUuid . '".', 0, $e); } }
[ "public", "function", "getPermissionsForUuid", "(", "$", "accessEntityUuid", ")", "{", "// Do not check the database if we haven't all data", "if", "(", "$", "accessEntityUuid", "==", "''", ")", "{", "return", "array", "(", ")", ";", "}", "try", "{", "$", "accessLevels", "=", "$", "this", "->", "getPermissionsRawForUuid", "(", "$", "accessEntityUuid", ")", ";", "$", "accessLevels", "=", "$", "this", "->", "runtimeManager", "->", "executeFilter", "(", "'\\\\Zepi\\\\Core\\\\AccessControl\\\\Filter\\\\PermissionsBackend\\\\ResolvePermissions'", ",", "$", "accessLevels", ")", ";", "return", "$", "accessLevels", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "'Cannot load the permission for the given uuid \"'", ".", "$", "accessEntityUuid", ".", "'\".'", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Returns an array with all granted access levels for the given access entity uuid @access public @param string $accessEntityUuid @return array|false @throws \Zepi\Core\AccessControl\Exception Cannot load the permission for the given uuid "{uuid}".
[ "Returns", "an", "array", "with", "all", "granted", "access", "levels", "for", "the", "given", "access", "entity", "uuid" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php#L224-L240
237,351
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php
PermissionsDataSourceDoctrine.revokePermissions
public function revokePermissions($accessLevel) { // Do not revoke the permissions if we haven't all data if ($accessLevel == '') { return false; } try { $em = $this->entityManager->getDoctrineEntityManager(); $permissions = $em->getRepository('\\Zepi\\Core\\AccessControl\\Entity\\Permission')->findBy(array( 'accessLevelKey' => $accessLevel )); foreach ($permissions as $permission) { $em->remove($permission); } $em->flush(); } catch (\Exception $e) { throw new Exception('Cannot revoke the access levels "' . $accessLevel . '".', 0, $e); } }
php
public function revokePermissions($accessLevel) { // Do not revoke the permissions if we haven't all data if ($accessLevel == '') { return false; } try { $em = $this->entityManager->getDoctrineEntityManager(); $permissions = $em->getRepository('\\Zepi\\Core\\AccessControl\\Entity\\Permission')->findBy(array( 'accessLevelKey' => $accessLevel )); foreach ($permissions as $permission) { $em->remove($permission); } $em->flush(); } catch (\Exception $e) { throw new Exception('Cannot revoke the access levels "' . $accessLevel . '".', 0, $e); } }
[ "public", "function", "revokePermissions", "(", "$", "accessLevel", ")", "{", "// Do not revoke the permissions if we haven't all data", "if", "(", "$", "accessLevel", "==", "''", ")", "{", "return", "false", ";", "}", "try", "{", "$", "em", "=", "$", "this", "->", "entityManager", "->", "getDoctrineEntityManager", "(", ")", ";", "$", "permissions", "=", "$", "em", "->", "getRepository", "(", "'\\\\Zepi\\\\Core\\\\AccessControl\\\\Entity\\\\Permission'", ")", "->", "findBy", "(", "array", "(", "'accessLevelKey'", "=>", "$", "accessLevel", ")", ")", ";", "foreach", "(", "$", "permissions", "as", "$", "permission", ")", "{", "$", "em", "->", "remove", "(", "$", "permission", ")", ";", "}", "$", "em", "->", "flush", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "'Cannot revoke the access levels \"'", ".", "$", "accessLevel", ".", "'\".'", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Revokes the permission for the given access level. @access public @param string $accessLevel @return boolean @throws \Zepi\Core\AccessControl\Exception Cannot revoke the access levels "{accessLevel}".
[ "Revokes", "the", "permission", "for", "the", "given", "access", "level", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php#L327-L347
237,352
antaresproject/tester
src/Http/Presenters/CollectivePresenter.php
CollectivePresenter.prepare
protected function prepare() { $active = app('antares.memory')->get("extensions.active"); $memory = app('antares.memory')->make('tests'); $tests = $memory->all(); $return = []; foreach ($tests as $index => $data) { if (!isset($data['executor'])) { $memory->forget($index); continue; } try { $reflection = new ReflectionClass($data['executor']); if (!$reflection->hasMethod('addTestButton')) { throw new Exception('Form Configuration is invalid. Form with test must contains Testable Trait.'); } } catch (Exception $e) { Log::emergency($e); $memory->forget($index); continue; } $name = $data['component']; $fullName = isset($active[$name]) ? $active[$name]['full_name'] : 'Foundation'; $return[$fullName][$data['name']][$index] = $data; } $memory->finish(); return $return; }
php
protected function prepare() { $active = app('antares.memory')->get("extensions.active"); $memory = app('antares.memory')->make('tests'); $tests = $memory->all(); $return = []; foreach ($tests as $index => $data) { if (!isset($data['executor'])) { $memory->forget($index); continue; } try { $reflection = new ReflectionClass($data['executor']); if (!$reflection->hasMethod('addTestButton')) { throw new Exception('Form Configuration is invalid. Form with test must contains Testable Trait.'); } } catch (Exception $e) { Log::emergency($e); $memory->forget($index); continue; } $name = $data['component']; $fullName = isset($active[$name]) ? $active[$name]['full_name'] : 'Foundation'; $return[$fullName][$data['name']][$index] = $data; } $memory->finish(); return $return; }
[ "protected", "function", "prepare", "(", ")", "{", "$", "active", "=", "app", "(", "'antares.memory'", ")", "->", "get", "(", "\"extensions.active\"", ")", ";", "$", "memory", "=", "app", "(", "'antares.memory'", ")", "->", "make", "(", "'tests'", ")", ";", "$", "tests", "=", "$", "memory", "->", "all", "(", ")", ";", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "tests", "as", "$", "index", "=>", "$", "data", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "'executor'", "]", ")", ")", "{", "$", "memory", "->", "forget", "(", "$", "index", ")", ";", "continue", ";", "}", "try", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "data", "[", "'executor'", "]", ")", ";", "if", "(", "!", "$", "reflection", "->", "hasMethod", "(", "'addTestButton'", ")", ")", "{", "throw", "new", "Exception", "(", "'Form Configuration is invalid. Form with test must contains Testable Trait.'", ")", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "Log", "::", "emergency", "(", "$", "e", ")", ";", "$", "memory", "->", "forget", "(", "$", "index", ")", ";", "continue", ";", "}", "$", "name", "=", "$", "data", "[", "'component'", "]", ";", "$", "fullName", "=", "isset", "(", "$", "active", "[", "$", "name", "]", ")", "?", "$", "active", "[", "$", "name", "]", "[", "'full_name'", "]", ":", "'Foundation'", ";", "$", "return", "[", "$", "fullName", "]", "[", "$", "data", "[", "'name'", "]", "]", "[", "$", "index", "]", "=", "$", "data", ";", "}", "$", "memory", "->", "finish", "(", ")", ";", "return", "$", "return", ";", "}" ]
script prepare before round robin launch @return array @throws Exception
[ "script", "prepare", "before", "round", "robin", "launch" ]
23e9b4dd7880475769486a8c8f979ab6530c99df
https://github.com/antaresproject/tester/blob/23e9b4dd7880475769486a8c8f979ab6530c99df/src/Http/Presenters/CollectivePresenter.php#L69-L96
237,353
phplegends/http
src/Message.php
Message.removeHeader
protected function removeHeader($name) { if (! $this->hasHeader($name)) { return false; } $value = $this->getHeader($name); unset($this->headers[$name]); return $value; }
php
protected function removeHeader($name) { if (! $this->hasHeader($name)) { return false; } $value = $this->getHeader($name); unset($this->headers[$name]); return $value; }
[ "protected", "function", "removeHeader", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasHeader", "(", "$", "name", ")", ")", "{", "return", "false", ";", "}", "$", "value", "=", "$", "this", "->", "getHeader", "(", "$", "name", ")", ";", "unset", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ")", ";", "return", "$", "value", ";", "}" ]
Remove a item of header @return array | false
[ "Remove", "a", "item", "of", "header" ]
a172792b71d12c88a05ac15faacc3a8ab110fb25
https://github.com/phplegends/http/blob/a172792b71d12c88a05ac15faacc3a8ab110fb25/src/Message.php#L99-L111
237,354
colorium/routing
src/Colorium/Routing/Router.php
Router.add
public function add($query, $resource, array $meta = []) { $query = static::clean($query); list($method, $uri) = explode(' ', $query); $this->routes[$query] = new Route($method, $uri, $resource, $meta); return $this; }
php
public function add($query, $resource, array $meta = []) { $query = static::clean($query); list($method, $uri) = explode(' ', $query); $this->routes[$query] = new Route($method, $uri, $resource, $meta); return $this; }
[ "public", "function", "add", "(", "$", "query", ",", "$", "resource", ",", "array", "$", "meta", "=", "[", "]", ")", "{", "$", "query", "=", "static", "::", "clean", "(", "$", "query", ")", ";", "list", "(", "$", "method", ",", "$", "uri", ")", "=", "explode", "(", "' '", ",", "$", "query", ")", ";", "$", "this", "->", "routes", "[", "$", "query", "]", "=", "new", "Route", "(", "$", "method", ",", "$", "uri", ",", "$", "resource", ",", "$", "meta", ")", ";", "return", "$", "this", ";", "}" ]
Add route definition @param string $query @param $resource @param array $meta @return $this
[ "Add", "route", "definition" ]
6b6b96321f581164e4f8fb639fd8920d68fbee21
https://github.com/colorium/routing/blob/6b6b96321f581164e4f8fb639fd8920d68fbee21/src/Colorium/Routing/Router.php#L44-L52
237,355
colorium/routing
src/Colorium/Routing/Router.php
Router.parse
public function parse($class, array $meta = []) { $methods = get_class_methods($class); foreach($methods as $method) { $query = Annotation::ofMethod($class, $method, 'uri'); if($query) { $this->add($query, [$class, $method], $meta); } } return $this; }
php
public function parse($class, array $meta = []) { $methods = get_class_methods($class); foreach($methods as $method) { $query = Annotation::ofMethod($class, $method, 'uri'); if($query) { $this->add($query, [$class, $method], $meta); } } return $this; }
[ "public", "function", "parse", "(", "$", "class", ",", "array", "$", "meta", "=", "[", "]", ")", "{", "$", "methods", "=", "get_class_methods", "(", "$", "class", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "$", "query", "=", "Annotation", "::", "ofMethod", "(", "$", "class", ",", "$", "method", ",", "'uri'", ")", ";", "if", "(", "$", "query", ")", "{", "$", "this", "->", "add", "(", "$", "query", ",", "[", "$", "class", ",", "$", "method", "]", ",", "$", "meta", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Parse class methods annotation and add route @param string $class @param array $meta @return $this
[ "Parse", "class", "methods", "annotation", "and", "add", "route" ]
6b6b96321f581164e4f8fb639fd8920d68fbee21
https://github.com/colorium/routing/blob/6b6b96321f581164e4f8fb639fd8920d68fbee21/src/Colorium/Routing/Router.php#L62-L73
237,356
colorium/routing
src/Colorium/Routing/Router.php
Router.mount
public function mount($prefix, RouterInterface $router, array $meta = []) { $prefix = '/' . trim($prefix, '/'); foreach($router->routes() as $route) { $route->uri = $prefix . $route->uri; $route->meta = array_merge($route->meta, $meta); $query = static::clean($route->method . ' ' . $route->uri); $this->routes[$query] = $route; } return $this; }
php
public function mount($prefix, RouterInterface $router, array $meta = []) { $prefix = '/' . trim($prefix, '/'); foreach($router->routes() as $route) { $route->uri = $prefix . $route->uri; $route->meta = array_merge($route->meta, $meta); $query = static::clean($route->method . ' ' . $route->uri); $this->routes[$query] = $route; } return $this; }
[ "public", "function", "mount", "(", "$", "prefix", ",", "RouterInterface", "$", "router", ",", "array", "$", "meta", "=", "[", "]", ")", "{", "$", "prefix", "=", "'/'", ".", "trim", "(", "$", "prefix", ",", "'/'", ")", ";", "foreach", "(", "$", "router", "->", "routes", "(", ")", "as", "$", "route", ")", "{", "$", "route", "->", "uri", "=", "$", "prefix", ".", "$", "route", "->", "uri", ";", "$", "route", "->", "meta", "=", "array_merge", "(", "$", "route", "->", "meta", ",", "$", "meta", ")", ";", "$", "query", "=", "static", "::", "clean", "(", "$", "route", "->", "method", ".", "' '", ".", "$", "route", "->", "uri", ")", ";", "$", "this", "->", "routes", "[", "$", "query", "]", "=", "$", "route", ";", "}", "return", "$", "this", ";", "}" ]
Mount router under prefix query @param $prefix @param RouterInterface $router @param array $meta @return $this
[ "Mount", "router", "under", "prefix", "query" ]
6b6b96321f581164e4f8fb639fd8920d68fbee21
https://github.com/colorium/routing/blob/6b6b96321f581164e4f8fb639fd8920d68fbee21/src/Colorium/Routing/Router.php#L84-L95
237,357
colorium/routing
src/Colorium/Routing/Router.php
Router.reverse
public function reverse($resource, array $params = []) { // search in all routes if($key = array_search($resource, $this->routes)) { $route = $this->routes[$key]; $route->params = $params; return $route; } }
php
public function reverse($resource, array $params = []) { // search in all routes if($key = array_search($resource, $this->routes)) { $route = $this->routes[$key]; $route->params = $params; return $route; } }
[ "public", "function", "reverse", "(", "$", "resource", ",", "array", "$", "params", "=", "[", "]", ")", "{", "// search in all routes", "if", "(", "$", "key", "=", "array_search", "(", "$", "resource", ",", "$", "this", "->", "routes", ")", ")", "{", "$", "route", "=", "$", "this", "->", "routes", "[", "$", "key", "]", ";", "$", "route", "->", "params", "=", "$", "params", ";", "return", "$", "route", ";", "}", "}" ]
Reverse finding by resource @param $resource @param array $params @return Route
[ "Reverse", "finding", "by", "resource" ]
6b6b96321f581164e4f8fb639fd8920d68fbee21
https://github.com/colorium/routing/blob/6b6b96321f581164e4f8fb639fd8920d68fbee21/src/Colorium/Routing/Router.php#L139-L147
237,358
webriq/core
module/Core/src/Grid/Core/Model/Translate.php
Translate.textDomain
public function textDomain( $textDomain = self::DEFAULT_TEXT_DOMAIN, $locale = null ) { $translator = $this->getTranslator(); $locale = $locale ?: $translator->getLocale(); if ( ! isset( $translator->myMessages[$textDomain][$locale] ) ) { $translator->loadMyMessages( $textDomain, $locale ); } if ( ! isset( $translator->messages[$textDomain][$locale] ) ) { $translator->loadMessages( $textDomain, $locale ); } $my = $translator->myMessages[$textDomain][$locale]; $global = $translator->messages[$textDomain][$locale]; if ( $my instanceof TextDomain ) { $my = $my->getArrayCopy(); } else if ( empty( $my ) ) { $my = array(); } if ( $global instanceof TextDomain ) { $global = $global->getArrayCopy(); } else if ( empty( $global ) ) { $global = array(); } return array_replace( $global, $my ); }
php
public function textDomain( $textDomain = self::DEFAULT_TEXT_DOMAIN, $locale = null ) { $translator = $this->getTranslator(); $locale = $locale ?: $translator->getLocale(); if ( ! isset( $translator->myMessages[$textDomain][$locale] ) ) { $translator->loadMyMessages( $textDomain, $locale ); } if ( ! isset( $translator->messages[$textDomain][$locale] ) ) { $translator->loadMessages( $textDomain, $locale ); } $my = $translator->myMessages[$textDomain][$locale]; $global = $translator->messages[$textDomain][$locale]; if ( $my instanceof TextDomain ) { $my = $my->getArrayCopy(); } else if ( empty( $my ) ) { $my = array(); } if ( $global instanceof TextDomain ) { $global = $global->getArrayCopy(); } else if ( empty( $global ) ) { $global = array(); } return array_replace( $global, $my ); }
[ "public", "function", "textDomain", "(", "$", "textDomain", "=", "self", "::", "DEFAULT_TEXT_DOMAIN", ",", "$", "locale", "=", "null", ")", "{", "$", "translator", "=", "$", "this", "->", "getTranslator", "(", ")", ";", "$", "locale", "=", "$", "locale", "?", ":", "$", "translator", "->", "getLocale", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "translator", "->", "myMessages", "[", "$", "textDomain", "]", "[", "$", "locale", "]", ")", ")", "{", "$", "translator", "->", "loadMyMessages", "(", "$", "textDomain", ",", "$", "locale", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "translator", "->", "messages", "[", "$", "textDomain", "]", "[", "$", "locale", "]", ")", ")", "{", "$", "translator", "->", "loadMessages", "(", "$", "textDomain", ",", "$", "locale", ")", ";", "}", "$", "my", "=", "$", "translator", "->", "myMessages", "[", "$", "textDomain", "]", "[", "$", "locale", "]", ";", "$", "global", "=", "$", "translator", "->", "messages", "[", "$", "textDomain", "]", "[", "$", "locale", "]", ";", "if", "(", "$", "my", "instanceof", "TextDomain", ")", "{", "$", "my", "=", "$", "my", "->", "getArrayCopy", "(", ")", ";", "}", "else", "if", "(", "empty", "(", "$", "my", ")", ")", "{", "$", "my", "=", "array", "(", ")", ";", "}", "if", "(", "$", "global", "instanceof", "TextDomain", ")", "{", "$", "global", "=", "$", "global", "->", "getArrayCopy", "(", ")", ";", "}", "else", "if", "(", "empty", "(", "$", "global", ")", ")", "{", "$", "global", "=", "array", "(", ")", ";", "}", "return", "array_replace", "(", "$", "global", ",", "$", "my", ")", ";", "}" ]
Get a whole text-domain @param string $textDomain @param string|null $locale @return array
[ "Get", "a", "whole", "text", "-", "domain" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Model/Translate.php#L113-L151
237,359
diskerror/Utilities
src/Ldap.php
Ldap.searchAll
public function searchAll($filter, array $attributes = []) { $ldap = $this->getResource(); // $ds is a valid link identifier (see ldap_connect) ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); $cookie = ''; $result = []; do { ldap_control_paged_result($ldap, self::PAGE_SIZE, true, $cookie); Stdlib\ErrorHandler::start(E_WARNING); $search = ldap_search($ldap, $this->getBaseDn(), $filter, $attributes); Stdlib\ErrorHandler::stop(); if ($search === false) { throw new Lp\Exception\LdapException($this, 'searching: ' . $filter); } $entries = $this->createCollection(new Lp\Collection\DefaultIterator($this, $search), null); foreach ( $entries as $es ) { $result[] = $es; } ldap_control_paged_result_response($ldap, $search, $cookie); } while ($cookie !== null && $cookie != ''); return $result; }
php
public function searchAll($filter, array $attributes = []) { $ldap = $this->getResource(); // $ds is a valid link identifier (see ldap_connect) ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); $cookie = ''; $result = []; do { ldap_control_paged_result($ldap, self::PAGE_SIZE, true, $cookie); Stdlib\ErrorHandler::start(E_WARNING); $search = ldap_search($ldap, $this->getBaseDn(), $filter, $attributes); Stdlib\ErrorHandler::stop(); if ($search === false) { throw new Lp\Exception\LdapException($this, 'searching: ' . $filter); } $entries = $this->createCollection(new Lp\Collection\DefaultIterator($this, $search), null); foreach ( $entries as $es ) { $result[] = $es; } ldap_control_paged_result_response($ldap, $search, $cookie); } while ($cookie !== null && $cookie != ''); return $result; }
[ "public", "function", "searchAll", "(", "$", "filter", ",", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "ldap", "=", "$", "this", "->", "getResource", "(", ")", ";", "// $ds is a valid link identifier (see ldap_connect)", "ldap_set_option", "(", "$", "ldap", ",", "LDAP_OPT_PROTOCOL_VERSION", ",", "3", ")", ";", "$", "cookie", "=", "''", ";", "$", "result", "=", "[", "]", ";", "do", "{", "ldap_control_paged_result", "(", "$", "ldap", ",", "self", "::", "PAGE_SIZE", ",", "true", ",", "$", "cookie", ")", ";", "Stdlib", "\\", "ErrorHandler", "::", "start", "(", "E_WARNING", ")", ";", "$", "search", "=", "ldap_search", "(", "$", "ldap", ",", "$", "this", "->", "getBaseDn", "(", ")", ",", "$", "filter", ",", "$", "attributes", ")", ";", "Stdlib", "\\", "ErrorHandler", "::", "stop", "(", ")", ";", "if", "(", "$", "search", "===", "false", ")", "{", "throw", "new", "Lp", "\\", "Exception", "\\", "LdapException", "(", "$", "this", ",", "'searching: '", ".", "$", "filter", ")", ";", "}", "$", "entries", "=", "$", "this", "->", "createCollection", "(", "new", "Lp", "\\", "Collection", "\\", "DefaultIterator", "(", "$", "this", ",", "$", "search", ")", ",", "null", ")", ";", "foreach", "(", "$", "entries", "as", "$", "es", ")", "{", "$", "result", "[", "]", "=", "$", "es", ";", "}", "ldap_control_paged_result_response", "(", "$", "ldap", ",", "$", "search", ",", "$", "cookie", ")", ";", "}", "while", "(", "$", "cookie", "!==", "null", "&&", "$", "cookie", "!=", "''", ")", ";", "return", "$", "result", ";", "}" ]
Search LDAP registry for entries matching filter and optional attributes and return ALL values, including those beyond the usual 1000 entries, as an array. @param string $filter @param array $attributes -OPTIONAL @return array @throws Exception\LdapException
[ "Search", "LDAP", "registry", "for", "entries", "matching", "filter", "and", "optional", "attributes", "and", "return", "ALL", "values", "including", "those", "beyond", "the", "usual", "1000", "entries", "as", "an", "array", "." ]
cc5eec2417f7c2c76a84584ebd5237197dc54236
https://github.com/diskerror/Utilities/blob/cc5eec2417f7c2c76a84584ebd5237197dc54236/src/Ldap.php#L25-L54
237,360
FiveLab/Resource
src/Serializer/Normalizer/ErrorCollectionObjectNormalizer.php
ErrorCollectionObjectNormalizer.appendCollectionAttributes
public function appendCollectionAttributes( array $data, ErrorCollection $error, string $format, array $context ): array { $innerError = new ErrorResource( $error->getMessage(), $error->getReason(), $error->getPath(), $error->getAttributes(), $error->getIdentifier() ); foreach ($error->getRelations() as $relation) { $innerError->addRelation($relation); } $normalizedInnerError = $this->normalizer->normalize($innerError, $format, $context); return array_merge($normalizedInnerError, $data); }
php
public function appendCollectionAttributes( array $data, ErrorCollection $error, string $format, array $context ): array { $innerError = new ErrorResource( $error->getMessage(), $error->getReason(), $error->getPath(), $error->getAttributes(), $error->getIdentifier() ); foreach ($error->getRelations() as $relation) { $innerError->addRelation($relation); } $normalizedInnerError = $this->normalizer->normalize($innerError, $format, $context); return array_merge($normalizedInnerError, $data); }
[ "public", "function", "appendCollectionAttributes", "(", "array", "$", "data", ",", "ErrorCollection", "$", "error", ",", "string", "$", "format", ",", "array", "$", "context", ")", ":", "array", "{", "$", "innerError", "=", "new", "ErrorResource", "(", "$", "error", "->", "getMessage", "(", ")", ",", "$", "error", "->", "getReason", "(", ")", ",", "$", "error", "->", "getPath", "(", ")", ",", "$", "error", "->", "getAttributes", "(", ")", ",", "$", "error", "->", "getIdentifier", "(", ")", ")", ";", "foreach", "(", "$", "error", "->", "getRelations", "(", ")", "as", "$", "relation", ")", "{", "$", "innerError", "->", "addRelation", "(", "$", "relation", ")", ";", "}", "$", "normalizedInnerError", "=", "$", "this", "->", "normalizer", "->", "normalize", "(", "$", "innerError", ",", "$", "format", ",", "$", "context", ")", ";", "return", "array_merge", "(", "$", "normalizedInnerError", ",", "$", "data", ")", ";", "}" ]
Append collection attributes to @param array $data @param ErrorCollection $error @param string $format @param array $context @return array
[ "Append", "collection", "attributes", "to" ]
f2864924212dd4e2d1a3e7a1ad8a863d9db26127
https://github.com/FiveLab/Resource/blob/f2864924212dd4e2d1a3e7a1ad8a863d9db26127/src/Serializer/Normalizer/ErrorCollectionObjectNormalizer.php#L67-L88
237,361
rozaverta/cmf
core/Events/SingletonEvent.php
SingletonEvent.addSingleton
public function addSingleton( string $name, $singleton ): self { $name = Str::studly($name); if( isset($this->ci[$name]) ) { throw new \InvalidArgumentException("Duplicated class name '{$name}' for singleton instance object"); } $this->ci[$name] = $singleton; return $this; }
php
public function addSingleton( string $name, $singleton ): self { $name = Str::studly($name); if( isset($this->ci[$name]) ) { throw new \InvalidArgumentException("Duplicated class name '{$name}' for singleton instance object"); } $this->ci[$name] = $singleton; return $this; }
[ "public", "function", "addSingleton", "(", "string", "$", "name", ",", "$", "singleton", ")", ":", "self", "{", "$", "name", "=", "Str", "::", "studly", "(", "$", "name", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "ci", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Duplicated class name '{$name}' for singleton instance object\"", ")", ";", "}", "$", "this", "->", "ci", "[", "$", "name", "]", "=", "$", "singleton", ";", "return", "$", "this", ";", "}" ]
Add new singleton @param string|object $name @param $singleton @return SingletonEvent
[ "Add", "new", "singleton" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Events/SingletonEvent.php#L24-L34
237,362
jurchiks/commons
src/http/Uri.php
Uri.get
public function get(bool $isRawUrl = false): string { if ($this->sourceChanged) { return $this->getAbsolute($isRawUrl); } return $this->getRelative($isRawUrl); }
php
public function get(bool $isRawUrl = false): string { if ($this->sourceChanged) { return $this->getAbsolute($isRawUrl); } return $this->getRelative($isRawUrl); }
[ "public", "function", "get", "(", "bool", "$", "isRawUrl", "=", "false", ")", ":", "string", "{", "if", "(", "$", "this", "->", "sourceChanged", ")", "{", "return", "$", "this", "->", "getAbsolute", "(", "$", "isRawUrl", ")", ";", "}", "return", "$", "this", "->", "getRelative", "(", "$", "isRawUrl", ")", ";", "}" ]
Get the URL contained in this object. May return a relative or absolute URL depending on whether the absolute part has changed. @param bool $isRawUrl : if true, spaces in query parameters are encoded as %20, otherwise as + @return string the link to the required route @see getRelative @see getAbsolute
[ "Get", "the", "URL", "contained", "in", "this", "object", ".", "May", "return", "a", "relative", "or", "absolute", "URL", "depending", "on", "whether", "the", "absolute", "part", "has", "changed", "." ]
be9e1eca6a94380647160a882b8476bee3e4d8f8
https://github.com/jurchiks/commons/blob/be9e1eca6a94380647160a882b8476bee3e4d8f8/src/http/Uri.php#L328-L336
237,363
xinc-develop/xinc-core
src/Config/Xml.php
Xml.getConfigurationSources
public function getConfigurationSources(ConfigInterface $conf) { if ($conf->hasOption('config-file')) { $file = $conf->getOption('config-file'); if (isset($file)) { if (!strstr($file, '/')) { $file = $conf->getOption('config-dir').$file; } return array($file); } } // load every xml file in config dir $dir = $conf->getOption('config-dir'); $list = glob("{$dir}*.xml", GLOB_ERR); if ($list === false) { throw new IOException($dir, null, "config-dir '$dir' is not readable", IOException::FAILURE_NOT_READABLE); } return $list; }
php
public function getConfigurationSources(ConfigInterface $conf) { if ($conf->hasOption('config-file')) { $file = $conf->getOption('config-file'); if (isset($file)) { if (!strstr($file, '/')) { $file = $conf->getOption('config-dir').$file; } return array($file); } } // load every xml file in config dir $dir = $conf->getOption('config-dir'); $list = glob("{$dir}*.xml", GLOB_ERR); if ($list === false) { throw new IOException($dir, null, "config-dir '$dir' is not readable", IOException::FAILURE_NOT_READABLE); } return $list; }
[ "public", "function", "getConfigurationSources", "(", "ConfigInterface", "$", "conf", ")", "{", "if", "(", "$", "conf", "->", "hasOption", "(", "'config-file'", ")", ")", "{", "$", "file", "=", "$", "conf", "->", "getOption", "(", "'config-file'", ")", ";", "if", "(", "isset", "(", "$", "file", ")", ")", "{", "if", "(", "!", "strstr", "(", "$", "file", ",", "'/'", ")", ")", "{", "$", "file", "=", "$", "conf", "->", "getOption", "(", "'config-dir'", ")", ".", "$", "file", ";", "}", "return", "array", "(", "$", "file", ")", ";", "}", "}", "// load every xml file in config dir", "$", "dir", "=", "$", "conf", "->", "getOption", "(", "'config-dir'", ")", ";", "$", "list", "=", "glob", "(", "\"{$dir}*.xml\"", ",", "GLOB_ERR", ")", ";", "if", "(", "$", "list", "===", "false", ")", "{", "throw", "new", "IOException", "(", "$", "dir", ",", "null", ",", "\"config-dir '$dir' is not readable\"", ",", "IOException", "::", "FAILURE_NOT_READABLE", ")", ";", "}", "return", "$", "list", ";", "}" ]
Finds the configured configuration sources. The config needs at least a valid config-dir or config-file option. @throw Xinc::Core::Exception::IOException @return array with configured sources
[ "Finds", "the", "configured", "configuration", "sources", "." ]
4bb69a6afe19e1186950a3122cbfe0989823e0d6
https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Config/Xml.php#L64-L86
237,364
potfur/statemachine
src/StateMachine/Process.php
Process.triggerEvent
public function triggerEvent($event, Payload $payload): string { return $this->state($payload->state())->triggerEvent($event, $payload); }
php
public function triggerEvent($event, Payload $payload): string { return $this->state($payload->state())->triggerEvent($event, $payload); }
[ "public", "function", "triggerEvent", "(", "$", "event", ",", "Payload", "$", "payload", ")", ":", "string", "{", "return", "$", "this", "->", "state", "(", "$", "payload", "->", "state", "(", ")", ")", "->", "triggerEvent", "(", "$", "event", ",", "$", "payload", ")", ";", "}" ]
Trigger event for payload Return next state name @param string $event @param Payload $payload @return string
[ "Trigger", "event", "for", "payload", "Return", "next", "state", "name" ]
6b68535e6c94b10bf618a7809a48f6a8f6d30deb
https://github.com/potfur/statemachine/blob/6b68535e6c94b10bf618a7809a48f6a8f6d30deb/src/StateMachine/Process.php#L124-L127
237,365
anklimsk/cakephp-extended-test
Vendor/PHPHtmlParser/paquettg/php-html-parser/src/PHPHtmlParser/Dom/Tag.php
Tag.setAttribute
public function setAttribute($key, $value) { $key = strtolower($key); if ( ! is_array($value)) { $value = [ 'value' => $value, 'doubleQuote' => true, ]; } $this->attr[$key] = $value; return $this; }
php
public function setAttribute($key, $value) { $key = strtolower($key); if ( ! is_array($value)) { $value = [ 'value' => $value, 'doubleQuote' => true, ]; } $this->attr[$key] = $value; return $this; }
[ "public", "function", "setAttribute", "(", "$", "key", ",", "$", "value", ")", "{", "$", "key", "=", "strtolower", "(", "$", "key", ")", ";", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "[", "'value'", "=>", "$", "value", ",", "'doubleQuote'", "=>", "true", ",", "]", ";", "}", "$", "this", "->", "attr", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set an attribute for this tag. @param string $key @param string|array $value @return $this
[ "Set", "an", "attribute", "for", "this", "tag", "." ]
21691a3be8a198419feb92fb6ed3b35a14dc24b1
https://github.com/anklimsk/cakephp-extended-test/blob/21691a3be8a198419feb92fb6ed3b35a14dc24b1/Vendor/PHPHtmlParser/paquettg/php-html-parser/src/PHPHtmlParser/Dom/Tag.php#L142-L154
237,366
anklimsk/cakephp-extended-test
Vendor/PHPHtmlParser/paquettg/php-html-parser/src/PHPHtmlParser/Dom/Tag.php
Tag.getAttribute
public function getAttribute($key) { if ( ! isset($this->attr[$key])) { return null; } $value = $this->attr[$key]['value']; if (is_string($value) && ! is_null($this->encode)) { // convert charset $this->attr[$key]['value'] = $this->encode->convert($value); } return $this->attr[$key]; }
php
public function getAttribute($key) { if ( ! isset($this->attr[$key])) { return null; } $value = $this->attr[$key]['value']; if (is_string($value) && ! is_null($this->encode)) { // convert charset $this->attr[$key]['value'] = $this->encode->convert($value); } return $this->attr[$key]; }
[ "public", "function", "getAttribute", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "attr", "[", "$", "key", "]", ")", ")", "{", "return", "null", ";", "}", "$", "value", "=", "$", "this", "->", "attr", "[", "$", "key", "]", "[", "'value'", "]", ";", "if", "(", "is_string", "(", "$", "value", ")", "&&", "!", "is_null", "(", "$", "this", "->", "encode", ")", ")", "{", "// convert charset", "$", "this", "->", "attr", "[", "$", "key", "]", "[", "'value'", "]", "=", "$", "this", "->", "encode", "->", "convert", "(", "$", "value", ")", ";", "}", "return", "$", "this", "->", "attr", "[", "$", "key", "]", ";", "}" ]
Returns an attribute by the key @param string $key @return mixed
[ "Returns", "an", "attribute", "by", "the", "key" ]
21691a3be8a198419feb92fb6ed3b35a14dc24b1
https://github.com/anklimsk/cakephp-extended-test/blob/21691a3be8a198419feb92fb6ed3b35a14dc24b1/Vendor/PHPHtmlParser/paquettg/php-html-parser/src/PHPHtmlParser/Dom/Tag.php#L214-L226
237,367
aloframework/handlers
src/class/Config/AbstractConfig.php
AbstractConfig.setDefaults
private static function setDefaults() { if (!self::$defaults) { self::$defaults = [self::CFG_CSS_PATH => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'error.min.css', self::CFG_TRACE_MAX_DEPTH => 50, self::CFG_BACKGROUND => 'default', self::CFG_FOREGROUND_NOTICE => 'cyan', self::CFG_FOREGROUND_WARNING => 'yellow', self::CFG_FOREGROUND_ERROR => 'red', self::CFG_FORCE_HTML => false]; } }
php
private static function setDefaults() { if (!self::$defaults) { self::$defaults = [self::CFG_CSS_PATH => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'error.min.css', self::CFG_TRACE_MAX_DEPTH => 50, self::CFG_BACKGROUND => 'default', self::CFG_FOREGROUND_NOTICE => 'cyan', self::CFG_FOREGROUND_WARNING => 'yellow', self::CFG_FOREGROUND_ERROR => 'red', self::CFG_FORCE_HTML => false]; } }
[ "private", "static", "function", "setDefaults", "(", ")", "{", "if", "(", "!", "self", "::", "$", "defaults", ")", "{", "self", "::", "$", "defaults", "=", "[", "self", "::", "CFG_CSS_PATH", "=>", "__DIR__", ".", "DIRECTORY_SEPARATOR", ".", "'..'", ".", "DIRECTORY_SEPARATOR", ".", "'..'", ".", "DIRECTORY_SEPARATOR", ".", "'error.min.css'", ",", "self", "::", "CFG_TRACE_MAX_DEPTH", "=>", "50", ",", "self", "::", "CFG_BACKGROUND", "=>", "'default'", ",", "self", "::", "CFG_FOREGROUND_NOTICE", "=>", "'cyan'", ",", "self", "::", "CFG_FOREGROUND_WARNING", "=>", "'yellow'", ",", "self", "::", "CFG_FOREGROUND_ERROR", "=>", "'red'", ",", "self", "::", "CFG_FORCE_HTML", "=>", "false", "]", ";", "}", "}" ]
Sets default config @author Art <a.molcanovas@gmail.com>
[ "Sets", "default", "config" ]
3f17510c5e9221855d39c332710d0e512ec8b42d
https://github.com/aloframework/handlers/blob/3f17510c5e9221855d39c332710d0e512ec8b42d/src/class/Config/AbstractConfig.php#L113-L125
237,368
devbr/pack-blog
Model/Article.php
Article.mountById
function mountById($id) { $db = new Db(); if ($this->where != false || $this->where != '') { $where = ' AND '.$this->where; } $res = $db->query('SELECT * FROM '.$this->table.' WHERE id = :id '.$where, [':id'=>0 + $id]); if (isset($res[0])) { $this->load($res[0]->getAll()); //Access counter $db->query('UPDATE article SET access = access + 1 WHERE id = '.$this->id); return $this; } return false; }
php
function mountById($id) { $db = new Db(); if ($this->where != false || $this->where != '') { $where = ' AND '.$this->where; } $res = $db->query('SELECT * FROM '.$this->table.' WHERE id = :id '.$where, [':id'=>0 + $id]); if (isset($res[0])) { $this->load($res[0]->getAll()); //Access counter $db->query('UPDATE article SET access = access + 1 WHERE id = '.$this->id); return $this; } return false; }
[ "function", "mountById", "(", "$", "id", ")", "{", "$", "db", "=", "new", "Db", "(", ")", ";", "if", "(", "$", "this", "->", "where", "!=", "false", "||", "$", "this", "->", "where", "!=", "''", ")", "{", "$", "where", "=", "' AND '", ".", "$", "this", "->", "where", ";", "}", "$", "res", "=", "$", "db", "->", "query", "(", "'SELECT * FROM '", ".", "$", "this", "->", "table", ".", "' WHERE id = :id '", ".", "$", "where", ",", "[", "':id'", "=>", "0", "+", "$", "id", "]", ")", ";", "if", "(", "isset", "(", "$", "res", "[", "0", "]", ")", ")", "{", "$", "this", "->", "load", "(", "$", "res", "[", "0", "]", "->", "getAll", "(", ")", ")", ";", "//Access counter", "$", "db", "->", "query", "(", "'UPDATE article\n SET access = access + 1 \n WHERE id = '", ".", "$", "this", "->", "id", ")", ";", "return", "$", "this", ";", "}", "return", "false", ";", "}" ]
Mount from DataBase - search by ID @param integer $id id in database @return bool|object $this object or false
[ "Mount", "from", "DataBase", "-", "search", "by", "ID" ]
4693e36521ee3d08077f0db3e013afb99785cc9d
https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Article.php#L77-L97
237,369
devbr/pack-blog
Model/Article.php
Article.requestNew
function requestNew() { $db = new Db; //Search from first register with [article.status] 5 and [article.editdate] <= datetime - 24 hours. $result = $db->query('SELECT MIN(id)id, (SELECT MAX(id+1) FROM article)nid FROM article WHERE status = 6 OR (status = 5 AND editdate <= STR_TO_DATE(\''.date('Y-m-d H:i:s', time()-86400).'\', \'%Y-%m-%d %H:%i:%s\'))'); if (isset($result[0])) { $this->editdate = date('Y-m-d H:i:s'); $this->pubdate = $this->editdate; //Criando novo registro if ($result[0]->get('id') == null) { $this->id = $result[0]->get('nid'); $db->query('INSERT INTO articlecontent SET article = '.$this->id.', content = "", editdate = "'.$this->editdate.'"'); $db->query('INSERT INTO article SET id = '.$this->id.', status = 5, editdate = \''.$this->editdate.'\''); //Atualizando o registro } else { $this->id = $result[0]->get('id'); $db->query('UPDATE article SET status = 5, pubdate = \''.$this->pubdate.'\', editdate = \''.$this->editdate.'\', rateup = 0, ratedown = 0, access = 0, link = "", tags = "", title = "", media = "{}", resume = "" WHERE id = '.$this->id.''); $db->query('UPDATE articlecontent SET content = "", editdate = \''.$this->editdate.'\' WHERE article = '.$this->id.''); } //Make dir clean (delete all files) $this->clearDir(); return $this; } return false; }
php
function requestNew() { $db = new Db; //Search from first register with [article.status] 5 and [article.editdate] <= datetime - 24 hours. $result = $db->query('SELECT MIN(id)id, (SELECT MAX(id+1) FROM article)nid FROM article WHERE status = 6 OR (status = 5 AND editdate <= STR_TO_DATE(\''.date('Y-m-d H:i:s', time()-86400).'\', \'%Y-%m-%d %H:%i:%s\'))'); if (isset($result[0])) { $this->editdate = date('Y-m-d H:i:s'); $this->pubdate = $this->editdate; //Criando novo registro if ($result[0]->get('id') == null) { $this->id = $result[0]->get('nid'); $db->query('INSERT INTO articlecontent SET article = '.$this->id.', content = "", editdate = "'.$this->editdate.'"'); $db->query('INSERT INTO article SET id = '.$this->id.', status = 5, editdate = \''.$this->editdate.'\''); //Atualizando o registro } else { $this->id = $result[0]->get('id'); $db->query('UPDATE article SET status = 5, pubdate = \''.$this->pubdate.'\', editdate = \''.$this->editdate.'\', rateup = 0, ratedown = 0, access = 0, link = "", tags = "", title = "", media = "{}", resume = "" WHERE id = '.$this->id.''); $db->query('UPDATE articlecontent SET content = "", editdate = \''.$this->editdate.'\' WHERE article = '.$this->id.''); } //Make dir clean (delete all files) $this->clearDir(); return $this; } return false; }
[ "function", "requestNew", "(", ")", "{", "$", "db", "=", "new", "Db", ";", "//Search from first register with [article.status] 5 and [article.editdate] <= datetime - 24 hours.", "$", "result", "=", "$", "db", "->", "query", "(", "'SELECT MIN(id)id, (SELECT MAX(id+1) FROM article)nid\n FROM article\n WHERE status = 6\n OR (status = 5 AND editdate <= STR_TO_DATE(\\''", ".", "date", "(", "'Y-m-d H:i:s'", ",", "time", "(", ")", "-", "86400", ")", ".", "'\\', \\'%Y-%m-%d %H:%i:%s\\'))'", ")", ";", "if", "(", "isset", "(", "$", "result", "[", "0", "]", ")", ")", "{", "$", "this", "->", "editdate", "=", "date", "(", "'Y-m-d H:i:s'", ")", ";", "$", "this", "->", "pubdate", "=", "$", "this", "->", "editdate", ";", "//Criando novo registro", "if", "(", "$", "result", "[", "0", "]", "->", "get", "(", "'id'", ")", "==", "null", ")", "{", "$", "this", "->", "id", "=", "$", "result", "[", "0", "]", "->", "get", "(", "'nid'", ")", ";", "$", "db", "->", "query", "(", "'INSERT INTO articlecontent\n SET article = '", ".", "$", "this", "->", "id", ".", "',\n \t content = \"\",\n \t\t\t\t editdate = \"'", ".", "$", "this", "->", "editdate", ".", "'\"'", ")", ";", "$", "db", "->", "query", "(", "'INSERT INTO article\n SET id = '", ".", "$", "this", "->", "id", ".", "',\n status = 5,\n editdate = \\''", ".", "$", "this", "->", "editdate", ".", "'\\''", ")", ";", "//Atualizando o registro", "}", "else", "{", "$", "this", "->", "id", "=", "$", "result", "[", "0", "]", "->", "get", "(", "'id'", ")", ";", "$", "db", "->", "query", "(", "'UPDATE article\n SET status = 5,\n pubdate = \\''", ".", "$", "this", "->", "pubdate", ".", "'\\',\n \t\t\t\t editdate = \\''", ".", "$", "this", "->", "editdate", ".", "'\\',\n \t\t\t\t rateup = 0,\n \t\t\t\t ratedown = 0,\n \t\t\t\t access = 0,\n \t\t\t\t link = \"\",\n \t\t\t\t tags = \"\",\n \t\t\t\t title = \"\",\n \t\t\t\t media = \"{}\",\n \t\t\t\t resume = \"\"\n \t\t\t\t \n \t\t\t WHERE id = '", ".", "$", "this", "->", "id", ".", "''", ")", ";", "$", "db", "->", "query", "(", "'UPDATE articlecontent\n SET content = \"\",\n \t\t\t\t editdate = \\''", ".", "$", "this", "->", "editdate", ".", "'\\'\n \t\t\t WHERE article = '", ".", "$", "this", "->", "id", ".", "''", ")", ";", "}", "//Make dir clean (delete all files)", "$", "this", "->", "clearDir", "(", ")", ";", "return", "$", "this", ";", "}", "return", "false", ";", "}" ]
Get Row in DB @return bool|integer New ID or false
[ "Get", "Row", "in", "DB" ]
4693e36521ee3d08077f0db3e013afb99785cc9d
https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Article.php#L133-L193
237,370
devbr/pack-blog
Model/Article.php
Article.getAll
function getAll() { foreach ($this as $k => $v) { if ($k == 'table' || $k == 'where') { continue; } $data[$k] = $v; } return $data; }
php
function getAll() { foreach ($this as $k => $v) { if ($k == 'table' || $k == 'where') { continue; } $data[$k] = $v; } return $data; }
[ "function", "getAll", "(", ")", "{", "foreach", "(", "$", "this", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "k", "==", "'table'", "||", "$", "k", "==", "'where'", ")", "{", "continue", ";", "}", "$", "data", "[", "$", "k", "]", "=", "$", "v", ";", "}", "return", "$", "data", ";", "}" ]
Get All data @return array array of fields name X data
[ "Get", "All", "data" ]
4693e36521ee3d08077f0db3e013afb99785cc9d
https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Article.php#L199-L208
237,371
devbr/pack-blog
Model/Article.php
Article.save
function save() { if ($this->id != false || $this->id != 0) { return $this->update(); } else { return $this->insert(); } }
php
function save() { if ($this->id != false || $this->id != 0) { return $this->update(); } else { return $this->insert(); } }
[ "function", "save", "(", ")", "{", "if", "(", "$", "this", "->", "id", "!=", "false", "||", "$", "this", "->", "id", "!=", "0", ")", "{", "return", "$", "this", "->", "update", "(", ")", ";", "}", "else", "{", "return", "$", "this", "->", "insert", "(", ")", ";", "}", "}" ]
SAVE a new or UPDATE this @return bool status of success
[ "SAVE", "a", "new", "or", "UPDATE", "this" ]
4693e36521ee3d08077f0db3e013afb99785cc9d
https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Article.php#L244-L251
237,372
devbr/pack-blog
Model/Article.php
Article.clearDir
function clearDir() { $dir = _WWW.$this->patch.$this->id.'/'; foreach (scandir($dir) as $file) { if ($file == '.' || $file == '..') { continue; } unlink($dir.$file); } }
php
function clearDir() { $dir = _WWW.$this->patch.$this->id.'/'; foreach (scandir($dir) as $file) { if ($file == '.' || $file == '..') { continue; } unlink($dir.$file); } }
[ "function", "clearDir", "(", ")", "{", "$", "dir", "=", "_WWW", ".", "$", "this", "->", "patch", ".", "$", "this", "->", "id", ".", "'/'", ";", "foreach", "(", "scandir", "(", "$", "dir", ")", "as", "$", "file", ")", "{", "if", "(", "$", "file", "==", "'.'", "||", "$", "file", "==", "'..'", ")", "{", "continue", ";", "}", "unlink", "(", "$", "dir", ".", "$", "file", ")", ";", "}", "}" ]
Delete all files in article directory @return void Clear directory
[ "Delete", "all", "files", "in", "article", "directory" ]
4693e36521ee3d08077f0db3e013afb99785cc9d
https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Article.php#L277-L286
237,373
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/database/pdo/connection.php
Database_PDO_Connection.driver_name
public function driver_name() { // Make sure the database is connected $this->_connection or $this->connect(); // Getting driver name return $this->_connection->getAttribute(\PDO::ATTR_DRIVER_NAME); }
php
public function driver_name() { // Make sure the database is connected $this->_connection or $this->connect(); // Getting driver name return $this->_connection->getAttribute(\PDO::ATTR_DRIVER_NAME); }
[ "public", "function", "driver_name", "(", ")", "{", "// Make sure the database is connected", "$", "this", "->", "_connection", "or", "$", "this", "->", "connect", "(", ")", ";", "// Getting driver name", "return", "$", "this", "->", "_connection", "->", "getAttribute", "(", "\\", "PDO", "::", "ATTR_DRIVER_NAME", ")", ";", "}" ]
Get the current PDO Driver name @return string
[ "Get", "the", "current", "PDO", "Driver", "name" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/pdo/connection.php#L139-L146
237,374
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/database/pdo/connection.php
Database_PDO_Connection.set_charset
public function set_charset($charset) { // Make sure the database is connected $this->_connection or $this->connect(); // Set Charset for SQL Server connection if (strtolower($this->driver_name()) == 'sqlsrv') { $this->_connection->setAttribute(\PDO::SQLSRV_ATTR_ENCODING, \PDO::SQLSRV_ENCODING_SYSTEM); } // Set Charset for SQLite connection elseif (strtolower($this->driver_name()) == 'sqlite') { // Execute a raw PRAGMA encoding query $this->_connection->exec('PRAGMA encoding = ' . $this->quote($charset)); } // Set Charset for any connection except ODBC, as it throws exception elseif (strtolower($this->driver_name()) != 'odbc') { // Execute a raw SET NAMES query $this->_connection->exec('SET NAMES '.$this->quote($charset)); } }
php
public function set_charset($charset) { // Make sure the database is connected $this->_connection or $this->connect(); // Set Charset for SQL Server connection if (strtolower($this->driver_name()) == 'sqlsrv') { $this->_connection->setAttribute(\PDO::SQLSRV_ATTR_ENCODING, \PDO::SQLSRV_ENCODING_SYSTEM); } // Set Charset for SQLite connection elseif (strtolower($this->driver_name()) == 'sqlite') { // Execute a raw PRAGMA encoding query $this->_connection->exec('PRAGMA encoding = ' . $this->quote($charset)); } // Set Charset for any connection except ODBC, as it throws exception elseif (strtolower($this->driver_name()) != 'odbc') { // Execute a raw SET NAMES query $this->_connection->exec('SET NAMES '.$this->quote($charset)); } }
[ "public", "function", "set_charset", "(", "$", "charset", ")", "{", "// Make sure the database is connected", "$", "this", "->", "_connection", "or", "$", "this", "->", "connect", "(", ")", ";", "// Set Charset for SQL Server connection", "if", "(", "strtolower", "(", "$", "this", "->", "driver_name", "(", ")", ")", "==", "'sqlsrv'", ")", "{", "$", "this", "->", "_connection", "->", "setAttribute", "(", "\\", "PDO", "::", "SQLSRV_ATTR_ENCODING", ",", "\\", "PDO", "::", "SQLSRV_ENCODING_SYSTEM", ")", ";", "}", "// Set Charset for SQLite connection", "elseif", "(", "strtolower", "(", "$", "this", "->", "driver_name", "(", ")", ")", "==", "'sqlite'", ")", "{", "// Execute a raw PRAGMA encoding query", "$", "this", "->", "_connection", "->", "exec", "(", "'PRAGMA encoding = '", ".", "$", "this", "->", "quote", "(", "$", "charset", ")", ")", ";", "}", "// Set Charset for any connection except ODBC, as it throws exception", "elseif", "(", "strtolower", "(", "$", "this", "->", "driver_name", "(", ")", ")", "!=", "'odbc'", ")", "{", "// Execute a raw SET NAMES query", "$", "this", "->", "_connection", "->", "exec", "(", "'SET NAMES '", ".", "$", "this", "->", "quote", "(", "$", "charset", ")", ")", ";", "}", "}" ]
Set the charset @param string $charset
[ "Set", "the", "charset" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/pdo/connection.php#L153-L175
237,375
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/database/pdo/connection.php
Database_PDO_Connection.escape
public function escape($value) { // Make sure the database is connected $this->_connection or $this->connect(); $result = $this->_connection->quote($value); // poor-mans workaround for the fact that not all drivers implement quote() if (empty($result)) { $result = "'".str_replace("'", "''", $value)."'"; } return $result; }
php
public function escape($value) { // Make sure the database is connected $this->_connection or $this->connect(); $result = $this->_connection->quote($value); // poor-mans workaround for the fact that not all drivers implement quote() if (empty($result)) { $result = "'".str_replace("'", "''", $value)."'"; } return $result; }
[ "public", "function", "escape", "(", "$", "value", ")", "{", "// Make sure the database is connected", "$", "this", "->", "_connection", "or", "$", "this", "->", "connect", "(", ")", ";", "$", "result", "=", "$", "this", "->", "_connection", "->", "quote", "(", "$", "value", ")", ";", "// poor-mans workaround for the fact that not all drivers implement quote()", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "$", "result", "=", "\"'\"", ".", "str_replace", "(", "\"'\"", ",", "\"''\"", ",", "$", "value", ")", ".", "\"'\"", ";", "}", "return", "$", "result", ";", "}" ]
Escape a value @param mixed $value @return string
[ "Escape", "a", "value" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/pdo/connection.php#L457-L469
237,376
wigedev/simple-mvc
src/Renderer/ViewHelper/StylesheetHelper.php
StylesheetHelper.init
public function init(?string $configuration = 'stylesheets'): void { $config = Core::i()->config->getConfiguration($configuration); foreach ($config as $script) { $this->append($script); } }
php
public function init(?string $configuration = 'stylesheets'): void { $config = Core::i()->config->getConfiguration($configuration); foreach ($config as $script) { $this->append($script); } }
[ "public", "function", "init", "(", "?", "string", "$", "configuration", "=", "'stylesheets'", ")", ":", "void", "{", "$", "config", "=", "Core", "::", "i", "(", ")", "->", "config", "->", "getConfiguration", "(", "$", "configuration", ")", ";", "foreach", "(", "$", "config", "as", "$", "script", ")", "{", "$", "this", "->", "append", "(", "$", "script", ")", ";", "}", "}" ]
Get the stylesheets that are defined in the configuration. @param string|null $configuration The name of the settings array in the configuration @return array|void @throws \Exception
[ "Get", "the", "stylesheets", "that", "are", "defined", "in", "the", "configuration", "." ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Renderer/ViewHelper/StylesheetHelper.php#L30-L36
237,377
wigedev/simple-mvc
src/Renderer/ViewHelper/StylesheetHelper.php
StylesheetHelper.prepend
public function prepend(): void { $script = $this->parseArgs(func_get_args()); if ($script !== false) { array_unshift($this->members, $script); } }
php
public function prepend(): void { $script = $this->parseArgs(func_get_args()); if ($script !== false) { array_unshift($this->members, $script); } }
[ "public", "function", "prepend", "(", ")", ":", "void", "{", "$", "script", "=", "$", "this", "->", "parseArgs", "(", "func_get_args", "(", ")", ")", ";", "if", "(", "$", "script", "!==", "false", ")", "{", "array_unshift", "(", "$", "this", "->", "members", ",", "$", "script", ")", ";", "}", "}" ]
Add a new stylesheet to the beginning of the list @param string ... The location of the stylesheet @param string ... The type of stylesheet
[ "Add", "a", "new", "stylesheet", "to", "the", "beginning", "of", "the", "list" ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Renderer/ViewHelper/StylesheetHelper.php#L44-L50
237,378
wigedev/simple-mvc
src/Renderer/ViewHelper/StylesheetHelper.php
StylesheetHelper.append
public function append(): void { $script = $this->parseArgs(func_get_args()); if ($script !== false) { array_push($this->members, $script); } }
php
public function append(): void { $script = $this->parseArgs(func_get_args()); if ($script !== false) { array_push($this->members, $script); } }
[ "public", "function", "append", "(", ")", ":", "void", "{", "$", "script", "=", "$", "this", "->", "parseArgs", "(", "func_get_args", "(", ")", ")", ";", "if", "(", "$", "script", "!==", "false", ")", "{", "array_push", "(", "$", "this", "->", "members", ",", "$", "script", ")", ";", "}", "}" ]
Add a new stylesheet to the end of the list @param string ... The location of the stylesheet @param string ... The type of stylesheet
[ "Add", "a", "new", "stylesheet", "to", "the", "end", "of", "the", "list" ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Renderer/ViewHelper/StylesheetHelper.php#L58-L64
237,379
wigedev/simple-mvc
src/Renderer/ViewHelper/StylesheetHelper.php
StylesheetHelper.makeLink
private function makeLink($args) { if (!isset($args['href'])) { Core::i()->log->warning('Unable to add stylesheet, no href attribute.'); return false; } if (!isset($args['rel'])) { $args['rel'] = 'stylesheet'; } if (!isset($args['type']) && $args['rel'] == 'stylesheet') { $args['type'] = 'text/css'; } $link = '<link'; foreach ($args as $key => $value) { $link .= ' ' . $key . '="' . $value . '"'; } $link .= ' />'; return $link; }
php
private function makeLink($args) { if (!isset($args['href'])) { Core::i()->log->warning('Unable to add stylesheet, no href attribute.'); return false; } if (!isset($args['rel'])) { $args['rel'] = 'stylesheet'; } if (!isset($args['type']) && $args['rel'] == 'stylesheet') { $args['type'] = 'text/css'; } $link = '<link'; foreach ($args as $key => $value) { $link .= ' ' . $key . '="' . $value . '"'; } $link .= ' />'; return $link; }
[ "private", "function", "makeLink", "(", "$", "args", ")", "{", "if", "(", "!", "isset", "(", "$", "args", "[", "'href'", "]", ")", ")", "{", "Core", "::", "i", "(", ")", "->", "log", "->", "warning", "(", "'Unable to add stylesheet, no href attribute.'", ")", ";", "return", "false", ";", "}", "if", "(", "!", "isset", "(", "$", "args", "[", "'rel'", "]", ")", ")", "{", "$", "args", "[", "'rel'", "]", "=", "'stylesheet'", ";", "}", "if", "(", "!", "isset", "(", "$", "args", "[", "'type'", "]", ")", "&&", "$", "args", "[", "'rel'", "]", "==", "'stylesheet'", ")", "{", "$", "args", "[", "'type'", "]", "=", "'text/css'", ";", "}", "$", "link", "=", "'<link'", ";", "foreach", "(", "$", "args", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "link", ".=", "' '", ".", "$", "key", ".", "'=\"'", ".", "$", "value", ".", "'\"'", ";", "}", "$", "link", ".=", "' />'", ";", "return", "$", "link", ";", "}" ]
Generate a link to the stylesheet based on the passed parameters. @param $args @return bool|string
[ "Generate", "a", "link", "to", "the", "stylesheet", "based", "on", "the", "passed", "parameters", "." ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Renderer/ViewHelper/StylesheetHelper.php#L128-L147
237,380
strident/Trident
src/Trident/Component/Caching/CachingFactory.php
CachingFactory.build
public function build($name = null) { $caching = new Caching(); $caching->setStack(new DebugStack()); if ($this->debug && isset($this->debugDriver)) { $caching->setDriver($this->resolveDriver($this->debugDriver)); return $caching; } if (null === $name) { $name = $this->configuration->get('caching.default', 'null'); } $driver = $this->resolveDriver($name); $caching->setDriver($driver); return $caching; }
php
public function build($name = null) { $caching = new Caching(); $caching->setStack(new DebugStack()); if ($this->debug && isset($this->debugDriver)) { $caching->setDriver($this->resolveDriver($this->debugDriver)); return $caching; } if (null === $name) { $name = $this->configuration->get('caching.default', 'null'); } $driver = $this->resolveDriver($name); $caching->setDriver($driver); return $caching; }
[ "public", "function", "build", "(", "$", "name", "=", "null", ")", "{", "$", "caching", "=", "new", "Caching", "(", ")", ";", "$", "caching", "->", "setStack", "(", "new", "DebugStack", "(", ")", ")", ";", "if", "(", "$", "this", "->", "debug", "&&", "isset", "(", "$", "this", "->", "debugDriver", ")", ")", "{", "$", "caching", "->", "setDriver", "(", "$", "this", "->", "resolveDriver", "(", "$", "this", "->", "debugDriver", ")", ")", ";", "return", "$", "caching", ";", "}", "if", "(", "null", "===", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "configuration", "->", "get", "(", "'caching.default'", ",", "'null'", ")", ";", "}", "$", "driver", "=", "$", "this", "->", "resolveDriver", "(", "$", "name", ")", ";", "$", "caching", "->", "setDriver", "(", "$", "driver", ")", ";", "return", "$", "caching", ";", "}" ]
Build cache driver. @param string $name @return DriverInterface
[ "Build", "cache", "driver", "." ]
a112f0b75601b897c470a49d85791dc386c29952
https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Component/Caching/CachingFactory.php#L67-L86
237,381
strident/Trident
src/Trident/Component/Caching/CachingFactory.php
CachingFactory.resolveDriver
protected function resolveDriver($name) { if ( ! isset($this->drivers[$name]) || ! $this->container->has($this->drivers[$name])) { throw new \RuntimeException(sprintf( 'Caching driver "%s" does not exist or is not registered as a service.', $name )); } $driver = $this->container->get($this->drivers[$name]); if ( ! $driver instanceof DriverInterface) { throw new \RuntimeException(sprintf( 'Service "%s" is not a valid caching driver.', $this->drivers[$name] )); } return $driver; }
php
protected function resolveDriver($name) { if ( ! isset($this->drivers[$name]) || ! $this->container->has($this->drivers[$name])) { throw new \RuntimeException(sprintf( 'Caching driver "%s" does not exist or is not registered as a service.', $name )); } $driver = $this->container->get($this->drivers[$name]); if ( ! $driver instanceof DriverInterface) { throw new \RuntimeException(sprintf( 'Service "%s" is not a valid caching driver.', $this->drivers[$name] )); } return $driver; }
[ "protected", "function", "resolveDriver", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "drivers", "[", "$", "name", "]", ")", "||", "!", "$", "this", "->", "container", "->", "has", "(", "$", "this", "->", "drivers", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Caching driver \"%s\" does not exist or is not registered as a service.'", ",", "$", "name", ")", ")", ";", "}", "$", "driver", "=", "$", "this", "->", "container", "->", "get", "(", "$", "this", "->", "drivers", "[", "$", "name", "]", ")", ";", "if", "(", "!", "$", "driver", "instanceof", "DriverInterface", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Service \"%s\" is not a valid caching driver.'", ",", "$", "this", "->", "drivers", "[", "$", "name", "]", ")", ")", ";", "}", "return", "$", "driver", ";", "}" ]
Resolve caching driver from name. @param string $name @return DriverInterface
[ "Resolve", "caching", "driver", "from", "name", "." ]
a112f0b75601b897c470a49d85791dc386c29952
https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Component/Caching/CachingFactory.php#L107-L126
237,382
tenside/core-bundle
src/Annotation/TensideApiDocHandler.php
TensideApiDocHandler.convertField
private function convertField($array) { $result = []; // Copy over well known keys. foreach (static::$convertFields as $key) { if (isset($array[$key])) { $result[$key] = $array[$key]; } } if (isset($array['dataType'])) { $result['dataType'] = $this->inferType($array['dataType']); } else { $result['dataType'] = isset($array['children']) ? 'object' : DataTypes::STRING; } $result['required'] = isset($array['required']) && (bool) $array['required']; $result['readonly'] = isset($array['readonly']) && (bool) $array['readonly']; $result = $this->convertChildren($array, $result); return $result; }
php
private function convertField($array) { $result = []; // Copy over well known keys. foreach (static::$convertFields as $key) { if (isset($array[$key])) { $result[$key] = $array[$key]; } } if (isset($array['dataType'])) { $result['dataType'] = $this->inferType($array['dataType']); } else { $result['dataType'] = isset($array['children']) ? 'object' : DataTypes::STRING; } $result['required'] = isset($array['required']) && (bool) $array['required']; $result['readonly'] = isset($array['readonly']) && (bool) $array['readonly']; $result = $this->convertChildren($array, $result); return $result; }
[ "private", "function", "convertField", "(", "$", "array", ")", "{", "$", "result", "=", "[", "]", ";", "// Copy over well known keys.", "foreach", "(", "static", "::", "$", "convertFields", "as", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "array", "[", "$", "key", "]", ")", ")", "{", "$", "result", "[", "$", "key", "]", "=", "$", "array", "[", "$", "key", "]", ";", "}", "}", "if", "(", "isset", "(", "$", "array", "[", "'dataType'", "]", ")", ")", "{", "$", "result", "[", "'dataType'", "]", "=", "$", "this", "->", "inferType", "(", "$", "array", "[", "'dataType'", "]", ")", ";", "}", "else", "{", "$", "result", "[", "'dataType'", "]", "=", "isset", "(", "$", "array", "[", "'children'", "]", ")", "?", "'object'", ":", "DataTypes", "::", "STRING", ";", "}", "$", "result", "[", "'required'", "]", "=", "isset", "(", "$", "array", "[", "'required'", "]", ")", "&&", "(", "bool", ")", "$", "array", "[", "'required'", "]", ";", "$", "result", "[", "'readonly'", "]", "=", "isset", "(", "$", "array", "[", "'readonly'", "]", ")", "&&", "(", "bool", ")", "$", "array", "[", "'readonly'", "]", ";", "$", "result", "=", "$", "this", "->", "convertChildren", "(", "$", "array", ",", "$", "result", ")", ";", "return", "$", "result", ";", "}" ]
Convert the annotation for a field. @param array $array The information for the field. @return array
[ "Convert", "the", "annotation", "for", "a", "field", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Annotation/TensideApiDocHandler.php#L86-L109
237,383
tenside/core-bundle
src/Annotation/TensideApiDocHandler.php
TensideApiDocHandler.convertChildren
private function convertChildren($array, $result) { if (isset($array['children'])) { foreach ($array['children'] as $key => $value) { $result['children'][$key] = $this->convertField($value); if (isset($result['children'][$key]['required'])) { $result['required'] = $result['required'] || (bool) $result['children'][$key]['required']; } } return $result; } return $result; }
php
private function convertChildren($array, $result) { if (isset($array['children'])) { foreach ($array['children'] as $key => $value) { $result['children'][$key] = $this->convertField($value); if (isset($result['children'][$key]['required'])) { $result['required'] = $result['required'] || (bool) $result['children'][$key]['required']; } } return $result; } return $result; }
[ "private", "function", "convertChildren", "(", "$", "array", ",", "$", "result", ")", "{", "if", "(", "isset", "(", "$", "array", "[", "'children'", "]", ")", ")", "{", "foreach", "(", "$", "array", "[", "'children'", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "result", "[", "'children'", "]", "[", "$", "key", "]", "=", "$", "this", "->", "convertField", "(", "$", "value", ")", ";", "if", "(", "isset", "(", "$", "result", "[", "'children'", "]", "[", "$", "key", "]", "[", "'required'", "]", ")", ")", "{", "$", "result", "[", "'required'", "]", "=", "$", "result", "[", "'required'", "]", "||", "(", "bool", ")", "$", "result", "[", "'children'", "]", "[", "$", "key", "]", "[", "'required'", "]", ";", "}", "}", "return", "$", "result", ";", "}", "return", "$", "result", ";", "}" ]
Convert the children key of an array. @param array $array The source array. @param array $result The partly converted array. @return array
[ "Convert", "the", "children", "key", "of", "an", "array", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Annotation/TensideApiDocHandler.php#L120-L134
237,384
tenside/core-bundle
src/Annotation/TensideApiDocHandler.php
TensideApiDocHandler.inferType
public function inferType($type) { if (DataTypes::isPrimitive($type)) { return $type; } elseif (DataTypes::COLLECTION === strtolower($type)) { return $type; } return DataTypes::STRING; }
php
public function inferType($type) { if (DataTypes::isPrimitive($type)) { return $type; } elseif (DataTypes::COLLECTION === strtolower($type)) { return $type; } return DataTypes::STRING; }
[ "public", "function", "inferType", "(", "$", "type", ")", "{", "if", "(", "DataTypes", "::", "isPrimitive", "(", "$", "type", ")", ")", "{", "return", "$", "type", ";", "}", "elseif", "(", "DataTypes", "::", "COLLECTION", "===", "strtolower", "(", "$", "type", ")", ")", "{", "return", "$", "type", ";", "}", "return", "DataTypes", "::", "STRING", ";", "}" ]
Convert the type. @param string $type The type name. @return string
[ "Convert", "the", "type", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Annotation/TensideApiDocHandler.php#L143-L151
237,385
cubiclab/users-cube
models/User.php
User.findIdentities
public static function findIdentities($ids, $scope = null) { $query = static::find()->where(['id' => $ids]); if ($scope !== null) { if (is_array($scope)) { foreach ($scope as $value) { $query->$value(); } } else { $query->$scope(); } } return $query->all(); }
php
public static function findIdentities($ids, $scope = null) { $query = static::find()->where(['id' => $ids]); if ($scope !== null) { if (is_array($scope)) { foreach ($scope as $value) { $query->$value(); } } else { $query->$scope(); } } return $query->all(); }
[ "public", "static", "function", "findIdentities", "(", "$", "ids", ",", "$", "scope", "=", "null", ")", "{", "$", "query", "=", "static", "::", "find", "(", ")", "->", "where", "(", "[", "'id'", "=>", "$", "ids", "]", ")", ";", "if", "(", "$", "scope", "!==", "null", ")", "{", "if", "(", "is_array", "(", "$", "scope", ")", ")", "{", "foreach", "(", "$", "scope", "as", "$", "value", ")", "{", "$", "query", "->", "$", "value", "(", ")", ";", "}", "}", "else", "{", "$", "query", "->", "$", "scope", "(", ")", ";", "}", "}", "return", "$", "query", "->", "all", "(", ")", ";", "}" ]
Find users by IDs. @param $ids Users IDs @param null $scope Scope @return array|\yii\db\ActiveRecord[] Users
[ "Find", "users", "by", "IDs", "." ]
32ad7b9ae650c226078e69c14eee1d730aa24888
https://github.com/cubiclab/users-cube/blob/32ad7b9ae650c226078e69c14eee1d730aa24888/models/User.php#L128-L141
237,386
cubiclab/users-cube
models/User.php
User.delete
public function delete(){ if(!($this->id == 1 && $this->module->cantDeleteRoot == true)){ if ($this->status == self::STATUS_DELETED) { Yii::$app->authManager->revokeAll($this->getId()); parent::delete(); } else { $this->status = self::STATUS_DELETED; $this->save(false); // validation = false } } }
php
public function delete(){ if(!($this->id == 1 && $this->module->cantDeleteRoot == true)){ if ($this->status == self::STATUS_DELETED) { Yii::$app->authManager->revokeAll($this->getId()); parent::delete(); } else { $this->status = self::STATUS_DELETED; $this->save(false); // validation = false } } }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "!", "(", "$", "this", "->", "id", "==", "1", "&&", "$", "this", "->", "module", "->", "cantDeleteRoot", "==", "true", ")", ")", "{", "if", "(", "$", "this", "->", "status", "==", "self", "::", "STATUS_DELETED", ")", "{", "Yii", "::", "$", "app", "->", "authManager", "->", "revokeAll", "(", "$", "this", "->", "getId", "(", ")", ")", ";", "parent", "::", "delete", "(", ")", ";", "}", "else", "{", "$", "this", "->", "status", "=", "self", "::", "STATUS_DELETED", ";", "$", "this", "->", "save", "(", "false", ")", ";", "// validation = false", "}", "}", "}" ]
Deside delete user or just set a deleted status
[ "Deside", "delete", "user", "or", "just", "set", "a", "deleted", "status" ]
32ad7b9ae650c226078e69c14eee1d730aa24888
https://github.com/cubiclab/users-cube/blob/32ad7b9ae650c226078e69c14eee1d730aa24888/models/User.php#L243-L253
237,387
webtoucher/geometeo-libs
src/GeoDataProvider.php
GeoDataProvider.calculate
public function calculate(Calculator $calculator, $inputValuesGrid) { $outputValuesGrid = []; foreach ($inputValuesGrid as $date => $inputValues) { $outputValuesGrid[$date] = $calculator->calculate($this, new \DateTime($date, $this->dataTimeZone), $inputValues); } return $outputValuesGrid; }
php
public function calculate(Calculator $calculator, $inputValuesGrid) { $outputValuesGrid = []; foreach ($inputValuesGrid as $date => $inputValues) { $outputValuesGrid[$date] = $calculator->calculate($this, new \DateTime($date, $this->dataTimeZone), $inputValues); } return $outputValuesGrid; }
[ "public", "function", "calculate", "(", "Calculator", "$", "calculator", ",", "$", "inputValuesGrid", ")", "{", "$", "outputValuesGrid", "=", "[", "]", ";", "foreach", "(", "$", "inputValuesGrid", "as", "$", "date", "=>", "$", "inputValues", ")", "{", "$", "outputValuesGrid", "[", "$", "date", "]", "=", "$", "calculator", "->", "calculate", "(", "$", "this", ",", "new", "\\", "DateTime", "(", "$", "date", ",", "$", "this", "->", "dataTimeZone", ")", ",", "$", "inputValues", ")", ";", "}", "return", "$", "outputValuesGrid", ";", "}" ]
Returns calculated params time grid. @param Calculator $calculator @param array $inputValuesGrid @return array
[ "Returns", "calculated", "params", "time", "grid", "." ]
196fa7261d98b95e058ee9ed6c5a80c4747797bd
https://github.com/webtoucher/geometeo-libs/blob/196fa7261d98b95e058ee9ed6c5a80c4747797bd/src/GeoDataProvider.php#L43-L50
237,388
edunola13/core-modules
src/DependencyEngine/Reflection.php
Reflection.getProperties
public function getProperties($properties){ $values= array(); foreach ($properties as $key) { $values[$key]= $this->getProperty($key); } return $values; }
php
public function getProperties($properties){ $values= array(); foreach ($properties as $key) { $values[$key]= $this->getProperty($key); } return $values; }
[ "public", "function", "getProperties", "(", "$", "properties", ")", "{", "$", "values", "=", "array", "(", ")", ";", "foreach", "(", "$", "properties", "as", "$", "key", ")", "{", "$", "values", "[", "$", "key", "]", "=", "$", "this", "->", "getProperty", "(", "$", "key", ")", ";", "}", "return", "$", "values", ";", "}" ]
Retorna un array con todos los valores de las propiedades. Para leer cada propiedad llama al metodo getProperty. @param array $properties @return array - propertyName => value
[ "Retorna", "un", "array", "con", "todos", "los", "valores", "de", "las", "propiedades", ".", "Para", "leer", "cada", "propiedad", "llama", "al", "metodo", "getProperty", "." ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DependencyEngine/Reflection.php#L54-L60
237,389
edunola13/core-modules
src/DependencyEngine/Reflection.php
Reflection.setProperties
public function setProperties($properties, $create = FALSE){ foreach ($properties as $key => $value) { $this->setProperty($key, $value, $create); } }
php
public function setProperties($properties, $create = FALSE){ foreach ($properties as $key => $value) { $this->setProperty($key, $value, $create); } }
[ "public", "function", "setProperties", "(", "$", "properties", ",", "$", "create", "=", "FALSE", ")", "{", "foreach", "(", "$", "properties", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "setProperty", "(", "$", "key", ",", "$", "value", ",", "$", "create", ")", ";", "}", "}" ]
Setea las propiedades de un objeto. Para setear cada valor llama al metodo setProperty @param array $properties @param boolean $create
[ "Setea", "las", "propiedades", "de", "un", "objeto", ".", "Para", "setear", "cada", "valor", "llama", "al", "metodo", "setProperty" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DependencyEngine/Reflection.php#L95-L99
237,390
opsbears/piccolo-web-io-standard
src/StandardWebIOModule.php
StandardWebIOModule.configureDependencyInjection
public function configureDependencyInjection(DependencyInjectionContainer $dic, array $moduleConfig, array $globalConfig) { $dic->alias(InputProcessor::class, StandardInputProcessor::class); $dic->alias(OutputProcessor::class, StandardOutputProcessor::class); $dic->setClassParameters(InputProcessor::class, [ 'server' => $_SERVER, 'get' => $_GET, 'post' => $_POST, 'cookie' => $_COOKIE ]); }
php
public function configureDependencyInjection(DependencyInjectionContainer $dic, array $moduleConfig, array $globalConfig) { $dic->alias(InputProcessor::class, StandardInputProcessor::class); $dic->alias(OutputProcessor::class, StandardOutputProcessor::class); $dic->setClassParameters(InputProcessor::class, [ 'server' => $_SERVER, 'get' => $_GET, 'post' => $_POST, 'cookie' => $_COOKIE ]); }
[ "public", "function", "configureDependencyInjection", "(", "DependencyInjectionContainer", "$", "dic", ",", "array", "$", "moduleConfig", ",", "array", "$", "globalConfig", ")", "{", "$", "dic", "->", "alias", "(", "InputProcessor", "::", "class", ",", "StandardInputProcessor", "::", "class", ")", ";", "$", "dic", "->", "alias", "(", "OutputProcessor", "::", "class", ",", "StandardOutputProcessor", "::", "class", ")", ";", "$", "dic", "->", "setClassParameters", "(", "InputProcessor", "::", "class", ",", "[", "'server'", "=>", "$", "_SERVER", ",", "'get'", "=>", "$", "_GET", ",", "'post'", "=>", "$", "_POST", ",", "'cookie'", "=>", "$", "_COOKIE", "]", ")", ";", "}" ]
Configures StandardInputProcessor and StandardOutputProcessor as IO handlers and wires up the input processor to use standard PHP superglobals for input. @param DependencyInjectionContainer $dic @param array $moduleConfig @param array $globalConfig @SuppressWarnings(PHPMD.Superglobals)
[ "Configures", "StandardInputProcessor", "and", "StandardOutputProcessor", "as", "IO", "handlers", "and", "wires", "up", "the", "input", "processor", "to", "use", "standard", "PHP", "superglobals", "for", "input", "." ]
ee8638bfded26d68a93a7fc3e0fed3f6add8d196
https://github.com/opsbears/piccolo-web-io-standard/blob/ee8638bfded26d68a93a7fc3e0fed3f6add8d196/src/StandardWebIOModule.php#L38-L49
237,391
Vovan-VE/array-dumper
src/ArrayDumper.php
ArrayDumper.dump
public function dump(array $input, string $outerIndent = ''): string { $this->indentLength = StringHelper::lengthUtf8($this->indent); return $this->dumpArray( $input, $outerIndent, StringHelper::lengthUtf8($outerIndent) ); }
php
public function dump(array $input, string $outerIndent = ''): string { $this->indentLength = StringHelper::lengthUtf8($this->indent); return $this->dumpArray( $input, $outerIndent, StringHelper::lengthUtf8($outerIndent) ); }
[ "public", "function", "dump", "(", "array", "$", "input", ",", "string", "$", "outerIndent", "=", "''", ")", ":", "string", "{", "$", "this", "->", "indentLength", "=", "StringHelper", "::", "lengthUtf8", "(", "$", "this", "->", "indent", ")", ";", "return", "$", "this", "->", "dumpArray", "(", "$", "input", ",", "$", "outerIndent", ",", "StringHelper", "::", "lengthUtf8", "(", "$", "outerIndent", ")", ")", ";", "}" ]
Dumps an array to PHP code @param array $input Input array @param string $outerIndent Optional outer indent string for wrapped lines @return string PHP code of array. Doing `eval()` of this code will return an array identical `===` to input array. @throws \InvalidArgumentException
[ "Dumps", "an", "array", "to", "PHP", "code" ]
63fe868a7539cdf020851dae7fe1248bd014a1ef
https://github.com/Vovan-VE/array-dumper/blob/63fe868a7539cdf020851dae7fe1248bd014a1ef/src/ArrayDumper.php#L32-L41
237,392
Vovan-VE/array-dumper
src/ArrayDumper.php
ArrayDumper.dumpValue
protected function dumpValue($value): string { if (null === $value) { return 'null'; } if (false === $value) { return 'false'; } if (true === $value) { return 'true'; } if (\is_int($value) || \is_float($value)) { return (string)$value; } if (\is_string($value)) { return StringHelper::dumpString($value); } throw new \InvalidArgumentException('Unsupported data type:' . gettype($value)); }
php
protected function dumpValue($value): string { if (null === $value) { return 'null'; } if (false === $value) { return 'false'; } if (true === $value) { return 'true'; } if (\is_int($value) || \is_float($value)) { return (string)$value; } if (\is_string($value)) { return StringHelper::dumpString($value); } throw new \InvalidArgumentException('Unsupported data type:' . gettype($value)); }
[ "protected", "function", "dumpValue", "(", "$", "value", ")", ":", "string", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "'null'", ";", "}", "if", "(", "false", "===", "$", "value", ")", "{", "return", "'false'", ";", "}", "if", "(", "true", "===", "$", "value", ")", "{", "return", "'true'", ";", "}", "if", "(", "\\", "is_int", "(", "$", "value", ")", "||", "\\", "is_float", "(", "$", "value", ")", ")", "{", "return", "(", "string", ")", "$", "value", ";", "}", "if", "(", "\\", "is_string", "(", "$", "value", ")", ")", "{", "return", "StringHelper", "::", "dumpString", "(", "$", "value", ")", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "'Unsupported data type:'", ".", "gettype", "(", "$", "value", ")", ")", ";", "}" ]
Dumps a value other then array @param mixed $value @return string @throws \InvalidArgumentException In case of unsupported data type
[ "Dumps", "a", "value", "other", "then", "array" ]
63fe868a7539cdf020851dae7fe1248bd014a1ef
https://github.com/Vovan-VE/array-dumper/blob/63fe868a7539cdf020851dae7fe1248bd014a1ef/src/ArrayDumper.php#L49-L71
237,393
Vovan-VE/array-dumper
src/ArrayDumper.php
ArrayDumper.dumpArray
protected function dumpArray(array $input, string $indent, int $outerLineLength): string { if (!$input) { return '[]'; } if ($outerLineLength < $this->lineLength) { $dump = $this->tryDumpList($input, $outerLineLength, 1); if (null !== $dump) { return $dump; } } $next_indent = $indent . $this->indent; $next_indent_length = $outerLineLength + $this->indentLength; $dump = '[' . $this->eol; $index = 0; $still_linear = true; foreach ($input as $key => $value) { $item = $next_indent; $item_outer_length = $next_indent_length; if ($still_linear && $key === $index) { ++$index; } else { $still_linear = false; $key_dump = $this->dumpValue($key); $item .= $key_dump . ' => '; $item_outer_length += 4 + StringHelper::lengthUtf8($key_dump); } if (\is_array($value)) { // there will be trailing comma ',' after value, so outer length gives +1 $value_dump = $this->dumpArray($value, $next_indent, $item_outer_length + 1); } else { $value_dump = $this->dumpValue($value); } $item .= $value_dump; $dump .= $item . ',' . $this->eol; } $dump .= $indent . ']'; return $dump; }
php
protected function dumpArray(array $input, string $indent, int $outerLineLength): string { if (!$input) { return '[]'; } if ($outerLineLength < $this->lineLength) { $dump = $this->tryDumpList($input, $outerLineLength, 1); if (null !== $dump) { return $dump; } } $next_indent = $indent . $this->indent; $next_indent_length = $outerLineLength + $this->indentLength; $dump = '[' . $this->eol; $index = 0; $still_linear = true; foreach ($input as $key => $value) { $item = $next_indent; $item_outer_length = $next_indent_length; if ($still_linear && $key === $index) { ++$index; } else { $still_linear = false; $key_dump = $this->dumpValue($key); $item .= $key_dump . ' => '; $item_outer_length += 4 + StringHelper::lengthUtf8($key_dump); } if (\is_array($value)) { // there will be trailing comma ',' after value, so outer length gives +1 $value_dump = $this->dumpArray($value, $next_indent, $item_outer_length + 1); } else { $value_dump = $this->dumpValue($value); } $item .= $value_dump; $dump .= $item . ',' . $this->eol; } $dump .= $indent . ']'; return $dump; }
[ "protected", "function", "dumpArray", "(", "array", "$", "input", ",", "string", "$", "indent", ",", "int", "$", "outerLineLength", ")", ":", "string", "{", "if", "(", "!", "$", "input", ")", "{", "return", "'[]'", ";", "}", "if", "(", "$", "outerLineLength", "<", "$", "this", "->", "lineLength", ")", "{", "$", "dump", "=", "$", "this", "->", "tryDumpList", "(", "$", "input", ",", "$", "outerLineLength", ",", "1", ")", ";", "if", "(", "null", "!==", "$", "dump", ")", "{", "return", "$", "dump", ";", "}", "}", "$", "next_indent", "=", "$", "indent", ".", "$", "this", "->", "indent", ";", "$", "next_indent_length", "=", "$", "outerLineLength", "+", "$", "this", "->", "indentLength", ";", "$", "dump", "=", "'['", ".", "$", "this", "->", "eol", ";", "$", "index", "=", "0", ";", "$", "still_linear", "=", "true", ";", "foreach", "(", "$", "input", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "item", "=", "$", "next_indent", ";", "$", "item_outer_length", "=", "$", "next_indent_length", ";", "if", "(", "$", "still_linear", "&&", "$", "key", "===", "$", "index", ")", "{", "++", "$", "index", ";", "}", "else", "{", "$", "still_linear", "=", "false", ";", "$", "key_dump", "=", "$", "this", "->", "dumpValue", "(", "$", "key", ")", ";", "$", "item", ".=", "$", "key_dump", ".", "' => '", ";", "$", "item_outer_length", "+=", "4", "+", "StringHelper", "::", "lengthUtf8", "(", "$", "key_dump", ")", ";", "}", "if", "(", "\\", "is_array", "(", "$", "value", ")", ")", "{", "// there will be trailing comma ',' after value, so outer length gives +1", "$", "value_dump", "=", "$", "this", "->", "dumpArray", "(", "$", "value", ",", "$", "next_indent", ",", "$", "item_outer_length", "+", "1", ")", ";", "}", "else", "{", "$", "value_dump", "=", "$", "this", "->", "dumpValue", "(", "$", "value", ")", ";", "}", "$", "item", ".=", "$", "value_dump", ";", "$", "dump", ".=", "$", "item", ".", "','", ".", "$", "this", "->", "eol", ";", "}", "$", "dump", ".=", "$", "indent", ".", "']'", ";", "return", "$", "dump", ";", "}" ]
Dumps an array with specific indention @param array $input Input array @param string $indent Full indention string @param int $outerLineLength Length of `$indent` in characters @return string PHP code @throws \InvalidArgumentException In case of unsupported data type
[ "Dumps", "an", "array", "with", "specific", "indention" ]
63fe868a7539cdf020851dae7fe1248bd014a1ef
https://github.com/Vovan-VE/array-dumper/blob/63fe868a7539cdf020851dae7fe1248bd014a1ef/src/ArrayDumper.php#L81-L129
237,394
Vovan-VE/array-dumper
src/ArrayDumper.php
ArrayDumper.tryDumpList
protected function tryDumpList(array $input, int $outerLineLength, int $level): ?string { if ($level > $this->listDepthLimit) { return null; } $dump = '['; $total_length = $outerLineLength + 1; $index = 0; foreach ($input as $key => $value) { if ($key !== $index) { return null; } if ($index > 0) { $dump .= ', '; $total_length += 2; } if ($total_length >= $this->lineLength) { return null; } ++$index; if (\is_array($value)) { $value_dump = $this->tryDumpList($value, $total_length, $level + 1); if (null === $value_dump) { return null; } } else { $value_dump = $this->dumpValue($value); } $total_length += StringHelper::lengthUtf8($value_dump); if ($total_length >= $this->lineLength) { return null; } $dump .= $value_dump; } $total_length += 1; if ($total_length > $this->lineLength) { return null; } $dump .= ']'; return $dump; }
php
protected function tryDumpList(array $input, int $outerLineLength, int $level): ?string { if ($level > $this->listDepthLimit) { return null; } $dump = '['; $total_length = $outerLineLength + 1; $index = 0; foreach ($input as $key => $value) { if ($key !== $index) { return null; } if ($index > 0) { $dump .= ', '; $total_length += 2; } if ($total_length >= $this->lineLength) { return null; } ++$index; if (\is_array($value)) { $value_dump = $this->tryDumpList($value, $total_length, $level + 1); if (null === $value_dump) { return null; } } else { $value_dump = $this->dumpValue($value); } $total_length += StringHelper::lengthUtf8($value_dump); if ($total_length >= $this->lineLength) { return null; } $dump .= $value_dump; } $total_length += 1; if ($total_length > $this->lineLength) { return null; } $dump .= ']'; return $dump; }
[ "protected", "function", "tryDumpList", "(", "array", "$", "input", ",", "int", "$", "outerLineLength", ",", "int", "$", "level", ")", ":", "?", "string", "{", "if", "(", "$", "level", ">", "$", "this", "->", "listDepthLimit", ")", "{", "return", "null", ";", "}", "$", "dump", "=", "'['", ";", "$", "total_length", "=", "$", "outerLineLength", "+", "1", ";", "$", "index", "=", "0", ";", "foreach", "(", "$", "input", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "!==", "$", "index", ")", "{", "return", "null", ";", "}", "if", "(", "$", "index", ">", "0", ")", "{", "$", "dump", ".=", "', '", ";", "$", "total_length", "+=", "2", ";", "}", "if", "(", "$", "total_length", ">=", "$", "this", "->", "lineLength", ")", "{", "return", "null", ";", "}", "++", "$", "index", ";", "if", "(", "\\", "is_array", "(", "$", "value", ")", ")", "{", "$", "value_dump", "=", "$", "this", "->", "tryDumpList", "(", "$", "value", ",", "$", "total_length", ",", "$", "level", "+", "1", ")", ";", "if", "(", "null", "===", "$", "value_dump", ")", "{", "return", "null", ";", "}", "}", "else", "{", "$", "value_dump", "=", "$", "this", "->", "dumpValue", "(", "$", "value", ")", ";", "}", "$", "total_length", "+=", "StringHelper", "::", "lengthUtf8", "(", "$", "value_dump", ")", ";", "if", "(", "$", "total_length", ">=", "$", "this", "->", "lineLength", ")", "{", "return", "null", ";", "}", "$", "dump", ".=", "$", "value_dump", ";", "}", "$", "total_length", "+=", "1", ";", "if", "(", "$", "total_length", ">", "$", "this", "->", "lineLength", ")", "{", "return", "null", ";", "}", "$", "dump", ".=", "']'", ";", "return", "$", "dump", ";", "}" ]
Dump list if possible @param array $input Input array @param int $outerLineLength Known line length outside of expected dump @param int $level Nesting lists level starting from 1. @return string|null PHP code in case of success. A `null` when one-line dump is not possible @throws \InvalidArgumentException In case of unsupported data type
[ "Dump", "list", "if", "possible" ]
63fe868a7539cdf020851dae7fe1248bd014a1ef
https://github.com/Vovan-VE/array-dumper/blob/63fe868a7539cdf020851dae7fe1248bd014a1ef/src/ArrayDumper.php#L140-L190
237,395
jeromeklam/freefw
src/FreeFW/JsonApi/V1/Encoder.php
Encoder.encodeSingleResource
protected function encodeSingleResource( \FreeFW\Interfaces\ApiResponseInterface $p_api_response ) : \FreeFW\JsonApi\V1\Model\ResourceObject { $resource = new \FreeFW\JsonApi\V1\Model\ResourceObject( $p_api_response->getApiType(), $p_api_response->getApiId() ); $fields = $p_api_response->getApiAttributes(); if ($fields) { $attributes = new \FreeFW\JsonApi\V1\Model\AttributesObject($fields); $resource->setAttributes($attributes); } return $resource; }
php
protected function encodeSingleResource( \FreeFW\Interfaces\ApiResponseInterface $p_api_response ) : \FreeFW\JsonApi\V1\Model\ResourceObject { $resource = new \FreeFW\JsonApi\V1\Model\ResourceObject( $p_api_response->getApiType(), $p_api_response->getApiId() ); $fields = $p_api_response->getApiAttributes(); if ($fields) { $attributes = new \FreeFW\JsonApi\V1\Model\AttributesObject($fields); $resource->setAttributes($attributes); } return $resource; }
[ "protected", "function", "encodeSingleResource", "(", "\\", "FreeFW", "\\", "Interfaces", "\\", "ApiResponseInterface", "$", "p_api_response", ")", ":", "\\", "FreeFW", "\\", "JsonApi", "\\", "V1", "\\", "Model", "\\", "ResourceObject", "{", "$", "resource", "=", "new", "\\", "FreeFW", "\\", "JsonApi", "\\", "V1", "\\", "Model", "\\", "ResourceObject", "(", "$", "p_api_response", "->", "getApiType", "(", ")", ",", "$", "p_api_response", "->", "getApiId", "(", ")", ")", ";", "$", "fields", "=", "$", "p_api_response", "->", "getApiAttributes", "(", ")", ";", "if", "(", "$", "fields", ")", "{", "$", "attributes", "=", "new", "\\", "FreeFW", "\\", "JsonApi", "\\", "V1", "\\", "Model", "\\", "AttributesObject", "(", "$", "fields", ")", ";", "$", "resource", "->", "setAttributes", "(", "$", "attributes", ")", ";", "}", "return", "$", "resource", ";", "}" ]
Encode single resource @param \FreeFW\Interfaces\ApiResponseInterface $p_api_response @return \FreeFW\JsonApi\V1\Model\ResourceObject
[ "Encode", "single", "resource" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/JsonApi/V1/Encoder.php#L19-L32
237,396
jeromeklam/freefw
src/FreeFW/JsonApi/V1/Encoder.php
Encoder.encode
public function encode( \FreeFW\Interfaces\ApiResponseInterface $p_api_response ) : \FreeFW\JsonApi\V1\Model\Document { $document = new \FreeFW\JsonApi\V1\Model\Document(); if ($p_api_response->hasErrors()) { /** * @var \FreeFW\Core\Error $oneError */ foreach ($p_api_response->getErrors() as $idx => $oneError) { $newError = new \FreeFW\JsonApi\V1\Model\ErrorObject( $oneError->getType(), $oneError->getMessage(), $oneError->getCode() ); $document->addError($newError); } } else { if ($p_api_response instanceof \Iterator) { // Composed of multiple objetcs } else { $resource = $this->encodeSingleResource($p_api_response); $document->setData($resource); } } return $document; }
php
public function encode( \FreeFW\Interfaces\ApiResponseInterface $p_api_response ) : \FreeFW\JsonApi\V1\Model\Document { $document = new \FreeFW\JsonApi\V1\Model\Document(); if ($p_api_response->hasErrors()) { /** * @var \FreeFW\Core\Error $oneError */ foreach ($p_api_response->getErrors() as $idx => $oneError) { $newError = new \FreeFW\JsonApi\V1\Model\ErrorObject( $oneError->getType(), $oneError->getMessage(), $oneError->getCode() ); $document->addError($newError); } } else { if ($p_api_response instanceof \Iterator) { // Composed of multiple objetcs } else { $resource = $this->encodeSingleResource($p_api_response); $document->setData($resource); } } return $document; }
[ "public", "function", "encode", "(", "\\", "FreeFW", "\\", "Interfaces", "\\", "ApiResponseInterface", "$", "p_api_response", ")", ":", "\\", "FreeFW", "\\", "JsonApi", "\\", "V1", "\\", "Model", "\\", "Document", "{", "$", "document", "=", "new", "\\", "FreeFW", "\\", "JsonApi", "\\", "V1", "\\", "Model", "\\", "Document", "(", ")", ";", "if", "(", "$", "p_api_response", "->", "hasErrors", "(", ")", ")", "{", "/**\n * @var \\FreeFW\\Core\\Error $oneError\n */", "foreach", "(", "$", "p_api_response", "->", "getErrors", "(", ")", "as", "$", "idx", "=>", "$", "oneError", ")", "{", "$", "newError", "=", "new", "\\", "FreeFW", "\\", "JsonApi", "\\", "V1", "\\", "Model", "\\", "ErrorObject", "(", "$", "oneError", "->", "getType", "(", ")", ",", "$", "oneError", "->", "getMessage", "(", ")", ",", "$", "oneError", "->", "getCode", "(", ")", ")", ";", "$", "document", "->", "addError", "(", "$", "newError", ")", ";", "}", "}", "else", "{", "if", "(", "$", "p_api_response", "instanceof", "\\", "Iterator", ")", "{", "// Composed of multiple objetcs", "}", "else", "{", "$", "resource", "=", "$", "this", "->", "encodeSingleResource", "(", "$", "p_api_response", ")", ";", "$", "document", "->", "setData", "(", "$", "resource", ")", ";", "}", "}", "return", "$", "document", ";", "}" ]
Encode a ApiResponseInterface @param \FreeFW\Interfaces\ApiResponseInterface $p_api_response @return \FreeFW\JsonApi\V1\Model\Document
[ "Encode", "a", "ApiResponseInterface" ]
16ecf24192375c920a070296f396b9d3fd994a1e
https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/JsonApi/V1/Encoder.php#L41-L66
237,397
consigliere/components
src/Migrations/Migrator.php
Migrator.table
public function table() { return $this->database ? $this->laravel['db']->connection($this->database)->table(config('database.migrations')) : $this->laravel['db']->table(config('database.migrations')); }
php
public function table() { return $this->database ? $this->laravel['db']->connection($this->database)->table(config('database.migrations')) : $this->laravel['db']->table(config('database.migrations')); }
[ "public", "function", "table", "(", ")", "{", "return", "$", "this", "->", "database", "?", "$", "this", "->", "laravel", "[", "'db'", "]", "->", "connection", "(", "$", "this", "->", "database", ")", "->", "table", "(", "config", "(", "'database.migrations'", ")", ")", ":", "$", "this", "->", "laravel", "[", "'db'", "]", "->", "table", "(", "config", "(", "'database.migrations'", ")", ")", ";", "}" ]
Get table instance. @return string
[ "Get", "table", "instance", "." ]
9b08bb111f0b55b0a860ed9c3407eda0d9cc1252
https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Migrations/Migrator.php#L223-L226
237,398
mszewcz/php-light-framework
src/Config/ReaderManager.php
ReaderManager.get
public static function get(string $type): AbstractReader { if (!\array_key_exists($type, static::$invokableClasses)) { throw new InvalidArgumentException('Unsupported config file type: '.$type); } return new static::$invokableClasses[$type]; }
php
public static function get(string $type): AbstractReader { if (!\array_key_exists($type, static::$invokableClasses)) { throw new InvalidArgumentException('Unsupported config file type: '.$type); } return new static::$invokableClasses[$type]; }
[ "public", "static", "function", "get", "(", "string", "$", "type", ")", ":", "AbstractReader", "{", "if", "(", "!", "\\", "array_key_exists", "(", "$", "type", ",", "static", "::", "$", "invokableClasses", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Unsupported config file type: '", ".", "$", "type", ")", ";", "}", "return", "new", "static", "::", "$", "invokableClasses", "[", "$", "type", "]", ";", "}" ]
Returns config reader class @param string $type @return AbstractReader
[ "Returns", "config", "reader", "class" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Config/ReaderManager.php#L35-L42
237,399
aruberutochan/repository
src/Traits/RepositoryAncestorCriteriaTrait.php
RepositoryAncestorCriteriaTrait.pushAncestor
public function pushAncestor($ancestor) { if (is_string($ancestor)) { $ancestor = new $ancestor; } if (!$ancestor instanceof AncestorCriteriaInterface) { throw new RepositoryException("Class " . get_class($ancestor) . " must be an instance of Aruberuto\\Repository\\Contracts\\AncestorCriteriaInterface"); } $this->ancestor->push($ancestor); return $this; }
php
public function pushAncestor($ancestor) { if (is_string($ancestor)) { $ancestor = new $ancestor; } if (!$ancestor instanceof AncestorCriteriaInterface) { throw new RepositoryException("Class " . get_class($ancestor) . " must be an instance of Aruberuto\\Repository\\Contracts\\AncestorCriteriaInterface"); } $this->ancestor->push($ancestor); return $this; }
[ "public", "function", "pushAncestor", "(", "$", "ancestor", ")", "{", "if", "(", "is_string", "(", "$", "ancestor", ")", ")", "{", "$", "ancestor", "=", "new", "$", "ancestor", ";", "}", "if", "(", "!", "$", "ancestor", "instanceof", "AncestorCriteriaInterface", ")", "{", "throw", "new", "RepositoryException", "(", "\"Class \"", ".", "get_class", "(", "$", "ancestor", ")", ".", "\" must be an instance of Aruberuto\\\\Repository\\\\Contracts\\\\AncestorCriteriaInterface\"", ")", ";", "}", "$", "this", "->", "ancestor", "->", "push", "(", "$", "ancestor", ")", ";", "return", "$", "this", ";", "}" ]
Push Ancestor for filter the query @param $ancestor @return $this @throws \Aruberuto\Repository\Exceptions\RepositoryException
[ "Push", "Ancestor", "for", "filter", "the", "query" ]
4ecc5eb37377af8f000af76c886c217479dcf454
https://github.com/aruberutochan/repository/blob/4ecc5eb37377af8f000af76c886c217479dcf454/src/Traits/RepositoryAncestorCriteriaTrait.php#L34-L45