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
16,200
Graphiques-Digitale/silverstripe-seo-metadata
code/SEO_Metadata_SiteTree_DataExtension.php
SEO_Metadata_SiteTree_DataExtension.MarkupMeta
public function MarkupMeta($name, $content, $encode = null) { if ($encode !== null) { return '<meta name="' . $name . '" content="' . $this->encodeContent($content, $encode) . '" />' . PHP_EOL; } else { return '<meta name="' . $name . '" content="' . $content . '" />' . PHP_EOL; } }
php
public function MarkupMeta($name, $content, $encode = null) { if ($encode !== null) { return '<meta name="' . $name . '" content="' . $this->encodeContent($content, $encode) . '" />' . PHP_EOL; } else { return '<meta name="' . $name . '" content="' . $content . '" />' . PHP_EOL; } }
[ "public", "function", "MarkupMeta", "(", "$", "name", ",", "$", "content", ",", "$", "encode", "=", "null", ")", "{", "if", "(", "$", "encode", "!==", "null", ")", "{", "return", "'<meta name=\"'", ".", "$", "name", ".", "'\" content=\"'", ".", "$", "this", "->", "encodeContent", "(", "$", "content", ",", "$", "encode", ")", ".", "'\" />'", ".", "PHP_EOL", ";", "}", "else", "{", "return", "'<meta name=\"'", ".", "$", "name", ".", "'\" content=\"'", ".", "$", "content", ".", "'\" />'", ".", "PHP_EOL", ";", "}", "}" ]
Returns markup for a HTML meta element. Can be flagged for encoding. @param string $name @param string $content @param string|null $encode @return string
[ "Returns", "markup", "for", "a", "HTML", "meta", "element", ".", "Can", "be", "flagged", "for", "encoding", "." ]
f92128688a60b6c6b514b6efb1486ac60f4a8e03
https://github.com/Graphiques-Digitale/silverstripe-seo-metadata/blob/f92128688a60b6c6b514b6efb1486ac60f4a8e03/code/SEO_Metadata_SiteTree_DataExtension.php#L174-L181
16,201
Graphiques-Digitale/silverstripe-seo-metadata
code/SEO_Metadata_SiteTree_DataExtension.php
SEO_Metadata_SiteTree_DataExtension.MarkupLink
public function MarkupLink($rel, $href, $type = null, $sizes = null) { // start fragment $return = '<link rel="' . $rel . '" href="' . $href . '"'; // if type if ($type !== null) { $return .= ' type="' . $type . '"'; } // if sizes if ($sizes !== null) { $return .= ' sizes="' . $sizes . '"'; } // end fragment $return .= ' />' . PHP_EOL; // return return $return; }
php
public function MarkupLink($rel, $href, $type = null, $sizes = null) { // start fragment $return = '<link rel="' . $rel . '" href="' . $href . '"'; // if type if ($type !== null) { $return .= ' type="' . $type . '"'; } // if sizes if ($sizes !== null) { $return .= ' sizes="' . $sizes . '"'; } // end fragment $return .= ' />' . PHP_EOL; // return return $return; }
[ "public", "function", "MarkupLink", "(", "$", "rel", ",", "$", "href", ",", "$", "type", "=", "null", ",", "$", "sizes", "=", "null", ")", "{", "// start fragment", "$", "return", "=", "'<link rel=\"'", ".", "$", "rel", ".", "'\" href=\"'", ".", "$", "href", ".", "'\"'", ";", "// if type", "if", "(", "$", "type", "!==", "null", ")", "{", "$", "return", ".=", "' type=\"'", ".", "$", "type", ".", "'\"'", ";", "}", "// if sizes", "if", "(", "$", "sizes", "!==", "null", ")", "{", "$", "return", ".=", "' sizes=\"'", ".", "$", "sizes", ".", "'\"'", ";", "}", "// end fragment", "$", "return", ".=", "' />'", ".", "PHP_EOL", ";", "// return", "return", "$", "return", ";", "}" ]
Returns markup for a HTML link element. @param string $rel @param string $href @param string|null $type @param string|null $sizes @return string
[ "Returns", "markup", "for", "a", "HTML", "link", "element", "." ]
f92128688a60b6c6b514b6efb1486ac60f4a8e03
https://github.com/Graphiques-Digitale/silverstripe-seo-metadata/blob/f92128688a60b6c6b514b6efb1486ac60f4a8e03/code/SEO_Metadata_SiteTree_DataExtension.php#L193-L209
16,202
Graphiques-Digitale/silverstripe-seo-metadata
code/SEO_Metadata_SiteTree_DataExtension.php
SEO_Metadata_SiteTree_DataExtension.GenerateDescription
public function GenerateDescription() { if ($this->owner->MetaDescription) { return $this->owner->MetaDescription; } else { return $this->owner->GenerateDescriptionFromContent(); } }
php
public function GenerateDescription() { if ($this->owner->MetaDescription) { return $this->owner->MetaDescription; } else { return $this->owner->GenerateDescriptionFromContent(); } }
[ "public", "function", "GenerateDescription", "(", ")", "{", "if", "(", "$", "this", "->", "owner", "->", "MetaDescription", ")", "{", "return", "$", "this", "->", "owner", "->", "MetaDescription", ";", "}", "else", "{", "return", "$", "this", "->", "owner", "->", "GenerateDescriptionFromContent", "(", ")", ";", "}", "}" ]
Generates description from the page `MetaDescription`, or the first paragraph of the `Content` attribute. @return string|null
[ "Generates", "description", "from", "the", "page", "MetaDescription", "or", "the", "first", "paragraph", "of", "the", "Content", "attribute", "." ]
f92128688a60b6c6b514b6efb1486ac60f4a8e03
https://github.com/Graphiques-Digitale/silverstripe-seo-metadata/blob/f92128688a60b6c6b514b6efb1486ac60f4a8e03/code/SEO_Metadata_SiteTree_DataExtension.php#L234-L241
16,203
Graphiques-Digitale/silverstripe-seo-metadata
code/SEO_Metadata_SiteTree_DataExtension.php
SEO_Metadata_SiteTree_DataExtension.GenerateDescriptionFromContent
public function GenerateDescriptionFromContent() { // check for content if ($content = trim($this->owner->Content)) { // pillage first paragraph from page content if (preg_match('/<p>(.*?)<\/p>/i', $content, $match)) { // is HTML $content = $match[0]; } else { // is plain text $content = explode(PHP_EOL, $content); $content = $content[0]; } // decode (no harm done) & return return trim(html_entity_decode(strip_tags($content))); } else { return null; } }
php
public function GenerateDescriptionFromContent() { // check for content if ($content = trim($this->owner->Content)) { // pillage first paragraph from page content if (preg_match('/<p>(.*?)<\/p>/i', $content, $match)) { // is HTML $content = $match[0]; } else { // is plain text $content = explode(PHP_EOL, $content); $content = $content[0]; } // decode (no harm done) & return return trim(html_entity_decode(strip_tags($content))); } else { return null; } }
[ "public", "function", "GenerateDescriptionFromContent", "(", ")", "{", "// check for content", "if", "(", "$", "content", "=", "trim", "(", "$", "this", "->", "owner", "->", "Content", ")", ")", "{", "// pillage first paragraph from page content", "if", "(", "preg_match", "(", "'/<p>(.*?)<\\/p>/i'", ",", "$", "content", ",", "$", "match", ")", ")", "{", "// is HTML", "$", "content", "=", "$", "match", "[", "0", "]", ";", "}", "else", "{", "// is plain text", "$", "content", "=", "explode", "(", "PHP_EOL", ",", "$", "content", ")", ";", "$", "content", "=", "$", "content", "[", "0", "]", ";", "}", "// decode (no harm done) & return", "return", "trim", "(", "html_entity_decode", "(", "strip_tags", "(", "$", "content", ")", ")", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Generates description from the first paragraph of the `Content` attribute. @return string|null
[ "Generates", "description", "from", "the", "first", "paragraph", "of", "the", "Content", "attribute", "." ]
f92128688a60b6c6b514b6efb1486ac60f4a8e03
https://github.com/Graphiques-Digitale/silverstripe-seo-metadata/blob/f92128688a60b6c6b514b6efb1486ac60f4a8e03/code/SEO_Metadata_SiteTree_DataExtension.php#L248-L266
16,204
Graphiques-Digitale/silverstripe-seo-metadata
code/SEO_Metadata_SiteTree_DataExtension.php
SEO_Metadata_SiteTree_DataExtension.GenerateExtraMeta
public function GenerateExtraMeta() { if ($this->owner->ExtraMeta) { return $this->owner->ExtraMeta . PHP_EOL; } else { return $this->owner->MarkupComment('none'); } }
php
public function GenerateExtraMeta() { if ($this->owner->ExtraMeta) { return $this->owner->ExtraMeta . PHP_EOL; } else { return $this->owner->MarkupComment('none'); } }
[ "public", "function", "GenerateExtraMeta", "(", ")", "{", "if", "(", "$", "this", "->", "owner", "->", "ExtraMeta", ")", "{", "return", "$", "this", "->", "owner", "->", "ExtraMeta", ".", "PHP_EOL", ";", "}", "else", "{", "return", "$", "this", "->", "owner", "->", "MarkupComment", "(", "'none'", ")", ";", "}", "}" ]
Generates extra metadata. @return string
[ "Generates", "extra", "metadata", "." ]
f92128688a60b6c6b514b6efb1486ac60f4a8e03
https://github.com/Graphiques-Digitale/silverstripe-seo-metadata/blob/f92128688a60b6c6b514b6efb1486ac60f4a8e03/code/SEO_Metadata_SiteTree_DataExtension.php#L273-L280
16,205
FrenchFrogs/framework
src/Ruler/Page/Page.php
Page.isCurrent
public function isCurrent() { $link = $this->getLink(); if ($link{0} == '/') { $link = substr($link, 1); } return request()->is($link); }
php
public function isCurrent() { $link = $this->getLink(); if ($link{0} == '/') { $link = substr($link, 1); } return request()->is($link); }
[ "public", "function", "isCurrent", "(", ")", "{", "$", "link", "=", "$", "this", "->", "getLink", "(", ")", ";", "if", "(", "$", "link", "{", "0", "}", "==", "'/'", ")", "{", "$", "link", "=", "substr", "(", "$", "link", ",", "1", ")", ";", "}", "return", "request", "(", ")", "->", "is", "(", "$", "link", ")", ";", "}" ]
Return TRUE if the current page is this page @return bool
[ "Return", "TRUE", "if", "the", "current", "page", "is", "this", "page" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Ruler/Page/Page.php#L338-L346
16,206
readdle/fqdb
src/Readdle/Database/FQDBQueryAPI.php
FQDBQueryAPI.queryArray
private function queryArray($query, $options, $fetcher) { $statement = $this->_runQuery($query, $options); $result = call_user_func($fetcher, $statement); return is_array($result) ? $result : []; }
php
private function queryArray($query, $options, $fetcher) { $statement = $this->_runQuery($query, $options); $result = call_user_func($fetcher, $statement); return is_array($result) ? $result : []; }
[ "private", "function", "queryArray", "(", "$", "query", ",", "$", "options", ",", "$", "fetcher", ")", "{", "$", "statement", "=", "$", "this", "->", "_runQuery", "(", "$", "query", ",", "$", "options", ")", ";", "$", "result", "=", "call_user_func", "(", "$", "fetcher", ",", "$", "statement", ")", ";", "return", "is_array", "(", "$", "result", ")", "?", "$", "result", ":", "[", "]", ";", "}" ]
executes SELECT or SHOW query and returns result array @param string $query @param array $options @param callable $fetcher @return array
[ "executes", "SELECT", "or", "SHOW", "query", "and", "returns", "result", "array" ]
4ef2e8f3343a7c8fbb309c243be502a160c42083
https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBQueryAPI.php#L34-L39
16,207
readdle/fqdb
src/Readdle/Database/FQDBQueryAPI.php
FQDBQueryAPI.queryValue
public function queryValue($query, $options = array()) { $statement = $this->_runQuery($query, $options); return $statement->fetch(\PDO::FETCH_COLUMN); }
php
public function queryValue($query, $options = array()) { $statement = $this->_runQuery($query, $options); return $statement->fetch(\PDO::FETCH_COLUMN); }
[ "public", "function", "queryValue", "(", "$", "query", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "statement", "=", "$", "this", "->", "_runQuery", "(", "$", "query", ",", "$", "options", ")", ";", "return", "$", "statement", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_COLUMN", ")", ";", "}" ]
executes SELECT or SHOW query and returns 1st returned element @param string $query @param array $options @return string|false
[ "executes", "SELECT", "or", "SHOW", "query", "and", "returns", "1st", "returned", "element" ]
4ef2e8f3343a7c8fbb309c243be502a160c42083
https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBQueryAPI.php#L47-L51
16,208
readdle/fqdb
src/Readdle/Database/FQDBQueryAPI.php
FQDBQueryAPI.queryAssoc
public function queryAssoc($query, $options = array()) { $statement = $this->_runQuery($query, $options); return $statement->fetch(\PDO::FETCH_ASSOC); }
php
public function queryAssoc($query, $options = array()) { $statement = $this->_runQuery($query, $options); return $statement->fetch(\PDO::FETCH_ASSOC); }
[ "public", "function", "queryAssoc", "(", "$", "query", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "statement", "=", "$", "this", "->", "_runQuery", "(", "$", "query", ",", "$", "options", ")", ";", "return", "$", "statement", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "}" ]
executes SELECT or SHOW query and returns 1st row as assoc array @param string $query @param array $options @return array|false
[ "executes", "SELECT", "or", "SHOW", "query", "and", "returns", "1st", "row", "as", "assoc", "array" ]
4ef2e8f3343a7c8fbb309c243be502a160c42083
https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBQueryAPI.php#L59-L63
16,209
readdle/fqdb
src/Readdle/Database/FQDBQueryAPI.php
FQDBQueryAPI.queryList
public function queryList($query, $options = array()) { $statement = $this->_runQuery($query, $options); return $statement->fetch(\PDO::FETCH_NUM); }
php
public function queryList($query, $options = array()) { $statement = $this->_runQuery($query, $options); return $statement->fetch(\PDO::FETCH_NUM); }
[ "public", "function", "queryList", "(", "$", "query", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "statement", "=", "$", "this", "->", "_runQuery", "(", "$", "query", ",", "$", "options", ")", ";", "return", "$", "statement", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_NUM", ")", ";", "}" ]
executes SELECT or SHOW query and returns as array @param string $query @param array $options @return array|false
[ "executes", "SELECT", "or", "SHOW", "query", "and", "returns", "as", "array" ]
4ef2e8f3343a7c8fbb309c243be502a160c42083
https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBQueryAPI.php#L71-L75
16,210
readdle/fqdb
src/Readdle/Database/FQDBQueryAPI.php
FQDBQueryAPI.queryVector
public function queryVector($query, $options = array()) { return $this->queryArray($query, $options, function(\PDOStatement $statement) { return $statement->fetchAll(\PDO::FETCH_COLUMN, 0); }); }
php
public function queryVector($query, $options = array()) { return $this->queryArray($query, $options, function(\PDOStatement $statement) { return $statement->fetchAll(\PDO::FETCH_COLUMN, 0); }); }
[ "public", "function", "queryVector", "(", "$", "query", ",", "$", "options", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "queryArray", "(", "$", "query", ",", "$", "options", ",", "function", "(", "\\", "PDOStatement", "$", "statement", ")", "{", "return", "$", "statement", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_COLUMN", ",", "0", ")", ";", "}", ")", ";", "}" ]
executes SELECT or SHOW query and returns result as array @param string $query @param array $options @return array
[ "executes", "SELECT", "or", "SHOW", "query", "and", "returns", "result", "as", "array" ]
4ef2e8f3343a7c8fbb309c243be502a160c42083
https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBQueryAPI.php#L85-L90
16,211
readdle/fqdb
src/Readdle/Database/FQDBQueryAPI.php
FQDBQueryAPI.queryTable
public function queryTable($query, $options = array()) { return $this->queryArray($query, $options, function(\PDOStatement $statement) { return $statement->fetchAll(\PDO::FETCH_ASSOC); } ); }
php
public function queryTable($query, $options = array()) { return $this->queryArray($query, $options, function(\PDOStatement $statement) { return $statement->fetchAll(\PDO::FETCH_ASSOC); } ); }
[ "public", "function", "queryTable", "(", "$", "query", ",", "$", "options", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "queryArray", "(", "$", "query", ",", "$", "options", ",", "function", "(", "\\", "PDOStatement", "$", "statement", ")", "{", "return", "$", "statement", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "}", ")", ";", "}" ]
executes SELECT or SHOW query and returns result as assoc array @param string $query @param array $options @return array
[ "executes", "SELECT", "or", "SHOW", "query", "and", "returns", "result", "as", "assoc", "array" ]
4ef2e8f3343a7c8fbb309c243be502a160c42083
https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBQueryAPI.php#L98-L103
16,212
readdle/fqdb
src/Readdle/Database/FQDBQueryAPI.php
FQDBQueryAPI.queryObjArray
public function queryObjArray($query, $className, $options = array(), $classConstructorArguments = NULL) { if (!class_exists($className)) { $this->_error(FQDBException::CLASS_NOT_EXIST, FQDBException::FQDB_CODE); } return $this->queryArray($query, $options, function(\PDOStatement $statement) use ($className, $classConstructorArguments) { return $statement->fetchAll(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $className, $classConstructorArguments); } ); }
php
public function queryObjArray($query, $className, $options = array(), $classConstructorArguments = NULL) { if (!class_exists($className)) { $this->_error(FQDBException::CLASS_NOT_EXIST, FQDBException::FQDB_CODE); } return $this->queryArray($query, $options, function(\PDOStatement $statement) use ($className, $classConstructorArguments) { return $statement->fetchAll(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $className, $classConstructorArguments); } ); }
[ "public", "function", "queryObjArray", "(", "$", "query", ",", "$", "className", ",", "$", "options", "=", "array", "(", ")", ",", "$", "classConstructorArguments", "=", "NULL", ")", "{", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{", "$", "this", "->", "_error", "(", "FQDBException", "::", "CLASS_NOT_EXIST", ",", "FQDBException", "::", "FQDB_CODE", ")", ";", "}", "return", "$", "this", "->", "queryArray", "(", "$", "query", ",", "$", "options", ",", "function", "(", "\\", "PDOStatement", "$", "statement", ")", "use", "(", "$", "className", ",", "$", "classConstructorArguments", ")", "{", "return", "$", "statement", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_CLASS", "|", "\\", "PDO", "::", "FETCH_PROPS_LATE", ",", "$", "className", ",", "$", "classConstructorArguments", ")", ";", "}", ")", ";", "}" ]
executes SELECT or SHOW query and returns result as array of objects of given class @param string $query @param string $className @param array $options @param array $classConstructorArguments @return array
[ "executes", "SELECT", "or", "SHOW", "query", "and", "returns", "result", "as", "array", "of", "objects", "of", "given", "class" ]
4ef2e8f3343a7c8fbb309c243be502a160c42083
https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBQueryAPI.php#L113-L125
16,213
readdle/fqdb
src/Readdle/Database/FQDBQueryAPI.php
FQDBQueryAPI.queryObj
public function queryObj($query, $className, $options = array(), $classConstructorArguments = NULL) { if (!class_exists($className)) { $this->_error(FQDBException::CLASS_NOT_EXIST, FQDBException::FQDB_CODE); } $statement = $this->_runQuery($query, $options); $statement->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $className, $classConstructorArguments); return $statement->fetch(); }
php
public function queryObj($query, $className, $options = array(), $classConstructorArguments = NULL) { if (!class_exists($className)) { $this->_error(FQDBException::CLASS_NOT_EXIST, FQDBException::FQDB_CODE); } $statement = $this->_runQuery($query, $options); $statement->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $className, $classConstructorArguments); return $statement->fetch(); }
[ "public", "function", "queryObj", "(", "$", "query", ",", "$", "className", ",", "$", "options", "=", "array", "(", ")", ",", "$", "classConstructorArguments", "=", "NULL", ")", "{", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "{", "$", "this", "->", "_error", "(", "FQDBException", "::", "CLASS_NOT_EXIST", ",", "FQDBException", "::", "FQDB_CODE", ")", ";", "}", "$", "statement", "=", "$", "this", "->", "_runQuery", "(", "$", "query", ",", "$", "options", ")", ";", "$", "statement", "->", "setFetchMode", "(", "\\", "PDO", "::", "FETCH_CLASS", "|", "\\", "PDO", "::", "FETCH_PROPS_LATE", ",", "$", "className", ",", "$", "classConstructorArguments", ")", ";", "return", "$", "statement", "->", "fetch", "(", ")", ";", "}" ]
executes SELECT or SHOW query and returns object of given class @param string $query @param string $className @param array $options @param array $classConstructorArguments @return object|false
[ "executes", "SELECT", "or", "SHOW", "query", "and", "returns", "object", "of", "given", "class" ]
4ef2e8f3343a7c8fbb309c243be502a160c42083
https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBQueryAPI.php#L136-L146
16,214
readdle/fqdb
src/Readdle/Database/FQDBQueryAPI.php
FQDBQueryAPI.queryTableCallback
public function queryTableCallback($query, $options = [], $callback) { if(!is_callable($callback)) { $this->_error(FQDBException::NOT_CALLABLE_ERROR, FQDBException::FQDB_CODE); } $statement = $this->_runQuery($query, $options); while ($row = $statement->fetch(\PDO::FETCH_ASSOC)) { call_user_func($callback, $row); } return true; //executed successfully }
php
public function queryTableCallback($query, $options = [], $callback) { if(!is_callable($callback)) { $this->_error(FQDBException::NOT_CALLABLE_ERROR, FQDBException::FQDB_CODE); } $statement = $this->_runQuery($query, $options); while ($row = $statement->fetch(\PDO::FETCH_ASSOC)) { call_user_func($callback, $row); } return true; //executed successfully }
[ "public", "function", "queryTableCallback", "(", "$", "query", ",", "$", "options", "=", "[", "]", ",", "$", "callback", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callback", ")", ")", "{", "$", "this", "->", "_error", "(", "FQDBException", "::", "NOT_CALLABLE_ERROR", ",", "FQDBException", "::", "FQDB_CODE", ")", ";", "}", "$", "statement", "=", "$", "this", "->", "_runQuery", "(", "$", "query", ",", "$", "options", ")", ";", "while", "(", "$", "row", "=", "$", "statement", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ")", "{", "call_user_func", "(", "$", "callback", ",", "$", "row", ")", ";", "}", "return", "true", ";", "//executed successfully", "}" ]
Execute query and apply a callback function to each row @param string $query @param array $options @param callable $callback @return boolean
[ "Execute", "query", "and", "apply", "a", "callback", "function", "to", "each", "row" ]
4ef2e8f3343a7c8fbb309c243be502a160c42083
https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBQueryAPI.php#L156-L166
16,215
readdle/fqdb
src/Readdle/Database/FQDBQueryAPI.php
FQDBQueryAPI.queryTableGenerator
public function queryTableGenerator($query, $options = []) { $statement = $this->_runQuery($query, $options); while ($row = $statement->fetch(\PDO::FETCH_ASSOC)) { yield $row; } }
php
public function queryTableGenerator($query, $options = []) { $statement = $this->_runQuery($query, $options); while ($row = $statement->fetch(\PDO::FETCH_ASSOC)) { yield $row; } }
[ "public", "function", "queryTableGenerator", "(", "$", "query", ",", "$", "options", "=", "[", "]", ")", "{", "$", "statement", "=", "$", "this", "->", "_runQuery", "(", "$", "query", ",", "$", "options", ")", ";", "while", "(", "$", "row", "=", "$", "statement", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ")", "{", "yield", "$", "row", ";", "}", "}" ]
Execute a query and makes generator from the result @param $query @param array $options @return \Generator
[ "Execute", "a", "query", "and", "makes", "generator", "from", "the", "result" ]
4ef2e8f3343a7c8fbb309c243be502a160c42083
https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBQueryAPI.php#L175-L181
16,216
readdle/fqdb
src/Readdle/Database/FQDBQueryAPI.php
FQDBQueryAPI.queryHash
public function queryHash($query, $options = array()) { return $this->queryArray( $query, $options, function(\PDOStatement $statement) { return $statement->fetchAll(\PDO::FETCH_KEY_PAIR); } ); }
php
public function queryHash($query, $options = array()) { return $this->queryArray( $query, $options, function(\PDOStatement $statement) { return $statement->fetchAll(\PDO::FETCH_KEY_PAIR); } ); }
[ "public", "function", "queryHash", "(", "$", "query", ",", "$", "options", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "queryArray", "(", "$", "query", ",", "$", "options", ",", "function", "(", "\\", "PDOStatement", "$", "statement", ")", "{", "return", "$", "statement", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_KEY_PAIR", ")", ";", "}", ")", ";", "}" ]
executes SELECT or SHOW query and returns an assoc array made of two-columns where the first column is a key and the second column is the value @param $query @param array $options @return array
[ "executes", "SELECT", "or", "SHOW", "query", "and", "returns", "an", "assoc", "array", "made", "of", "two", "-", "columns", "where", "the", "first", "column", "is", "a", "key", "and", "the", "second", "column", "is", "the", "value" ]
4ef2e8f3343a7c8fbb309c243be502a160c42083
https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBQueryAPI.php#L190-L199
16,217
comodojo/dispatcher.framework
src/Comodojo/Dispatcher/Router/Parser.php
Parser.read
public function read($folders = array(), Route $value = null, $regex = '') { if (is_null($value)) { $value = new Route(); } // if the first 'folder' is empty is removed while (!empty($folders) && empty($folders[0])) { array_shift($folders); } // if the 'folder' array is empty, the route has been fully analyzed // this is the exit condition from the recursive loop. if (empty($folders)) { return '^'.$regex.'[\/]?$'; } else { // The first element of the array 'folders' is taken in order to be analyzed $folder = array_shift($folders); // All the parameters of the route must be json strings $decoded = json_decode($folder, true); if (!is_null($decoded) && is_array($decoded)) { $param_regex = ''; $param_required = false; /* All the folders can include more than one parameter * Eg: /service_name/{'param1': 'regex1', 'param2': 'regex2'}/ * /calendar/{'ux_timestamp*': '\d{10}', 'microseconds': '\d{4}'}/ * * The '*' at the end of the paramerter name implies that the parameter is required * This example can be read as a calendar service that accepts both * timestamps in unix or javascript format. * * This is the reason of the following 'foreach' */ foreach ($decoded as $key => $string) { $this->logger->debug("Route parser - parameter key: $key"); $this->logger->debug("Route parser - parameter string: $string"); /* The key and the regex of every paramater is passed to the 'param' * method which will build an appropriate regular expression and will understand * if the parameter is required and will build the Route query object */ $param_regex .= $this->param($key, $string, $value); if ($value->isQueryRequired($key)) { $param_required = true; } $this->logger->debug("Route parser - parameter regex: $param_regex"); } // Once the parameter is analyzed, the result is passed to the next iteration return $this->read( $folders, $value, $regex.'(?:\/'.$param_regex.')'.(($param_required) ? '{1}' : '?') ); } else { // if the element is not a json string, I assume it's the service name $value->addService($folder); return $this->read( $folders, $value, $regex.'\/'.$folder ); } } }
php
public function read($folders = array(), Route $value = null, $regex = '') { if (is_null($value)) { $value = new Route(); } // if the first 'folder' is empty is removed while (!empty($folders) && empty($folders[0])) { array_shift($folders); } // if the 'folder' array is empty, the route has been fully analyzed // this is the exit condition from the recursive loop. if (empty($folders)) { return '^'.$regex.'[\/]?$'; } else { // The first element of the array 'folders' is taken in order to be analyzed $folder = array_shift($folders); // All the parameters of the route must be json strings $decoded = json_decode($folder, true); if (!is_null($decoded) && is_array($decoded)) { $param_regex = ''; $param_required = false; /* All the folders can include more than one parameter * Eg: /service_name/{'param1': 'regex1', 'param2': 'regex2'}/ * /calendar/{'ux_timestamp*': '\d{10}', 'microseconds': '\d{4}'}/ * * The '*' at the end of the paramerter name implies that the parameter is required * This example can be read as a calendar service that accepts both * timestamps in unix or javascript format. * * This is the reason of the following 'foreach' */ foreach ($decoded as $key => $string) { $this->logger->debug("Route parser - parameter key: $key"); $this->logger->debug("Route parser - parameter string: $string"); /* The key and the regex of every paramater is passed to the 'param' * method which will build an appropriate regular expression and will understand * if the parameter is required and will build the Route query object */ $param_regex .= $this->param($key, $string, $value); if ($value->isQueryRequired($key)) { $param_required = true; } $this->logger->debug("Route parser - parameter regex: $param_regex"); } // Once the parameter is analyzed, the result is passed to the next iteration return $this->read( $folders, $value, $regex.'(?:\/'.$param_regex.')'.(($param_required) ? '{1}' : '?') ); } else { // if the element is not a json string, I assume it's the service name $value->addService($folder); return $this->read( $folders, $value, $regex.'\/'.$folder ); } } }
[ "public", "function", "read", "(", "$", "folders", "=", "array", "(", ")", ",", "Route", "$", "value", "=", "null", ",", "$", "regex", "=", "''", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "value", "=", "new", "Route", "(", ")", ";", "}", "// if the first 'folder' is empty is removed", "while", "(", "!", "empty", "(", "$", "folders", ")", "&&", "empty", "(", "$", "folders", "[", "0", "]", ")", ")", "{", "array_shift", "(", "$", "folders", ")", ";", "}", "// if the 'folder' array is empty, the route has been fully analyzed", "// this is the exit condition from the recursive loop.", "if", "(", "empty", "(", "$", "folders", ")", ")", "{", "return", "'^'", ".", "$", "regex", ".", "'[\\/]?$'", ";", "}", "else", "{", "// The first element of the array 'folders' is taken in order to be analyzed", "$", "folder", "=", "array_shift", "(", "$", "folders", ")", ";", "// All the parameters of the route must be json strings", "$", "decoded", "=", "json_decode", "(", "$", "folder", ",", "true", ")", ";", "if", "(", "!", "is_null", "(", "$", "decoded", ")", "&&", "is_array", "(", "$", "decoded", ")", ")", "{", "$", "param_regex", "=", "''", ";", "$", "param_required", "=", "false", ";", "/* All the folders can include more than one parameter\n * Eg: /service_name/{'param1': 'regex1', 'param2': 'regex2'}/\n * /calendar/{'ux_timestamp*': '\\d{10}', 'microseconds': '\\d{4}'}/\n *\n * The '*' at the end of the paramerter name implies that the parameter is required\n * This example can be read as a calendar service that accepts both\n * timestamps in unix or javascript format.\n *\n * This is the reason of the following 'foreach'\n */", "foreach", "(", "$", "decoded", "as", "$", "key", "=>", "$", "string", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "\"Route parser - parameter key: $key\"", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "\"Route parser - parameter string: $string\"", ")", ";", "/* The key and the regex of every paramater is passed to the 'param'\n * method which will build an appropriate regular expression and will understand\n * if the parameter is required and will build the Route query object\n */", "$", "param_regex", ".=", "$", "this", "->", "param", "(", "$", "key", ",", "$", "string", ",", "$", "value", ")", ";", "if", "(", "$", "value", "->", "isQueryRequired", "(", "$", "key", ")", ")", "{", "$", "param_required", "=", "true", ";", "}", "$", "this", "->", "logger", "->", "debug", "(", "\"Route parser - parameter regex: $param_regex\"", ")", ";", "}", "// Once the parameter is analyzed, the result is passed to the next iteration", "return", "$", "this", "->", "read", "(", "$", "folders", ",", "$", "value", ",", "$", "regex", ".", "'(?:\\/'", ".", "$", "param_regex", ".", "')'", ".", "(", "(", "$", "param_required", ")", "?", "'{1}'", ":", "'?'", ")", ")", ";", "}", "else", "{", "// if the element is not a json string, I assume it's the service name", "$", "value", "->", "addService", "(", "$", "folder", ")", ";", "return", "$", "this", "->", "read", "(", "$", "folders", ",", "$", "value", ",", "$", "regex", ".", "'\\/'", ".", "$", "folder", ")", ";", "}", "}", "}" ]
the global regular expression against which all the request URI will be compared
[ "the", "global", "regular", "expression", "against", "which", "all", "the", "request", "URI", "will", "be", "compared" ]
5093297dcb7441a8d8f79cbb2429c93232e16d1c
https://github.com/comodojo/dispatcher.framework/blob/5093297dcb7441a8d8f79cbb2429c93232e16d1c/src/Comodojo/Dispatcher/Router/Parser.php#L37-L122
16,218
comodojo/dispatcher.framework
src/Comodojo/Dispatcher/Router/Parser.php
Parser.param
private function param($key, $string, $value) { $field_required = false; // If the field name ends with a '*', the parameter is considered as required if (preg_match('/^(.+)\*$/', $key, $bits)) { $key = $bits[1]; $field_required = true; } // The $value query object contains all regex which will be used by the collector to parse the route fields $value->setQuery($key, $string, $field_required); /* Every parameter can include it's own logic into the regular expression, * it can use backreferences and it's expected to be used against a single parameter. * This means that it can't be used as is to build the route regular expression, * Backreferences are not useful at this point and can make the regular expression more time consuming * and resource hungry. This is why they are replaced with the grouping parenthesis. * Eg: (value) changes in (?:value) * * Delimiting characters like '^' and '$' are also meaningless in the complete regular expression and * need to be removed. Contrariwise, wildcards must be delimited in order to keep the whole regular * expression consistent, hence a '?' is added to all the '.*' or '.+' that don't already have one. */ $string = preg_replace("/(?<!\\\\)\\((?!\\?)/", '(?:', $string); $string = preg_replace("/\\.([\\*\\+])(?!\\?)/", '.${1}?', $string); $string = preg_replace("/^[\\^]/", '', $string); $string = preg_replace("/[\\$]$/", '', $string); /* The produced regular expression is grouped and associated with its key (this means that the 'preg_match' * function will generate an associative array where the key/value association is preserved). * If the field is required, the regular expression is completed with a '{1}' (which make it compulsory), * otherwise a '?' is added. */ return '(?P<'.$key.'>'.$string.')'.(($field_required) ? '{1}' : '?'); }
php
private function param($key, $string, $value) { $field_required = false; // If the field name ends with a '*', the parameter is considered as required if (preg_match('/^(.+)\*$/', $key, $bits)) { $key = $bits[1]; $field_required = true; } // The $value query object contains all regex which will be used by the collector to parse the route fields $value->setQuery($key, $string, $field_required); /* Every parameter can include it's own logic into the regular expression, * it can use backreferences and it's expected to be used against a single parameter. * This means that it can't be used as is to build the route regular expression, * Backreferences are not useful at this point and can make the regular expression more time consuming * and resource hungry. This is why they are replaced with the grouping parenthesis. * Eg: (value) changes in (?:value) * * Delimiting characters like '^' and '$' are also meaningless in the complete regular expression and * need to be removed. Contrariwise, wildcards must be delimited in order to keep the whole regular * expression consistent, hence a '?' is added to all the '.*' or '.+' that don't already have one. */ $string = preg_replace("/(?<!\\\\)\\((?!\\?)/", '(?:', $string); $string = preg_replace("/\\.([\\*\\+])(?!\\?)/", '.${1}?', $string); $string = preg_replace("/^[\\^]/", '', $string); $string = preg_replace("/[\\$]$/", '', $string); /* The produced regular expression is grouped and associated with its key (this means that the 'preg_match' * function will generate an associative array where the key/value association is preserved). * If the field is required, the regular expression is completed with a '{1}' (which make it compulsory), * otherwise a '?' is added. */ return '(?P<'.$key.'>'.$string.')'.(($field_required) ? '{1}' : '?'); }
[ "private", "function", "param", "(", "$", "key", ",", "$", "string", ",", "$", "value", ")", "{", "$", "field_required", "=", "false", ";", "// If the field name ends with a '*', the parameter is considered as required", "if", "(", "preg_match", "(", "'/^(.+)\\*$/'", ",", "$", "key", ",", "$", "bits", ")", ")", "{", "$", "key", "=", "$", "bits", "[", "1", "]", ";", "$", "field_required", "=", "true", ";", "}", "// The $value query object contains all regex which will be used by the collector to parse the route fields", "$", "value", "->", "setQuery", "(", "$", "key", ",", "$", "string", ",", "$", "field_required", ")", ";", "/* Every parameter can include it's own logic into the regular expression,\n * it can use backreferences and it's expected to be used against a single parameter.\n * This means that it can't be used as is to build the route regular expression,\n * Backreferences are not useful at this point and can make the regular expression more time consuming\n * and resource hungry. This is why they are replaced with the grouping parenthesis.\n * Eg: (value) changes in (?:value)\n *\n * Delimiting characters like '^' and '$' are also meaningless in the complete regular expression and\n * need to be removed. Contrariwise, wildcards must be delimited in order to keep the whole regular\n * expression consistent, hence a '?' is added to all the '.*' or '.+' that don't already have one.\n */", "$", "string", "=", "preg_replace", "(", "\"/(?<!\\\\\\\\)\\\\((?!\\\\?)/\"", ",", "'(?:'", ",", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "\"/\\\\.([\\\\*\\\\+])(?!\\\\?)/\"", ",", "'.${1}?'", ",", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "\"/^[\\\\^]/\"", ",", "''", ",", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "\"/[\\\\$]$/\"", ",", "''", ",", "$", "string", ")", ";", "/* The produced regular expression is grouped and associated with its key (this means that the 'preg_match'\n * function will generate an associative array where the key/value association is preserved).\n * If the field is required, the regular expression is completed with a '{1}' (which make it compulsory),\n * otherwise a '?' is added.\n */", "return", "'(?P<'", ".", "$", "key", ".", "'>'", ".", "$", "string", ".", "')'", ".", "(", "(", "$", "field_required", ")", "?", "'{1}'", ":", "'?'", ")", ";", "}" ]
This method read a single parameter and build the regular expression
[ "This", "method", "read", "a", "single", "parameter", "and", "build", "the", "regular", "expression" ]
5093297dcb7441a8d8f79cbb2429c93232e16d1c
https://github.com/comodojo/dispatcher.framework/blob/5093297dcb7441a8d8f79cbb2429c93232e16d1c/src/Comodojo/Dispatcher/Router/Parser.php#L125-L163
16,219
bfitech/zapcore
dev/RouterDev.php
RouterDev.reset
public static function reset() { $_SERVER['REQUEST_URI'] = '/'; $_SERVER['REQUEST_METHOD'] = 'GET'; $_GET = $_POST = $_FILES = $_REQUEST = []; self::$code = 200; self::$head = []; self::$body_raw = null; self::$body = null; self::$errno = 0; self::$data = []; }
php
public static function reset() { $_SERVER['REQUEST_URI'] = '/'; $_SERVER['REQUEST_METHOD'] = 'GET'; $_GET = $_POST = $_FILES = $_REQUEST = []; self::$code = 200; self::$head = []; self::$body_raw = null; self::$body = null; self::$errno = 0; self::$data = []; }
[ "public", "static", "function", "reset", "(", ")", "{", "$", "_SERVER", "[", "'REQUEST_URI'", "]", "=", "'/'", ";", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", "=", "'GET'", ";", "$", "_GET", "=", "$", "_POST", "=", "$", "_FILES", "=", "$", "_REQUEST", "=", "[", "]", ";", "self", "::", "$", "code", "=", "200", ";", "self", "::", "$", "head", "=", "[", "]", ";", "self", "::", "$", "body_raw", "=", "null", ";", "self", "::", "$", "body", "=", "null", ";", "self", "::", "$", "errno", "=", "0", ";", "self", "::", "$", "data", "=", "[", "]", ";", "}" ]
Reset fake HTTP variables and properties.
[ "Reset", "fake", "HTTP", "variables", "and", "properties", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/dev/RouterDev.php#L35-L45
16,220
bfitech/zapcore
dev/RouterDev.php
RouterDev.override_callback_args
public function override_callback_args(array $args=[]) { foreach ($args as $key => $val) { if (!in_array($key, [ 'get', 'post', 'files', 'put', 'patch', 'delete', ])) continue; self::$override_args[$key] = $val; } }
php
public function override_callback_args(array $args=[]) { foreach ($args as $key => $val) { if (!in_array($key, [ 'get', 'post', 'files', 'put', 'patch', 'delete', ])) continue; self::$override_args[$key] = $val; } }
[ "public", "function", "override_callback_args", "(", "array", "$", "args", "=", "[", "]", ")", "{", "foreach", "(", "$", "args", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "!", "in_array", "(", "$", "key", ",", "[", "'get'", ",", "'post'", ",", "'files'", ",", "'put'", ",", "'patch'", ",", "'delete'", ",", "]", ")", ")", "continue", ";", "self", "::", "$", "override_args", "[", "$", "key", "]", "=", "$", "val", ";", "}", "}" ]
Overrides callback args. Use this in case you want to manipulate collected HTTP variables without actually changing the entire route. @param array $args Dict of HTTP variables for overriding existing args. Key must be one or more of: 'get', 'post', 'files', 'put', 'patch', 'delete'. Invalid keys are ignored.
[ "Overrides", "callback", "args", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/dev/RouterDev.php#L133-L141
16,221
bfitech/zapcore
dev/RouterDev.php
RouterDev.abort_custom
public function abort_custom(int $code) { self::$code = $code; static::$body_raw = "ERROR: $code"; self::$body = "ERROR: $code"; self::$errno = $code; self::$data = []; }
php
public function abort_custom(int $code) { self::$code = $code; static::$body_raw = "ERROR: $code"; self::$body = "ERROR: $code"; self::$errno = $code; self::$data = []; }
[ "public", "function", "abort_custom", "(", "int", "$", "code", ")", "{", "self", "::", "$", "code", "=", "$", "code", ";", "static", "::", "$", "body_raw", "=", "\"ERROR: $code\"", ";", "self", "::", "$", "body", "=", "\"ERROR: $code\"", ";", "self", "::", "$", "errno", "=", "$", "code", ";", "self", "::", "$", "data", "=", "[", "]", ";", "}" ]
Custom abort for testing. @param int $code HTTP error code.
[ "Custom", "abort", "for", "testing", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/dev/RouterDev.php#L148-L154
16,222
bfitech/zapcore
dev/RouterDev.php
RouterDev.redirect_custom
public function redirect_custom(string $url) { self::$code = 301; self::$head = ["Location: $url"]; self::$body_raw = self::$body = "Location: $url"; self::$errno = 0; self::$data = [$url]; }
php
public function redirect_custom(string $url) { self::$code = 301; self::$head = ["Location: $url"]; self::$body_raw = self::$body = "Location: $url"; self::$errno = 0; self::$data = [$url]; }
[ "public", "function", "redirect_custom", "(", "string", "$", "url", ")", "{", "self", "::", "$", "code", "=", "301", ";", "self", "::", "$", "head", "=", "[", "\"Location: $url\"", "]", ";", "self", "::", "$", "body_raw", "=", "self", "::", "$", "body", "=", "\"Location: $url\"", ";", "self", "::", "$", "errno", "=", "0", ";", "self", "::", "$", "data", "=", "[", "$", "url", "]", ";", "}" ]
Custom redirect for testing. @param string $url Destination URL.
[ "Custom", "redirect", "for", "testing", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/dev/RouterDev.php#L161-L167
16,223
bfitech/zapcore
dev/RouterDev.php
RouterDev.static_file_custom
public function static_file_custom( string $path, int $cache=0, $disposition=null ) { self::reset(); if (file_exists($path)) { self::$code = 200; self::$body_raw = file_get_contents($path); self::$body = "Path: $path"; self::$errno = 0; self::$data = [$path]; } else { self::$code = 404; } }
php
public function static_file_custom( string $path, int $cache=0, $disposition=null ) { self::reset(); if (file_exists($path)) { self::$code = 200; self::$body_raw = file_get_contents($path); self::$body = "Path: $path"; self::$errno = 0; self::$data = [$path]; } else { self::$code = 404; } }
[ "public", "function", "static_file_custom", "(", "string", "$", "path", ",", "int", "$", "cache", "=", "0", ",", "$", "disposition", "=", "null", ")", "{", "self", "::", "reset", "(", ")", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "self", "::", "$", "code", "=", "200", ";", "self", "::", "$", "body_raw", "=", "file_get_contents", "(", "$", "path", ")", ";", "self", "::", "$", "body", "=", "\"Path: $path\"", ";", "self", "::", "$", "errno", "=", "0", ";", "self", "::", "$", "data", "=", "[", "$", "path", "]", ";", "}", "else", "{", "self", "::", "$", "code", "=", "404", ";", "}", "}" ]
Custom static file serving for testing. @param string $path Absolute path to file. @param int $cache Cache age in seconds. @param mixed $disposition If string, use it as content-disposition in header. If true, infer from basename. If null, no content-disposition header is sent. @cond @SuppressWarnings(PHPMD.UnusedFormalParameter) @endcond
[ "Custom", "static", "file", "serving", "for", "testing", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/dev/RouterDev.php#L182-L195
16,224
comodojo/dispatcher.framework
src/Comodojo/Dispatcher/Router/Table.php
Table.registerRoute
private function registerRoute($folders, $type, $class = null, array $parameters = []) { // The values associated with a route are as follows: // $route = new Route($this->router); $route = new Route(); $this->updateRoute($route, $type, $class, $parameters); // $route->setType($type) // Type of route // ->setClassName($class) // Class to be invoked // ->setParameters($parameters); // Parameters passed via the composer.json configuration (cache, ttl, etc...) $this->logger->debug("Route table - route: ".implode("/", $folders)); // This method generate a global regular expression which will be able to match all the URI supported by the route $regex = $this->parser->read($folders, $route); $this->logger->debug("Route table - route regex: $regex"); $this->routes = array_merge($this->routes, [$regex => $route]); }
php
private function registerRoute($folders, $type, $class = null, array $parameters = []) { // The values associated with a route are as follows: // $route = new Route($this->router); $route = new Route(); $this->updateRoute($route, $type, $class, $parameters); // $route->setType($type) // Type of route // ->setClassName($class) // Class to be invoked // ->setParameters($parameters); // Parameters passed via the composer.json configuration (cache, ttl, etc...) $this->logger->debug("Route table - route: ".implode("/", $folders)); // This method generate a global regular expression which will be able to match all the URI supported by the route $regex = $this->parser->read($folders, $route); $this->logger->debug("Route table - route regex: $regex"); $this->routes = array_merge($this->routes, [$regex => $route]); }
[ "private", "function", "registerRoute", "(", "$", "folders", ",", "$", "type", ",", "$", "class", "=", "null", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "// The values associated with a route are as follows:", "// $route = new Route($this->router);", "$", "route", "=", "new", "Route", "(", ")", ";", "$", "this", "->", "updateRoute", "(", "$", "route", ",", "$", "type", ",", "$", "class", ",", "$", "parameters", ")", ";", "// $route->setType($type) // Type of route", "// ->setClassName($class) // Class to be invoked", "// ->setParameters($parameters); // Parameters passed via the composer.json configuration (cache, ttl, etc...)", "$", "this", "->", "logger", "->", "debug", "(", "\"Route table - route: \"", ".", "implode", "(", "\"/\"", ",", "$", "folders", ")", ")", ";", "// This method generate a global regular expression which will be able to match all the URI supported by the route", "$", "regex", "=", "$", "this", "->", "parser", "->", "read", "(", "$", "folders", ",", "$", "route", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "\"Route table - route regex: $regex\"", ")", ";", "$", "this", "->", "routes", "=", "array_merge", "(", "$", "this", "->", "routes", ",", "[", "$", "regex", "=>", "$", "route", "]", ")", ";", "}" ]
This method add a route to the supported list
[ "This", "method", "add", "a", "route", "to", "the", "supported", "list" ]
5093297dcb7441a8d8f79cbb2429c93232e16d1c
https://github.com/comodojo/dispatcher.framework/blob/5093297dcb7441a8d8f79cbb2429c93232e16d1c/src/Comodojo/Dispatcher/Router/Table.php#L206-L227
16,225
bolt/configuration-notices
src/EventListener/ConfigurationNoticesListener.php
ConfigurationNoticesListener.mailConfigCheck
protected function mailConfigCheck() { if (!$this->app['config']->get('general/mailoptions') && $this->app['users']->getCurrentuser() && $this->app['users']->isAllowed('files:config')) { $notice = json_encode([ 'severity' => 1, 'notice' => 'The <strong>mail configuration parameters</strong> have not been set up. This may interfere with password resets, and extension functionality. Please set up the <code>mailoptions</code> in <code>config.yml</code>.', ]); $this->app['logger.flash']->configuration($notice); } }
php
protected function mailConfigCheck() { if (!$this->app['config']->get('general/mailoptions') && $this->app['users']->getCurrentuser() && $this->app['users']->isAllowed('files:config')) { $notice = json_encode([ 'severity' => 1, 'notice' => 'The <strong>mail configuration parameters</strong> have not been set up. This may interfere with password resets, and extension functionality. Please set up the <code>mailoptions</code> in <code>config.yml</code>.', ]); $this->app['logger.flash']->configuration($notice); } }
[ "protected", "function", "mailConfigCheck", "(", ")", "{", "if", "(", "!", "$", "this", "->", "app", "[", "'config'", "]", "->", "get", "(", "'general/mailoptions'", ")", "&&", "$", "this", "->", "app", "[", "'users'", "]", "->", "getCurrentuser", "(", ")", "&&", "$", "this", "->", "app", "[", "'users'", "]", "->", "isAllowed", "(", "'files:config'", ")", ")", "{", "$", "notice", "=", "json_encode", "(", "[", "'severity'", "=>", "1", ",", "'notice'", "=>", "'The <strong>mail configuration parameters</strong> have not been set up. This may interfere with password resets, and extension functionality. Please set up the <code>mailoptions</code> in <code>config.yml</code>.'", ",", "]", ")", ";", "$", "this", "->", "app", "[", "'logger.flash'", "]", "->", "configuration", "(", "$", "notice", ")", ";", "}", "}" ]
No mail transport has been set. We should gently nudge the user to set the mail configuration. @see https://github.com/bolt/bolt/issues/2908
[ "No", "mail", "transport", "has", "been", "set", ".", "We", "should", "gently", "nudge", "the", "user", "to", "set", "the", "mail", "configuration", "." ]
0e6439f69bf3099bd6ea30288207a3fd2351e404
https://github.com/bolt/configuration-notices/blob/0e6439f69bf3099bd6ea30288207a3fd2351e404/src/EventListener/ConfigurationNoticesListener.php#L93-L102
16,226
bolt/configuration-notices
src/EventListener/ConfigurationNoticesListener.php
ConfigurationNoticesListener.liveCheck
protected function liveCheck(Request $request) { if (!$this->app['debug']) { return; } $host = parse_url($request->getSchemeAndHttpHost()); // If we have an IP-address, we assume it's "dev" if (filter_var($host['host'], FILTER_VALIDATE_IP) !== false) { return; } $domainPartials = (array) $this->app['config']->get('general/debug_local_domains', []); $domainPartials = array_unique(array_merge( (array) $domainPartials, $this->defaultDomainPartials )); foreach ($domainPartials as $partial) { if (strpos($host['host'], $partial) !== false) { return; } } $notice = json_encode([ 'severity' => 2, 'notice' => "It seems like this website is running on a <strong>non-development environment</strong>, while 'debug' is enabled. Make sure debug is disabled in production environments. If you don't do this, it will result in an extremely large <code>app/cache</code> folder and a measurable reduced performance across all pages.", 'info' => "If you wish to hide this message, add a key to your <code>config.yml</code> with a (partial) domain name in it, that should be seen as a development environment: <code>debug_local_domains: [ '.foo' ]</code>.", ]); $this->app['logger.flash']->configuration($notice); }
php
protected function liveCheck(Request $request) { if (!$this->app['debug']) { return; } $host = parse_url($request->getSchemeAndHttpHost()); // If we have an IP-address, we assume it's "dev" if (filter_var($host['host'], FILTER_VALIDATE_IP) !== false) { return; } $domainPartials = (array) $this->app['config']->get('general/debug_local_domains', []); $domainPartials = array_unique(array_merge( (array) $domainPartials, $this->defaultDomainPartials )); foreach ($domainPartials as $partial) { if (strpos($host['host'], $partial) !== false) { return; } } $notice = json_encode([ 'severity' => 2, 'notice' => "It seems like this website is running on a <strong>non-development environment</strong>, while 'debug' is enabled. Make sure debug is disabled in production environments. If you don't do this, it will result in an extremely large <code>app/cache</code> folder and a measurable reduced performance across all pages.", 'info' => "If you wish to hide this message, add a key to your <code>config.yml</code> with a (partial) domain name in it, that should be seen as a development environment: <code>debug_local_domains: [ '.foo' ]</code>.", ]); $this->app['logger.flash']->configuration($notice); }
[ "protected", "function", "liveCheck", "(", "Request", "$", "request", ")", "{", "if", "(", "!", "$", "this", "->", "app", "[", "'debug'", "]", ")", "{", "return", ";", "}", "$", "host", "=", "parse_url", "(", "$", "request", "->", "getSchemeAndHttpHost", "(", ")", ")", ";", "// If we have an IP-address, we assume it's \"dev\"", "if", "(", "filter_var", "(", "$", "host", "[", "'host'", "]", ",", "FILTER_VALIDATE_IP", ")", "!==", "false", ")", "{", "return", ";", "}", "$", "domainPartials", "=", "(", "array", ")", "$", "this", "->", "app", "[", "'config'", "]", "->", "get", "(", "'general/debug_local_domains'", ",", "[", "]", ")", ";", "$", "domainPartials", "=", "array_unique", "(", "array_merge", "(", "(", "array", ")", "$", "domainPartials", ",", "$", "this", "->", "defaultDomainPartials", ")", ")", ";", "foreach", "(", "$", "domainPartials", "as", "$", "partial", ")", "{", "if", "(", "strpos", "(", "$", "host", "[", "'host'", "]", ",", "$", "partial", ")", "!==", "false", ")", "{", "return", ";", "}", "}", "$", "notice", "=", "json_encode", "(", "[", "'severity'", "=>", "2", ",", "'notice'", "=>", "\"It seems like this website is running on a <strong>non-development environment</strong>, while 'debug' is enabled. Make sure debug is disabled in production environments. If you don't do this, it will result in an extremely large <code>app/cache</code> folder and a measurable reduced performance across all pages.\"", ",", "'info'", "=>", "\"If you wish to hide this message, add a key to your <code>config.yml</code> with a (partial) domain name in it, that should be seen as a development environment: <code>debug_local_domains: [ '.foo' ]</code>.\"", ",", "]", ")", ";", "$", "this", "->", "app", "[", "'logger.flash'", "]", "->", "configuration", "(", "$", "notice", ")", ";", "}" ]
Check whether the site is live or not.
[ "Check", "whether", "the", "site", "is", "live", "or", "not", "." ]
0e6439f69bf3099bd6ea30288207a3fd2351e404
https://github.com/bolt/configuration-notices/blob/0e6439f69bf3099bd6ea30288207a3fd2351e404/src/EventListener/ConfigurationNoticesListener.php#L121-L154
16,227
bolt/configuration-notices
src/EventListener/ConfigurationNoticesListener.php
ConfigurationNoticesListener.writableFolderCheck
protected function writableFolderCheck() { $fileName = '/configtester_' . date('Y-m-d-h-i-s') . '.txt'; $fileSystems = [ ['name' => 'files', 'folder' => '', 'label' => '<code>files/</code> in the webroot'], ['name' => 'extensions', 'folder' => '', 'label' => '<code>extensions/</code> in the webroot'], ['name' => 'config', 'folder' => ''], ['name' => 'cache', 'folder' => ''], ]; if ($this->app['config']->get('general/database/driver') === 'pdo_sqlite') { $fileSystems[] = ['name' => 'app', 'folder' => 'database']; } $fileSystems = Bag::fromRecursive($fileSystems); foreach ($fileSystems as $fileSystem) { $contents = $this->isWritable($fileSystem, $fileName); if ($contents != 'ok') { $folderName = $this->getFoldername($fileSystem); $notice = json_encode([ 'severity' => 1, 'notice' => 'Bolt needs to be able to <strong>write files to</strong> the folder <code>' . $folderName . "</code>, but it doesn't seem to be writable.", 'info' => 'Make sure the folder exists, and is writable to the webserver.', ]); $this->app['logger.flash']->configuration($notice); } } }
php
protected function writableFolderCheck() { $fileName = '/configtester_' . date('Y-m-d-h-i-s') . '.txt'; $fileSystems = [ ['name' => 'files', 'folder' => '', 'label' => '<code>files/</code> in the webroot'], ['name' => 'extensions', 'folder' => '', 'label' => '<code>extensions/</code> in the webroot'], ['name' => 'config', 'folder' => ''], ['name' => 'cache', 'folder' => ''], ]; if ($this->app['config']->get('general/database/driver') === 'pdo_sqlite') { $fileSystems[] = ['name' => 'app', 'folder' => 'database']; } $fileSystems = Bag::fromRecursive($fileSystems); foreach ($fileSystems as $fileSystem) { $contents = $this->isWritable($fileSystem, $fileName); if ($contents != 'ok') { $folderName = $this->getFoldername($fileSystem); $notice = json_encode([ 'severity' => 1, 'notice' => 'Bolt needs to be able to <strong>write files to</strong> the folder <code>' . $folderName . "</code>, but it doesn't seem to be writable.", 'info' => 'Make sure the folder exists, and is writable to the webserver.', ]); $this->app['logger.flash']->configuration($notice); } } }
[ "protected", "function", "writableFolderCheck", "(", ")", "{", "$", "fileName", "=", "'/configtester_'", ".", "date", "(", "'Y-m-d-h-i-s'", ")", ".", "'.txt'", ";", "$", "fileSystems", "=", "[", "[", "'name'", "=>", "'files'", ",", "'folder'", "=>", "''", ",", "'label'", "=>", "'<code>files/</code> in the webroot'", "]", ",", "[", "'name'", "=>", "'extensions'", ",", "'folder'", "=>", "''", ",", "'label'", "=>", "'<code>extensions/</code> in the webroot'", "]", ",", "[", "'name'", "=>", "'config'", ",", "'folder'", "=>", "''", "]", ",", "[", "'name'", "=>", "'cache'", ",", "'folder'", "=>", "''", "]", ",", "]", ";", "if", "(", "$", "this", "->", "app", "[", "'config'", "]", "->", "get", "(", "'general/database/driver'", ")", "===", "'pdo_sqlite'", ")", "{", "$", "fileSystems", "[", "]", "=", "[", "'name'", "=>", "'app'", ",", "'folder'", "=>", "'database'", "]", ";", "}", "$", "fileSystems", "=", "Bag", "::", "fromRecursive", "(", "$", "fileSystems", ")", ";", "foreach", "(", "$", "fileSystems", "as", "$", "fileSystem", ")", "{", "$", "contents", "=", "$", "this", "->", "isWritable", "(", "$", "fileSystem", ",", "$", "fileName", ")", ";", "if", "(", "$", "contents", "!=", "'ok'", ")", "{", "$", "folderName", "=", "$", "this", "->", "getFoldername", "(", "$", "fileSystem", ")", ";", "$", "notice", "=", "json_encode", "(", "[", "'severity'", "=>", "1", ",", "'notice'", "=>", "'Bolt needs to be able to <strong>write files to</strong> the folder <code>'", ".", "$", "folderName", ".", "\"</code>, but it doesn't seem to be writable.\"", ",", "'info'", "=>", "'Make sure the folder exists, and is writable to the webserver.'", ",", "]", ")", ";", "$", "this", "->", "app", "[", "'logger.flash'", "]", "->", "configuration", "(", "$", "notice", ")", ";", "}", "}", "}" ]
Check if some common file locations are writable.
[ "Check", "if", "some", "common", "file", "locations", "are", "writable", "." ]
0e6439f69bf3099bd6ea30288207a3fd2351e404
https://github.com/bolt/configuration-notices/blob/0e6439f69bf3099bd6ea30288207a3fd2351e404/src/EventListener/ConfigurationNoticesListener.php#L242-L269
16,228
bolt/configuration-notices
src/EventListener/ConfigurationNoticesListener.php
ConfigurationNoticesListener.canonicalCheck
protected function canonicalCheck(Request $request) { $hostname = strtok($request->getUri(), '?'); $canonical = strtok($this->app['canonical']->getUrl()); if (!empty($canonical) && ($hostname != $canonical)) { $notice = json_encode([ 'severity' => 1, 'notice' => "The <code>canonical hostname</code> is set to <code>$canonical</code> in <code>config.yml</code>, but you are currently logged in using another hostname. This might cause issues with uploaded files, or links inserted in the content.", 'info' => sprintf( "Log in on Bolt using the proper URL: <code><a href='%s'>%s</a></code>.", $this->app['canonical']->getUrl(), $this->app['canonical']->getUrl() ), ]); $this->app['logger.flash']->configuration($notice); } }
php
protected function canonicalCheck(Request $request) { $hostname = strtok($request->getUri(), '?'); $canonical = strtok($this->app['canonical']->getUrl()); if (!empty($canonical) && ($hostname != $canonical)) { $notice = json_encode([ 'severity' => 1, 'notice' => "The <code>canonical hostname</code> is set to <code>$canonical</code> in <code>config.yml</code>, but you are currently logged in using another hostname. This might cause issues with uploaded files, or links inserted in the content.", 'info' => sprintf( "Log in on Bolt using the proper URL: <code><a href='%s'>%s</a></code>.", $this->app['canonical']->getUrl(), $this->app['canonical']->getUrl() ), ]); $this->app['logger.flash']->configuration($notice); } }
[ "protected", "function", "canonicalCheck", "(", "Request", "$", "request", ")", "{", "$", "hostname", "=", "strtok", "(", "$", "request", "->", "getUri", "(", ")", ",", "'?'", ")", ";", "$", "canonical", "=", "strtok", "(", "$", "this", "->", "app", "[", "'canonical'", "]", "->", "getUrl", "(", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "canonical", ")", "&&", "(", "$", "hostname", "!=", "$", "canonical", ")", ")", "{", "$", "notice", "=", "json_encode", "(", "[", "'severity'", "=>", "1", ",", "'notice'", "=>", "\"The <code>canonical hostname</code> is set to <code>$canonical</code> in <code>config.yml</code>, but you are currently logged in using another hostname. This might cause issues with uploaded files, or links inserted in the content.\"", ",", "'info'", "=>", "sprintf", "(", "\"Log in on Bolt using the proper URL: <code><a href='%s'>%s</a></code>.\"", ",", "$", "this", "->", "app", "[", "'canonical'", "]", "->", "getUrl", "(", ")", ",", "$", "this", "->", "app", "[", "'canonical'", "]", "->", "getUrl", "(", ")", ")", ",", "]", ")", ";", "$", "this", "->", "app", "[", "'logger.flash'", "]", "->", "configuration", "(", "$", "notice", ")", ";", "}", "}" ]
Check if the current url matches the canonical. @param Request $request
[ "Check", "if", "the", "current", "url", "matches", "the", "canonical", "." ]
0e6439f69bf3099bd6ea30288207a3fd2351e404
https://github.com/bolt/configuration-notices/blob/0e6439f69bf3099bd6ea30288207a3fd2351e404/src/EventListener/ConfigurationNoticesListener.php#L297-L314
16,229
bolt/configuration-notices
src/EventListener/ConfigurationNoticesListener.php
ConfigurationNoticesListener.maintenanceCheck
protected function maintenanceCheck() { if ($this->app['config']->get('general/maintenance_mode', false)) { $notice = json_encode([ 'severity' => 1, 'notice' => "Bolt's <strong>maintenance mode</strong> is enabled. This means that non-authenticated users will not be able to see the website.", 'info' => 'To make the site available to the general public again, set <code>maintenance_mode: false</code> in your <code>config.yml</code> file.', ]); $this->app['logger.flash']->configuration($notice); } }
php
protected function maintenanceCheck() { if ($this->app['config']->get('general/maintenance_mode', false)) { $notice = json_encode([ 'severity' => 1, 'notice' => "Bolt's <strong>maintenance mode</strong> is enabled. This means that non-authenticated users will not be able to see the website.", 'info' => 'To make the site available to the general public again, set <code>maintenance_mode: false</code> in your <code>config.yml</code> file.', ]); $this->app['logger.flash']->configuration($notice); } }
[ "protected", "function", "maintenanceCheck", "(", ")", "{", "if", "(", "$", "this", "->", "app", "[", "'config'", "]", "->", "get", "(", "'general/maintenance_mode'", ",", "false", ")", ")", "{", "$", "notice", "=", "json_encode", "(", "[", "'severity'", "=>", "1", ",", "'notice'", "=>", "\"Bolt's <strong>maintenance mode</strong> is enabled. This means that non-authenticated users will not be able to see the website.\"", ",", "'info'", "=>", "'To make the site available to the general public again, set <code>maintenance_mode: false</code> in your <code>config.yml</code> file.'", ",", "]", ")", ";", "$", "this", "->", "app", "[", "'logger.flash'", "]", "->", "configuration", "(", "$", "notice", ")", ";", "}", "}" ]
If the site is in maintenance mode, show this on the dashboard.
[ "If", "the", "site", "is", "in", "maintenance", "mode", "show", "this", "on", "the", "dashboard", "." ]
0e6439f69bf3099bd6ea30288207a3fd2351e404
https://github.com/bolt/configuration-notices/blob/0e6439f69bf3099bd6ea30288207a3fd2351e404/src/EventListener/ConfigurationNoticesListener.php#L352-L362
16,230
bolt/configuration-notices
src/EventListener/ConfigurationNoticesListener.php
ConfigurationNoticesListener.changelogCheck
protected function changelogCheck() { if (!$this->app['config']->get('general/changelog/enabled', false)) { return; } // Get the number of items in the changelog $count = $this->app['storage']->getRepository(LogChange::class)->count(); if ($count > $this->logThreshold) { $message = sprintf( "Bolt's <strong>changelog</strong> is enabled, and there are more than %s rows in the table.", $this->logThreshold ); $info = sprintf( "Be sure to clean it up periodically, using a Cron job or on the <a href='%s'>Changelog page</a>.", $this->app['url_generator']->generate('changelog') ); $notice = json_encode([ 'severity' => 1, 'notice' => $message, 'info' => $info, ]); $this->app['logger.flash']->configuration($notice); } }
php
protected function changelogCheck() { if (!$this->app['config']->get('general/changelog/enabled', false)) { return; } // Get the number of items in the changelog $count = $this->app['storage']->getRepository(LogChange::class)->count(); if ($count > $this->logThreshold) { $message = sprintf( "Bolt's <strong>changelog</strong> is enabled, and there are more than %s rows in the table.", $this->logThreshold ); $info = sprintf( "Be sure to clean it up periodically, using a Cron job or on the <a href='%s'>Changelog page</a>.", $this->app['url_generator']->generate('changelog') ); $notice = json_encode([ 'severity' => 1, 'notice' => $message, 'info' => $info, ]); $this->app['logger.flash']->configuration($notice); } }
[ "protected", "function", "changelogCheck", "(", ")", "{", "if", "(", "!", "$", "this", "->", "app", "[", "'config'", "]", "->", "get", "(", "'general/changelog/enabled'", ",", "false", ")", ")", "{", "return", ";", "}", "// Get the number of items in the changelog", "$", "count", "=", "$", "this", "->", "app", "[", "'storage'", "]", "->", "getRepository", "(", "LogChange", "::", "class", ")", "->", "count", "(", ")", ";", "if", "(", "$", "count", ">", "$", "this", "->", "logThreshold", ")", "{", "$", "message", "=", "sprintf", "(", "\"Bolt's <strong>changelog</strong> is enabled, and there are more than %s rows in the table.\"", ",", "$", "this", "->", "logThreshold", ")", ";", "$", "info", "=", "sprintf", "(", "\"Be sure to clean it up periodically, using a Cron job or on the <a href='%s'>Changelog page</a>.\"", ",", "$", "this", "->", "app", "[", "'url_generator'", "]", "->", "generate", "(", "'changelog'", ")", ")", ";", "$", "notice", "=", "json_encode", "(", "[", "'severity'", "=>", "1", ",", "'notice'", "=>", "$", "message", ",", "'info'", "=>", "$", "info", ",", "]", ")", ";", "$", "this", "->", "app", "[", "'logger.flash'", "]", "->", "configuration", "(", "$", "notice", ")", ";", "}", "}" ]
Check if Changelog is enabled, and if doesn't contain too many rows.
[ "Check", "if", "Changelog", "is", "enabled", "and", "if", "doesn", "t", "contain", "too", "many", "rows", "." ]
0e6439f69bf3099bd6ea30288207a3fd2351e404
https://github.com/bolt/configuration-notices/blob/0e6439f69bf3099bd6ea30288207a3fd2351e404/src/EventListener/ConfigurationNoticesListener.php#L367-L392
16,231
bolt/configuration-notices
src/EventListener/ConfigurationNoticesListener.php
ConfigurationNoticesListener.systemlogCheck
protected function systemlogCheck() { // Get the number of items in the changelog $count = $this->app['storage']->getRepository(LogSystem::class)->count(); if ($count > $this->logThreshold) { $message = sprintf( "Bolt's <strong>systemlog</strong> is enabled, and there are more than %s rows in the table.", $this->logThreshold ); $info = sprintf( "Be sure to clean it up periodically, using a Cron job or on the <a href='%s'>Systemlog page</a>.", $this->app['url_generator']->generate('systemlog') ); $notice = json_encode([ 'severity' => 1, 'notice' => $message, 'info' => $info, ]); $this->app['logger.flash']->configuration($notice); } }
php
protected function systemlogCheck() { // Get the number of items in the changelog $count = $this->app['storage']->getRepository(LogSystem::class)->count(); if ($count > $this->logThreshold) { $message = sprintf( "Bolt's <strong>systemlog</strong> is enabled, and there are more than %s rows in the table.", $this->logThreshold ); $info = sprintf( "Be sure to clean it up periodically, using a Cron job or on the <a href='%s'>Systemlog page</a>.", $this->app['url_generator']->generate('systemlog') ); $notice = json_encode([ 'severity' => 1, 'notice' => $message, 'info' => $info, ]); $this->app['logger.flash']->configuration($notice); } }
[ "protected", "function", "systemlogCheck", "(", ")", "{", "// Get the number of items in the changelog", "$", "count", "=", "$", "this", "->", "app", "[", "'storage'", "]", "->", "getRepository", "(", "LogSystem", "::", "class", ")", "->", "count", "(", ")", ";", "if", "(", "$", "count", ">", "$", "this", "->", "logThreshold", ")", "{", "$", "message", "=", "sprintf", "(", "\"Bolt's <strong>systemlog</strong> is enabled, and there are more than %s rows in the table.\"", ",", "$", "this", "->", "logThreshold", ")", ";", "$", "info", "=", "sprintf", "(", "\"Be sure to clean it up periodically, using a Cron job or on the <a href='%s'>Systemlog page</a>.\"", ",", "$", "this", "->", "app", "[", "'url_generator'", "]", "->", "generate", "(", "'systemlog'", ")", ")", ";", "$", "notice", "=", "json_encode", "(", "[", "'severity'", "=>", "1", ",", "'notice'", "=>", "$", "message", ",", "'info'", "=>", "$", "info", ",", "]", ")", ";", "$", "this", "->", "app", "[", "'logger.flash'", "]", "->", "configuration", "(", "$", "notice", ")", ";", "}", "}" ]
Check if systemlog doesn't contain too many rows.
[ "Check", "if", "systemlog", "doesn", "t", "contain", "too", "many", "rows", "." ]
0e6439f69bf3099bd6ea30288207a3fd2351e404
https://github.com/bolt/configuration-notices/blob/0e6439f69bf3099bd6ea30288207a3fd2351e404/src/EventListener/ConfigurationNoticesListener.php#L397-L418
16,232
bolt/configuration-notices
src/EventListener/ConfigurationNoticesListener.php
ConfigurationNoticesListener.thumbnailConfigCheck
protected function thumbnailConfigCheck() { $thumbConfig = $this->app['config']->get('general/thumbnails'); if ((strpos($thumbConfig['notfound_image'] . $thumbConfig['error_image'], '://') === false)) { $notice = json_encode([ 'severity' => 1, 'notice' => 'Your configuration settings for <code>thumbnails/notfound_image</code> or <code>thumbnails/error_image</code> contain a value that needs to be updated.', 'info' => 'Update the value with a namespace, for example: <code>bolt_assets://img/default_notfound.png</code>.', ]); $this->app['logger.flash']->configuration($notice); } }
php
protected function thumbnailConfigCheck() { $thumbConfig = $this->app['config']->get('general/thumbnails'); if ((strpos($thumbConfig['notfound_image'] . $thumbConfig['error_image'], '://') === false)) { $notice = json_encode([ 'severity' => 1, 'notice' => 'Your configuration settings for <code>thumbnails/notfound_image</code> or <code>thumbnails/error_image</code> contain a value that needs to be updated.', 'info' => 'Update the value with a namespace, for example: <code>bolt_assets://img/default_notfound.png</code>.', ]); $this->app['logger.flash']->configuration($notice); } }
[ "protected", "function", "thumbnailConfigCheck", "(", ")", "{", "$", "thumbConfig", "=", "$", "this", "->", "app", "[", "'config'", "]", "->", "get", "(", "'general/thumbnails'", ")", ";", "if", "(", "(", "strpos", "(", "$", "thumbConfig", "[", "'notfound_image'", "]", ".", "$", "thumbConfig", "[", "'error_image'", "]", ",", "'://'", ")", "===", "false", ")", ")", "{", "$", "notice", "=", "json_encode", "(", "[", "'severity'", "=>", "1", ",", "'notice'", "=>", "'Your configuration settings for <code>thumbnails/notfound_image</code> or <code>thumbnails/error_image</code> contain a value that needs to be updated.'", ",", "'info'", "=>", "'Update the value with a namespace, for example: <code>bolt_assets://img/default_notfound.png</code>.'", ",", "]", ")", ";", "$", "this", "->", "app", "[", "'logger.flash'", "]", "->", "configuration", "(", "$", "notice", ")", ";", "}", "}" ]
Check if the thumbnail config has been updated for 3.3+ .
[ "Check", "if", "the", "thumbnail", "config", "has", "been", "updated", "for", "3", ".", "3", "+", "." ]
0e6439f69bf3099bd6ea30288207a3fd2351e404
https://github.com/bolt/configuration-notices/blob/0e6439f69bf3099bd6ea30288207a3fd2351e404/src/EventListener/ConfigurationNoticesListener.php#L423-L435
16,233
FrenchFrogs/framework
src/Table/Column/Strainer/Strainer.php
Strainer.setValue
public function setValue($value) { if (isset($this->element)) { $this->element->setValue($value); } return $this; }
php
public function setValue($value) { if (isset($this->element)) { $this->element->setValue($value); } return $this; }
[ "public", "function", "setValue", "(", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "element", ")", ")", "{", "$", "this", "->", "element", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set value to strainer element @param $value @return $this
[ "Set", "value", "to", "strainer", "element" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Column/Strainer/Strainer.php#L148-L156
16,234
PandawanTechnology/neo4j-data-fixtures
src/Loader.php
Loader.loadFromDirectory
public function loadFromDirectory($dir) { if (!is_dir($dir)) { throw new \InvalidArgumentException(sprintf('"%s" does not exist', $dir)); } $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY ); return $this->loadFromIterator($iterator); }
php
public function loadFromDirectory($dir) { if (!is_dir($dir)) { throw new \InvalidArgumentException(sprintf('"%s" does not exist', $dir)); } $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY ); return $this->loadFromIterator($iterator); }
[ "public", "function", "loadFromDirectory", "(", "$", "dir", ")", "{", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'\"%s\" does not exist'", ",", "$", "dir", ")", ")", ";", "}", "$", "iterator", "=", "new", "\\", "RecursiveIteratorIterator", "(", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "dir", ",", "\\", "RecursiveDirectoryIterator", "::", "SKIP_DOTS", ")", ",", "\\", "RecursiveIteratorIterator", "::", "LEAVES_ONLY", ")", ";", "return", "$", "this", "->", "loadFromIterator", "(", "$", "iterator", ")", ";", "}" ]
Find fixtures classes in a given directory and load them. @param string $dir Directory to find fixture classes in. @return array $fixtures Array of loaded fixture object instances.
[ "Find", "fixtures", "classes", "in", "a", "given", "directory", "and", "load", "them", "." ]
58701f30f3de9c848308623c5e773aada106a2aa
https://github.com/PandawanTechnology/neo4j-data-fixtures/blob/58701f30f3de9c848308623c5e773aada106a2aa/src/Loader.php#L36-L48
16,235
PandawanTechnology/neo4j-data-fixtures
src/Loader.php
Loader.isTransient
public function isTransient($className) { $rc = new \ReflectionClass($className); if ($rc->isAbstract()) { return true; } $interfaces = class_implements($className); return !in_array('PandawanTechnology\Neo4jDataFixtures\Neo4jFixtureInterface', $interfaces); }
php
public function isTransient($className) { $rc = new \ReflectionClass($className); if ($rc->isAbstract()) { return true; } $interfaces = class_implements($className); return !in_array('PandawanTechnology\Neo4jDataFixtures\Neo4jFixtureInterface', $interfaces); }
[ "public", "function", "isTransient", "(", "$", "className", ")", "{", "$", "rc", "=", "new", "\\", "ReflectionClass", "(", "$", "className", ")", ";", "if", "(", "$", "rc", "->", "isAbstract", "(", ")", ")", "{", "return", "true", ";", "}", "$", "interfaces", "=", "class_implements", "(", "$", "className", ")", ";", "return", "!", "in_array", "(", "'PandawanTechnology\\Neo4jDataFixtures\\Neo4jFixtureInterface'", ",", "$", "interfaces", ")", ";", "}" ]
Check if a given fixture is transient and should not be considered a data fixtures class. @param string $className @return bool
[ "Check", "if", "a", "given", "fixture", "is", "transient", "and", "should", "not", "be", "considered", "a", "data", "fixtures", "class", "." ]
58701f30f3de9c848308623c5e773aada106a2aa
https://github.com/PandawanTechnology/neo4j-data-fixtures/blob/58701f30f3de9c848308623c5e773aada106a2aa/src/Loader.php#L134-L145
16,236
PandawanTechnology/neo4j-data-fixtures
src/Loader.php
Loader.loadFromIterator
private function loadFromIterator(\Iterator $iterator) { $includedFiles = []; foreach ($iterator as $file) { if (($fileName = $file->getBasename($this->fileExtension)) == $file->getBasename()) { continue; } $sourceFile = realpath($file->getPathName()); require_once $sourceFile; $includedFiles[] = $sourceFile; } $fixtures = []; $declared = get_declared_classes(); foreach ($declared as $className) { $reflClass = new \ReflectionClass($className); $sourceFile = $reflClass->getFileName(); if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) { $fixture = new $className(); $fixtures[] = $fixture; $this->addFixture($fixture); } } return $fixtures; }
php
private function loadFromIterator(\Iterator $iterator) { $includedFiles = []; foreach ($iterator as $file) { if (($fileName = $file->getBasename($this->fileExtension)) == $file->getBasename()) { continue; } $sourceFile = realpath($file->getPathName()); require_once $sourceFile; $includedFiles[] = $sourceFile; } $fixtures = []; $declared = get_declared_classes(); foreach ($declared as $className) { $reflClass = new \ReflectionClass($className); $sourceFile = $reflClass->getFileName(); if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) { $fixture = new $className(); $fixtures[] = $fixture; $this->addFixture($fixture); } } return $fixtures; }
[ "private", "function", "loadFromIterator", "(", "\\", "Iterator", "$", "iterator", ")", "{", "$", "includedFiles", "=", "[", "]", ";", "foreach", "(", "$", "iterator", "as", "$", "file", ")", "{", "if", "(", "(", "$", "fileName", "=", "$", "file", "->", "getBasename", "(", "$", "this", "->", "fileExtension", ")", ")", "==", "$", "file", "->", "getBasename", "(", ")", ")", "{", "continue", ";", "}", "$", "sourceFile", "=", "realpath", "(", "$", "file", "->", "getPathName", "(", ")", ")", ";", "require_once", "$", "sourceFile", ";", "$", "includedFiles", "[", "]", "=", "$", "sourceFile", ";", "}", "$", "fixtures", "=", "[", "]", ";", "$", "declared", "=", "get_declared_classes", "(", ")", ";", "foreach", "(", "$", "declared", "as", "$", "className", ")", "{", "$", "reflClass", "=", "new", "\\", "ReflectionClass", "(", "$", "className", ")", ";", "$", "sourceFile", "=", "$", "reflClass", "->", "getFileName", "(", ")", ";", "if", "(", "in_array", "(", "$", "sourceFile", ",", "$", "includedFiles", ")", "&&", "!", "$", "this", "->", "isTransient", "(", "$", "className", ")", ")", "{", "$", "fixture", "=", "new", "$", "className", "(", ")", ";", "$", "fixtures", "[", "]", "=", "$", "fixture", ";", "$", "this", "->", "addFixture", "(", "$", "fixture", ")", ";", "}", "}", "return", "$", "fixtures", ";", "}" ]
Load fixtures from files contained in iterator. @param \Iterator $iterator Iterator over files from which fixtures should be loaded. @return Neo4jFixtureInterface[] $fixtures Array of loaded fixture object instances.
[ "Load", "fixtures", "from", "files", "contained", "in", "iterator", "." ]
58701f30f3de9c848308623c5e773aada106a2aa
https://github.com/PandawanTechnology/neo4j-data-fixtures/blob/58701f30f3de9c848308623c5e773aada106a2aa/src/Loader.php#L274-L303
16,237
jkribeiro/composer-hydration
src/Composer/ComposerHydrationHandler.php
ComposerHydrationHandler.toUpperCamelCase
public function toUpperCamelCase($string) { $string = str_replace(array('-', '_'), ' ', $string); $string = ucwords(strtolower($string)); $string = str_replace(' ', '', $string); return $string; }
php
public function toUpperCamelCase($string) { $string = str_replace(array('-', '_'), ' ', $string); $string = ucwords(strtolower($string)); $string = str_replace(' ', '', $string); return $string; }
[ "public", "function", "toUpperCamelCase", "(", "$", "string", ")", "{", "$", "string", "=", "str_replace", "(", "array", "(", "'-'", ",", "'_'", ")", ",", "' '", ",", "$", "string", ")", ";", "$", "string", "=", "ucwords", "(", "strtolower", "(", "$", "string", ")", ")", ";", "$", "string", "=", "str_replace", "(", "' '", ",", "''", ",", "$", "string", ")", ";", "return", "$", "string", ";", "}" ]
Converts a string to upper camel case. @param string $string The string to be converted. @return string An upper camel case string.
[ "Converts", "a", "string", "to", "upper", "camel", "case", "." ]
b0dd7e9c4a966f664c2df08b3067c1b6f263e226
https://github.com/jkribeiro/composer-hydration/blob/b0dd7e9c4a966f664c2df08b3067c1b6f263e226/src/Composer/ComposerHydrationHandler.php#L99-L106
16,238
jkribeiro/composer-hydration
src/Composer/ComposerHydrationHandler.php
ComposerHydrationHandler.getMagicVariableValue
public function getMagicVariableValue($variable) { $base_path_name = basename(realpath(".")); switch ($variable) { case self::MAGIC_VAR_BASENAME: return $base_path_name; break; case self::MAGIC_VAR_UCFIRST_BASENAME: return ucfirst($base_path_name); break; case self::MAGIC_VAR_UPPER_CAMEL_CASE_BASENAME: return $this->toUpperCamelCase($base_path_name); break; case self::MAGIC_VAR_LOWER_CAMEL_CASE_BASENAME: return $this->toLowerCamelCase($base_path_name); break; } return null; }
php
public function getMagicVariableValue($variable) { $base_path_name = basename(realpath(".")); switch ($variable) { case self::MAGIC_VAR_BASENAME: return $base_path_name; break; case self::MAGIC_VAR_UCFIRST_BASENAME: return ucfirst($base_path_name); break; case self::MAGIC_VAR_UPPER_CAMEL_CASE_BASENAME: return $this->toUpperCamelCase($base_path_name); break; case self::MAGIC_VAR_LOWER_CAMEL_CASE_BASENAME: return $this->toLowerCamelCase($base_path_name); break; } return null; }
[ "public", "function", "getMagicVariableValue", "(", "$", "variable", ")", "{", "$", "base_path_name", "=", "basename", "(", "realpath", "(", "\".\"", ")", ")", ";", "switch", "(", "$", "variable", ")", "{", "case", "self", "::", "MAGIC_VAR_BASENAME", ":", "return", "$", "base_path_name", ";", "break", ";", "case", "self", "::", "MAGIC_VAR_UCFIRST_BASENAME", ":", "return", "ucfirst", "(", "$", "base_path_name", ")", ";", "break", ";", "case", "self", "::", "MAGIC_VAR_UPPER_CAMEL_CASE_BASENAME", ":", "return", "$", "this", "->", "toUpperCamelCase", "(", "$", "base_path_name", ")", ";", "break", ";", "case", "self", "::", "MAGIC_VAR_LOWER_CAMEL_CASE_BASENAME", ":", "return", "$", "this", "->", "toLowerCamelCase", "(", "$", "base_path_name", ")", ";", "break", ";", "}", "return", "null", ";", "}" ]
Returns the magic value of a magic variable. @return string The magic value.
[ "Returns", "the", "magic", "value", "of", "a", "magic", "variable", "." ]
b0dd7e9c4a966f664c2df08b3067c1b6f263e226
https://github.com/jkribeiro/composer-hydration/blob/b0dd7e9c4a966f664c2df08b3067c1b6f263e226/src/Composer/ComposerHydrationHandler.php#L130-L153
16,239
jkribeiro/composer-hydration
src/Composer/ComposerHydrationHandler.php
ComposerHydrationHandler.getReplaceValuesFromArgument
public function getReplaceValuesFromArgument($argValues) { $replaceValues = array(); $argValues = explode(',', $argValues); foreach ($argValues as $argValue) { $argValue = explode(':', $argValue); if (count($argValue) != 2) { $msg = 'Command argument "--replace" must follow the format: --replace="{SEARCH}:{REPLACE},..."'; throw new \ErrorException($msg); } $search = trim($argValue[0]); $replace = trim($argValue[1]); if ($this->isMagicVariable($replace)) { // Is magic variable, so, replace by the magic value. $replace = $this->getMagicVariableValue($replace); } $replaceValues[$search] = $replace; } return $replaceValues; }
php
public function getReplaceValuesFromArgument($argValues) { $replaceValues = array(); $argValues = explode(',', $argValues); foreach ($argValues as $argValue) { $argValue = explode(':', $argValue); if (count($argValue) != 2) { $msg = 'Command argument "--replace" must follow the format: --replace="{SEARCH}:{REPLACE},..."'; throw new \ErrorException($msg); } $search = trim($argValue[0]); $replace = trim($argValue[1]); if ($this->isMagicVariable($replace)) { // Is magic variable, so, replace by the magic value. $replace = $this->getMagicVariableValue($replace); } $replaceValues[$search] = $replace; } return $replaceValues; }
[ "public", "function", "getReplaceValuesFromArgument", "(", "$", "argValues", ")", "{", "$", "replaceValues", "=", "array", "(", ")", ";", "$", "argValues", "=", "explode", "(", "','", ",", "$", "argValues", ")", ";", "foreach", "(", "$", "argValues", "as", "$", "argValue", ")", "{", "$", "argValue", "=", "explode", "(", "':'", ",", "$", "argValue", ")", ";", "if", "(", "count", "(", "$", "argValue", ")", "!=", "2", ")", "{", "$", "msg", "=", "'Command argument \"--replace\" must follow the format: --replace=\"{SEARCH}:{REPLACE},...\"'", ";", "throw", "new", "\\", "ErrorException", "(", "$", "msg", ")", ";", "}", "$", "search", "=", "trim", "(", "$", "argValue", "[", "0", "]", ")", ";", "$", "replace", "=", "trim", "(", "$", "argValue", "[", "1", "]", ")", ";", "if", "(", "$", "this", "->", "isMagicVariable", "(", "$", "replace", ")", ")", "{", "// Is magic variable, so, replace by the magic value.", "$", "replace", "=", "$", "this", "->", "getMagicVariableValue", "(", "$", "replace", ")", ";", "}", "$", "replaceValues", "[", "$", "search", "]", "=", "$", "replace", ";", "}", "return", "$", "replaceValues", ";", "}" ]
Returns an array containing the replace values from command argument. @param string $argValues Command argument replace value. @return array An array, following the format: SEARCH => REPLACE.
[ "Returns", "an", "array", "containing", "the", "replace", "values", "from", "command", "argument", "." ]
b0dd7e9c4a966f664c2df08b3067c1b6f263e226
https://github.com/jkribeiro/composer-hydration/blob/b0dd7e9c4a966f664c2df08b3067c1b6f263e226/src/Composer/ComposerHydrationHandler.php#L164-L187
16,240
jkribeiro/composer-hydration
src/Composer/ComposerHydrationHandler.php
ComposerHydrationHandler.getArguments
public function getArguments() { // Checks if script received command arguments. $cmdArguments = $this->event->getArguments(); if (!$cmdArguments) { throw new \ErrorException('Hydrate command expects arguments.'); } // Treats arguments. $returnArguments = array(); foreach ($cmdArguments as $cmdArgument) { $cmdArgument = explode('=', $cmdArgument); $argument = $cmdArgument[0]; // Checks if the argument exists. if (!$this->cmdArgumentExist($argument)) { throw new \ErrorException("Command argument '$argument' do not exist."); } // Treats REPLACE_ARG argument. if ($argument == self::REPLACE_ARG) { $replaceValues = !empty($cmdArgument[1]) ? $cmdArgument[1] : null; if (!$replaceValues) { $msg = 'Command argument "--replace" must contain values, like: --replace="{SEARCH}:{REPLACE},.."'; throw new \ErrorException($msg); } $returnArguments[self::REPLACE_ARG] = $this->getReplaceValuesFromArgument($replaceValues); } } return $returnArguments; }
php
public function getArguments() { // Checks if script received command arguments. $cmdArguments = $this->event->getArguments(); if (!$cmdArguments) { throw new \ErrorException('Hydrate command expects arguments.'); } // Treats arguments. $returnArguments = array(); foreach ($cmdArguments as $cmdArgument) { $cmdArgument = explode('=', $cmdArgument); $argument = $cmdArgument[0]; // Checks if the argument exists. if (!$this->cmdArgumentExist($argument)) { throw new \ErrorException("Command argument '$argument' do not exist."); } // Treats REPLACE_ARG argument. if ($argument == self::REPLACE_ARG) { $replaceValues = !empty($cmdArgument[1]) ? $cmdArgument[1] : null; if (!$replaceValues) { $msg = 'Command argument "--replace" must contain values, like: --replace="{SEARCH}:{REPLACE},.."'; throw new \ErrorException($msg); } $returnArguments[self::REPLACE_ARG] = $this->getReplaceValuesFromArgument($replaceValues); } } return $returnArguments; }
[ "public", "function", "getArguments", "(", ")", "{", "// Checks if script received command arguments.", "$", "cmdArguments", "=", "$", "this", "->", "event", "->", "getArguments", "(", ")", ";", "if", "(", "!", "$", "cmdArguments", ")", "{", "throw", "new", "\\", "ErrorException", "(", "'Hydrate command expects arguments.'", ")", ";", "}", "// Treats arguments.", "$", "returnArguments", "=", "array", "(", ")", ";", "foreach", "(", "$", "cmdArguments", "as", "$", "cmdArgument", ")", "{", "$", "cmdArgument", "=", "explode", "(", "'='", ",", "$", "cmdArgument", ")", ";", "$", "argument", "=", "$", "cmdArgument", "[", "0", "]", ";", "// Checks if the argument exists.", "if", "(", "!", "$", "this", "->", "cmdArgumentExist", "(", "$", "argument", ")", ")", "{", "throw", "new", "\\", "ErrorException", "(", "\"Command argument '$argument' do not exist.\"", ")", ";", "}", "// Treats REPLACE_ARG argument.", "if", "(", "$", "argument", "==", "self", "::", "REPLACE_ARG", ")", "{", "$", "replaceValues", "=", "!", "empty", "(", "$", "cmdArgument", "[", "1", "]", ")", "?", "$", "cmdArgument", "[", "1", "]", ":", "null", ";", "if", "(", "!", "$", "replaceValues", ")", "{", "$", "msg", "=", "'Command argument \"--replace\" must contain values, like: --replace=\"{SEARCH}:{REPLACE},..\"'", ";", "throw", "new", "\\", "ErrorException", "(", "$", "msg", ")", ";", "}", "$", "returnArguments", "[", "self", "::", "REPLACE_ARG", "]", "=", "$", "this", "->", "getReplaceValuesFromArgument", "(", "$", "replaceValues", ")", ";", "}", "}", "return", "$", "returnArguments", ";", "}" ]
Returns an array containing the command arguments values. @return array An array containing the script command arguments.
[ "Returns", "an", "array", "containing", "the", "command", "arguments", "values", "." ]
b0dd7e9c4a966f664c2df08b3067c1b6f263e226
https://github.com/jkribeiro/composer-hydration/blob/b0dd7e9c4a966f664c2df08b3067c1b6f263e226/src/Composer/ComposerHydrationHandler.php#L195-L227
16,241
jkribeiro/composer-hydration
src/Composer/ComposerHydrationHandler.php
ComposerHydrationHandler.hydrateFileContents
public function hydrateFileContents($replaceMap) { $io = $this->event->getIO(); $finder = new Finder(); $finder->in($this->basePath); $finder->ignoreDotFiles(false); $finder->notPath('vendor'); $finder->notName('composer.json'); // Find files. foreach ($replaceMap as $search => $replace) { // Restrict files by search. $finder->contains($search); } $count = iterator_count($finder); if (!$count) { $io->write("[Hydration][OK] Skipping, no file contents to be replaced."); return; } $io->write("[Hydration][INFO] Hydrating $count file(s)."); foreach ($finder as $file) { $filePath = $file->getRelativePathname(); // Replace values. $fileContent = str_replace(array_keys($replaceMap), array_values($replaceMap), $file->getContents()); // Save file with new replaced content. if (!file_put_contents($filePath, $fileContent)) { // Failed. $msg = "Unable to Hydrate the file, check the file permissions and try again: $filePath"; throw new \ErrorException($msg); } // Success. $io->write("[Hydration][OK] File Hydrated: $filePath"); } }
php
public function hydrateFileContents($replaceMap) { $io = $this->event->getIO(); $finder = new Finder(); $finder->in($this->basePath); $finder->ignoreDotFiles(false); $finder->notPath('vendor'); $finder->notName('composer.json'); // Find files. foreach ($replaceMap as $search => $replace) { // Restrict files by search. $finder->contains($search); } $count = iterator_count($finder); if (!$count) { $io->write("[Hydration][OK] Skipping, no file contents to be replaced."); return; } $io->write("[Hydration][INFO] Hydrating $count file(s)."); foreach ($finder as $file) { $filePath = $file->getRelativePathname(); // Replace values. $fileContent = str_replace(array_keys($replaceMap), array_values($replaceMap), $file->getContents()); // Save file with new replaced content. if (!file_put_contents($filePath, $fileContent)) { // Failed. $msg = "Unable to Hydrate the file, check the file permissions and try again: $filePath"; throw new \ErrorException($msg); } // Success. $io->write("[Hydration][OK] File Hydrated: $filePath"); } }
[ "public", "function", "hydrateFileContents", "(", "$", "replaceMap", ")", "{", "$", "io", "=", "$", "this", "->", "event", "->", "getIO", "(", ")", ";", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "in", "(", "$", "this", "->", "basePath", ")", ";", "$", "finder", "->", "ignoreDotFiles", "(", "false", ")", ";", "$", "finder", "->", "notPath", "(", "'vendor'", ")", ";", "$", "finder", "->", "notName", "(", "'composer.json'", ")", ";", "// Find files.", "foreach", "(", "$", "replaceMap", "as", "$", "search", "=>", "$", "replace", ")", "{", "// Restrict files by search.", "$", "finder", "->", "contains", "(", "$", "search", ")", ";", "}", "$", "count", "=", "iterator_count", "(", "$", "finder", ")", ";", "if", "(", "!", "$", "count", ")", "{", "$", "io", "->", "write", "(", "\"[Hydration][OK] Skipping, no file contents to be replaced.\"", ")", ";", "return", ";", "}", "$", "io", "->", "write", "(", "\"[Hydration][INFO] Hydrating $count file(s).\"", ")", ";", "foreach", "(", "$", "finder", "as", "$", "file", ")", "{", "$", "filePath", "=", "$", "file", "->", "getRelativePathname", "(", ")", ";", "// Replace values.", "$", "fileContent", "=", "str_replace", "(", "array_keys", "(", "$", "replaceMap", ")", ",", "array_values", "(", "$", "replaceMap", ")", ",", "$", "file", "->", "getContents", "(", ")", ")", ";", "// Save file with new replaced content.", "if", "(", "!", "file_put_contents", "(", "$", "filePath", ",", "$", "fileContent", ")", ")", "{", "// Failed.", "$", "msg", "=", "\"Unable to Hydrate the file, check the file permissions and try again: $filePath\"", ";", "throw", "new", "\\", "ErrorException", "(", "$", "msg", ")", ";", "}", "// Success.", "$", "io", "->", "write", "(", "\"[Hydration][OK] File Hydrated: $filePath\"", ")", ";", "}", "}" ]
Process hydration to File contents. @param string $replaceMap An array containing the replacement map following the format: [{SEARCH} => {REPLACE}, {SEARCH} => {REPLACE}, ...]
[ "Process", "hydration", "to", "File", "contents", "." ]
b0dd7e9c4a966f664c2df08b3067c1b6f263e226
https://github.com/jkribeiro/composer-hydration/blob/b0dd7e9c4a966f664c2df08b3067c1b6f263e226/src/Composer/ComposerHydrationHandler.php#L238-L279
16,242
jkribeiro/composer-hydration
src/Composer/ComposerHydrationHandler.php
ComposerHydrationHandler.hydrateRenameFilesAndFolders
public function hydrateRenameFilesAndFolders($replaceMap) { $io = $this->event->getIO(); $finder = new Finder(); $finder->in($this->basePath); $finder->ignoreDotFiles(false); $finder->exclude('vendor'); foreach ($replaceMap as $search => $replace) { // Restrict files by search. $finder->name(".*$search*"); $finder->name("*$search*"); } $count = iterator_count($finder); if (!$count) { $io->write("[Hydration][OK] Skipping, no folders and files to be renamed."); return; } $io->write("[Hydration][INFO] Renaming $count file(s)/folder(s)."); $finder = array_keys(iterator_to_array($finder, true)); foreach ($finder as $currentName) { $newName = str_replace(array_keys($replaceMap), array_values($replaceMap), $currentName); // Replace values. $renamed = rename($currentName, $newName); if (!$renamed) { // Failed. throw new \ErrorException("Unable to rename file/folder: $currentName"); } // Success. $io->write("[Hydration][OK] Renamed $currentName ---> $newName"); } }
php
public function hydrateRenameFilesAndFolders($replaceMap) { $io = $this->event->getIO(); $finder = new Finder(); $finder->in($this->basePath); $finder->ignoreDotFiles(false); $finder->exclude('vendor'); foreach ($replaceMap as $search => $replace) { // Restrict files by search. $finder->name(".*$search*"); $finder->name("*$search*"); } $count = iterator_count($finder); if (!$count) { $io->write("[Hydration][OK] Skipping, no folders and files to be renamed."); return; } $io->write("[Hydration][INFO] Renaming $count file(s)/folder(s)."); $finder = array_keys(iterator_to_array($finder, true)); foreach ($finder as $currentName) { $newName = str_replace(array_keys($replaceMap), array_values($replaceMap), $currentName); // Replace values. $renamed = rename($currentName, $newName); if (!$renamed) { // Failed. throw new \ErrorException("Unable to rename file/folder: $currentName"); } // Success. $io->write("[Hydration][OK] Renamed $currentName ---> $newName"); } }
[ "public", "function", "hydrateRenameFilesAndFolders", "(", "$", "replaceMap", ")", "{", "$", "io", "=", "$", "this", "->", "event", "->", "getIO", "(", ")", ";", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "in", "(", "$", "this", "->", "basePath", ")", ";", "$", "finder", "->", "ignoreDotFiles", "(", "false", ")", ";", "$", "finder", "->", "exclude", "(", "'vendor'", ")", ";", "foreach", "(", "$", "replaceMap", "as", "$", "search", "=>", "$", "replace", ")", "{", "// Restrict files by search.", "$", "finder", "->", "name", "(", "\".*$search*\"", ")", ";", "$", "finder", "->", "name", "(", "\"*$search*\"", ")", ";", "}", "$", "count", "=", "iterator_count", "(", "$", "finder", ")", ";", "if", "(", "!", "$", "count", ")", "{", "$", "io", "->", "write", "(", "\"[Hydration][OK] Skipping, no folders and files to be renamed.\"", ")", ";", "return", ";", "}", "$", "io", "->", "write", "(", "\"[Hydration][INFO] Renaming $count file(s)/folder(s).\"", ")", ";", "$", "finder", "=", "array_keys", "(", "iterator_to_array", "(", "$", "finder", ",", "true", ")", ")", ";", "foreach", "(", "$", "finder", "as", "$", "currentName", ")", "{", "$", "newName", "=", "str_replace", "(", "array_keys", "(", "$", "replaceMap", ")", ",", "array_values", "(", "$", "replaceMap", ")", ",", "$", "currentName", ")", ";", "// Replace values.", "$", "renamed", "=", "rename", "(", "$", "currentName", ",", "$", "newName", ")", ";", "if", "(", "!", "$", "renamed", ")", "{", "// Failed.", "throw", "new", "\\", "ErrorException", "(", "\"Unable to rename file/folder: $currentName\"", ")", ";", "}", "// Success.", "$", "io", "->", "write", "(", "\"[Hydration][OK] Renamed $currentName ---> $newName\"", ")", ";", "}", "}" ]
Process hydration renaming files and folders. @param string $replaceMap An array containing the replacement map following the format: [{SEARCH} => {REPLACE}, {SEARCH} => {REPLACE}, ...]
[ "Process", "hydration", "renaming", "files", "and", "folders", "." ]
b0dd7e9c4a966f664c2df08b3067c1b6f263e226
https://github.com/jkribeiro/composer-hydration/blob/b0dd7e9c4a966f664c2df08b3067c1b6f263e226/src/Composer/ComposerHydrationHandler.php#L290-L328
16,243
jkribeiro/composer-hydration
src/Composer/ComposerHydrationHandler.php
ComposerHydrationHandler.hydrate
public function hydrate() { $arguments = $this->getArguments(); $replaceMap = $arguments[self::REPLACE_ARG]; // Rename Files and Folders. $this->hydrateRenameFilesAndFolders($replaceMap); // Hydrate file contents. $this->hydrateFileContents($replaceMap); }
php
public function hydrate() { $arguments = $this->getArguments(); $replaceMap = $arguments[self::REPLACE_ARG]; // Rename Files and Folders. $this->hydrateRenameFilesAndFolders($replaceMap); // Hydrate file contents. $this->hydrateFileContents($replaceMap); }
[ "public", "function", "hydrate", "(", ")", "{", "$", "arguments", "=", "$", "this", "->", "getArguments", "(", ")", ";", "$", "replaceMap", "=", "$", "arguments", "[", "self", "::", "REPLACE_ARG", "]", ";", "// Rename Files and Folders.", "$", "this", "->", "hydrateRenameFilesAndFolders", "(", "$", "replaceMap", ")", ";", "// Hydrate file contents.", "$", "this", "->", "hydrateFileContents", "(", "$", "replaceMap", ")", ";", "}" ]
Performs Hydration process.
[ "Performs", "Hydration", "process", "." ]
b0dd7e9c4a966f664c2df08b3067c1b6f263e226
https://github.com/jkribeiro/composer-hydration/blob/b0dd7e9c4a966f664c2df08b3067c1b6f263e226/src/Composer/ComposerHydrationHandler.php#L333-L343
16,244
acasademont/wurfl
WURFL/DeviceRepositoryBuilder.php
WURFL_DeviceRepositoryBuilder.buildRepository
private function buildRepository($wurflInfoIterator, $deviceIterator, $patchDeviceIterators = null) { $this->persistWurflInfo($wurflInfoIterator); $patchingDevices = $this->toListOfPatchingDevices($patchDeviceIterators); try { $this->process($deviceIterator, $patchingDevices); } catch (Exception $exception) { $this->clean(); throw new Exception("Problem Building WURFL Repository: " . $exception->getMessage(), 0, $exception); } }
php
private function buildRepository($wurflInfoIterator, $deviceIterator, $patchDeviceIterators = null) { $this->persistWurflInfo($wurflInfoIterator); $patchingDevices = $this->toListOfPatchingDevices($patchDeviceIterators); try { $this->process($deviceIterator, $patchingDevices); } catch (Exception $exception) { $this->clean(); throw new Exception("Problem Building WURFL Repository: " . $exception->getMessage(), 0, $exception); } }
[ "private", "function", "buildRepository", "(", "$", "wurflInfoIterator", ",", "$", "deviceIterator", ",", "$", "patchDeviceIterators", "=", "null", ")", "{", "$", "this", "->", "persistWurflInfo", "(", "$", "wurflInfoIterator", ")", ";", "$", "patchingDevices", "=", "$", "this", "->", "toListOfPatchingDevices", "(", "$", "patchDeviceIterators", ")", ";", "try", "{", "$", "this", "->", "process", "(", "$", "deviceIterator", ",", "$", "patchingDevices", ")", ";", "}", "catch", "(", "Exception", "$", "exception", ")", "{", "$", "this", "->", "clean", "(", ")", ";", "throw", "new", "Exception", "(", "\"Problem Building WURFL Repository: \"", ".", "$", "exception", "->", "getMessage", "(", ")", ",", "0", ",", "$", "exception", ")", ";", "}", "}" ]
Iterates over XML files and pulls relevent data @param WURFL_Xml_VersionIterator $wurflInfoIterator @param WURFL_Xml_DeviceIterator $deviceIterator @param array $patchDeviceIterators arrray of WURFL_Xml_DeviceIterator objects for patch files @throws Exception
[ "Iterates", "over", "XML", "files", "and", "pulls", "relevent", "data" ]
0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/DeviceRepositoryBuilder.php#L185-L195
16,245
marmelab/phpcr-api
src/PHPCRAPI/PHPCR/Node.php
Node.getReducedTree
public function getReducedTree() { $parseTree = function (Node $node, Node $target) use ( &$parseTree ) { if (substr($target->getPath(),0, strlen($node->getPath())) != $node->getPath()) { return array(); } $tree = array(); foreach ($node->getNodes() as $child) { $tree[] = array( 'name' => $child->getName(), 'path' => $child->getPath(), 'hasChildren' => $child->hasNodes(), 'children' => $parseTree($child, $target) ); } return $tree; }; $treeFactory = function($parent, $node) use ($parseTree) { return [ '/' => [ 'name' => '/', 'path' => '/', 'hasChildren' => $parent->hasNodes(), 'children' => $parseTree($parent, $node) ]]; }; if ($this->getPath() == '/') { return $treeFactory($this, $this); } $parent = $this; do { $parent = $parent->getParent(); } while ($parent->getPath() != '/'); return $treeFactory($parent, $this); }
php
public function getReducedTree() { $parseTree = function (Node $node, Node $target) use ( &$parseTree ) { if (substr($target->getPath(),0, strlen($node->getPath())) != $node->getPath()) { return array(); } $tree = array(); foreach ($node->getNodes() as $child) { $tree[] = array( 'name' => $child->getName(), 'path' => $child->getPath(), 'hasChildren' => $child->hasNodes(), 'children' => $parseTree($child, $target) ); } return $tree; }; $treeFactory = function($parent, $node) use ($parseTree) { return [ '/' => [ 'name' => '/', 'path' => '/', 'hasChildren' => $parent->hasNodes(), 'children' => $parseTree($parent, $node) ]]; }; if ($this->getPath() == '/') { return $treeFactory($this, $this); } $parent = $this; do { $parent = $parent->getParent(); } while ($parent->getPath() != '/'); return $treeFactory($parent, $this); }
[ "public", "function", "getReducedTree", "(", ")", "{", "$", "parseTree", "=", "function", "(", "Node", "$", "node", ",", "Node", "$", "target", ")", "use", "(", "&", "$", "parseTree", ")", "{", "if", "(", "substr", "(", "$", "target", "->", "getPath", "(", ")", ",", "0", ",", "strlen", "(", "$", "node", "->", "getPath", "(", ")", ")", ")", "!=", "$", "node", "->", "getPath", "(", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "tree", "=", "array", "(", ")", ";", "foreach", "(", "$", "node", "->", "getNodes", "(", ")", "as", "$", "child", ")", "{", "$", "tree", "[", "]", "=", "array", "(", "'name'", "=>", "$", "child", "->", "getName", "(", ")", ",", "'path'", "=>", "$", "child", "->", "getPath", "(", ")", ",", "'hasChildren'", "=>", "$", "child", "->", "hasNodes", "(", ")", ",", "'children'", "=>", "$", "parseTree", "(", "$", "child", ",", "$", "target", ")", ")", ";", "}", "return", "$", "tree", ";", "}", ";", "$", "treeFactory", "=", "function", "(", "$", "parent", ",", "$", "node", ")", "use", "(", "$", "parseTree", ")", "{", "return", "[", "'/'", "=>", "[", "'name'", "=>", "'/'", ",", "'path'", "=>", "'/'", ",", "'hasChildren'", "=>", "$", "parent", "->", "hasNodes", "(", ")", ",", "'children'", "=>", "$", "parseTree", "(", "$", "parent", ",", "$", "node", ")", "]", "]", ";", "}", ";", "if", "(", "$", "this", "->", "getPath", "(", ")", "==", "'/'", ")", "{", "return", "$", "treeFactory", "(", "$", "this", ",", "$", "this", ")", ";", "}", "$", "parent", "=", "$", "this", ";", "do", "{", "$", "parent", "=", "$", "parent", "->", "getParent", "(", ")", ";", "}", "while", "(", "$", "parent", "->", "getPath", "(", ")", "!=", "'/'", ")", ";", "return", "$", "treeFactory", "(", "$", "parent", ",", "$", "this", ")", ";", "}" ]
Return a the minimum tree to display for a node @return array The tree @api
[ "Return", "a", "the", "minimum", "tree", "to", "display", "for", "a", "node" ]
372149e27d45babe142d0546894362fce987729b
https://github.com/marmelab/phpcr-api/blob/372149e27d45babe142d0546894362fce987729b/src/PHPCRAPI/PHPCR/Node.php#L88-L127
16,246
marmelab/phpcr-api
src/PHPCRAPI/PHPCR/Node.php
Node.getPropertiesAsArray
public function getPropertiesAsArray() { $array = array(); foreach ($this->getProperties() as $property) { $array[$property->getName()] = [ 'value' => $property->getValue(), 'type' => $property->getType() ]; } return $array; }
php
public function getPropertiesAsArray() { $array = array(); foreach ($this->getProperties() as $property) { $array[$property->getName()] = [ 'value' => $property->getValue(), 'type' => $property->getType() ]; } return $array; }
[ "public", "function", "getPropertiesAsArray", "(", ")", "{", "$", "array", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "$", "array", "[", "$", "property", "->", "getName", "(", ")", "]", "=", "[", "'value'", "=>", "$", "property", "->", "getValue", "(", ")", ",", "'type'", "=>", "$", "property", "->", "getType", "(", ")", "]", ";", "}", "return", "$", "array", ";", "}" ]
Convert node's properties to array @return array Properties @api
[ "Convert", "node", "s", "properties", "to", "array" ]
372149e27d45babe142d0546894362fce987729b
https://github.com/marmelab/phpcr-api/blob/372149e27d45babe142d0546894362fce987729b/src/PHPCRAPI/PHPCR/Node.php#L136-L145
16,247
jan-dolata/crude-crud
src/Engine/CrudeSetupTrait/Filters.php
Filters.setFilters
public function setFilters($filters) { if (! is_array($filters)) $filters = [$filters]; $this->filters = array_unique(array_merge($this->filters, $filters)); return $this; }
php
public function setFilters($filters) { if (! is_array($filters)) $filters = [$filters]; $this->filters = array_unique(array_merge($this->filters, $filters)); return $this; }
[ "public", "function", "setFilters", "(", "$", "filters", ")", "{", "if", "(", "!", "is_array", "(", "$", "filters", ")", ")", "$", "filters", "=", "[", "$", "filters", "]", ";", "$", "this", "->", "filters", "=", "array_unique", "(", "array_merge", "(", "$", "this", "->", "filters", ",", "$", "filters", ")", ")", ";", "return", "$", "this", ";", "}" ]
Sets the Filters. @param array|sting $filters the filters @return self
[ "Sets", "the", "Filters", "." ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/Filters.php#L33-L41
16,248
pipelinersales/pipeliner-php-sdk
src/PipelinerSales/ApiClient/Entity.php
Entity.setFields
public function setFields($values) { foreach ($values as $field => $value) { $this->setField($field, $value); } }
php
public function setFields($values) { foreach ($values as $field => $value) { $this->setField($field, $value); } }
[ "public", "function", "setFields", "(", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "field", "=>", "$", "value", ")", "{", "$", "this", "->", "setField", "(", "$", "field", ",", "$", "value", ")", ";", "}", "}" ]
Sets values of multiple fields at once. Fields not present in the array will not be changed in any way. @param array $values an associative array of fields to values
[ "Sets", "values", "of", "multiple", "fields", "at", "once", ".", "Fields", "not", "present", "in", "the", "array", "will", "not", "be", "changed", "in", "any", "way", "." ]
a020149ffde815be17634542010814cf854c3d5f
https://github.com/pipelinersales/pipeliner-php-sdk/blob/a020149ffde815be17634542010814cf854c3d5f/src/PipelinerSales/ApiClient/Entity.php#L92-L97
16,249
WindomZ/shmcache
src/shmop.php
shmop.exists
protected function exists(int $id = 0): bool { return (bool)@shmop_open($id ? $id : $this->id, 'a', 0, 0); }
php
protected function exists(int $id = 0): bool { return (bool)@shmop_open($id ? $id : $this->id, 'a', 0, 0); }
[ "protected", "function", "exists", "(", "int", "$", "id", "=", "0", ")", ":", "bool", "{", "return", "(", "bool", ")", "@", "shmop_open", "(", "$", "id", "?", "$", "id", ":", "$", "this", "->", "id", ",", "'a'", ",", "0", ",", "0", ")", ";", "}" ]
Whether there is a system's id @param int $id [optional] @return bool
[ "Whether", "there", "is", "a", "system", "s", "id" ]
dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a
https://github.com/WindomZ/shmcache/blob/dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a/src/shmop.php#L65-L68
16,250
WindomZ/shmcache
src/shmop.php
shmop.pack
protected function pack($data, int $seconds = 0): string { return serialize( array( 'data' => $this->toPack($data), 'timeout' => $seconds ? $this->microtime($seconds * 1000) : 0, ) ); }
php
protected function pack($data, int $seconds = 0): string { return serialize( array( 'data' => $this->toPack($data), 'timeout' => $seconds ? $this->microtime($seconds * 1000) : 0, ) ); }
[ "protected", "function", "pack", "(", "$", "data", ",", "int", "$", "seconds", "=", "0", ")", ":", "string", "{", "return", "serialize", "(", "array", "(", "'data'", "=>", "$", "this", "->", "toPack", "(", "$", "data", ")", ",", "'timeout'", "=>", "$", "seconds", "?", "$", "this", "->", "microtime", "(", "$", "seconds", "*", "1000", ")", ":", "0", ",", ")", ")", ";", "}" ]
Package to an array and serialize to a string @param mixed $data @param int $seconds [optional] @return string
[ "Package", "to", "an", "array", "and", "serialize", "to", "a", "string" ]
dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a
https://github.com/WindomZ/shmcache/blob/dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a/src/shmop.php#L93-L101
16,251
WindomZ/shmcache
src/shmop.php
shmop.unpack
protected function unpack(string $data) { if ($data) { $data = unserialize($data); if (is_array($data) && isset($data['data']) && isset($data['timeout'])) { $timeout = intval($data['timeout']); if (!$timeout || $timeout >= $this->microtime()) { return $this->toUnpack($data['data']); } } } return false; }
php
protected function unpack(string $data) { if ($data) { $data = unserialize($data); if (is_array($data) && isset($data['data']) && isset($data['timeout'])) { $timeout = intval($data['timeout']); if (!$timeout || $timeout >= $this->microtime()) { return $this->toUnpack($data['data']); } } } return false; }
[ "protected", "function", "unpack", "(", "string", "$", "data", ")", "{", "if", "(", "$", "data", ")", "{", "$", "data", "=", "unserialize", "(", "$", "data", ")", ";", "if", "(", "is_array", "(", "$", "data", ")", "&&", "isset", "(", "$", "data", "[", "'data'", "]", ")", "&&", "isset", "(", "$", "data", "[", "'timeout'", "]", ")", ")", "{", "$", "timeout", "=", "intval", "(", "$", "data", "[", "'timeout'", "]", ")", ";", "if", "(", "!", "$", "timeout", "||", "$", "timeout", ">=", "$", "this", "->", "microtime", "(", ")", ")", "{", "return", "$", "this", "->", "toUnpack", "(", "$", "data", "[", "'data'", "]", ")", ";", "}", "}", "}", "return", "false", ";", "}" ]
Unpacking a string and parse no timeout data from array @param string $data @return mixed|bool
[ "Unpacking", "a", "string", "and", "parse", "no", "timeout", "data", "from", "array" ]
dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a
https://github.com/WindomZ/shmcache/blob/dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a/src/shmop.php#L115-L128
16,252
WindomZ/shmcache
src/shmop.php
shmop.write
protected function write($data, int $seconds = 0): bool { if (!$data) { return false; } $this->clean(); $data = $this->pack($data, $seconds); $id = shmop_open($this->id, "n", $this->mode, strlen($data)); if (!$id) { return false; } $size = shmop_write($id, $data, 0); return !empty($size); }
php
protected function write($data, int $seconds = 0): bool { if (!$data) { return false; } $this->clean(); $data = $this->pack($data, $seconds); $id = shmop_open($this->id, "n", $this->mode, strlen($data)); if (!$id) { return false; } $size = shmop_write($id, $data, 0); return !empty($size); }
[ "protected", "function", "write", "(", "$", "data", ",", "int", "$", "seconds", "=", "0", ")", ":", "bool", "{", "if", "(", "!", "$", "data", ")", "{", "return", "false", ";", "}", "$", "this", "->", "clean", "(", ")", ";", "$", "data", "=", "$", "this", "->", "pack", "(", "$", "data", ",", "$", "seconds", ")", ";", "$", "id", "=", "shmop_open", "(", "$", "this", "->", "id", ",", "\"n\"", ",", "$", "this", "->", "mode", ",", "strlen", "(", "$", "data", ")", ")", ";", "if", "(", "!", "$", "id", ")", "{", "return", "false", ";", "}", "$", "size", "=", "shmop_write", "(", "$", "id", ",", "$", "data", ",", "0", ")", ";", "return", "!", "empty", "(", "$", "size", ")", ";", "}" ]
Write data into shared memory block @param mixed $data @param int $seconds [optional] @return bool
[ "Write", "data", "into", "shared", "memory", "block" ]
dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a
https://github.com/WindomZ/shmcache/blob/dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a/src/shmop.php#L136-L154
16,253
WindomZ/shmcache
src/shmop.php
shmop.read
protected function read() { if ($this->exists()) { $id = shmop_open($this->id, "a", 0, 0); if (!$id) { return false; } $data = shmop_read($id, 0, shmop_size($id)); if (!$data) { return false; } $data = $this->unpack($data); shmop_close($id); return $data; } return false; }
php
protected function read() { if ($this->exists()) { $id = shmop_open($this->id, "a", 0, 0); if (!$id) { return false; } $data = shmop_read($id, 0, shmop_size($id)); if (!$data) { return false; } $data = $this->unpack($data); shmop_close($id); return $data; } return false; }
[ "protected", "function", "read", "(", ")", "{", "if", "(", "$", "this", "->", "exists", "(", ")", ")", "{", "$", "id", "=", "shmop_open", "(", "$", "this", "->", "id", ",", "\"a\"", ",", "0", ",", "0", ")", ";", "if", "(", "!", "$", "id", ")", "{", "return", "false", ";", "}", "$", "data", "=", "shmop_read", "(", "$", "id", ",", "0", ",", "shmop_size", "(", "$", "id", ")", ")", ";", "if", "(", "!", "$", "data", ")", "{", "return", "false", ";", "}", "$", "data", "=", "$", "this", "->", "unpack", "(", "$", "data", ")", ";", "shmop_close", "(", "$", "id", ")", ";", "return", "$", "data", ";", "}", "return", "false", ";", "}" ]
Read data from shared memory block @return bool|mixed
[ "Read", "data", "from", "shared", "memory", "block" ]
dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a
https://github.com/WindomZ/shmcache/blob/dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a/src/shmop.php#L160-L180
16,254
WindomZ/shmcache
src/shmop.php
shmop.clean
protected function clean() { if ($this->exists()) { $id = shmop_open($this->id, "a", 0, 0); shmop_delete($id); shmop_close($id); } }
php
protected function clean() { if ($this->exists()) { $id = shmop_open($this->id, "a", 0, 0); shmop_delete($id); shmop_close($id); } }
[ "protected", "function", "clean", "(", ")", "{", "if", "(", "$", "this", "->", "exists", "(", ")", ")", "{", "$", "id", "=", "shmop_open", "(", "$", "this", "->", "id", ",", "\"a\"", ",", "0", ",", "0", ")", ";", "shmop_delete", "(", "$", "id", ")", ";", "shmop_close", "(", "$", "id", ")", ";", "}", "}" ]
Clean data from shared memory block
[ "Clean", "data", "from", "shared", "memory", "block" ]
dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a
https://github.com/WindomZ/shmcache/blob/dfb1660b72e6807ba9c6eb4bed70169f4d7e0a7a/src/shmop.php#L185-L192
16,255
stubbles/stubbles-webapp-core
src/main/php/routing/SupportedMimeTypes.php
SupportedMimeTypes.findMatch
public function findMatch(AcceptHeader $acceptedMimeTypes) { if (count($this->mimeTypes) === 0) { return 'text/html'; } if (count($acceptedMimeTypes) === 0) { reset($this->mimeTypes); return current($this->mimeTypes); } return $acceptedMimeTypes->findMatchWithGreatestPriority($this->mimeTypes); }
php
public function findMatch(AcceptHeader $acceptedMimeTypes) { if (count($this->mimeTypes) === 0) { return 'text/html'; } if (count($acceptedMimeTypes) === 0) { reset($this->mimeTypes); return current($this->mimeTypes); } return $acceptedMimeTypes->findMatchWithGreatestPriority($this->mimeTypes); }
[ "public", "function", "findMatch", "(", "AcceptHeader", "$", "acceptedMimeTypes", ")", "{", "if", "(", "count", "(", "$", "this", "->", "mimeTypes", ")", "===", "0", ")", "{", "return", "'text/html'", ";", "}", "if", "(", "count", "(", "$", "acceptedMimeTypes", ")", "===", "0", ")", "{", "reset", "(", "$", "this", "->", "mimeTypes", ")", ";", "return", "current", "(", "$", "this", "->", "mimeTypes", ")", ";", "}", "return", "$", "acceptedMimeTypes", "->", "findMatchWithGreatestPriority", "(", "$", "this", "->", "mimeTypes", ")", ";", "}" ]
finds best matching mime type based on accept header @param \stubbles\peer\http\AcceptHeader $acceptedMimeTypes @return string|null
[ "finds", "best", "matching", "mime", "type", "based", "on", "accept", "header" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/SupportedMimeTypes.php#L122-L134
16,256
stubbles/stubbles-webapp-core
src/main/php/routing/SupportedMimeTypes.php
SupportedMimeTypes.removeDefaultMimeTypeClass
public static function removeDefaultMimeTypeClass(string $mimeType) { if (isset(self::$supported[$mimeType])) { unset(self::$supported[$mimeType]); } }
php
public static function removeDefaultMimeTypeClass(string $mimeType) { if (isset(self::$supported[$mimeType])) { unset(self::$supported[$mimeType]); } }
[ "public", "static", "function", "removeDefaultMimeTypeClass", "(", "string", "$", "mimeType", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "supported", "[", "$", "mimeType", "]", ")", ")", "{", "unset", "(", "self", "::", "$", "supported", "[", "$", "mimeType", "]", ")", ";", "}", "}" ]
removes default mime type class for given mime type @param string $mimeType @since 5.1.1
[ "removes", "default", "mime", "type", "class", "for", "given", "mime", "type" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/SupportedMimeTypes.php#L154-L159
16,257
stubbles/stubbles-webapp-core
src/main/php/routing/SupportedMimeTypes.php
SupportedMimeTypes.provideDefaultClassFor
public static function provideDefaultClassFor(string $mimeType): bool { if (in_array($mimeType, array_keys(self::$supported))) { return true; } if (class_exists('stubbles\xml\serializer\XmlSerializerFacade') && in_array($mimeType, array_keys(self::$xml))) { return true; } if (class_exists('stubbles\img\Image') && in_array($mimeType, array_keys(self::$image))) { return true; } return false; }
php
public static function provideDefaultClassFor(string $mimeType): bool { if (in_array($mimeType, array_keys(self::$supported))) { return true; } if (class_exists('stubbles\xml\serializer\XmlSerializerFacade') && in_array($mimeType, array_keys(self::$xml))) { return true; } if (class_exists('stubbles\img\Image') && in_array($mimeType, array_keys(self::$image))) { return true; } return false; }
[ "public", "static", "function", "provideDefaultClassFor", "(", "string", "$", "mimeType", ")", ":", "bool", "{", "if", "(", "in_array", "(", "$", "mimeType", ",", "array_keys", "(", "self", "::", "$", "supported", ")", ")", ")", "{", "return", "true", ";", "}", "if", "(", "class_exists", "(", "'stubbles\\xml\\serializer\\XmlSerializerFacade'", ")", "&&", "in_array", "(", "$", "mimeType", ",", "array_keys", "(", "self", "::", "$", "xml", ")", ")", ")", "{", "return", "true", ";", "}", "if", "(", "class_exists", "(", "'stubbles\\img\\Image'", ")", "&&", "in_array", "(", "$", "mimeType", ",", "array_keys", "(", "self", "::", "$", "image", ")", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
checks if a default class is known for the given mime type @param string $mimeType @return bool @since 5.0.0
[ "checks", "if", "a", "default", "class", "is", "known", "for", "the", "given", "mime", "type" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/SupportedMimeTypes.php#L168-L183
16,258
stubbles/stubbles-webapp-core
src/main/php/routing/SupportedMimeTypes.php
SupportedMimeTypes.classFor
public function classFor(string $mimeType) { if ($this->provideClass($mimeType)) { return $this->mimeTypeClasses[$mimeType]; } return null; }
php
public function classFor(string $mimeType) { if ($this->provideClass($mimeType)) { return $this->mimeTypeClasses[$mimeType]; } return null; }
[ "public", "function", "classFor", "(", "string", "$", "mimeType", ")", "{", "if", "(", "$", "this", "->", "provideClass", "(", "$", "mimeType", ")", ")", "{", "return", "$", "this", "->", "mimeTypeClasses", "[", "$", "mimeType", "]", ";", "}", "return", "null", ";", "}" ]
returns special class which was defined for given mime type or null if none defined @param string $mimeType @return string|null @since 3.2.0
[ "returns", "special", "class", "which", "was", "defined", "for", "given", "mime", "type", "or", "null", "if", "none", "defined" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/SupportedMimeTypes.php#L204-L211
16,259
belgattitude/soluble-metadata
src/Soluble/Metadata/Reader/AbstractMetadataReader.php
AbstractMetadataReader.getColumnsMetadata
public function getColumnsMetadata(string $sql): ColumnsMetadata { if ($this->cache_active) { $cache_key = md5($sql); if (!array_key_exists($cache_key, static::$metadata_cache)) { $md = $this->readColumnsMetadata($sql); static::$metadata_cache[$cache_key] = $md; } return static::$metadata_cache[$cache_key]; } return $this->readColumnsMetadata($sql); }
php
public function getColumnsMetadata(string $sql): ColumnsMetadata { if ($this->cache_active) { $cache_key = md5($sql); if (!array_key_exists($cache_key, static::$metadata_cache)) { $md = $this->readColumnsMetadata($sql); static::$metadata_cache[$cache_key] = $md; } return static::$metadata_cache[$cache_key]; } return $this->readColumnsMetadata($sql); }
[ "public", "function", "getColumnsMetadata", "(", "string", "$", "sql", ")", ":", "ColumnsMetadata", "{", "if", "(", "$", "this", "->", "cache_active", ")", "{", "$", "cache_key", "=", "md5", "(", "$", "sql", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "cache_key", ",", "static", "::", "$", "metadata_cache", ")", ")", "{", "$", "md", "=", "$", "this", "->", "readColumnsMetadata", "(", "$", "sql", ")", ";", "static", "::", "$", "metadata_cache", "[", "$", "cache_key", "]", "=", "$", "md", ";", "}", "return", "static", "::", "$", "metadata_cache", "[", "$", "cache_key", "]", ";", "}", "return", "$", "this", "->", "readColumnsMetadata", "(", "$", "sql", ")", ";", "}" ]
Return columns metadata from query. @throws Exception\UnsupportedTypeException @throws Exception\AmbiguousColumnException @throws Exception\InvalidQueryException
[ "Return", "columns", "metadata", "from", "query", "." ]
6285461c40a619070f601184d58e6c772b769d5c
https://github.com/belgattitude/soluble-metadata/blob/6285461c40a619070f601184d58e6c772b769d5c/src/Soluble/Metadata/Reader/AbstractMetadataReader.php#L48-L61
16,260
belgattitude/soluble-metadata
src/Soluble/Metadata/Reader/AbstractMetadataReader.php
AbstractMetadataReader.getTableMetadata
public function getTableMetadata(string $table): ColumnsMetadata { try { $metadata = $this->getColumnsMetadata(sprintf('select * from %s', $table)); } catch (Exception\InvalidQueryException $e) { throw new Exception\TableNotFoundException(sprintf( 'Table "%s" does not exists (%s).', $table, $e->getMessage() )); } return $metadata; }
php
public function getTableMetadata(string $table): ColumnsMetadata { try { $metadata = $this->getColumnsMetadata(sprintf('select * from %s', $table)); } catch (Exception\InvalidQueryException $e) { throw new Exception\TableNotFoundException(sprintf( 'Table "%s" does not exists (%s).', $table, $e->getMessage() )); } return $metadata; }
[ "public", "function", "getTableMetadata", "(", "string", "$", "table", ")", ":", "ColumnsMetadata", "{", "try", "{", "$", "metadata", "=", "$", "this", "->", "getColumnsMetadata", "(", "sprintf", "(", "'select * from %s'", ",", "$", "table", ")", ")", ";", "}", "catch", "(", "Exception", "\\", "InvalidQueryException", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "TableNotFoundException", "(", "sprintf", "(", "'Table \"%s\" does not exists (%s).'", ",", "$", "table", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "return", "$", "metadata", ";", "}" ]
Return columns metadata from a table. @throws Exception\UnsupportedTypeException @throws Exception\AmbiguousColumnException @throws Exception\TableNotFoundException
[ "Return", "columns", "metadata", "from", "a", "table", "." ]
6285461c40a619070f601184d58e6c772b769d5c
https://github.com/belgattitude/soluble-metadata/blob/6285461c40a619070f601184d58e6c772b769d5c/src/Soluble/Metadata/Reader/AbstractMetadataReader.php#L70-L83
16,261
belgattitude/soluble-metadata
src/Soluble/Metadata/Reader/AbstractMetadataReader.php
AbstractMetadataReader.getEmptiedQuery
protected function getEmptiedQuery(string $sql): string { // see the reason why in Vision_Store_Adapter_ZendDbSelect::getMetaData //$sql = str_replace("('__innerselect'='__innerselect')", '(1=0)', $sql); $sql = preg_replace('/(\r\n|\r|\n|\t)+/', ' ', strtolower($sql)); $sql = trim($sql ?: ''); $sql = preg_replace('/\s+/', ' ', $sql) ?: ''; $replace_regexp = "LIMIT[\s]+[\d]+((\s*,\s*\d+)|(\s+OFFSET\s+\d+)){0,1}"; $search_regexp = "$replace_regexp"; if (preg_match("/$search_regexp/i", $sql) < 1) { // Limit is not already present $sql .= ' LIMIT 0'; } else { // replace first if offset exists, then if not //preg_match_all("/($search_regexp)/i", $sql, $matches, PREG_PATTERN_ORDER); //var_dump($matches); $sql = preg_replace("/($replace_regexp)/i", 'LIMIT 0', $sql) ?: ''; } return $sql; }
php
protected function getEmptiedQuery(string $sql): string { // see the reason why in Vision_Store_Adapter_ZendDbSelect::getMetaData //$sql = str_replace("('__innerselect'='__innerselect')", '(1=0)', $sql); $sql = preg_replace('/(\r\n|\r|\n|\t)+/', ' ', strtolower($sql)); $sql = trim($sql ?: ''); $sql = preg_replace('/\s+/', ' ', $sql) ?: ''; $replace_regexp = "LIMIT[\s]+[\d]+((\s*,\s*\d+)|(\s+OFFSET\s+\d+)){0,1}"; $search_regexp = "$replace_regexp"; if (preg_match("/$search_regexp/i", $sql) < 1) { // Limit is not already present $sql .= ' LIMIT 0'; } else { // replace first if offset exists, then if not //preg_match_all("/($search_regexp)/i", $sql, $matches, PREG_PATTERN_ORDER); //var_dump($matches); $sql = preg_replace("/($replace_regexp)/i", 'LIMIT 0', $sql) ?: ''; } return $sql; }
[ "protected", "function", "getEmptiedQuery", "(", "string", "$", "sql", ")", ":", "string", "{", "// see the reason why in Vision_Store_Adapter_ZendDbSelect::getMetaData", "//$sql = str_replace(\"('__innerselect'='__innerselect')\", '(1=0)', $sql);", "$", "sql", "=", "preg_replace", "(", "'/(\\r\\n|\\r|\\n|\\t)+/'", ",", "' '", ",", "strtolower", "(", "$", "sql", ")", ")", ";", "$", "sql", "=", "trim", "(", "$", "sql", "?", ":", "''", ")", ";", "$", "sql", "=", "preg_replace", "(", "'/\\s+/'", ",", "' '", ",", "$", "sql", ")", "?", ":", "''", ";", "$", "replace_regexp", "=", "\"LIMIT[\\s]+[\\d]+((\\s*,\\s*\\d+)|(\\s+OFFSET\\s+\\d+)){0,1}\"", ";", "$", "search_regexp", "=", "\"$replace_regexp\"", ";", "if", "(", "preg_match", "(", "\"/$search_regexp/i\"", ",", "$", "sql", ")", "<", "1", ")", "{", "// Limit is not already present", "$", "sql", ".=", "' LIMIT 0'", ";", "}", "else", "{", "// replace first if offset exists, then if not", "//preg_match_all(\"/($search_regexp)/i\", $sql, $matches, PREG_PATTERN_ORDER);", "//var_dump($matches);", "$", "sql", "=", "preg_replace", "(", "\"/($replace_regexp)/i\"", ",", "'LIMIT 0'", ",", "$", "sql", ")", "?", ":", "''", ";", "}", "return", "$", "sql", ";", "}" ]
Optimization, will add false condition to the query so the metadata loading will be faster.
[ "Optimization", "will", "add", "false", "condition", "to", "the", "query", "so", "the", "metadata", "loading", "will", "be", "faster", "." ]
6285461c40a619070f601184d58e6c772b769d5c
https://github.com/belgattitude/soluble-metadata/blob/6285461c40a619070f601184d58e6c772b769d5c/src/Soluble/Metadata/Reader/AbstractMetadataReader.php#L98-L122
16,262
andyvenus/form
src/Type/CollectionType.php
CollectionType.processFieldsCollection
protected function processFieldsCollection($fieldCollection, $data, FormHandler $formHandler) { $fields = array(); foreach ($fieldCollection as $field) { // Unnamed array fields if ($field['name'] === null) { if (!isset($i)) $i = 0; $field['name'] = $i; $field = $this->typeHandler->makeView($field, $data, $formHandler); $fields[] = $field; $i++; } // Named array fields else { $fieldName = $field['name']; $field = $this->typeHandler->makeView($field, $data, $formHandler); $field['has_error'] = false; if ($formHandler->fieldHasError($field['name'])) { $field['has_error'] = true; } $fields[$fieldName] = $field; } } return $fields; }
php
protected function processFieldsCollection($fieldCollection, $data, FormHandler $formHandler) { $fields = array(); foreach ($fieldCollection as $field) { // Unnamed array fields if ($field['name'] === null) { if (!isset($i)) $i = 0; $field['name'] = $i; $field = $this->typeHandler->makeView($field, $data, $formHandler); $fields[] = $field; $i++; } // Named array fields else { $fieldName = $field['name']; $field = $this->typeHandler->makeView($field, $data, $formHandler); $field['has_error'] = false; if ($formHandler->fieldHasError($field['name'])) { $field['has_error'] = true; } $fields[$fieldName] = $field; } } return $fields; }
[ "protected", "function", "processFieldsCollection", "(", "$", "fieldCollection", ",", "$", "data", ",", "FormHandler", "$", "formHandler", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "foreach", "(", "$", "fieldCollection", "as", "$", "field", ")", "{", "// Unnamed array fields", "if", "(", "$", "field", "[", "'name'", "]", "===", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "i", ")", ")", "$", "i", "=", "0", ";", "$", "field", "[", "'name'", "]", "=", "$", "i", ";", "$", "field", "=", "$", "this", "->", "typeHandler", "->", "makeView", "(", "$", "field", ",", "$", "data", ",", "$", "formHandler", ")", ";", "$", "fields", "[", "]", "=", "$", "field", ";", "$", "i", "++", ";", "}", "// Named array fields", "else", "{", "$", "fieldName", "=", "$", "field", "[", "'name'", "]", ";", "$", "field", "=", "$", "this", "->", "typeHandler", "->", "makeView", "(", "$", "field", ",", "$", "data", ",", "$", "formHandler", ")", ";", "$", "field", "[", "'has_error'", "]", "=", "false", ";", "if", "(", "$", "formHandler", "->", "fieldHasError", "(", "$", "field", "[", "'name'", "]", ")", ")", "{", "$", "field", "[", "'has_error'", "]", "=", "true", ";", "}", "$", "fields", "[", "$", "fieldName", "]", "=", "$", "field", ";", "}", "}", "return", "$", "fields", ";", "}" ]
Process a collection of fields @param $fieldCollection @param $data @param \AV\Form\FormHandler $formHandler @return array
[ "Process", "a", "collection", "of", "fields" ]
fde9d7e1741a707028aec4fd55c3568802df3708
https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/Type/CollectionType.php#L72-L101
16,263
tjbp/laravel-verify-emails
src/Auth/VerifyEmails/VerifyEmailServiceProvider.php
VerifyEmailServiceProvider.registerVerifyEmailBroker
protected function registerVerifyEmailBroker() { $this->app->singleton('auth.verify_emails', function ($app) { return new VerifyEmailBrokerManager($app); }); $this->app->bind('auth.verify_emails.broker', function ($app) { return $app->make('auth.verify_emails')->broker(); }); }
php
protected function registerVerifyEmailBroker() { $this->app->singleton('auth.verify_emails', function ($app) { return new VerifyEmailBrokerManager($app); }); $this->app->bind('auth.verify_emails.broker', function ($app) { return $app->make('auth.verify_emails')->broker(); }); }
[ "protected", "function", "registerVerifyEmailBroker", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'auth.verify_emails'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "VerifyEmailBrokerManager", "(", "$", "app", ")", ";", "}", ")", ";", "$", "this", "->", "app", "->", "bind", "(", "'auth.verify_emails.broker'", ",", "function", "(", "$", "app", ")", "{", "return", "$", "app", "->", "make", "(", "'auth.verify_emails'", ")", "->", "broker", "(", ")", ";", "}", ")", ";", "}" ]
Register the verify email broker instance. @return void
[ "Register", "the", "verify", "email", "broker", "instance", "." ]
1e2ac10a696c10f2fdf0d7de6c3388d549bc07c6
https://github.com/tjbp/laravel-verify-emails/blob/1e2ac10a696c10f2fdf0d7de6c3388d549bc07c6/src/Auth/VerifyEmails/VerifyEmailServiceProvider.php#L34-L43
16,264
FrenchFrogs/framework
src/Form/Form/Form.php
Form.render
public function render() { $render = ''; try { $render = $this->getRenderer()->render('form', $this); } catch(\Exception $e){ dd($e->getMessage());//@todo find a good way to warn the developper } return $render; }
php
public function render() { $render = ''; try { $render = $this->getRenderer()->render('form', $this); } catch(\Exception $e){ dd($e->getMessage());//@todo find a good way to warn the developper } return $render; }
[ "public", "function", "render", "(", ")", "{", "$", "render", "=", "''", ";", "try", "{", "$", "render", "=", "$", "this", "->", "getRenderer", "(", ")", "->", "render", "(", "'form'", ",", "$", "this", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "dd", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "//@todo find a good way to warn the developper", "}", "return", "$", "render", ";", "}" ]
Render the polliwog @return mixed|string
[ "Render", "the", "polliwog" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Form/Form.php#L268-L278
16,265
FrenchFrogs/framework
src/Form/Form/Form.php
Form.getValues
public function getValues() { $values = []; foreach($this->getElements() as $name => $e) { /** @var $e \FrenchFrogs\Form\Element\Element */ if ($e->isDiscreet()) {continue;} $values[$name] = $e->getValue(); } return $values; }
php
public function getValues() { $values = []; foreach($this->getElements() as $name => $e) { /** @var $e \FrenchFrogs\Form\Element\Element */ if ($e->isDiscreet()) {continue;} $values[$name] = $e->getValue(); } return $values; }
[ "public", "function", "getValues", "(", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getElements", "(", ")", "as", "$", "name", "=>", "$", "e", ")", "{", "/** @var $e \\FrenchFrogs\\Form\\Element\\Element */", "if", "(", "$", "e", "->", "isDiscreet", "(", ")", ")", "{", "continue", ";", "}", "$", "values", "[", "$", "name", "]", "=", "$", "e", "->", "getValue", "(", ")", ";", "}", "return", "$", "values", ";", "}" ]
Return all values from all elements @return array
[ "Return", "all", "values", "from", "all", "elements" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Form/Form.php#L333-L344
16,266
FrenchFrogs/framework
src/Form/Form/Form.php
Form.getFilteredValues
public function getFilteredValues() { $values = []; foreach($this->getElements() as $name => $e){ /** @var \FrenchFrogs\Form\Element\Element $e */ if ($e->isDiscreet()) {continue;} $values[$name] = $e->getFilteredValue(); } return $values; }
php
public function getFilteredValues() { $values = []; foreach($this->getElements() as $name => $e){ /** @var \FrenchFrogs\Form\Element\Element $e */ if ($e->isDiscreet()) {continue;} $values[$name] = $e->getFilteredValue(); } return $values; }
[ "public", "function", "getFilteredValues", "(", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getElements", "(", ")", "as", "$", "name", "=>", "$", "e", ")", "{", "/** @var \\FrenchFrogs\\Form\\Element\\Element $e */", "if", "(", "$", "e", "->", "isDiscreet", "(", ")", ")", "{", "continue", ";", "}", "$", "values", "[", "$", "name", "]", "=", "$", "e", "->", "getFilteredValue", "(", ")", ";", "}", "return", "$", "values", ";", "}" ]
Return all filtered values from all elements @return array
[ "Return", "all", "filtered", "values", "from", "all", "elements" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Form/Form.php#L364-L374
16,267
FrenchFrogs/framework
src/Form/Form/Form.php
Form.valid
public function valid(array $values, $populate = true) { foreach($this->getElements() as $index => &$element) { if(!array_key_exists($index, $values)) { if(is_a($element, 'FrenchFrogs\Form\Element\Boolean')){ $values[$index] = 0; } else { $values[$index] = ''; } } $element->valid($values[$index]); if (!$element->isValid()) { $this->getValidator()->addError($index, $element->getErrorAsString()); } } return $this; }
php
public function valid(array $values, $populate = true) { foreach($this->getElements() as $index => &$element) { if(!array_key_exists($index, $values)) { if(is_a($element, 'FrenchFrogs\Form\Element\Boolean')){ $values[$index] = 0; } else { $values[$index] = ''; } } $element->valid($values[$index]); if (!$element->isValid()) { $this->getValidator()->addError($index, $element->getErrorAsString()); } } return $this; }
[ "public", "function", "valid", "(", "array", "$", "values", ",", "$", "populate", "=", "true", ")", "{", "foreach", "(", "$", "this", "->", "getElements", "(", ")", "as", "$", "index", "=>", "&", "$", "element", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "index", ",", "$", "values", ")", ")", "{", "if", "(", "is_a", "(", "$", "element", ",", "'FrenchFrogs\\Form\\Element\\Boolean'", ")", ")", "{", "$", "values", "[", "$", "index", "]", "=", "0", ";", "}", "else", "{", "$", "values", "[", "$", "index", "]", "=", "''", ";", "}", "}", "$", "element", "->", "valid", "(", "$", "values", "[", "$", "index", "]", ")", ";", "if", "(", "!", "$", "element", "->", "isValid", "(", ")", ")", "{", "$", "this", "->", "getValidator", "(", ")", "->", "addError", "(", "$", "index", ",", "$", "element", "->", "getErrorAsString", "(", ")", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Valid all the form elements @param array $values @param bool|true $populate @return $this
[ "Valid", "all", "the", "form", "elements" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Form/Form.php#L416-L436
16,268
FrenchFrogs/framework
src/Form/Form/Form.php
Form.getErrorAsString
public function getErrorAsString() { $errors = []; foreach($this->getValidator()->getErrors() as $index => $message){ $errors[] = sprintf('%s:%s %s', $index, PHP_EOL, $message); } return implode(PHP_EOL, $errors); }
php
public function getErrorAsString() { $errors = []; foreach($this->getValidator()->getErrors() as $index => $message){ $errors[] = sprintf('%s:%s %s', $index, PHP_EOL, $message); } return implode(PHP_EOL, $errors); }
[ "public", "function", "getErrorAsString", "(", ")", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getValidator", "(", ")", "->", "getErrors", "(", ")", "as", "$", "index", "=>", "$", "message", ")", "{", "$", "errors", "[", "]", "=", "sprintf", "(", "'%s:%s %s'", ",", "$", "index", ",", "PHP_EOL", ",", "$", "message", ")", ";", "}", "return", "implode", "(", "PHP_EOL", ",", "$", "errors", ")", ";", "}" ]
Return string formated error from the form validation @return string
[ "Return", "string", "formated", "error", "from", "the", "form", "validation" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Form/Form.php#L445-L452
16,269
okvpn/fixture-bundle
src/Fixture/AbstractEntityReferenceFixture.php
AbstractEntityReferenceFixture.getObjectReferences
protected function getObjectReferences(ObjectManager $objectManager, $className) { $identifier = $objectManager->getClassMetadata($className)->getIdentifier(); $idField = reset($identifier); /** @var EntityRepository $objectRepository */ $objectRepository = $objectManager->getRepository($className); $idsResult = $objectRepository ->createQueryBuilder('t') ->select('t.' . $idField) ->getQuery() ->getArrayResult(); $ids = []; foreach ($idsResult as $result) { $ids[] = $result[$idField]; } return $this->getObjectReferencesByIds($objectManager, $className, $ids); }
php
protected function getObjectReferences(ObjectManager $objectManager, $className) { $identifier = $objectManager->getClassMetadata($className)->getIdentifier(); $idField = reset($identifier); /** @var EntityRepository $objectRepository */ $objectRepository = $objectManager->getRepository($className); $idsResult = $objectRepository ->createQueryBuilder('t') ->select('t.' . $idField) ->getQuery() ->getArrayResult(); $ids = []; foreach ($idsResult as $result) { $ids[] = $result[$idField]; } return $this->getObjectReferencesByIds($objectManager, $className, $ids); }
[ "protected", "function", "getObjectReferences", "(", "ObjectManager", "$", "objectManager", ",", "$", "className", ")", "{", "$", "identifier", "=", "$", "objectManager", "->", "getClassMetadata", "(", "$", "className", ")", "->", "getIdentifier", "(", ")", ";", "$", "idField", "=", "reset", "(", "$", "identifier", ")", ";", "/** @var EntityRepository $objectRepository */", "$", "objectRepository", "=", "$", "objectManager", "->", "getRepository", "(", "$", "className", ")", ";", "$", "idsResult", "=", "$", "objectRepository", "->", "createQueryBuilder", "(", "'t'", ")", "->", "select", "(", "'t.'", ".", "$", "idField", ")", "->", "getQuery", "(", ")", "->", "getArrayResult", "(", ")", ";", "$", "ids", "=", "[", "]", ";", "foreach", "(", "$", "idsResult", "as", "$", "result", ")", "{", "$", "ids", "[", "]", "=", "$", "result", "[", "$", "idField", "]", ";", "}", "return", "$", "this", "->", "getObjectReferencesByIds", "(", "$", "objectManager", ",", "$", "className", ",", "$", "ids", ")", ";", "}" ]
Returns array of object references. @param ObjectManager $objectManager @param string $className @return array @see getObjectReferencesByIds
[ "Returns", "array", "of", "object", "references", "." ]
243b5e4dff9773e97fa447280e929c936a5d66ae
https://github.com/okvpn/fixture-bundle/blob/243b5e4dff9773e97fa447280e929c936a5d66ae/src/Fixture/AbstractEntityReferenceFixture.php#L21-L41
16,270
okvpn/fixture-bundle
src/Fixture/AbstractEntityReferenceFixture.php
AbstractEntityReferenceFixture.getObjectReferencesByIds
protected function getObjectReferencesByIds(ObjectManager $objectManager, $className, array $ids) { $entities = []; foreach ($ids as $id) { /** @var EntityManager $objectManager */ $entities[] = $objectManager->getReference($className, $id); } return $entities; }
php
protected function getObjectReferencesByIds(ObjectManager $objectManager, $className, array $ids) { $entities = []; foreach ($ids as $id) { /** @var EntityManager $objectManager */ $entities[] = $objectManager->getReference($className, $id); } return $entities; }
[ "protected", "function", "getObjectReferencesByIds", "(", "ObjectManager", "$", "objectManager", ",", "$", "className", ",", "array", "$", "ids", ")", "{", "$", "entities", "=", "[", "]", ";", "foreach", "(", "$", "ids", "as", "$", "id", ")", "{", "/** @var EntityManager $objectManager */", "$", "entities", "[", "]", "=", "$", "objectManager", "->", "getReference", "(", "$", "className", ",", "$", "id", ")", ";", "}", "return", "$", "entities", ";", "}" ]
Returns array of object references by their ids. It's useful when ids are known and objects are used as other entities' relation. @param ObjectManager $objectManager @param string $className @param array $ids @return array
[ "Returns", "array", "of", "object", "references", "by", "their", "ids", ".", "It", "s", "useful", "when", "ids", "are", "known", "and", "objects", "are", "used", "as", "other", "entities", "relation", "." ]
243b5e4dff9773e97fa447280e929c936a5d66ae
https://github.com/okvpn/fixture-bundle/blob/243b5e4dff9773e97fa447280e929c936a5d66ae/src/Fixture/AbstractEntityReferenceFixture.php#L52-L62
16,271
matthenning/eloquent-api-filter
src/Matthenning/EloquentApiFilter/EloquentApiFilter.php
EloquentApiFilter.applyFilter
private function applyFilter(Builder $query, $field, $filter, $or = false) { $filter = explode(':', $filter); if (count($filter) > 1) { $operator = $this->getFilterOperator($filter[0]); $value = $this->replaceWildcards($filter[1]); } else { $operator = '='; $value = $this->replaceWildcards($filter[0]); } $fields = explode('.', $field); if (count($fields) > 1) { return $this->applyNestedFilter($query, $fields, $operator, $value, $or); } else { return $this->applyWhereClause($query, $field, $operator, $value, $or); } }
php
private function applyFilter(Builder $query, $field, $filter, $or = false) { $filter = explode(':', $filter); if (count($filter) > 1) { $operator = $this->getFilterOperator($filter[0]); $value = $this->replaceWildcards($filter[1]); } else { $operator = '='; $value = $this->replaceWildcards($filter[0]); } $fields = explode('.', $field); if (count($fields) > 1) { return $this->applyNestedFilter($query, $fields, $operator, $value, $or); } else { return $this->applyWhereClause($query, $field, $operator, $value, $or); } }
[ "private", "function", "applyFilter", "(", "Builder", "$", "query", ",", "$", "field", ",", "$", "filter", ",", "$", "or", "=", "false", ")", "{", "$", "filter", "=", "explode", "(", "':'", ",", "$", "filter", ")", ";", "if", "(", "count", "(", "$", "filter", ")", ">", "1", ")", "{", "$", "operator", "=", "$", "this", "->", "getFilterOperator", "(", "$", "filter", "[", "0", "]", ")", ";", "$", "value", "=", "$", "this", "->", "replaceWildcards", "(", "$", "filter", "[", "1", "]", ")", ";", "}", "else", "{", "$", "operator", "=", "'='", ";", "$", "value", "=", "$", "this", "->", "replaceWildcards", "(", "$", "filter", "[", "0", "]", ")", ";", "}", "$", "fields", "=", "explode", "(", "'.'", ",", "$", "field", ")", ";", "if", "(", "count", "(", "$", "fields", ")", ">", "1", ")", "{", "return", "$", "this", "->", "applyNestedFilter", "(", "$", "query", ",", "$", "fields", ",", "$", "operator", ",", "$", "value", ",", "$", "or", ")", ";", "}", "else", "{", "return", "$", "this", "->", "applyWhereClause", "(", "$", "query", ",", "$", "field", ",", "$", "operator", ",", "$", "value", ",", "$", "or", ")", ";", "}", "}" ]
Applies a single filter to the query @param Builder $query @param $field @param $filter @param $or = false @return Builder
[ "Applies", "a", "single", "filter", "to", "the", "query" ]
3533155f894fbc0e6566b9d69baefda557031506
https://github.com/matthenning/eloquent-api-filter/blob/3533155f894fbc0e6566b9d69baefda557031506/src/Matthenning/EloquentApiFilter/EloquentApiFilter.php#L152-L171
16,272
matthenning/eloquent-api-filter
src/Matthenning/EloquentApiFilter/EloquentApiFilter.php
EloquentApiFilter.applyNestedFilter
private function applyNestedFilter(Builder $query, array $fields, $operator, $value, $or = false) { $relation_name = implode('.', array_slice($fields, 0, count($fields) - 1)); $relation_field = end($fields); if ($relation_name[0] == '!') { $relation_name = substr($relation_name, 1, strlen($relation_name)); $that = $this; return $query->whereHas($relation_name, function ($query) use ($relation_field, $operator, $value, $that, $or) { $query = $that->applyWhereClause($query, $relation_field, $operator, $value, $or); }, '=', 0); } $that = $this; return $query->whereHas($relation_name, function ($query) use ($relation_field, $operator, $value, $that, $or) { $query = $that->applyWhereClause($query, $relation_field, $operator, $value, $or); }); }
php
private function applyNestedFilter(Builder $query, array $fields, $operator, $value, $or = false) { $relation_name = implode('.', array_slice($fields, 0, count($fields) - 1)); $relation_field = end($fields); if ($relation_name[0] == '!') { $relation_name = substr($relation_name, 1, strlen($relation_name)); $that = $this; return $query->whereHas($relation_name, function ($query) use ($relation_field, $operator, $value, $that, $or) { $query = $that->applyWhereClause($query, $relation_field, $operator, $value, $or); }, '=', 0); } $that = $this; return $query->whereHas($relation_name, function ($query) use ($relation_field, $operator, $value, $that, $or) { $query = $that->applyWhereClause($query, $relation_field, $operator, $value, $or); }); }
[ "private", "function", "applyNestedFilter", "(", "Builder", "$", "query", ",", "array", "$", "fields", ",", "$", "operator", ",", "$", "value", ",", "$", "or", "=", "false", ")", "{", "$", "relation_name", "=", "implode", "(", "'.'", ",", "array_slice", "(", "$", "fields", ",", "0", ",", "count", "(", "$", "fields", ")", "-", "1", ")", ")", ";", "$", "relation_field", "=", "end", "(", "$", "fields", ")", ";", "if", "(", "$", "relation_name", "[", "0", "]", "==", "'!'", ")", "{", "$", "relation_name", "=", "substr", "(", "$", "relation_name", ",", "1", ",", "strlen", "(", "$", "relation_name", ")", ")", ";", "$", "that", "=", "$", "this", ";", "return", "$", "query", "->", "whereHas", "(", "$", "relation_name", ",", "function", "(", "$", "query", ")", "use", "(", "$", "relation_field", ",", "$", "operator", ",", "$", "value", ",", "$", "that", ",", "$", "or", ")", "{", "$", "query", "=", "$", "that", "->", "applyWhereClause", "(", "$", "query", ",", "$", "relation_field", ",", "$", "operator", ",", "$", "value", ",", "$", "or", ")", ";", "}", ",", "'='", ",", "0", ")", ";", "}", "$", "that", "=", "$", "this", ";", "return", "$", "query", "->", "whereHas", "(", "$", "relation_name", ",", "function", "(", "$", "query", ")", "use", "(", "$", "relation_field", ",", "$", "operator", ",", "$", "value", ",", "$", "that", ",", "$", "or", ")", "{", "$", "query", "=", "$", "that", "->", "applyWhereClause", "(", "$", "query", ",", "$", "relation_field", ",", "$", "operator", ",", "$", "value", ",", "$", "or", ")", ";", "}", ")", ";", "}" ]
Applies a nested filter. Nested filters are filters on field on related models. @param Builder $query @param array $fields @param $operator @param $value @param $or = false @return Builder
[ "Applies", "a", "nested", "filter", ".", "Nested", "filters", "are", "filters", "on", "field", "on", "related", "models", "." ]
3533155f894fbc0e6566b9d69baefda557031506
https://github.com/matthenning/eloquent-api-filter/blob/3533155f894fbc0e6566b9d69baefda557031506/src/Matthenning/EloquentApiFilter/EloquentApiFilter.php#L184-L203
16,273
matthenning/eloquent-api-filter
src/Matthenning/EloquentApiFilter/EloquentApiFilter.php
EloquentApiFilter.applyWhereClause
private function applyWhereClause(Builder $query, $field, $operator, $value, $or = false) { $verb = $or ? 'orWhere' : 'where'; $null_verb = $or ? 'orWhereNull' : 'whereNull'; $not_null_verb = $or ? 'orWhereNotNull' : 'whereNotNull'; $value = $this->base64decodeIfNecessary($value); switch ($value) { case 'today': return $query->$verb($field, 'like', Carbon::now()->format('Y-m-d') . '%'); case 'nottoday': return $query->$verb(function ($q) use ($field) { $q->where($field, 'not like', Carbon::now()->format('Y-m-d') . '%') ->orWhereNull($field); }); case 'null': return $query->$null_verb($field); case 'notnull': return $query->$not_null_verb($field); default: return $query->$verb($field, $operator, $value); } }
php
private function applyWhereClause(Builder $query, $field, $operator, $value, $or = false) { $verb = $or ? 'orWhere' : 'where'; $null_verb = $or ? 'orWhereNull' : 'whereNull'; $not_null_verb = $or ? 'orWhereNotNull' : 'whereNotNull'; $value = $this->base64decodeIfNecessary($value); switch ($value) { case 'today': return $query->$verb($field, 'like', Carbon::now()->format('Y-m-d') . '%'); case 'nottoday': return $query->$verb(function ($q) use ($field) { $q->where($field, 'not like', Carbon::now()->format('Y-m-d') . '%') ->orWhereNull($field); }); case 'null': return $query->$null_verb($field); case 'notnull': return $query->$not_null_verb($field); default: return $query->$verb($field, $operator, $value); } }
[ "private", "function", "applyWhereClause", "(", "Builder", "$", "query", ",", "$", "field", ",", "$", "operator", ",", "$", "value", ",", "$", "or", "=", "false", ")", "{", "$", "verb", "=", "$", "or", "?", "'orWhere'", ":", "'where'", ";", "$", "null_verb", "=", "$", "or", "?", "'orWhereNull'", ":", "'whereNull'", ";", "$", "not_null_verb", "=", "$", "or", "?", "'orWhereNotNull'", ":", "'whereNotNull'", ";", "$", "value", "=", "$", "this", "->", "base64decodeIfNecessary", "(", "$", "value", ")", ";", "switch", "(", "$", "value", ")", "{", "case", "'today'", ":", "return", "$", "query", "->", "$", "verb", "(", "$", "field", ",", "'like'", ",", "Carbon", "::", "now", "(", ")", "->", "format", "(", "'Y-m-d'", ")", ".", "'%'", ")", ";", "case", "'nottoday'", ":", "return", "$", "query", "->", "$", "verb", "(", "function", "(", "$", "q", ")", "use", "(", "$", "field", ")", "{", "$", "q", "->", "where", "(", "$", "field", ",", "'not like'", ",", "Carbon", "::", "now", "(", ")", "->", "format", "(", "'Y-m-d'", ")", ".", "'%'", ")", "->", "orWhereNull", "(", "$", "field", ")", ";", "}", ")", ";", "case", "'null'", ":", "return", "$", "query", "->", "$", "null_verb", "(", "$", "field", ")", ";", "case", "'notnull'", ":", "return", "$", "query", "->", "$", "not_null_verb", "(", "$", "field", ")", ";", "default", ":", "return", "$", "query", "->", "$", "verb", "(", "$", "field", ",", "$", "operator", ",", "$", "value", ")", ";", "}", "}" ]
Applies a where clause. Is used by applyFilter and applyNestedFilter to apply the clause to the query. @param Builder $query @param $field @param $operator @param $value @param $or = false @return Builder
[ "Applies", "a", "where", "clause", ".", "Is", "used", "by", "applyFilter", "and", "applyNestedFilter", "to", "apply", "the", "clause", "to", "the", "query", "." ]
3533155f894fbc0e6566b9d69baefda557031506
https://github.com/matthenning/eloquent-api-filter/blob/3533155f894fbc0e6566b9d69baefda557031506/src/Matthenning/EloquentApiFilter/EloquentApiFilter.php#L216-L238
16,274
matthenning/eloquent-api-filter
src/Matthenning/EloquentApiFilter/EloquentApiFilter.php
EloquentApiFilter.getFilterOperator
private function getFilterOperator($filter) { $operator = str_replace('notlike', 'not like', $filter); $operator = str_replace('gt', '>', $operator); $operator = str_replace('ge', '>=', $operator); $operator = str_replace('lt', '<', $operator); $operator = str_replace('le', '<=', $operator); $operator = str_replace('eq', '=', $operator); $operator = str_replace('ne', '!=', $operator); return $operator; }
php
private function getFilterOperator($filter) { $operator = str_replace('notlike', 'not like', $filter); $operator = str_replace('gt', '>', $operator); $operator = str_replace('ge', '>=', $operator); $operator = str_replace('lt', '<', $operator); $operator = str_replace('le', '<=', $operator); $operator = str_replace('eq', '=', $operator); $operator = str_replace('ne', '!=', $operator); return $operator; }
[ "private", "function", "getFilterOperator", "(", "$", "filter", ")", "{", "$", "operator", "=", "str_replace", "(", "'notlike'", ",", "'not like'", ",", "$", "filter", ")", ";", "$", "operator", "=", "str_replace", "(", "'gt'", ",", "'>'", ",", "$", "operator", ")", ";", "$", "operator", "=", "str_replace", "(", "'ge'", ",", "'>='", ",", "$", "operator", ")", ";", "$", "operator", "=", "str_replace", "(", "'lt'", ",", "'<'", ",", "$", "operator", ")", ";", "$", "operator", "=", "str_replace", "(", "'le'", ",", "'<='", ",", "$", "operator", ")", ";", "$", "operator", "=", "str_replace", "(", "'eq'", ",", "'='", ",", "$", "operator", ")", ";", "$", "operator", "=", "str_replace", "(", "'ne'", ",", "'!='", ",", "$", "operator", ")", ";", "return", "$", "operator", ";", "}" ]
Translates operators to SQL @param $filter @return mixed
[ "Translates", "operators", "to", "SQL" ]
3533155f894fbc0e6566b9d69baefda557031506
https://github.com/matthenning/eloquent-api-filter/blob/3533155f894fbc0e6566b9d69baefda557031506/src/Matthenning/EloquentApiFilter/EloquentApiFilter.php#L304-L315
16,275
codeburnerframework/router
src/Collectors/ResourceCollectorTrait.php
ResourceCollectorTrait.resource
public function resource($controller, array $options = array()) { $name = isset($options["prefix"]) ? $options["prefix"] : ""; $name .= $this->getResourceName($controller, $options); $actions = $this->getResourceActions($options); $resource = new RouteResource; foreach ($actions as $action => $map) { $resource->set( $this->set( $map[0], $this->getResourcePath($action, $map[1], $name, $options), [$controller, $action] ) ->setName("$name.$action") ); } return $resource; }
php
public function resource($controller, array $options = array()) { $name = isset($options["prefix"]) ? $options["prefix"] : ""; $name .= $this->getResourceName($controller, $options); $actions = $this->getResourceActions($options); $resource = new RouteResource; foreach ($actions as $action => $map) { $resource->set( $this->set( $map[0], $this->getResourcePath($action, $map[1], $name, $options), [$controller, $action] ) ->setName("$name.$action") ); } return $resource; }
[ "public", "function", "resource", "(", "$", "controller", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "name", "=", "isset", "(", "$", "options", "[", "\"prefix\"", "]", ")", "?", "$", "options", "[", "\"prefix\"", "]", ":", "\"\"", ";", "$", "name", ".=", "$", "this", "->", "getResourceName", "(", "$", "controller", ",", "$", "options", ")", ";", "$", "actions", "=", "$", "this", "->", "getResourceActions", "(", "$", "options", ")", ";", "$", "resource", "=", "new", "RouteResource", ";", "foreach", "(", "$", "actions", "as", "$", "action", "=>", "$", "map", ")", "{", "$", "resource", "->", "set", "(", "$", "this", "->", "set", "(", "$", "map", "[", "0", "]", ",", "$", "this", "->", "getResourcePath", "(", "$", "action", ",", "$", "map", "[", "1", "]", ",", "$", "name", ",", "$", "options", ")", ",", "[", "$", "controller", ",", "$", "action", "]", ")", "->", "setName", "(", "\"$name.$action\"", ")", ")", ";", "}", "return", "$", "resource", ";", "}" ]
Resource routing allows you to quickly declare all of the common routes for a given resourceful controller. Instead of declaring separate routes for your index, show, new, edit, create, update and destroy actions, a resourceful route declares them in a single line of code. @param string $controller The controller name. @param array $options Some options like, "as" to name the route pattern, "only" to explicit say that only this routes will be registered, and "except" that register all the routes except the indicates. @return RouteResource
[ "Resource", "routing", "allows", "you", "to", "quickly", "declare", "all", "of", "the", "common", "routes", "for", "a", "given", "resourceful", "controller", ".", "Instead", "of", "declaring", "separate", "routes", "for", "your", "index", "show", "new", "edit", "create", "update", "and", "destroy", "actions", "a", "resourceful", "route", "declares", "them", "in", "a", "single", "line", "of", "code", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Collectors/ResourceCollectorTrait.php#L68-L87
16,276
codeburnerframework/router
src/Collectors/ResourceCollectorTrait.php
ResourceCollectorTrait.resources
public function resources(array $controllers) { $resource = new RouteResource; foreach ($controllers as $controller) $resource->set($this->resource($controller)); return $resource; }
php
public function resources(array $controllers) { $resource = new RouteResource; foreach ($controllers as $controller) $resource->set($this->resource($controller)); return $resource; }
[ "public", "function", "resources", "(", "array", "$", "controllers", ")", "{", "$", "resource", "=", "new", "RouteResource", ";", "foreach", "(", "$", "controllers", "as", "$", "controller", ")", "$", "resource", "->", "set", "(", "$", "this", "->", "resource", "(", "$", "controller", ")", ")", ";", "return", "$", "resource", ";", "}" ]
Collect several resources at same time. @param array $controllers Several controller names as parameters or an array with all controller names. @return RouteResource
[ "Collect", "several", "resources", "at", "same", "time", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Collectors/ResourceCollectorTrait.php#L96-L102
16,277
phossa2/middleware
src/Middleware/Utility.php
Utility.setCookie
public static function setCookie( ResponseInterface $response, /*# string */ $name, /*# string */ $value = null, /*# int */ $ttl = null, /*# string */ $path = null, /*# string */ $domain = null, /*# bool */ $secure = false, /*# bool */ $httponly = true )/*# : ResponseInterface */ { $cookie = urlencode($name) . '=' . urlencode($value); self::addExpire($cookie, $ttl); self::addDomain($cookie, $domain); self::addPath($cookie, $path); self::addSecure($cookie, $secure); self::addHttpOnly($cookie, $httponly); return $response->withAddedHeader('Set-Cookie', $cookie); }
php
public static function setCookie( ResponseInterface $response, /*# string */ $name, /*# string */ $value = null, /*# int */ $ttl = null, /*# string */ $path = null, /*# string */ $domain = null, /*# bool */ $secure = false, /*# bool */ $httponly = true )/*# : ResponseInterface */ { $cookie = urlencode($name) . '=' . urlencode($value); self::addExpire($cookie, $ttl); self::addDomain($cookie, $domain); self::addPath($cookie, $path); self::addSecure($cookie, $secure); self::addHttpOnly($cookie, $httponly); return $response->withAddedHeader('Set-Cookie', $cookie); }
[ "public", "static", "function", "setCookie", "(", "ResponseInterface", "$", "response", ",", "/*# string */", "$", "name", ",", "/*# string */", "$", "value", "=", "null", ",", "/*# int */", "$", "ttl", "=", "null", ",", "/*# string */", "$", "path", "=", "null", ",", "/*# string */", "$", "domain", "=", "null", ",", "/*# bool */", "$", "secure", "=", "false", ",", "/*# bool */", "$", "httponly", "=", "true", ")", "/*# : ResponseInterface */", "{", "$", "cookie", "=", "urlencode", "(", "$", "name", ")", ".", "'='", ".", "urlencode", "(", "$", "value", ")", ";", "self", "::", "addExpire", "(", "$", "cookie", ",", "$", "ttl", ")", ";", "self", "::", "addDomain", "(", "$", "cookie", ",", "$", "domain", ")", ";", "self", "::", "addPath", "(", "$", "cookie", ",", "$", "path", ")", ";", "self", "::", "addSecure", "(", "$", "cookie", ",", "$", "secure", ")", ";", "self", "::", "addHttpOnly", "(", "$", "cookie", ",", "$", "httponly", ")", ";", "return", "$", "response", "->", "withAddedHeader", "(", "'Set-Cookie'", ",", "$", "cookie", ")", ";", "}" ]
Set a cookie in the response @param ResponseInterface $response @param string $name @param string $value @param int $ttl @param string $path @param string $domain @param bool $secure @param bool $httponly @return ResponseInterface @access public
[ "Set", "a", "cookie", "in", "the", "response" ]
518e97ae48077f2c11adcd3c2393830ed7ab7ce7
https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Utility.php#L47-L70
16,278
phossa2/middleware
src/Middleware/Utility.php
Utility.unsetCookie
public static function unsetCookie( ResponseInterface $response, /*# string */ $name, /*# string */ $path = null )/*# : ResponseInterface */ { return self::setCookie($response, $name, '', time() - 86400, $path); }
php
public static function unsetCookie( ResponseInterface $response, /*# string */ $name, /*# string */ $path = null )/*# : ResponseInterface */ { return self::setCookie($response, $name, '', time() - 86400, $path); }
[ "public", "static", "function", "unsetCookie", "(", "ResponseInterface", "$", "response", ",", "/*# string */", "$", "name", ",", "/*# string */", "$", "path", "=", "null", ")", "/*# : ResponseInterface */", "{", "return", "self", "::", "setCookie", "(", "$", "response", ",", "$", "name", ",", "''", ",", "time", "(", ")", "-", "86400", ",", "$", "path", ")", ";", "}" ]
Unset a cookie @param ResponseInterface $response @param string $name @param string $path @return ResponseInterface @access public
[ "Unset", "a", "cookie" ]
518e97ae48077f2c11adcd3c2393830ed7ab7ce7
https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Utility.php#L81-L87
16,279
phossa2/middleware
src/Middleware/Utility.php
Utility.publicCache
public static function publicCache( ResponseInterface $response, /*# int */ $cacheTime = 120 )/*# : ResponseInterface */ { $maxAge = $cacheTime * 60; return $response ->withAddedHeader('Expires', self::timeStamp($maxAge)) ->withAddedHeader('Cache-Control', "public, max-age={$maxAge}") ->withAddedHeader('Last-Modified', self::timeStamp()); }
php
public static function publicCache( ResponseInterface $response, /*# int */ $cacheTime = 120 )/*# : ResponseInterface */ { $maxAge = $cacheTime * 60; return $response ->withAddedHeader('Expires', self::timeStamp($maxAge)) ->withAddedHeader('Cache-Control', "public, max-age={$maxAge}") ->withAddedHeader('Last-Modified', self::timeStamp()); }
[ "public", "static", "function", "publicCache", "(", "ResponseInterface", "$", "response", ",", "/*# int */", "$", "cacheTime", "=", "120", ")", "/*# : ResponseInterface */", "{", "$", "maxAge", "=", "$", "cacheTime", "*", "60", ";", "return", "$", "response", "->", "withAddedHeader", "(", "'Expires'", ",", "self", "::", "timeStamp", "(", "$", "maxAge", ")", ")", "->", "withAddedHeader", "(", "'Cache-Control'", ",", "\"public, max-age={$maxAge}\"", ")", "->", "withAddedHeader", "(", "'Last-Modified'", ",", "self", "::", "timeStamp", "(", ")", ")", ";", "}" ]
Set public cache header @param ResponseInterface $response @param int $cacheTime cache time in minutes @return ResponseInterface @access public
[ "Set", "public", "cache", "header" ]
518e97ae48077f2c11adcd3c2393830ed7ab7ce7
https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Utility.php#L97-L106
16,280
phossa2/middleware
src/Middleware/Utility.php
Utility.privateNoExpireCache
public static function privateNoExpireCache( ResponseInterface $response, /*# int */ $cacheTime = 120 )/*# : ResponseInterface */ { $maxAge = $cacheTime * 60; return $response ->withAddedHeader('Cache-Control', "private, max-age={$maxAge}, pre-check={$maxAge}") ->withAddedHeader('Last-Modified', self::timeStamp()); }
php
public static function privateNoExpireCache( ResponseInterface $response, /*# int */ $cacheTime = 120 )/*# : ResponseInterface */ { $maxAge = $cacheTime * 60; return $response ->withAddedHeader('Cache-Control', "private, max-age={$maxAge}, pre-check={$maxAge}") ->withAddedHeader('Last-Modified', self::timeStamp()); }
[ "public", "static", "function", "privateNoExpireCache", "(", "ResponseInterface", "$", "response", ",", "/*# int */", "$", "cacheTime", "=", "120", ")", "/*# : ResponseInterface */", "{", "$", "maxAge", "=", "$", "cacheTime", "*", "60", ";", "return", "$", "response", "->", "withAddedHeader", "(", "'Cache-Control'", ",", "\"private, max-age={$maxAge}, pre-check={$maxAge}\"", ")", "->", "withAddedHeader", "(", "'Last-Modified'", ",", "self", "::", "timeStamp", "(", ")", ")", ";", "}" ]
Set private_no_expire cache header @param ResponseInterface $response @param int $cacheTime cache time in minutes @return ResponseInterface @access public
[ "Set", "private_no_expire", "cache", "header" ]
518e97ae48077f2c11adcd3c2393830ed7ab7ce7
https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Utility.php#L116-L124
16,281
pipelinersales/pipeliner-php-sdk
src/PipelinerSales/ApiClient/Http/PipelinerHttpException.php
PipelinerHttpException.getErrorMessage
public function getErrorMessage() { if (is_string($this->jsonError)) { return $this->jsonError; } elseif (isset($this->jsonError['message'])) { return $this->jsonError['message']; } return ''; }
php
public function getErrorMessage() { if (is_string($this->jsonError)) { return $this->jsonError; } elseif (isset($this->jsonError['message'])) { return $this->jsonError['message']; } return ''; }
[ "public", "function", "getErrorMessage", "(", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "jsonError", ")", ")", "{", "return", "$", "this", "->", "jsonError", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "jsonError", "[", "'message'", "]", ")", ")", "{", "return", "$", "this", "->", "jsonError", "[", "'message'", "]", ";", "}", "return", "''", ";", "}" ]
The error message specified in the API, or an empty string if not available. @return string
[ "The", "error", "message", "specified", "in", "the", "API", "or", "an", "empty", "string", "if", "not", "available", "." ]
a020149ffde815be17634542010814cf854c3d5f
https://github.com/pipelinersales/pipeliner-php-sdk/blob/a020149ffde815be17634542010814cf854c3d5f/src/PipelinerSales/ApiClient/Http/PipelinerHttpException.php#L67-L75
16,282
codeburnerframework/router
src/Route.php
Route.reset
public function reset() { return $this->collector->set($this->method, $this->pattern, $this->action)->nth(0) ->setStrategy($this->strategy)->setParams($this->params) ->setDefaults($this->defaults)->setMetadataArray($this->metadata); }
php
public function reset() { return $this->collector->set($this->method, $this->pattern, $this->action)->nth(0) ->setStrategy($this->strategy)->setParams($this->params) ->setDefaults($this->defaults)->setMetadataArray($this->metadata); }
[ "public", "function", "reset", "(", ")", "{", "return", "$", "this", "->", "collector", "->", "set", "(", "$", "this", "->", "method", ",", "$", "this", "->", "pattern", ",", "$", "this", "->", "action", ")", "->", "nth", "(", "0", ")", "->", "setStrategy", "(", "$", "this", "->", "strategy", ")", "->", "setParams", "(", "$", "this", "->", "params", ")", "->", "setDefaults", "(", "$", "this", "->", "defaults", ")", "->", "setMetadataArray", "(", "$", "this", "->", "metadata", ")", ";", "}" ]
Clone this route and set it into the collector. @return Route
[ "Clone", "this", "route", "and", "set", "it", "into", "the", "collector", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Route.php#L139-L144
16,283
codeburnerframework/router
src/Route.php
Route.call
public function call(callable $container = null) { $this->action = $this->buildCallable($this->action, $container); if ($this->strategy === null) { return call_user_func_array($this->action, array_merge($this->defaults, $this->params)); } if (!is_object($this->strategy)) { if ($container === null) { $this->strategy = new $this->strategy; } else $this->strategy = $container($this->strategy); } return $this->callWithStrategy(); }
php
public function call(callable $container = null) { $this->action = $this->buildCallable($this->action, $container); if ($this->strategy === null) { return call_user_func_array($this->action, array_merge($this->defaults, $this->params)); } if (!is_object($this->strategy)) { if ($container === null) { $this->strategy = new $this->strategy; } else $this->strategy = $container($this->strategy); } return $this->callWithStrategy(); }
[ "public", "function", "call", "(", "callable", "$", "container", "=", "null", ")", "{", "$", "this", "->", "action", "=", "$", "this", "->", "buildCallable", "(", "$", "this", "->", "action", ",", "$", "container", ")", ";", "if", "(", "$", "this", "->", "strategy", "===", "null", ")", "{", "return", "call_user_func_array", "(", "$", "this", "->", "action", ",", "array_merge", "(", "$", "this", "->", "defaults", ",", "$", "this", "->", "params", ")", ")", ";", "}", "if", "(", "!", "is_object", "(", "$", "this", "->", "strategy", ")", ")", "{", "if", "(", "$", "container", "===", "null", ")", "{", "$", "this", "->", "strategy", "=", "new", "$", "this", "->", "strategy", ";", "}", "else", "$", "this", "->", "strategy", "=", "$", "container", "(", "$", "this", "->", "strategy", ")", ";", "}", "return", "$", "this", "->", "callWithStrategy", "(", ")", ";", "}" ]
Execute the route action, if no strategy was provided the action will be executed by the call_user_func PHP function. @param callable $container @throws BadRouteException @return mixed
[ "Execute", "the", "route", "action", "if", "no", "strategy", "was", "provided", "the", "action", "will", "be", "executed", "by", "the", "call_user_func", "PHP", "function", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Route.php#L167-L182
16,284
codeburnerframework/router
src/Route.php
Route.parseCallableController
private function parseCallableController($controller, $container) { $controller = rtrim($this->namespace, "\\") . "\\" . $this->parseCallablePlaceholders($controller); if ($container === null) { return new $controller; } else return $container($controller); }
php
private function parseCallableController($controller, $container) { $controller = rtrim($this->namespace, "\\") . "\\" . $this->parseCallablePlaceholders($controller); if ($container === null) { return new $controller; } else return $container($controller); }
[ "private", "function", "parseCallableController", "(", "$", "controller", ",", "$", "container", ")", "{", "$", "controller", "=", "rtrim", "(", "$", "this", "->", "namespace", ",", "\"\\\\\"", ")", ".", "\"\\\\\"", ".", "$", "this", "->", "parseCallablePlaceholders", "(", "$", "controller", ")", ";", "if", "(", "$", "container", "===", "null", ")", "{", "return", "new", "$", "controller", ";", "}", "else", "return", "$", "container", "(", "$", "controller", ")", ";", "}" ]
Get the controller object. @param string $controller @param callable $container @return Object
[ "Get", "the", "controller", "object", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Route.php#L224-L231
16,285
codeburnerframework/router
src/Route.php
Route.parseCallablePlaceholders
private function parseCallablePlaceholders($fragment) { if (strpos($fragment, "{") !== false) { foreach ($this->params as $placeholder => $value) { if (strpos($fragment, "{" . $placeholder . "}") !== false) { $fragment = str_replace("{" . $placeholder . "}", ucwords(str_replace("-", " ", $value)), $fragment); } } } return $fragment; }
php
private function parseCallablePlaceholders($fragment) { if (strpos($fragment, "{") !== false) { foreach ($this->params as $placeholder => $value) { if (strpos($fragment, "{" . $placeholder . "}") !== false) { $fragment = str_replace("{" . $placeholder . "}", ucwords(str_replace("-", " ", $value)), $fragment); } } } return $fragment; }
[ "private", "function", "parseCallablePlaceholders", "(", "$", "fragment", ")", "{", "if", "(", "strpos", "(", "$", "fragment", ",", "\"{\"", ")", "!==", "false", ")", "{", "foreach", "(", "$", "this", "->", "params", "as", "$", "placeholder", "=>", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "fragment", ",", "\"{\"", ".", "$", "placeholder", ".", "\"}\"", ")", "!==", "false", ")", "{", "$", "fragment", "=", "str_replace", "(", "\"{\"", ".", "$", "placeholder", ".", "\"}\"", ",", "ucwords", "(", "str_replace", "(", "\"-\"", ",", "\" \"", ",", "$", "value", ")", ")", ",", "$", "fragment", ")", ";", "}", "}", "}", "return", "$", "fragment", ";", "}" ]
Parse and replace dynamic content on route action. @param string $fragment Part of callable @return string
[ "Parse", "and", "replace", "dynamic", "content", "on", "route", "action", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Route.php#L240-L251
16,286
codeburnerframework/router
src/Route.php
Route.callWithStrategy
private function callWithStrategy() { if ($this->strategy instanceof StrategyInterface) { if ($this->strategy instanceof MatcherAwareInterface) { $this->strategy->setMatcher($this->matcher); } return $this->strategy->call($this); } throw new BadRouteException(str_replace("%s", get_class($this->strategy), BadRouteException::BAD_STRATEGY)); }
php
private function callWithStrategy() { if ($this->strategy instanceof StrategyInterface) { if ($this->strategy instanceof MatcherAwareInterface) { $this->strategy->setMatcher($this->matcher); } return $this->strategy->call($this); } throw new BadRouteException(str_replace("%s", get_class($this->strategy), BadRouteException::BAD_STRATEGY)); }
[ "private", "function", "callWithStrategy", "(", ")", "{", "if", "(", "$", "this", "->", "strategy", "instanceof", "StrategyInterface", ")", "{", "if", "(", "$", "this", "->", "strategy", "instanceof", "MatcherAwareInterface", ")", "{", "$", "this", "->", "strategy", "->", "setMatcher", "(", "$", "this", "->", "matcher", ")", ";", "}", "return", "$", "this", "->", "strategy", "->", "call", "(", "$", "this", ")", ";", "}", "throw", "new", "BadRouteException", "(", "str_replace", "(", "\"%s\"", ",", "get_class", "(", "$", "this", "->", "strategy", ")", ",", "BadRouteException", "::", "BAD_STRATEGY", ")", ")", ";", "}" ]
Execute the route action with the given strategy. @throws BadRouteException @return mixed
[ "Execute", "the", "route", "action", "with", "the", "given", "strategy", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Route.php#L260-L271
16,287
codeburnerframework/router
src/Route.php
Route.setConstraint
public function setConstraint($token, $regex) { $initPos = strpos($this->pattern, "{" . $token); if ($initPos !== false) { $endPos = strpos($this->pattern, "}", $initPos); $newPattern = substr_replace($this->pattern, "{" . "$token:$regex" . "}", $initPos, $endPos - $initPos + 1); $wildcards = $this->collector->getParser()->getWildcardTokens(); $newPattern = str_replace(array_keys($wildcards), $wildcards, $newPattern); $this->setPatternWithoutReset($newPattern); } return $this; }
php
public function setConstraint($token, $regex) { $initPos = strpos($this->pattern, "{" . $token); if ($initPos !== false) { $endPos = strpos($this->pattern, "}", $initPos); $newPattern = substr_replace($this->pattern, "{" . "$token:$regex" . "}", $initPos, $endPos - $initPos + 1); $wildcards = $this->collector->getParser()->getWildcardTokens(); $newPattern = str_replace(array_keys($wildcards), $wildcards, $newPattern); $this->setPatternWithoutReset($newPattern); } return $this; }
[ "public", "function", "setConstraint", "(", "$", "token", ",", "$", "regex", ")", "{", "$", "initPos", "=", "strpos", "(", "$", "this", "->", "pattern", ",", "\"{\"", ".", "$", "token", ")", ";", "if", "(", "$", "initPos", "!==", "false", ")", "{", "$", "endPos", "=", "strpos", "(", "$", "this", "->", "pattern", ",", "\"}\"", ",", "$", "initPos", ")", ";", "$", "newPattern", "=", "substr_replace", "(", "$", "this", "->", "pattern", ",", "\"{\"", ".", "\"$token:$regex\"", ".", "\"}\"", ",", "$", "initPos", ",", "$", "endPos", "-", "$", "initPos", "+", "1", ")", ";", "$", "wildcards", "=", "$", "this", "->", "collector", "->", "getParser", "(", ")", "->", "getWildcardTokens", "(", ")", ";", "$", "newPattern", "=", "str_replace", "(", "array_keys", "(", "$", "wildcards", ")", ",", "$", "wildcards", ",", "$", "newPattern", ")", ";", "$", "this", "->", "setPatternWithoutReset", "(", "$", "newPattern", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set a constraint to a token in the route pattern. @param string $token @param string $regex @return self
[ "Set", "a", "constraint", "to", "a", "token", "in", "the", "route", "pattern", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Route.php#L627-L640
16,288
prooph/link-app-core
src/SharedKernel/ApplicationDataTypeLocation.php
ApplicationDataTypeLocation.addDataTypeClass
public function addDataTypeClass($dataTypeFQCN, $classContent, $replace = false) { if (strpos($dataTypeFQCN, "Prooph\\Link\\Application\\DataType\\") !== 0) { throw new \InvalidArgumentException("Namespace of data type should start with Prooph\\Link\\Application\\DataType\\. Got " . $dataTypeFQCN); } $nsDirs = explode("\\", str_replace("Prooph\\Link\\Application\\DataType\\", "", $dataTypeFQCN)); $className = array_pop($nsDirs); if (empty($className)) { throw new \InvalidArgumentException("Provided data type FQCN contains no class name: " . $dataTypeFQCN); } $currentPath = $this->toString(); if (! empty($nsDirs)) { foreach ($nsDirs as $nsDir) { $currentPath .= DIRECTORY_SEPARATOR . $nsDir; if (! is_dir($currentPath)) mkdir($currentPath); } } $filename = $currentPath . DIRECTORY_SEPARATOR . $className . ".php"; if (!$replace && file_exists($filename)) return; file_put_contents($filename, $classContent); }
php
public function addDataTypeClass($dataTypeFQCN, $classContent, $replace = false) { if (strpos($dataTypeFQCN, "Prooph\\Link\\Application\\DataType\\") !== 0) { throw new \InvalidArgumentException("Namespace of data type should start with Prooph\\Link\\Application\\DataType\\. Got " . $dataTypeFQCN); } $nsDirs = explode("\\", str_replace("Prooph\\Link\\Application\\DataType\\", "", $dataTypeFQCN)); $className = array_pop($nsDirs); if (empty($className)) { throw new \InvalidArgumentException("Provided data type FQCN contains no class name: " . $dataTypeFQCN); } $currentPath = $this->toString(); if (! empty($nsDirs)) { foreach ($nsDirs as $nsDir) { $currentPath .= DIRECTORY_SEPARATOR . $nsDir; if (! is_dir($currentPath)) mkdir($currentPath); } } $filename = $currentPath . DIRECTORY_SEPARATOR . $className . ".php"; if (!$replace && file_exists($filename)) return; file_put_contents($filename, $classContent); }
[ "public", "function", "addDataTypeClass", "(", "$", "dataTypeFQCN", ",", "$", "classContent", ",", "$", "replace", "=", "false", ")", "{", "if", "(", "strpos", "(", "$", "dataTypeFQCN", ",", "\"Prooph\\\\Link\\\\Application\\\\DataType\\\\\"", ")", "!==", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Namespace of data type should start with Prooph\\\\Link\\\\Application\\\\DataType\\\\. Got \"", ".", "$", "dataTypeFQCN", ")", ";", "}", "$", "nsDirs", "=", "explode", "(", "\"\\\\\"", ",", "str_replace", "(", "\"Prooph\\\\Link\\\\Application\\\\DataType\\\\\"", ",", "\"\"", ",", "$", "dataTypeFQCN", ")", ")", ";", "$", "className", "=", "array_pop", "(", "$", "nsDirs", ")", ";", "if", "(", "empty", "(", "$", "className", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Provided data type FQCN contains no class name: \"", ".", "$", "dataTypeFQCN", ")", ";", "}", "$", "currentPath", "=", "$", "this", "->", "toString", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "nsDirs", ")", ")", "{", "foreach", "(", "$", "nsDirs", "as", "$", "nsDir", ")", "{", "$", "currentPath", ".=", "DIRECTORY_SEPARATOR", ".", "$", "nsDir", ";", "if", "(", "!", "is_dir", "(", "$", "currentPath", ")", ")", "mkdir", "(", "$", "currentPath", ")", ";", "}", "}", "$", "filename", "=", "$", "currentPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "className", ".", "\".php\"", ";", "if", "(", "!", "$", "replace", "&&", "file_exists", "(", "$", "filename", ")", ")", "return", ";", "file_put_contents", "(", "$", "filename", ",", "$", "classContent", ")", ";", "}" ]
Writes the given class content to a class file named after the class. The root directory is defined by the path of ApplicationDataTypeLocation. The namespace of the class should start with Application\DataType\ If more sub namespaces are defined, the method creates a directory for each namespace part if not already exists. By default a new class is only generated if it does not exist already. You can force an override by setting the replace flag to true. @param $dataTypeFQCN @param $classContent @param bool $replace @throws \InvalidArgumentException
[ "Writes", "the", "given", "class", "content", "to", "a", "class", "file", "named", "after", "the", "class", ".", "The", "root", "directory", "is", "defined", "by", "the", "path", "of", "ApplicationDataTypeLocation", ".", "The", "namespace", "of", "the", "class", "should", "start", "with", "Application", "\\", "DataType", "\\", "If", "more", "sub", "namespaces", "are", "defined", "the", "method", "creates", "a", "directory", "for", "each", "namespace", "part", "if", "not", "already", "exists", "." ]
835a5945dfa7be7b2cebfa6e84e757ecfd783357
https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/SharedKernel/ApplicationDataTypeLocation.php#L43-L70
16,289
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.checkForDuplicateNames
protected function checkForDuplicateNames() { $normalized = []; foreach ($this->data->rawData['modules'] as $moduleId => $module) { $normalized[ $moduleId ] = $this->normalizeName( array_get($module, 'prefixed_name') ?: $module['name'] ); } return $this->getKeysForDuplicates($normalized); }
php
protected function checkForDuplicateNames() { $normalized = []; foreach ($this->data->rawData['modules'] as $moduleId => $module) { $normalized[ $moduleId ] = $this->normalizeName( array_get($module, 'prefixed_name') ?: $module['name'] ); } return $this->getKeysForDuplicates($normalized); }
[ "protected", "function", "checkForDuplicateNames", "(", ")", "{", "$", "normalized", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "as", "$", "moduleId", "=>", "$", "module", ")", "{", "$", "normalized", "[", "$", "moduleId", "]", "=", "$", "this", "->", "normalizeName", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ")", ";", "}", "return", "$", "this", "->", "getKeysForDuplicates", "(", "$", "normalized", ")", ";", "}" ]
Checks all modules for conflicting module names, and returns modules per duplicate set. @return array
[ "Checks", "all", "modules", "for", "conflicting", "module", "names", "and", "returns", "modules", "per", "duplicate", "set", "." ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L102-L113
16,290
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.addOrInjectSectionNamePrefix
protected function addOrInjectSectionNamePrefix($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; $prefix = $module['parent_names']['section']; // mark so we don't prefix it twice $this->modulePrefixedSection[$moduleId] = true; // simple prefix if nothing else was prefixed yet if ( ! $this->prefixGroup && ! $this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $prefix ); } // simple prefix won't work, we'll need to rebuild the name, prefixing the section first $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['section'] ); if ($this->prefixGroup) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['group'] ); } if ($this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['menu'] ); } }
php
protected function addOrInjectSectionNamePrefix($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; $prefix = $module['parent_names']['section']; // mark so we don't prefix it twice $this->modulePrefixedSection[$moduleId] = true; // simple prefix if nothing else was prefixed yet if ( ! $this->prefixGroup && ! $this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $prefix ); } // simple prefix won't work, we'll need to rebuild the name, prefixing the section first $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['section'] ); if ($this->prefixGroup) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['group'] ); } if ($this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['menu'] ); } }
[ "protected", "function", "addOrInjectSectionNamePrefix", "(", "$", "moduleId", ")", "{", "$", "module", "=", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", ";", "$", "prefix", "=", "$", "module", "[", "'parent_names'", "]", "[", "'section'", "]", ";", "// mark so we don't prefix it twice", "$", "this", "->", "modulePrefixedSection", "[", "$", "moduleId", "]", "=", "true", ";", "// simple prefix if nothing else was prefixed yet", "if", "(", "!", "$", "this", "->", "prefixGroup", "&&", "!", "$", "this", "->", "prefixMenu", ")", "{", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "prefix", ")", ";", "}", "// simple prefix won't work, we'll need to rebuild the name, prefixing the section first", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'section'", "]", ")", ";", "if", "(", "$", "this", "->", "prefixGroup", ")", "{", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'group'", "]", ")", ";", "}", "if", "(", "$", "this", "->", "prefixMenu", ")", "{", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'menu'", "]", ")", ";", "}", "}" ]
Prefixes module name with section name, keeping into account whether other, higher-level prefixes have been applied @param int $moduleId
[ "Prefixes", "module", "name", "with", "section", "name", "keeping", "into", "account", "whether", "other", "higher", "-", "level", "prefixes", "have", "been", "applied" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L161-L200
16,291
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.addOrInjectGroupNamePrefix
protected function addOrInjectGroupNamePrefix($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; $prefix = $module['parent_names']['group']; // mark so we don't prefix it twice $this->modulePrefixedGroup[$moduleId] = true; // simple prefix if nothing else was prefixed yet if ( ! $this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $prefix ); } // simple prefix won't work, we'll need to rebuild the name, prefixing the section and group first // note that the section will always have been prefixed, one way or the other, at this point! $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['section'] ); $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['group'] ); if ($this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['menu'] ); } }
php
protected function addOrInjectGroupNamePrefix($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; $prefix = $module['parent_names']['group']; // mark so we don't prefix it twice $this->modulePrefixedGroup[$moduleId] = true; // simple prefix if nothing else was prefixed yet if ( ! $this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $prefix ); } // simple prefix won't work, we'll need to rebuild the name, prefixing the section and group first // note that the section will always have been prefixed, one way or the other, at this point! $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['section'] ); $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['group'] ); if ($this->prefixMenu) { $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $module['parent_names']['menu'] ); } }
[ "protected", "function", "addOrInjectGroupNamePrefix", "(", "$", "moduleId", ")", "{", "$", "module", "=", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", ";", "$", "prefix", "=", "$", "module", "[", "'parent_names'", "]", "[", "'group'", "]", ";", "// mark so we don't prefix it twice", "$", "this", "->", "modulePrefixedGroup", "[", "$", "moduleId", "]", "=", "true", ";", "// simple prefix if nothing else was prefixed yet", "if", "(", "!", "$", "this", "->", "prefixMenu", ")", "{", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "prefix", ")", ";", "}", "// simple prefix won't work, we'll need to rebuild the name, prefixing the section and group first", "// note that the section will always have been prefixed, one way or the other, at this point!", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'section'", "]", ")", ";", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'group'", "]", ")", ";", "if", "(", "$", "this", "->", "prefixMenu", ")", "{", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "module", "[", "'parent_names'", "]", "[", "'menu'", "]", ")", ";", "}", "}" ]
Prefixes module name with group name, keeping into account whether other, higher-level prefixes have been applied @param int $moduleId
[ "Prefixes", "module", "name", "with", "group", "name", "keeping", "into", "account", "whether", "other", "higher", "-", "level", "prefixes", "have", "been", "applied" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L208-L246
16,292
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.addOrInjectMenuNamePrefix
protected function addOrInjectMenuNamePrefix($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; $prefix = $module['parent_names']['menu']; // mark so we don't prefix it twice $this->modulePrefixedMenu[$moduleId] = true; // this is always a simple prefix $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $prefix ); }
php
protected function addOrInjectMenuNamePrefix($moduleId) { $module = $this->data->rawData['modules'][ $moduleId ]; $prefix = $module['parent_names']['menu']; // mark so we don't prefix it twice $this->modulePrefixedMenu[$moduleId] = true; // this is always a simple prefix $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = $this->addPrefix( array_get($module, 'prefixed_name') ?: $module['name'], $prefix ); }
[ "protected", "function", "addOrInjectMenuNamePrefix", "(", "$", "moduleId", ")", "{", "$", "module", "=", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", ";", "$", "prefix", "=", "$", "module", "[", "'parent_names'", "]", "[", "'menu'", "]", ";", "// mark so we don't prefix it twice", "$", "this", "->", "modulePrefixedMenu", "[", "$", "moduleId", "]", "=", "true", ";", "// this is always a simple prefix", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "$", "this", "->", "addPrefix", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ",", "$", "prefix", ")", ";", "}" ]
Prefixes module name with menu name, keeping into account whether other, higher-level prefixes have been applied @param int $moduleId
[ "Prefixes", "module", "name", "with", "menu", "name", "keeping", "into", "account", "whether", "other", "higher", "-", "level", "prefixes", "have", "been", "applied" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L254-L268
16,293
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.addModuleIdPostFix
protected function addModuleIdPostFix($moduleId) { // undo previously applied prefixes (if any) $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = null; $this->prefixModuleName($moduleId); // postfix the module ID $module = $this->data->rawData['modules'][ $moduleId ]; $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = trim(array_get($module, 'prefixed_name') ?: $module['name']) . ' ' . $moduleId; }
php
protected function addModuleIdPostFix($moduleId) { // undo previously applied prefixes (if any) $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = null; $this->prefixModuleName($moduleId); // postfix the module ID $module = $this->data->rawData['modules'][ $moduleId ]; $this->data->rawData['modules'][ $moduleId ]['prefixed_name'] = trim(array_get($module, 'prefixed_name') ?: $module['name']) . ' ' . $moduleId; }
[ "protected", "function", "addModuleIdPostFix", "(", "$", "moduleId", ")", "{", "// undo previously applied prefixes (if any)", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "null", ";", "$", "this", "->", "prefixModuleName", "(", "$", "moduleId", ")", ";", "// postfix the module ID", "$", "module", "=", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", ";", "$", "this", "->", "data", "->", "rawData", "[", "'modules'", "]", "[", "$", "moduleId", "]", "[", "'prefixed_name'", "]", "=", "trim", "(", "array_get", "(", "$", "module", ",", "'prefixed_name'", ")", "?", ":", "$", "module", "[", "'name'", "]", ")", ".", "' '", ".", "$", "moduleId", ";", "}" ]
Postfixes the module name with the module ID, as a last resort to making a unique module name. Ideally this should undo any other attempts by prefixes, since they are useless anyway.. but this might be tricky in edge cases. You'd have to recheck for duplicates or trust the module IDs. We'll do the latter for now. @param $moduleId
[ "Postfixes", "the", "module", "name", "with", "the", "module", "ID", "as", "a", "last", "resort", "to", "making", "a", "unique", "module", "name", "." ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L281-L292
16,294
czim/laravel-pxlcms
src/Generator/Analyzer/Steps/ResolveModuleNames.php
ResolveModuleNames.getKeysForDuplicates
function getKeysForDuplicates(array $array) { $duplicates = $newArray = []; foreach ($array as $key => $value) { if ( ! isset($newArray[ $value ])) { $newArray[ $value ] = $key; continue; } if (isset($duplicates[ $value ])) { $duplicates[ $value ][] = $key; } else { $duplicates[ $value ] = [ $newArray[ $value ], $key ]; } } return $duplicates; }
php
function getKeysForDuplicates(array $array) { $duplicates = $newArray = []; foreach ($array as $key => $value) { if ( ! isset($newArray[ $value ])) { $newArray[ $value ] = $key; continue; } if (isset($duplicates[ $value ])) { $duplicates[ $value ][] = $key; } else { $duplicates[ $value ] = [ $newArray[ $value ], $key ]; } } return $duplicates; }
[ "function", "getKeysForDuplicates", "(", "array", "$", "array", ")", "{", "$", "duplicates", "=", "$", "newArray", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "newArray", "[", "$", "value", "]", ")", ")", "{", "$", "newArray", "[", "$", "value", "]", "=", "$", "key", ";", "continue", ";", "}", "if", "(", "isset", "(", "$", "duplicates", "[", "$", "value", "]", ")", ")", "{", "$", "duplicates", "[", "$", "value", "]", "[", "]", "=", "$", "key", ";", "}", "else", "{", "$", "duplicates", "[", "$", "value", "]", "=", "[", "$", "newArray", "[", "$", "value", "]", ",", "$", "key", "]", ";", "}", "}", "return", "$", "duplicates", ";", "}" ]
Returns the keys for values that occur more than once in an array @param array $array @return array
[ "Returns", "the", "keys", "for", "values", "that", "occur", "more", "than", "once", "in", "an", "array" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/ResolveModuleNames.php#L314-L336
16,295
discophp/framework
core/classes/Paginate.class.php
Paginate.getPageUrl
public function getPageUrl($page){ $qs = ''; if($_SERVER['QUERY_STRING']){ $qs = '?' . $_SERVER['QUERY_STRING']; }//if return str_replace($this->fromFormat($this->currentPage),$this->fromFormat($page),$this->uri) . $qs; }
php
public function getPageUrl($page){ $qs = ''; if($_SERVER['QUERY_STRING']){ $qs = '?' . $_SERVER['QUERY_STRING']; }//if return str_replace($this->fromFormat($this->currentPage),$this->fromFormat($page),$this->uri) . $qs; }
[ "public", "function", "getPageUrl", "(", "$", "page", ")", "{", "$", "qs", "=", "''", ";", "if", "(", "$", "_SERVER", "[", "'QUERY_STRING'", "]", ")", "{", "$", "qs", "=", "'?'", ".", "$", "_SERVER", "[", "'QUERY_STRING'", "]", ";", "}", "//if", "return", "str_replace", "(", "$", "this", "->", "fromFormat", "(", "$", "this", "->", "currentPage", ")", ",", "$", "this", "->", "fromFormat", "(", "$", "page", ")", ",", "$", "this", "->", "uri", ")", ".", "$", "qs", ";", "}" ]
Get the url for a specified page number. @param int $page The page number to build a link to. @return string
[ "Get", "the", "url", "for", "a", "specified", "page", "number", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Paginate.class.php#L240-L246
16,296
discophp/framework
core/classes/Paginate.class.php
Paginate.getPrevUrls
public function getPrevUrls($floor = null){ if($floor){ $floor = $this->currentPage - $floor; } else { $floor = 1; }//el return $this->getRangeUrls($floor,$this->currentPage - 1); }
php
public function getPrevUrls($floor = null){ if($floor){ $floor = $this->currentPage - $floor; } else { $floor = 1; }//el return $this->getRangeUrls($floor,$this->currentPage - 1); }
[ "public", "function", "getPrevUrls", "(", "$", "floor", "=", "null", ")", "{", "if", "(", "$", "floor", ")", "{", "$", "floor", "=", "$", "this", "->", "currentPage", "-", "$", "floor", ";", "}", "else", "{", "$", "floor", "=", "1", ";", "}", "//el", "return", "$", "this", "->", "getRangeUrls", "(", "$", "floor", ",", "$", "this", "->", "currentPage", "-", "1", ")", ";", "}" ]
Get paginated urls that come before the current page. @param null|int $floor The max number of links to generate. @return string[]
[ "Get", "paginated", "urls", "that", "come", "before", "the", "current", "page", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Paginate.class.php#L258-L268
16,297
discophp/framework
core/classes/Paginate.class.php
Paginate.getNextUrls
public function getNextUrls($max = null){ if($max){ $max = $this->currentPage + $max; } else { $max = $this->totalPages; }//el return $this->getRangeUrls($this->currentPage + 1,$max); }
php
public function getNextUrls($max = null){ if($max){ $max = $this->currentPage + $max; } else { $max = $this->totalPages; }//el return $this->getRangeUrls($this->currentPage + 1,$max); }
[ "public", "function", "getNextUrls", "(", "$", "max", "=", "null", ")", "{", "if", "(", "$", "max", ")", "{", "$", "max", "=", "$", "this", "->", "currentPage", "+", "$", "max", ";", "}", "else", "{", "$", "max", "=", "$", "this", "->", "totalPages", ";", "}", "//el", "return", "$", "this", "->", "getRangeUrls", "(", "$", "this", "->", "currentPage", "+", "1", ",", "$", "max", ")", ";", "}" ]
Get paginated urls that come after the current page. @param null|int $max The max number of links to generate. @return string[]
[ "Get", "paginated", "urls", "that", "come", "after", "the", "current", "page", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Paginate.class.php#L280-L290
16,298
discophp/framework
core/classes/Paginate.class.php
Paginate.getEasyMarkup
public function getEasyMarkup(){ $markup = ''; if($this->prevUrl){ $markup .= "<li class='pagination-previous' title='View previous page'><a href='{$this->prevUrl}'>prev</a></li>"; }//if $pages = $this->getPrevUrls(5); foreach($pages as $i => $page){ $markup .= "<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>"; }//foreach if($this->totalPages){ $markup .= "<li class='current' title='Your viewing page {$this->currentPage} of {$this->totalPages}'><a>{$this->currentPage}</a></li>"; }//if $pages = $this->getNextUrls(5); foreach($pages as $i => $page){ $markup .= "<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>"; }//foreach if($this->nextUrl){ $markup .= "<li class='pagination-next' title='View next page'><a href='{$this->nextUrl}'>next</a></li>"; }//if return "<ul class='pagination'>{$markup}</ul>"; }
php
public function getEasyMarkup(){ $markup = ''; if($this->prevUrl){ $markup .= "<li class='pagination-previous' title='View previous page'><a href='{$this->prevUrl}'>prev</a></li>"; }//if $pages = $this->getPrevUrls(5); foreach($pages as $i => $page){ $markup .= "<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>"; }//foreach if($this->totalPages){ $markup .= "<li class='current' title='Your viewing page {$this->currentPage} of {$this->totalPages}'><a>{$this->currentPage}</a></li>"; }//if $pages = $this->getNextUrls(5); foreach($pages as $i => $page){ $markup .= "<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>"; }//foreach if($this->nextUrl){ $markup .= "<li class='pagination-next' title='View next page'><a href='{$this->nextUrl}'>next</a></li>"; }//if return "<ul class='pagination'>{$markup}</ul>"; }
[ "public", "function", "getEasyMarkup", "(", ")", "{", "$", "markup", "=", "''", ";", "if", "(", "$", "this", "->", "prevUrl", ")", "{", "$", "markup", ".=", "\"<li class='pagination-previous' title='View previous page'><a href='{$this->prevUrl}'>prev</a></li>\"", ";", "}", "//if", "$", "pages", "=", "$", "this", "->", "getPrevUrls", "(", "5", ")", ";", "foreach", "(", "$", "pages", "as", "$", "i", "=>", "$", "page", ")", "{", "$", "markup", ".=", "\"<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>\"", ";", "}", "//foreach", "if", "(", "$", "this", "->", "totalPages", ")", "{", "$", "markup", ".=", "\"<li class='current' title='Your viewing page {$this->currentPage} of {$this->totalPages}'><a>{$this->currentPage}</a></li>\"", ";", "}", "//if", "$", "pages", "=", "$", "this", "->", "getNextUrls", "(", "5", ")", ";", "foreach", "(", "$", "pages", "as", "$", "i", "=>", "$", "page", ")", "{", "$", "markup", ".=", "\"<li><a href='{$page}' title='View page {$i} of {$this->totalPages}'>{$i}</a></li>\"", ";", "}", "//foreach", "if", "(", "$", "this", "->", "nextUrl", ")", "{", "$", "markup", ".=", "\"<li class='pagination-next' title='View next page'><a href='{$this->nextUrl}'>next</a></li>\"", ";", "}", "//if", "return", "\"<ul class='pagination'>{$markup}</ul>\"", ";", "}" ]
Get a simple markup for a pagination feed. @return string The pagination markup.
[ "Get", "a", "simple", "markup", "for", "a", "pagination", "feed", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Paginate.class.php#L344-L374
16,299
heyday/heystack
src/Output/Handler.php
Handler.process
public function process($identifier, \Controller $controller, $result = null) { if ($this->hasProcessor($identifier)) { return $this->processors[$identifier]->process($controller, $result); } else { return false; } }
php
public function process($identifier, \Controller $controller, $result = null) { if ($this->hasProcessor($identifier)) { return $this->processors[$identifier]->process($controller, $result); } else { return false; } }
[ "public", "function", "process", "(", "$", "identifier", ",", "\\", "Controller", "$", "controller", ",", "$", "result", "=", "null", ")", "{", "if", "(", "$", "this", "->", "hasProcessor", "(", "$", "identifier", ")", ")", "{", "return", "$", "this", "->", "processors", "[", "$", "identifier", "]", "->", "process", "(", "$", "controller", ",", "$", "result", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Process an output processor by identifier if it exists @param string $identifier The identifier of the processor to run @param \Controller $controller The controller that handled the request @param mixed $result The result from the run input processor @return mixed|null
[ "Process", "an", "output", "processor", "by", "identifier", "if", "it", "exists" ]
2c051933f8c532d0a9a23be6ee1ff5c619e47dfe
https://github.com/heyday/heystack/blob/2c051933f8c532d0a9a23be6ee1ff5c619e47dfe/src/Output/Handler.php#L42-L49