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
15,600
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php
LogQuery.filterByClientAgent
public function filterByClientAgent($clientAgent = null, $comparison = null) { if (null === $comparison) { if (is_array($clientAgent)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $clientAgent)) { $clientAgent = str_replace('*', '%', $clientAgent); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LogTableMap::COL_CLIENT_AGENT, $clientAgent, $comparison); }
php
public function filterByClientAgent($clientAgent = null, $comparison = null) { if (null === $comparison) { if (is_array($clientAgent)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $clientAgent)) { $clientAgent = str_replace('*', '%', $clientAgent); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LogTableMap::COL_CLIENT_AGENT, $clientAgent, $comparison); }
[ "public", "function", "filterByClientAgent", "(", "$", "clientAgent", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "clientAgent", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "clientAgent", ")", ")", "{", "$", "clientAgent", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "clientAgent", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "LogTableMap", "::", "COL_CLIENT_AGENT", ",", "$", "clientAgent", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the client_agent column Example usage: <code> $query->filterByClientAgent('fooValue'); // WHERE client_agent = 'fooValue' $query->filterByClientAgent('%fooValue%'); // WHERE client_agent LIKE '%fooValue%' </code> @param string $clientAgent The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildLogQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "client_agent", "column" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php#L558-L570
15,601
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php
LogQuery.filterByClientPlatform
public function filterByClientPlatform($clientPlatform = null, $comparison = null) { if (null === $comparison) { if (is_array($clientPlatform)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $clientPlatform)) { $clientPlatform = str_replace('*', '%', $clientPlatform); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LogTableMap::COL_CLIENT_PLATFORM, $clientPlatform, $comparison); }
php
public function filterByClientPlatform($clientPlatform = null, $comparison = null) { if (null === $comparison) { if (is_array($clientPlatform)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $clientPlatform)) { $clientPlatform = str_replace('*', '%', $clientPlatform); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LogTableMap::COL_CLIENT_PLATFORM, $clientPlatform, $comparison); }
[ "public", "function", "filterByClientPlatform", "(", "$", "clientPlatform", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "clientPlatform", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "clientPlatform", ")", ")", "{", "$", "clientPlatform", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "clientPlatform", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "LogTableMap", "::", "COL_CLIENT_PLATFORM", ",", "$", "clientPlatform", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the client_platform column Example usage: <code> $query->filterByClientPlatform('fooValue'); // WHERE client_platform = 'fooValue' $query->filterByClientPlatform('%fooValue%'); // WHERE client_platform LIKE '%fooValue%' </code> @param string $clientPlatform The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildLogQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "client_platform", "column" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LogQuery.php#L587-L599
15,602
datasift/datasift-php
lib/DataSift/Account.php
DataSift_Account.usage
public function usage($start = false, $end = false, $period = null) { $params = array(); if ($start) { $params['start'] = $start; } if ($end) { $params['end'] = $end; } if (isset($period)) { $params['period'] = $period; } return $this->_user->get('account/usage', $params); }
php
public function usage($start = false, $end = false, $period = null) { $params = array(); if ($start) { $params['start'] = $start; } if ($end) { $params['end'] = $end; } if (isset($period)) { $params['period'] = $period; } return $this->_user->get('account/usage', $params); }
[ "public", "function", "usage", "(", "$", "start", "=", "false", ",", "$", "end", "=", "false", ",", "$", "period", "=", "null", ")", "{", "$", "params", "=", "array", "(", ")", ";", "if", "(", "$", "start", ")", "{", "$", "params", "[", "'start'", "]", "=", "$", "start", ";", "}", "if", "(", "$", "end", ")", "{", "$", "params", "[", "'end'", "]", "=", "$", "end", ";", "}", "if", "(", "isset", "(", "$", "period", ")", ")", "{", "$", "params", "[", "'period'", "]", "=", "$", "period", ";", "}", "return", "$", "this", "->", "_user", "->", "get", "(", "'account/usage'", ",", "$", "params", ")", ";", "}" ]
Returns the user agent this library should use for all API calls. @return string
[ "Returns", "the", "user", "agent", "this", "library", "should", "use", "for", "all", "API", "calls", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Account.php#L57-L72
15,603
crossjoin/Css
src/Crossjoin/Css/Format/Rule/TraitDeclarations.php
TraitDeclarations.setDeclarations
public function setDeclarations($declarations) { $this->declarations = []; if (!is_array($declarations)) { $declarations = [$declarations]; } foreach ($declarations as $declaration) { $this->addDeclaration($declaration); } return $this; }
php
public function setDeclarations($declarations) { $this->declarations = []; if (!is_array($declarations)) { $declarations = [$declarations]; } foreach ($declarations as $declaration) { $this->addDeclaration($declaration); } return $this; }
[ "public", "function", "setDeclarations", "(", "$", "declarations", ")", "{", "$", "this", "->", "declarations", "=", "[", "]", ";", "if", "(", "!", "is_array", "(", "$", "declarations", ")", ")", "{", "$", "declarations", "=", "[", "$", "declarations", "]", ";", "}", "foreach", "(", "$", "declarations", "as", "$", "declaration", ")", "{", "$", "this", "->", "addDeclaration", "(", "$", "declaration", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the declarations. @param DeclarationAbstract[]|DeclarationAbstract $declarations @return $this
[ "Sets", "the", "declarations", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/TraitDeclarations.php#L17-L28
15,604
Atlantic18/CoralCoreBundle
Service/Request/Response.php
Response.parserHttpHeadersAsArray
protected function parserHttpHeadersAsArray($rawHeaders) { $headers = array(); foreach(explode("\n", $rawHeaders) as $i => $line) { if($i == 0) { $headers['HTTP_STATUS'] = substr($line, 9, 3); } else { list($key, $value) = explode(': ', $line); $headers[trim($key)] = trim($value); } } return $headers; }
php
protected function parserHttpHeadersAsArray($rawHeaders) { $headers = array(); foreach(explode("\n", $rawHeaders) as $i => $line) { if($i == 0) { $headers['HTTP_STATUS'] = substr($line, 9, 3); } else { list($key, $value) = explode(': ', $line); $headers[trim($key)] = trim($value); } } return $headers; }
[ "protected", "function", "parserHttpHeadersAsArray", "(", "$", "rawHeaders", ")", "{", "$", "headers", "=", "array", "(", ")", ";", "foreach", "(", "explode", "(", "\"\\n\"", ",", "$", "rawHeaders", ")", "as", "$", "i", "=>", "$", "line", ")", "{", "if", "(", "$", "i", "==", "0", ")", "{", "$", "headers", "[", "'HTTP_STATUS'", "]", "=", "substr", "(", "$", "line", ",", "9", ",", "3", ")", ";", "}", "else", "{", "list", "(", "$", "key", ",", "$", "value", ")", "=", "explode", "(", "': '", ",", "$", "line", ")", ";", "$", "headers", "[", "trim", "(", "$", "key", ")", "]", "=", "trim", "(", "$", "value", ")", ";", "}", "}", "return", "$", "headers", ";", "}" ]
Convert string headers into an array @param string $rawHeaders @return array HTTP Headers
[ "Convert", "string", "headers", "into", "an", "array" ]
7d74ffaf51046ad13cbfc2b0b69d656a499f38ab
https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Service/Request/Response.php#L51-L69
15,605
opis/utils
lib/Mutex.php
Mutex.lock
public function lock() { if ($this->fp === null) { $this->fp = fopen($this->file, 'r'); } return flock($this->fp, LOCK_EX); }
php
public function lock() { if ($this->fp === null) { $this->fp = fopen($this->file, 'r'); } return flock($this->fp, LOCK_EX); }
[ "public", "function", "lock", "(", ")", "{", "if", "(", "$", "this", "->", "fp", "===", "null", ")", "{", "$", "this", "->", "fp", "=", "fopen", "(", "$", "this", "->", "file", ",", "'r'", ")", ";", "}", "return", "flock", "(", "$", "this", "->", "fp", ",", "LOCK_EX", ")", ";", "}" ]
Aquire the mutex @return boolean
[ "Aquire", "the", "mutex" ]
239cd3dc3760eb746838011e712592700fe5d58c
https://github.com/opis/utils/blob/239cd3dc3760eb746838011e712592700fe5d58c/lib/Mutex.php#L73-L80
15,606
opis/utils
lib/Mutex.php
Mutex.unlock
public function unlock() { if ($this->fp !== null) { flock($this->fp, LOCK_UN); fclose($this->fp); $this->fp = null; } return true; }
php
public function unlock() { if ($this->fp !== null) { flock($this->fp, LOCK_UN); fclose($this->fp); $this->fp = null; } return true; }
[ "public", "function", "unlock", "(", ")", "{", "if", "(", "$", "this", "->", "fp", "!==", "null", ")", "{", "flock", "(", "$", "this", "->", "fp", ",", "LOCK_UN", ")", ";", "fclose", "(", "$", "this", "->", "fp", ")", ";", "$", "this", "->", "fp", "=", "null", ";", "}", "return", "true", ";", "}" ]
Realese the mutex @return boolean
[ "Realese", "the", "mutex" ]
239cd3dc3760eb746838011e712592700fe5d58c
https://github.com/opis/utils/blob/239cd3dc3760eb746838011e712592700fe5d58c/lib/Mutex.php#L87-L96
15,607
harp-orm/query
src/Compiler/Update.php
Update.render
public static function render(Query\Update $query) { return Compiler::withDb($query->getDb(), function () use ($query) { return Compiler::expression(array( 'UPDATE', $query->getType(), Aliased::combine($query->getTable()), Join::combine($query->getJoin()), Compiler::word('SET', Set::combine($query->getSet())), Compiler::word('WHERE', Condition::combine($query->getWhere())), Compiler::word('ORDER BY', Direction::combine($query->getOrder())), Compiler::word('LIMIT', $query->getLimit()), )); }); }
php
public static function render(Query\Update $query) { return Compiler::withDb($query->getDb(), function () use ($query) { return Compiler::expression(array( 'UPDATE', $query->getType(), Aliased::combine($query->getTable()), Join::combine($query->getJoin()), Compiler::word('SET', Set::combine($query->getSet())), Compiler::word('WHERE', Condition::combine($query->getWhere())), Compiler::word('ORDER BY', Direction::combine($query->getOrder())), Compiler::word('LIMIT', $query->getLimit()), )); }); }
[ "public", "static", "function", "render", "(", "Query", "\\", "Update", "$", "query", ")", "{", "return", "Compiler", "::", "withDb", "(", "$", "query", "->", "getDb", "(", ")", ",", "function", "(", ")", "use", "(", "$", "query", ")", "{", "return", "Compiler", "::", "expression", "(", "array", "(", "'UPDATE'", ",", "$", "query", "->", "getType", "(", ")", ",", "Aliased", "::", "combine", "(", "$", "query", "->", "getTable", "(", ")", ")", ",", "Join", "::", "combine", "(", "$", "query", "->", "getJoin", "(", ")", ")", ",", "Compiler", "::", "word", "(", "'SET'", ",", "Set", "::", "combine", "(", "$", "query", "->", "getSet", "(", ")", ")", ")", ",", "Compiler", "::", "word", "(", "'WHERE'", ",", "Condition", "::", "combine", "(", "$", "query", "->", "getWhere", "(", ")", ")", ")", ",", "Compiler", "::", "word", "(", "'ORDER BY'", ",", "Direction", "::", "combine", "(", "$", "query", "->", "getOrder", "(", ")", ")", ")", ",", "Compiler", "::", "word", "(", "'LIMIT'", ",", "$", "query", "->", "getLimit", "(", ")", ")", ",", ")", ")", ";", "}", ")", ";", "}" ]
Render Update object @param Query\Update $query @return string
[ "Render", "Update", "object" ]
98ce2468a0a31fe15ed3692bad32547bf6dbe41a
https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Update.php#L19-L33
15,608
tonicospinelli/class-generation
src/ClassGeneration/UseCollection.php
UseCollection.toString
public function toString() { $uses = $this->getIterator(); $string = ''; foreach ($uses as $use) { $string .= $use->toString(); } return $string; }
php
public function toString() { $uses = $this->getIterator(); $string = ''; foreach ($uses as $use) { $string .= $use->toString(); } return $string; }
[ "public", "function", "toString", "(", ")", "{", "$", "uses", "=", "$", "this", "->", "getIterator", "(", ")", ";", "$", "string", "=", "''", ";", "foreach", "(", "$", "uses", "as", "$", "use", ")", "{", "$", "string", ".=", "$", "use", "->", "toString", "(", ")", ";", "}", "return", "$", "string", ";", "}" ]
Parse the Uses to string; @return string
[ "Parse", "the", "Uses", "to", "string", ";" ]
eee63bdb68c066b25b885b57b23656e809381a76
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/UseCollection.php#L67-L76
15,609
harp-orm/query
src/Compiler/Values.php
Values.render
public static function render(SQL\Values $item) { $placeholders = array_fill(0, count($item->getParameters()), '?'); return '('.join(', ', $placeholders).')'; }
php
public static function render(SQL\Values $item) { $placeholders = array_fill(0, count($item->getParameters()), '?'); return '('.join(', ', $placeholders).')'; }
[ "public", "static", "function", "render", "(", "SQL", "\\", "Values", "$", "item", ")", "{", "$", "placeholders", "=", "array_fill", "(", "0", ",", "count", "(", "$", "item", "->", "getParameters", "(", ")", ")", ",", "'?'", ")", ";", "return", "'('", ".", "join", "(", "', '", ",", "$", "placeholders", ")", ".", "')'", ";", "}" ]
Render Values object @param SQL\Values $item @return string
[ "Render", "Values", "object" ]
98ce2468a0a31fe15ed3692bad32547bf6dbe41a
https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Values.php#L30-L35
15,610
e0ipso/drupal-unit-autoload
src/Loader.php
Loader.autoloadPaths
protected function autoloadPaths($class) { $class = static::unprefixClass($class); // If the class that PHP is trying to find is not in the class map, built // from the composer configuration, then bail. if (!in_array($class, array_keys($this->classMap))) { return FALSE; } try { $resolver = $this->tokenResolverFactory->factory($this->classMap[$class]); $finder = $resolver->resolve(); // Have the path finder require the file and return TRUE or FALSE if it // found the file or not. $finder->requireFile($this->seed); return TRUE; } catch (ClassLoaderException $e) { // If there was an error, inform PHP that the class could not be found. return FALSE; } }
php
protected function autoloadPaths($class) { $class = static::unprefixClass($class); // If the class that PHP is trying to find is not in the class map, built // from the composer configuration, then bail. if (!in_array($class, array_keys($this->classMap))) { return FALSE; } try { $resolver = $this->tokenResolverFactory->factory($this->classMap[$class]); $finder = $resolver->resolve(); // Have the path finder require the file and return TRUE or FALSE if it // found the file or not. $finder->requireFile($this->seed); return TRUE; } catch (ClassLoaderException $e) { // If there was an error, inform PHP that the class could not be found. return FALSE; } }
[ "protected", "function", "autoloadPaths", "(", "$", "class", ")", "{", "$", "class", "=", "static", "::", "unprefixClass", "(", "$", "class", ")", ";", "// If the class that PHP is trying to find is not in the class map, built", "// from the composer configuration, then bail.", "if", "(", "!", "in_array", "(", "$", "class", ",", "array_keys", "(", "$", "this", "->", "classMap", ")", ")", ")", "{", "return", "FALSE", ";", "}", "try", "{", "$", "resolver", "=", "$", "this", "->", "tokenResolverFactory", "->", "factory", "(", "$", "this", "->", "classMap", "[", "$", "class", "]", ")", ";", "$", "finder", "=", "$", "resolver", "->", "resolve", "(", ")", ";", "// Have the path finder require the file and return TRUE or FALSE if it", "// found the file or not.", "$", "finder", "->", "requireFile", "(", "$", "this", "->", "seed", ")", ";", "return", "TRUE", ";", "}", "catch", "(", "ClassLoaderException", "$", "e", ")", "{", "// If there was an error, inform PHP that the class could not be found.", "return", "FALSE", ";", "}", "}" ]
Helper function to autoload path based files. @param string $class The requested class. @return bool TRUE if the class was found. FALSE otherwise.
[ "Helper", "function", "to", "autoload", "path", "based", "files", "." ]
7ce147b269c7333eca31e2cd04b736d6274b9cbf
https://github.com/e0ipso/drupal-unit-autoload/blob/7ce147b269c7333eca31e2cd04b736d6274b9cbf/src/Loader.php#L129-L148
15,611
czim/laravel-pxlcms
src/Generator/Writer/Model/ModelWriterContext.php
ModelWriterContext.getConfigNameForStandardModelType
protected function getConfigNameForStandardModelType($type) { switch ($type) { case CmsModel::RELATION_TYPE_IMAGE: return 'image'; case CmsModel::RELATION_TYPE_FILE: return 'file'; case CmsModel::RELATION_TYPE_CATEGORY: return 'category'; case CmsModel::RELATION_TYPE_CHECKBOX: return 'checkbox'; // default omitted on purpose } return null; }
php
protected function getConfigNameForStandardModelType($type) { switch ($type) { case CmsModel::RELATION_TYPE_IMAGE: return 'image'; case CmsModel::RELATION_TYPE_FILE: return 'file'; case CmsModel::RELATION_TYPE_CATEGORY: return 'category'; case CmsModel::RELATION_TYPE_CHECKBOX: return 'checkbox'; // default omitted on purpose } return null; }
[ "protected", "function", "getConfigNameForStandardModelType", "(", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "CmsModel", "::", "RELATION_TYPE_IMAGE", ":", "return", "'image'", ";", "case", "CmsModel", "::", "RELATION_TYPE_FILE", ":", "return", "'file'", ";", "case", "CmsModel", "::", "RELATION_TYPE_CATEGORY", ":", "return", "'category'", ";", "case", "CmsModel", "::", "RELATION_TYPE_CHECKBOX", ":", "return", "'checkbox'", ";", "// default omitted on purpose", "}", "return", "null", ";", "}" ]
Returns the special model type name used for config properties based on CmsModel const values for RELATION_TYPEs @param int $type @return null|string
[ "Returns", "the", "special", "model", "type", "name", "used", "for", "config", "properties", "based", "on", "CmsModel", "const", "values", "for", "RELATION_TYPEs" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/ModelWriterContext.php#L104-L124
15,612
fuelphp/display
src/ViewManager.php
ViewManager.configure
protected function configure(array $config) { if (isset($config['parsers'])) { $this->registerParsers($config['parsers']); } if (isset($config['cache'])) { $this->cachePath = rtrim('cache', '\\/').DIRECTORY_SEPARATOR; } if (isset($config['auto_filter'])) { $this->autoFilter = (bool) $config['auto_filter']; } if (isset($config['view_folder'])) { $this->setViewFolder($config['view_folder']); } if (isset($config['whitelist'])) { $this->whitelist($config['whitelist']); } }
php
protected function configure(array $config) { if (isset($config['parsers'])) { $this->registerParsers($config['parsers']); } if (isset($config['cache'])) { $this->cachePath = rtrim('cache', '\\/').DIRECTORY_SEPARATOR; } if (isset($config['auto_filter'])) { $this->autoFilter = (bool) $config['auto_filter']; } if (isset($config['view_folder'])) { $this->setViewFolder($config['view_folder']); } if (isset($config['whitelist'])) { $this->whitelist($config['whitelist']); } }
[ "protected", "function", "configure", "(", "array", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'parsers'", "]", ")", ")", "{", "$", "this", "->", "registerParsers", "(", "$", "config", "[", "'parsers'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'cache'", "]", ")", ")", "{", "$", "this", "->", "cachePath", "=", "rtrim", "(", "'cache'", ",", "'\\\\/'", ")", ".", "DIRECTORY_SEPARATOR", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'auto_filter'", "]", ")", ")", "{", "$", "this", "->", "autoFilter", "=", "(", "bool", ")", "$", "config", "[", "'auto_filter'", "]", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'view_folder'", "]", ")", ")", "{", "$", "this", "->", "setViewFolder", "(", "$", "config", "[", "'view_folder'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'whitelist'", "]", ")", ")", "{", "$", "this", "->", "whitelist", "(", "$", "config", "[", "'whitelist'", "]", ")", ";", "}", "}" ]
Configures the view manager @param array $config
[ "Configures", "the", "view", "manager" ]
d9a3eddbf80f0fd81beb40d9f4507600ac6611a4
https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/ViewManager.php#L59-L85
15,613
fuelphp/display
src/ViewManager.php
ViewManager.whitelist
public function whitelist($classes) { if ( ! is_array($classes)) { $classes = func_get_args(); } $this->whitelist = array_unique(array_merge($this->whitelist, $classes)); }
php
public function whitelist($classes) { if ( ! is_array($classes)) { $classes = func_get_args(); } $this->whitelist = array_unique(array_merge($this->whitelist, $classes)); }
[ "public", "function", "whitelist", "(", "$", "classes", ")", "{", "if", "(", "!", "is_array", "(", "$", "classes", ")", ")", "{", "$", "classes", "=", "func_get_args", "(", ")", ";", "}", "$", "this", "->", "whitelist", "=", "array_unique", "(", "array_merge", "(", "$", "this", "->", "whitelist", ",", "$", "classes", ")", ")", ";", "}" ]
Adds the given classes to the whitelist. @param string[] $classes
[ "Adds", "the", "given", "classes", "to", "the", "whitelist", "." ]
d9a3eddbf80f0fd81beb40d9f4507600ac6611a4
https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/ViewManager.php#L102-L110
15,614
fuelphp/display
src/ViewManager.php
ViewManager.registerParser
public function registerParser($extension, Parser $parser) { if ($parser instanceof ViewManagerAware) { $parser->setViewManager($this); } $this->parsers[$extension] = $parser; }
php
public function registerParser($extension, Parser $parser) { if ($parser instanceof ViewManagerAware) { $parser->setViewManager($this); } $this->parsers[$extension] = $parser; }
[ "public", "function", "registerParser", "(", "$", "extension", ",", "Parser", "$", "parser", ")", "{", "if", "(", "$", "parser", "instanceof", "ViewManagerAware", ")", "{", "$", "parser", "->", "setViewManager", "(", "$", "this", ")", ";", "}", "$", "this", "->", "parsers", "[", "$", "extension", "]", "=", "$", "parser", ";", "}" ]
Registers a new parser for rendering a given file type @param string $extension @param Parser $parser
[ "Registers", "a", "new", "parser", "for", "rendering", "a", "given", "file", "type" ]
d9a3eddbf80f0fd81beb40d9f4507600ac6611a4
https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/ViewManager.php#L118-L126
15,615
fuelphp/display
src/ViewManager.php
ViewManager.registerParsers
public function registerParsers(array $parsers) { foreach ($parsers as $extension => $parser) { $this->registerParser($extension, $parser); } }
php
public function registerParsers(array $parsers) { foreach ($parsers as $extension => $parser) { $this->registerParser($extension, $parser); } }
[ "public", "function", "registerParsers", "(", "array", "$", "parsers", ")", "{", "foreach", "(", "$", "parsers", "as", "$", "extension", "=>", "$", "parser", ")", "{", "$", "this", "->", "registerParser", "(", "$", "extension", ",", "$", "parser", ")", ";", "}", "}" ]
Registers multiple parsers at once @param array $parsers Key as the file extension and value as the parser instance
[ "Registers", "multiple", "parsers", "at", "once" ]
d9a3eddbf80f0fd81beb40d9f4507600ac6611a4
https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/ViewManager.php#L133-L139
15,616
fuelphp/display
src/ViewManager.php
ViewManager.findView
public function findView($view) { $view = $this->viewFolder.DIRECTORY_SEPARATOR.ltrim($view, DIRECTORY_SEPARATOR); return $this->finder->findFileReversed($view); }
php
public function findView($view) { $view = $this->viewFolder.DIRECTORY_SEPARATOR.ltrim($view, DIRECTORY_SEPARATOR); return $this->finder->findFileReversed($view); }
[ "public", "function", "findView", "(", "$", "view", ")", "{", "$", "view", "=", "$", "this", "->", "viewFolder", ".", "DIRECTORY_SEPARATOR", ".", "ltrim", "(", "$", "view", ",", "DIRECTORY_SEPARATOR", ")", ";", "return", "$", "this", "->", "finder", "->", "findFileReversed", "(", "$", "view", ")", ";", "}" ]
Attempts to get the file name for the given view @param $view @return array|\Fuel\FileSystem\Directory|\Fuel\FileSystem\File|string
[ "Attempts", "to", "get", "the", "file", "name", "for", "the", "given", "view" ]
d9a3eddbf80f0fd81beb40d9f4507600ac6611a4
https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/ViewManager.php#L191-L196
15,617
fuelphp/display
src/ViewManager.php
ViewManager.forge
public function forge($view, array $data = null, $filter = null) { if ( ! $file = $this->findView($view)) { throw new Exception\ViewNotFound('Could not locate view: '.$view); } if ($filter === null) { $filter = $this->autoFilter; } $extension = pathinfo($file, PATHINFO_EXTENSION); if ( ! isset($this->parsers[$extension])) { throw new \DomainException('Could not find parser for extension: '.$extension); } $parser = $this->parsers[$extension]; $view = new View($this, $parser, $file, $filter); if ($data) { $view->set($data); } return $view; }
php
public function forge($view, array $data = null, $filter = null) { if ( ! $file = $this->findView($view)) { throw new Exception\ViewNotFound('Could not locate view: '.$view); } if ($filter === null) { $filter = $this->autoFilter; } $extension = pathinfo($file, PATHINFO_EXTENSION); if ( ! isset($this->parsers[$extension])) { throw new \DomainException('Could not find parser for extension: '.$extension); } $parser = $this->parsers[$extension]; $view = new View($this, $parser, $file, $filter); if ($data) { $view->set($data); } return $view; }
[ "public", "function", "forge", "(", "$", "view", ",", "array", "$", "data", "=", "null", ",", "$", "filter", "=", "null", ")", "{", "if", "(", "!", "$", "file", "=", "$", "this", "->", "findView", "(", "$", "view", ")", ")", "{", "throw", "new", "Exception", "\\", "ViewNotFound", "(", "'Could not locate view: '", ".", "$", "view", ")", ";", "}", "if", "(", "$", "filter", "===", "null", ")", "{", "$", "filter", "=", "$", "this", "->", "autoFilter", ";", "}", "$", "extension", "=", "pathinfo", "(", "$", "file", ",", "PATHINFO_EXTENSION", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "parsers", "[", "$", "extension", "]", ")", ")", "{", "throw", "new", "\\", "DomainException", "(", "'Could not find parser for extension: '", ".", "$", "extension", ")", ";", "}", "$", "parser", "=", "$", "this", "->", "parsers", "[", "$", "extension", "]", ";", "$", "view", "=", "new", "View", "(", "$", "this", ",", "$", "parser", ",", "$", "file", ",", "$", "filter", ")", ";", "if", "(", "$", "data", ")", "{", "$", "view", "->", "set", "(", "$", "data", ")", ";", "}", "return", "$", "view", ";", "}" ]
Attempts to find and load the given view @param string $view @param array $data @param null|bool $filter @return View @throws Exception\ViewNotFound If the given view cannot be found @throws \DomainException If a parser for the view cannot be found
[ "Attempts", "to", "find", "and", "load", "the", "given", "view" ]
d9a3eddbf80f0fd81beb40d9f4507600ac6611a4
https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/ViewManager.php#L210-L238
15,618
czim/laravel-pxlcms
src/Models/CmsModel.php
CmsModel.getCmsReferenceKeyForRelation
public function getCmsReferenceKeyForRelation($relation, $reversed = false) { $isParent = ( array_key_exists($relation, $this->relationsConfig) && array_key_exists('parent', $this->relationsConfig[$relation]) && (bool) $this->relationsConfig[$relation]['parent'] ); if ($reversed) { $isParent = ! $isParent; } return $isParent ? config('pxlcms.relations.references.keys.to', 'to_entry_id') : config('pxlcms.relations.references.keys.from', 'from_entry_id'); }
php
public function getCmsReferenceKeyForRelation($relation, $reversed = false) { $isParent = ( array_key_exists($relation, $this->relationsConfig) && array_key_exists('parent', $this->relationsConfig[$relation]) && (bool) $this->relationsConfig[$relation]['parent'] ); if ($reversed) { $isParent = ! $isParent; } return $isParent ? config('pxlcms.relations.references.keys.to', 'to_entry_id') : config('pxlcms.relations.references.keys.from', 'from_entry_id'); }
[ "public", "function", "getCmsReferenceKeyForRelation", "(", "$", "relation", ",", "$", "reversed", "=", "false", ")", "{", "$", "isParent", "=", "(", "array_key_exists", "(", "$", "relation", ",", "$", "this", "->", "relationsConfig", ")", "&&", "array_key_exists", "(", "'parent'", ",", "$", "this", "->", "relationsConfig", "[", "$", "relation", "]", ")", "&&", "(", "bool", ")", "$", "this", "->", "relationsConfig", "[", "$", "relation", "]", "[", "'parent'", "]", ")", ";", "if", "(", "$", "reversed", ")", "{", "$", "isParent", "=", "!", "$", "isParent", ";", "}", "return", "$", "isParent", "?", "config", "(", "'pxlcms.relations.references.keys.to'", ",", "'to_entry_id'", ")", ":", "config", "(", "'pxlcms.relations.references.keys.from'", ",", "'from_entry_id'", ")", ";", "}" ]
Get standard belongsToMany reference key name for 'from' and 'to' models Reversed gives the 'to' key @param string $relation @param bool $reversed (default: false) @return string
[ "Get", "standard", "belongsToMany", "reference", "key", "name", "for", "from", "and", "to", "models", "Reversed", "gives", "the", "to", "key" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/CmsModel.php#L276-L290
15,619
czim/laravel-pxlcms
src/Models/CmsModel.php
CmsModel.getCmsReferenceFieldId
public function getCmsReferenceFieldId($relation) { if ( ! array_key_exists($relation, $this->relationsConfig) || ! array_key_exists('field', $this->relationsConfig[$relation]) ) { return null; } return (int) $this->relationsConfig[ $relation ]['field']; }
php
public function getCmsReferenceFieldId($relation) { if ( ! array_key_exists($relation, $this->relationsConfig) || ! array_key_exists('field', $this->relationsConfig[$relation]) ) { return null; } return (int) $this->relationsConfig[ $relation ]['field']; }
[ "public", "function", "getCmsReferenceFieldId", "(", "$", "relation", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "relation", ",", "$", "this", "->", "relationsConfig", ")", "||", "!", "array_key_exists", "(", "'field'", ",", "$", "this", "->", "relationsConfig", "[", "$", "relation", "]", ")", ")", "{", "return", "null", ";", "}", "return", "(", "int", ")", "$", "this", "->", "relationsConfig", "[", "$", "relation", "]", "[", "'field'", "]", ";", "}" ]
Returns the configured 'from_field_id' field id value for the reference relation @param string $relation @return int|null
[ "Returns", "the", "configured", "from_field_id", "field", "id", "value", "for", "the", "reference", "relation" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/CmsModel.php#L298-L307
15,620
czim/laravel-pxlcms
src/Models/CmsModel.php
CmsModel.getCmsSpecialRelationType
public function getCmsSpecialRelationType($relation) { if ( ! array_key_exists($relation, $this->relationsConfig) || ! array_key_exists('type', $this->relationsConfig[$relation]) ) { return null; } return $this->relationsConfig[ $relation ]['type']; }
php
public function getCmsSpecialRelationType($relation) { if ( ! array_key_exists($relation, $this->relationsConfig) || ! array_key_exists('type', $this->relationsConfig[$relation]) ) { return null; } return $this->relationsConfig[ $relation ]['type']; }
[ "public", "function", "getCmsSpecialRelationType", "(", "$", "relation", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "relation", ",", "$", "this", "->", "relationsConfig", ")", "||", "!", "array_key_exists", "(", "'type'", ",", "$", "this", "->", "relationsConfig", "[", "$", "relation", "]", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "relationsConfig", "[", "$", "relation", "]", "[", "'type'", "]", ";", "}" ]
Returns the configured special standard model type for the reference relation @param string $relation @return string|null
[ "Returns", "the", "configured", "special", "standard", "model", "type", "for", "the", "reference", "relation" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/CmsModel.php#L315-L324
15,621
czim/laravel-pxlcms
src/Models/CmsModel.php
CmsModel.belongsTo
public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null) { // If no relation name was given, we will use this debug backtrace to extract // the calling method's name and use that as the relationship name as most // of the time this will be what we desire to use for the relationships. if (is_null($relation)) { list($current, $caller) = debug_backtrace(false, 2); $relation = $caller['function']; } $specialType = $this->getCmsSpecialRelationType($relation); // If no foreign key was supplied, we can use a backtrace to guess the proper // foreign key name by using the name of the relationship function, which // when combined with an "_id" should conventionally match the columns. if (is_null($foreignKey)) { if ($specialType === self::RELATION_TYPE_CATEGORY) { $foreignKey = config('pxlcms.relations.categories.keys.category'); } else { $foreignKey = Str::snake($relation); } } // If the relation name is the same (casing aside) as the foreign key attribute, // we must make sure that the foreign key property is at least a key in the // attributes array. If it is not, there will be recursive lookup problems // where the attribute is never resolved and 'property does not exist' exceptions occur. if ( snake_case($relation) == $foreignKey && ! array_key_exists($foreignKey, $this->attributes) ) { $this->attributes[ $foreignKey ] = null; } /** @var Builder $belongsTo */ $belongsTo = parent::belongsTo($related, $foreignKey, $otherKey, $relation); // category relation must be filtered by module id if ($specialType === self::RELATION_TYPE_CATEGORY) { $belongsTo->where( config('pxlcms.relations.categories.keys.module'), $this->getModuleNumber() ); } return $belongsTo; }
php
public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null) { // If no relation name was given, we will use this debug backtrace to extract // the calling method's name and use that as the relationship name as most // of the time this will be what we desire to use for the relationships. if (is_null($relation)) { list($current, $caller) = debug_backtrace(false, 2); $relation = $caller['function']; } $specialType = $this->getCmsSpecialRelationType($relation); // If no foreign key was supplied, we can use a backtrace to guess the proper // foreign key name by using the name of the relationship function, which // when combined with an "_id" should conventionally match the columns. if (is_null($foreignKey)) { if ($specialType === self::RELATION_TYPE_CATEGORY) { $foreignKey = config('pxlcms.relations.categories.keys.category'); } else { $foreignKey = Str::snake($relation); } } // If the relation name is the same (casing aside) as the foreign key attribute, // we must make sure that the foreign key property is at least a key in the // attributes array. If it is not, there will be recursive lookup problems // where the attribute is never resolved and 'property does not exist' exceptions occur. if ( snake_case($relation) == $foreignKey && ! array_key_exists($foreignKey, $this->attributes) ) { $this->attributes[ $foreignKey ] = null; } /** @var Builder $belongsTo */ $belongsTo = parent::belongsTo($related, $foreignKey, $otherKey, $relation); // category relation must be filtered by module id if ($specialType === self::RELATION_TYPE_CATEGORY) { $belongsTo->where( config('pxlcms.relations.categories.keys.module'), $this->getModuleNumber() ); } return $belongsTo; }
[ "public", "function", "belongsTo", "(", "$", "related", ",", "$", "foreignKey", "=", "null", ",", "$", "otherKey", "=", "null", ",", "$", "relation", "=", "null", ")", "{", "// If no relation name was given, we will use this debug backtrace to extract", "// the calling method's name and use that as the relationship name as most", "// of the time this will be what we desire to use for the relationships.", "if", "(", "is_null", "(", "$", "relation", ")", ")", "{", "list", "(", "$", "current", ",", "$", "caller", ")", "=", "debug_backtrace", "(", "false", ",", "2", ")", ";", "$", "relation", "=", "$", "caller", "[", "'function'", "]", ";", "}", "$", "specialType", "=", "$", "this", "->", "getCmsSpecialRelationType", "(", "$", "relation", ")", ";", "// If no foreign key was supplied, we can use a backtrace to guess the proper", "// foreign key name by using the name of the relationship function, which", "// when combined with an \"_id\" should conventionally match the columns.", "if", "(", "is_null", "(", "$", "foreignKey", ")", ")", "{", "if", "(", "$", "specialType", "===", "self", "::", "RELATION_TYPE_CATEGORY", ")", "{", "$", "foreignKey", "=", "config", "(", "'pxlcms.relations.categories.keys.category'", ")", ";", "}", "else", "{", "$", "foreignKey", "=", "Str", "::", "snake", "(", "$", "relation", ")", ";", "}", "}", "// If the relation name is the same (casing aside) as the foreign key attribute,", "// we must make sure that the foreign key property is at least a key in the", "// attributes array. If it is not, there will be recursive lookup problems", "// where the attribute is never resolved and 'property does not exist' exceptions occur.", "if", "(", "snake_case", "(", "$", "relation", ")", "==", "$", "foreignKey", "&&", "!", "array_key_exists", "(", "$", "foreignKey", ",", "$", "this", "->", "attributes", ")", ")", "{", "$", "this", "->", "attributes", "[", "$", "foreignKey", "]", "=", "null", ";", "}", "/** @var Builder $belongsTo */", "$", "belongsTo", "=", "parent", "::", "belongsTo", "(", "$", "related", ",", "$", "foreignKey", ",", "$", "otherKey", ",", "$", "relation", ")", ";", "// category relation must be filtered by module id", "if", "(", "$", "specialType", "===", "self", "::", "RELATION_TYPE_CATEGORY", ")", "{", "$", "belongsTo", "->", "where", "(", "config", "(", "'pxlcms.relations.categories.keys.module'", ")", ",", "$", "this", "->", "getModuleNumber", "(", ")", ")", ";", "}", "return", "$", "belongsTo", ";", "}" ]
Override for different naming convention @param string $related @param string $foreignKey @param string $otherKey @param string $relation @return \Illuminate\Database\Eloquent\Relations\BelongsTo
[ "Override", "for", "different", "naming", "convention" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/CmsModel.php#L354-L400
15,622
czim/laravel-pxlcms
src/Models/CmsModel.php
CmsModel.belongsToMany
public function belongsToMany($related, $table = null, $foreignKey = null, $otherKey = null, $relation = null) { // If no relationship name was passed, we will pull backtraces to get the // name of the calling function. We will use that function name as the // title of this relation since that is a great convention to apply. if (is_null($relation)) { $relation = $this->getBelongsToManyCaller(); } $foreignKey = $foreignKey ?: $this->getCmsReferenceKeyForRelation($relation); $otherKey = $otherKey ?: $this->getCmsReferenceKeyForRelation($relation, true); if (is_null($table)) { $table = $this->getCmsJoiningTable(); } $fieldId = $this->getCmsReferenceFieldId($relation); if (empty($fieldId)) { throw new InvalidArgumentException("No 'field' id configured for relation/reference: '{$relation}'!"); } // originally, it was possible to just get the parent's BelongsToMany instance, but // to avoid problems when saving on the relationship, we need a specialized extension // of the relation class for the CMS. //$belongsToMany = parent::belongsToMany($related, $table, $foreignKey, $otherKey); /** @var Model $instance */ $instance = new $related; $query = $instance->newQuery(); $belongsToMany = new BelongsToMany($query, $this, $table, $foreignKey, $otherKey, $relation, $fieldId); // add constraints $belongsToMany->wherePivot(config('pxlcms.relations.references.keys.field', 'from_field_id'), $fieldId); return $belongsToMany; }
php
public function belongsToMany($related, $table = null, $foreignKey = null, $otherKey = null, $relation = null) { // If no relationship name was passed, we will pull backtraces to get the // name of the calling function. We will use that function name as the // title of this relation since that is a great convention to apply. if (is_null($relation)) { $relation = $this->getBelongsToManyCaller(); } $foreignKey = $foreignKey ?: $this->getCmsReferenceKeyForRelation($relation); $otherKey = $otherKey ?: $this->getCmsReferenceKeyForRelation($relation, true); if (is_null($table)) { $table = $this->getCmsJoiningTable(); } $fieldId = $this->getCmsReferenceFieldId($relation); if (empty($fieldId)) { throw new InvalidArgumentException("No 'field' id configured for relation/reference: '{$relation}'!"); } // originally, it was possible to just get the parent's BelongsToMany instance, but // to avoid problems when saving on the relationship, we need a specialized extension // of the relation class for the CMS. //$belongsToMany = parent::belongsToMany($related, $table, $foreignKey, $otherKey); /** @var Model $instance */ $instance = new $related; $query = $instance->newQuery(); $belongsToMany = new BelongsToMany($query, $this, $table, $foreignKey, $otherKey, $relation, $fieldId); // add constraints $belongsToMany->wherePivot(config('pxlcms.relations.references.keys.field', 'from_field_id'), $fieldId); return $belongsToMany; }
[ "public", "function", "belongsToMany", "(", "$", "related", ",", "$", "table", "=", "null", ",", "$", "foreignKey", "=", "null", ",", "$", "otherKey", "=", "null", ",", "$", "relation", "=", "null", ")", "{", "// If no relationship name was passed, we will pull backtraces to get the", "// name of the calling function. We will use that function name as the", "// title of this relation since that is a great convention to apply.", "if", "(", "is_null", "(", "$", "relation", ")", ")", "{", "$", "relation", "=", "$", "this", "->", "getBelongsToManyCaller", "(", ")", ";", "}", "$", "foreignKey", "=", "$", "foreignKey", "?", ":", "$", "this", "->", "getCmsReferenceKeyForRelation", "(", "$", "relation", ")", ";", "$", "otherKey", "=", "$", "otherKey", "?", ":", "$", "this", "->", "getCmsReferenceKeyForRelation", "(", "$", "relation", ",", "true", ")", ";", "if", "(", "is_null", "(", "$", "table", ")", ")", "{", "$", "table", "=", "$", "this", "->", "getCmsJoiningTable", "(", ")", ";", "}", "$", "fieldId", "=", "$", "this", "->", "getCmsReferenceFieldId", "(", "$", "relation", ")", ";", "if", "(", "empty", "(", "$", "fieldId", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"No 'field' id configured for relation/reference: '{$relation}'!\"", ")", ";", "}", "// originally, it was possible to just get the parent's BelongsToMany instance, but", "// to avoid problems when saving on the relationship, we need a specialized extension", "// of the relation class for the CMS.", "//$belongsToMany = parent::belongsToMany($related, $table, $foreignKey, $otherKey);", "/** @var Model $instance */", "$", "instance", "=", "new", "$", "related", ";", "$", "query", "=", "$", "instance", "->", "newQuery", "(", ")", ";", "$", "belongsToMany", "=", "new", "BelongsToMany", "(", "$", "query", ",", "$", "this", ",", "$", "table", ",", "$", "foreignKey", ",", "$", "otherKey", ",", "$", "relation", ",", "$", "fieldId", ")", ";", "// add constraints", "$", "belongsToMany", "->", "wherePivot", "(", "config", "(", "'pxlcms.relations.references.keys.field'", ",", "'from_field_id'", ")", ",", "$", "fieldId", ")", ";", "return", "$", "belongsToMany", ";", "}" ]
Override for special cms_m_references 'pivot' table @param string $related @param string $table @param string $foreignKey @param string $otherKey @param string $relation @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
[ "Override", "for", "special", "cms_m_references", "pivot", "table" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/CmsModel.php#L412-L449
15,623
czim/laravel-pxlcms
src/Models/CmsModel.php
CmsModel.belongsToManyNormal
public function belongsToManyNormal($related, $table = null, $foreignKey = null, $otherKey = null, $relation = null) { return parent::belongsToMany($related, $table, $foreignKey, $otherKey, $relation); }
php
public function belongsToManyNormal($related, $table = null, $foreignKey = null, $otherKey = null, $relation = null) { return parent::belongsToMany($related, $table, $foreignKey, $otherKey, $relation); }
[ "public", "function", "belongsToManyNormal", "(", "$", "related", ",", "$", "table", "=", "null", ",", "$", "foreignKey", "=", "null", ",", "$", "otherKey", "=", "null", ",", "$", "relation", "=", "null", ")", "{", "return", "parent", "::", "belongsToMany", "(", "$", "related", ",", "$", "table", ",", "$", "foreignKey", ",", "$", "otherKey", ",", "$", "relation", ")", ";", "}" ]
For when you still want to use the 'normal' belongsToMany relationship in a CmsModel that should be related to non-CmsModels in the laravel convention @param string $related @param string $table @param string $foreignKey @param string $otherKey @param string $relation @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
[ "For", "when", "you", "still", "want", "to", "use", "the", "normal", "belongsToMany", "relationship", "in", "a", "CmsModel", "that", "should", "be", "related", "to", "non", "-", "CmsModels", "in", "the", "laravel", "convention" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/CmsModel.php#L462-L465
15,624
czim/laravel-pxlcms
src/Models/CmsModel.php
CmsModel.hasOne
public function hasOne($related, $foreignKey = null, $localKey = null, $locale = null) { $relation = $this->getHasOneOrManyCaller(); if ( ! ($specialType = $this->getCmsSpecialRelationType($relation))) { return parent::hasOne($related, $foreignKey, $localKey); } list($foreignKey, $fieldKey) = $this->getKeysForSpecialRelation($specialType, $foreignKey); $fieldId = $this->getCmsReferenceFieldId($relation); // create the correct hasOne, for special relations that must save field_id values /** @var Builder $hasOne */ if ( $specialType === static::RELATION_TYPE_CHECKBOX || $specialType === static::RELATION_TYPE_FILE || $specialType === static::RELATION_TYPE_IMAGE ) { /** @var Model $instance */ $instance = new $related; $localKey = $localKey ?: $this->getKeyName(); $hasOne = new HasOne( $instance->newQuery(), $this, $instance->getTable() . '.' . $foreignKey, $localKey, $fieldId, $specialType ); } else { $hasOne = parent::hasOne($related, $foreignKey, $localKey); } // add field key for wheres $hasOne->where($fieldKey, $fieldId); // limit to selected locale, if translated if ($this->getCmsSpecialRelationTranslated($relation)) { if (is_null($locale)) $locale = app()->getLocale(); $hasOne->where( config('pxlcms.translatable.locale_key'), $this->lookUpLanguageIdForLocale($locale) ); } return $hasOne; }
php
public function hasOne($related, $foreignKey = null, $localKey = null, $locale = null) { $relation = $this->getHasOneOrManyCaller(); if ( ! ($specialType = $this->getCmsSpecialRelationType($relation))) { return parent::hasOne($related, $foreignKey, $localKey); } list($foreignKey, $fieldKey) = $this->getKeysForSpecialRelation($specialType, $foreignKey); $fieldId = $this->getCmsReferenceFieldId($relation); // create the correct hasOne, for special relations that must save field_id values /** @var Builder $hasOne */ if ( $specialType === static::RELATION_TYPE_CHECKBOX || $specialType === static::RELATION_TYPE_FILE || $specialType === static::RELATION_TYPE_IMAGE ) { /** @var Model $instance */ $instance = new $related; $localKey = $localKey ?: $this->getKeyName(); $hasOne = new HasOne( $instance->newQuery(), $this, $instance->getTable() . '.' . $foreignKey, $localKey, $fieldId, $specialType ); } else { $hasOne = parent::hasOne($related, $foreignKey, $localKey); } // add field key for wheres $hasOne->where($fieldKey, $fieldId); // limit to selected locale, if translated if ($this->getCmsSpecialRelationTranslated($relation)) { if (is_null($locale)) $locale = app()->getLocale(); $hasOne->where( config('pxlcms.translatable.locale_key'), $this->lookUpLanguageIdForLocale($locale) ); } return $hasOne; }
[ "public", "function", "hasOne", "(", "$", "related", ",", "$", "foreignKey", "=", "null", ",", "$", "localKey", "=", "null", ",", "$", "locale", "=", "null", ")", "{", "$", "relation", "=", "$", "this", "->", "getHasOneOrManyCaller", "(", ")", ";", "if", "(", "!", "(", "$", "specialType", "=", "$", "this", "->", "getCmsSpecialRelationType", "(", "$", "relation", ")", ")", ")", "{", "return", "parent", "::", "hasOne", "(", "$", "related", ",", "$", "foreignKey", ",", "$", "localKey", ")", ";", "}", "list", "(", "$", "foreignKey", ",", "$", "fieldKey", ")", "=", "$", "this", "->", "getKeysForSpecialRelation", "(", "$", "specialType", ",", "$", "foreignKey", ")", ";", "$", "fieldId", "=", "$", "this", "->", "getCmsReferenceFieldId", "(", "$", "relation", ")", ";", "// create the correct hasOne, for special relations that must save field_id values", "/** @var Builder $hasOne */", "if", "(", "$", "specialType", "===", "static", "::", "RELATION_TYPE_CHECKBOX", "||", "$", "specialType", "===", "static", "::", "RELATION_TYPE_FILE", "||", "$", "specialType", "===", "static", "::", "RELATION_TYPE_IMAGE", ")", "{", "/** @var Model $instance */", "$", "instance", "=", "new", "$", "related", ";", "$", "localKey", "=", "$", "localKey", "?", ":", "$", "this", "->", "getKeyName", "(", ")", ";", "$", "hasOne", "=", "new", "HasOne", "(", "$", "instance", "->", "newQuery", "(", ")", ",", "$", "this", ",", "$", "instance", "->", "getTable", "(", ")", ".", "'.'", ".", "$", "foreignKey", ",", "$", "localKey", ",", "$", "fieldId", ",", "$", "specialType", ")", ";", "}", "else", "{", "$", "hasOne", "=", "parent", "::", "hasOne", "(", "$", "related", ",", "$", "foreignKey", ",", "$", "localKey", ")", ";", "}", "// add field key for wheres", "$", "hasOne", "->", "where", "(", "$", "fieldKey", ",", "$", "fieldId", ")", ";", "// limit to selected locale, if translated", "if", "(", "$", "this", "->", "getCmsSpecialRelationTranslated", "(", "$", "relation", ")", ")", "{", "if", "(", "is_null", "(", "$", "locale", ")", ")", "$", "locale", "=", "app", "(", ")", "->", "getLocale", "(", ")", ";", "$", "hasOne", "->", "where", "(", "config", "(", "'pxlcms.translatable.locale_key'", ")", ",", "$", "this", "->", "lookUpLanguageIdForLocale", "(", "$", "locale", ")", ")", ";", "}", "return", "$", "hasOne", ";", "}" ]
Overridden to catch special relationships to standard CMS models @param string $related @param string $foreignKey @param string $localKey @param string $locale only used as an override, and only for ML images @return \Illuminate\Database\Eloquent\Relations\HasOne
[ "Overridden", "to", "catch", "special", "relationships", "to", "standard", "CMS", "models" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/CmsModel.php#L537-L589
15,625
czim/laravel-pxlcms
src/Models/CmsModel.php
CmsModel.getKeysForSpecialRelation
protected function getKeysForSpecialRelation($specialType, $foreignKey = null) { switch ($specialType) { case static::RELATION_TYPE_FILE: $foreignKey = $foreignKey ?: config('pxlcms.relations.files.keys.entry'); $secondaryKey = config('pxlcms.relations.files.keys.field'); break; case static::RELATION_TYPE_CHECKBOX: $foreignKey = $foreignKey ?: config('pxlcms.relations.checkboxes.keys.entry'); $secondaryKey = config('pxlcms.relations.checkboxes.keys.field'); break; case static::RELATION_TYPE_IMAGE: default: $foreignKey = $foreignKey ?: config('pxlcms.relations.images.keys.entry'); $secondaryKey = config('pxlcms.relations.images.keys.field'); } return [ $foreignKey, $secondaryKey ]; }
php
protected function getKeysForSpecialRelation($specialType, $foreignKey = null) { switch ($specialType) { case static::RELATION_TYPE_FILE: $foreignKey = $foreignKey ?: config('pxlcms.relations.files.keys.entry'); $secondaryKey = config('pxlcms.relations.files.keys.field'); break; case static::RELATION_TYPE_CHECKBOX: $foreignKey = $foreignKey ?: config('pxlcms.relations.checkboxes.keys.entry'); $secondaryKey = config('pxlcms.relations.checkboxes.keys.field'); break; case static::RELATION_TYPE_IMAGE: default: $foreignKey = $foreignKey ?: config('pxlcms.relations.images.keys.entry'); $secondaryKey = config('pxlcms.relations.images.keys.field'); } return [ $foreignKey, $secondaryKey ]; }
[ "protected", "function", "getKeysForSpecialRelation", "(", "$", "specialType", ",", "$", "foreignKey", "=", "null", ")", "{", "switch", "(", "$", "specialType", ")", "{", "case", "static", "::", "RELATION_TYPE_FILE", ":", "$", "foreignKey", "=", "$", "foreignKey", "?", ":", "config", "(", "'pxlcms.relations.files.keys.entry'", ")", ";", "$", "secondaryKey", "=", "config", "(", "'pxlcms.relations.files.keys.field'", ")", ";", "break", ";", "case", "static", "::", "RELATION_TYPE_CHECKBOX", ":", "$", "foreignKey", "=", "$", "foreignKey", "?", ":", "config", "(", "'pxlcms.relations.checkboxes.keys.entry'", ")", ";", "$", "secondaryKey", "=", "config", "(", "'pxlcms.relations.checkboxes.keys.field'", ")", ";", "break", ";", "case", "static", "::", "RELATION_TYPE_IMAGE", ":", "default", ":", "$", "foreignKey", "=", "$", "foreignKey", "?", ":", "config", "(", "'pxlcms.relations.images.keys.entry'", ")", ";", "$", "secondaryKey", "=", "config", "(", "'pxlcms.relations.images.keys.field'", ")", ";", "}", "return", "[", "$", "foreignKey", ",", "$", "secondaryKey", "]", ";", "}" ]
Get the foreign and field keys for the special relation's standard CMS model @param int $specialType @param string $foreignKey @return array [ foreignKey, secondaryKey ]
[ "Get", "the", "foreign", "and", "field", "keys", "for", "the", "special", "relation", "s", "standard", "CMS", "model" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/CmsModel.php#L616-L637
15,626
czim/laravel-pxlcms
src/Models/CmsModel.php
CmsModel.getBelongsToRelationAttributeValue
public function getBelongsToRelationAttributeValue($key) { $relationKey = camel_case($key); $attributeKey = snake_case($key); if ($this->relationLoaded($relationKey)) { // check to make sure we don't break eager loading and internal // lookups for the foreign key $self = __FUNCTION__; $caller = array_first(debug_backtrace(false), function ($key, $trace) use ($self) { $caller = $trace['function']; // skip first two (since that includes the Model's generated method) if ($key < 2) { return false; } if (array_get($trace, 'class') === 'Illuminate\Database\Eloquent\Relations\BelongsTo') { return false; } return $caller != $self && $caller != 'mutateAttribute' && $caller != 'getAttributeValue' && $caller != 'getAttribute' && $caller != '__get'; }); if ( ! array_key_exists('class', $caller) || ( $caller['class'] !== 'Illuminate\Database\Eloquent\Model' && $caller['class'] !== 'Illuminate\Database\Eloquent\Builder' && $caller['class'] !== 'Illuminate\Database\Eloquent\Relations\Relation' ) ) { return $this->relations[$relationKey]; } } return $this->attributes[$attributeKey]; }
php
public function getBelongsToRelationAttributeValue($key) { $relationKey = camel_case($key); $attributeKey = snake_case($key); if ($this->relationLoaded($relationKey)) { // check to make sure we don't break eager loading and internal // lookups for the foreign key $self = __FUNCTION__; $caller = array_first(debug_backtrace(false), function ($key, $trace) use ($self) { $caller = $trace['function']; // skip first two (since that includes the Model's generated method) if ($key < 2) { return false; } if (array_get($trace, 'class') === 'Illuminate\Database\Eloquent\Relations\BelongsTo') { return false; } return $caller != $self && $caller != 'mutateAttribute' && $caller != 'getAttributeValue' && $caller != 'getAttribute' && $caller != '__get'; }); if ( ! array_key_exists('class', $caller) || ( $caller['class'] !== 'Illuminate\Database\Eloquent\Model' && $caller['class'] !== 'Illuminate\Database\Eloquent\Builder' && $caller['class'] !== 'Illuminate\Database\Eloquent\Relations\Relation' ) ) { return $this->relations[$relationKey]; } } return $this->attributes[$attributeKey]; }
[ "public", "function", "getBelongsToRelationAttributeValue", "(", "$", "key", ")", "{", "$", "relationKey", "=", "camel_case", "(", "$", "key", ")", ";", "$", "attributeKey", "=", "snake_case", "(", "$", "key", ")", ";", "if", "(", "$", "this", "->", "relationLoaded", "(", "$", "relationKey", ")", ")", "{", "// check to make sure we don't break eager loading and internal", "// lookups for the foreign key", "$", "self", "=", "__FUNCTION__", ";", "$", "caller", "=", "array_first", "(", "debug_backtrace", "(", "false", ")", ",", "function", "(", "$", "key", ",", "$", "trace", ")", "use", "(", "$", "self", ")", "{", "$", "caller", "=", "$", "trace", "[", "'function'", "]", ";", "// skip first two (since that includes the Model's generated method)", "if", "(", "$", "key", "<", "2", ")", "{", "return", "false", ";", "}", "if", "(", "array_get", "(", "$", "trace", ",", "'class'", ")", "===", "'Illuminate\\Database\\Eloquent\\Relations\\BelongsTo'", ")", "{", "return", "false", ";", "}", "return", "$", "caller", "!=", "$", "self", "&&", "$", "caller", "!=", "'mutateAttribute'", "&&", "$", "caller", "!=", "'getAttributeValue'", "&&", "$", "caller", "!=", "'getAttribute'", "&&", "$", "caller", "!=", "'__get'", ";", "}", ")", ";", "if", "(", "!", "array_key_exists", "(", "'class'", ",", "$", "caller", ")", "||", "(", "$", "caller", "[", "'class'", "]", "!==", "'Illuminate\\Database\\Eloquent\\Model'", "&&", "$", "caller", "[", "'class'", "]", "!==", "'Illuminate\\Database\\Eloquent\\Builder'", "&&", "$", "caller", "[", "'class'", "]", "!==", "'Illuminate\\Database\\Eloquent\\Relations\\Relation'", ")", ")", "{", "return", "$", "this", "->", "relations", "[", "$", "relationKey", "]", ";", "}", "}", "return", "$", "this", "->", "attributes", "[", "$", "attributeKey", "]", ";", "}" ]
Returns value for either foreign key or eager loaded contents of relation, depending on what is expected This should not break calls to the belongsTo relation method, including after using the load() method to eager load the relation's contents @param string $key @return mixed
[ "Returns", "value", "for", "either", "foreign", "key", "or", "eager", "loaded", "contents", "of", "relation", "depending", "on", "what", "is", "expected" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/CmsModel.php#L649-L690
15,627
czim/laravel-pxlcms
src/Models/CmsModel.php
CmsModel.getImagesWithResizes
protected function getImagesWithResizes() { // first get the images through the relation $relation = $this->getRelationForImagesWithResizesCaller(); $images = $this->{$relation}()->get(); if (empty($images)) return $images; // then get extra info and retrieve the resizes for it $fieldId = $this->getCmsReferenceFieldId($relation); $resizes = $this->getResizesForFieldId($fieldId); if (empty($resizes)) return $images; // decorate the images with resizes foreach ($images as $image) { $fileName = $image->file; $imageResizes = []; foreach ($resizes as $resize) { $imageResizes[ $resize->prefix ] = [ 'id' => $resize->id, 'prefix' => $resize->prefix, 'file' => $resize->prefix . $fileName, 'url' => Paths::images($resize->prefix . $fileName), 'width' => $resize->width, 'height' => $resize->height, ]; } // append full resizes info $image->resizes = $imageResizes; } return $images; }
php
protected function getImagesWithResizes() { // first get the images through the relation $relation = $this->getRelationForImagesWithResizesCaller(); $images = $this->{$relation}()->get(); if (empty($images)) return $images; // then get extra info and retrieve the resizes for it $fieldId = $this->getCmsReferenceFieldId($relation); $resizes = $this->getResizesForFieldId($fieldId); if (empty($resizes)) return $images; // decorate the images with resizes foreach ($images as $image) { $fileName = $image->file; $imageResizes = []; foreach ($resizes as $resize) { $imageResizes[ $resize->prefix ] = [ 'id' => $resize->id, 'prefix' => $resize->prefix, 'file' => $resize->prefix . $fileName, 'url' => Paths::images($resize->prefix . $fileName), 'width' => $resize->width, 'height' => $resize->height, ]; } // append full resizes info $image->resizes = $imageResizes; } return $images; }
[ "protected", "function", "getImagesWithResizes", "(", ")", "{", "// first get the images through the relation", "$", "relation", "=", "$", "this", "->", "getRelationForImagesWithResizesCaller", "(", ")", ";", "$", "images", "=", "$", "this", "->", "{", "$", "relation", "}", "(", ")", "->", "get", "(", ")", ";", "if", "(", "empty", "(", "$", "images", ")", ")", "return", "$", "images", ";", "// then get extra info and retrieve the resizes for it", "$", "fieldId", "=", "$", "this", "->", "getCmsReferenceFieldId", "(", "$", "relation", ")", ";", "$", "resizes", "=", "$", "this", "->", "getResizesForFieldId", "(", "$", "fieldId", ")", ";", "if", "(", "empty", "(", "$", "resizes", ")", ")", "return", "$", "images", ";", "// decorate the images with resizes", "foreach", "(", "$", "images", "as", "$", "image", ")", "{", "$", "fileName", "=", "$", "image", "->", "file", ";", "$", "imageResizes", "=", "[", "]", ";", "foreach", "(", "$", "resizes", "as", "$", "resize", ")", "{", "$", "imageResizes", "[", "$", "resize", "->", "prefix", "]", "=", "[", "'id'", "=>", "$", "resize", "->", "id", ",", "'prefix'", "=>", "$", "resize", "->", "prefix", ",", "'file'", "=>", "$", "resize", "->", "prefix", ".", "$", "fileName", ",", "'url'", "=>", "Paths", "::", "images", "(", "$", "resize", "->", "prefix", ".", "$", "fileName", ")", ",", "'width'", "=>", "$", "resize", "->", "width", ",", "'height'", "=>", "$", "resize", "->", "height", ",", "]", ";", "}", "// append full resizes info", "$", "image", "->", "resizes", "=", "$", "imageResizes", ";", "}", "return", "$", "images", ";", "}" ]
Returns resize-enriched images for a special CMS model image relation To be called from an accessor, so it can return images based on its name, which should be get<relationname>Attribute(). @return Collection
[ "Returns", "resize", "-", "enriched", "images", "for", "a", "special", "CMS", "model", "image", "relation" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/CmsModel.php#L772-L811
15,628
czim/laravel-pxlcms
src/Models/CmsModel.php
CmsModel.getRelationForImagesWithResizesCaller
protected function getRelationForImagesWithResizesCaller() { $self = __FUNCTION__; $caller = Arr::first(debug_backtrace(false), function ($key, $trace) use ($self) { $caller = $trace['function']; return ! in_array($caller, ['getImagesWithResizes']) && $caller != $self; }); if (is_null($caller)) return null; // strip 'get' from front and 'attribute' from rear return Str::camel(substr($caller['function'], 3, -9)); }
php
protected function getRelationForImagesWithResizesCaller() { $self = __FUNCTION__; $caller = Arr::first(debug_backtrace(false), function ($key, $trace) use ($self) { $caller = $trace['function']; return ! in_array($caller, ['getImagesWithResizes']) && $caller != $self; }); if (is_null($caller)) return null; // strip 'get' from front and 'attribute' from rear return Str::camel(substr($caller['function'], 3, -9)); }
[ "protected", "function", "getRelationForImagesWithResizesCaller", "(", ")", "{", "$", "self", "=", "__FUNCTION__", ";", "$", "caller", "=", "Arr", "::", "first", "(", "debug_backtrace", "(", "false", ")", ",", "function", "(", "$", "key", ",", "$", "trace", ")", "use", "(", "$", "self", ")", "{", "$", "caller", "=", "$", "trace", "[", "'function'", "]", ";", "return", "!", "in_array", "(", "$", "caller", ",", "[", "'getImagesWithResizes'", "]", ")", "&&", "$", "caller", "!=", "$", "self", ";", "}", ")", ";", "if", "(", "is_null", "(", "$", "caller", ")", ")", "return", "null", ";", "// strip 'get' from front and 'attribute' from rear", "return", "Str", "::", "camel", "(", "substr", "(", "$", "caller", "[", "'function'", "]", ",", "3", ",", "-", "9", ")", ")", ";", "}" ]
Get the relationship name of the image accessor for which images are enriched @return string
[ "Get", "the", "relationship", "name", "of", "the", "image", "accessor", "for", "which", "images", "are", "enriched" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/CmsModel.php#L836-L850
15,629
czim/laravel-pxlcms
src/Models/CmsModel.php
CmsModel.lookupLocaleForLanguageId
public function lookupLocaleForLanguageId($languageId) { /** @var Model $languageModel */ $languageModel = static::$cmsLanguageModel; $language = $languageModel::where('id', $languageId) ->remember((config('pxlcms.cache.languages', 15))) ->first(); if (empty($language)) return null; return $this->normalizeToLocale($language->code); }
php
public function lookupLocaleForLanguageId($languageId) { /** @var Model $languageModel */ $languageModel = static::$cmsLanguageModel; $language = $languageModel::where('id', $languageId) ->remember((config('pxlcms.cache.languages', 15))) ->first(); if (empty($language)) return null; return $this->normalizeToLocale($language->code); }
[ "public", "function", "lookupLocaleForLanguageId", "(", "$", "languageId", ")", "{", "/** @var Model $languageModel */", "$", "languageModel", "=", "static", "::", "$", "cmsLanguageModel", ";", "$", "language", "=", "$", "languageModel", "::", "where", "(", "'id'", ",", "$", "languageId", ")", "->", "remember", "(", "(", "config", "(", "'pxlcms.cache.languages'", ",", "15", ")", ")", ")", "->", "first", "(", ")", ";", "if", "(", "empty", "(", "$", "language", ")", ")", "return", "null", ";", "return", "$", "this", "->", "normalizeToLocale", "(", "$", "language", "->", "code", ")", ";", "}" ]
Retrieves locale for a given language ID code @param int $languageId @return string|null of language for ID was not found
[ "Retrieves", "locale", "for", "a", "given", "language", "ID", "code" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/CmsModel.php#L885-L897
15,630
harp-orm/query
src/DB.php
DB.execute
public function execute($sql, array $parameters = array()) { $this->logger->info($sql, array('parameters' => $parameters)); try { $statement = $this->getPdo()->prepare($sql); $statement->execute($parameters); } catch (PDOException $exception) { $this->logger->error($exception->getMessage()); throw $exception; } return $statement; }
php
public function execute($sql, array $parameters = array()) { $this->logger->info($sql, array('parameters' => $parameters)); try { $statement = $this->getPdo()->prepare($sql); $statement->execute($parameters); } catch (PDOException $exception) { $this->logger->error($exception->getMessage()); throw $exception; } return $statement; }
[ "public", "function", "execute", "(", "$", "sql", ",", "array", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "this", "->", "logger", "->", "info", "(", "$", "sql", ",", "array", "(", "'parameters'", "=>", "$", "parameters", ")", ")", ";", "try", "{", "$", "statement", "=", "$", "this", "->", "getPdo", "(", ")", "->", "prepare", "(", "$", "sql", ")", ";", "$", "statement", "->", "execute", "(", "$", "parameters", ")", ";", "}", "catch", "(", "PDOException", "$", "exception", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "$", "exception", "->", "getMessage", "(", ")", ")", ";", "throw", "$", "exception", ";", "}", "return", "$", "statement", ";", "}" ]
Run "prepare" a statement and then execute it @param string $sql @param array $parameters @return \PDOStatement
[ "Run", "prepare", "a", "statement", "and", "then", "execute", "it" ]
98ce2468a0a31fe15ed3692bad32547bf6dbe41a
https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/DB.php#L240-L254
15,631
WellCommerce/OrderBundle
Form/Front/CartFormBuilder.php
CartFormBuilder.addShippingOptions
private function addShippingOptions(Order $order, FormInterface $form) { if ($order->getShippingMethod() instanceof ShippingMethod) { $provider = $this->getOptionsProvider($order->getShippingMethod()); if ($provider instanceof ShippingMethodOptionsProviderInterface) { $form->addChild($this->getElement('select', [ 'name' => 'shippingMethodOption', 'label' => 'order.label.shipping_method', 'options' => $provider->getShippingOptions(), ])); } } }
php
private function addShippingOptions(Order $order, FormInterface $form) { if ($order->getShippingMethod() instanceof ShippingMethod) { $provider = $this->getOptionsProvider($order->getShippingMethod()); if ($provider instanceof ShippingMethodOptionsProviderInterface) { $form->addChild($this->getElement('select', [ 'name' => 'shippingMethodOption', 'label' => 'order.label.shipping_method', 'options' => $provider->getShippingOptions(), ])); } } }
[ "private", "function", "addShippingOptions", "(", "Order", "$", "order", ",", "FormInterface", "$", "form", ")", "{", "if", "(", "$", "order", "->", "getShippingMethod", "(", ")", "instanceof", "ShippingMethod", ")", "{", "$", "provider", "=", "$", "this", "->", "getOptionsProvider", "(", "$", "order", "->", "getShippingMethod", "(", ")", ")", ";", "if", "(", "$", "provider", "instanceof", "ShippingMethodOptionsProviderInterface", ")", "{", "$", "form", "->", "addChild", "(", "$", "this", "->", "getElement", "(", "'select'", ",", "[", "'name'", "=>", "'shippingMethodOption'", ",", "'label'", "=>", "'order.label.shipping_method'", ",", "'options'", "=>", "$", "provider", "->", "getShippingOptions", "(", ")", ",", "]", ")", ")", ";", "}", "}", "}" ]
Adds shipping options if available for order's shipping method @param Order $order @param FormInterface $form
[ "Adds", "shipping", "options", "if", "available", "for", "order", "s", "shipping", "method" ]
d72cfb51eab7a1f66f186900d1e2d533a822c424
https://github.com/WellCommerce/OrderBundle/blob/d72cfb51eab7a1f66f186900d1e2d533a822c424/Form/Front/CartFormBuilder.php#L85-L97
15,632
drpdigital/json-api-parser
src/JsonApiParser.php
JsonApiParser.parse
public function parse(array $input) { $this->data = Arr::get($input, 'data'); if ($this->data === null) { return null; } $this->included = Arr::get($input, 'included', []); $this->start(); return $this->resolver->getResolved(); }
php
public function parse(array $input) { $this->data = Arr::get($input, 'data'); if ($this->data === null) { return null; } $this->included = Arr::get($input, 'included', []); $this->start(); return $this->resolver->getResolved(); }
[ "public", "function", "parse", "(", "array", "$", "input", ")", "{", "$", "this", "->", "data", "=", "Arr", "::", "get", "(", "$", "input", ",", "'data'", ")", ";", "if", "(", "$", "this", "->", "data", "===", "null", ")", "{", "return", "null", ";", "}", "$", "this", "->", "included", "=", "Arr", "::", "get", "(", "$", "input", ",", "'included'", ",", "[", "]", ")", ";", "$", "this", "->", "start", "(", ")", ";", "return", "$", "this", "->", "resolver", "->", "getResolved", "(", ")", ";", "}" ]
Parse the data given Returns all the models that were resolved. @param array $input @return \Drp\JsonApiParser\ResolvedCollection|null @throws \ReflectionException @throws \Drp\JsonApiParser\Exceptions\MissingResolverException
[ "Parse", "the", "data", "given" ]
b1ceefc0c19ec326129126253114c121e97ca943
https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/JsonApiParser.php#L47-L59
15,633
drpdigital/json-api-parser
src/JsonApiParser.php
JsonApiParser.resolver
public function resolver($resourceNames, $callback) { $resourceNames = Arr::wrap($resourceNames); foreach ($resourceNames as $name) { $this->resolver->bind($name, $callback); } return $this; }
php
public function resolver($resourceNames, $callback) { $resourceNames = Arr::wrap($resourceNames); foreach ($resourceNames as $name) { $this->resolver->bind($name, $callback); } return $this; }
[ "public", "function", "resolver", "(", "$", "resourceNames", ",", "$", "callback", ")", "{", "$", "resourceNames", "=", "Arr", "::", "wrap", "(", "$", "resourceNames", ")", ";", "foreach", "(", "$", "resourceNames", "as", "$", "name", ")", "{", "$", "this", "->", "resolver", "->", "bind", "(", "$", "name", ",", "$", "callback", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds the callbacks for resolve the different objects in the response @param array|string $resourceNames @param callable|string $callback @return JsonApiParser
[ "Adds", "the", "callbacks", "for", "resolve", "the", "different", "objects", "in", "the", "response" ]
b1ceefc0c19ec326129126253114c121e97ca943
https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/JsonApiParser.php#L68-L77
15,634
drpdigital/json-api-parser
src/JsonApiParser.php
JsonApiParser.fetcher
public function fetcher($className, $relationshipName, $callback = null) { $this->resolver->bindFetcher($className, $relationshipName, $callback); return $this; }
php
public function fetcher($className, $relationshipName, $callback = null) { $this->resolver->bindFetcher($className, $relationshipName, $callback); return $this; }
[ "public", "function", "fetcher", "(", "$", "className", ",", "$", "relationshipName", ",", "$", "callback", "=", "null", ")", "{", "$", "this", "->", "resolver", "->", "bindFetcher", "(", "$", "className", ",", "$", "relationshipName", ",", "$", "callback", ")", ";", "return", "$", "this", ";", "}" ]
Add a callback for a class that when called will return an existing instance of a relationship. This callback will be called when trying to resolve a parameter dependency on a resolver callback. The callback will only be given the id of the relationship it needs to be fetched. @param string|array $className @param string|callable $relationshipName This can be an optional relationship name or the callable for the fetcher. @param callable|string $callback @return static
[ "Add", "a", "callback", "for", "a", "class", "that", "when", "called", "will", "return", "an", "existing", "instance", "of", "a", "relationship", "." ]
b1ceefc0c19ec326129126253114c121e97ca943
https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/JsonApiParser.php#L93-L98
15,635
drpdigital/json-api-parser
src/JsonApiParser.php
JsonApiParser.start
private function start() { if (Arr::is_assoc($this->data)) { $this->data = [$this->data]; } foreach ($this->data as $data) { $relationshipsToProcess = $this->resolveResource($data); $this->resolveRelationships($relationshipsToProcess); } }
php
private function start() { if (Arr::is_assoc($this->data)) { $this->data = [$this->data]; } foreach ($this->data as $data) { $relationshipsToProcess = $this->resolveResource($data); $this->resolveRelationships($relationshipsToProcess); } }
[ "private", "function", "start", "(", ")", "{", "if", "(", "Arr", "::", "is_assoc", "(", "$", "this", "->", "data", ")", ")", "{", "$", "this", "->", "data", "=", "[", "$", "this", "->", "data", "]", ";", "}", "foreach", "(", "$", "this", "->", "data", "as", "$", "data", ")", "{", "$", "relationshipsToProcess", "=", "$", "this", "->", "resolveResource", "(", "$", "data", ")", ";", "$", "this", "->", "resolveRelationships", "(", "$", "relationshipsToProcess", ")", ";", "}", "}" ]
Starts the parsing and creating of the relationships. @return void @throws \ReflectionException @throws \Drp\JsonApiParser\Exceptions\MissingResolverException
[ "Starts", "the", "parsing", "and", "creating", "of", "the", "relationships", "." ]
b1ceefc0c19ec326129126253114c121e97ca943
https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/JsonApiParser.php#L107-L117
15,636
drpdigital/json-api-parser
src/JsonApiParser.php
JsonApiParser.getIncludedResource
private function getIncludedResource($id, $type) { foreach ($this->included as $included) { $includedId = Arr::get($included, 'id'); $includedType = Arr::get($included, 'type'); if ((string) $includedType === (string) $type && (string) $includedId === (string) $id) { return $included; } } return $this->getDefaultIncludedResource($id, $type); }
php
private function getIncludedResource($id, $type) { foreach ($this->included as $included) { $includedId = Arr::get($included, 'id'); $includedType = Arr::get($included, 'type'); if ((string) $includedType === (string) $type && (string) $includedId === (string) $id) { return $included; } } return $this->getDefaultIncludedResource($id, $type); }
[ "private", "function", "getIncludedResource", "(", "$", "id", ",", "$", "type", ")", "{", "foreach", "(", "$", "this", "->", "included", "as", "$", "included", ")", "{", "$", "includedId", "=", "Arr", "::", "get", "(", "$", "included", ",", "'id'", ")", ";", "$", "includedType", "=", "Arr", "::", "get", "(", "$", "included", ",", "'type'", ")", ";", "if", "(", "(", "string", ")", "$", "includedType", "===", "(", "string", ")", "$", "type", "&&", "(", "string", ")", "$", "includedId", "===", "(", "string", ")", "$", "id", ")", "{", "return", "$", "included", ";", "}", "}", "return", "$", "this", "->", "getDefaultIncludedResource", "(", "$", "id", ",", "$", "type", ")", ";", "}" ]
Get a resource that is in the included array Returns default resource if it was not able to find a resource with the given type and id. @param integer $id @param string $type @return bool|mixed
[ "Get", "a", "resource", "that", "is", "in", "the", "included", "array" ]
b1ceefc0c19ec326129126253114c121e97ca943
https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/JsonApiParser.php#L226-L238
15,637
dakalab/division-code
src/DivisionCode/DivisionCode.php
DivisionCode.get
public function get($code = null): string { if (!$this->validate($code)) { throw new \InvalidArgumentException('Invalid code'); } return isset(self::$codes[$code]) ? self::$codes[$code] : ''; }
php
public function get($code = null): string { if (!$this->validate($code)) { throw new \InvalidArgumentException('Invalid code'); } return isset(self::$codes[$code]) ? self::$codes[$code] : ''; }
[ "public", "function", "get", "(", "$", "code", "=", "null", ")", ":", "string", "{", "if", "(", "!", "$", "this", "->", "validate", "(", "$", "code", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid code'", ")", ";", "}", "return", "isset", "(", "self", "::", "$", "codes", "[", "$", "code", "]", ")", "?", "self", "::", "$", "codes", "[", "$", "code", "]", ":", "''", ";", "}" ]
Get local name by code @param string|int $code @throws \InvalidArgumentException @return string
[ "Get", "local", "name", "by", "code" ]
f8b2c4c7981c49e1bf6f203425b89ae94087d99f
https://github.com/dakalab/division-code/blob/f8b2c4c7981c49e1bf6f203425b89ae94087d99f/src/DivisionCode/DivisionCode.php#L62-L69
15,638
dakalab/division-code
src/DivisionCode/DivisionCode.php
DivisionCode.getCity
public function getCity($code): string { $provinceCode = substr($code, 0, 2) . '0000'; $cityCode = substr($code, 0, 4) . '00'; if ($provinceCode != $cityCode) { return $this->get($cityCode); } return ''; }
php
public function getCity($code): string { $provinceCode = substr($code, 0, 2) . '0000'; $cityCode = substr($code, 0, 4) . '00'; if ($provinceCode != $cityCode) { return $this->get($cityCode); } return ''; }
[ "public", "function", "getCity", "(", "$", "code", ")", ":", "string", "{", "$", "provinceCode", "=", "substr", "(", "$", "code", ",", "0", ",", "2", ")", ".", "'0000'", ";", "$", "cityCode", "=", "substr", "(", "$", "code", ",", "0", ",", "4", ")", ".", "'00'", ";", "if", "(", "$", "provinceCode", "!=", "$", "cityCode", ")", "{", "return", "$", "this", "->", "get", "(", "$", "cityCode", ")", ";", "}", "return", "''", ";", "}" ]
Get the city by code @param string|int $code @return string
[ "Get", "the", "city", "by", "code" ]
f8b2c4c7981c49e1bf6f203425b89ae94087d99f
https://github.com/dakalab/division-code/blob/f8b2c4c7981c49e1bf6f203425b89ae94087d99f/src/DivisionCode/DivisionCode.php#L90-L99
15,639
dakalab/division-code
src/DivisionCode/DivisionCode.php
DivisionCode.getAddress
public function getAddress($code): string { return $this->getProvince($code) . $this->getCity($code) . $this->getCounty($code); }
php
public function getAddress($code): string { return $this->getProvince($code) . $this->getCity($code) . $this->getCounty($code); }
[ "public", "function", "getAddress", "(", "$", "code", ")", ":", "string", "{", "return", "$", "this", "->", "getProvince", "(", "$", "code", ")", ".", "$", "this", "->", "getCity", "(", "$", "code", ")", ".", "$", "this", "->", "getCounty", "(", "$", "code", ")", ";", "}" ]
Get the address by code @param string|int $code @return string
[ "Get", "the", "address", "by", "code" ]
f8b2c4c7981c49e1bf6f203425b89ae94087d99f
https://github.com/dakalab/division-code/blob/f8b2c4c7981c49e1bf6f203425b89ae94087d99f/src/DivisionCode/DivisionCode.php#L122-L125
15,640
nicoSWD/put.io-api-v2
src/PutIO/Engines/PutIO/FilesEngine.php
FilesEngine.search
public function search($query, $page = 1) { return $this->get(sprintf( 'files/search/%s/page/%d', rawurlencode(trim($query)), $page )); }
php
public function search($query, $page = 1) { return $this->get(sprintf( 'files/search/%s/page/%d', rawurlencode(trim($query)), $page )); }
[ "public", "function", "search", "(", "$", "query", ",", "$", "page", "=", "1", ")", "{", "return", "$", "this", "->", "get", "(", "sprintf", "(", "'files/search/%s/page/%d'", ",", "rawurlencode", "(", "trim", "(", "$", "query", ")", ")", ",", "$", "page", ")", ")", ";", "}" ]
Returns an array of files matching the given search query. @param string $query Search query @param integer $page Page number @return array
[ "Returns", "an", "array", "of", "files", "matching", "the", "given", "search", "query", "." ]
d91bedd91ea75793512a921bfd9aa83e86a6f0a7
https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Engines/PutIO/FilesEngine.php#L46-L53
15,641
nicoSWD/put.io-api-v2
src/PutIO/Engines/PutIO/FilesEngine.php
FilesEngine.upload
public function upload($file, $parentID = 0) { if (!$file = realpath($file)) { throw new \Exception('File not found'); } return $this->uploadFile('files/upload', [ 'parent_id' => $parentID, 'file' => "@{$file}" ]); }
php
public function upload($file, $parentID = 0) { if (!$file = realpath($file)) { throw new \Exception('File not found'); } return $this->uploadFile('files/upload', [ 'parent_id' => $parentID, 'file' => "@{$file}" ]); }
[ "public", "function", "upload", "(", "$", "file", ",", "$", "parentID", "=", "0", ")", "{", "if", "(", "!", "$", "file", "=", "realpath", "(", "$", "file", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'File not found'", ")", ";", "}", "return", "$", "this", "->", "uploadFile", "(", "'files/upload'", ",", "[", "'parent_id'", "=>", "$", "parentID", ",", "'file'", "=>", "\"@{$file}\"", "]", ")", ";", "}" ]
Uploads a local file to your account. NOTE 1: The response differs based on the uploaded file. For regular files, the array key containing the info is 'file', but for torrents it's 'transfer'. @see https://api.put.io/v2/docs/#files-upload NOTE 2: Files need to be read into the memory when using NATIVE functions. Keep that in mind when uploading large files or running multiple instances. @param string $file Path to local file. @param integer $parentID ID of upload folder. @return mixed @throws \Exception
[ "Uploads", "a", "local", "file", "to", "your", "account", "." ]
d91bedd91ea75793512a921bfd9aa83e86a6f0a7
https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Engines/PutIO/FilesEngine.php#L73-L83
15,642
nicoSWD/put.io-api-v2
src/PutIO/Engines/PutIO/FilesEngine.php
FilesEngine.makeDir
public function makeDir($name, $parentID = 0) { $data = [ 'name' => $name, 'parent_id' => $parentID ]; return $this->post('files/create-folder', $data, \false, 'file'); }
php
public function makeDir($name, $parentID = 0) { $data = [ 'name' => $name, 'parent_id' => $parentID ]; return $this->post('files/create-folder', $data, \false, 'file'); }
[ "public", "function", "makeDir", "(", "$", "name", ",", "$", "parentID", "=", "0", ")", "{", "$", "data", "=", "[", "'name'", "=>", "$", "name", ",", "'parent_id'", "=>", "$", "parentID", "]", ";", "return", "$", "this", "->", "post", "(", "'files/create-folder'", ",", "$", "data", ",", "\\", "false", ",", "'file'", ")", ";", "}" ]
Creates a new folder. Returns folder info on success, false on error. @param string $name Name of the new folder. @param integer $parentID ID of the parent folder. @return mixed
[ "Creates", "a", "new", "folder", ".", "Returns", "folder", "info", "on", "success", "false", "on", "error", "." ]
d91bedd91ea75793512a921bfd9aa83e86a6f0a7
https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Engines/PutIO/FilesEngine.php#L92-L100
15,643
nicoSWD/put.io-api-v2
src/PutIO/Engines/PutIO/FilesEngine.php
FilesEngine.delete
public function delete($fileIDs) { if (is_array($fileIDs)) { $fileIDs = implode(',', $fileIDs); } $data = [ 'file_ids' => $fileIDs ]; return $this->post('files/delete', $data, \true); }
php
public function delete($fileIDs) { if (is_array($fileIDs)) { $fileIDs = implode(',', $fileIDs); } $data = [ 'file_ids' => $fileIDs ]; return $this->post('files/delete', $data, \true); }
[ "public", "function", "delete", "(", "$", "fileIDs", ")", "{", "if", "(", "is_array", "(", "$", "fileIDs", ")", ")", "{", "$", "fileIDs", "=", "implode", "(", "','", ",", "$", "fileIDs", ")", ";", "}", "$", "data", "=", "[", "'file_ids'", "=>", "$", "fileIDs", "]", ";", "return", "$", "this", "->", "post", "(", "'files/delete'", ",", "$", "data", ",", "\\", "true", ")", ";", "}" ]
Deletes files from your account. @param mixed $fileIDs IDs of files you want to delete. Array or integer. @return boolean
[ "Deletes", "files", "from", "your", "account", "." ]
d91bedd91ea75793512a921bfd9aa83e86a6f0a7
https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Engines/PutIO/FilesEngine.php#L119-L130
15,644
nicoSWD/put.io-api-v2
src/PutIO/Engines/PutIO/FilesEngine.php
FilesEngine.move
public function move($fileIDs, $parentID) { if (is_array($fileIDs)) { $fileIDs = implode(',', $fileIDs); } $data = [ 'file_ids' => $fileIDs, 'parent_id' => $parentID ]; return $this->post('files/move', $data, \true); }
php
public function move($fileIDs, $parentID) { if (is_array($fileIDs)) { $fileIDs = implode(',', $fileIDs); } $data = [ 'file_ids' => $fileIDs, 'parent_id' => $parentID ]; return $this->post('files/move', $data, \true); }
[ "public", "function", "move", "(", "$", "fileIDs", ",", "$", "parentID", ")", "{", "if", "(", "is_array", "(", "$", "fileIDs", ")", ")", "{", "$", "fileIDs", "=", "implode", "(", "','", ",", "$", "fileIDs", ")", ";", "}", "$", "data", "=", "[", "'file_ids'", "=>", "$", "fileIDs", ",", "'parent_id'", "=>", "$", "parentID", "]", ";", "return", "$", "this", "->", "post", "(", "'files/move'", ",", "$", "data", ",", "\\", "true", ")", ";", "}" ]
Moves one of more files to a new directory. @param mixed $fileIDs IDs of files you want to move. Array or integer. @param integer $parentID ID of the folder you want to move the files to. @return boolean
[ "Moves", "one", "of", "more", "files", "to", "a", "new", "directory", "." ]
d91bedd91ea75793512a921bfd9aa83e86a6f0a7
https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Engines/PutIO/FilesEngine.php#L156-L168
15,645
thecodingmachine/utils.graphics.mouf-imagine
src/Mouf/Utils/Graphics/MoufImagine/Controller/ImagePresetController.php
ImagePresetController.deletePreset
private function deletePreset ($imagePath) { $finalPath = ROOT_PATH . $this->url . DIRECTORY_SEPARATOR . $imagePath; if (file_exists($finalPath)){ unlink($finalPath); } }
php
private function deletePreset ($imagePath) { $finalPath = ROOT_PATH . $this->url . DIRECTORY_SEPARATOR . $imagePath; if (file_exists($finalPath)){ unlink($finalPath); } }
[ "private", "function", "deletePreset", "(", "$", "imagePath", ")", "{", "$", "finalPath", "=", "ROOT_PATH", ".", "$", "this", "->", "url", ".", "DIRECTORY_SEPARATOR", ".", "$", "imagePath", ";", "if", "(", "file_exists", "(", "$", "finalPath", ")", ")", "{", "unlink", "(", "$", "finalPath", ")", ";", "}", "}" ]
Delete a preset of an image @param $imagePath
[ "Delete", "a", "preset", "of", "an", "image" ]
54366dec4839569290bf79a4ffd41b032461779b
https://github.com/thecodingmachine/utils.graphics.mouf-imagine/blob/54366dec4839569290bf79a4ffd41b032461779b/src/Mouf/Utils/Graphics/MoufImagine/Controller/ImagePresetController.php#L174-L179
15,646
thecodingmachine/utils.graphics.mouf-imagine
src/Mouf/Utils/Graphics/MoufImagine/Controller/ImagePresetController.php
ImagePresetController.createPresets
public static function createPresets($path = null, $callback = null) { $moufManager = MoufManager::getMoufManager(); $instances = $moufManager->findInstances('Mouf\\Utils\\Graphics\\MoufImagine\\Controller\\ImagePresetController'); foreach ($instances as $instanceName) { $instance = $moufManager->getInstance($instanceName); if ($path && strpos($path, $instance->originalPath) !== false && $instance->createPresetsEnabled === true) { $imagePath = substr($path, strlen($instance->originalPath) + 1); $instance->image($imagePath); if(is_callable($callback)) { $finalPath = ROOT_PATH . $instance->url . DIRECTORY_SEPARATOR . $imagePath; $callback($finalPath); } } } }
php
public static function createPresets($path = null, $callback = null) { $moufManager = MoufManager::getMoufManager(); $instances = $moufManager->findInstances('Mouf\\Utils\\Graphics\\MoufImagine\\Controller\\ImagePresetController'); foreach ($instances as $instanceName) { $instance = $moufManager->getInstance($instanceName); if ($path && strpos($path, $instance->originalPath) !== false && $instance->createPresetsEnabled === true) { $imagePath = substr($path, strlen($instance->originalPath) + 1); $instance->image($imagePath); if(is_callable($callback)) { $finalPath = ROOT_PATH . $instance->url . DIRECTORY_SEPARATOR . $imagePath; $callback($finalPath); } } } }
[ "public", "static", "function", "createPresets", "(", "$", "path", "=", "null", ",", "$", "callback", "=", "null", ")", "{", "$", "moufManager", "=", "MoufManager", "::", "getMoufManager", "(", ")", ";", "$", "instances", "=", "$", "moufManager", "->", "findInstances", "(", "'Mouf\\\\Utils\\\\Graphics\\\\MoufImagine\\\\Controller\\\\ImagePresetController'", ")", ";", "foreach", "(", "$", "instances", "as", "$", "instanceName", ")", "{", "$", "instance", "=", "$", "moufManager", "->", "getInstance", "(", "$", "instanceName", ")", ";", "if", "(", "$", "path", "&&", "strpos", "(", "$", "path", ",", "$", "instance", "->", "originalPath", ")", "!==", "false", "&&", "$", "instance", "->", "createPresetsEnabled", "===", "true", ")", "{", "$", "imagePath", "=", "substr", "(", "$", "path", ",", "strlen", "(", "$", "instance", "->", "originalPath", ")", "+", "1", ")", ";", "$", "instance", "->", "image", "(", "$", "imagePath", ")", ";", "if", "(", "is_callable", "(", "$", "callback", ")", ")", "{", "$", "finalPath", "=", "ROOT_PATH", ".", "$", "instance", "->", "url", ".", "DIRECTORY_SEPARATOR", ".", "$", "imagePath", ";", "$", "callback", "(", "$", "finalPath", ")", ";", "}", "}", "}", "}" ]
Create presets of an image @param string $path
[ "Create", "presets", "of", "an", "image" ]
54366dec4839569290bf79a4ffd41b032461779b
https://github.com/thecodingmachine/utils.graphics.mouf-imagine/blob/54366dec4839569290bf79a4ffd41b032461779b/src/Mouf/Utils/Graphics/MoufImagine/Controller/ImagePresetController.php#L185-L200
15,647
thecodingmachine/utils.graphics.mouf-imagine
src/Mouf/Utils/Graphics/MoufImagine/Controller/ImagePresetController.php
ImagePresetController.purgePresets
public static function purgePresets($path = null, $callback = null) { $moufManager = MoufManager::getMoufManager(); $instances = $moufManager->findInstances('Mouf\\Utils\\Graphics\\MoufImagine\\Controller\\ImagePresetController'); foreach ($instances as $instanceName) { $instance = $moufManager->getInstance($instanceName); if ($path && strpos($path, $instance->originalPath) !== false) { $imagePath = substr($path, strlen($instance->originalPath) + 1); $instance->deletePreset($imagePath); if(is_callable($callback)) { $finalPath = ROOT_PATH . $instance->url . DIRECTORY_SEPARATOR . $imagePath; $callback($finalPath); } } } }
php
public static function purgePresets($path = null, $callback = null) { $moufManager = MoufManager::getMoufManager(); $instances = $moufManager->findInstances('Mouf\\Utils\\Graphics\\MoufImagine\\Controller\\ImagePresetController'); foreach ($instances as $instanceName) { $instance = $moufManager->getInstance($instanceName); if ($path && strpos($path, $instance->originalPath) !== false) { $imagePath = substr($path, strlen($instance->originalPath) + 1); $instance->deletePreset($imagePath); if(is_callable($callback)) { $finalPath = ROOT_PATH . $instance->url . DIRECTORY_SEPARATOR . $imagePath; $callback($finalPath); } } } }
[ "public", "static", "function", "purgePresets", "(", "$", "path", "=", "null", ",", "$", "callback", "=", "null", ")", "{", "$", "moufManager", "=", "MoufManager", "::", "getMoufManager", "(", ")", ";", "$", "instances", "=", "$", "moufManager", "->", "findInstances", "(", "'Mouf\\\\Utils\\\\Graphics\\\\MoufImagine\\\\Controller\\\\ImagePresetController'", ")", ";", "foreach", "(", "$", "instances", "as", "$", "instanceName", ")", "{", "$", "instance", "=", "$", "moufManager", "->", "getInstance", "(", "$", "instanceName", ")", ";", "if", "(", "$", "path", "&&", "strpos", "(", "$", "path", ",", "$", "instance", "->", "originalPath", ")", "!==", "false", ")", "{", "$", "imagePath", "=", "substr", "(", "$", "path", ",", "strlen", "(", "$", "instance", "->", "originalPath", ")", "+", "1", ")", ";", "$", "instance", "->", "deletePreset", "(", "$", "imagePath", ")", ";", "if", "(", "is_callable", "(", "$", "callback", ")", ")", "{", "$", "finalPath", "=", "ROOT_PATH", ".", "$", "instance", "->", "url", ".", "DIRECTORY_SEPARATOR", ".", "$", "imagePath", ";", "$", "callback", "(", "$", "finalPath", ")", ";", "}", "}", "}", "}" ]
Purge presets of an image @param string $path
[ "Purge", "presets", "of", "an", "image" ]
54366dec4839569290bf79a4ffd41b032461779b
https://github.com/thecodingmachine/utils.graphics.mouf-imagine/blob/54366dec4839569290bf79a4ffd41b032461779b/src/Mouf/Utils/Graphics/MoufImagine/Controller/ImagePresetController.php#L206-L221
15,648
raoul2000/yii2-twbsmaxlength-widget
TwbsMaxlength.php
TwbsMaxlength.registerClientScript
public function registerClientScript() { $view = $this->getView(); TwbsMaxlengthAsset::register($view); $options = empty($this->clientOptions) ? "{}" : Json::encode($this->clientOptions); if( isset($this->selector)) { $js = "jQuery(\"{$this->selector}\").maxlength(" . $options . ")"; } else { $js = "jQuery(\"#{$this->options['id']}\").maxlength(" . $options . ")"; } $view->registerJs($js); }
php
public function registerClientScript() { $view = $this->getView(); TwbsMaxlengthAsset::register($view); $options = empty($this->clientOptions) ? "{}" : Json::encode($this->clientOptions); if( isset($this->selector)) { $js = "jQuery(\"{$this->selector}\").maxlength(" . $options . ")"; } else { $js = "jQuery(\"#{$this->options['id']}\").maxlength(" . $options . ")"; } $view->registerJs($js); }
[ "public", "function", "registerClientScript", "(", ")", "{", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "TwbsMaxlengthAsset", "::", "register", "(", "$", "view", ")", ";", "$", "options", "=", "empty", "(", "$", "this", "->", "clientOptions", ")", "?", "\"{}\"", ":", "Json", "::", "encode", "(", "$", "this", "->", "clientOptions", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "selector", ")", ")", "{", "$", "js", "=", "\"jQuery(\\\"{$this->selector}\\\").maxlength(\"", ".", "$", "options", ".", "\")\"", ";", "}", "else", "{", "$", "js", "=", "\"jQuery(\\\"#{$this->options['id']}\\\").maxlength(\"", ".", "$", "options", ".", "\")\"", ";", "}", "$", "view", "->", "registerJs", "(", "$", "js", ")", ";", "}" ]
Generates and registers javascript to start the plugin.
[ "Generates", "and", "registers", "javascript", "to", "start", "the", "plugin", "." ]
87ba6bf179a8db398bff0aaee6701a1e6dfc8b3b
https://github.com/raoul2000/yii2-twbsmaxlength-widget/blob/87ba6bf179a8db398bff0aaee6701a1e6dfc8b3b/TwbsMaxlength.php#L128-L140
15,649
raoul2000/yii2-twbsmaxlength-widget
TwbsMaxlength.php
TwbsMaxlength.apply
public static function apply($field, $clientOptions, $render = true) { if ( isset($field->inputOptions['maxlength'])) { $maxLength = $field->inputOptions['maxlength']; } else { $maxLength = static::getMaxLength($field->model, Html::getAttributeName($field->attribute)); } if ( ! empty($maxLength) ) { $field->inputOptions['maxlength'] = $maxLength; $id = Html::getInputId($field->model, $field->attribute); static::widget( [ 'selector' => '#'.$id, 'clientOptions' => $clientOptions ]); } if ( $render ) { echo $field; } return $field; }
php
public static function apply($field, $clientOptions, $render = true) { if ( isset($field->inputOptions['maxlength'])) { $maxLength = $field->inputOptions['maxlength']; } else { $maxLength = static::getMaxLength($field->model, Html::getAttributeName($field->attribute)); } if ( ! empty($maxLength) ) { $field->inputOptions['maxlength'] = $maxLength; $id = Html::getInputId($field->model, $field->attribute); static::widget( [ 'selector' => '#'.$id, 'clientOptions' => $clientOptions ]); } if ( $render ) { echo $field; } return $field; }
[ "public", "static", "function", "apply", "(", "$", "field", ",", "$", "clientOptions", ",", "$", "render", "=", "true", ")", "{", "if", "(", "isset", "(", "$", "field", "->", "inputOptions", "[", "'maxlength'", "]", ")", ")", "{", "$", "maxLength", "=", "$", "field", "->", "inputOptions", "[", "'maxlength'", "]", ";", "}", "else", "{", "$", "maxLength", "=", "static", "::", "getMaxLength", "(", "$", "field", "->", "model", ",", "Html", "::", "getAttributeName", "(", "$", "field", "->", "attribute", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "maxLength", ")", ")", "{", "$", "field", "->", "inputOptions", "[", "'maxlength'", "]", "=", "$", "maxLength", ";", "$", "id", "=", "Html", "::", "getInputId", "(", "$", "field", "->", "model", ",", "$", "field", "->", "attribute", ")", ";", "static", "::", "widget", "(", "[", "'selector'", "=>", "'#'", ".", "$", "id", ",", "'clientOptions'", "=>", "$", "clientOptions", "]", ")", ";", "}", "if", "(", "$", "render", ")", "{", "echo", "$", "field", ";", "}", "return", "$", "field", ";", "}" ]
Add the maxlength attribute to an ActiveField. The plugin requires that the max number of characters is specified as the HTML5 attribute "maxlength". This method adds this attribute if it is not already defined into the HTML attributes of an ActiveField. The value is retrieved from the StringValidator settings that is attached to the model attribute. Note that if maxlength can't be defined, the plugin is not registred for the view. Note that this method is deprecated and should be replaced by ActiveField widget initialization as explained in the README file. @deprecated since Yii2 2.0.3 it is possible to set the maxlength HTML attribute of a text input [Read more](http://www.yiiframework.com/doc-2.0/yii-widgets-activefield.html#textInput%28%29-detail) @param yii\widgets\ActiveField $field @param array $clientOptions Bootstrap maxlength plugin options @param boolean $render when true, the $field is output @return yii\widgets\ActiveField the field containing the "maxlength" option (if it could be obtained)
[ "Add", "the", "maxlength", "attribute", "to", "an", "ActiveField", "." ]
87ba6bf179a8db398bff0aaee6701a1e6dfc8b3b
https://github.com/raoul2000/yii2-twbsmaxlength-widget/blob/87ba6bf179a8db398bff0aaee6701a1e6dfc8b3b/TwbsMaxlength.php#L161-L180
15,650
raoul2000/yii2-twbsmaxlength-widget
TwbsMaxlength.php
TwbsMaxlength.getMaxLength
public static function getMaxLength($model, $attribute, $defaultValue = null) { $maxLength = null; foreach ($model->getActiveValidators($attribute) as $validator) { if ( $validator instanceof yii\validators\StringValidator) { $maxLength = $validator->max; break; } } return $maxLength !== null ? $maxLength : $defaultValue; }
php
public static function getMaxLength($model, $attribute, $defaultValue = null) { $maxLength = null; foreach ($model->getActiveValidators($attribute) as $validator) { if ( $validator instanceof yii\validators\StringValidator) { $maxLength = $validator->max; break; } } return $maxLength !== null ? $maxLength : $defaultValue; }
[ "public", "static", "function", "getMaxLength", "(", "$", "model", ",", "$", "attribute", ",", "$", "defaultValue", "=", "null", ")", "{", "$", "maxLength", "=", "null", ";", "foreach", "(", "$", "model", "->", "getActiveValidators", "(", "$", "attribute", ")", "as", "$", "validator", ")", "{", "if", "(", "$", "validator", "instanceof", "yii", "\\", "validators", "\\", "StringValidator", ")", "{", "$", "maxLength", "=", "$", "validator", "->", "max", ";", "break", ";", "}", "}", "return", "$", "maxLength", "!==", "null", "?", "$", "maxLength", ":", "$", "defaultValue", ";", "}" ]
Find the maxlength parameter for an attribute's model. This method searches for a yii\validators\StringValidator among all the active validators (based on the current model scenario). If it founds one, it returns the max length parameter value. If no such value can be found because it is not defined or because no StringValidator is active, $defaultValue is returned. @param yii\base\Model $model @param string $attribute the attribute name @return integer | null the maxlength setting @see yii\validators\StringValidator
[ "Find", "the", "maxlength", "parameter", "for", "an", "attribute", "s", "model", "." ]
87ba6bf179a8db398bff0aaee6701a1e6dfc8b3b
https://github.com/raoul2000/yii2-twbsmaxlength-widget/blob/87ba6bf179a8db398bff0aaee6701a1e6dfc8b3b/TwbsMaxlength.php#L194-L204
15,651
drunomics/service-utils
src/Core/Entity/EntityTypeManagerTrait.php
EntityTypeManagerTrait.getEntityTypeManager
public function getEntityTypeManager() { if (empty($this->entityTypeManager)) { $this->entityTypeManager = \Drupal::entityTypeManager(); } return $this->entityTypeManager; }
php
public function getEntityTypeManager() { if (empty($this->entityTypeManager)) { $this->entityTypeManager = \Drupal::entityTypeManager(); } return $this->entityTypeManager; }
[ "public", "function", "getEntityTypeManager", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "entityTypeManager", ")", ")", "{", "$", "this", "->", "entityTypeManager", "=", "\\", "Drupal", "::", "entityTypeManager", "(", ")", ";", "}", "return", "$", "this", "->", "entityTypeManager", ";", "}" ]
Gets the entity type manager. @return \Drupal\Core\Entity\EntityTypeManagerInterface The entity type manager.
[ "Gets", "the", "entity", "type", "manager", "." ]
56761750043132365ef4ae5d9e0cf4263459328f
https://github.com/drunomics/service-utils/blob/56761750043132365ef4ae5d9e0cf4263459328f/src/Core/Entity/EntityTypeManagerTrait.php#L38-L43
15,652
axelitus/php-base
src/Num.php
Num.parse
public static function parse($value, $default = null) { if (!is_string($value) || !is_numeric($value)) { return $default; } if(Int::extIs($value)){ return Int::parse($value); } else { return Float::parse($value); } }
php
public static function parse($value, $default = null) { if (!is_string($value) || !is_numeric($value)) { return $default; } if(Int::extIs($value)){ return Int::parse($value); } else { return Float::parse($value); } }
[ "public", "static", "function", "parse", "(", "$", "value", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "is_string", "(", "$", "value", ")", "||", "!", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "$", "default", ";", "}", "if", "(", "Int", "::", "extIs", "(", "$", "value", ")", ")", "{", "return", "Int", "::", "parse", "(", "$", "value", ")", ";", "}", "else", "{", "return", "Float", "::", "parse", "(", "$", "value", ")", ";", "}", "}" ]
Parses a string numeric value into an integer or a float. @param string $value The value to parse. @param null $default The default return value if the given value is not a string or is not numeric. @return mixed Returns the parsed value or the default value.
[ "Parses", "a", "string", "numeric", "value", "into", "an", "integer", "or", "a", "float", "." ]
c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075
https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Num.php#L68-L79
15,653
axelitus/php-base
src/Num.php
Num.compare
public static function compare($num1, $num2) { if (!static::is($num1) || !static::is($num2)) { throw new \InvalidArgumentException("The \$num1 and \$num2 parameters must be numeric."); } return ($num1 - $num2); }
php
public static function compare($num1, $num2) { if (!static::is($num1) || !static::is($num2)) { throw new \InvalidArgumentException("The \$num1 and \$num2 parameters must be numeric."); } return ($num1 - $num2); }
[ "public", "static", "function", "compare", "(", "$", "num1", ",", "$", "num2", ")", "{", "if", "(", "!", "static", "::", "is", "(", "$", "num1", ")", "||", "!", "static", "::", "is", "(", "$", "num2", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"The \\$num1 and \\$num2 parameters must be numeric.\"", ")", ";", "}", "return", "(", "$", "num1", "-", "$", "num2", ")", ";", "}" ]
Compares two numeric values. The returning value contains the actual value difference. @param int|float $num1 The left operand. @param int|float $num2 The right operand. @return int Returns <0 if $num1<$num2, =0 if $num1 == $num2, >0 if $num1>$num2 @throws \InvalidArgumentException
[ "Compares", "two", "numeric", "values", "." ]
c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075
https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Num.php#L128-L135
15,654
goblindegook/Syllables
src/Shortcode.php
Shortcode.output
final public function output( $atts, $content = null, $tag = null ) { if ( empty( $tag ) ) { $tag = $this->get_tag(); } $output = $this->render( $atts, $content, $tag ); /** * Filters the shortcode content. * * @param string $output This shortcode's rendered content. * @param array $atts The attributes used to invoke this shortcode. * @param string $content This shortcode's raw inner content. * @param string $tag This shortcode tag. * @return string This shortcode's filtered content. */ return \apply_filters( 'syllables/shortcode/output', $output, $atts, $content, $tag ); }
php
final public function output( $atts, $content = null, $tag = null ) { if ( empty( $tag ) ) { $tag = $this->get_tag(); } $output = $this->render( $atts, $content, $tag ); /** * Filters the shortcode content. * * @param string $output This shortcode's rendered content. * @param array $atts The attributes used to invoke this shortcode. * @param string $content This shortcode's raw inner content. * @param string $tag This shortcode tag. * @return string This shortcode's filtered content. */ return \apply_filters( 'syllables/shortcode/output', $output, $atts, $content, $tag ); }
[ "final", "public", "function", "output", "(", "$", "atts", ",", "$", "content", "=", "null", ",", "$", "tag", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "tag", ")", ")", "{", "$", "tag", "=", "$", "this", "->", "get_tag", "(", ")", ";", "}", "$", "output", "=", "$", "this", "->", "render", "(", "$", "atts", ",", "$", "content", ",", "$", "tag", ")", ";", "/**\n\t\t * Filters the shortcode content.\n\t\t *\n\t\t * @param string $output This shortcode's rendered content.\n\t\t * @param array $atts The attributes used to invoke this shortcode.\n\t\t * @param string $content This shortcode's raw inner content.\n\t\t * @param string $tag This shortcode tag.\n\t\t * @return string This shortcode's filtered content.\n\t\t */", "return", "\\", "apply_filters", "(", "'syllables/shortcode/output'", ",", "$", "output", ",", "$", "atts", ",", "$", "content", ",", "$", "tag", ")", ";", "}" ]
Callback that outputs the shortcode. @param array $atts The shortcode's attributes. @param string|null $content (Optional) Content enclosed in shortcode. @param string|null $tag (Optional) Shortcode tag. @return string The rendered shortcode. @uses \apply_filters()
[ "Callback", "that", "outputs", "the", "shortcode", "." ]
1a98cd15e37595a85b242242f88fee38c4e36acc
https://github.com/goblindegook/Syllables/blob/1a98cd15e37595a85b242242f88fee38c4e36acc/src/Shortcode.php#L91-L108
15,655
goblindegook/Syllables
src/Shortcode.php
Shortcode.render
public function render( $atts, $content = null, $tag = null ) { if ( is_callable( $this->callback ) ) { $content = call_user_func( $this->callback, $atts, $content, $tag ); } /** * Filters the shortcode content. * * @param string $content This shortcode's rendered content. * @param array $atts The attributes used to invoke this shortcode. * @param string $tag This shortcode tag. * @return string This shortcode's filtered content. * * @deprecated since 0.3.2. Use the `syllables/shortcode/output` filter hook. */ return \apply_filters( 'syllables/shortcode/render', $content, $atts, $tag ); }
php
public function render( $atts, $content = null, $tag = null ) { if ( is_callable( $this->callback ) ) { $content = call_user_func( $this->callback, $atts, $content, $tag ); } /** * Filters the shortcode content. * * @param string $content This shortcode's rendered content. * @param array $atts The attributes used to invoke this shortcode. * @param string $tag This shortcode tag. * @return string This shortcode's filtered content. * * @deprecated since 0.3.2. Use the `syllables/shortcode/output` filter hook. */ return \apply_filters( 'syllables/shortcode/render', $content, $atts, $tag ); }
[ "public", "function", "render", "(", "$", "atts", ",", "$", "content", "=", "null", ",", "$", "tag", "=", "null", ")", "{", "if", "(", "is_callable", "(", "$", "this", "->", "callback", ")", ")", "{", "$", "content", "=", "call_user_func", "(", "$", "this", "->", "callback", ",", "$", "atts", ",", "$", "content", ",", "$", "tag", ")", ";", "}", "/**\n\t\t * Filters the shortcode content.\n\t\t *\n\t\t * @param string $content This shortcode's rendered content.\n\t\t * @param array $atts The attributes used to invoke this shortcode.\n\t\t * @param string $tag This shortcode tag.\n\t\t * @return string This shortcode's filtered content.\n\t\t *\n\t\t * @deprecated since 0.3.2. Use the `syllables/shortcode/output` filter hook.\n\t\t */", "return", "\\", "apply_filters", "(", "'syllables/shortcode/render'", ",", "$", "content", ",", "$", "atts", ",", "$", "tag", ")", ";", "}" ]
Renders the hooked shortcode. @param array $atts The shortcode's attributes. @param string|null $content (Optional) Content enclosed in shortcode. @param string|null $tag (Optional) Shortcode tag. @return string The rendered shortcode. @uses \apply_filters()
[ "Renders", "the", "hooked", "shortcode", "." ]
1a98cd15e37595a85b242242f88fee38c4e36acc
https://github.com/goblindegook/Syllables/blob/1a98cd15e37595a85b242242f88fee38c4e36acc/src/Shortcode.php#L120-L137
15,656
contao-bootstrap/buttons
src/Netzmacht/Bootstrap/Buttons/Button.php
Button.generate
public function generate() { return sprintf( '<%s %s>%s</%s>%s', $this->tag, parent::generate(), $this->label, $this->tag, PHP_EOL ); }
php
public function generate() { return sprintf( '<%s %s>%s</%s>%s', $this->tag, parent::generate(), $this->label, $this->tag, PHP_EOL ); }
[ "public", "function", "generate", "(", ")", "{", "return", "sprintf", "(", "'<%s %s>%s</%s>%s'", ",", "$", "this", "->", "tag", ",", "parent", "::", "generate", "(", ")", ",", "$", "this", "->", "label", ",", "$", "this", "->", "tag", ",", "PHP_EOL", ")", ";", "}" ]
Generate the button. @return string
[ "Generate", "the", "button", "." ]
f573a24c19ec059aae528a12ba46dfc993844201
https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/Button.php#L106-L116
15,657
baleen/cli
src/CommandBus/Config/InitHandler.php
InitHandler.handle
public function handle(InitMessage $message) { $output = $message->getOutput(); $configStorage = $message->getConfigStorage(); if ($configStorage->isInitialized($message->getConfig())) { $output->writeln(sprintf( '%s is already initialised!', $message->getCliCommand()->getApplication()->getName() )); return; } $result = $configStorage->write($message->getConfig()); if ($result !== false) { $msg = sprintf('Config file created at "<info>%s</info>".', $message->getConfig()->getFileName()); } else { $msg = sprintf( '<error>Error: Could not create and write file "<info>%s</info>". '. 'Please check file and directory permissions.</error>', $message->getConfig()->getFileName() ); } $output->writeln($msg); }
php
public function handle(InitMessage $message) { $output = $message->getOutput(); $configStorage = $message->getConfigStorage(); if ($configStorage->isInitialized($message->getConfig())) { $output->writeln(sprintf( '%s is already initialised!', $message->getCliCommand()->getApplication()->getName() )); return; } $result = $configStorage->write($message->getConfig()); if ($result !== false) { $msg = sprintf('Config file created at "<info>%s</info>".', $message->getConfig()->getFileName()); } else { $msg = sprintf( '<error>Error: Could not create and write file "<info>%s</info>". '. 'Please check file and directory permissions.</error>', $message->getConfig()->getFileName() ); } $output->writeln($msg); }
[ "public", "function", "handle", "(", "InitMessage", "$", "message", ")", "{", "$", "output", "=", "$", "message", "->", "getOutput", "(", ")", ";", "$", "configStorage", "=", "$", "message", "->", "getConfigStorage", "(", ")", ";", "if", "(", "$", "configStorage", "->", "isInitialized", "(", "$", "message", "->", "getConfig", "(", ")", ")", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'%s is already initialised!'", ",", "$", "message", "->", "getCliCommand", "(", ")", "->", "getApplication", "(", ")", "->", "getName", "(", ")", ")", ")", ";", "return", ";", "}", "$", "result", "=", "$", "configStorage", "->", "write", "(", "$", "message", "->", "getConfig", "(", ")", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "$", "msg", "=", "sprintf", "(", "'Config file created at \"<info>%s</info>\".'", ",", "$", "message", "->", "getConfig", "(", ")", "->", "getFileName", "(", ")", ")", ";", "}", "else", "{", "$", "msg", "=", "sprintf", "(", "'<error>Error: Could not create and write file \"<info>%s</info>\". '", ".", "'Please check file and directory permissions.</error>'", ",", "$", "message", "->", "getConfig", "(", ")", "->", "getFileName", "(", ")", ")", ";", "}", "$", "output", "->", "writeln", "(", "$", "msg", ")", ";", "}" ]
Handle an InitMessage. Creates an end-user configuration file using default values. If the file already exists it simply exists without doing anything. @param InitMessage $message
[ "Handle", "an", "InitMessage", ".", "Creates", "an", "end", "-", "user", "configuration", "file", "using", "default", "values", ".", "If", "the", "file", "already", "exists", "it", "simply", "exists", "without", "doing", "anything", "." ]
2ecbc7179c5800c9075fd93204ef25da375536ed
https://github.com/baleen/cli/blob/2ecbc7179c5800c9075fd93204ef25da375536ed/src/CommandBus/Config/InitHandler.php#L36-L62
15,658
pageon/SlackWebhookMonolog
src/Slack/Payload.php
Payload.setIcon
private function setIcon() { if (!$this->slackConfig->getCustomUser()->hasIcon()) { return; } $iconType = 'icon_' . $this->slackConfig->getCustomUser()->getIcon()->getType(); $this->payload[$iconType] = $this->slackConfig->getCustomUser()->getIcon(); }
php
private function setIcon() { if (!$this->slackConfig->getCustomUser()->hasIcon()) { return; } $iconType = 'icon_' . $this->slackConfig->getCustomUser()->getIcon()->getType(); $this->payload[$iconType] = $this->slackConfig->getCustomUser()->getIcon(); }
[ "private", "function", "setIcon", "(", ")", "{", "if", "(", "!", "$", "this", "->", "slackConfig", "->", "getCustomUser", "(", ")", "->", "hasIcon", "(", ")", ")", "{", "return", ";", "}", "$", "iconType", "=", "'icon_'", ".", "$", "this", "->", "slackConfig", "->", "getCustomUser", "(", ")", "->", "getIcon", "(", ")", "->", "getType", "(", ")", ";", "$", "this", "->", "payload", "[", "$", "iconType", "]", "=", "$", "this", "->", "slackConfig", "->", "getCustomUser", "(", ")", "->", "getIcon", "(", ")", ";", "}" ]
Set a custom icon if available.
[ "Set", "a", "custom", "icon", "if", "available", "." ]
6755060ddd6429620fd4c7decbb95f05463fc36b
https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Payload.php#L93-L101
15,659
pageon/SlackWebhookMonolog
src/Slack/Payload.php
Payload.setUsername
private function setUsername() { if (!$this->slackConfig->getCustomUser()->hasUsername()) { return; } $this->payload['username'] = $this->slackConfig->getCustomUser()->getUsername(); }
php
private function setUsername() { if (!$this->slackConfig->getCustomUser()->hasUsername()) { return; } $this->payload['username'] = $this->slackConfig->getCustomUser()->getUsername(); }
[ "private", "function", "setUsername", "(", ")", "{", "if", "(", "!", "$", "this", "->", "slackConfig", "->", "getCustomUser", "(", ")", "->", "hasUsername", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "payload", "[", "'username'", "]", "=", "$", "this", "->", "slackConfig", "->", "getCustomUser", "(", ")", "->", "getUsername", "(", ")", ";", "}" ]
Set a custom username if available.
[ "Set", "a", "custom", "username", "if", "available", "." ]
6755060ddd6429620fd4c7decbb95f05463fc36b
https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Payload.php#L106-L113
15,660
pageon/SlackWebhookMonolog
src/Slack/Payload.php
Payload.setChannel
private function setChannel() { if (!$this->slackConfig->getWebhook()->hasCustomChannel()) { return; } $this->payload['channel'] = $this->slackConfig->getWebhook()->getCustomChannel(); }
php
private function setChannel() { if (!$this->slackConfig->getWebhook()->hasCustomChannel()) { return; } $this->payload['channel'] = $this->slackConfig->getWebhook()->getCustomChannel(); }
[ "private", "function", "setChannel", "(", ")", "{", "if", "(", "!", "$", "this", "->", "slackConfig", "->", "getWebhook", "(", ")", "->", "hasCustomChannel", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "payload", "[", "'channel'", "]", "=", "$", "this", "->", "slackConfig", "->", "getWebhook", "(", ")", "->", "getCustomChannel", "(", ")", ";", "}" ]
Set a custom channel if available.
[ "Set", "a", "custom", "channel", "if", "available", "." ]
6755060ddd6429620fd4c7decbb95f05463fc36b
https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Payload.php#L118-L125
15,661
pageon/SlackWebhookMonolog
src/Slack/Payload.php
Payload.setErrorData
private function setErrorData() { if (!isset($this->record['context']['error'])) { return; } $this->errorData = $this->record['context']['error']; // remove the error from the context so we can use it for for other things. unset($this->record['context']['error']); }
php
private function setErrorData() { if (!isset($this->record['context']['error'])) { return; } $this->errorData = $this->record['context']['error']; // remove the error from the context so we can use it for for other things. unset($this->record['context']['error']); }
[ "private", "function", "setErrorData", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "record", "[", "'context'", "]", "[", "'error'", "]", ")", ")", "{", "return", ";", "}", "$", "this", "->", "errorData", "=", "$", "this", "->", "record", "[", "'context'", "]", "[", "'error'", "]", ";", "// remove the error from the context so we can use it for for other things.", "unset", "(", "$", "this", "->", "record", "[", "'context'", "]", "[", "'error'", "]", ")", ";", "}" ]
If available set the error data.
[ "If", "available", "set", "the", "error", "data", "." ]
6755060ddd6429620fd4c7decbb95f05463fc36b
https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Payload.php#L130-L140
15,662
DeprecatedPackages/CodingStandard
src/ZenifyCodingStandard/Sniffs/Namespaces/UseDeclarationSniff.php
UseDeclarationSniff.shouldIgnoreUse
private function shouldIgnoreUse(PHP_CodeSniffer_File $file, $position) : bool { $tokens = $file->getTokens(); // Ignore USE keywords inside closures. $next = $file->findNext(T_WHITESPACE, ($position + 1), NULL, TRUE); if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS) { return TRUE; } // Ignore USE keywords for traits. if ($file->hasCondition($position, [T_CLASS, T_TRAIT]) === TRUE) { return TRUE; } return FALSE; }
php
private function shouldIgnoreUse(PHP_CodeSniffer_File $file, $position) : bool { $tokens = $file->getTokens(); // Ignore USE keywords inside closures. $next = $file->findNext(T_WHITESPACE, ($position + 1), NULL, TRUE); if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS) { return TRUE; } // Ignore USE keywords for traits. if ($file->hasCondition($position, [T_CLASS, T_TRAIT]) === TRUE) { return TRUE; } return FALSE; }
[ "private", "function", "shouldIgnoreUse", "(", "PHP_CodeSniffer_File", "$", "file", ",", "$", "position", ")", ":", "bool", "{", "$", "tokens", "=", "$", "file", "->", "getTokens", "(", ")", ";", "// Ignore USE keywords inside closures.", "$", "next", "=", "$", "file", "->", "findNext", "(", "T_WHITESPACE", ",", "(", "$", "position", "+", "1", ")", ",", "NULL", ",", "TRUE", ")", ";", "if", "(", "$", "tokens", "[", "$", "next", "]", "[", "'code'", "]", "===", "T_OPEN_PARENTHESIS", ")", "{", "return", "TRUE", ";", "}", "// Ignore USE keywords for traits.", "if", "(", "$", "file", "->", "hasCondition", "(", "$", "position", ",", "[", "T_CLASS", ",", "T_TRAIT", "]", ")", "===", "TRUE", ")", "{", "return", "TRUE", ";", "}", "return", "FALSE", ";", "}" ]
Check if this use statement is part of the namespace block. @param PHP_CodeSniffer_File $file @param int|bool $position
[ "Check", "if", "this", "use", "statement", "is", "part", "of", "the", "namespace", "block", "." ]
071a296bca199c8b7341e7c9e2f20f33d81b230e
https://github.com/DeprecatedPackages/CodingStandard/blob/071a296bca199c8b7341e7c9e2f20f33d81b230e/src/ZenifyCodingStandard/Sniffs/Namespaces/UseDeclarationSniff.php#L84-L100
15,663
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/LoginLogQuery.php
LoginLogQuery.filterByClientAddress
public function filterByClientAddress($clientAddress = null, $comparison = null) { if (null === $comparison) { if (is_array($clientAddress)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $clientAddress)) { $clientAddress = str_replace('*', '%', $clientAddress); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LoginLogTableMap::COL_CLIENT_ADDRESS, $clientAddress, $comparison); }
php
public function filterByClientAddress($clientAddress = null, $comparison = null) { if (null === $comparison) { if (is_array($clientAddress)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $clientAddress)) { $clientAddress = str_replace('*', '%', $clientAddress); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LoginLogTableMap::COL_CLIENT_ADDRESS, $clientAddress, $comparison); }
[ "public", "function", "filterByClientAddress", "(", "$", "clientAddress", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "clientAddress", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "clientAddress", ")", ")", "{", "$", "clientAddress", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "clientAddress", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "LoginLogTableMap", "::", "COL_CLIENT_ADDRESS", ",", "$", "clientAddress", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the client_address column Example usage: <code> $query->filterByClientAddress('fooValue'); // WHERE client_address = 'fooValue' $query->filterByClientAddress('%fooValue%'); // WHERE client_address LIKE '%fooValue%' </code> @param string $clientAddress The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildLoginLogQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "client_address", "column" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LoginLogQuery.php#L467-L479
15,664
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/LoginLogQuery.php
LoginLogQuery.filterByClientIp
public function filterByClientIp($clientIp = null, $comparison = null) { if (null === $comparison) { if (is_array($clientIp)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $clientIp)) { $clientIp = str_replace('*', '%', $clientIp); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LoginLogTableMap::COL_CLIENT_IP, $clientIp, $comparison); }
php
public function filterByClientIp($clientIp = null, $comparison = null) { if (null === $comparison) { if (is_array($clientIp)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $clientIp)) { $clientIp = str_replace('*', '%', $clientIp); $comparison = Criteria::LIKE; } } return $this->addUsingAlias(LoginLogTableMap::COL_CLIENT_IP, $clientIp, $comparison); }
[ "public", "function", "filterByClientIp", "(", "$", "clientIp", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "if", "(", "is_array", "(", "$", "clientIp", ")", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "elseif", "(", "preg_match", "(", "'/[\\%\\*]/'", ",", "$", "clientIp", ")", ")", "{", "$", "clientIp", "=", "str_replace", "(", "'*'", ",", "'%'", ",", "$", "clientIp", ")", ";", "$", "comparison", "=", "Criteria", "::", "LIKE", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "LoginLogTableMap", "::", "COL_CLIENT_IP", ",", "$", "clientIp", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the client_ip column Example usage: <code> $query->filterByClientIp('fooValue'); // WHERE client_ip = 'fooValue' $query->filterByClientIp('%fooValue%'); // WHERE client_ip LIKE '%fooValue%' </code> @param string $clientIp The value to use as filter. Accepts wildcards (* and % trigger a LIKE) @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildLoginLogQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "client_ip", "column" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/LoginLogQuery.php#L496-L508
15,665
withfatpanda/illuminate-wordpress
src/WordPress/Models/PostBuilder.php
PostBuilder.with
function with($meta, $operator = null, $value = null) { list($value, $operator) = $this->prepareValueAndOperator( $value, $operator, func_num_args() == 2 ); static $count; if (empty($count)) { $count = 0; } if (!is_array($meta)) { $meta = [ $meta => $value ]; } foreach($meta as $key => $value) { $alias = '_with_condition_'.(++$count); $this->query->join("postmeta as {$alias}", "{$alias}.post_id", '=', 'ID'); $this->query->where("{$alias}.meta_key", '_' . $key); $this->query->where("{$alias}.meta_value", $operator, $value); } return $this; }
php
function with($meta, $operator = null, $value = null) { list($value, $operator) = $this->prepareValueAndOperator( $value, $operator, func_num_args() == 2 ); static $count; if (empty($count)) { $count = 0; } if (!is_array($meta)) { $meta = [ $meta => $value ]; } foreach($meta as $key => $value) { $alias = '_with_condition_'.(++$count); $this->query->join("postmeta as {$alias}", "{$alias}.post_id", '=', 'ID'); $this->query->where("{$alias}.meta_key", '_' . $key); $this->query->where("{$alias}.meta_value", $operator, $value); } return $this; }
[ "function", "with", "(", "$", "meta", ",", "$", "operator", "=", "null", ",", "$", "value", "=", "null", ")", "{", "list", "(", "$", "value", ",", "$", "operator", ")", "=", "$", "this", "->", "prepareValueAndOperator", "(", "$", "value", ",", "$", "operator", ",", "func_num_args", "(", ")", "==", "2", ")", ";", "static", "$", "count", ";", "if", "(", "empty", "(", "$", "count", ")", ")", "{", "$", "count", "=", "0", ";", "}", "if", "(", "!", "is_array", "(", "$", "meta", ")", ")", "{", "$", "meta", "=", "[", "$", "meta", "=>", "$", "value", "]", ";", "}", "foreach", "(", "$", "meta", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "alias", "=", "'_with_condition_'", ".", "(", "++", "$", "count", ")", ";", "$", "this", "->", "query", "->", "join", "(", "\"postmeta as {$alias}\"", ",", "\"{$alias}.post_id\"", ",", "'='", ",", "'ID'", ")", ";", "$", "this", "->", "query", "->", "where", "(", "\"{$alias}.meta_key\"", ",", "'_'", ".", "$", "key", ")", ";", "$", "this", "->", "query", "->", "where", "(", "\"{$alias}.meta_value\"", ",", "$", "operator", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add one or more meta data conditions to the query.
[ "Add", "one", "or", "more", "meta", "data", "conditions", "to", "the", "query", "." ]
b426ca81a55367459430c974932ee5a941d759d8
https://github.com/withfatpanda/illuminate-wordpress/blob/b426ca81a55367459430c974932ee5a941d759d8/src/WordPress/Models/PostBuilder.php#L11-L35
15,666
CalderaWP/magic-tags
src/magictag.php
magictag.do_magic_tag
public function do_magic_tag($content){ // check for magics preg_match_all("/\{(.+?)\}/", (string) $content, $magics); // on found tags if(!empty($magics[1])){ foreach($magics[1] as $magic_key=>$magic_tag){ $params = explode(':', $magic_tag, 2 ); if( empty( $params[1] ) ){ continue; } // filter a general tag using the second argument as the original tag $filter_value = apply_filters( 'caldera_magic_tag', apply_filters( "caldera_magic_tag-{$params[0]}", $params[1] ) , $magics[0][$magic_key]); // chech the tag changed if( $filter_value !== $params[1] ){ // on a difference in the tag, replace it. $content = str_replace( $magics[0][$magic_key], $filter_value, $content ); } } } // return content converted or not. return $content; }
php
public function do_magic_tag($content){ // check for magics preg_match_all("/\{(.+?)\}/", (string) $content, $magics); // on found tags if(!empty($magics[1])){ foreach($magics[1] as $magic_key=>$magic_tag){ $params = explode(':', $magic_tag, 2 ); if( empty( $params[1] ) ){ continue; } // filter a general tag using the second argument as the original tag $filter_value = apply_filters( 'caldera_magic_tag', apply_filters( "caldera_magic_tag-{$params[0]}", $params[1] ) , $magics[0][$magic_key]); // chech the tag changed if( $filter_value !== $params[1] ){ // on a difference in the tag, replace it. $content = str_replace( $magics[0][$magic_key], $filter_value, $content ); } } } // return content converted or not. return $content; }
[ "public", "function", "do_magic_tag", "(", "$", "content", ")", "{", "// check for magics", "preg_match_all", "(", "\"/\\{(.+?)\\}/\"", ",", "(", "string", ")", "$", "content", ",", "$", "magics", ")", ";", "// on found tags", "if", "(", "!", "empty", "(", "$", "magics", "[", "1", "]", ")", ")", "{", "foreach", "(", "$", "magics", "[", "1", "]", "as", "$", "magic_key", "=>", "$", "magic_tag", ")", "{", "$", "params", "=", "explode", "(", "':'", ",", "$", "magic_tag", ",", "2", ")", ";", "if", "(", "empty", "(", "$", "params", "[", "1", "]", ")", ")", "{", "continue", ";", "}", "// filter a general tag using the second argument as the original tag", "$", "filter_value", "=", "apply_filters", "(", "'caldera_magic_tag'", ",", "apply_filters", "(", "\"caldera_magic_tag-{$params[0]}\"", ",", "$", "params", "[", "1", "]", ")", ",", "$", "magics", "[", "0", "]", "[", "$", "magic_key", "]", ")", ";", "// chech the tag changed", "if", "(", "$", "filter_value", "!==", "$", "params", "[", "1", "]", ")", "{", "// on a difference in the tag, replace it.", "$", "content", "=", "str_replace", "(", "$", "magics", "[", "0", "]", "[", "$", "magic_key", "]", ",", "$", "filter_value", ",", "$", "content", ")", ";", "}", "}", "}", "// return content converted or not.", "return", "$", "content", ";", "}" ]
Renders a magic tag @return string converted string with matched tags replaced
[ "Renders", "a", "magic", "tag" ]
0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9
https://github.com/CalderaWP/magic-tags/blob/0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9/src/magictag.php#L48-L71
15,667
CalderaWP/magic-tags
src/magictag.php
magictag.get_post_value
private function get_post_value( $field, $in_params, $post ){ if( !is_object( $post ) ){ return $in_params; } if ( 'permalink' == $field || 'post_permalink' == $field ) { return esc_url( get_permalink( $post->ID ) ); } //handle auto-generated and <!--more--> tag excerpts @since 1.1.0 if ( 'post_excerpt' == $field && '' == $post->post_excerpt ) { if ( 0 < strpos( $post->post_content, '<!--more-->' ) ){ $excerpt = substr( $post->post_content, 0, strpos( $post->post_content, '<!--more-->') ); } else { /** * This filer is duplicated from WordPress core to respect core setting for excerpt length. * * It is documented in wp-includes/formatting.php */ $excerpt_length = apply_filters( 'excerpt_length', 55 ); $excerpt = wp_trim_words( $post->post_content, $excerpt_length, '' ); } return $excerpt; } //possibly do a post_thumbnail magic tag @since 1.1.0 $maybe_thumbnail = $this->maybe_do_post_thumbnail( $field, $post ); if ( filter_var( $maybe_thumbnail, FILTER_VALIDATE_URL ) ) { return $maybe_thumbnail; } if( isset( $post->{$field} ) ){ return implode( ', ', (array) $post->{$field} ); } return $in_params; }
php
private function get_post_value( $field, $in_params, $post ){ if( !is_object( $post ) ){ return $in_params; } if ( 'permalink' == $field || 'post_permalink' == $field ) { return esc_url( get_permalink( $post->ID ) ); } //handle auto-generated and <!--more--> tag excerpts @since 1.1.0 if ( 'post_excerpt' == $field && '' == $post->post_excerpt ) { if ( 0 < strpos( $post->post_content, '<!--more-->' ) ){ $excerpt = substr( $post->post_content, 0, strpos( $post->post_content, '<!--more-->') ); } else { /** * This filer is duplicated from WordPress core to respect core setting for excerpt length. * * It is documented in wp-includes/formatting.php */ $excerpt_length = apply_filters( 'excerpt_length', 55 ); $excerpt = wp_trim_words( $post->post_content, $excerpt_length, '' ); } return $excerpt; } //possibly do a post_thumbnail magic tag @since 1.1.0 $maybe_thumbnail = $this->maybe_do_post_thumbnail( $field, $post ); if ( filter_var( $maybe_thumbnail, FILTER_VALIDATE_URL ) ) { return $maybe_thumbnail; } if( isset( $post->{$field} ) ){ return implode( ', ', (array) $post->{$field} ); } return $in_params; }
[ "private", "function", "get_post_value", "(", "$", "field", ",", "$", "in_params", ",", "$", "post", ")", "{", "if", "(", "!", "is_object", "(", "$", "post", ")", ")", "{", "return", "$", "in_params", ";", "}", "if", "(", "'permalink'", "==", "$", "field", "||", "'post_permalink'", "==", "$", "field", ")", "{", "return", "esc_url", "(", "get_permalink", "(", "$", "post", "->", "ID", ")", ")", ";", "}", "//handle auto-generated and <!--more--> tag excerpts @since 1.1.0", "if", "(", "'post_excerpt'", "==", "$", "field", "&&", "''", "==", "$", "post", "->", "post_excerpt", ")", "{", "if", "(", "0", "<", "strpos", "(", "$", "post", "->", "post_content", ",", "'<!--more-->'", ")", ")", "{", "$", "excerpt", "=", "substr", "(", "$", "post", "->", "post_content", ",", "0", ",", "strpos", "(", "$", "post", "->", "post_content", ",", "'<!--more-->'", ")", ")", ";", "}", "else", "{", "/**\n\t\t\t\t * This filer is duplicated from WordPress core to respect core setting for excerpt length.\n\t\t\t\t *\n\t\t\t\t * It is documented in wp-includes/formatting.php\n\t\t\t\t */", "$", "excerpt_length", "=", "apply_filters", "(", "'excerpt_length'", ",", "55", ")", ";", "$", "excerpt", "=", "wp_trim_words", "(", "$", "post", "->", "post_content", ",", "$", "excerpt_length", ",", "''", ")", ";", "}", "return", "$", "excerpt", ";", "}", "//possibly do a post_thumbnail magic tag @since 1.1.0", "$", "maybe_thumbnail", "=", "$", "this", "->", "maybe_do_post_thumbnail", "(", "$", "field", ",", "$", "post", ")", ";", "if", "(", "filter_var", "(", "$", "maybe_thumbnail", ",", "FILTER_VALIDATE_URL", ")", ")", "{", "return", "$", "maybe_thumbnail", ";", "}", "if", "(", "isset", "(", "$", "post", "->", "{", "$", "field", "}", ")", ")", "{", "return", "implode", "(", "', '", ",", "(", "array", ")", "$", "post", "->", "{", "$", "field", "}", ")", ";", "}", "return", "$", "in_params", ";", "}" ]
Gets a posts meta value @since 0.0.1 @return string post field value
[ "Gets", "a", "posts", "meta", "value" ]
0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9
https://github.com/CalderaWP/magic-tags/blob/0e46a6d187bff87c027ed8a6a9e09446aa5f3bd9/src/magictag.php#L80-L123
15,668
withfatpanda/illuminate-wordpress
src/WordPress/Models/FieldGroup.php
FieldGroup.buildConfig
function buildConfig(Plugin $plugin) { if (!empty($this->fields)) { $this->config['fields'] = []; foreach($this->fields as $field) { $this->config['fields'][] = $field->buildConfig($plugin); } } if (!is_null($this->id)) { $this->config['id'] = $this->id; } return $this->config; }
php
function buildConfig(Plugin $plugin) { if (!empty($this->fields)) { $this->config['fields'] = []; foreach($this->fields as $field) { $this->config['fields'][] = $field->buildConfig($plugin); } } if (!is_null($this->id)) { $this->config['id'] = $this->id; } return $this->config; }
[ "function", "buildConfig", "(", "Plugin", "$", "plugin", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "fields", ")", ")", "{", "$", "this", "->", "config", "[", "'fields'", "]", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "fields", "as", "$", "field", ")", "{", "$", "this", "->", "config", "[", "'fields'", "]", "[", "]", "=", "$", "field", "->", "buildConfig", "(", "$", "plugin", ")", ";", "}", "}", "if", "(", "!", "is_null", "(", "$", "this", "->", "id", ")", ")", "{", "$", "this", "->", "config", "[", "'id'", "]", "=", "$", "this", "->", "id", ";", "}", "return", "$", "this", "->", "config", ";", "}" ]
Build field group config @return array
[ "Build", "field", "group", "config" ]
b426ca81a55367459430c974932ee5a941d759d8
https://github.com/withfatpanda/illuminate-wordpress/blob/b426ca81a55367459430c974932ee5a941d759d8/src/WordPress/Models/FieldGroup.php#L196-L210
15,669
phramework/jsonapi
src/Controller/GET.php
GET.handleGET
protected static function handleGET( $parameters, $modelClass, $primaryDataParameters = [], $relationshipParameters = [] ) { $page = $modelClass::parsePage($parameters); $filter = $modelClass::parseFilter($parameters); $sort = $modelClass::parseSort($parameters); $fields = $modelClass::parseFields($parameters); $requestInclude = static::getRequestInclude($parameters, $modelClass); $data = $modelClass::get( $page, $filter, $sort, $fields, ...$primaryDataParameters ); //Get included data $includedData = $modelClass::getIncludedData( $data, $requestInclude, $fields, $relationshipParameters ); $meta = (object) [ 'page' => ( $page === null ? $modelClass::getDefaultPage() : $page ) ]; return static::viewData( $data, (object) [ 'self' => $modelClass::getSelfLink() ], $meta, (empty($requestInclude) ? null : $includedData) ); }
php
protected static function handleGET( $parameters, $modelClass, $primaryDataParameters = [], $relationshipParameters = [] ) { $page = $modelClass::parsePage($parameters); $filter = $modelClass::parseFilter($parameters); $sort = $modelClass::parseSort($parameters); $fields = $modelClass::parseFields($parameters); $requestInclude = static::getRequestInclude($parameters, $modelClass); $data = $modelClass::get( $page, $filter, $sort, $fields, ...$primaryDataParameters ); //Get included data $includedData = $modelClass::getIncludedData( $data, $requestInclude, $fields, $relationshipParameters ); $meta = (object) [ 'page' => ( $page === null ? $modelClass::getDefaultPage() : $page ) ]; return static::viewData( $data, (object) [ 'self' => $modelClass::getSelfLink() ], $meta, (empty($requestInclude) ? null : $includedData) ); }
[ "protected", "static", "function", "handleGET", "(", "$", "parameters", ",", "$", "modelClass", ",", "$", "primaryDataParameters", "=", "[", "]", ",", "$", "relationshipParameters", "=", "[", "]", ")", "{", "$", "page", "=", "$", "modelClass", "::", "parsePage", "(", "$", "parameters", ")", ";", "$", "filter", "=", "$", "modelClass", "::", "parseFilter", "(", "$", "parameters", ")", ";", "$", "sort", "=", "$", "modelClass", "::", "parseSort", "(", "$", "parameters", ")", ";", "$", "fields", "=", "$", "modelClass", "::", "parseFields", "(", "$", "parameters", ")", ";", "$", "requestInclude", "=", "static", "::", "getRequestInclude", "(", "$", "parameters", ",", "$", "modelClass", ")", ";", "$", "data", "=", "$", "modelClass", "::", "get", "(", "$", "page", ",", "$", "filter", ",", "$", "sort", ",", "$", "fields", ",", "...", "$", "primaryDataParameters", ")", ";", "//Get included data", "$", "includedData", "=", "$", "modelClass", "::", "getIncludedData", "(", "$", "data", ",", "$", "requestInclude", ",", "$", "fields", ",", "$", "relationshipParameters", ")", ";", "$", "meta", "=", "(", "object", ")", "[", "'page'", "=>", "(", "$", "page", "===", "null", "?", "$", "modelClass", "::", "getDefaultPage", "(", ")", ":", "$", "page", ")", "]", ";", "return", "static", "::", "viewData", "(", "$", "data", ",", "(", "object", ")", "[", "'self'", "=>", "$", "modelClass", "::", "getSelfLink", "(", ")", "]", ",", "$", "meta", ",", "(", "empty", "(", "$", "requestInclude", ")", "?", "null", ":", "$", "includedData", ")", ")", ";", "}" ]
handles GET requests @param object $parameters Request parameters @param string $modelClass Resource's primary model class name to be used @param array $primaryDataParameters *[Optional]* Array with any additional arguments that the primary data is requiring @param array $relationshipParameters [Optional] Array with any additional argument primary data's relationships are requiring @param boolean $filterable *[Optional]* Default is true, if true allows `filter` URI parameters to be parsed for filtering @param boolean $filterableJSON *[Optional]* Default is false, if true allows `filter` URI parameters to be parsed for filtering for JSON encoded fields @param boolean $sortable *[Optional]* Default is true, if true allows sorting @uses $modelClass::get method to fetch resource collection @throws \Exception @throws RequestException @return boolean @todo Force parsing of relationship data when included
[ "handles", "GET", "requests" ]
af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Controller/GET.php#L59-L104
15,670
jan-dolata/crude-crud
src/Engine/CrudeSetupTrait/ColumnFormat.php
ColumnFormat.setColumnFormat
public function setColumnFormat($attr, $format = null) { $formats = is_array($attr) ? $attr : [$attr => $format]; foreach ($formats as $a => $f) $this->_setSingleColumnFormat($a, $f); return $this; }
php
public function setColumnFormat($attr, $format = null) { $formats = is_array($attr) ? $attr : [$attr => $format]; foreach ($formats as $a => $f) $this->_setSingleColumnFormat($a, $f); return $this; }
[ "public", "function", "setColumnFormat", "(", "$", "attr", ",", "$", "format", "=", "null", ")", "{", "$", "formats", "=", "is_array", "(", "$", "attr", ")", "?", "$", "attr", ":", "[", "$", "attr", "=>", "$", "format", "]", ";", "foreach", "(", "$", "formats", "as", "$", "a", "=>", "$", "f", ")", "$", "this", "->", "_setSingleColumnFormat", "(", "$", "a", ",", "$", "f", ")", ";", "return", "$", "this", ";", "}" ]
Sets the Column cell format rules. @param array $columnFormat the column format @return self
[ "Sets", "the", "Column", "cell", "format", "rules", "." ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/ColumnFormat.php#L31-L41
15,671
comelyio/comely
src/Comely/IO/Mailer/Agents/SMTP.php
SMTP.authCredentials
public function authCredentials(string $username, string $password): self { $this->username = $username; $this->password = $password; return $this; }
php
public function authCredentials(string $username, string $password): self { $this->username = $username; $this->password = $password; return $this; }
[ "public", "function", "authCredentials", "(", "string", "$", "username", ",", "string", "$", "password", ")", ":", "self", "{", "$", "this", "->", "username", "=", "$", "username", ";", "$", "this", "->", "password", "=", "$", "password", ";", "return", "$", "this", ";", "}" ]
Set auth. credentials for AUTH LOGIN @param string $username @param string $password @return SMTP
[ "Set", "auth", ".", "credentials", "for", "AUTH", "LOGIN" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Mailer/Agents/SMTP.php#L112-L117
15,672
comelyio/comely
src/Comely/IO/Mailer/Agents/SMTP.php
SMTP.connect
private function connect() { if (!$this->stream) { $errorNum = 0; $errorMsg = ""; $context = @stream_context_create($this->streamOptions); $this->stream = @stream_socket_client( sprintf('%1$s:%2$d', $this->host, $this->port), $errorNum, $errorMsg, $this->timeOut, STREAM_CLIENT_CONNECT, $context ); if (!$this->stream) { throw SMTPException::connectionError($errorNum, $errorMsg); } $this->read(); // Read response from server if ($this->lastResponseCode() !== 220) { throw SMTPException::unexpectedResponse("CONNECT", 220, $this->lastResponseCode()); } // Build specs/options available at remote SMTP server $this->smtpServerOptions( $this->command("EHLO", $this->serverName) ); // Use TLS? if ($this->secure === true) { if ($this->options["startTLS"] !== true) { throw SMTPException::tlsNotAvailable(); } $this->command("STARTTLS", null, 220); $tls = @stream_socket_enable_crypto($this->stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); if (!$tls) { throw SMTPException::tlsNegotiateFailed(); } $this->command("EHLO", $this->serverName); // Resend EHLO command } // Authenticate if ($this->options["authLogin"] === true) { try { $this->command("AUTH LOGIN", null, 334); $this->command(base64_encode($this->username ?? " "), null, 334); $this->command(base64_encode($this->password ?? " "), null, 235); } catch (SMTPException $e) { throw SMTPException::authFailed($this->lastResponse); } } elseif ($this->options["authPlain"] === true) { // Todo: plain authentication throw SMTPException::authUnavailable(); } else { throw SMTPException::authUnavailable(); } } else { try { if (!stream_get_meta_data($this->stream)["timed_out"]) { throw new SMTPException(__METHOD__, "Timed out"); } $this->command("NOOP", null, 250); } catch (SMTPException $e) { $this->stream = null; $this->connect(); return; } } }
php
private function connect() { if (!$this->stream) { $errorNum = 0; $errorMsg = ""; $context = @stream_context_create($this->streamOptions); $this->stream = @stream_socket_client( sprintf('%1$s:%2$d', $this->host, $this->port), $errorNum, $errorMsg, $this->timeOut, STREAM_CLIENT_CONNECT, $context ); if (!$this->stream) { throw SMTPException::connectionError($errorNum, $errorMsg); } $this->read(); // Read response from server if ($this->lastResponseCode() !== 220) { throw SMTPException::unexpectedResponse("CONNECT", 220, $this->lastResponseCode()); } // Build specs/options available at remote SMTP server $this->smtpServerOptions( $this->command("EHLO", $this->serverName) ); // Use TLS? if ($this->secure === true) { if ($this->options["startTLS"] !== true) { throw SMTPException::tlsNotAvailable(); } $this->command("STARTTLS", null, 220); $tls = @stream_socket_enable_crypto($this->stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); if (!$tls) { throw SMTPException::tlsNegotiateFailed(); } $this->command("EHLO", $this->serverName); // Resend EHLO command } // Authenticate if ($this->options["authLogin"] === true) { try { $this->command("AUTH LOGIN", null, 334); $this->command(base64_encode($this->username ?? " "), null, 334); $this->command(base64_encode($this->password ?? " "), null, 235); } catch (SMTPException $e) { throw SMTPException::authFailed($this->lastResponse); } } elseif ($this->options["authPlain"] === true) { // Todo: plain authentication throw SMTPException::authUnavailable(); } else { throw SMTPException::authUnavailable(); } } else { try { if (!stream_get_meta_data($this->stream)["timed_out"]) { throw new SMTPException(__METHOD__, "Timed out"); } $this->command("NOOP", null, 250); } catch (SMTPException $e) { $this->stream = null; $this->connect(); return; } } }
[ "private", "function", "connect", "(", ")", "{", "if", "(", "!", "$", "this", "->", "stream", ")", "{", "$", "errorNum", "=", "0", ";", "$", "errorMsg", "=", "\"\"", ";", "$", "context", "=", "@", "stream_context_create", "(", "$", "this", "->", "streamOptions", ")", ";", "$", "this", "->", "stream", "=", "@", "stream_socket_client", "(", "sprintf", "(", "'%1$s:%2$d'", ",", "$", "this", "->", "host", ",", "$", "this", "->", "port", ")", ",", "$", "errorNum", ",", "$", "errorMsg", ",", "$", "this", "->", "timeOut", ",", "STREAM_CLIENT_CONNECT", ",", "$", "context", ")", ";", "if", "(", "!", "$", "this", "->", "stream", ")", "{", "throw", "SMTPException", "::", "connectionError", "(", "$", "errorNum", ",", "$", "errorMsg", ")", ";", "}", "$", "this", "->", "read", "(", ")", ";", "// Read response from server", "if", "(", "$", "this", "->", "lastResponseCode", "(", ")", "!==", "220", ")", "{", "throw", "SMTPException", "::", "unexpectedResponse", "(", "\"CONNECT\"", ",", "220", ",", "$", "this", "->", "lastResponseCode", "(", ")", ")", ";", "}", "// Build specs/options available at remote SMTP server", "$", "this", "->", "smtpServerOptions", "(", "$", "this", "->", "command", "(", "\"EHLO\"", ",", "$", "this", "->", "serverName", ")", ")", ";", "// Use TLS?", "if", "(", "$", "this", "->", "secure", "===", "true", ")", "{", "if", "(", "$", "this", "->", "options", "[", "\"startTLS\"", "]", "!==", "true", ")", "{", "throw", "SMTPException", "::", "tlsNotAvailable", "(", ")", ";", "}", "$", "this", "->", "command", "(", "\"STARTTLS\"", ",", "null", ",", "220", ")", ";", "$", "tls", "=", "@", "stream_socket_enable_crypto", "(", "$", "this", "->", "stream", ",", "true", ",", "STREAM_CRYPTO_METHOD_TLS_CLIENT", ")", ";", "if", "(", "!", "$", "tls", ")", "{", "throw", "SMTPException", "::", "tlsNegotiateFailed", "(", ")", ";", "}", "$", "this", "->", "command", "(", "\"EHLO\"", ",", "$", "this", "->", "serverName", ")", ";", "// Resend EHLO command", "}", "// Authenticate", "if", "(", "$", "this", "->", "options", "[", "\"authLogin\"", "]", "===", "true", ")", "{", "try", "{", "$", "this", "->", "command", "(", "\"AUTH LOGIN\"", ",", "null", ",", "334", ")", ";", "$", "this", "->", "command", "(", "base64_encode", "(", "$", "this", "->", "username", "??", "\" \"", ")", ",", "null", ",", "334", ")", ";", "$", "this", "->", "command", "(", "base64_encode", "(", "$", "this", "->", "password", "??", "\" \"", ")", ",", "null", ",", "235", ")", ";", "}", "catch", "(", "SMTPException", "$", "e", ")", "{", "throw", "SMTPException", "::", "authFailed", "(", "$", "this", "->", "lastResponse", ")", ";", "}", "}", "elseif", "(", "$", "this", "->", "options", "[", "\"authPlain\"", "]", "===", "true", ")", "{", "// Todo: plain authentication", "throw", "SMTPException", "::", "authUnavailable", "(", ")", ";", "}", "else", "{", "throw", "SMTPException", "::", "authUnavailable", "(", ")", ";", "}", "}", "else", "{", "try", "{", "if", "(", "!", "stream_get_meta_data", "(", "$", "this", "->", "stream", ")", "[", "\"timed_out\"", "]", ")", "{", "throw", "new", "SMTPException", "(", "__METHOD__", ",", "\"Timed out\"", ")", ";", "}", "$", "this", "->", "command", "(", "\"NOOP\"", ",", "null", ",", "250", ")", ";", "}", "catch", "(", "SMTPException", "$", "e", ")", "{", "$", "this", "->", "stream", "=", "null", ";", "$", "this", "->", "connect", "(", ")", ";", "return", ";", "}", "}", "}" ]
Establish connection to SMTP server or revive existing one
[ "Establish", "connection", "to", "SMTP", "server", "or", "revive", "existing", "one" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Mailer/Agents/SMTP.php#L157-L229
15,673
comelyio/comely
src/Comely/IO/Mailer/Agents/SMTP.php
SMTP.command
public function command(string $command, string $args = null, int $expect = 0): string { $sendCommand = $args ? sprintf('%1$s %2$s', $command, $args) : $command; $this->write($sendCommand); $response = $this->read(); $responseCode = $this->lastResponseCode(); if ($expect > 0) { if ($responseCode !== $expect) { throw SMTPException::unexpectedResponse($command, $expect, $responseCode); } } return $response; }
php
public function command(string $command, string $args = null, int $expect = 0): string { $sendCommand = $args ? sprintf('%1$s %2$s', $command, $args) : $command; $this->write($sendCommand); $response = $this->read(); $responseCode = $this->lastResponseCode(); if ($expect > 0) { if ($responseCode !== $expect) { throw SMTPException::unexpectedResponse($command, $expect, $responseCode); } } return $response; }
[ "public", "function", "command", "(", "string", "$", "command", ",", "string", "$", "args", "=", "null", ",", "int", "$", "expect", "=", "0", ")", ":", "string", "{", "$", "sendCommand", "=", "$", "args", "?", "sprintf", "(", "'%1$s %2$s'", ",", "$", "command", ",", "$", "args", ")", ":", "$", "command", ";", "$", "this", "->", "write", "(", "$", "sendCommand", ")", ";", "$", "response", "=", "$", "this", "->", "read", "(", ")", ";", "$", "responseCode", "=", "$", "this", "->", "lastResponseCode", "(", ")", ";", "if", "(", "$", "expect", ">", "0", ")", "{", "if", "(", "$", "responseCode", "!==", "$", "expect", ")", "{", "throw", "SMTPException", "::", "unexpectedResponse", "(", "$", "command", ",", "$", "expect", ",", "$", "responseCode", ")", ";", "}", "}", "return", "$", "response", ";", "}" ]
Send command to server, read response, and make sure response code matches expected code @param string $command @param string|null $args @param int $expect @return string @throws SMTPException
[ "Send", "command", "to", "server", "read", "response", "and", "make", "sure", "response", "code", "matches", "expected", "code" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Mailer/Agents/SMTP.php#L283-L297
15,674
comelyio/comely
src/Comely/IO/Mailer/Agents/SMTP.php
SMTP.read
private function read(): string { $this->lastResponse = fread($this->stream, 1024); // Read up to 1KB $this->lastResponseCode = intval(explode(" ", $this->lastResponse)[0]); $this->lastResponseCode = $this->lastResponseCode > 0 ? $this->lastResponseCode : -1; return $this->lastResponse; }
php
private function read(): string { $this->lastResponse = fread($this->stream, 1024); // Read up to 1KB $this->lastResponseCode = intval(explode(" ", $this->lastResponse)[0]); $this->lastResponseCode = $this->lastResponseCode > 0 ? $this->lastResponseCode : -1; return $this->lastResponse; }
[ "private", "function", "read", "(", ")", ":", "string", "{", "$", "this", "->", "lastResponse", "=", "fread", "(", "$", "this", "->", "stream", ",", "1024", ")", ";", "// Read up to 1KB", "$", "this", "->", "lastResponseCode", "=", "intval", "(", "explode", "(", "\" \"", ",", "$", "this", "->", "lastResponse", ")", "[", "0", "]", ")", ";", "$", "this", "->", "lastResponseCode", "=", "$", "this", "->", "lastResponseCode", ">", "0", "?", "$", "this", "->", "lastResponseCode", ":", "-", "1", ";", "return", "$", "this", "->", "lastResponse", ";", "}" ]
Read response from SMTP server @return string
[ "Read", "response", "from", "SMTP", "server" ]
561ea7aef36fea347a1a79d3ee5597d4057ddf82
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Mailer/Agents/SMTP.php#L314-L320
15,675
stubbles/stubbles-webapp-core
src/main/php/routing/Interceptors.php
Interceptors.executePreInterceptor
private function executePreInterceptor($preInterceptor, Request $request, Response $response) { if (is_callable($preInterceptor)) { return $preInterceptor($request, $response); } if ($preInterceptor instanceof PreInterceptor) { return $preInterceptor->preProcess($request, $response); } $instance = $this->injector->getInstance($preInterceptor); if (!($instance instanceof PreInterceptor)) { $response->write( $response->internalServerError( 'Configured pre interceptor ' . $preInterceptor . ' is not an instance of ' . PreInterceptor::class ) ); return false; } return $instance->preProcess($request, $response); }
php
private function executePreInterceptor($preInterceptor, Request $request, Response $response) { if (is_callable($preInterceptor)) { return $preInterceptor($request, $response); } if ($preInterceptor instanceof PreInterceptor) { return $preInterceptor->preProcess($request, $response); } $instance = $this->injector->getInstance($preInterceptor); if (!($instance instanceof PreInterceptor)) { $response->write( $response->internalServerError( 'Configured pre interceptor ' . $preInterceptor . ' is not an instance of ' . PreInterceptor::class ) ); return false; } return $instance->preProcess($request, $response); }
[ "private", "function", "executePreInterceptor", "(", "$", "preInterceptor", ",", "Request", "$", "request", ",", "Response", "$", "response", ")", "{", "if", "(", "is_callable", "(", "$", "preInterceptor", ")", ")", "{", "return", "$", "preInterceptor", "(", "$", "request", ",", "$", "response", ")", ";", "}", "if", "(", "$", "preInterceptor", "instanceof", "PreInterceptor", ")", "{", "return", "$", "preInterceptor", "->", "preProcess", "(", "$", "request", ",", "$", "response", ")", ";", "}", "$", "instance", "=", "$", "this", "->", "injector", "->", "getInstance", "(", "$", "preInterceptor", ")", ";", "if", "(", "!", "(", "$", "instance", "instanceof", "PreInterceptor", ")", ")", "{", "$", "response", "->", "write", "(", "$", "response", "->", "internalServerError", "(", "'Configured pre interceptor '", ".", "$", "preInterceptor", ".", "' is not an instance of '", ".", "PreInterceptor", "::", "class", ")", ")", ";", "return", "false", ";", "}", "return", "$", "instance", "->", "preProcess", "(", "$", "request", ",", "$", "response", ")", ";", "}" ]
executes pre interceptor @param mixed $preInterceptor @param \stubbles\webapp\Request $request current request @param \stubbles\webapp\Response $response response to send @return bool|null
[ "executes", "pre", "interceptor" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Interceptors.php#L83-L105
15,676
stubbles/stubbles-webapp-core
src/main/php/routing/Interceptors.php
Interceptors.executePostInterceptor
private function executePostInterceptor($postInterceptor, Request $request, Response $response) { if (is_callable($postInterceptor)) { return $postInterceptor($request, $response); } if ($postInterceptor instanceof PostInterceptor) { return $postInterceptor->postProcess($request, $response); } $instance = $this->injector->getInstance($postInterceptor); if (!($instance instanceof PostInterceptor)) { $response->write( $response->internalServerError( 'Configured post interceptor ' . $postInterceptor . ' is not an instance of ' . PostInterceptor::class ) ); return false; } return $instance->postProcess($request, $response); }
php
private function executePostInterceptor($postInterceptor, Request $request, Response $response) { if (is_callable($postInterceptor)) { return $postInterceptor($request, $response); } if ($postInterceptor instanceof PostInterceptor) { return $postInterceptor->postProcess($request, $response); } $instance = $this->injector->getInstance($postInterceptor); if (!($instance instanceof PostInterceptor)) { $response->write( $response->internalServerError( 'Configured post interceptor ' . $postInterceptor . ' is not an instance of ' . PostInterceptor::class ) ); return false; } return $instance->postProcess($request, $response); }
[ "private", "function", "executePostInterceptor", "(", "$", "postInterceptor", ",", "Request", "$", "request", ",", "Response", "$", "response", ")", "{", "if", "(", "is_callable", "(", "$", "postInterceptor", ")", ")", "{", "return", "$", "postInterceptor", "(", "$", "request", ",", "$", "response", ")", ";", "}", "if", "(", "$", "postInterceptor", "instanceof", "PostInterceptor", ")", "{", "return", "$", "postInterceptor", "->", "postProcess", "(", "$", "request", ",", "$", "response", ")", ";", "}", "$", "instance", "=", "$", "this", "->", "injector", "->", "getInstance", "(", "$", "postInterceptor", ")", ";", "if", "(", "!", "(", "$", "instance", "instanceof", "PostInterceptor", ")", ")", "{", "$", "response", "->", "write", "(", "$", "response", "->", "internalServerError", "(", "'Configured post interceptor '", ".", "$", "postInterceptor", ".", "' is not an instance of '", ".", "PostInterceptor", "::", "class", ")", ")", ";", "return", "false", ";", "}", "return", "$", "instance", "->", "postProcess", "(", "$", "request", ",", "$", "response", ")", ";", "}" ]
executes post interceptor @param mixed $postInterceptor @param \stubbles\webapp\Request $request current request @param \stubbles\webapp\Response $response response to send @return bool|null
[ "executes", "post", "interceptor" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Interceptors.php#L133-L155
15,677
ekyna/GlsUniBox
Renderer/LabelRenderer.php
LabelRenderer.text
private function text($text, $size, $x, $y, $color = 'black', $font = 'swiss_normal', $angle = 0) { imagettftext($this->image, $size, $angle, $x, $y, $this->colors[$color], $this->fonts[$font], $text); }
php
private function text($text, $size, $x, $y, $color = 'black', $font = 'swiss_normal', $angle = 0) { imagettftext($this->image, $size, $angle, $x, $y, $this->colors[$color], $this->fonts[$font], $text); }
[ "private", "function", "text", "(", "$", "text", ",", "$", "size", ",", "$", "x", ",", "$", "y", ",", "$", "color", "=", "'black'", ",", "$", "font", "=", "'swiss_normal'", ",", "$", "angle", "=", "0", ")", "{", "imagettftext", "(", "$", "this", "->", "image", ",", "$", "size", ",", "$", "angle", ",", "$", "x", ",", "$", "y", ",", "$", "this", "->", "colors", "[", "$", "color", "]", ",", "$", "this", "->", "fonts", "[", "$", "font", "]", ",", "$", "text", ")", ";", "}" ]
Writes the given text. @param string $text @param int $size @param int $x @param int $y @param string $color @param string $font @param int $angle
[ "Writes", "the", "given", "text", "." ]
b474271ba355c3917074422306dc64abf09584d0
https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Renderer/LabelRenderer.php#L204-L207
15,678
ekyna/GlsUniBox
Renderer/LabelRenderer.php
LabelRenderer.getImageData
private function getImageData() { ob_start(); imagegif($this->image); $output = ob_get_contents(); ob_end_clean(); imagedestroy($this->image); return $output; }
php
private function getImageData() { ob_start(); imagegif($this->image); $output = ob_get_contents(); ob_end_clean(); imagedestroy($this->image); return $output; }
[ "private", "function", "getImageData", "(", ")", "{", "ob_start", "(", ")", ";", "imagegif", "(", "$", "this", "->", "image", ")", ";", "$", "output", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "imagedestroy", "(", "$", "this", "->", "image", ")", ";", "return", "$", "output", ";", "}" ]
Returns the image raw data. @return string
[ "Returns", "the", "image", "raw", "data", "." ]
b474271ba355c3917074422306dc64abf09584d0
https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Renderer/LabelRenderer.php#L214-L223
15,679
ekyna/GlsUniBox
Renderer/LabelRenderer.php
LabelRenderer.getBarcodeDatamatrix
public function getBarcodeDatamatrix($data) { $barcode = new Barcode(); $bobj = $barcode->getBarcodeObj( 'DATAMATRIX', $data, 256, 256, 'black', array(0, 0, 0, 0) )->setBackgroundColor('white'); return $bobj->getPngData(); }
php
public function getBarcodeDatamatrix($data) { $barcode = new Barcode(); $bobj = $barcode->getBarcodeObj( 'DATAMATRIX', $data, 256, 256, 'black', array(0, 0, 0, 0) )->setBackgroundColor('white'); return $bobj->getPngData(); }
[ "public", "function", "getBarcodeDatamatrix", "(", "$", "data", ")", "{", "$", "barcode", "=", "new", "Barcode", "(", ")", ";", "$", "bobj", "=", "$", "barcode", "->", "getBarcodeObj", "(", "'DATAMATRIX'", ",", "$", "data", ",", "256", ",", "256", ",", "'black'", ",", "array", "(", "0", ",", "0", ",", "0", ",", "0", ")", ")", "->", "setBackgroundColor", "(", "'white'", ")", ";", "return", "$", "bobj", "->", "getPngData", "(", ")", ";", "}" ]
Returns the datamatrix from the given data. @param string $data @return string
[ "Returns", "the", "datamatrix", "from", "the", "given", "data", "." ]
b474271ba355c3917074422306dc64abf09584d0
https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Renderer/LabelRenderer.php#L232-L246
15,680
ekyna/GlsUniBox
Renderer/LabelRenderer.php
LabelRenderer.getBarcode128
public function getBarcode128($data) { $barcode = new Barcode(); $bobj = $barcode->getBarcodeObj( 'C128', $data, 380, 135, 'black', array(0, 0, 0, 0) )->setBackgroundColor('white'); return $bobj->getPngData(); }
php
public function getBarcode128($data) { $barcode = new Barcode(); $bobj = $barcode->getBarcodeObj( 'C128', $data, 380, 135, 'black', array(0, 0, 0, 0) )->setBackgroundColor('white'); return $bobj->getPngData(); }
[ "public", "function", "getBarcode128", "(", "$", "data", ")", "{", "$", "barcode", "=", "new", "Barcode", "(", ")", ";", "$", "bobj", "=", "$", "barcode", "->", "getBarcodeObj", "(", "'C128'", ",", "$", "data", ",", "380", ",", "135", ",", "'black'", ",", "array", "(", "0", ",", "0", ",", "0", ",", "0", ")", ")", "->", "setBackgroundColor", "(", "'white'", ")", ";", "return", "$", "bobj", "->", "getPngData", "(", ")", ";", "}" ]
Returns the barcode from the given data. @param string $data @return string
[ "Returns", "the", "barcode", "from", "the", "given", "data", "." ]
b474271ba355c3917074422306dc64abf09584d0
https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Renderer/LabelRenderer.php#L255-L269
15,681
ray-di/Ray.WebFormModule
src/AuraInputInterceptor.php
AuraInputInterceptor.getNamedArguments
private function getNamedArguments(MethodInvocation $invocation) { $submit = []; $params = $invocation->getMethod()->getParameters(); $args = $invocation->getArguments()->getArrayCopy(); foreach ($params as $param) { $arg = array_shift($args); $submit[$param->getName()] = $arg; } // has token ? if (isset($_POST[AntiCsrf::TOKEN_KEY])) { $submit[AntiCsrf::TOKEN_KEY] = $_POST[AntiCsrf::TOKEN_KEY]; } return $submit; }
php
private function getNamedArguments(MethodInvocation $invocation) { $submit = []; $params = $invocation->getMethod()->getParameters(); $args = $invocation->getArguments()->getArrayCopy(); foreach ($params as $param) { $arg = array_shift($args); $submit[$param->getName()] = $arg; } // has token ? if (isset($_POST[AntiCsrf::TOKEN_KEY])) { $submit[AntiCsrf::TOKEN_KEY] = $_POST[AntiCsrf::TOKEN_KEY]; } return $submit; }
[ "private", "function", "getNamedArguments", "(", "MethodInvocation", "$", "invocation", ")", "{", "$", "submit", "=", "[", "]", ";", "$", "params", "=", "$", "invocation", "->", "getMethod", "(", ")", "->", "getParameters", "(", ")", ";", "$", "args", "=", "$", "invocation", "->", "getArguments", "(", ")", "->", "getArrayCopy", "(", ")", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "$", "arg", "=", "array_shift", "(", "$", "args", ")", ";", "$", "submit", "[", "$", "param", "->", "getName", "(", ")", "]", "=", "$", "arg", ";", "}", "// has token ?", "if", "(", "isset", "(", "$", "_POST", "[", "AntiCsrf", "::", "TOKEN_KEY", "]", ")", ")", "{", "$", "submit", "[", "AntiCsrf", "::", "TOKEN_KEY", "]", "=", "$", "_POST", "[", "AntiCsrf", "::", "TOKEN_KEY", "]", ";", "}", "return", "$", "submit", ";", "}" ]
Return arguments as named arguments. @param MethodInvocation $invocation @return array
[ "Return", "arguments", "as", "named", "arguments", "." ]
4b6d33adb4a5c285278a068f3e7a5afdc4e680d9
https://github.com/ray-di/Ray.WebFormModule/blob/4b6d33adb4a5c285278a068f3e7a5afdc4e680d9/src/AuraInputInterceptor.php#L83-L98
15,682
ray-di/Ray.WebFormModule
src/AuraInputInterceptor.php
AuraInputInterceptor.getFormProperty
private function getFormProperty(AbstractValidation $formValidation, $object) { if (! property_exists($object, $formValidation->form)) { throw new InvalidFormPropertyException($formValidation->form); } $prop = (new \ReflectionClass($object))->getProperty($formValidation->form); $prop->setAccessible(true); $form = $prop->getValue($object); if (! $form instanceof AbstractForm) { throw new InvalidFormPropertyException($formValidation->form); } return $form; }
php
private function getFormProperty(AbstractValidation $formValidation, $object) { if (! property_exists($object, $formValidation->form)) { throw new InvalidFormPropertyException($formValidation->form); } $prop = (new \ReflectionClass($object))->getProperty($formValidation->form); $prop->setAccessible(true); $form = $prop->getValue($object); if (! $form instanceof AbstractForm) { throw new InvalidFormPropertyException($formValidation->form); } return $form; }
[ "private", "function", "getFormProperty", "(", "AbstractValidation", "$", "formValidation", ",", "$", "object", ")", "{", "if", "(", "!", "property_exists", "(", "$", "object", ",", "$", "formValidation", "->", "form", ")", ")", "{", "throw", "new", "InvalidFormPropertyException", "(", "$", "formValidation", "->", "form", ")", ";", "}", "$", "prop", "=", "(", "new", "\\", "ReflectionClass", "(", "$", "object", ")", ")", "->", "getProperty", "(", "$", "formValidation", "->", "form", ")", ";", "$", "prop", "->", "setAccessible", "(", "true", ")", ";", "$", "form", "=", "$", "prop", "->", "getValue", "(", "$", "object", ")", ";", "if", "(", "!", "$", "form", "instanceof", "AbstractForm", ")", "{", "throw", "new", "InvalidFormPropertyException", "(", "$", "formValidation", "->", "form", ")", ";", "}", "return", "$", "form", ";", "}" ]
Return form property @param AbstractValidation $formValidation @param object $object @return mixed
[ "Return", "form", "property" ]
4b6d33adb4a5c285278a068f3e7a5afdc4e680d9
https://github.com/ray-di/Ray.WebFormModule/blob/4b6d33adb4a5c285278a068f3e7a5afdc4e680d9/src/AuraInputInterceptor.php#L108-L121
15,683
DevGroup-ru/yii2-intent-analytics
src/models/Visitor.php
Visitor.hasUserId
public function hasUserId() { if (Yii::$app->user->isGuest) { return $this->user_id !== 0; } return $this->user_id == Yii::$app->user->identity->getId(); }
php
public function hasUserId() { if (Yii::$app->user->isGuest) { return $this->user_id !== 0; } return $this->user_id == Yii::$app->user->identity->getId(); }
[ "public", "function", "hasUserId", "(", ")", "{", "if", "(", "Yii", "::", "$", "app", "->", "user", "->", "isGuest", ")", "{", "return", "$", "this", "->", "user_id", "!==", "0", ";", "}", "return", "$", "this", "->", "user_id", "==", "Yii", "::", "$", "app", "->", "user", "->", "identity", "->", "getId", "(", ")", ";", "}" ]
Detect is visitor connected with User @return bool
[ "Detect", "is", "visitor", "connected", "with", "User" ]
53937d44df8c73dca402cc7351b018e6758c3af6
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/models/Visitor.php#L165-L171
15,684
keiosweb/moneyright
src/Math.php
Math.bcRoundHalfUp
final private static function bcRoundHalfUp($number, $precision) { return self::truncate(bcadd($number, self::getHalfUpValue($number, $precision), $precision + 1), $precision); }
php
final private static function bcRoundHalfUp($number, $precision) { return self::truncate(bcadd($number, self::getHalfUpValue($number, $precision), $precision + 1), $precision); }
[ "final", "private", "static", "function", "bcRoundHalfUp", "(", "$", "number", ",", "$", "precision", ")", "{", "return", "self", "::", "truncate", "(", "bcadd", "(", "$", "number", ",", "self", "::", "getHalfUpValue", "(", "$", "number", ",", "$", "precision", ")", ",", "$", "precision", "+", "1", ")", ",", "$", "precision", ")", ";", "}" ]
Round decimals from 5 up, less than 5 down @param $number @param $precision @return string
[ "Round", "decimals", "from", "5", "up", "less", "than", "5", "down" ]
6c6d8ce34e37e42aa1eebbf45a949bbae6b44780
https://github.com/keiosweb/moneyright/blob/6c6d8ce34e37e42aa1eebbf45a949bbae6b44780/src/Math.php#L216-L219
15,685
ARCANEDEV/SpamBlocker
src/SpamBlockerServiceProvider.php
SpamBlockerServiceProvider.registerSpamBlocker
private function registerSpamBlocker() { $this->singleton(Contracts\SpamBlocker::class, function ($app) { /** @var \Illuminate\Contracts\Config\Repository $config */ $config = $app['config']; return new SpamBlocker( $config->get('spam-blocker') ); }); }
php
private function registerSpamBlocker() { $this->singleton(Contracts\SpamBlocker::class, function ($app) { /** @var \Illuminate\Contracts\Config\Repository $config */ $config = $app['config']; return new SpamBlocker( $config->get('spam-blocker') ); }); }
[ "private", "function", "registerSpamBlocker", "(", ")", "{", "$", "this", "->", "singleton", "(", "Contracts", "\\", "SpamBlocker", "::", "class", ",", "function", "(", "$", "app", ")", "{", "/** @var \\Illuminate\\Contracts\\Config\\Repository $config */", "$", "config", "=", "$", "app", "[", "'config'", "]", ";", "return", "new", "SpamBlocker", "(", "$", "config", "->", "get", "(", "'spam-blocker'", ")", ")", ";", "}", ")", ";", "}" ]
Register the spam blocker
[ "Register", "the", "spam", "blocker" ]
708c9d5363616e0b257451256c4ca9fb9a9ff55f
https://github.com/ARCANEDEV/SpamBlocker/blob/708c9d5363616e0b257451256c4ca9fb9a9ff55f/src/SpamBlockerServiceProvider.php#L72-L82
15,686
tonicospinelli/class-generation
src/ClassGeneration/DocBlock/Tag.php
Tag.createFromArgument
public static function createFromArgument(ArgumentInterface $argument) { $tag = new self(); $tag ->setName(self::TAG_PARAM) ->setType($argument->getType()) ->setVariable($argument->getName()) ->setDescription($argument->getDescription()) ->setReferenced($argument); return $tag; }
php
public static function createFromArgument(ArgumentInterface $argument) { $tag = new self(); $tag ->setName(self::TAG_PARAM) ->setType($argument->getType()) ->setVariable($argument->getName()) ->setDescription($argument->getDescription()) ->setReferenced($argument); return $tag; }
[ "public", "static", "function", "createFromArgument", "(", "ArgumentInterface", "$", "argument", ")", "{", "$", "tag", "=", "new", "self", "(", ")", ";", "$", "tag", "->", "setName", "(", "self", "::", "TAG_PARAM", ")", "->", "setType", "(", "$", "argument", "->", "getType", "(", ")", ")", "->", "setVariable", "(", "$", "argument", "->", "getName", "(", ")", ")", "->", "setDescription", "(", "$", "argument", "->", "getDescription", "(", ")", ")", "->", "setReferenced", "(", "$", "argument", ")", ";", "return", "$", "tag", ";", "}" ]
Creating a Tag from an Argument Object. @param ArgumentInterface $argument @return TagInterface
[ "Creating", "a", "Tag", "from", "an", "Argument", "Object", "." ]
eee63bdb68c066b25b885b57b23656e809381a76
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/DocBlock/Tag.php#L229-L240
15,687
tonicospinelli/class-generation
src/ClassGeneration/DocBlock/Tag.php
Tag.createFromProperty
public static function createFromProperty(PropertyInterface $property) { $tag = new self(); $tag->setName(self::TAG_VAR); $tag->setType($property->getType()); return $tag; }
php
public static function createFromProperty(PropertyInterface $property) { $tag = new self(); $tag->setName(self::TAG_VAR); $tag->setType($property->getType()); return $tag; }
[ "public", "static", "function", "createFromProperty", "(", "PropertyInterface", "$", "property", ")", "{", "$", "tag", "=", "new", "self", "(", ")", ";", "$", "tag", "->", "setName", "(", "self", "::", "TAG_VAR", ")", ";", "$", "tag", "->", "setType", "(", "$", "property", "->", "getType", "(", ")", ")", ";", "return", "$", "tag", ";", "}" ]
Create var tag from property. @param PropertyInterface $property @return Tag
[ "Create", "var", "tag", "from", "property", "." ]
eee63bdb68c066b25b885b57b23656e809381a76
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/DocBlock/Tag.php#L249-L256
15,688
FrenchFrogs/framework
src/Core/Configurator.php
Configurator.build
public function build($index, $default = null, $params = []) { $class = $this->get($index, $default); if (!class_exists($class)) { throw new \Exception('Class doesn\'t exist for the index : ' .$index); } $class = new \ReflectionClass($class); return $class->newInstanceArgs($params); }
php
public function build($index, $default = null, $params = []) { $class = $this->get($index, $default); if (!class_exists($class)) { throw new \Exception('Class doesn\'t exist for the index : ' .$index); } $class = new \ReflectionClass($class); return $class->newInstanceArgs($params); }
[ "public", "function", "build", "(", "$", "index", ",", "$", "default", "=", "null", ",", "$", "params", "=", "[", "]", ")", "{", "$", "class", "=", "$", "this", "->", "get", "(", "$", "index", ",", "$", "default", ")", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Class doesn\\'t exist for the index : '", ".", "$", "index", ")", ";", "}", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "return", "$", "class", "->", "newInstanceArgs", "(", "$", "params", ")", ";", "}" ]
Return an instantiated object @param $index @param null $default @param array $params @return object @throws \Exception
[ "Return", "an", "instantiated", "object" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Core/Configurator.php#L134-L143
15,689
jenky/laravel-api-helper
src/Factory.php
Factory.parseBuilder
protected function parseBuilder($builder) { if ($builder instanceof EloquentBuilder) { return $this->createHandler($builder->getQuery(), $builder); } if (is_subclass_of($builder, Model::class)) { return $this->createHandler($builder->getQuery(), $builder->newQuery()); } if ($builder instanceof QueryBuilder) { return $this->createHandler($builder, $builder); } }
php
protected function parseBuilder($builder) { if ($builder instanceof EloquentBuilder) { return $this->createHandler($builder->getQuery(), $builder); } if (is_subclass_of($builder, Model::class)) { return $this->createHandler($builder->getQuery(), $builder->newQuery()); } if ($builder instanceof QueryBuilder) { return $this->createHandler($builder, $builder); } }
[ "protected", "function", "parseBuilder", "(", "$", "builder", ")", "{", "if", "(", "$", "builder", "instanceof", "EloquentBuilder", ")", "{", "return", "$", "this", "->", "createHandler", "(", "$", "builder", "->", "getQuery", "(", ")", ",", "$", "builder", ")", ";", "}", "if", "(", "is_subclass_of", "(", "$", "builder", ",", "Model", "::", "class", ")", ")", "{", "return", "$", "this", "->", "createHandler", "(", "$", "builder", "->", "getQuery", "(", ")", ",", "$", "builder", "->", "newQuery", "(", ")", ")", ";", "}", "if", "(", "$", "builder", "instanceof", "QueryBuilder", ")", "{", "return", "$", "this", "->", "createHandler", "(", "$", "builder", ",", "$", "builder", ")", ";", "}", "}" ]
Parse the builder. @param mixed $builder
[ "Parse", "the", "builder", "." ]
9af8f4d99d96ed3ea1bee7eabcdb0472f1bfa367
https://github.com/jenky/laravel-api-helper/blob/9af8f4d99d96ed3ea1bee7eabcdb0472f1bfa367/src/Factory.php#L47-L58
15,690
jenky/laravel-api-helper
src/Factory.php
Factory.createHandler
protected function createHandler($query, $builder = null) { $handler = new Handler($this->request, $this->config); $handler->setQuery($query); if (! is_null($builder)) { $handler->setBuilder($builder); } return $handler; }
php
protected function createHandler($query, $builder = null) { $handler = new Handler($this->request, $this->config); $handler->setQuery($query); if (! is_null($builder)) { $handler->setBuilder($builder); } return $handler; }
[ "protected", "function", "createHandler", "(", "$", "query", ",", "$", "builder", "=", "null", ")", "{", "$", "handler", "=", "new", "Handler", "(", "$", "this", "->", "request", ",", "$", "this", "->", "config", ")", ";", "$", "handler", "->", "setQuery", "(", "$", "query", ")", ";", "if", "(", "!", "is_null", "(", "$", "builder", ")", ")", "{", "$", "handler", "->", "setBuilder", "(", "$", "builder", ")", ";", "}", "return", "$", "handler", ";", "}" ]
Create the handler. @param mixed $query @param mixed $builder @return \Jenky\LaravelApiHelper\Handler
[ "Create", "the", "handler", "." ]
9af8f4d99d96ed3ea1bee7eabcdb0472f1bfa367
https://github.com/jenky/laravel-api-helper/blob/9af8f4d99d96ed3ea1bee7eabcdb0472f1bfa367/src/Factory.php#L68-L79
15,691
heyday/heystack
src/Input/Handler.php
Handler.process
public function process($identifier, \SS_HTTPRequest $request) { if ($this->hasProcessor($identifier)) { return $this->processors[$identifier]->process($request); } else { return false; } }
php
public function process($identifier, \SS_HTTPRequest $request) { if ($this->hasProcessor($identifier)) { return $this->processors[$identifier]->process($request); } else { return false; } }
[ "public", "function", "process", "(", "$", "identifier", ",", "\\", "SS_HTTPRequest", "$", "request", ")", "{", "if", "(", "$", "this", "->", "hasProcessor", "(", "$", "identifier", ")", ")", "{", "return", "$", "this", "->", "processors", "[", "$", "identifier", "]", "->", "process", "(", "$", "request", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Process an input processor by identifier if it exists @param string $identifier The identifier of the input processor @param \SS_HTTPRequest $request The request object to process from @return mixed
[ "Process", "an", "input", "processor", "by", "identifier", "if", "it", "exists" ]
2c051933f8c532d0a9a23be6ee1ff5c619e47dfe
https://github.com/heyday/heystack/blob/2c051933f8c532d0a9a23be6ee1ff5c619e47dfe/src/Input/Handler.php#L41-L48
15,692
link0/profiler
src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php
ZendDbHandler.getTableStructure
private function getTableStructure() { return array( 'columns' => array( // Unique auto-incrementing primary key new BigInteger('id', false, null, array('auto_increment' => true, 'unsigned' => true)), // Identifier column new Varchar($this->getIdentifierColumn(), 64), // The blob column creates a length specification if(length), so length 0 is a nice hack to not specify length new Blob($this->getDataColumn(), 0) ), 'constraints' => array( // Primary key and index constraints new PrimaryKey('id'), new UniqueKey(array($this->getIdentifierColumn()), $this->getIdentifierColumn()) ), ); }
php
private function getTableStructure() { return array( 'columns' => array( // Unique auto-incrementing primary key new BigInteger('id', false, null, array('auto_increment' => true, 'unsigned' => true)), // Identifier column new Varchar($this->getIdentifierColumn(), 64), // The blob column creates a length specification if(length), so length 0 is a nice hack to not specify length new Blob($this->getDataColumn(), 0) ), 'constraints' => array( // Primary key and index constraints new PrimaryKey('id'), new UniqueKey(array($this->getIdentifierColumn()), $this->getIdentifierColumn()) ), ); }
[ "private", "function", "getTableStructure", "(", ")", "{", "return", "array", "(", "'columns'", "=>", "array", "(", "// Unique auto-incrementing primary key", "new", "BigInteger", "(", "'id'", ",", "false", ",", "null", ",", "array", "(", "'auto_increment'", "=>", "true", ",", "'unsigned'", "=>", "true", ")", ")", ",", "// Identifier column", "new", "Varchar", "(", "$", "this", "->", "getIdentifierColumn", "(", ")", ",", "64", ")", ",", "// The blob column creates a length specification if(length), so length 0 is a nice hack to not specify length", "new", "Blob", "(", "$", "this", "->", "getDataColumn", "(", ")", ",", "0", ")", ")", ",", "'constraints'", "=>", "array", "(", "// Primary key and index constraints", "new", "PrimaryKey", "(", "'id'", ")", ",", "new", "UniqueKey", "(", "array", "(", "$", "this", "->", "getIdentifierColumn", "(", ")", ")", ",", "$", "this", "->", "getIdentifierColumn", "(", ")", ")", ")", ",", ")", ";", "}" ]
Returns the table structure in Zend\Db\Column objects @return array
[ "Returns", "the", "table", "structure", "in", "Zend", "\\", "Db", "\\", "Column", "objects" ]
0573073ff029743734de747619ab65ab2476052d
https://github.com/link0/profiler/blob/0573073ff029743734de747619ab65ab2476052d/src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php#L227-L246
15,693
link0/profiler
src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php
ZendDbHandler.createTable
public function createTable() { $sql = $this->getSql(); $createTable = new CreateTable($this->getTableName()); $tableStructure = $this->getTableStructure(); foreach($tableStructure['columns'] as $column) { $createTable->addColumn($column); } foreach($tableStructure['constraints'] as $constraint) { $createTable->addConstraint($constraint); } $sql->getAdapter()->query( $sql->getSqlStringForSqlObject($createTable), Adapter::QUERY_MODE_EXECUTE ); return $this; }
php
public function createTable() { $sql = $this->getSql(); $createTable = new CreateTable($this->getTableName()); $tableStructure = $this->getTableStructure(); foreach($tableStructure['columns'] as $column) { $createTable->addColumn($column); } foreach($tableStructure['constraints'] as $constraint) { $createTable->addConstraint($constraint); } $sql->getAdapter()->query( $sql->getSqlStringForSqlObject($createTable), Adapter::QUERY_MODE_EXECUTE ); return $this; }
[ "public", "function", "createTable", "(", ")", "{", "$", "sql", "=", "$", "this", "->", "getSql", "(", ")", ";", "$", "createTable", "=", "new", "CreateTable", "(", "$", "this", "->", "getTableName", "(", ")", ")", ";", "$", "tableStructure", "=", "$", "this", "->", "getTableStructure", "(", ")", ";", "foreach", "(", "$", "tableStructure", "[", "'columns'", "]", "as", "$", "column", ")", "{", "$", "createTable", "->", "addColumn", "(", "$", "column", ")", ";", "}", "foreach", "(", "$", "tableStructure", "[", "'constraints'", "]", "as", "$", "constraint", ")", "{", "$", "createTable", "->", "addConstraint", "(", "$", "constraint", ")", ";", "}", "$", "sql", "->", "getAdapter", "(", ")", "->", "query", "(", "$", "sql", "->", "getSqlStringForSqlObject", "(", "$", "createTable", ")", ",", "Adapter", "::", "QUERY_MODE_EXECUTE", ")", ";", "return", "$", "this", ";", "}" ]
Creates the table structure for you NOTE: This code should fully work when ZendFramework 2.4.0 is released, since then DDL supports auto_increment @see https://github.com/zendframework/zf2/pull/6257 @return PersistenceHandlerInterface
[ "Creates", "the", "table", "structure", "for", "you" ]
0573073ff029743734de747619ab65ab2476052d
https://github.com/link0/profiler/blob/0573073ff029743734de747619ab65ab2476052d/src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php#L256-L277
15,694
link0/profiler
src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php
ZendDbHandler.dropTable
public function dropTable() { $sql = $this->getSql(); $dropTable = new DropTable($this->getTableName()); $sql->getAdapter()->query($sql->getSqlStringForSqlObject($dropTable), Adapter::QUERY_MODE_EXECUTE ); return $this; }
php
public function dropTable() { $sql = $this->getSql(); $dropTable = new DropTable($this->getTableName()); $sql->getAdapter()->query($sql->getSqlStringForSqlObject($dropTable), Adapter::QUERY_MODE_EXECUTE ); return $this; }
[ "public", "function", "dropTable", "(", ")", "{", "$", "sql", "=", "$", "this", "->", "getSql", "(", ")", ";", "$", "dropTable", "=", "new", "DropTable", "(", "$", "this", "->", "getTableName", "(", ")", ")", ";", "$", "sql", "->", "getAdapter", "(", ")", "->", "query", "(", "$", "sql", "->", "getSqlStringForSqlObject", "(", "$", "dropTable", ")", ",", "Adapter", "::", "QUERY_MODE_EXECUTE", ")", ";", "return", "$", "this", ";", "}" ]
Drops the table structure for you @return PersistenceHandlerInterface
[ "Drops", "the", "table", "structure", "for", "you" ]
0573073ff029743734de747619ab65ab2476052d
https://github.com/link0/profiler/blob/0573073ff029743734de747619ab65ab2476052d/src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php#L284-L295
15,695
Teamsisu/contao-mm-frontendInput
src/Teamsisu/MetaModelsFrontendInput/Handler/Save/SaveHandler.php
SaveHandler.parseWidget
public function parseWidget($widget) { if(is_a($widget, 'Contao\FormTextArea') || is_a($widget, 'Contao\FormTextField')){ if($this->field->getEval('allowHtml')){ $value = strip_tags(\String::decodeEntities($widget->value), \Config::get('allowedTags')); }else{ $value = strip_tags(\String::decodeEntities($widget->value)); } if($this->field->getEval('decodeEntities')){ return $value; }else{ return specialchars($value); } } return $widget->value; }
php
public function parseWidget($widget) { if(is_a($widget, 'Contao\FormTextArea') || is_a($widget, 'Contao\FormTextField')){ if($this->field->getEval('allowHtml')){ $value = strip_tags(\String::decodeEntities($widget->value), \Config::get('allowedTags')); }else{ $value = strip_tags(\String::decodeEntities($widget->value)); } if($this->field->getEval('decodeEntities')){ return $value; }else{ return specialchars($value); } } return $widget->value; }
[ "public", "function", "parseWidget", "(", "$", "widget", ")", "{", "if", "(", "is_a", "(", "$", "widget", ",", "'Contao\\FormTextArea'", ")", "||", "is_a", "(", "$", "widget", ",", "'Contao\\FormTextField'", ")", ")", "{", "if", "(", "$", "this", "->", "field", "->", "getEval", "(", "'allowHtml'", ")", ")", "{", "$", "value", "=", "strip_tags", "(", "\\", "String", "::", "decodeEntities", "(", "$", "widget", "->", "value", ")", ",", "\\", "Config", "::", "get", "(", "'allowedTags'", ")", ")", ";", "}", "else", "{", "$", "value", "=", "strip_tags", "(", "\\", "String", "::", "decodeEntities", "(", "$", "widget", "->", "value", ")", ")", ";", "}", "if", "(", "$", "this", "->", "field", "->", "getEval", "(", "'decodeEntities'", ")", ")", "{", "return", "$", "value", ";", "}", "else", "{", "return", "specialchars", "(", "$", "value", ")", ";", "}", "}", "return", "$", "widget", "->", "value", ";", "}" ]
This function is for the manipulation of the attribute value Must return the value in the format what is needed for MetaModels @param $widget @return mixed
[ "This", "function", "is", "for", "the", "manipulation", "of", "the", "attribute", "value", "Must", "return", "the", "value", "in", "the", "format", "what", "is", "needed", "for", "MetaModels" ]
ab92e61c24644f1e61265304b6a35e505007d021
https://github.com/Teamsisu/contao-mm-frontendInput/blob/ab92e61c24644f1e61265304b6a35e505007d021/src/Teamsisu/MetaModelsFrontendInput/Handler/Save/SaveHandler.php#L61-L80
15,696
Teamsisu/contao-mm-frontendInput
src/Teamsisu/MetaModelsFrontendInput/Handler/Save/SaveHandler.php
SaveHandler.setValue
public function setValue($value) { $this->item->set($this->field->getColName(), $this->field->mmAttribute->widgetToValue($value, null)); }
php
public function setValue($value) { $this->item->set($this->field->getColName(), $this->field->mmAttribute->widgetToValue($value, null)); }
[ "public", "function", "setValue", "(", "$", "value", ")", "{", "$", "this", "->", "item", "->", "set", "(", "$", "this", "->", "field", "->", "getColName", "(", ")", ",", "$", "this", "->", "field", "->", "mmAttribute", "->", "widgetToValue", "(", "$", "value", ",", "null", ")", ")", ";", "}" ]
Set the value of the Attribute from given MetaModels Item
[ "Set", "the", "value", "of", "the", "Attribute", "from", "given", "MetaModels", "Item" ]
ab92e61c24644f1e61265304b6a35e505007d021
https://github.com/Teamsisu/contao-mm-frontendInput/blob/ab92e61c24644f1e61265304b6a35e505007d021/src/Teamsisu/MetaModelsFrontendInput/Handler/Save/SaveHandler.php#L85-L88
15,697
verschoof/bunq-api
src/HttpClientFactory.php
HttpClientFactory.createInstallationClient
public static function createInstallationClient($url, CertificateStorage $certificateStorage) { $handlerStack = HandlerStack::create(); $handlerStack->push( Middleware::mapRequest(new RequestIdMiddleware()) ); $handlerStack->push( Middleware::mapRequest(new RequestSignatureMiddleware($certificateStorage->load(CertificateType::PRIVATE_KEY()))) ); return self::createBaseClient((string)$url, $handlerStack); }
php
public static function createInstallationClient($url, CertificateStorage $certificateStorage) { $handlerStack = HandlerStack::create(); $handlerStack->push( Middleware::mapRequest(new RequestIdMiddleware()) ); $handlerStack->push( Middleware::mapRequest(new RequestSignatureMiddleware($certificateStorage->load(CertificateType::PRIVATE_KEY()))) ); return self::createBaseClient((string)$url, $handlerStack); }
[ "public", "static", "function", "createInstallationClient", "(", "$", "url", ",", "CertificateStorage", "$", "certificateStorage", ")", "{", "$", "handlerStack", "=", "HandlerStack", "::", "create", "(", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapRequest", "(", "new", "RequestIdMiddleware", "(", ")", ")", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapRequest", "(", "new", "RequestSignatureMiddleware", "(", "$", "certificateStorage", "->", "load", "(", "CertificateType", "::", "PRIVATE_KEY", "(", ")", ")", ")", ")", ")", ";", "return", "self", "::", "createBaseClient", "(", "(", "string", ")", "$", "url", ",", "$", "handlerStack", ")", ";", "}" ]
Creates an installation client @param string $url @param CertificateStorage $certificateStorage @return ClientInterface
[ "Creates", "an", "installation", "client" ]
df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd
https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/HttpClientFactory.php#L29-L40
15,698
verschoof/bunq-api
src/HttpClientFactory.php
HttpClientFactory.create
public static function create( $url, TokenService $tokenService, CertificateStorage $certificateStorage, InstallationService $installationService, TokenStorage $tokenStorage ) { $sessionToken = $tokenService->sessionToken(); $publicServerKey = $certificateStorage->load(CertificateType::BUNQ_SERVER_KEY()); $handlerStack = HandlerStack::create(); $handlerStack->push( Middleware::mapRequest(new RequestIdMiddleware()) ); $handlerStack->push( Middleware::mapRequest(new RequestAuthenticationMiddleware($sessionToken)) ); $handlerStack->push( Middleware::mapRequest(new RequestSignatureMiddleware($certificateStorage->load(CertificateType::PRIVATE_KEY()))) ); $handlerStack->push( Middleware::mapResponse(new ResponseSignatureMiddleware($publicServerKey)) ); $handlerStack->push( Middleware::mapResponse(new RefreshSessionMiddleware($installationService, $tokenStorage)) ); $httpClient = self::createBaseClient($url, $handlerStack); return $httpClient; }
php
public static function create( $url, TokenService $tokenService, CertificateStorage $certificateStorage, InstallationService $installationService, TokenStorage $tokenStorage ) { $sessionToken = $tokenService->sessionToken(); $publicServerKey = $certificateStorage->load(CertificateType::BUNQ_SERVER_KEY()); $handlerStack = HandlerStack::create(); $handlerStack->push( Middleware::mapRequest(new RequestIdMiddleware()) ); $handlerStack->push( Middleware::mapRequest(new RequestAuthenticationMiddleware($sessionToken)) ); $handlerStack->push( Middleware::mapRequest(new RequestSignatureMiddleware($certificateStorage->load(CertificateType::PRIVATE_KEY()))) ); $handlerStack->push( Middleware::mapResponse(new ResponseSignatureMiddleware($publicServerKey)) ); $handlerStack->push( Middleware::mapResponse(new RefreshSessionMiddleware($installationService, $tokenStorage)) ); $httpClient = self::createBaseClient($url, $handlerStack); return $httpClient; }
[ "public", "static", "function", "create", "(", "$", "url", ",", "TokenService", "$", "tokenService", ",", "CertificateStorage", "$", "certificateStorage", ",", "InstallationService", "$", "installationService", ",", "TokenStorage", "$", "tokenStorage", ")", "{", "$", "sessionToken", "=", "$", "tokenService", "->", "sessionToken", "(", ")", ";", "$", "publicServerKey", "=", "$", "certificateStorage", "->", "load", "(", "CertificateType", "::", "BUNQ_SERVER_KEY", "(", ")", ")", ";", "$", "handlerStack", "=", "HandlerStack", "::", "create", "(", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapRequest", "(", "new", "RequestIdMiddleware", "(", ")", ")", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapRequest", "(", "new", "RequestAuthenticationMiddleware", "(", "$", "sessionToken", ")", ")", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapRequest", "(", "new", "RequestSignatureMiddleware", "(", "$", "certificateStorage", "->", "load", "(", "CertificateType", "::", "PRIVATE_KEY", "(", ")", ")", ")", ")", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapResponse", "(", "new", "ResponseSignatureMiddleware", "(", "$", "publicServerKey", ")", ")", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapResponse", "(", "new", "RefreshSessionMiddleware", "(", "$", "installationService", ",", "$", "tokenStorage", ")", ")", ")", ";", "$", "httpClient", "=", "self", "::", "createBaseClient", "(", "$", "url", ",", "$", "handlerStack", ")", ";", "return", "$", "httpClient", ";", "}" ]
Creates the HttpClient with all handlers @param string $url @param TokenService $tokenService @param CertificateStorage $certificateStorage @param InstallationService $installationService @param TokenStorage $tokenStorage @return ClientInterface
[ "Creates", "the", "HttpClient", "with", "all", "handlers" ]
df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd
https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/HttpClientFactory.php#L53-L83
15,699
verschoof/bunq-api
src/HttpClientFactory.php
HttpClientFactory.createBaseClient
private static function createBaseClient($url, HandlerStack $handlerStack = null) { $httpClient = new \GuzzleHttp\Client( [ 'base_uri' => $url, 'handler' => $handlerStack, 'headers' => [ 'Content-Type' => 'application/json', 'User-Agent' => 'bunq-api-client:user', ], ] ); return $httpClient; }
php
private static function createBaseClient($url, HandlerStack $handlerStack = null) { $httpClient = new \GuzzleHttp\Client( [ 'base_uri' => $url, 'handler' => $handlerStack, 'headers' => [ 'Content-Type' => 'application/json', 'User-Agent' => 'bunq-api-client:user', ], ] ); return $httpClient; }
[ "private", "static", "function", "createBaseClient", "(", "$", "url", ",", "HandlerStack", "$", "handlerStack", "=", "null", ")", "{", "$", "httpClient", "=", "new", "\\", "GuzzleHttp", "\\", "Client", "(", "[", "'base_uri'", "=>", "$", "url", ",", "'handler'", "=>", "$", "handlerStack", ",", "'headers'", "=>", "[", "'Content-Type'", "=>", "'application/json'", ",", "'User-Agent'", "=>", "'bunq-api-client:user'", ",", "]", ",", "]", ")", ";", "return", "$", "httpClient", ";", "}" ]
Returns the standard used headers. @param string $url @param HandlerStack|null $handlerStack @return ClientInterface
[ "Returns", "the", "standard", "used", "headers", "." ]
df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd
https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/HttpClientFactory.php#L93-L107