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
236,600
gossi/trixionary
src/model/Base/ObjectQuery.php
ObjectQuery.filterBySkillCount
public function filterBySkillCount($skillCount = null, $comparison = null) { if (is_array($skillCount)) { $useMinMax = false; if (isset($skillCount['min'])) { $this->addUsingAlias(ObjectTableMap::COL_SKILL_COUNT, $skillCount['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($skillCount['max'])) { $this->addUsingAlias(ObjectTableMap::COL_SKILL_COUNT, $skillCount['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(ObjectTableMap::COL_SKILL_COUNT, $skillCount, $comparison); }
php
public function filterBySkillCount($skillCount = null, $comparison = null) { if (is_array($skillCount)) { $useMinMax = false; if (isset($skillCount['min'])) { $this->addUsingAlias(ObjectTableMap::COL_SKILL_COUNT, $skillCount['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($skillCount['max'])) { $this->addUsingAlias(ObjectTableMap::COL_SKILL_COUNT, $skillCount['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(ObjectTableMap::COL_SKILL_COUNT, $skillCount, $comparison); }
[ "public", "function", "filterBySkillCount", "(", "$", "skillCount", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "skillCount", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "skillCount", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "ObjectTableMap", "::", "COL_SKILL_COUNT", ",", "$", "skillCount", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "skillCount", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "ObjectTableMap", "::", "COL_SKILL_COUNT", ",", "$", "skillCount", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "ObjectTableMap", "::", "COL_SKILL_COUNT", ",", "$", "skillCount", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the skill_count column Example usage: <code> $query->filterBySkillCount(1234); // WHERE skill_count = 1234 $query->filterBySkillCount(array(12, 34)); // WHERE skill_count IN (12, 34) $query->filterBySkillCount(array('min' => 12)); // WHERE skill_count > 12 </code> @param mixed $skillCount The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildObjectQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "skill_count", "column" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/ObjectQuery.php#L481-L502
236,601
jetfirephp/debugbar
src/DebugBar/DataCollector/PDO/TracedStatement.php
TracedStatement.getParameters
public function getParameters() { $params = array(); foreach ($this->parameters as $name => $param) { $params[$name] = htmlentities($param, ENT_QUOTES, 'UTF-8', false); } return $params; }
php
public function getParameters() { $params = array(); foreach ($this->parameters as $name => $param) { $params[$name] = htmlentities($param, ENT_QUOTES, 'UTF-8', false); } return $params; }
[ "public", "function", "getParameters", "(", ")", "{", "$", "params", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "parameters", "as", "$", "name", "=>", "$", "param", ")", "{", "$", "params", "[", "$", "name", "]", "=", "htmlentities", "(", "$", "param", ",", "ENT_QUOTES", ",", "'UTF-8'", ",", "false", ")", ";", "}", "return", "$", "params", ";", "}" ]
Returns an array of parameters used with the query @return array
[ "Returns", "an", "array", "of", "parameters", "used", "with", "the", "query" ]
ee083ebf60536d13aecf05d250d8455f4693f730
https://github.com/jetfirephp/debugbar/blob/ee083ebf60536d13aecf05d250d8455f4693f730/src/DebugBar/DataCollector/PDO/TracedStatement.php#L137-L144
236,602
kambo-1st/HttpMessage
src/Factories/Environment/Superglobal/HeadersFactory.php
HeadersFactory.resolveHeaders
private function resolveHeaders($headersForResolve) { $headers = []; foreach ($headersForResolve as $name => $value) { if (strpos($name, 'REDIRECT_') === 0) { $name = substr($name, 9); // Do not replace existing variables if (array_key_exists($name, $headersForResolve)) { continue; } } if (substr($name, 0, 5) == 'HTTP_' || isset($this->specialHeaders[$name])) { $headers[$name] = $value; } } return $headers; }
php
private function resolveHeaders($headersForResolve) { $headers = []; foreach ($headersForResolve as $name => $value) { if (strpos($name, 'REDIRECT_') === 0) { $name = substr($name, 9); // Do not replace existing variables if (array_key_exists($name, $headersForResolve)) { continue; } } if (substr($name, 0, 5) == 'HTTP_' || isset($this->specialHeaders[$name])) { $headers[$name] = $value; } } return $headers; }
[ "private", "function", "resolveHeaders", "(", "$", "headersForResolve", ")", "{", "$", "headers", "=", "[", "]", ";", "foreach", "(", "$", "headersForResolve", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "name", ",", "'REDIRECT_'", ")", "===", "0", ")", "{", "$", "name", "=", "substr", "(", "$", "name", ",", "9", ")", ";", "// Do not replace existing variables", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "headersForResolve", ")", ")", "{", "continue", ";", "}", "}", "if", "(", "substr", "(", "$", "name", ",", "0", ",", "5", ")", "==", "'HTTP_'", "||", "isset", "(", "$", "this", "->", "specialHeaders", "[", "$", "name", "]", ")", ")", "{", "$", "headers", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "return", "$", "headers", ";", "}" ]
Resolve headers from provided array @param array $headersForResolve array compatible with $_SERVER superglobal variable @return Headers Instance of Headers object from environment
[ "Resolve", "headers", "from", "provided", "array" ]
38877b9d895f279fdd5bdf957d8f23f9808a940a
https://github.com/kambo-1st/HttpMessage/blob/38877b9d895f279fdd5bdf957d8f23f9808a940a/src/Factories/Environment/Superglobal/HeadersFactory.php#L51-L71
236,603
webriq/core
module/Core/src/Grid/Core/Model/Rpc/Json.php
Json.error
public function error( $message, $code = null, $data = null ) { if ( null === $code && isset( $this->errorCodes[$message] ) ) { $code = $this->errorCodes[$message]; } return $this->getResponse( 'error', (object) array( 'code' => $code, 'message' => $message, 'data' => $data, ) ); }
php
public function error( $message, $code = null, $data = null ) { if ( null === $code && isset( $this->errorCodes[$message] ) ) { $code = $this->errorCodes[$message]; } return $this->getResponse( 'error', (object) array( 'code' => $code, 'message' => $message, 'data' => $data, ) ); }
[ "public", "function", "error", "(", "$", "message", ",", "$", "code", "=", "null", ",", "$", "data", "=", "null", ")", "{", "if", "(", "null", "===", "$", "code", "&&", "isset", "(", "$", "this", "->", "errorCodes", "[", "$", "message", "]", ")", ")", "{", "$", "code", "=", "$", "this", "->", "errorCodes", "[", "$", "message", "]", ";", "}", "return", "$", "this", "->", "getResponse", "(", "'error'", ",", "(", "object", ")", "array", "(", "'code'", "=>", "$", "code", ",", "'message'", "=>", "$", "message", ",", "'data'", "=>", "$", "data", ",", ")", ")", ";", "}" ]
Send error result @param string $message @param int $code @param mixed $data
[ "Send", "error", "result" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Model/Rpc/Json.php#L123-L135
236,604
tadcka/Routing
Generator/RouteGenerator.php
RouteGenerator.generateRouteFromText
public function generateRouteFromText($text, $withSlash = false) { if ($withSlash) { $result = ''; foreach (explode('/', $text) as $value) { if ('' !== $value = trim($value)) { $result .= '/' . Urlizer::urlize($value); } } return $result ?: '/'; } return $this->normalizeRoute(Urlizer::urlize($text)); }
php
public function generateRouteFromText($text, $withSlash = false) { if ($withSlash) { $result = ''; foreach (explode('/', $text) as $value) { if ('' !== $value = trim($value)) { $result .= '/' . Urlizer::urlize($value); } } return $result ?: '/'; } return $this->normalizeRoute(Urlizer::urlize($text)); }
[ "public", "function", "generateRouteFromText", "(", "$", "text", ",", "$", "withSlash", "=", "false", ")", "{", "if", "(", "$", "withSlash", ")", "{", "$", "result", "=", "''", ";", "foreach", "(", "explode", "(", "'/'", ",", "$", "text", ")", "as", "$", "value", ")", "{", "if", "(", "''", "!==", "$", "value", "=", "trim", "(", "$", "value", ")", ")", "{", "$", "result", ".=", "'/'", ".", "Urlizer", "::", "urlize", "(", "$", "value", ")", ";", "}", "}", "return", "$", "result", "?", ":", "'/'", ";", "}", "return", "$", "this", "->", "normalizeRoute", "(", "Urlizer", "::", "urlize", "(", "$", "text", ")", ")", ";", "}" ]
Generate route from text. @param string $text @param bool $withSlash @return string
[ "Generate", "route", "from", "text", "." ]
b2280bac33eb76eec76ecc8d665c70092f3cbba9
https://github.com/tadcka/Routing/blob/b2280bac33eb76eec76ecc8d665c70092f3cbba9/Generator/RouteGenerator.php#L49-L63
236,605
tadcka/Routing
Generator/RouteGenerator.php
RouteGenerator.generateUniqueRoute
public function generateUniqueRoute(RouteInterface $route, $withSlash = false) { $originalRoutePattern = $this->generateRouteFromText($route->getRoutePattern(), $withSlash); if ($originalRoutePattern) { $key = 0; $routePattern = $this->normalizeRoute($originalRoutePattern); while ($this->hasRoute($routePattern, $route->getName())) { $key++; $routePattern = $originalRoutePattern . '-' . $key; } $route->setRoutePattern($routePattern); return $route; } return null; }
php
public function generateUniqueRoute(RouteInterface $route, $withSlash = false) { $originalRoutePattern = $this->generateRouteFromText($route->getRoutePattern(), $withSlash); if ($originalRoutePattern) { $key = 0; $routePattern = $this->normalizeRoute($originalRoutePattern); while ($this->hasRoute($routePattern, $route->getName())) { $key++; $routePattern = $originalRoutePattern . '-' . $key; } $route->setRoutePattern($routePattern); return $route; } return null; }
[ "public", "function", "generateUniqueRoute", "(", "RouteInterface", "$", "route", ",", "$", "withSlash", "=", "false", ")", "{", "$", "originalRoutePattern", "=", "$", "this", "->", "generateRouteFromText", "(", "$", "route", "->", "getRoutePattern", "(", ")", ",", "$", "withSlash", ")", ";", "if", "(", "$", "originalRoutePattern", ")", "{", "$", "key", "=", "0", ";", "$", "routePattern", "=", "$", "this", "->", "normalizeRoute", "(", "$", "originalRoutePattern", ")", ";", "while", "(", "$", "this", "->", "hasRoute", "(", "$", "routePattern", ",", "$", "route", "->", "getName", "(", ")", ")", ")", "{", "$", "key", "++", ";", "$", "routePattern", "=", "$", "originalRoutePattern", ".", "'-'", ".", "$", "key", ";", "}", "$", "route", "->", "setRoutePattern", "(", "$", "routePattern", ")", ";", "return", "$", "route", ";", "}", "return", "null", ";", "}" ]
Generate unique route. @param RouteInterface $route @param bool $withSlash @return null|RouteInterface
[ "Generate", "unique", "route", "." ]
b2280bac33eb76eec76ecc8d665c70092f3cbba9
https://github.com/tadcka/Routing/blob/b2280bac33eb76eec76ecc8d665c70092f3cbba9/Generator/RouteGenerator.php#L73-L92
236,606
tadcka/Routing
Generator/RouteGenerator.php
RouteGenerator.hasRoute
private function hasRoute($routePattern, $routeName) { if (!$routeName) { throw new RoutingRuntimeException('Route name is empty!'); } $route = $this->routeManager->findByRoutePattern($routePattern); return ((null !== $route) && ($routeName !== $route->getName())); }
php
private function hasRoute($routePattern, $routeName) { if (!$routeName) { throw new RoutingRuntimeException('Route name is empty!'); } $route = $this->routeManager->findByRoutePattern($routePattern); return ((null !== $route) && ($routeName !== $route->getName())); }
[ "private", "function", "hasRoute", "(", "$", "routePattern", ",", "$", "routeName", ")", "{", "if", "(", "!", "$", "routeName", ")", "{", "throw", "new", "RoutingRuntimeException", "(", "'Route name is empty!'", ")", ";", "}", "$", "route", "=", "$", "this", "->", "routeManager", "->", "findByRoutePattern", "(", "$", "routePattern", ")", ";", "return", "(", "(", "null", "!==", "$", "route", ")", "&&", "(", "$", "routeName", "!==", "$", "route", "->", "getName", "(", ")", ")", ")", ";", "}" ]
Has route. @param string $routePattern @param string $routeName @return bool @throws RoutingRuntimeException
[ "Has", "route", "." ]
b2280bac33eb76eec76ecc8d665c70092f3cbba9
https://github.com/tadcka/Routing/blob/b2280bac33eb76eec76ecc8d665c70092f3cbba9/Generator/RouteGenerator.php#L104-L113
236,607
todstoychev/websafe-colors
src/Wsc.php
Wsc.createRgbArray
private static function createRgbArray(array $vals) { foreach ($vals as $r) { foreach ($vals as $g) { foreach ($vals as $b) { $colors[] = ['r' => $r, 'g' => $g, 'b' => $b]; } } } return $colors; }
php
private static function createRgbArray(array $vals) { foreach ($vals as $r) { foreach ($vals as $g) { foreach ($vals as $b) { $colors[] = ['r' => $r, 'g' => $g, 'b' => $b]; } } } return $colors; }
[ "private", "static", "function", "createRgbArray", "(", "array", "$", "vals", ")", "{", "foreach", "(", "$", "vals", "as", "$", "r", ")", "{", "foreach", "(", "$", "vals", "as", "$", "g", ")", "{", "foreach", "(", "$", "vals", "as", "$", "b", ")", "{", "$", "colors", "[", "]", "=", "[", "'r'", "=>", "$", "r", ",", "'g'", "=>", "$", "g", ",", "'b'", "=>", "$", "b", "]", ";", "}", "}", "}", "return", "$", "colors", ";", "}" ]
Creates rgb codes array @example [ ['r' => 0, 'g' => 0, 'b' => 0], ['r' => 0, 'g' => 51, 'b' => 0], ['r' => 0, 'g' => 0, 'b' => 51], ... ] @param array $vals Initial values @return array
[ "Creates", "rgb", "codes", "array" ]
3ab5d9307abb1ed6bf9f2d46eca33ebcdc778958
https://github.com/todstoychev/websafe-colors/blob/3ab5d9307abb1ed6bf9f2d46eca33ebcdc778958/src/Wsc.php#L79-L90
236,608
todstoychev/websafe-colors
src/Wsc.php
Wsc.createHexArray
private static function createHexArray(array $vals) { foreach ($vals as $r) { foreach ($vals as $g) { foreach ($vals as $b) { $colors[] = self::rgbToHex($r, $g, $b); } } } return $colors; }
php
private static function createHexArray(array $vals) { foreach ($vals as $r) { foreach ($vals as $g) { foreach ($vals as $b) { $colors[] = self::rgbToHex($r, $g, $b); } } } return $colors; }
[ "private", "static", "function", "createHexArray", "(", "array", "$", "vals", ")", "{", "foreach", "(", "$", "vals", "as", "$", "r", ")", "{", "foreach", "(", "$", "vals", "as", "$", "g", ")", "{", "foreach", "(", "$", "vals", "as", "$", "b", ")", "{", "$", "colors", "[", "]", "=", "self", "::", "rgbToHex", "(", "$", "r", ",", "$", "g", ",", "$", "b", ")", ";", "}", "}", "}", "return", "$", "colors", ";", "}" ]
Creates hex values array @example [ 000000, 003300, 000033, ... ] @param array $vals initial values @return array
[ "Creates", "hex", "values", "array" ]
3ab5d9307abb1ed6bf9f2d46eca33ebcdc778958
https://github.com/todstoychev/websafe-colors/blob/3ab5d9307abb1ed6bf9f2d46eca33ebcdc778958/src/Wsc.php#L104-L115
236,609
rozaverta/cmf
core/Cmd/Api/Host/Host.php
Host.setWww
public function setWww( bool $www = true ) { $this->www = $www; $this->invoke("www", $www); return $this; }
php
public function setWww( bool $www = true ) { $this->www = $www; $this->invoke("www", $www); return $this; }
[ "public", "function", "setWww", "(", "bool", "$", "www", "=", "true", ")", "{", "$", "this", "->", "www", "=", "$", "www", ";", "$", "this", "->", "invoke", "(", "\"www\"", ",", "$", "www", ")", ";", "return", "$", "this", ";", "}" ]
Use or not WWW prefix for domain @param bool $www @return $this
[ "Use", "or", "not", "WWW", "prefix", "for", "domain" ]
95ed38362e397d1c700ee255f7200234ef98d356
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Cmd/Api/Host/Host.php#L159-L164
236,610
simplecomplex/php-config
src/IniSectionedFlatConfig.php
IniSectionedFlatConfig.getMultiple
public function getMultiple(string $section, $keys, $default = null) { $concatted = []; foreach ($keys as $key) { $concatted[] = $section . $this->sectionKeyDelimiter . $key; } return $this->cacheStore->getMultiple($concatted, $default); }
php
public function getMultiple(string $section, $keys, $default = null) { $concatted = []; foreach ($keys as $key) { $concatted[] = $section . $this->sectionKeyDelimiter . $key; } return $this->cacheStore->getMultiple($concatted, $default); }
[ "public", "function", "getMultiple", "(", "string", "$", "section", ",", "$", "keys", ",", "$", "default", "=", "null", ")", "{", "$", "concatted", "=", "[", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "concatted", "[", "]", "=", "$", "section", ".", "$", "this", "->", "sectionKeyDelimiter", ".", "$", "key", ";", "}", "return", "$", "this", "->", "cacheStore", "->", "getMultiple", "(", "$", "concatted", ",", "$", "default", ")", ";", "}" ]
Retrieves multiple config items by their unique section+keys, from cache. @see SectionedConfigInterface::getMultiple() @inheritdoc
[ "Retrieves", "multiple", "config", "items", "by", "their", "unique", "section", "+", "keys", "from", "cache", "." ]
0d8450bc7523e8991452ef70f4f57f3d3e67f0d4
https://github.com/simplecomplex/php-config/blob/0d8450bc7523e8991452ef70f4f57f3d3e67f0d4/src/IniSectionedFlatConfig.php#L127-L134
236,611
simplecomplex/php-config
src/IniSectionedFlatConfig.php
IniSectionedFlatConfig.setMultiple
public function setMultiple(string $section, $values) : bool { $concatted = []; foreach ($values as $key => $value) { $concatted[$section . $this->sectionKeyDelimiter . $key] = $value; } return $this->cacheStore->setMultiple($concatted); }
php
public function setMultiple(string $section, $values) : bool { $concatted = []; foreach ($values as $key => $value) { $concatted[$section . $this->sectionKeyDelimiter . $key] = $value; } return $this->cacheStore->setMultiple($concatted); }
[ "public", "function", "setMultiple", "(", "string", "$", "section", ",", "$", "values", ")", ":", "bool", "{", "$", "concatted", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "concatted", "[", "$", "section", ".", "$", "this", "->", "sectionKeyDelimiter", ".", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "this", "->", "cacheStore", "->", "setMultiple", "(", "$", "concatted", ")", ";", "}" ]
Persists a set of section+key => value pairs; in the cache, not .ini file. @see SectionedConfigInterface::setMultiple() @inheritdoc
[ "Persists", "a", "set", "of", "section", "+", "key", "=", ">", "value", "pairs", ";", "in", "the", "cache", "not", ".", "ini", "file", "." ]
0d8450bc7523e8991452ef70f4f57f3d3e67f0d4
https://github.com/simplecomplex/php-config/blob/0d8450bc7523e8991452ef70f4f57f3d3e67f0d4/src/IniSectionedFlatConfig.php#L144-L151
236,612
webbuilders-group/silverstripe-kapost-bridge
code/forms/KapostGridFieldDetailForm_ItemRequest.php
KapostGridFieldDetailForm_ItemRequest.convert
public function convert() { //Verify the record exists before proceeding if(empty($this->record) || $this->record===false || !$this->record->exists()) { return $this->httpError(404, _t('KapostAdmin.KAPOST_CONTENT_NOT_FOUND', '_Incoming Kapost Content could not be found')); } return $this->customise(array( 'Title'=>_t('KapostAdmin.CONVERT_OBJECT', '_Convert Object'), 'Content'=>null, 'Form'=>$this->ConvertObjectForm(), 'KapostObject'=>$this->record ))->renderWith('KapostAdmin_ConvertDialog'); }
php
public function convert() { //Verify the record exists before proceeding if(empty($this->record) || $this->record===false || !$this->record->exists()) { return $this->httpError(404, _t('KapostAdmin.KAPOST_CONTENT_NOT_FOUND', '_Incoming Kapost Content could not be found')); } return $this->customise(array( 'Title'=>_t('KapostAdmin.CONVERT_OBJECT', '_Convert Object'), 'Content'=>null, 'Form'=>$this->ConvertObjectForm(), 'KapostObject'=>$this->record ))->renderWith('KapostAdmin_ConvertDialog'); }
[ "public", "function", "convert", "(", ")", "{", "//Verify the record exists before proceeding", "if", "(", "empty", "(", "$", "this", "->", "record", ")", "||", "$", "this", "->", "record", "===", "false", "||", "!", "$", "this", "->", "record", "->", "exists", "(", ")", ")", "{", "return", "$", "this", "->", "httpError", "(", "404", ",", "_t", "(", "'KapostAdmin.KAPOST_CONTENT_NOT_FOUND'", ",", "'_Incoming Kapost Content could not be found'", ")", ")", ";", "}", "return", "$", "this", "->", "customise", "(", "array", "(", "'Title'", "=>", "_t", "(", "'KapostAdmin.CONVERT_OBJECT'", ",", "'_Convert Object'", ")", ",", "'Content'", "=>", "null", ",", "'Form'", "=>", "$", "this", "->", "ConvertObjectForm", "(", ")", ",", "'KapostObject'", "=>", "$", "this", "->", "record", ")", ")", "->", "renderWith", "(", "'KapostAdmin_ConvertDialog'", ")", ";", "}" ]
Handles requests for the convert dialog @return string HTML to be sent to the browser
[ "Handles", "requests", "for", "the", "convert", "dialog" ]
718f498cad0eec764d19c9081404b2a0c8f44d71
https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/forms/KapostGridFieldDetailForm_ItemRequest.php#L52-L64
236,613
webbuilders-group/silverstripe-kapost-bridge
code/forms/KapostGridFieldDetailForm_ItemRequest.php
KapostGridFieldDetailForm_ItemRequest.getDestinationClass
private function getDestinationClass() { if(empty($this->record) || $this->record===false) { return false; } $convertToClass=false; if(class_exists($this->record->DestinationClass) && is_subclass_of($this->record->DestinationClass, 'SiteTree')) { $convertToClass=$this->record->DestinationClass; }else { $parentClasses=array_reverse(ClassInfo::dataClassesFor($this->record->ClassName)); unset($parentClasses[$this->record->ClassName]); unset($parentClasses['KapostObject']); if(count($parentClasses)>0) { foreach($parentClasses as $class) { $sng=singleton($class); if(class_exists($sng->DestinationClass) && is_subclass_of($sng->DestinationClass, 'SiteTree')) { $convertToClass=$sng->DestinationClass; break; } } if(isset($sng)) { unset($sng); } } } return $convertToClass; }
php
private function getDestinationClass() { if(empty($this->record) || $this->record===false) { return false; } $convertToClass=false; if(class_exists($this->record->DestinationClass) && is_subclass_of($this->record->DestinationClass, 'SiteTree')) { $convertToClass=$this->record->DestinationClass; }else { $parentClasses=array_reverse(ClassInfo::dataClassesFor($this->record->ClassName)); unset($parentClasses[$this->record->ClassName]); unset($parentClasses['KapostObject']); if(count($parentClasses)>0) { foreach($parentClasses as $class) { $sng=singleton($class); if(class_exists($sng->DestinationClass) && is_subclass_of($sng->DestinationClass, 'SiteTree')) { $convertToClass=$sng->DestinationClass; break; } } if(isset($sng)) { unset($sng); } } } return $convertToClass; }
[ "private", "function", "getDestinationClass", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "record", ")", "||", "$", "this", "->", "record", "===", "false", ")", "{", "return", "false", ";", "}", "$", "convertToClass", "=", "false", ";", "if", "(", "class_exists", "(", "$", "this", "->", "record", "->", "DestinationClass", ")", "&&", "is_subclass_of", "(", "$", "this", "->", "record", "->", "DestinationClass", ",", "'SiteTree'", ")", ")", "{", "$", "convertToClass", "=", "$", "this", "->", "record", "->", "DestinationClass", ";", "}", "else", "{", "$", "parentClasses", "=", "array_reverse", "(", "ClassInfo", "::", "dataClassesFor", "(", "$", "this", "->", "record", "->", "ClassName", ")", ")", ";", "unset", "(", "$", "parentClasses", "[", "$", "this", "->", "record", "->", "ClassName", "]", ")", ";", "unset", "(", "$", "parentClasses", "[", "'KapostObject'", "]", ")", ";", "if", "(", "count", "(", "$", "parentClasses", ")", ">", "0", ")", "{", "foreach", "(", "$", "parentClasses", "as", "$", "class", ")", "{", "$", "sng", "=", "singleton", "(", "$", "class", ")", ";", "if", "(", "class_exists", "(", "$", "sng", "->", "DestinationClass", ")", "&&", "is_subclass_of", "(", "$", "sng", "->", "DestinationClass", ",", "'SiteTree'", ")", ")", "{", "$", "convertToClass", "=", "$", "sng", "->", "DestinationClass", ";", "break", ";", "}", "}", "if", "(", "isset", "(", "$", "sng", ")", ")", "{", "unset", "(", "$", "sng", ")", ";", "}", "}", "}", "return", "$", "convertToClass", ";", "}" ]
Gets the destination class for the record @return string|bool Returns the destination class name or false if it can't be found
[ "Gets", "the", "destination", "class", "for", "the", "record" ]
718f498cad0eec764d19c9081404b2a0c8f44d71
https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/forms/KapostGridFieldDetailForm_ItemRequest.php#L571-L601
236,614
webbuilders-group/silverstripe-kapost-bridge
code/forms/KapostGridFieldDetailForm_ItemRequest.php
KapostGridFieldDetailForm_ItemRequest.cleanUpExpiredPreviews
private function cleanUpExpiredPreviews() { $expiredPreviews=KapostObject::get()->filter('IsKapostPreview', true)->filter('LastEdited:LessThan', date('Y-m-d H:i:s', strtotime('-'.(KapostService::config()->preview_data_expiry).' minutes'))); if($expiredPreviews->count()>0) { foreach($expiredPreviews as $kapostObj) { $kapostObj->delete(); } } }
php
private function cleanUpExpiredPreviews() { $expiredPreviews=KapostObject::get()->filter('IsKapostPreview', true)->filter('LastEdited:LessThan', date('Y-m-d H:i:s', strtotime('-'.(KapostService::config()->preview_data_expiry).' minutes'))); if($expiredPreviews->count()>0) { foreach($expiredPreviews as $kapostObj) { $kapostObj->delete(); } } }
[ "private", "function", "cleanUpExpiredPreviews", "(", ")", "{", "$", "expiredPreviews", "=", "KapostObject", "::", "get", "(", ")", "->", "filter", "(", "'IsKapostPreview'", ",", "true", ")", "->", "filter", "(", "'LastEdited:LessThan'", ",", "date", "(", "'Y-m-d H:i:s'", ",", "strtotime", "(", "'-'", ".", "(", "KapostService", "::", "config", "(", ")", "->", "preview_data_expiry", ")", ".", "' minutes'", ")", ")", ")", ";", "if", "(", "$", "expiredPreviews", "->", "count", "(", ")", ">", "0", ")", "{", "foreach", "(", "$", "expiredPreviews", "as", "$", "kapostObj", ")", "{", "$", "kapostObj", "->", "delete", "(", ")", ";", "}", "}", "}" ]
Cleans up expired Kapost previews after twice the token expiry
[ "Cleans", "up", "expired", "Kapost", "previews", "after", "twice", "the", "token", "expiry" ]
718f498cad0eec764d19c9081404b2a0c8f44d71
https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/forms/KapostGridFieldDetailForm_ItemRequest.php#L606-L613
236,615
a3020/cron-expression
src/Cron/CronExpression.php
CronExpression.getPreviousRunDate
public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) { return $this->getRunDate($currentTime, $nth, true, $allowCurrentDate); }
php
public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) { return $this->getRunDate($currentTime, $nth, true, $allowCurrentDate); }
[ "public", "function", "getPreviousRunDate", "(", "$", "currentTime", "=", "'now'", ",", "$", "nth", "=", "0", ",", "$", "allowCurrentDate", "=", "false", ")", "{", "return", "$", "this", "->", "getRunDate", "(", "$", "currentTime", ",", "$", "nth", ",", "true", ",", "$", "allowCurrentDate", ")", ";", "}" ]
Get a previous run date relative to the current date or a specific date @param string|\DateTime $currentTime Relative calculation date @param int $nth Number of matches to skip before returning @param bool $allowCurrentDate Set to TRUE to return the current date if it matches the cron expression @return \DateTime @throws \RuntimeException on too many iterations @see \Cron\CronExpression::getNextRunDate
[ "Get", "a", "previous", "run", "date", "relative", "to", "the", "current", "date", "or", "a", "specific", "date" ]
a78465476b01b302ca35253780999b6fc122c248
https://github.com/a3020/cron-expression/blob/a78465476b01b302ca35253780999b6fc122c248/src/Cron/CronExpression.php#L211-L214
236,616
a3020/cron-expression
src/Cron/CronExpression.php
CronExpression.getRunDate
protected function getRunDate($currentTime = null, $nth = 0, $invert = false, $allowCurrentDate = false) { if ($currentTime instanceof DateTime) { $currentDate = clone $currentTime; } elseif ($currentTime instanceof DateTimeImmutable) { $currentDate = DateTime::createFromFormat('U', $currentTime->format('U')); $currentDate->setTimezone($currentTime->getTimezone()); } else { $currentDate = new DateTime($currentTime ?: 'now'); $currentDate->setTimezone(new DateTimeZone(date_default_timezone_get())); } $currentDate->setTime($currentDate->format('H'), $currentDate->format('i'), 0); $nextRun = clone $currentDate; $nth = (int) $nth; // We don't have to satisfy * or null fields $parts = array(); $fields = array(); foreach (self::$order as $position) { $part = $this->getExpression($position); if (null === $part || '*' === $part) { continue; } $parts[$position] = $part; $fields[$position] = $this->fieldFactory->getField($position); } // Set a hard limit to bail on an impossible date for ($i = 0; $i < $this->maxIterationCount; $i++) { foreach ($parts as $position => $part) { $satisfied = false; // Get the field object used to validate this part $field = $fields[$position]; // Check if this is singular or a list if (strpos($part, ',') === false) { $satisfied = $field->isSatisfiedBy($nextRun, $part); } else { foreach (array_map('trim', explode(',', $part)) as $listPart) { if ($field->isSatisfiedBy($nextRun, $listPart)) { $satisfied = true; break; } } } // If the field is not satisfied, then start over if (!$satisfied) { $field->increment($nextRun, $invert, $part); continue 2; } } // Skip this match if needed if ((!$allowCurrentDate && $nextRun == $currentDate) || --$nth > -1) { $this->fieldFactory->getField(0)->increment($nextRun, $invert, isset($parts[0]) ? $parts[0] : null); continue; } return $nextRun; } // @codeCoverageIgnoreStart throw new RuntimeException('Impossible CRON expression'); // @codeCoverageIgnoreEnd }
php
protected function getRunDate($currentTime = null, $nth = 0, $invert = false, $allowCurrentDate = false) { if ($currentTime instanceof DateTime) { $currentDate = clone $currentTime; } elseif ($currentTime instanceof DateTimeImmutable) { $currentDate = DateTime::createFromFormat('U', $currentTime->format('U')); $currentDate->setTimezone($currentTime->getTimezone()); } else { $currentDate = new DateTime($currentTime ?: 'now'); $currentDate->setTimezone(new DateTimeZone(date_default_timezone_get())); } $currentDate->setTime($currentDate->format('H'), $currentDate->format('i'), 0); $nextRun = clone $currentDate; $nth = (int) $nth; // We don't have to satisfy * or null fields $parts = array(); $fields = array(); foreach (self::$order as $position) { $part = $this->getExpression($position); if (null === $part || '*' === $part) { continue; } $parts[$position] = $part; $fields[$position] = $this->fieldFactory->getField($position); } // Set a hard limit to bail on an impossible date for ($i = 0; $i < $this->maxIterationCount; $i++) { foreach ($parts as $position => $part) { $satisfied = false; // Get the field object used to validate this part $field = $fields[$position]; // Check if this is singular or a list if (strpos($part, ',') === false) { $satisfied = $field->isSatisfiedBy($nextRun, $part); } else { foreach (array_map('trim', explode(',', $part)) as $listPart) { if ($field->isSatisfiedBy($nextRun, $listPart)) { $satisfied = true; break; } } } // If the field is not satisfied, then start over if (!$satisfied) { $field->increment($nextRun, $invert, $part); continue 2; } } // Skip this match if needed if ((!$allowCurrentDate && $nextRun == $currentDate) || --$nth > -1) { $this->fieldFactory->getField(0)->increment($nextRun, $invert, isset($parts[0]) ? $parts[0] : null); continue; } return $nextRun; } // @codeCoverageIgnoreStart throw new RuntimeException('Impossible CRON expression'); // @codeCoverageIgnoreEnd }
[ "protected", "function", "getRunDate", "(", "$", "currentTime", "=", "null", ",", "$", "nth", "=", "0", ",", "$", "invert", "=", "false", ",", "$", "allowCurrentDate", "=", "false", ")", "{", "if", "(", "$", "currentTime", "instanceof", "DateTime", ")", "{", "$", "currentDate", "=", "clone", "$", "currentTime", ";", "}", "elseif", "(", "$", "currentTime", "instanceof", "DateTimeImmutable", ")", "{", "$", "currentDate", "=", "DateTime", "::", "createFromFormat", "(", "'U'", ",", "$", "currentTime", "->", "format", "(", "'U'", ")", ")", ";", "$", "currentDate", "->", "setTimezone", "(", "$", "currentTime", "->", "getTimezone", "(", ")", ")", ";", "}", "else", "{", "$", "currentDate", "=", "new", "DateTime", "(", "$", "currentTime", "?", ":", "'now'", ")", ";", "$", "currentDate", "->", "setTimezone", "(", "new", "DateTimeZone", "(", "date_default_timezone_get", "(", ")", ")", ")", ";", "}", "$", "currentDate", "->", "setTime", "(", "$", "currentDate", "->", "format", "(", "'H'", ")", ",", "$", "currentDate", "->", "format", "(", "'i'", ")", ",", "0", ")", ";", "$", "nextRun", "=", "clone", "$", "currentDate", ";", "$", "nth", "=", "(", "int", ")", "$", "nth", ";", "// We don't have to satisfy * or null fields", "$", "parts", "=", "array", "(", ")", ";", "$", "fields", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "$", "order", "as", "$", "position", ")", "{", "$", "part", "=", "$", "this", "->", "getExpression", "(", "$", "position", ")", ";", "if", "(", "null", "===", "$", "part", "||", "'*'", "===", "$", "part", ")", "{", "continue", ";", "}", "$", "parts", "[", "$", "position", "]", "=", "$", "part", ";", "$", "fields", "[", "$", "position", "]", "=", "$", "this", "->", "fieldFactory", "->", "getField", "(", "$", "position", ")", ";", "}", "// Set a hard limit to bail on an impossible date", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this", "->", "maxIterationCount", ";", "$", "i", "++", ")", "{", "foreach", "(", "$", "parts", "as", "$", "position", "=>", "$", "part", ")", "{", "$", "satisfied", "=", "false", ";", "// Get the field object used to validate this part", "$", "field", "=", "$", "fields", "[", "$", "position", "]", ";", "// Check if this is singular or a list", "if", "(", "strpos", "(", "$", "part", ",", "','", ")", "===", "false", ")", "{", "$", "satisfied", "=", "$", "field", "->", "isSatisfiedBy", "(", "$", "nextRun", ",", "$", "part", ")", ";", "}", "else", "{", "foreach", "(", "array_map", "(", "'trim'", ",", "explode", "(", "','", ",", "$", "part", ")", ")", "as", "$", "listPart", ")", "{", "if", "(", "$", "field", "->", "isSatisfiedBy", "(", "$", "nextRun", ",", "$", "listPart", ")", ")", "{", "$", "satisfied", "=", "true", ";", "break", ";", "}", "}", "}", "// If the field is not satisfied, then start over", "if", "(", "!", "$", "satisfied", ")", "{", "$", "field", "->", "increment", "(", "$", "nextRun", ",", "$", "invert", ",", "$", "part", ")", ";", "continue", "2", ";", "}", "}", "// Skip this match if needed", "if", "(", "(", "!", "$", "allowCurrentDate", "&&", "$", "nextRun", "==", "$", "currentDate", ")", "||", "--", "$", "nth", ">", "-", "1", ")", "{", "$", "this", "->", "fieldFactory", "->", "getField", "(", "0", ")", "->", "increment", "(", "$", "nextRun", ",", "$", "invert", ",", "isset", "(", "$", "parts", "[", "0", "]", ")", "?", "$", "parts", "[", "0", "]", ":", "null", ")", ";", "continue", ";", "}", "return", "$", "nextRun", ";", "}", "// @codeCoverageIgnoreStart", "throw", "new", "RuntimeException", "(", "'Impossible CRON expression'", ")", ";", "// @codeCoverageIgnoreEnd", "}" ]
Get the next or previous run date of the expression relative to a date @param string|\DateTime $currentTime Relative calculation date @param int $nth Number of matches to skip before returning @param bool $invert Set to TRUE to go backwards in time @param bool $allowCurrentDate Set to TRUE to return the current date if it matches the cron expression @return \DateTime @throws \RuntimeException on too many iterations
[ "Get", "the", "next", "or", "previous", "run", "date", "of", "the", "expression", "relative", "to", "a", "date" ]
a78465476b01b302ca35253780999b6fc122c248
https://github.com/a3020/cron-expression/blob/a78465476b01b302ca35253780999b6fc122c248/src/Cron/CronExpression.php#L322-L388
236,617
deasilworks/api
src/UUID.php
UUID.getV4
public static function getV4() { return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) ); }
php
public static function getV4() { return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) ); }
[ "public", "static", "function", "getV4", "(", ")", "{", "return", "sprintf", "(", "'%04x%04x-%04x-%04x-%04x-%04x%04x%04x'", ",", "mt_rand", "(", "0", ",", "0xffff", ")", ",", "mt_rand", "(", "0", ",", "0xffff", ")", ",", "mt_rand", "(", "0", ",", "0xffff", ")", ",", "mt_rand", "(", "0", ",", "0x0fff", ")", "|", "0x4000", ",", "mt_rand", "(", "0", ",", "0x3fff", ")", "|", "0x8000", ",", "mt_rand", "(", "0", ",", "0xffff", ")", ",", "mt_rand", "(", "0", ",", "0xffff", ")", ",", "mt_rand", "(", "0", ",", "0xffff", ")", ")", ";", "}" ]
Get a UUID v4. @ApiAction() @return string
[ "Get", "a", "UUID", "v4", "." ]
f3ba8900b246e8ea1777692b16168fd7295670fc
https://github.com/deasilworks/api/blob/f3ba8900b246e8ea1777692b16168fd7295670fc/src/UUID.php#L45-L54
236,618
polary/polary
src/polary/component/i18n/Recognizer.php
Recognizer.handle
public function handle() { foreach ($this->loaders as $loader) { if ($language = call_user_func($loader)) { if (in_array($language, $this->supportedLanguages)) { return $language; } $special = strpos($language, '-') !== false; if ($special && $this->allowFallback && in_array(substr($language, 0, 2), $this->supportedLanguages)) { return substr($language, 0, 2); } if ( ! $special && $this->allowAdvance) { foreach ($this->supportedLanguages as $supportedLanguage) { if ($language === substr($supportedLanguage, 0, 2)) { return $supportedLanguage; } } } } } return false; }
php
public function handle() { foreach ($this->loaders as $loader) { if ($language = call_user_func($loader)) { if (in_array($language, $this->supportedLanguages)) { return $language; } $special = strpos($language, '-') !== false; if ($special && $this->allowFallback && in_array(substr($language, 0, 2), $this->supportedLanguages)) { return substr($language, 0, 2); } if ( ! $special && $this->allowAdvance) { foreach ($this->supportedLanguages as $supportedLanguage) { if ($language === substr($supportedLanguage, 0, 2)) { return $supportedLanguage; } } } } } return false; }
[ "public", "function", "handle", "(", ")", "{", "foreach", "(", "$", "this", "->", "loaders", "as", "$", "loader", ")", "{", "if", "(", "$", "language", "=", "call_user_func", "(", "$", "loader", ")", ")", "{", "if", "(", "in_array", "(", "$", "language", ",", "$", "this", "->", "supportedLanguages", ")", ")", "{", "return", "$", "language", ";", "}", "$", "special", "=", "strpos", "(", "$", "language", ",", "'-'", ")", "!==", "false", ";", "if", "(", "$", "special", "&&", "$", "this", "->", "allowFallback", "&&", "in_array", "(", "substr", "(", "$", "language", ",", "0", ",", "2", ")", ",", "$", "this", "->", "supportedLanguages", ")", ")", "{", "return", "substr", "(", "$", "language", ",", "0", ",", "2", ")", ";", "}", "if", "(", "!", "$", "special", "&&", "$", "this", "->", "allowAdvance", ")", "{", "foreach", "(", "$", "this", "->", "supportedLanguages", "as", "$", "supportedLanguage", ")", "{", "if", "(", "$", "language", "===", "substr", "(", "$", "supportedLanguage", ",", "0", ",", "2", ")", ")", "{", "return", "$", "supportedLanguage", ";", "}", "}", "}", "}", "}", "return", "false", ";", "}" ]
Run all loaders returns a language string or false. @return bool|string
[ "Run", "all", "loaders", "returns", "a", "language", "string", "or", "false", "." ]
683212e631e59faedce488f0d2cea82c94a83aae
https://github.com/polary/polary/blob/683212e631e59faedce488f0d2cea82c94a83aae/src/polary/component/i18n/Recognizer.php#L99-L124
236,619
polary/polary
src/polary/component/i18n/Recognizer.php
Recognizer.loadFromHttpHeader
protected function loadFromHttpHeader() { foreach (Yii::$app->request->getAcceptableLanguages() as $language) { if (in_array($language, $this->supportedLanguages)) { return $language; } } return false; }
php
protected function loadFromHttpHeader() { foreach (Yii::$app->request->getAcceptableLanguages() as $language) { if (in_array($language, $this->supportedLanguages)) { return $language; } } return false; }
[ "protected", "function", "loadFromHttpHeader", "(", ")", "{", "foreach", "(", "Yii", "::", "$", "app", "->", "request", "->", "getAcceptableLanguages", "(", ")", "as", "$", "language", ")", "{", "if", "(", "in_array", "(", "$", "language", ",", "$", "this", "->", "supportedLanguages", ")", ")", "{", "return", "$", "language", ";", "}", "}", "return", "false", ";", "}" ]
Load language from HTTP header. @return string|bool
[ "Load", "language", "from", "HTTP", "header", "." ]
683212e631e59faedce488f0d2cea82c94a83aae
https://github.com/polary/polary/blob/683212e631e59faedce488f0d2cea82c94a83aae/src/polary/component/i18n/Recognizer.php#L131-L140
236,620
polary/polary
src/polary/component/i18n/Recognizer.php
Recognizer.loadFromCookie
protected function loadFromCookie() { if ($this->cookieLanguageField && ($language = Yii::$app->request->cookies->has($this->cookieLanguageField))) { return $language; } return false; }
php
protected function loadFromCookie() { if ($this->cookieLanguageField && ($language = Yii::$app->request->cookies->has($this->cookieLanguageField))) { return $language; } return false; }
[ "protected", "function", "loadFromCookie", "(", ")", "{", "if", "(", "$", "this", "->", "cookieLanguageField", "&&", "(", "$", "language", "=", "Yii", "::", "$", "app", "->", "request", "->", "cookies", "->", "has", "(", "$", "this", "->", "cookieLanguageField", ")", ")", ")", "{", "return", "$", "language", ";", "}", "return", "false", ";", "}" ]
Load language from client cookie. @return string|bool
[ "Load", "language", "from", "client", "cookie", "." ]
683212e631e59faedce488f0d2cea82c94a83aae
https://github.com/polary/polary/blob/683212e631e59faedce488f0d2cea82c94a83aae/src/polary/component/i18n/Recognizer.php#L147-L154
236,621
polary/polary
src/polary/component/i18n/Recognizer.php
Recognizer.loadFromQueryParam
protected function loadFromQueryParam() { if ( ! $this->queryParamField) { return false; } if (Yii::$app->state < WebApplication::STATE_HANDLING_REQUEST) { Yii::$app->request->resolve(); } if (($language = Yii::$app->request->get($this->queryParamField, false))) { return $language; } return false; }
php
protected function loadFromQueryParam() { if ( ! $this->queryParamField) { return false; } if (Yii::$app->state < WebApplication::STATE_HANDLING_REQUEST) { Yii::$app->request->resolve(); } if (($language = Yii::$app->request->get($this->queryParamField, false))) { return $language; } return false; }
[ "protected", "function", "loadFromQueryParam", "(", ")", "{", "if", "(", "!", "$", "this", "->", "queryParamField", ")", "{", "return", "false", ";", "}", "if", "(", "Yii", "::", "$", "app", "->", "state", "<", "WebApplication", "::", "STATE_HANDLING_REQUEST", ")", "{", "Yii", "::", "$", "app", "->", "request", "->", "resolve", "(", ")", ";", "}", "if", "(", "(", "$", "language", "=", "Yii", "::", "$", "app", "->", "request", "->", "get", "(", "$", "this", "->", "queryParamField", ",", "false", ")", ")", ")", "{", "return", "$", "language", ";", "}", "return", "false", ";", "}" ]
Load language from url query param. @return string|bool
[ "Load", "language", "from", "url", "query", "param", "." ]
683212e631e59faedce488f0d2cea82c94a83aae
https://github.com/polary/polary/blob/683212e631e59faedce488f0d2cea82c94a83aae/src/polary/component/i18n/Recognizer.php#L161-L176
236,622
polary/polary
src/polary/component/i18n/Recognizer.php
Recognizer.loadFromUri
protected function loadFromUri() { if ( ! $this->uriPosition) { return false; } $url = Yii::$app->request->getAbsoluteUrl(); $parse = parse_url($url); if ( ! empty($parse)) { $path = explode('/', trim($parse['path']), $this->uriPosition + 1); is_string($path) and $path = [$path]; if (isset($parse[$this->uriPosition - 1])) { return $parse[0]; } } return false; }
php
protected function loadFromUri() { if ( ! $this->uriPosition) { return false; } $url = Yii::$app->request->getAbsoluteUrl(); $parse = parse_url($url); if ( ! empty($parse)) { $path = explode('/', trim($parse['path']), $this->uriPosition + 1); is_string($path) and $path = [$path]; if (isset($parse[$this->uriPosition - 1])) { return $parse[0]; } } return false; }
[ "protected", "function", "loadFromUri", "(", ")", "{", "if", "(", "!", "$", "this", "->", "uriPosition", ")", "{", "return", "false", ";", "}", "$", "url", "=", "Yii", "::", "$", "app", "->", "request", "->", "getAbsoluteUrl", "(", ")", ";", "$", "parse", "=", "parse_url", "(", "$", "url", ")", ";", "if", "(", "!", "empty", "(", "$", "parse", ")", ")", "{", "$", "path", "=", "explode", "(", "'/'", ",", "trim", "(", "$", "parse", "[", "'path'", "]", ")", ",", "$", "this", "->", "uriPosition", "+", "1", ")", ";", "is_string", "(", "$", "path", ")", "and", "$", "path", "=", "[", "$", "path", "]", ";", "if", "(", "isset", "(", "$", "parse", "[", "$", "this", "->", "uriPosition", "-", "1", "]", ")", ")", "{", "return", "$", "parse", "[", "0", "]", ";", "}", "}", "return", "false", ";", "}" ]
Load language from uri position. @return bool
[ "Load", "language", "from", "uri", "position", "." ]
683212e631e59faedce488f0d2cea82c94a83aae
https://github.com/polary/polary/blob/683212e631e59faedce488f0d2cea82c94a83aae/src/polary/component/i18n/Recognizer.php#L183-L200
236,623
vinala/kernel
src/Plugins/Plugins.php
Plugins.getInfo
protected static function getInfo() { $files = self::getFiles(); // foreach ($files as $path) { $data = self::convert(self::readFile($path.'/vinala.json'), $path); $data = $data['system']; $data['path'] = $path; if (array_key_exists('alias', $data)) { self::$infos[$data['alias']] = $data; } else { // die($path."/.info"); } } // return self::$infos; }
php
protected static function getInfo() { $files = self::getFiles(); // foreach ($files as $path) { $data = self::convert(self::readFile($path.'/vinala.json'), $path); $data = $data['system']; $data['path'] = $path; if (array_key_exists('alias', $data)) { self::$infos[$data['alias']] = $data; } else { // die($path."/.info"); } } // return self::$infos; }
[ "protected", "static", "function", "getInfo", "(", ")", "{", "$", "files", "=", "self", "::", "getFiles", "(", ")", ";", "//", "foreach", "(", "$", "files", "as", "$", "path", ")", "{", "$", "data", "=", "self", "::", "convert", "(", "self", "::", "readFile", "(", "$", "path", ".", "'/vinala.json'", ")", ",", "$", "path", ")", ";", "$", "data", "=", "$", "data", "[", "'system'", "]", ";", "$", "data", "[", "'path'", "]", "=", "$", "path", ";", "if", "(", "array_key_exists", "(", "'alias'", ",", "$", "data", ")", ")", "{", "self", "::", "$", "infos", "[", "$", "data", "[", "'alias'", "]", "]", "=", "$", "data", ";", "}", "else", "{", "// die($path.\"/.info\");", "}", "}", "//", "return", "self", "::", "$", "infos", ";", "}" ]
Get infos about plug-ins.
[ "Get", "infos", "about", "plug", "-", "ins", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Plugins/Plugins.php#L61-L78
236,624
vinala/kernel
src/Plugins/Plugins.php
Plugins.convert
protected static function convert($string, $path) { $data = json_decode($string, true); // if (json_last_error() == JSON_ERROR_SYNTAX) { throw new InfoStructureException($path); } // return $data; }
php
protected static function convert($string, $path) { $data = json_decode($string, true); // if (json_last_error() == JSON_ERROR_SYNTAX) { throw new InfoStructureException($path); } // return $data; }
[ "protected", "static", "function", "convert", "(", "$", "string", ",", "$", "path", ")", "{", "$", "data", "=", "json_decode", "(", "$", "string", ",", "true", ")", ";", "//", "if", "(", "json_last_error", "(", ")", "==", "JSON_ERROR_SYNTAX", ")", "{", "throw", "new", "InfoStructureException", "(", "$", "path", ")", ";", "}", "//", "return", "$", "data", ";", "}" ]
Convert JSON to PHP array.
[ "Convert", "JSON", "to", "PHP", "array", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Plugins/Plugins.php#L98-L107
236,625
vinala/kernel
src/Plugins/Plugins.php
Plugins.getFiles
protected static function getFiles() { $files = []; // foreach (glob(Application::$root.'plugins/*') as $value) { $files[] = $value; } // return $files; }
php
protected static function getFiles() { $files = []; // foreach (glob(Application::$root.'plugins/*') as $value) { $files[] = $value; } // return $files; }
[ "protected", "static", "function", "getFiles", "(", ")", "{", "$", "files", "=", "[", "]", ";", "//", "foreach", "(", "glob", "(", "Application", "::", "$", "root", ".", "'plugins/*'", ")", "as", "$", "value", ")", "{", "$", "files", "[", "]", "=", "$", "value", ";", "}", "//", "return", "$", "files", ";", "}" ]
Get all info files path.
[ "Get", "all", "info", "files", "path", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Plugins/Plugins.php#L120-L129
236,626
vinala/kernel
src/Plugins/Plugins.php
Plugins.setAlias
public static function setAlias($alias) { if (self::isConfigKeyExist($alias, 'shortcuts')) { $shortcuts = self::$config[$alias]['shortcuts']; // foreach ($shortcuts as $alias => $target) { $target = Strings::replace($target, '/', '\\'); Alias::set($target, $alias); } } }
php
public static function setAlias($alias) { if (self::isConfigKeyExist($alias, 'shortcuts')) { $shortcuts = self::$config[$alias]['shortcuts']; // foreach ($shortcuts as $alias => $target) { $target = Strings::replace($target, '/', '\\'); Alias::set($target, $alias); } } }
[ "public", "static", "function", "setAlias", "(", "$", "alias", ")", "{", "if", "(", "self", "::", "isConfigKeyExist", "(", "$", "alias", ",", "'shortcuts'", ")", ")", "{", "$", "shortcuts", "=", "self", "::", "$", "config", "[", "$", "alias", "]", "[", "'shortcuts'", "]", ";", "//", "foreach", "(", "$", "shortcuts", "as", "$", "alias", "=>", "$", "target", ")", "{", "$", "target", "=", "Strings", "::", "replace", "(", "$", "target", ",", "'/'", ",", "'\\\\'", ")", ";", "Alias", "::", "set", "(", "$", "target", ",", "$", "alias", ")", ";", "}", "}", "}" ]
Set classes aliases.
[ "Set", "classes", "aliases", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Plugins/Plugins.php#L188-L198
236,627
vinala/kernel
src/Plugins/Plugins.php
Plugins.getCore
public static function getCore($alias, $param) { if (self::isInfoKeyExist($alias, 'core', $param)) { return self::$infos[$alias]['core'][$param]; } else { return; } }
php
public static function getCore($alias, $param) { if (self::isInfoKeyExist($alias, 'core', $param)) { return self::$infos[$alias]['core'][$param]; } else { return; } }
[ "public", "static", "function", "getCore", "(", "$", "alias", ",", "$", "param", ")", "{", "if", "(", "self", "::", "isInfoKeyExist", "(", "$", "alias", ",", "'core'", ",", "$", "param", ")", ")", "{", "return", "self", "::", "$", "infos", "[", "$", "alias", "]", "[", "'core'", "]", "[", "$", "param", "]", ";", "}", "else", "{", "return", ";", "}", "}" ]
Get core.
[ "Get", "core", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Plugins/Plugins.php#L211-L218
236,628
slickframework/template
src/Extension/Text.php
Text.getFilters
public function getFilters() { return [ new \Twig_SimpleFilter( 'truncate', function ($value, $len=75, $ter='...', $preserve = false) { return \Slick\Template\Utils\Text::truncate( $value, $len, $ter, $preserve ); } ), new \Twig_SimpleFilter( 'wordwrap', function ($value, $length = 75, $break = "\n", $cut = false) { return \Slick\Template\Utils\Text::wordwrap( $value, $length, $break, $cut ); } ) ]; }
php
public function getFilters() { return [ new \Twig_SimpleFilter( 'truncate', function ($value, $len=75, $ter='...', $preserve = false) { return \Slick\Template\Utils\Text::truncate( $value, $len, $ter, $preserve ); } ), new \Twig_SimpleFilter( 'wordwrap', function ($value, $length = 75, $break = "\n", $cut = false) { return \Slick\Template\Utils\Text::wordwrap( $value, $length, $break, $cut ); } ) ]; }
[ "public", "function", "getFilters", "(", ")", "{", "return", "[", "new", "\\", "Twig_SimpleFilter", "(", "'truncate'", ",", "function", "(", "$", "value", ",", "$", "len", "=", "75", ",", "$", "ter", "=", "'...'", ",", "$", "preserve", "=", "false", ")", "{", "return", "\\", "Slick", "\\", "Template", "\\", "Utils", "\\", "Text", "::", "truncate", "(", "$", "value", ",", "$", "len", ",", "$", "ter", ",", "$", "preserve", ")", ";", "}", ")", ",", "new", "\\", "Twig_SimpleFilter", "(", "'wordwrap'", ",", "function", "(", "$", "value", ",", "$", "length", "=", "75", ",", "$", "break", "=", "\"\\n\"", ",", "$", "cut", "=", "false", ")", "{", "return", "\\", "Slick", "\\", "Template", "\\", "Utils", "\\", "Text", "::", "wordwrap", "(", "$", "value", ",", "$", "length", ",", "$", "break", ",", "$", "cut", ")", ";", "}", ")", "]", ";", "}" ]
Returns a list of filters @return array
[ "Returns", "a", "list", "of", "filters" ]
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Extension/Text.php#L37-L63
236,629
coolms/authentication
src/Adapter/AbstractAdapter.php
AbstractAdapter.setSatisfied
public function setSatisfied($bool = true) { $storage = $this->getStorage()->read() ?: []; $storage['is_satisfied'] = $bool; $this->getStorage()->write($storage); return $this; }
php
public function setSatisfied($bool = true) { $storage = $this->getStorage()->read() ?: []; $storage['is_satisfied'] = $bool; $this->getStorage()->write($storage); return $this; }
[ "public", "function", "setSatisfied", "(", "$", "bool", "=", "true", ")", "{", "$", "storage", "=", "$", "this", "->", "getStorage", "(", ")", "->", "read", "(", ")", "?", ":", "[", "]", ";", "$", "storage", "[", "'is_satisfied'", "]", "=", "$", "bool", ";", "$", "this", "->", "getStorage", "(", ")", "->", "write", "(", "$", "storage", ")", ";", "return", "$", "this", ";", "}" ]
Set if this adapter is satisfied or not @param bool $bool @return self
[ "Set", "if", "this", "adapter", "is", "satisfied", "or", "not" ]
4563cc4cc3a4d777db45977bd179cc5bd3f57cd8
https://github.com/coolms/authentication/blob/4563cc4cc3a4d777db45977bd179cc5bd3f57cd8/src/Adapter/AbstractAdapter.php#L70-L77
236,630
phn-io/template
spec/Phn/Template/LexerSpec.php
LexerSpec.it_tokenize_templates
function it_tokenize_templates() { $this->tokenize(new Cursor("TEXT <{ ... . keyword 'string' \"string\" 3.14 var null true false }> TEXT"))->shouldBeLike([ new Token(Token::TYPE_TEXT, 'TEXT ', 1), new Token(Token::TYPE_OPEN_TAG | Token::TYPE_SYMBOL, '<{', 1), new Token(Token::TYPE_SYMBOL, '...', 1), new Token(Token::TYPE_SYMBOL, '.', 1), new Token(Token::TYPE_KEYWORD | Token::TYPE_IDENTIFIER, 'keyword', 1), new Token(Token::TYPE_STRING | Token::TYPE_SINGLE_QUOTED, 'string', 1), new Token(Token::TYPE_STRING | Token::TYPE_DOUBLE_QUOTED, 'string', 1), new Token(Token::TYPE_NUMBER, '3.14', 1), new Token(Token::TYPE_IDENTIFIER, 'var', 1), new Token(Token::TYPE_CONSTANT, 'null', 1), new Token(Token::TYPE_CONSTANT, 'true', 1), new Token(Token::TYPE_CONSTANT, 'false', 1), new Token(Token::TYPE_CLOSE_TAG | Token::TYPE_SYMBOL, '}>', 1), new Token(Token::TYPE_TEXT, ' TEXT', 1), new Token(Token::TYPE_EOF, null, 1), ]); }
php
function it_tokenize_templates() { $this->tokenize(new Cursor("TEXT <{ ... . keyword 'string' \"string\" 3.14 var null true false }> TEXT"))->shouldBeLike([ new Token(Token::TYPE_TEXT, 'TEXT ', 1), new Token(Token::TYPE_OPEN_TAG | Token::TYPE_SYMBOL, '<{', 1), new Token(Token::TYPE_SYMBOL, '...', 1), new Token(Token::TYPE_SYMBOL, '.', 1), new Token(Token::TYPE_KEYWORD | Token::TYPE_IDENTIFIER, 'keyword', 1), new Token(Token::TYPE_STRING | Token::TYPE_SINGLE_QUOTED, 'string', 1), new Token(Token::TYPE_STRING | Token::TYPE_DOUBLE_QUOTED, 'string', 1), new Token(Token::TYPE_NUMBER, '3.14', 1), new Token(Token::TYPE_IDENTIFIER, 'var', 1), new Token(Token::TYPE_CONSTANT, 'null', 1), new Token(Token::TYPE_CONSTANT, 'true', 1), new Token(Token::TYPE_CONSTANT, 'false', 1), new Token(Token::TYPE_CLOSE_TAG | Token::TYPE_SYMBOL, '}>', 1), new Token(Token::TYPE_TEXT, ' TEXT', 1), new Token(Token::TYPE_EOF, null, 1), ]); }
[ "function", "it_tokenize_templates", "(", ")", "{", "$", "this", "->", "tokenize", "(", "new", "Cursor", "(", "\"TEXT <{ ... . keyword 'string' \\\"string\\\" 3.14 var null true false }> TEXT\"", ")", ")", "->", "shouldBeLike", "(", "[", "new", "Token", "(", "Token", "::", "TYPE_TEXT", ",", "'TEXT '", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_OPEN_TAG", "|", "Token", "::", "TYPE_SYMBOL", ",", "'<{'", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_SYMBOL", ",", "'...'", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_SYMBOL", ",", "'.'", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_KEYWORD", "|", "Token", "::", "TYPE_IDENTIFIER", ",", "'keyword'", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_STRING", "|", "Token", "::", "TYPE_SINGLE_QUOTED", ",", "'string'", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_STRING", "|", "Token", "::", "TYPE_DOUBLE_QUOTED", ",", "'string'", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_NUMBER", ",", "'3.14'", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_IDENTIFIER", ",", "'var'", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_CONSTANT", ",", "'null'", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_CONSTANT", ",", "'true'", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_CONSTANT", ",", "'false'", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_CLOSE_TAG", "|", "Token", "::", "TYPE_SYMBOL", ",", "'}>'", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_TEXT", ",", "' TEXT'", ",", "1", ")", ",", "new", "Token", "(", "Token", "::", "TYPE_EOF", ",", "null", ",", "1", ")", ",", "]", ")", ";", "}" ]
It tokenize templates.
[ "It", "tokenize", "templates", "." ]
7d89c2a54347069340ff9b545b4c64b5512da1c3
https://github.com/phn-io/template/blob/7d89c2a54347069340ff9b545b4c64b5512da1c3/spec/Phn/Template/LexerSpec.php#L48-L67
236,631
zepi/turbo-base
Zepi/Web/General/src/Helper/CssHelper.php
CssHelper.optimizeUrls
protected function optimizeUrls($content, $file) { preg_match_all('/url\((.[^\)]*)\)/is', $content, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $uri = $match[1]; // Remove the apostrophs if (strpos($uri, '\'') === 0 || strpos($uri, '"') === 0) { $uri = substr($uri, 1, -1); } // If the uri is an absolute url we do not change anything if (strpos($uri, 'http') === 0) { continue; } $additionalData = $this->getAdditionalUriData($uri); $uri = $this->removeAdditionalUriData($uri); $path = dirname($file); $fullFilePath = realpath($path . '/' . $uri); $fileInformation = pathinfo($fullFilePath); $imageExtensions = array('png', 'jpg', 'jpeg', 'gif'); if (in_array($fileInformation['extension'], $imageExtensions)) { // Load the file content $fileContent = $this->fileBackend->loadFromFile($fullFilePath); // Encode the file content $encodedContent = base64_encode($fileContent); $urlData = 'data:image/gif;base64,' . $encodedContent; // Replace the reference in the css content $content = str_replace($match[1], '\'' . $urlData . '\'', $content); } else { $type = AssetManager::BINARY; // Cache the file $cachedFile = $this->assetCacheManager->generateCachedFile($type, $fullFilePath); $url = $this->assetCacheManager->getUrlToTheAssetLoader($cachedFile['file']); // Add the additional data if ($additionalData !== '') { $url .= $additionalData; } // Replace the reference in the css content $content = str_replace($match[1], '\'' . $url . '\'', $content); } } return $content; }
php
protected function optimizeUrls($content, $file) { preg_match_all('/url\((.[^\)]*)\)/is', $content, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $uri = $match[1]; // Remove the apostrophs if (strpos($uri, '\'') === 0 || strpos($uri, '"') === 0) { $uri = substr($uri, 1, -1); } // If the uri is an absolute url we do not change anything if (strpos($uri, 'http') === 0) { continue; } $additionalData = $this->getAdditionalUriData($uri); $uri = $this->removeAdditionalUriData($uri); $path = dirname($file); $fullFilePath = realpath($path . '/' . $uri); $fileInformation = pathinfo($fullFilePath); $imageExtensions = array('png', 'jpg', 'jpeg', 'gif'); if (in_array($fileInformation['extension'], $imageExtensions)) { // Load the file content $fileContent = $this->fileBackend->loadFromFile($fullFilePath); // Encode the file content $encodedContent = base64_encode($fileContent); $urlData = 'data:image/gif;base64,' . $encodedContent; // Replace the reference in the css content $content = str_replace($match[1], '\'' . $urlData . '\'', $content); } else { $type = AssetManager::BINARY; // Cache the file $cachedFile = $this->assetCacheManager->generateCachedFile($type, $fullFilePath); $url = $this->assetCacheManager->getUrlToTheAssetLoader($cachedFile['file']); // Add the additional data if ($additionalData !== '') { $url .= $additionalData; } // Replace the reference in the css content $content = str_replace($match[1], '\'' . $url . '\'', $content); } } return $content; }
[ "protected", "function", "optimizeUrls", "(", "$", "content", ",", "$", "file", ")", "{", "preg_match_all", "(", "'/url\\((.[^\\)]*)\\)/is'", ",", "$", "content", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "$", "uri", "=", "$", "match", "[", "1", "]", ";", "// Remove the apostrophs", "if", "(", "strpos", "(", "$", "uri", ",", "'\\''", ")", "===", "0", "||", "strpos", "(", "$", "uri", ",", "'\"'", ")", "===", "0", ")", "{", "$", "uri", "=", "substr", "(", "$", "uri", ",", "1", ",", "-", "1", ")", ";", "}", "// If the uri is an absolute url we do not change anything", "if", "(", "strpos", "(", "$", "uri", ",", "'http'", ")", "===", "0", ")", "{", "continue", ";", "}", "$", "additionalData", "=", "$", "this", "->", "getAdditionalUriData", "(", "$", "uri", ")", ";", "$", "uri", "=", "$", "this", "->", "removeAdditionalUriData", "(", "$", "uri", ")", ";", "$", "path", "=", "dirname", "(", "$", "file", ")", ";", "$", "fullFilePath", "=", "realpath", "(", "$", "path", ".", "'/'", ".", "$", "uri", ")", ";", "$", "fileInformation", "=", "pathinfo", "(", "$", "fullFilePath", ")", ";", "$", "imageExtensions", "=", "array", "(", "'png'", ",", "'jpg'", ",", "'jpeg'", ",", "'gif'", ")", ";", "if", "(", "in_array", "(", "$", "fileInformation", "[", "'extension'", "]", ",", "$", "imageExtensions", ")", ")", "{", "// Load the file content", "$", "fileContent", "=", "$", "this", "->", "fileBackend", "->", "loadFromFile", "(", "$", "fullFilePath", ")", ";", "// Encode the file content", "$", "encodedContent", "=", "base64_encode", "(", "$", "fileContent", ")", ";", "$", "urlData", "=", "'data:image/gif;base64,'", ".", "$", "encodedContent", ";", "// Replace the reference in the css content", "$", "content", "=", "str_replace", "(", "$", "match", "[", "1", "]", ",", "'\\''", ".", "$", "urlData", ".", "'\\''", ",", "$", "content", ")", ";", "}", "else", "{", "$", "type", "=", "AssetManager", "::", "BINARY", ";", "// Cache the file", "$", "cachedFile", "=", "$", "this", "->", "assetCacheManager", "->", "generateCachedFile", "(", "$", "type", ",", "$", "fullFilePath", ")", ";", "$", "url", "=", "$", "this", "->", "assetCacheManager", "->", "getUrlToTheAssetLoader", "(", "$", "cachedFile", "[", "'file'", "]", ")", ";", "// Add the additional data", "if", "(", "$", "additionalData", "!==", "''", ")", "{", "$", "url", ".=", "$", "additionalData", ";", "}", "// Replace the reference in the css content", "$", "content", "=", "str_replace", "(", "$", "match", "[", "1", "]", ",", "'\\''", ".", "$", "url", ".", "'\\''", ",", "$", "content", ")", ";", "}", "}", "return", "$", "content", ";", "}" ]
Optimizes the urls in the css content. @access protected @param string $content @param string $file @return string
[ "Optimizes", "the", "urls", "in", "the", "css", "content", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Helper/CssHelper.php#L99-L153
236,632
zepi/turbo-base
Zepi/Web/General/src/Helper/CssHelper.php
CssHelper.getAdditionalUriData
protected function getAdditionalUriData($uri) { if (strpos($uri, '?') !== false) { return substr($uri, strpos($uri, '?')); } else if (strpos($uri, '#') !== false) { return substr($uri, strpos($uri, '#')); } return ''; }
php
protected function getAdditionalUriData($uri) { if (strpos($uri, '?') !== false) { return substr($uri, strpos($uri, '?')); } else if (strpos($uri, '#') !== false) { return substr($uri, strpos($uri, '#')); } return ''; }
[ "protected", "function", "getAdditionalUriData", "(", "$", "uri", ")", "{", "if", "(", "strpos", "(", "$", "uri", ",", "'?'", ")", "!==", "false", ")", "{", "return", "substr", "(", "$", "uri", ",", "strpos", "(", "$", "uri", ",", "'?'", ")", ")", ";", "}", "else", "if", "(", "strpos", "(", "$", "uri", ",", "'#'", ")", "!==", "false", ")", "{", "return", "substr", "(", "$", "uri", ",", "strpos", "(", "$", "uri", ",", "'#'", ")", ")", ";", "}", "return", "''", ";", "}" ]
Returns the additional uri data of the given uri. @access protected @param string $uri @return string
[ "Returns", "the", "additional", "uri", "data", "of", "the", "given", "uri", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Helper/CssHelper.php#L162-L171
236,633
zepi/turbo-base
Zepi/Web/General/src/Helper/CssHelper.php
CssHelper.removeAdditionalUriData
protected function removeAdditionalUriData($uri) { if (strpos($uri, '?') !== false) { return substr($uri, 0, strpos($uri, '?')); } else if (strpos($uri, '#') !== false) { return substr($uri, 0, strpos($uri, '#')); } return $uri; }
php
protected function removeAdditionalUriData($uri) { if (strpos($uri, '?') !== false) { return substr($uri, 0, strpos($uri, '?')); } else if (strpos($uri, '#') !== false) { return substr($uri, 0, strpos($uri, '#')); } return $uri; }
[ "protected", "function", "removeAdditionalUriData", "(", "$", "uri", ")", "{", "if", "(", "strpos", "(", "$", "uri", ",", "'?'", ")", "!==", "false", ")", "{", "return", "substr", "(", "$", "uri", ",", "0", ",", "strpos", "(", "$", "uri", ",", "'?'", ")", ")", ";", "}", "else", "if", "(", "strpos", "(", "$", "uri", ",", "'#'", ")", "!==", "false", ")", "{", "return", "substr", "(", "$", "uri", ",", "0", ",", "strpos", "(", "$", "uri", ",", "'#'", ")", ")", ";", "}", "return", "$", "uri", ";", "}" ]
Returns the uri without any additional uri data. @access protected @param string $uri @return string
[ "Returns", "the", "uri", "without", "any", "additional", "uri", "data", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Helper/CssHelper.php#L180-L189
236,634
webbuilders-group/silverstripe-kapost-bridge
code/model/KapostPage.php
KapostPage.createConversionHistory
public function createConversionHistory($destinationID) { $obj=new KapostConversionHistory(); $obj->Title=$this->Title; $obj->KapostChangeType=$this->KapostChangeType; $obj->KapostRefID=$this->KapostRefID; $obj->KapostAuthor=$this->KapostAuthor; $obj->DestinationType=$this->DestinationClass; $obj->DestinationID=$destinationID; $obj->ConverterName=Member::currentUser()->Name; $obj->write(); return $obj; }
php
public function createConversionHistory($destinationID) { $obj=new KapostConversionHistory(); $obj->Title=$this->Title; $obj->KapostChangeType=$this->KapostChangeType; $obj->KapostRefID=$this->KapostRefID; $obj->KapostAuthor=$this->KapostAuthor; $obj->DestinationType=$this->DestinationClass; $obj->DestinationID=$destinationID; $obj->ConverterName=Member::currentUser()->Name; $obj->write(); return $obj; }
[ "public", "function", "createConversionHistory", "(", "$", "destinationID", ")", "{", "$", "obj", "=", "new", "KapostConversionHistory", "(", ")", ";", "$", "obj", "->", "Title", "=", "$", "this", "->", "Title", ";", "$", "obj", "->", "KapostChangeType", "=", "$", "this", "->", "KapostChangeType", ";", "$", "obj", "->", "KapostRefID", "=", "$", "this", "->", "KapostRefID", ";", "$", "obj", "->", "KapostAuthor", "=", "$", "this", "->", "KapostAuthor", ";", "$", "obj", "->", "DestinationType", "=", "$", "this", "->", "DestinationClass", ";", "$", "obj", "->", "DestinationID", "=", "$", "destinationID", ";", "$", "obj", "->", "ConverterName", "=", "Member", "::", "currentUser", "(", ")", "->", "Name", ";", "$", "obj", "->", "write", "(", ")", ";", "return", "$", "obj", ";", "}" ]
Used for recording a conversion history record @param int $destinationID ID of the destination object when converting @return KapostConversionHistory
[ "Used", "for", "recording", "a", "conversion", "history", "record" ]
718f498cad0eec764d19c9081404b2a0c8f44d71
https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/model/KapostPage.php#L66-L78
236,635
webbuilders-group/silverstripe-kapost-bridge
code/model/KapostPage.php
KapostPage.renderPreview
public function renderPreview() { $previewFieldMap=array( 'ClassName'=>$this->DestinationClass, 'IsKapostPreview'=>true, 'Children'=>false, 'Menu'=>false, 'MetaTags'=>false, 'Breadcrumbs'=>false, 'current_stage'=>Versioned::current_stage(), 'SilverStripeNavigator'=>false ); //Allow extensions to add onto the array $extensions=$this->extend('updatePreviewFieldMap'); $extensions=array_filter($extensions, function($v) {return !is_null($v) && is_array($v);}); if(count($extensions)>0) { foreach($extensions as $ext) { $previewFieldMap=array_merge($previewFieldMap, $ext); } } //Find the controller class $ancestry=ClassInfo::ancestry($this->DestinationClass); while($class=array_pop($ancestry)) { if(class_exists($class."_Controller")) { break; } } $controller=($class!==null ? "{$class}_Controller":"ContentController"); return $controller::create($this)->customise($previewFieldMap); }
php
public function renderPreview() { $previewFieldMap=array( 'ClassName'=>$this->DestinationClass, 'IsKapostPreview'=>true, 'Children'=>false, 'Menu'=>false, 'MetaTags'=>false, 'Breadcrumbs'=>false, 'current_stage'=>Versioned::current_stage(), 'SilverStripeNavigator'=>false ); //Allow extensions to add onto the array $extensions=$this->extend('updatePreviewFieldMap'); $extensions=array_filter($extensions, function($v) {return !is_null($v) && is_array($v);}); if(count($extensions)>0) { foreach($extensions as $ext) { $previewFieldMap=array_merge($previewFieldMap, $ext); } } //Find the controller class $ancestry=ClassInfo::ancestry($this->DestinationClass); while($class=array_pop($ancestry)) { if(class_exists($class."_Controller")) { break; } } $controller=($class!==null ? "{$class}_Controller":"ContentController"); return $controller::create($this)->customise($previewFieldMap); }
[ "public", "function", "renderPreview", "(", ")", "{", "$", "previewFieldMap", "=", "array", "(", "'ClassName'", "=>", "$", "this", "->", "DestinationClass", ",", "'IsKapostPreview'", "=>", "true", ",", "'Children'", "=>", "false", ",", "'Menu'", "=>", "false", ",", "'MetaTags'", "=>", "false", ",", "'Breadcrumbs'", "=>", "false", ",", "'current_stage'", "=>", "Versioned", "::", "current_stage", "(", ")", ",", "'SilverStripeNavigator'", "=>", "false", ")", ";", "//Allow extensions to add onto the array", "$", "extensions", "=", "$", "this", "->", "extend", "(", "'updatePreviewFieldMap'", ")", ";", "$", "extensions", "=", "array_filter", "(", "$", "extensions", ",", "function", "(", "$", "v", ")", "{", "return", "!", "is_null", "(", "$", "v", ")", "&&", "is_array", "(", "$", "v", ")", ";", "}", ")", ";", "if", "(", "count", "(", "$", "extensions", ")", ">", "0", ")", "{", "foreach", "(", "$", "extensions", "as", "$", "ext", ")", "{", "$", "previewFieldMap", "=", "array_merge", "(", "$", "previewFieldMap", ",", "$", "ext", ")", ";", "}", "}", "//Find the controller class", "$", "ancestry", "=", "ClassInfo", "::", "ancestry", "(", "$", "this", "->", "DestinationClass", ")", ";", "while", "(", "$", "class", "=", "array_pop", "(", "$", "ancestry", ")", ")", "{", "if", "(", "class_exists", "(", "$", "class", ".", "\"_Controller\"", ")", ")", "{", "break", ";", "}", "}", "$", "controller", "=", "(", "$", "class", "!==", "null", "?", "\"{$class}_Controller\"", ":", "\"ContentController\"", ")", ";", "return", "$", "controller", "::", "create", "(", "$", "this", ")", "->", "customise", "(", "$", "previewFieldMap", ")", ";", "}" ]
Handles rendering of the preview for this object @return string Preview to be rendered
[ "Handles", "rendering", "of", "the", "preview", "for", "this", "object" ]
718f498cad0eec764d19c9081404b2a0c8f44d71
https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/model/KapostPage.php#L84-L117
236,636
rinvex/renamed-tags
src/Models/Tag.php
Tag.findByName
public static function findByName($tags, string $group = null, string $locale = null): Collection { $locale = $locale ?? app()->getLocale(); return collect(Taggable::parseDelimitedTags($tags))->map(function (string $tag) use ($group, $locale) { return ($exists = static::firstByName($tag, $group, $locale)) ? $exists->getKey() : null; })->filter()->unique(); }
php
public static function findByName($tags, string $group = null, string $locale = null): Collection { $locale = $locale ?? app()->getLocale(); return collect(Taggable::parseDelimitedTags($tags))->map(function (string $tag) use ($group, $locale) { return ($exists = static::firstByName($tag, $group, $locale)) ? $exists->getKey() : null; })->filter()->unique(); }
[ "public", "static", "function", "findByName", "(", "$", "tags", ",", "string", "$", "group", "=", "null", ",", "string", "$", "locale", "=", "null", ")", ":", "Collection", "{", "$", "locale", "=", "$", "locale", "??", "app", "(", ")", "->", "getLocale", "(", ")", ";", "return", "collect", "(", "Taggable", "::", "parseDelimitedTags", "(", "$", "tags", ")", ")", "->", "map", "(", "function", "(", "string", "$", "tag", ")", "use", "(", "$", "group", ",", "$", "locale", ")", "{", "return", "(", "$", "exists", "=", "static", "::", "firstByName", "(", "$", "tag", ",", "$", "group", ",", "$", "locale", ")", ")", "?", "$", "exists", "->", "getKey", "(", ")", ":", "null", ";", "}", ")", "->", "filter", "(", ")", "->", "unique", "(", ")", ";", "}" ]
Find tag by name. @param mixed $tags @param string|null $group @param string|null $locale @return \Illuminate\Support\Collection
[ "Find", "tag", "by", "name", "." ]
b7f0a9758236da057ceaf1b30748646503399c89
https://github.com/rinvex/renamed-tags/blob/b7f0a9758236da057ceaf1b30748646503399c89/src/Models/Tag.php#L199-L206
236,637
rinvex/renamed-tags
src/Models/Tag.php
Tag.firstByName
public static function firstByName(string $tag, string $group = null, string $locale = null) { $locale = $locale ?? app()->getLocale(); return static::query()->where("name->{$locale}", $tag)->when($group, function (Builder $builder) use ($group) { return $builder->where('group', $group); })->first(); }
php
public static function firstByName(string $tag, string $group = null, string $locale = null) { $locale = $locale ?? app()->getLocale(); return static::query()->where("name->{$locale}", $tag)->when($group, function (Builder $builder) use ($group) { return $builder->where('group', $group); })->first(); }
[ "public", "static", "function", "firstByName", "(", "string", "$", "tag", ",", "string", "$", "group", "=", "null", ",", "string", "$", "locale", "=", "null", ")", "{", "$", "locale", "=", "$", "locale", "??", "app", "(", ")", "->", "getLocale", "(", ")", ";", "return", "static", "::", "query", "(", ")", "->", "where", "(", "\"name->{$locale}\"", ",", "$", "tag", ")", "->", "when", "(", "$", "group", ",", "function", "(", "Builder", "$", "builder", ")", "use", "(", "$", "group", ")", "{", "return", "$", "builder", "->", "where", "(", "'group'", ",", "$", "group", ")", ";", "}", ")", "->", "first", "(", ")", ";", "}" ]
Get first tag by name. @param string $tag @param string|null $group @param string|null $locale @return static|null
[ "Get", "first", "tag", "by", "name", "." ]
b7f0a9758236da057ceaf1b30748646503399c89
https://github.com/rinvex/renamed-tags/blob/b7f0a9758236da057ceaf1b30748646503399c89/src/Models/Tag.php#L217-L224
236,638
lukaszmakuch/haringo
src/BuildingStrategy/Impl/BuildingStrategyTpl.php
BuildingStrategyTpl.findMatchingMethods
protected function findMatchingMethods( \ReflectionClass $reflectedClass, MethodSelector $selector ) { try { return $this->findMatchingMethodsImpl($reflectedClass, $selector); } catch (UnsupportedMatcher $e) { throw new UnableToBuild(); } }
php
protected function findMatchingMethods( \ReflectionClass $reflectedClass, MethodSelector $selector ) { try { return $this->findMatchingMethodsImpl($reflectedClass, $selector); } catch (UnsupportedMatcher $e) { throw new UnableToBuild(); } }
[ "protected", "function", "findMatchingMethods", "(", "\\", "ReflectionClass", "$", "reflectedClass", ",", "MethodSelector", "$", "selector", ")", "{", "try", "{", "return", "$", "this", "->", "findMatchingMethodsImpl", "(", "$", "reflectedClass", ",", "$", "selector", ")", ";", "}", "catch", "(", "UnsupportedMatcher", "$", "e", ")", "{", "throw", "new", "UnableToBuild", "(", ")", ";", "}", "}" ]
Finds all methods matching the given selector. @return ReflectionMethod[] @throws UnableToBuild
[ "Finds", "all", "methods", "matching", "the", "given", "selector", "." ]
7a2ff30f4e7b215b2573a9562ed449f6495d303d
https://github.com/lukaszmakuch/haringo/blob/7a2ff30f4e7b215b2573a9562ed449f6495d303d/src/BuildingStrategy/Impl/BuildingStrategyTpl.php#L113-L122
236,639
dlevacher/php-git-hg-repo
lib/PHPHg/Configuration.php
Configuration.computeCredentialsName
protected function computeCredentialsName($prefix = null) { if (!$prefix) { $paths = $this->get('paths'); if ($paths && isset($paths['default'])) { $prefix = $paths['default']; } } preg_match('/([http:\/\/|https:\/\/|ssh:\/\/])*(\w@)*([\w\.\-_]{1,}+)/', $prefix, $prefix); if (count($prefix)) return end($prefix); return basename($this->repository->getDir()); }
php
protected function computeCredentialsName($prefix = null) { if (!$prefix) { $paths = $this->get('paths'); if ($paths && isset($paths['default'])) { $prefix = $paths['default']; } } preg_match('/([http:\/\/|https:\/\/|ssh:\/\/])*(\w@)*([\w\.\-_]{1,}+)/', $prefix, $prefix); if (count($prefix)) return end($prefix); return basename($this->repository->getDir()); }
[ "protected", "function", "computeCredentialsName", "(", "$", "prefix", "=", "null", ")", "{", "if", "(", "!", "$", "prefix", ")", "{", "$", "paths", "=", "$", "this", "->", "get", "(", "'paths'", ")", ";", "if", "(", "$", "paths", "&&", "isset", "(", "$", "paths", "[", "'default'", "]", ")", ")", "{", "$", "prefix", "=", "$", "paths", "[", "'default'", "]", ";", "}", "}", "preg_match", "(", "'/([http:\\/\\/|https:\\/\\/|ssh:\\/\\/])*(\\w@)*([\\w\\.\\-_]{1,}+)/'", ",", "$", "prefix", ",", "$", "prefix", ")", ";", "if", "(", "count", "(", "$", "prefix", ")", ")", "return", "end", "(", "$", "prefix", ")", ";", "return", "basename", "(", "$", "this", "->", "repository", "->", "getDir", "(", ")", ")", ";", "}" ]
Compute the repository credentials name @return string
[ "Compute", "the", "repository", "credentials", "name" ]
415cb600cc8a8cba8817c92c9d6bc4e02f2d7535
https://github.com/dlevacher/php-git-hg-repo/blob/415cb600cc8a8cba8817c92c9d6bc4e02f2d7535/lib/PHPHg/Configuration.php#L63-L73
236,640
dlevacher/php-git-hg-repo
lib/PHPHg/Configuration.php
Configuration.rm
protected function rm($configOption) { if (isset($this->configuration[$configOption])) unset($this->configuration[$configOption]); return $this; }
php
protected function rm($configOption) { if (isset($this->configuration[$configOption])) unset($this->configuration[$configOption]); return $this; }
[ "protected", "function", "rm", "(", "$", "configOption", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "configuration", "[", "$", "configOption", "]", ")", ")", "unset", "(", "$", "this", "->", "configuration", "[", "$", "configOption", "]", ")", ";", "return", "$", "this", ";", "}" ]
Remove a config option @param string $configOption The config option to write @return Configuration
[ "Remove", "a", "config", "option" ]
415cb600cc8a8cba8817c92c9d6bc4e02f2d7535
https://github.com/dlevacher/php-git-hg-repo/blob/415cb600cc8a8cba8817c92c9d6bc4e02f2d7535/lib/PHPHg/Configuration.php#L106-L110
236,641
dlevacher/php-git-hg-repo
lib/PHPHg/Configuration.php
Configuration.save
protected function save() { // write contents modify in hgrc if ($fileConfig = @fopen($this->repository->getDir() . $this->repository->getFileConfig() . "hgrc", 'w+')) { $ret = fwrite($fileConfig, $this->arr2ini($this->configuration)); fclose($fileConfig); return $ret; } return false; }
php
protected function save() { // write contents modify in hgrc if ($fileConfig = @fopen($this->repository->getDir() . $this->repository->getFileConfig() . "hgrc", 'w+')) { $ret = fwrite($fileConfig, $this->arr2ini($this->configuration)); fclose($fileConfig); return $ret; } return false; }
[ "protected", "function", "save", "(", ")", "{", "// write contents modify in hgrc", "if", "(", "$", "fileConfig", "=", "@", "fopen", "(", "$", "this", "->", "repository", "->", "getDir", "(", ")", ".", "$", "this", "->", "repository", "->", "getFileConfig", "(", ")", ".", "\"hgrc\"", ",", "'w+'", ")", ")", "{", "$", "ret", "=", "fwrite", "(", "$", "fileConfig", ",", "$", "this", "->", "arr2ini", "(", "$", "this", "->", "configuration", ")", ")", ";", "fclose", "(", "$", "fileConfig", ")", ";", "return", "$", "ret", ";", "}", "return", "false", ";", "}" ]
Save the config to file @return boolean
[ "Save", "the", "config", "to", "file" ]
415cb600cc8a8cba8817c92c9d6bc4e02f2d7535
https://github.com/dlevacher/php-git-hg-repo/blob/415cb600cc8a8cba8817c92c9d6bc4e02f2d7535/lib/PHPHg/Configuration.php#L117-L125
236,642
bytic/translation
src/TranslatorServiceProvider.php
TranslatorServiceProvider.registerTranslator
protected function registerTranslator() { $this->getContainer() ->share('translator', function () { $translator = new Translator('en'); $translator->addLoader('php', new PhpFileLoader()); return $translator; }); }
php
protected function registerTranslator() { $this->getContainer() ->share('translator', function () { $translator = new Translator('en'); $translator->addLoader('php', new PhpFileLoader()); return $translator; }); }
[ "protected", "function", "registerTranslator", "(", ")", "{", "$", "this", "->", "getContainer", "(", ")", "->", "share", "(", "'translator'", ",", "function", "(", ")", "{", "$", "translator", "=", "new", "Translator", "(", "'en'", ")", ";", "$", "translator", "->", "addLoader", "(", "'php'", ",", "new", "PhpFileLoader", "(", ")", ")", ";", "return", "$", "translator", ";", "}", ")", ";", "}" ]
Register the session manager instance. @return void
[ "Register", "the", "session", "manager", "instance", "." ]
974e57099d901126c4117010f4a269fe1f80b651
https://github.com/bytic/translation/blob/974e57099d901126c4117010f4a269fe1f80b651/src/TranslatorServiceProvider.php#L44-L52
236,643
koriym/Any.Serializer
src/Any/Serializer/Serializer.php
Serializer.removeUnrealizableInArray
private function removeUnrealizableInArray(array &$array) { $this->removeReferenceItemInArray($array); foreach ($array as &$value) { if (is_object($value)) { $value = $this->removeUnserializable($value); } if (is_array($value)) { $this->removeUnrealizableInArray($value); } if ($this->isUnserializable($value)) { $value = null; } } return $array; }
php
private function removeUnrealizableInArray(array &$array) { $this->removeReferenceItemInArray($array); foreach ($array as &$value) { if (is_object($value)) { $value = $this->removeUnserializable($value); } if (is_array($value)) { $this->removeUnrealizableInArray($value); } if ($this->isUnserializable($value)) { $value = null; } } return $array; }
[ "private", "function", "removeUnrealizableInArray", "(", "array", "&", "$", "array", ")", "{", "$", "this", "->", "removeReferenceItemInArray", "(", "$", "array", ")", ";", "foreach", "(", "$", "array", "as", "&", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "removeUnserializable", "(", "$", "value", ")", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "this", "->", "removeUnrealizableInArray", "(", "$", "value", ")", ";", "}", "if", "(", "$", "this", "->", "isUnserializable", "(", "$", "value", ")", ")", "{", "$", "value", "=", "null", ";", "}", "}", "return", "$", "array", ";", "}" ]
remove Unrealizable In Array @param array &$array @return array
[ "remove", "Unrealizable", "In", "Array" ]
06426462fbcbd8c824206390959e30f54da58392
https://github.com/koriym/Any.Serializer/blob/06426462fbcbd8c824206390959e30f54da58392/src/Any/Serializer/Serializer.php#L89-L105
236,644
koriym/Any.Serializer
src/Any/Serializer/Serializer.php
Serializer.removeReferenceItemInArray
private function removeReferenceItemInArray(array &$room) { $roomCopy = $room; $keys = array_keys($room); foreach ($keys as $key) { if (is_array($roomCopy[$key])) { $roomCopy[$key]['_test'] = true; if (isset($room[$key]['_test'])) { // It's a reference unset($room[$key]); } } } }
php
private function removeReferenceItemInArray(array &$room) { $roomCopy = $room; $keys = array_keys($room); foreach ($keys as $key) { if (is_array($roomCopy[$key])) { $roomCopy[$key]['_test'] = true; if (isset($room[$key]['_test'])) { // It's a reference unset($room[$key]); } } } }
[ "private", "function", "removeReferenceItemInArray", "(", "array", "&", "$", "room", ")", "{", "$", "roomCopy", "=", "$", "room", ";", "$", "keys", "=", "array_keys", "(", "$", "room", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "is_array", "(", "$", "roomCopy", "[", "$", "key", "]", ")", ")", "{", "$", "roomCopy", "[", "$", "key", "]", "[", "'_test'", "]", "=", "true", ";", "if", "(", "isset", "(", "$", "room", "[", "$", "key", "]", "[", "'_test'", "]", ")", ")", "{", "// It's a reference", "unset", "(", "$", "room", "[", "$", "key", "]", ")", ";", "}", "}", "}", "}" ]
Remove reference item in array @param array &$room @return void @see http://stackoverflow.com/questions/3148125/php-check-if-object-array-is-a-reference @author Chris Smith (original source)
[ "Remove", "reference", "item", "in", "array" ]
06426462fbcbd8c824206390959e30f54da58392
https://github.com/koriym/Any.Serializer/blob/06426462fbcbd8c824206390959e30f54da58392/src/Any/Serializer/Serializer.php#L117-L130
236,645
janschumann/drupal-dic
src/Drupal/Dic/DicHelper.php
DicHelper.setBundleInfo
public function setBundleInfo(array $bundleInfo) { $this->kernel->setDrupalBundles($this->getAutoloadedBundles($bundleInfo)); $this->bundlesBooted = false; }
php
public function setBundleInfo(array $bundleInfo) { $this->kernel->setDrupalBundles($this->getAutoloadedBundles($bundleInfo)); $this->bundlesBooted = false; }
[ "public", "function", "setBundleInfo", "(", "array", "$", "bundleInfo", ")", "{", "$", "this", "->", "kernel", "->", "setDrupalBundles", "(", "$", "this", "->", "getAutoloadedBundles", "(", "$", "bundleInfo", ")", ")", ";", "$", "this", "->", "bundlesBooted", "=", "false", ";", "}" ]
Set bundle info @param array $bundleInfo
[ "Set", "bundle", "info" ]
d5e70088708432b30a6c21f3e4541660da016d9b
https://github.com/janschumann/drupal-dic/blob/d5e70088708432b30a6c21f3e4541660da016d9b/src/Drupal/Dic/DicHelper.php#L60-L63
236,646
janschumann/drupal-dic
src/Drupal/Dic/DicHelper.php
DicHelper.getContainer
public function getContainer() { // kernel will only boot if necessary $this->kernel->boot(); // boot bundles if necessary if (!$this->bundlesBooted) { foreach ($this->kernel->getBundles() as $bundle) { $bundle->boot(); } $this->bundlesBooted = true; } return $this->kernel->getContainer(); }
php
public function getContainer() { // kernel will only boot if necessary $this->kernel->boot(); // boot bundles if necessary if (!$this->bundlesBooted) { foreach ($this->kernel->getBundles() as $bundle) { $bundle->boot(); } $this->bundlesBooted = true; } return $this->kernel->getContainer(); }
[ "public", "function", "getContainer", "(", ")", "{", "// kernel will only boot if necessary", "$", "this", "->", "kernel", "->", "boot", "(", ")", ";", "// boot bundles if necessary", "if", "(", "!", "$", "this", "->", "bundlesBooted", ")", "{", "foreach", "(", "$", "this", "->", "kernel", "->", "getBundles", "(", ")", "as", "$", "bundle", ")", "{", "$", "bundle", "->", "boot", "(", ")", ";", "}", "$", "this", "->", "bundlesBooted", "=", "true", ";", "}", "return", "$", "this", "->", "kernel", "->", "getContainer", "(", ")", ";", "}" ]
Retrieves the container @return ContainerInterface
[ "Retrieves", "the", "container" ]
d5e70088708432b30a6c21f3e4541660da016d9b
https://github.com/janschumann/drupal-dic/blob/d5e70088708432b30a6c21f3e4541660da016d9b/src/Drupal/Dic/DicHelper.php#L70-L83
236,647
janschumann/drupal-dic
src/Drupal/Dic/DicHelper.php
DicHelper.flushCaches
public function flushCaches($all = false) { $dir = $this->kernel->getCacheDir(); if ($all) { $dir .= '/..'; } $fs = new Filesystem(); $fs->remove(realpath($dir)); }
php
public function flushCaches($all = false) { $dir = $this->kernel->getCacheDir(); if ($all) { $dir .= '/..'; } $fs = new Filesystem(); $fs->remove(realpath($dir)); }
[ "public", "function", "flushCaches", "(", "$", "all", "=", "false", ")", "{", "$", "dir", "=", "$", "this", "->", "kernel", "->", "getCacheDir", "(", ")", ";", "if", "(", "$", "all", ")", "{", "$", "dir", ".=", "'/..'", ";", "}", "$", "fs", "=", "new", "Filesystem", "(", ")", ";", "$", "fs", "->", "remove", "(", "realpath", "(", "$", "dir", ")", ")", ";", "}" ]
Cleanup cache files
[ "Cleanup", "cache", "files" ]
d5e70088708432b30a6c21f3e4541660da016d9b
https://github.com/janschumann/drupal-dic/blob/d5e70088708432b30a6c21f3e4541660da016d9b/src/Drupal/Dic/DicHelper.php#L88-L95
236,648
cyberspectrum/i18n
src/JobBuilder/CopyJobBuilder.php
CopyJobBuilder.copyStringToFlag
private function copyStringToFlag($value): int { switch (true) { case 'true' === $value: case true === $value: case 'yes' === $value: return CopyDictionaryJob::COPY; case 'no' === $value: case 'false' === $value: case false === $value: return CopyDictionaryJob::DO_NOT_COPY; case 'if-empty' === $value: return CopyDictionaryJob::COPY_IF_EMPTY; default: throw new \InvalidArgumentException('Invalid value for copy flag.'); } }
php
private function copyStringToFlag($value): int { switch (true) { case 'true' === $value: case true === $value: case 'yes' === $value: return CopyDictionaryJob::COPY; case 'no' === $value: case 'false' === $value: case false === $value: return CopyDictionaryJob::DO_NOT_COPY; case 'if-empty' === $value: return CopyDictionaryJob::COPY_IF_EMPTY; default: throw new \InvalidArgumentException('Invalid value for copy flag.'); } }
[ "private", "function", "copyStringToFlag", "(", "$", "value", ")", ":", "int", "{", "switch", "(", "true", ")", "{", "case", "'true'", "===", "$", "value", ":", "case", "true", "===", "$", "value", ":", "case", "'yes'", "===", "$", "value", ":", "return", "CopyDictionaryJob", "::", "COPY", ";", "case", "'no'", "===", "$", "value", ":", "case", "'false'", "===", "$", "value", ":", "case", "false", "===", "$", "value", ":", "return", "CopyDictionaryJob", "::", "DO_NOT_COPY", ";", "case", "'if-empty'", "===", "$", "value", ":", "return", "CopyDictionaryJob", "::", "COPY_IF_EMPTY", ";", "default", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid value for copy flag.'", ")", ";", "}", "}" ]
Convert the passed value to a copy flag. @param string|bool|null $value The value. @return int @throws \InvalidArgumentException When the value can not be converted.
[ "Convert", "the", "passed", "value", "to", "a", "copy", "flag", "." ]
138e81d7119db82c2420bd33967a566e02b1d2f5
https://github.com/cyberspectrum/i18n/blob/138e81d7119db82c2420bd33967a566e02b1d2f5/src/JobBuilder/CopyJobBuilder.php#L89-L105
236,649
cyberspectrum/i18n
src/JobBuilder/CopyJobBuilder.php
CopyJobBuilder.boolishToFlag
private function boolishToFlag($value): bool { switch (true) { case 'true' === $value: case true === $value: case 'yes' === $value: return true; case 'no' === $value: case 'false' === $value: case false === $value: return false; default: throw new \InvalidArgumentException('Invalid value for remove-obsolete flag.'); } }
php
private function boolishToFlag($value): bool { switch (true) { case 'true' === $value: case true === $value: case 'yes' === $value: return true; case 'no' === $value: case 'false' === $value: case false === $value: return false; default: throw new \InvalidArgumentException('Invalid value for remove-obsolete flag.'); } }
[ "private", "function", "boolishToFlag", "(", "$", "value", ")", ":", "bool", "{", "switch", "(", "true", ")", "{", "case", "'true'", "===", "$", "value", ":", "case", "true", "===", "$", "value", ":", "case", "'yes'", "===", "$", "value", ":", "return", "true", ";", "case", "'no'", "===", "$", "value", ":", "case", "'false'", "===", "$", "value", ":", "case", "false", "===", "$", "value", ":", "return", "false", ";", "default", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid value for remove-obsolete flag.'", ")", ";", "}", "}" ]
Convert the passed value to a bool. @param string|bool|null $value The value. @return bool @throws \InvalidArgumentException When the value can not be converted.
[ "Convert", "the", "passed", "value", "to", "a", "bool", "." ]
138e81d7119db82c2420bd33967a566e02b1d2f5
https://github.com/cyberspectrum/i18n/blob/138e81d7119db82c2420bd33967a566e02b1d2f5/src/JobBuilder/CopyJobBuilder.php#L116-L130
236,650
AnonymPHP/Anonym-Library
src/Anonym/Security/Authentication/Guard.php
Guard.isLogined
public function isLogined() { $session = $this->getSession(); $cookie = $this->getCookie(); if ($cookie->has(self::USER_SESSION)) { $login = $cookie->get(self::USER_SESSION); $login = unserialize(base64_decode($login)); }elseif (false !== $session->has(self::USER_SESSION)) { $login = $session->get(self::USER_SESSION); }else{ return false; } return $this->isSameIp($login); }
php
public function isLogined() { $session = $this->getSession(); $cookie = $this->getCookie(); if ($cookie->has(self::USER_SESSION)) { $login = $cookie->get(self::USER_SESSION); $login = unserialize(base64_decode($login)); }elseif (false !== $session->has(self::USER_SESSION)) { $login = $session->get(self::USER_SESSION); }else{ return false; } return $this->isSameIp($login); }
[ "public", "function", "isLogined", "(", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "cookie", "=", "$", "this", "->", "getCookie", "(", ")", ";", "if", "(", "$", "cookie", "->", "has", "(", "self", "::", "USER_SESSION", ")", ")", "{", "$", "login", "=", "$", "cookie", "->", "get", "(", "self", "::", "USER_SESSION", ")", ";", "$", "login", "=", "unserialize", "(", "base64_decode", "(", "$", "login", ")", ")", ";", "}", "elseif", "(", "false", "!==", "$", "session", "->", "has", "(", "self", "::", "USER_SESSION", ")", ")", "{", "$", "login", "=", "$", "session", "->", "get", "(", "self", "::", "USER_SESSION", ")", ";", "}", "else", "{", "return", "false", ";", "}", "return", "$", "this", "->", "isSameIp", "(", "$", "login", ")", ";", "}" ]
check is login usered @return bool
[ "check", "is", "login", "usered" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Security/Authentication/Guard.php#L36-L51
236,651
AnonymPHP/Anonym-Library
src/Anonym/Security/Authentication/Guard.php
Guard.hasRole
public function hasRole($role = ''){ $session = $this->getSession(); $cookie = $this->getCookie(); if ($cookie->has(self::USER_SESSION)) { $login = $cookie->get(self::USER_SESSION); }elseif (false !== $session->has(self::USER_SESSION)) { $login = $session->get(self::USER_SESSION); }else{ return false; } $roleLogin = $login['role']; if (is_string($role)) { return $roleLogin === $role; }elseif(is_array($role)){ return array_search($roleLogin, $role); } return false; }
php
public function hasRole($role = ''){ $session = $this->getSession(); $cookie = $this->getCookie(); if ($cookie->has(self::USER_SESSION)) { $login = $cookie->get(self::USER_SESSION); }elseif (false !== $session->has(self::USER_SESSION)) { $login = $session->get(self::USER_SESSION); }else{ return false; } $roleLogin = $login['role']; if (is_string($role)) { return $roleLogin === $role; }elseif(is_array($role)){ return array_search($roleLogin, $role); } return false; }
[ "public", "function", "hasRole", "(", "$", "role", "=", "''", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "cookie", "=", "$", "this", "->", "getCookie", "(", ")", ";", "if", "(", "$", "cookie", "->", "has", "(", "self", "::", "USER_SESSION", ")", ")", "{", "$", "login", "=", "$", "cookie", "->", "get", "(", "self", "::", "USER_SESSION", ")", ";", "}", "elseif", "(", "false", "!==", "$", "session", "->", "has", "(", "self", "::", "USER_SESSION", ")", ")", "{", "$", "login", "=", "$", "session", "->", "get", "(", "self", "::", "USER_SESSION", ")", ";", "}", "else", "{", "return", "false", ";", "}", "$", "roleLogin", "=", "$", "login", "[", "'role'", "]", ";", "if", "(", "is_string", "(", "$", "role", ")", ")", "{", "return", "$", "roleLogin", "===", "$", "role", ";", "}", "elseif", "(", "is_array", "(", "$", "role", ")", ")", "{", "return", "array_search", "(", "$", "roleLogin", ",", "$", "role", ")", ";", "}", "return", "false", ";", "}" ]
check the user role @param string|int $role @return bool
[ "check", "the", "user", "role" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Security/Authentication/Guard.php#L74-L97
236,652
nubs/sensible
src/Pager.php
Pager.viewFile
public function viewFile(ProcessBuilder $processBuilder, $filePath) { $proc = $processBuilder->setPrefix($this->_pagerCommand)->setArguments([$filePath])->getProcess(); $proc->setTty(true)->run(); return $proc; }
php
public function viewFile(ProcessBuilder $processBuilder, $filePath) { $proc = $processBuilder->setPrefix($this->_pagerCommand)->setArguments([$filePath])->getProcess(); $proc->setTty(true)->run(); return $proc; }
[ "public", "function", "viewFile", "(", "ProcessBuilder", "$", "processBuilder", ",", "$", "filePath", ")", "{", "$", "proc", "=", "$", "processBuilder", "->", "setPrefix", "(", "$", "this", "->", "_pagerCommand", ")", "->", "setArguments", "(", "[", "$", "filePath", "]", ")", "->", "getProcess", "(", ")", ";", "$", "proc", "->", "setTty", "(", "true", ")", "->", "run", "(", ")", ";", "return", "$", "proc", ";", "}" ]
View the given file using the symfony process builder to build the symfony process to execute. @api @param \Symfony\Component\Process\ProcessBuilder $processBuilder The process builder. @param string $filePath The path to the file to view. @return \Symfony\Component\Process\Process The already-executed process.
[ "View", "the", "given", "file", "using", "the", "symfony", "process", "builder", "to", "build", "the", "symfony", "process", "to", "execute", "." ]
d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7
https://github.com/nubs/sensible/blob/d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7/src/Pager.php#L35-L41
236,653
nubs/sensible
src/Pager.php
Pager.viewData
public function viewData(ProcessBuilder $processBuilder, $data) { $proc = $processBuilder->setPrefix($this->_pagerCommand)->setInput($data)->getProcess(); $proc->setTty(true)->run(); return $proc; }
php
public function viewData(ProcessBuilder $processBuilder, $data) { $proc = $processBuilder->setPrefix($this->_pagerCommand)->setInput($data)->getProcess(); $proc->setTty(true)->run(); return $proc; }
[ "public", "function", "viewData", "(", "ProcessBuilder", "$", "processBuilder", ",", "$", "data", ")", "{", "$", "proc", "=", "$", "processBuilder", "->", "setPrefix", "(", "$", "this", "->", "_pagerCommand", ")", "->", "setInput", "(", "$", "data", ")", "->", "getProcess", "(", ")", ";", "$", "proc", "->", "setTty", "(", "true", ")", "->", "run", "(", ")", ";", "return", "$", "proc", ";", "}" ]
View the given data using the symfony process builder to build the symfony process to execute. @api @param \Symfony\Component\Process\ProcessBuilder $processBuilder The process builder. @param string $data The data to view. @return \Symfony\Component\Process\Process The already-executed process.
[ "View", "the", "given", "data", "using", "the", "symfony", "process", "builder", "to", "build", "the", "symfony", "process", "to", "execute", "." ]
d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7
https://github.com/nubs/sensible/blob/d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7/src/Pager.php#L53-L59
236,654
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.pollFeed
public function pollFeed($url) { $self = $this; $eventEmitter = $this->getEventEmitter(); $logger = $this->getLogger(); $logger->info('Sending request for feed URL', array('url' => $url)); $request = new HttpRequest(array( 'url' => $url, 'resolveCallback' => function($data) use ($url, $self) { $self->processFeed($url, $data); }, 'rejectCallback' => function($error) use ($url, $self) { $self->processFailure($url, $error); } )); $eventEmitter->emit('http.request', array($request)); }
php
public function pollFeed($url) { $self = $this; $eventEmitter = $this->getEventEmitter(); $logger = $this->getLogger(); $logger->info('Sending request for feed URL', array('url' => $url)); $request = new HttpRequest(array( 'url' => $url, 'resolveCallback' => function($data) use ($url, $self) { $self->processFeed($url, $data); }, 'rejectCallback' => function($error) use ($url, $self) { $self->processFailure($url, $error); } )); $eventEmitter->emit('http.request', array($request)); }
[ "public", "function", "pollFeed", "(", "$", "url", ")", "{", "$", "self", "=", "$", "this", ";", "$", "eventEmitter", "=", "$", "this", "->", "getEventEmitter", "(", ")", ";", "$", "logger", "=", "$", "this", "->", "getLogger", "(", ")", ";", "$", "logger", "->", "info", "(", "'Sending request for feed URL'", ",", "array", "(", "'url'", "=>", "$", "url", ")", ")", ";", "$", "request", "=", "new", "HttpRequest", "(", "array", "(", "'url'", "=>", "$", "url", ",", "'resolveCallback'", "=>", "function", "(", "$", "data", ")", "use", "(", "$", "url", ",", "$", "self", ")", "{", "$", "self", "->", "processFeed", "(", "$", "url", ",", "$", "data", ")", ";", "}", ",", "'rejectCallback'", "=>", "function", "(", "$", "error", ")", "use", "(", "$", "url", ",", "$", "self", ")", "{", "$", "self", "->", "processFailure", "(", "$", "url", ",", "$", "error", ")", ";", "}", ")", ")", ";", "$", "eventEmitter", "->", "emit", "(", "'http.request'", ",", "array", "(", "$", "request", ")", ")", ";", "}" ]
Polls an individual feed for new content to syndicate to channels or users. This method is public so that queuePoll() can invoke it as a callback. It should not be invoked outside of this class. @param string $url Feed URL
[ "Polls", "an", "individual", "feed", "for", "new", "content", "to", "syndicate", "to", "channels", "or", "users", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L180-L196
236,655
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.processFeed
public function processFeed($url, $data) { $logger = $this->getLogger(); $logger->info('Processing feed', array('url' => $url)); $logger->debug('Received feed data', array('data' => $data)); try { $new = iterator_to_array(FeedReader::importString($data)); $old = isset($this->cache[$url]) ? $this->cache[$url] : array(); $diff = $this->getNewFeedItems($new, $old); if ($old) { $this->syndicateFeedItems($diff); } $this->cache[$url] = $new; } catch (\Exception $e) { $logger->warning( 'Failed to process feed', array( 'url' => $url, 'data' => $data, 'error' => $e, ) ); } $this->queuePoll($url); }
php
public function processFeed($url, $data) { $logger = $this->getLogger(); $logger->info('Processing feed', array('url' => $url)); $logger->debug('Received feed data', array('data' => $data)); try { $new = iterator_to_array(FeedReader::importString($data)); $old = isset($this->cache[$url]) ? $this->cache[$url] : array(); $diff = $this->getNewFeedItems($new, $old); if ($old) { $this->syndicateFeedItems($diff); } $this->cache[$url] = $new; } catch (\Exception $e) { $logger->warning( 'Failed to process feed', array( 'url' => $url, 'data' => $data, 'error' => $e, ) ); } $this->queuePoll($url); }
[ "public", "function", "processFeed", "(", "$", "url", ",", "$", "data", ")", "{", "$", "logger", "=", "$", "this", "->", "getLogger", "(", ")", ";", "$", "logger", "->", "info", "(", "'Processing feed'", ",", "array", "(", "'url'", "=>", "$", "url", ")", ")", ";", "$", "logger", "->", "debug", "(", "'Received feed data'", ",", "array", "(", "'data'", "=>", "$", "data", ")", ")", ";", "try", "{", "$", "new", "=", "iterator_to_array", "(", "FeedReader", "::", "importString", "(", "$", "data", ")", ")", ";", "$", "old", "=", "isset", "(", "$", "this", "->", "cache", "[", "$", "url", "]", ")", "?", "$", "this", "->", "cache", "[", "$", "url", "]", ":", "array", "(", ")", ";", "$", "diff", "=", "$", "this", "->", "getNewFeedItems", "(", "$", "new", ",", "$", "old", ")", ";", "if", "(", "$", "old", ")", "{", "$", "this", "->", "syndicateFeedItems", "(", "$", "diff", ")", ";", "}", "$", "this", "->", "cache", "[", "$", "url", "]", "=", "$", "new", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "logger", "->", "warning", "(", "'Failed to process feed'", ",", "array", "(", "'url'", "=>", "$", "url", ",", "'data'", "=>", "$", "data", ",", "'error'", "=>", "$", "e", ",", ")", ")", ";", "}", "$", "this", "->", "queuePoll", "(", "$", "url", ")", ";", "}" ]
Processes content from successfully polled feeds. @param string $url URL of the polled feed @param string $data Content received from the feed poll
[ "Processes", "content", "from", "successfully", "polled", "feeds", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L204-L230
236,656
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.getNewFeedItems
protected function getNewFeedItems(array $new, array $old) { $map = array(); $getKey = function($item) { return $item->getPermalink(); }; $logger = $this->getLogger(); foreach ($new as $item) { $key = $getKey($item); $logger->debug('New: ' . $key); $map[$key] = $item; } foreach ($old as $item) { $key = $getKey($item); $logger->debug('Old: ' . $key); unset($map[$key]); } $logger->debug('Diff: ' . implode(' ', array_keys($map))); return array_values($map); }
php
protected function getNewFeedItems(array $new, array $old) { $map = array(); $getKey = function($item) { return $item->getPermalink(); }; $logger = $this->getLogger(); foreach ($new as $item) { $key = $getKey($item); $logger->debug('New: ' . $key); $map[$key] = $item; } foreach ($old as $item) { $key = $getKey($item); $logger->debug('Old: ' . $key); unset($map[$key]); } $logger->debug('Diff: ' . implode(' ', array_keys($map))); return array_values($map); }
[ "protected", "function", "getNewFeedItems", "(", "array", "$", "new", ",", "array", "$", "old", ")", "{", "$", "map", "=", "array", "(", ")", ";", "$", "getKey", "=", "function", "(", "$", "item", ")", "{", "return", "$", "item", "->", "getPermalink", "(", ")", ";", "}", ";", "$", "logger", "=", "$", "this", "->", "getLogger", "(", ")", ";", "foreach", "(", "$", "new", "as", "$", "item", ")", "{", "$", "key", "=", "$", "getKey", "(", "$", "item", ")", ";", "$", "logger", "->", "debug", "(", "'New: '", ".", "$", "key", ")", ";", "$", "map", "[", "$", "key", "]", "=", "$", "item", ";", "}", "foreach", "(", "$", "old", "as", "$", "item", ")", "{", "$", "key", "=", "$", "getKey", "(", "$", "item", ")", ";", "$", "logger", "->", "debug", "(", "'Old: '", ".", "$", "key", ")", ";", "unset", "(", "$", "map", "[", "$", "key", "]", ")", ";", "}", "$", "logger", "->", "debug", "(", "'Diff: '", ".", "implode", "(", "' '", ",", "array_keys", "(", "$", "map", ")", ")", ")", ";", "return", "array_values", "(", "$", "map", ")", ";", "}" ]
Locates new items in a feed given newer and older lists of items from the feed. @param \Zend\Feed\Reader\Entry\EntryInterface[] $new @param \Zend\Feed\Reader\Entry\EntryInterface[] $old
[ "Locates", "new", "items", "in", "a", "feed", "given", "newer", "and", "older", "lists", "of", "items", "from", "the", "feed", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L239-L258
236,657
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.syndicateFeedItems
protected function syndicateFeedItems(array $items) { $messages = array(); foreach ($items as $item) { $messages[] = $this->formatter->format($item); } foreach ($this->targets as $connection => $targets) { $this->getEventQueue($connection)->then( function($queue) use ($targets, $messages) { foreach ($targets as $target) { foreach ($messages as $message) { $queue->ircPrivmsg($target, $message); } } } ); } }
php
protected function syndicateFeedItems(array $items) { $messages = array(); foreach ($items as $item) { $messages[] = $this->formatter->format($item); } foreach ($this->targets as $connection => $targets) { $this->getEventQueue($connection)->then( function($queue) use ($targets, $messages) { foreach ($targets as $target) { foreach ($messages as $message) { $queue->ircPrivmsg($target, $message); } } } ); } }
[ "protected", "function", "syndicateFeedItems", "(", "array", "$", "items", ")", "{", "$", "messages", "=", "array", "(", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "messages", "[", "]", "=", "$", "this", "->", "formatter", "->", "format", "(", "$", "item", ")", ";", "}", "foreach", "(", "$", "this", "->", "targets", "as", "$", "connection", "=>", "$", "targets", ")", "{", "$", "this", "->", "getEventQueue", "(", "$", "connection", ")", "->", "then", "(", "function", "(", "$", "queue", ")", "use", "(", "$", "targets", ",", "$", "messages", ")", "{", "foreach", "(", "$", "targets", "as", "$", "target", ")", "{", "foreach", "(", "$", "messages", "as", "$", "message", ")", "{", "$", "queue", "->", "ircPrivmsg", "(", "$", "target", ",", "$", "message", ")", ";", "}", "}", "}", ")", ";", "}", "}" ]
Syndicates a given list of feed items to all targets. @param \Zend\Feed\Reader\Entry\EntryInterface[] $items
[ "Syndicates", "a", "given", "list", "of", "feed", "items", "to", "all", "targets", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L265-L283
236,658
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.processFailure
public function processFailure($url, $error) { $this->getLogger()->warning( 'Failed to poll feed', array( 'url' => $url, 'error' => $error, ) ); $this->queuePoll($url); }
php
public function processFailure($url, $error) { $this->getLogger()->warning( 'Failed to poll feed', array( 'url' => $url, 'error' => $error, ) ); $this->queuePoll($url); }
[ "public", "function", "processFailure", "(", "$", "url", ",", "$", "error", ")", "{", "$", "this", "->", "getLogger", "(", ")", "->", "warning", "(", "'Failed to poll feed'", ",", "array", "(", "'url'", "=>", "$", "url", ",", "'error'", "=>", "$", "error", ",", ")", ")", ";", "$", "this", "->", "queuePoll", "(", "$", "url", ")", ";", "}" ]
Logs feed poll failures. @param string $url URL of the feed for which a poll failure occurred @param string $error Message describing the failure
[ "Logs", "feed", "poll", "failures", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L291-L302
236,659
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.queuePoll
protected function queuePoll($url) { $self = $this; $this->loop->addTimer( $this->interval, function() use ($url, $self) { $self->pollFeed($url); } ); }
php
protected function queuePoll($url) { $self = $this; $this->loop->addTimer( $this->interval, function() use ($url, $self) { $self->pollFeed($url); } ); }
[ "protected", "function", "queuePoll", "(", "$", "url", ")", "{", "$", "self", "=", "$", "this", ";", "$", "this", "->", "loop", "->", "addTimer", "(", "$", "this", "->", "interval", ",", "function", "(", ")", "use", "(", "$", "url", ",", "$", "self", ")", "{", "$", "self", "->", "pollFeed", "(", "$", "url", ")", ";", "}", ")", ";", "}" ]
Sets up a callback to poll a specified feed. @param string $url Feed URL
[ "Sets", "up", "a", "callback", "to", "poll", "a", "specified", "feed", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L309-L318
236,660
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.getEventQueueDeferred
protected function getEventQueueDeferred($mask) { if (!isset($this->queues[$mask])) { $this->queues[$mask] = new Deferred; } return $this->queues[$mask]; }
php
protected function getEventQueueDeferred($mask) { if (!isset($this->queues[$mask])) { $this->queues[$mask] = new Deferred; } return $this->queues[$mask]; }
[ "protected", "function", "getEventQueueDeferred", "(", "$", "mask", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "queues", "[", "$", "mask", "]", ")", ")", "{", "$", "this", "->", "queues", "[", "$", "mask", "]", "=", "new", "Deferred", ";", "}", "return", "$", "this", "->", "queues", "[", "$", "mask", "]", ";", "}" ]
Creates a deferred for the event queue of a given connection. @param string $mask Mask for the connection @return \React\Promise\Deferred
[ "Creates", "a", "deferred", "for", "the", "event", "queue", "of", "a", "given", "connection", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L326-L332
236,661
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.setEventQueue
public function setEventQueue(Event $event, Queue $queue) { $mask = $this->getConnectionMask($event->getConnection()); $this->getEventQueueDeferred($mask)->resolve($queue); }
php
public function setEventQueue(Event $event, Queue $queue) { $mask = $this->getConnectionMask($event->getConnection()); $this->getEventQueueDeferred($mask)->resolve($queue); }
[ "public", "function", "setEventQueue", "(", "Event", "$", "event", ",", "Queue", "$", "queue", ")", "{", "$", "mask", "=", "$", "this", "->", "getConnectionMask", "(", "$", "event", "->", "getConnection", "(", ")", ")", ";", "$", "this", "->", "getEventQueueDeferred", "(", "$", "mask", ")", "->", "resolve", "(", "$", "queue", ")", ";", "}" ]
Stores a reference to the event queue for the connection on which a USER event occurs. @param \Phergie\Irc\EventInterface $event @param \Phergie\Irc\Bot\React\EventQueueInterface $queue
[ "Stores", "a", "reference", "to", "the", "event", "queue", "for", "the", "connection", "on", "which", "a", "USER", "event", "occurs", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L341-L345
236,662
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.getUrls
protected function getUrls(array $config) { if (!isset($config['urls']) || !is_array($config['urls']) || array_filter($config['urls'], 'is_string') != $config['urls']) { throw new \DomainException( 'urls must be a list of strings containing feed URLs', self::ERR_URLS_INVALID ); } return $config['urls']; }
php
protected function getUrls(array $config) { if (!isset($config['urls']) || !is_array($config['urls']) || array_filter($config['urls'], 'is_string') != $config['urls']) { throw new \DomainException( 'urls must be a list of strings containing feed URLs', self::ERR_URLS_INVALID ); } return $config['urls']; }
[ "protected", "function", "getUrls", "(", "array", "$", "config", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'urls'", "]", ")", "||", "!", "is_array", "(", "$", "config", "[", "'urls'", "]", ")", "||", "array_filter", "(", "$", "config", "[", "'urls'", "]", ",", "'is_string'", ")", "!=", "$", "config", "[", "'urls'", "]", ")", "{", "throw", "new", "\\", "DomainException", "(", "'urls must be a list of strings containing feed URLs'", ",", "self", "::", "ERR_URLS_INVALID", ")", ";", "}", "return", "$", "config", "[", "'urls'", "]", ";", "}" ]
Extracts feed URLs from configuration. @param array $config @return array @throws \DomainException if urls setting is invalid
[ "Extracts", "feed", "URLs", "from", "configuration", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L380-L391
236,663
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.getTargets
protected function getTargets(array $config) { if (!isset($config['targets']) || !is_array($config['targets']) || array_filter($config['targets'], 'is_array') != $config['targets']) { throw new \DomainException( 'targets must be an array of arrays', self::ERR_TARGETS_INVALID ); } return $config['targets']; }
php
protected function getTargets(array $config) { if (!isset($config['targets']) || !is_array($config['targets']) || array_filter($config['targets'], 'is_array') != $config['targets']) { throw new \DomainException( 'targets must be an array of arrays', self::ERR_TARGETS_INVALID ); } return $config['targets']; }
[ "protected", "function", "getTargets", "(", "array", "$", "config", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'targets'", "]", ")", "||", "!", "is_array", "(", "$", "config", "[", "'targets'", "]", ")", "||", "array_filter", "(", "$", "config", "[", "'targets'", "]", ",", "'is_array'", ")", "!=", "$", "config", "[", "'targets'", "]", ")", "{", "throw", "new", "\\", "DomainException", "(", "'targets must be an array of arrays'", ",", "self", "::", "ERR_TARGETS_INVALID", ")", ";", "}", "return", "$", "config", "[", "'targets'", "]", ";", "}" ]
Extracts targets from configuration. @param array $config @return array @throws \DomainException if targets setting is invalid
[ "Extracts", "targets", "from", "configuration", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L400-L411
236,664
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.getInterval
protected function getInterval(array $config) { if (isset($config['interval'])) { if (!is_int($config['interval']) || $config['interval'] <= 0) { throw new \DomainException( 'interval must reference a positive integer value', self::ERR_INTERVAL_INVALID ); } return $config['interval']; } return 300; // default to 5 minutes }
php
protected function getInterval(array $config) { if (isset($config['interval'])) { if (!is_int($config['interval']) || $config['interval'] <= 0) { throw new \DomainException( 'interval must reference a positive integer value', self::ERR_INTERVAL_INVALID ); } return $config['interval']; } return 300; // default to 5 minutes }
[ "protected", "function", "getInterval", "(", "array", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'interval'", "]", ")", ")", "{", "if", "(", "!", "is_int", "(", "$", "config", "[", "'interval'", "]", ")", "||", "$", "config", "[", "'interval'", "]", "<=", "0", ")", "{", "throw", "new", "\\", "DomainException", "(", "'interval must reference a positive integer value'", ",", "self", "::", "ERR_INTERVAL_INVALID", ")", ";", "}", "return", "$", "config", "[", "'interval'", "]", ";", "}", "return", "300", ";", "// default to 5 minutes", "}" ]
Extracts the interval on which to update feeds from configuration. @param array $config @return int @throws \DomainException if interval setting is invalid
[ "Extracts", "the", "interval", "on", "which", "to", "update", "feeds", "from", "configuration", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L420-L432
236,665
phergie/phergie-irc-plugin-react-feedticker
src/Plugin.php
Plugin.getFormatter
protected function getFormatter(array $config) { if (isset($config['formatter'])) { if (!$config['formatter'] instanceof FormatterInterface) { throw new \DomainException( 'formatter must implement ' . __NAMESPACE__ . '\FormatterInterface', self::ERR_FORMATTER_INVALID ); } return $config['formatter']; } return new DefaultFormatter; }
php
protected function getFormatter(array $config) { if (isset($config['formatter'])) { if (!$config['formatter'] instanceof FormatterInterface) { throw new \DomainException( 'formatter must implement ' . __NAMESPACE__ . '\FormatterInterface', self::ERR_FORMATTER_INVALID ); } return $config['formatter']; } return new DefaultFormatter; }
[ "protected", "function", "getFormatter", "(", "array", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'formatter'", "]", ")", ")", "{", "if", "(", "!", "$", "config", "[", "'formatter'", "]", "instanceof", "FormatterInterface", ")", "{", "throw", "new", "\\", "DomainException", "(", "'formatter must implement '", ".", "__NAMESPACE__", ".", "'\\FormatterInterface'", ",", "self", "::", "ERR_FORMATTER_INVALID", ")", ";", "}", "return", "$", "config", "[", "'formatter'", "]", ";", "}", "return", "new", "DefaultFormatter", ";", "}" ]
Extracts the feed item formatter from configuration. @param array $config @return \Phergie\Irc\Plugin\React\FeedTicker\FormatterInterface @throws \DomainException if formatter setting is invalid
[ "Extracts", "the", "feed", "item", "formatter", "from", "configuration", "." ]
32f880499d5a61804caae097673f6937c308fa4f
https://github.com/phergie/phergie-irc-plugin-react-feedticker/blob/32f880499d5a61804caae097673f6937c308fa4f/src/Plugin.php#L441-L453
236,666
alevilar/MtSites
Utility/MtSites.php
MtSites.loadConfigFiles
public static function loadConfigFiles () { // Read configuration file from ini file if ( self::isTenant() ) { if ( file_exists( TENANT_PATH . DS . self::getSiteName() . DS . 'settings.ini' ) ) { App::uses('IniReader', 'Configure'); Configure::config('ini', new IniReader( TENANT_PATH . DS . self::getSiteName() . DS )); Configure::load( 'settings', 'ini'); App::uses('CakeNumber', 'Utility'); CakeNumber::defaultCurrency(Configure::read('Geo.currency_code')); } else { throw new CakeException("El archivo de configuracion para el sitio ". self::getSiteName(). " no pudo ser encontrado"); } } }
php
public static function loadConfigFiles () { // Read configuration file from ini file if ( self::isTenant() ) { if ( file_exists( TENANT_PATH . DS . self::getSiteName() . DS . 'settings.ini' ) ) { App::uses('IniReader', 'Configure'); Configure::config('ini', new IniReader( TENANT_PATH . DS . self::getSiteName() . DS )); Configure::load( 'settings', 'ini'); App::uses('CakeNumber', 'Utility'); CakeNumber::defaultCurrency(Configure::read('Geo.currency_code')); } else { throw new CakeException("El archivo de configuracion para el sitio ". self::getSiteName(). " no pudo ser encontrado"); } } }
[ "public", "static", "function", "loadConfigFiles", "(", ")", "{", "// Read configuration file from ini file", "if", "(", "self", "::", "isTenant", "(", ")", ")", "{", "if", "(", "file_exists", "(", "TENANT_PATH", ".", "DS", ".", "self", "::", "getSiteName", "(", ")", ".", "DS", ".", "'settings.ini'", ")", ")", "{", "App", "::", "uses", "(", "'IniReader'", ",", "'Configure'", ")", ";", "Configure", "::", "config", "(", "'ini'", ",", "new", "IniReader", "(", "TENANT_PATH", ".", "DS", ".", "self", "::", "getSiteName", "(", ")", ".", "DS", ")", ")", ";", "Configure", "::", "load", "(", "'settings'", ",", "'ini'", ")", ";", "App", "::", "uses", "(", "'CakeNumber'", ",", "'Utility'", ")", ";", "CakeNumber", "::", "defaultCurrency", "(", "Configure", "::", "read", "(", "'Geo.currency_code'", ")", ")", ";", "}", "else", "{", "throw", "new", "CakeException", "(", "\"El archivo de configuracion para el sitio \"", ".", "self", "::", "getSiteName", "(", ")", ".", "\" no pudo ser encontrado\"", ")", ";", "}", "}", "}" ]
Loads settings files from Tenant folder
[ "Loads", "settings", "files", "from", "Tenant", "folder" ]
5b1cdc52a929ca86a220ae12add84c52027a3c20
https://github.com/alevilar/MtSites/blob/5b1cdc52a929ca86a220ae12add84c52027a3c20/Utility/MtSites.php#L115-L131
236,667
prototypemvc/prototypemvc
Core/Data.php
Data.count
public static function count($data = false) { if ($data && Validate::isArray($data)) { return count($data); } else if ($data && Validate::isObject($data)) { return count(get_object_vars($data)); } return 0; }
php
public static function count($data = false) { if ($data && Validate::isArray($data)) { return count($data); } else if ($data && Validate::isObject($data)) { return count(get_object_vars($data)); } return 0; }
[ "public", "static", "function", "count", "(", "$", "data", "=", "false", ")", "{", "if", "(", "$", "data", "&&", "Validate", "::", "isArray", "(", "$", "data", ")", ")", "{", "return", "count", "(", "$", "data", ")", ";", "}", "else", "if", "(", "$", "data", "&&", "Validate", "::", "isObject", "(", "$", "data", ")", ")", "{", "return", "count", "(", "get_object_vars", "(", "$", "data", ")", ")", ";", "}", "return", "0", ";", "}" ]
Count the numbers of keys in a given array or object. @param array || object @return int numbers of keys
[ "Count", "the", "numbers", "of", "keys", "in", "a", "given", "array", "or", "object", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Data.php#L15-L26
236,668
prototypemvc/prototypemvc
Core/Data.php
Data.keys
public static function keys($data = false) { if ($data && Validate::isArray($data)) { return array_keys($data); } else if ($data && Validate::isObject($data)) { return get_object_vars($data); } return false; }
php
public static function keys($data = false) { if ($data && Validate::isArray($data)) { return array_keys($data); } else if ($data && Validate::isObject($data)) { return get_object_vars($data); } return false; }
[ "public", "static", "function", "keys", "(", "$", "data", "=", "false", ")", "{", "if", "(", "$", "data", "&&", "Validate", "::", "isArray", "(", "$", "data", ")", ")", "{", "return", "array_keys", "(", "$", "data", ")", ";", "}", "else", "if", "(", "$", "data", "&&", "Validate", "::", "isObject", "(", "$", "data", ")", ")", "{", "return", "get_object_vars", "(", "$", "data", ")", ";", "}", "return", "false", ";", "}" ]
Get all keys from a given array or object. @param array || object @return array
[ "Get", "all", "keys", "from", "a", "given", "array", "or", "object", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Data.php#L69-L80
236,669
prototypemvc/prototypemvc
Core/Data.php
Data.random
public static function random($data = false) { if($data) { if(Validate::isObject($data)) { $data = Format::objectToArray($data); } if(Validate::isArray($data)) { return $data[array_rand($data, 1)]; } } return false; }
php
public static function random($data = false) { if($data) { if(Validate::isObject($data)) { $data = Format::objectToArray($data); } if(Validate::isArray($data)) { return $data[array_rand($data, 1)]; } } return false; }
[ "public", "static", "function", "random", "(", "$", "data", "=", "false", ")", "{", "if", "(", "$", "data", ")", "{", "if", "(", "Validate", "::", "isObject", "(", "$", "data", ")", ")", "{", "$", "data", "=", "Format", "::", "objectToArray", "(", "$", "data", ")", ";", "}", "if", "(", "Validate", "::", "isArray", "(", "$", "data", ")", ")", "{", "return", "$", "data", "[", "array_rand", "(", "$", "data", ",", "1", ")", "]", ";", "}", "}", "return", "false", ";", "}" ]
Return a random value from a given array or object. @param array || object @return string random value
[ "Return", "a", "random", "value", "from", "a", "given", "array", "or", "object", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Data.php#L147-L163
236,670
prototypemvc/prototypemvc
Core/Data.php
Data.sanitize
public function sanitize($input = false) { if($input) { if(Validate::isArray($input)) { return filter_var_array($input,FILTER_SANITIZE_STRING); } if(Validate::isString($input)) { return filter_var($input, FILTER_SANITIZE_STRING); } } return false; }
php
public function sanitize($input = false) { if($input) { if(Validate::isArray($input)) { return filter_var_array($input,FILTER_SANITIZE_STRING); } if(Validate::isString($input)) { return filter_var($input, FILTER_SANITIZE_STRING); } } return false; }
[ "public", "function", "sanitize", "(", "$", "input", "=", "false", ")", "{", "if", "(", "$", "input", ")", "{", "if", "(", "Validate", "::", "isArray", "(", "$", "input", ")", ")", "{", "return", "filter_var_array", "(", "$", "input", ",", "FILTER_SANITIZE_STRING", ")", ";", "}", "if", "(", "Validate", "::", "isString", "(", "$", "input", ")", ")", "{", "return", "filter_var", "(", "$", "input", ",", "FILTER_SANITIZE_STRING", ")", ";", "}", "}", "return", "false", ";", "}" ]
Sanitize input. @param array || string @return array || string
[ "Sanitize", "input", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Data.php#L190-L205
236,671
prototypemvc/prototypemvc
Core/Data.php
Data.type
public static function type($data = false) { if ($data) { $dataType = gettype($data); if ($dataType === 'string') { if (Validate::isJson($data)) { $dataType = 'json'; } } return $dataType; } return false; }
php
public static function type($data = false) { if ($data) { $dataType = gettype($data); if ($dataType === 'string') { if (Validate::isJson($data)) { $dataType = 'json'; } } return $dataType; } return false; }
[ "public", "static", "function", "type", "(", "$", "data", "=", "false", ")", "{", "if", "(", "$", "data", ")", "{", "$", "dataType", "=", "gettype", "(", "$", "data", ")", ";", "if", "(", "$", "dataType", "===", "'string'", ")", "{", "if", "(", "Validate", "::", "isJson", "(", "$", "data", ")", ")", "{", "$", "dataType", "=", "'json'", ";", "}", "}", "return", "$", "dataType", ";", "}", "return", "false", ";", "}" ]
Return type of a given variable. @param array || double || integer || json || object || string @return string type of variable
[ "Return", "type", "of", "a", "given", "variable", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Data.php#L232-L249
236,672
XTAIN/JoomlaBundle
Resources/joomla/com_symfony/site/views/symfony/view.html.php
SymfonyViewSymfony.display
public function display($tpl = null) { $attributes = array(); $query = array(); $app = JFactory::getApplication(); $input = $app->input; $routeName = $input->get('route', null, 'string'); $path = $input->get('path', null, 'string'); $route = self::$router->getRouteCollection()->get($routeName); $defaults = $route->getDefaults(); if ($path !== null) { $path = rtrim($route->getPath(), '/') . '/' . $path; $defaults = self::$router->match($path, null, false); } unset($attributes['_controller']); foreach ($defaults as $key => $default) { if (!isset($attributes[$key])) { $attributes[$key] = $default; } } $subRequest = self::$requestStack->getCurrentRequest()->duplicate($query, null, $attributes); $this->response = self::$kernel->handle( $subRequest, \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST, false ); // Display the view parent::display($tpl); }
php
public function display($tpl = null) { $attributes = array(); $query = array(); $app = JFactory::getApplication(); $input = $app->input; $routeName = $input->get('route', null, 'string'); $path = $input->get('path', null, 'string'); $route = self::$router->getRouteCollection()->get($routeName); $defaults = $route->getDefaults(); if ($path !== null) { $path = rtrim($route->getPath(), '/') . '/' . $path; $defaults = self::$router->match($path, null, false); } unset($attributes['_controller']); foreach ($defaults as $key => $default) { if (!isset($attributes[$key])) { $attributes[$key] = $default; } } $subRequest = self::$requestStack->getCurrentRequest()->duplicate($query, null, $attributes); $this->response = self::$kernel->handle( $subRequest, \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST, false ); // Display the view parent::display($tpl); }
[ "public", "function", "display", "(", "$", "tpl", "=", "null", ")", "{", "$", "attributes", "=", "array", "(", ")", ";", "$", "query", "=", "array", "(", ")", ";", "$", "app", "=", "JFactory", "::", "getApplication", "(", ")", ";", "$", "input", "=", "$", "app", "->", "input", ";", "$", "routeName", "=", "$", "input", "->", "get", "(", "'route'", ",", "null", ",", "'string'", ")", ";", "$", "path", "=", "$", "input", "->", "get", "(", "'path'", ",", "null", ",", "'string'", ")", ";", "$", "route", "=", "self", "::", "$", "router", "->", "getRouteCollection", "(", ")", "->", "get", "(", "$", "routeName", ")", ";", "$", "defaults", "=", "$", "route", "->", "getDefaults", "(", ")", ";", "if", "(", "$", "path", "!==", "null", ")", "{", "$", "path", "=", "rtrim", "(", "$", "route", "->", "getPath", "(", ")", ",", "'/'", ")", ".", "'/'", ".", "$", "path", ";", "$", "defaults", "=", "self", "::", "$", "router", "->", "match", "(", "$", "path", ",", "null", ",", "false", ")", ";", "}", "unset", "(", "$", "attributes", "[", "'_controller'", "]", ")", ";", "foreach", "(", "$", "defaults", "as", "$", "key", "=>", "$", "default", ")", "{", "if", "(", "!", "isset", "(", "$", "attributes", "[", "$", "key", "]", ")", ")", "{", "$", "attributes", "[", "$", "key", "]", "=", "$", "default", ";", "}", "}", "$", "subRequest", "=", "self", "::", "$", "requestStack", "->", "getCurrentRequest", "(", ")", "->", "duplicate", "(", "$", "query", ",", "null", ",", "$", "attributes", ")", ";", "$", "this", "->", "response", "=", "self", "::", "$", "kernel", "->", "handle", "(", "$", "subRequest", ",", "\\", "Symfony", "\\", "Component", "\\", "HttpKernel", "\\", "HttpKernelInterface", "::", "SUB_REQUEST", ",", "false", ")", ";", "// Display the view", "parent", "::", "display", "(", "$", "tpl", ")", ";", "}" ]
Display the Hello World view @param string $tpl The name of the template file to parse; automatically searches through the template paths. @return void
[ "Display", "the", "Hello", "World", "view" ]
3d39e1278deba77c5a2197ad91973964ed2a38bd
https://github.com/XTAIN/JoomlaBundle/blob/3d39e1278deba77c5a2197ad91973964ed2a38bd/Resources/joomla/com_symfony/site/views/symfony/view.html.php#L85-L122
236,673
aleksip/patternengine-php-tpl
src/aleksip/PatternEngine/Tpl/Loaders/PatternLoader.php
PatternLoader.render
public function render($options = array()) { $pattern = $options['pattern']; $data = $options['data']; return $this->renderTpl($pattern, $data); }
php
public function render($options = array()) { $pattern = $options['pattern']; $data = $options['data']; return $this->renderTpl($pattern, $data); }
[ "public", "function", "render", "(", "$", "options", "=", "array", "(", ")", ")", "{", "$", "pattern", "=", "$", "options", "[", "'pattern'", "]", ";", "$", "data", "=", "$", "options", "[", "'data'", "]", ";", "return", "$", "this", "->", "renderTpl", "(", "$", "pattern", ",", "$", "data", ")", ";", "}" ]
Render a pattern. @param array $options Options @return string The rendered result
[ "Render", "a", "pattern", "." ]
08b56cff240481855a012f85eb94b10ddb994d59
https://github.com/aleksip/patternengine-php-tpl/blob/08b56cff240481855a012f85eb94b10ddb994d59/src/aleksip/PatternEngine/Tpl/Loaders/PatternLoader.php#L17-L23
236,674
nirix/radium
src/Database/Model/SecurePassword.php
SecurePassword.preparePassword
public function preparePassword() { $this->{$this->securePasswordField} = crypt( $this->{$this->securePasswordField}, '$2y$10$' . sha1(microtime() . $this->username . $this->email) . '$' ); }
php
public function preparePassword() { $this->{$this->securePasswordField} = crypt( $this->{$this->securePasswordField}, '$2y$10$' . sha1(microtime() . $this->username . $this->email) . '$' ); }
[ "public", "function", "preparePassword", "(", ")", "{", "$", "this", "->", "{", "$", "this", "->", "securePasswordField", "}", "=", "crypt", "(", "$", "this", "->", "{", "$", "this", "->", "securePasswordField", "}", ",", "'$2y$10$'", ".", "sha1", "(", "microtime", "(", ")", ".", "$", "this", "->", "username", ".", "$", "this", "->", "email", ")", ".", "'$'", ")", ";", "}" ]
Crypts the users password.
[ "Crypts", "the", "users", "password", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Database/Model/SecurePassword.php#L35-L41
236,675
agencms/auth
src/Handlers/AgencmsHandler.php
AgencmsHandler.registerUsersAdmin
private static function registerUsersAdmin() { if (!Gate::allows('users_read')) { return; } Agencms::registerRoute( Route::init('users', ['Users' => 'Manage Users'], '/agencms-auth/users') ->icon('person') ->addGroup( Group::large('Details')->addField( Field::number('id', 'Id')->readonly()->list(), Field::string('name', 'Name')->medium()->required()->list(), Field::string('email', 'Email')->medium()->required()->list(), Field::related('roleids', 'Roles')->model( Relationship::make('roles') ) ), Group::small('Extra')->addField( Field::boolean('active', 'Active')->list(), Field::image('avatar', 'Profile Picture')->ratio(600, 600, $resize = true) ) ) ); }
php
private static function registerUsersAdmin() { if (!Gate::allows('users_read')) { return; } Agencms::registerRoute( Route::init('users', ['Users' => 'Manage Users'], '/agencms-auth/users') ->icon('person') ->addGroup( Group::large('Details')->addField( Field::number('id', 'Id')->readonly()->list(), Field::string('name', 'Name')->medium()->required()->list(), Field::string('email', 'Email')->medium()->required()->list(), Field::related('roleids', 'Roles')->model( Relationship::make('roles') ) ), Group::small('Extra')->addField( Field::boolean('active', 'Active')->list(), Field::image('avatar', 'Profile Picture')->ratio(600, 600, $resize = true) ) ) ); }
[ "private", "static", "function", "registerUsersAdmin", "(", ")", "{", "if", "(", "!", "Gate", "::", "allows", "(", "'users_read'", ")", ")", "{", "return", ";", "}", "Agencms", "::", "registerRoute", "(", "Route", "::", "init", "(", "'users'", ",", "[", "'Users'", "=>", "'Manage Users'", "]", ",", "'/agencms-auth/users'", ")", "->", "icon", "(", "'person'", ")", "->", "addGroup", "(", "Group", "::", "large", "(", "'Details'", ")", "->", "addField", "(", "Field", "::", "number", "(", "'id'", ",", "'Id'", ")", "->", "readonly", "(", ")", "->", "list", "(", ")", ",", "Field", "::", "string", "(", "'name'", ",", "'Name'", ")", "->", "medium", "(", ")", "->", "required", "(", ")", "->", "list", "(", ")", ",", "Field", "::", "string", "(", "'email'", ",", "'Email'", ")", "->", "medium", "(", ")", "->", "required", "(", ")", "->", "list", "(", ")", ",", "Field", "::", "related", "(", "'roleids'", ",", "'Roles'", ")", "->", "model", "(", "Relationship", "::", "make", "(", "'roles'", ")", ")", ")", ",", "Group", "::", "small", "(", "'Extra'", ")", "->", "addField", "(", "Field", "::", "boolean", "(", "'active'", ",", "'Active'", ")", "->", "list", "(", ")", ",", "Field", "::", "image", "(", "'avatar'", ",", "'Profile Picture'", ")", "->", "ratio", "(", "600", ",", "600", ",", "$", "resize", "=", "true", ")", ")", ")", ")", ";", "}" ]
Register the Agencms endpoints for User administration @return void
[ "Register", "the", "Agencms", "endpoints", "for", "User", "administration" ]
a255988180c461c1ccbc62e2ab3660d379e6e072
https://github.com/agencms/auth/blob/a255988180c461c1ccbc62e2ab3660d379e6e072/src/Handlers/AgencmsHandler.php#L38-L62
236,676
agencms/auth
src/Handlers/AgencmsHandler.php
AgencmsHandler.registerUserProfile
private static function registerUserProfile() { Agencms::registerRoute( Route::initSingle('profile', '', '/agencms-auth/profile') ->icon('person') ->addGroup( Group::large('Details')->addField( Field::number('id', 'Id')->readonly()->list(), Field::string('name', 'Name')->medium()->required()->list(), Field::string('email', 'Email')->medium()->readonly()->list() ), Group::small('Extra')->addField( Field::image('avatar', 'Profile Picture')->ratio(600, 600, $resize = true) ) ) ); }
php
private static function registerUserProfile() { Agencms::registerRoute( Route::initSingle('profile', '', '/agencms-auth/profile') ->icon('person') ->addGroup( Group::large('Details')->addField( Field::number('id', 'Id')->readonly()->list(), Field::string('name', 'Name')->medium()->required()->list(), Field::string('email', 'Email')->medium()->readonly()->list() ), Group::small('Extra')->addField( Field::image('avatar', 'Profile Picture')->ratio(600, 600, $resize = true) ) ) ); }
[ "private", "static", "function", "registerUserProfile", "(", ")", "{", "Agencms", "::", "registerRoute", "(", "Route", "::", "initSingle", "(", "'profile'", ",", "''", ",", "'/agencms-auth/profile'", ")", "->", "icon", "(", "'person'", ")", "->", "addGroup", "(", "Group", "::", "large", "(", "'Details'", ")", "->", "addField", "(", "Field", "::", "number", "(", "'id'", ",", "'Id'", ")", "->", "readonly", "(", ")", "->", "list", "(", ")", ",", "Field", "::", "string", "(", "'name'", ",", "'Name'", ")", "->", "medium", "(", ")", "->", "required", "(", ")", "->", "list", "(", ")", ",", "Field", "::", "string", "(", "'email'", ",", "'Email'", ")", "->", "medium", "(", ")", "->", "readonly", "(", ")", "->", "list", "(", ")", ")", ",", "Group", "::", "small", "(", "'Extra'", ")", "->", "addField", "(", "Field", "::", "image", "(", "'avatar'", ",", "'Profile Picture'", ")", "->", "ratio", "(", "600", ",", "600", ",", "$", "resize", "=", "true", ")", ")", ")", ")", ";", "}" ]
Register the Agencms endpoints for the User's account profile @return void
[ "Register", "the", "Agencms", "endpoints", "for", "the", "User", "s", "account", "profile" ]
a255988180c461c1ccbc62e2ab3660d379e6e072
https://github.com/agencms/auth/blob/a255988180c461c1ccbc62e2ab3660d379e6e072/src/Handlers/AgencmsHandler.php#L69-L85
236,677
happyDemon/elements
classes/Kohana/Element/Render.php
Kohana_Element_Render.get_view_path
public function get_view_path() { return $this->_element->view ? $this->_element->view : self::VIEWS_DIR.DIRECTORY_SEPARATOR.$this->_template_dir.DIRECTORY_SEPARATOR.$this->template; }
php
public function get_view_path() { return $this->_element->view ? $this->_element->view : self::VIEWS_DIR.DIRECTORY_SEPARATOR.$this->_template_dir.DIRECTORY_SEPARATOR.$this->template; }
[ "public", "function", "get_view_path", "(", ")", "{", "return", "$", "this", "->", "_element", "->", "view", "?", "$", "this", "->", "_element", "->", "view", ":", "self", "::", "VIEWS_DIR", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "_template_dir", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "template", ";", "}" ]
Get the path of the view file @return string
[ "Get", "the", "path", "of", "the", "view", "file" ]
19534fcbf4735a12a0219f8aada49f30e3b690e1
https://github.com/happyDemon/elements/blob/19534fcbf4735a12a0219f8aada49f30e3b690e1/classes/Kohana/Element/Render.php#L84-L87
236,678
prototypemvc/prototypemvc
Core/Number.php
Number.average
public static function average($array = false, $decimals = 2) { if($array && Validate::isArray($array)) { return self::round((array_sum($array) / count($array)), $decimals); } return false; }
php
public static function average($array = false, $decimals = 2) { if($array && Validate::isArray($array)) { return self::round((array_sum($array) / count($array)), $decimals); } return false; }
[ "public", "static", "function", "average", "(", "$", "array", "=", "false", ",", "$", "decimals", "=", "2", ")", "{", "if", "(", "$", "array", "&&", "Validate", "::", "isArray", "(", "$", "array", ")", ")", "{", "return", "self", "::", "round", "(", "(", "array_sum", "(", "$", "array", ")", "/", "count", "(", "$", "array", ")", ")", ",", "$", "decimals", ")", ";", "}", "return", "false", ";", "}" ]
Get the average value of a given array. @param array with values @param int number of decimals @return int || float
[ "Get", "the", "average", "value", "of", "a", "given", "array", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Number.php#L15-L23
236,679
prototypemvc/prototypemvc
Core/Number.php
Number.max
public static function max($array = false, $decimals = 3) { if($array && Validate::isArray($array)) { return self::round(max($array), $decimals); } return false; }
php
public static function max($array = false, $decimals = 3) { if($array && Validate::isArray($array)) { return self::round(max($array), $decimals); } return false; }
[ "public", "static", "function", "max", "(", "$", "array", "=", "false", ",", "$", "decimals", "=", "3", ")", "{", "if", "(", "$", "array", "&&", "Validate", "::", "isArray", "(", "$", "array", ")", ")", "{", "return", "self", "::", "round", "(", "max", "(", "$", "array", ")", ",", "$", "decimals", ")", ";", "}", "return", "false", ";", "}" ]
Get the heighest value of a given array. @param array with values @param int number of decimals @return int || float
[ "Get", "the", "heighest", "value", "of", "a", "given", "array", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Number.php#L31-L39
236,680
prototypemvc/prototypemvc
Core/Number.php
Number.min
public static function min($array = false, $decimals = 3) { if($array && Validate::isArray($array)) { return self::round(min($array), $decimals); } return false; }
php
public static function min($array = false, $decimals = 3) { if($array && Validate::isArray($array)) { return self::round(min($array), $decimals); } return false; }
[ "public", "static", "function", "min", "(", "$", "array", "=", "false", ",", "$", "decimals", "=", "3", ")", "{", "if", "(", "$", "array", "&&", "Validate", "::", "isArray", "(", "$", "array", ")", ")", "{", "return", "self", "::", "round", "(", "min", "(", "$", "array", ")", ",", "$", "decimals", ")", ";", "}", "return", "false", ";", "}" ]
Get the lowest value of a given array. @param array with values @param int number of decimals @return int || float
[ "Get", "the", "lowest", "value", "of", "a", "given", "array", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Number.php#L47-L55
236,681
prototypemvc/prototypemvc
Core/Number.php
Number.percentage
public static function percentage($number1 = false, $number2 = false, $decimals = 2) { if($number1 && $number2) { return self::round(($number1 / $number2) * 100, $decimals); } return false; }
php
public static function percentage($number1 = false, $number2 = false, $decimals = 2) { if($number1 && $number2) { return self::round(($number1 / $number2) * 100, $decimals); } return false; }
[ "public", "static", "function", "percentage", "(", "$", "number1", "=", "false", ",", "$", "number2", "=", "false", ",", "$", "decimals", "=", "2", ")", "{", "if", "(", "$", "number1", "&&", "$", "number2", ")", "{", "return", "self", "::", "round", "(", "(", "$", "number1", "/", "$", "number2", ")", "*", "100", ",", "$", "decimals", ")", ";", "}", "return", "false", ";", "}" ]
Get the percentage. @param float number part @param float number total @param numbes of decimals @return int || float
[ "Get", "the", "percentage", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Number.php#L64-L72
236,682
prototypemvc/prototypemvc
Core/Number.php
Number.round
public static function round($number = false, $decimals = false) { if($number) { return number_format((float)$number, $decimals); } return false; }
php
public static function round($number = false, $decimals = false) { if($number) { return number_format((float)$number, $decimals); } return false; }
[ "public", "static", "function", "round", "(", "$", "number", "=", "false", ",", "$", "decimals", "=", "false", ")", "{", "if", "(", "$", "number", ")", "{", "return", "number_format", "(", "(", "float", ")", "$", "number", ",", "$", "decimals", ")", ";", "}", "return", "false", ";", "}" ]
Get a round number. @example round(15, 2) - will return 15.00 @example round(15.123, 2) - will return 15.12 @param float number @param int number of decimals @return int || float
[ "Get", "a", "round", "number", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Number.php#L93-L101
236,683
prototypemvc/prototypemvc
Core/Number.php
Number.total
public static function total($array = false, $decimals = 2) { if($array && Validate::isArray($array)) { return self::round(array_sum($array), $decimals); } return false; }
php
public static function total($array = false, $decimals = 2) { if($array && Validate::isArray($array)) { return self::round(array_sum($array), $decimals); } return false; }
[ "public", "static", "function", "total", "(", "$", "array", "=", "false", ",", "$", "decimals", "=", "2", ")", "{", "if", "(", "$", "array", "&&", "Validate", "::", "isArray", "(", "$", "array", ")", ")", "{", "return", "self", "::", "round", "(", "array_sum", "(", "$", "array", ")", ",", "$", "decimals", ")", ";", "}", "return", "false", ";", "}" ]
Get the sum total of a given array's values. @param array with values @return int || float
[ "Get", "the", "sum", "total", "of", "a", "given", "array", "s", "values", "." ]
039e238857d4b627e40ba681a376583b0821cd36
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Number.php#L130-L138
236,684
opsbears/piccolo-web-io-standard
src/StandardOutputProcessor.php
StandardOutputProcessor.execute
public function execute(ResponseInterface $httpResponse) { $headerFunction = $this->headerFunction; $bodyFunction = $this->bodyFunction; $headerFunction('HTTP/' . $httpResponse->getProtocolVersion() . ' ' . $httpResponse->getStatusCode() . ' ' . $httpResponse->getReasonPhrase()); foreach ($httpResponse->getHeaders() as $name => $values) { foreach ($values as $value) { $headerFunction(sprintf('%s: %s', $name, $value)); } } $bodyFunction($httpResponse->getBody()); }
php
public function execute(ResponseInterface $httpResponse) { $headerFunction = $this->headerFunction; $bodyFunction = $this->bodyFunction; $headerFunction('HTTP/' . $httpResponse->getProtocolVersion() . ' ' . $httpResponse->getStatusCode() . ' ' . $httpResponse->getReasonPhrase()); foreach ($httpResponse->getHeaders() as $name => $values) { foreach ($values as $value) { $headerFunction(sprintf('%s: %s', $name, $value)); } } $bodyFunction($httpResponse->getBody()); }
[ "public", "function", "execute", "(", "ResponseInterface", "$", "httpResponse", ")", "{", "$", "headerFunction", "=", "$", "this", "->", "headerFunction", ";", "$", "bodyFunction", "=", "$", "this", "->", "bodyFunction", ";", "$", "headerFunction", "(", "'HTTP/'", ".", "$", "httpResponse", "->", "getProtocolVersion", "(", ")", ".", "' '", ".", "$", "httpResponse", "->", "getStatusCode", "(", ")", ".", "' '", ".", "$", "httpResponse", "->", "getReasonPhrase", "(", ")", ")", ";", "foreach", "(", "$", "httpResponse", "->", "getHeaders", "(", ")", "as", "$", "name", "=>", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "headerFunction", "(", "sprintf", "(", "'%s: %s'", ",", "$", "name", ",", "$", "value", ")", ")", ";", "}", "}", "$", "bodyFunction", "(", "$", "httpResponse", "->", "getBody", "(", ")", ")", ";", "}" ]
Process a ResponseInterface into an output. @param ResponseInterface $httpResponse
[ "Process", "a", "ResponseInterface", "into", "an", "output", "." ]
ee8638bfded26d68a93a7fc3e0fed3f6add8d196
https://github.com/opsbears/piccolo-web-io-standard/blob/ee8638bfded26d68a93a7fc3e0fed3f6add8d196/src/StandardOutputProcessor.php#L57-L69
236,685
osflab/helper
Price.php
Price.htToTtc
public static function htToTtc($price, $tax, bool $taxIsPercent = false) { if ($taxIsPercent) { $tax = $tax / 100; } return $price + ($price * $tax); }
php
public static function htToTtc($price, $tax, bool $taxIsPercent = false) { if ($taxIsPercent) { $tax = $tax / 100; } return $price + ($price * $tax); }
[ "public", "static", "function", "htToTtc", "(", "$", "price", ",", "$", "tax", ",", "bool", "$", "taxIsPercent", "=", "false", ")", "{", "if", "(", "$", "taxIsPercent", ")", "{", "$", "tax", "=", "$", "tax", "/", "100", ";", "}", "return", "$", "price", "+", "(", "$", "price", "*", "$", "tax", ")", ";", "}" ]
HT to TTC transformation @param float $price @param float $tax @param bool $taxIsPercent @return float
[ "HT", "to", "TTC", "transformation" ]
313be45d2366e052238790eb8377ea7cf9ba5931
https://github.com/osflab/helper/blob/313be45d2366e052238790eb8377ea7cf9ba5931/Price.php#L30-L36
236,686
osflab/helper
Price.php
Price.TtcToHt
public static function TtcToHt($price, $tax, bool $taxIsPercent = false) { if ($taxIsPercent) { $tax = $tax / 100; } return $price / (1 + $tax); }
php
public static function TtcToHt($price, $tax, bool $taxIsPercent = false) { if ($taxIsPercent) { $tax = $tax / 100; } return $price / (1 + $tax); }
[ "public", "static", "function", "TtcToHt", "(", "$", "price", ",", "$", "tax", ",", "bool", "$", "taxIsPercent", "=", "false", ")", "{", "if", "(", "$", "taxIsPercent", ")", "{", "$", "tax", "=", "$", "tax", "/", "100", ";", "}", "return", "$", "price", "/", "(", "1", "+", "$", "tax", ")", ";", "}" ]
TTC to HT transformation @param float $price @param float $tax @param bool $taxIsPercent @return float
[ "TTC", "to", "HT", "transformation" ]
313be45d2366e052238790eb8377ea7cf9ba5931
https://github.com/osflab/helper/blob/313be45d2366e052238790eb8377ea7cf9ba5931/Price.php#L45-L51
236,687
osflab/helper
Price.php
Price.priceWithDiscount
public static function priceWithDiscount($price, $discount, bool $discountIsPercent = false) { if ($discountIsPercent) { $discount = $discount / 100; } return $price - ($price * $discount); }
php
public static function priceWithDiscount($price, $discount, bool $discountIsPercent = false) { if ($discountIsPercent) { $discount = $discount / 100; } return $price - ($price * $discount); }
[ "public", "static", "function", "priceWithDiscount", "(", "$", "price", ",", "$", "discount", ",", "bool", "$", "discountIsPercent", "=", "false", ")", "{", "if", "(", "$", "discountIsPercent", ")", "{", "$", "discount", "=", "$", "discount", "/", "100", ";", "}", "return", "$", "price", "-", "(", "$", "price", "*", "$", "discount", ")", ";", "}" ]
Get a price minus the discount @param float $price @param float $discount @param bool $discountIsPercent @return float
[ "Get", "a", "price", "minus", "the", "discount" ]
313be45d2366e052238790eb8377ea7cf9ba5931
https://github.com/osflab/helper/blob/313be45d2366e052238790eb8377ea7cf9ba5931/Price.php#L60-L66
236,688
zoopcommerce/shard
lib/Zoop/Shard/State/AccessControl/StatePermission.php
StatePermission.areAllowed
public function areAllowed(array $testRoles, array $testActions) { //only check allow and deny if there is at least one matching role if (count($testRoles) == 0) { $testRoles = ['']; } $roleMatch = false; foreach ($this->roles as $role) { if (count( array_filter( $testRoles, function ($testRole) use ($role) { return preg_match($role, $testRole); } ) ) > 0 ) { $roleMatch = true; break; } } if (!$roleMatch) { //Permission is neither explicitly allowed or denied. return new AllowedResult; } //check allow $allowMatches = 0; //check each testAction in turn foreach ($testActions as $testAction) { $allowMatch = count( array_filter( $this->allow, function ($action) use ($testAction) { //first check that action matches at least one allow return preg_match($action, $testAction); } ) ) > 0; $denyMatch = count( array_filter( $this->deny, function ($action) use ($testAction) { //second check that action does not match any deny return preg_match($action, $testAction); } ) ) > 0; if ($denyMatch) { //one or more actions are explicitly denied return new AllowedResult(false, [], [$this->stateField => $this->regex($this->states)]); } if ($allowMatch) { $allowMatches++; } } if ($allowMatches == count($testActions)) { //all actions are explicitly allowed return new AllowedResult(true, [], [$this->stateField => $this->regex($this->states)]); } //Permission is neither explicitly allowed or denied. return new AllowedResult; }
php
public function areAllowed(array $testRoles, array $testActions) { //only check allow and deny if there is at least one matching role if (count($testRoles) == 0) { $testRoles = ['']; } $roleMatch = false; foreach ($this->roles as $role) { if (count( array_filter( $testRoles, function ($testRole) use ($role) { return preg_match($role, $testRole); } ) ) > 0 ) { $roleMatch = true; break; } } if (!$roleMatch) { //Permission is neither explicitly allowed or denied. return new AllowedResult; } //check allow $allowMatches = 0; //check each testAction in turn foreach ($testActions as $testAction) { $allowMatch = count( array_filter( $this->allow, function ($action) use ($testAction) { //first check that action matches at least one allow return preg_match($action, $testAction); } ) ) > 0; $denyMatch = count( array_filter( $this->deny, function ($action) use ($testAction) { //second check that action does not match any deny return preg_match($action, $testAction); } ) ) > 0; if ($denyMatch) { //one or more actions are explicitly denied return new AllowedResult(false, [], [$this->stateField => $this->regex($this->states)]); } if ($allowMatch) { $allowMatches++; } } if ($allowMatches == count($testActions)) { //all actions are explicitly allowed return new AllowedResult(true, [], [$this->stateField => $this->regex($this->states)]); } //Permission is neither explicitly allowed or denied. return new AllowedResult; }
[ "public", "function", "areAllowed", "(", "array", "$", "testRoles", ",", "array", "$", "testActions", ")", "{", "//only check allow and deny if there is at least one matching role", "if", "(", "count", "(", "$", "testRoles", ")", "==", "0", ")", "{", "$", "testRoles", "=", "[", "''", "]", ";", "}", "$", "roleMatch", "=", "false", ";", "foreach", "(", "$", "this", "->", "roles", "as", "$", "role", ")", "{", "if", "(", "count", "(", "array_filter", "(", "$", "testRoles", ",", "function", "(", "$", "testRole", ")", "use", "(", "$", "role", ")", "{", "return", "preg_match", "(", "$", "role", ",", "$", "testRole", ")", ";", "}", ")", ")", ">", "0", ")", "{", "$", "roleMatch", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "$", "roleMatch", ")", "{", "//Permission is neither explicitly allowed or denied.", "return", "new", "AllowedResult", ";", "}", "//check allow", "$", "allowMatches", "=", "0", ";", "//check each testAction in turn", "foreach", "(", "$", "testActions", "as", "$", "testAction", ")", "{", "$", "allowMatch", "=", "count", "(", "array_filter", "(", "$", "this", "->", "allow", ",", "function", "(", "$", "action", ")", "use", "(", "$", "testAction", ")", "{", "//first check that action matches at least one allow", "return", "preg_match", "(", "$", "action", ",", "$", "testAction", ")", ";", "}", ")", ")", ">", "0", ";", "$", "denyMatch", "=", "count", "(", "array_filter", "(", "$", "this", "->", "deny", ",", "function", "(", "$", "action", ")", "use", "(", "$", "testAction", ")", "{", "//second check that action does not match any deny", "return", "preg_match", "(", "$", "action", ",", "$", "testAction", ")", ";", "}", ")", ")", ">", "0", ";", "if", "(", "$", "denyMatch", ")", "{", "//one or more actions are explicitly denied", "return", "new", "AllowedResult", "(", "false", ",", "[", "]", ",", "[", "$", "this", "->", "stateField", "=>", "$", "this", "->", "regex", "(", "$", "this", "->", "states", ")", "]", ")", ";", "}", "if", "(", "$", "allowMatch", ")", "{", "$", "allowMatches", "++", ";", "}", "}", "if", "(", "$", "allowMatches", "==", "count", "(", "$", "testActions", ")", ")", "{", "//all actions are explicitly allowed", "return", "new", "AllowedResult", "(", "true", ",", "[", "]", ",", "[", "$", "this", "->", "stateField", "=>", "$", "this", "->", "regex", "(", "$", "this", "->", "states", ")", "]", ")", ";", "}", "//Permission is neither explicitly allowed or denied.", "return", "new", "AllowedResult", ";", "}" ]
Will test if a user with the supplied roles can do ALL the supplied actions. @param array $roles @param array $action @return \Zoop\Shard\AccessControl\IsAllowedResult
[ "Will", "test", "if", "a", "user", "with", "the", "supplied", "roles", "can", "do", "ALL", "the", "supplied", "actions", "." ]
14dde6ff25bc3125ad35667c8ff65cb755750b27
https://github.com/zoopcommerce/shard/blob/14dde6ff25bc3125ad35667c8ff65cb755750b27/lib/Zoop/Shard/State/AccessControl/StatePermission.php#L65-L131
236,689
johanderuijter/mailer
src/Part/SubjectResolver.php
SubjectResolver.resolveSubject
private function resolveSubject(Subject $part) { $subject = $part->getSubject(); foreach ($part->getParameters() as $search => $replace) { $subject = str_replace($search, $replace, $subject); } return $subject; }
php
private function resolveSubject(Subject $part) { $subject = $part->getSubject(); foreach ($part->getParameters() as $search => $replace) { $subject = str_replace($search, $replace, $subject); } return $subject; }
[ "private", "function", "resolveSubject", "(", "Subject", "$", "part", ")", "{", "$", "subject", "=", "$", "part", "->", "getSubject", "(", ")", ";", "foreach", "(", "$", "part", "->", "getParameters", "(", ")", "as", "$", "search", "=>", "$", "replace", ")", "{", "$", "subject", "=", "str_replace", "(", "$", "search", ",", "$", "replace", ",", "$", "subject", ")", ";", "}", "return", "$", "subject", ";", "}" ]
Resolve the subject. @return string
[ "Resolve", "the", "subject", "." ]
5a0cbb7f8be91bb1fc7a4816964dddaff10ac25c
https://github.com/johanderuijter/mailer/blob/5a0cbb7f8be91bb1fc7a4816964dddaff10ac25c/src/Part/SubjectResolver.php#L23-L31
236,690
tux-rampage/rampage-module-installer
src/rampage/composer/ModuleInstaller.php
ModuleInstaller.getModuleName
protected function getModuleName(PackageInterface $package) { $extra = $package->getExtra(); if (isset($extra['modulename'])) { $name = $extra['modulename']; } else { $name = strtr($package->getPrettyName(), array( '\\' => '.', '-' => '.', '_' => '.', ' ' => '' )); } return $name; }
php
protected function getModuleName(PackageInterface $package) { $extra = $package->getExtra(); if (isset($extra['modulename'])) { $name = $extra['modulename']; } else { $name = strtr($package->getPrettyName(), array( '\\' => '.', '-' => '.', '_' => '.', ' ' => '' )); } return $name; }
[ "protected", "function", "getModuleName", "(", "PackageInterface", "$", "package", ")", "{", "$", "extra", "=", "$", "package", "->", "getExtra", "(", ")", ";", "if", "(", "isset", "(", "$", "extra", "[", "'modulename'", "]", ")", ")", "{", "$", "name", "=", "$", "extra", "[", "'modulename'", "]", ";", "}", "else", "{", "$", "name", "=", "strtr", "(", "$", "package", "->", "getPrettyName", "(", ")", ",", "array", "(", "'\\\\'", "=>", "'.'", ",", "'-'", "=>", "'.'", ",", "'_'", "=>", "'.'", ",", "' '", "=>", "''", ")", ")", ";", "}", "return", "$", "name", ";", "}" ]
Get the module name @param PackageInterface $package @return string
[ "Get", "the", "module", "name" ]
0ef87826447ff9b9010356009f295bde31d4a05b
https://github.com/tux-rampage/rampage-module-installer/blob/0ef87826447ff9b9010356009f295bde31d4a05b/src/rampage/composer/ModuleInstaller.php#L86-L102
236,691
Dhii/normalization-helper-base
src/NormalizeIntCapableTrait.php
NormalizeIntCapableTrait._normalizeInt
protected function _normalizeInt($value) { $origValue = $value; if ($value instanceof Stringable) { $value = $this->_normalizeString($value); } if (!is_numeric($value)) { throw $this->_createInvalidArgumentException($this->__('Not a number'), null, null, $origValue); } $value += 0; if (fmod($value, 1) !== 0.00) { throw $this->_createInvalidArgumentException($this->__('Not a whole number'), null, null, $origValue); } $value = (int) $value; return $value; }
php
protected function _normalizeInt($value) { $origValue = $value; if ($value instanceof Stringable) { $value = $this->_normalizeString($value); } if (!is_numeric($value)) { throw $this->_createInvalidArgumentException($this->__('Not a number'), null, null, $origValue); } $value += 0; if (fmod($value, 1) !== 0.00) { throw $this->_createInvalidArgumentException($this->__('Not a whole number'), null, null, $origValue); } $value = (int) $value; return $value; }
[ "protected", "function", "_normalizeInt", "(", "$", "value", ")", "{", "$", "origValue", "=", "$", "value", ";", "if", "(", "$", "value", "instanceof", "Stringable", ")", "{", "$", "value", "=", "$", "this", "->", "_normalizeString", "(", "$", "value", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "value", ")", ")", "{", "throw", "$", "this", "->", "_createInvalidArgumentException", "(", "$", "this", "->", "__", "(", "'Not a number'", ")", ",", "null", ",", "null", ",", "$", "origValue", ")", ";", "}", "$", "value", "+=", "0", ";", "if", "(", "fmod", "(", "$", "value", ",", "1", ")", "!==", "0.00", ")", "{", "throw", "$", "this", "->", "_createInvalidArgumentException", "(", "$", "this", "->", "__", "(", "'Not a whole number'", ")", ",", "null", ",", "null", ",", "$", "origValue", ")", ";", "}", "$", "value", "=", "(", "int", ")", "$", "value", ";", "return", "$", "value", ";", "}" ]
Normalizes a value into an integer. The value must be a whole number, or a string representing such a number, or an object representing such a string. @since [*next-version*] @param string|Stringable|float|int $value The value to normalize. @throws InvalidArgumentException If value cannot be normalized. @return int The normalized value.
[ "Normalizes", "a", "value", "into", "an", "integer", "." ]
1b64f0ea6b3e32f9478f854f6049500795b51da7
https://github.com/Dhii/normalization-helper-base/blob/1b64f0ea6b3e32f9478f854f6049500795b51da7/src/NormalizeIntCapableTrait.php#L30-L50
236,692
DoSomething/stathat-php
src/Client.php
Client.count
public function count($stat_key, $count = 1) { if (! isset($this->config['user_key'])) { throw new Exception('StatHat user key not set.'); } $this->post('c', ['ukey' => $this->config['user_key'], 'key' => $stat_key, 'count' => $count]); }
php
public function count($stat_key, $count = 1) { if (! isset($this->config['user_key'])) { throw new Exception('StatHat user key not set.'); } $this->post('c', ['ukey' => $this->config['user_key'], 'key' => $stat_key, 'count' => $count]); }
[ "public", "function", "count", "(", "$", "stat_key", ",", "$", "count", "=", "1", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'user_key'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'StatHat user key not set.'", ")", ";", "}", "$", "this", "->", "post", "(", "'c'", ",", "[", "'ukey'", "=>", "$", "this", "->", "config", "[", "'user_key'", "]", ",", "'key'", "=>", "$", "stat_key", ",", "'count'", "=>", "$", "count", "]", ")", ";", "}" ]
Increment a counter using the classic API. @see https://www.stathat.com/manual/send#classic @param string $stat_key - Private key identifying the stat @param int $count - Number you want to count @throws \Exception
[ "Increment", "a", "counter", "using", "the", "classic", "API", "." ]
b030fbe81eddfe5e06af142e053af418b8aa549d
https://github.com/DoSomething/stathat-php/blob/b030fbe81eddfe5e06af142e053af418b8aa549d/src/Client.php#L39-L46
236,693
DoSomething/stathat-php
src/Client.php
Client.value
public function value($stat_key, $value) { if (! isset($this->config['user_key'])) { throw new Exception('StatHat user key not set.'); } $this->post('v', ['ukey' => $this->config['user_key'], 'key' => $stat_key, 'value' => $value]); }
php
public function value($stat_key, $value) { if (! isset($this->config['user_key'])) { throw new Exception('StatHat user key not set.'); } $this->post('v', ['ukey' => $this->config['user_key'], 'key' => $stat_key, 'value' => $value]); }
[ "public", "function", "value", "(", "$", "stat_key", ",", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'user_key'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'StatHat user key not set.'", ")", ";", "}", "$", "this", "->", "post", "(", "'v'", ",", "[", "'ukey'", "=>", "$", "this", "->", "config", "[", "'user_key'", "]", ",", "'key'", "=>", "$", "stat_key", ",", "'value'", "=>", "$", "value", "]", ")", ";", "}" ]
Send a value using the classic API. @see https://www.stathat.com/manual/send#classic @param string $stat_key - Private key identifying the stat @param int $value - Value you want to track @throws \Exception
[ "Send", "a", "value", "using", "the", "classic", "API", "." ]
b030fbe81eddfe5e06af142e053af418b8aa549d
https://github.com/DoSomething/stathat-php/blob/b030fbe81eddfe5e06af142e053af418b8aa549d/src/Client.php#L56-L63
236,694
DoSomething/stathat-php
src/Client.php
Client.ezCount
public function ezCount($stat, $count = 1) { if (! isset($this->config['ez_key'])) { throw new Exception('StatHat EZ key not set.'); } // If a prefix is set, prepend it to the stat name. if (! empty($this->config['prefix'])) { $stat = $this->config['prefix'].$stat; } $this->post('ez', ['ezkey' => $this->config['ez_key'], 'stat' => $stat, 'count' => $count]); }
php
public function ezCount($stat, $count = 1) { if (! isset($this->config['ez_key'])) { throw new Exception('StatHat EZ key not set.'); } // If a prefix is set, prepend it to the stat name. if (! empty($this->config['prefix'])) { $stat = $this->config['prefix'].$stat; } $this->post('ez', ['ezkey' => $this->config['ez_key'], 'stat' => $stat, 'count' => $count]); }
[ "public", "function", "ezCount", "(", "$", "stat", ",", "$", "count", "=", "1", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'ez_key'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'StatHat EZ key not set.'", ")", ";", "}", "// If a prefix is set, prepend it to the stat name.", "if", "(", "!", "empty", "(", "$", "this", "->", "config", "[", "'prefix'", "]", ")", ")", "{", "$", "stat", "=", "$", "this", "->", "config", "[", "'prefix'", "]", ".", "$", "stat", ";", "}", "$", "this", "->", "post", "(", "'ez'", ",", "[", "'ezkey'", "=>", "$", "this", "->", "config", "[", "'ez_key'", "]", ",", "'stat'", "=>", "$", "stat", ",", "'count'", "=>", "$", "count", "]", ")", ";", "}" ]
Increment a counter using the EZ API. @see https://www.stathat.com/manual/send#ez @param string $stat - Unique stat name @param int $count - Number you want to count @throws \Exception
[ "Increment", "a", "counter", "using", "the", "EZ", "API", "." ]
b030fbe81eddfe5e06af142e053af418b8aa549d
https://github.com/DoSomething/stathat-php/blob/b030fbe81eddfe5e06af142e053af418b8aa549d/src/Client.php#L73-L85
236,695
DoSomething/stathat-php
src/Client.php
Client.ezValue
public function ezValue($stat, $value) { if (! isset($this->config['ez_key'])) { throw new Exception('StatHat EZ key not set.'); } // If a prefix is set, prepend it to the stat name. if (! empty($this->config['prefix'])) { $stat = $this->config['prefix'].$stat; } $this->post('ez', ['ezkey' => $this->config['ez_key'], 'stat' => $stat, 'value' => $value]); }
php
public function ezValue($stat, $value) { if (! isset($this->config['ez_key'])) { throw new Exception('StatHat EZ key not set.'); } // If a prefix is set, prepend it to the stat name. if (! empty($this->config['prefix'])) { $stat = $this->config['prefix'].$stat; } $this->post('ez', ['ezkey' => $this->config['ez_key'], 'stat' => $stat, 'value' => $value]); }
[ "public", "function", "ezValue", "(", "$", "stat", ",", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'ez_key'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'StatHat EZ key not set.'", ")", ";", "}", "// If a prefix is set, prepend it to the stat name.", "if", "(", "!", "empty", "(", "$", "this", "->", "config", "[", "'prefix'", "]", ")", ")", "{", "$", "stat", "=", "$", "this", "->", "config", "[", "'prefix'", "]", ".", "$", "stat", ";", "}", "$", "this", "->", "post", "(", "'ez'", ",", "[", "'ezkey'", "=>", "$", "this", "->", "config", "[", "'ez_key'", "]", ",", "'stat'", "=>", "$", "stat", ",", "'value'", "=>", "$", "value", "]", ")", ";", "}" ]
Send a value using the EZ API. @see https://www.stathat.com/manual/send#ez @param string $stat - Unique stat name @param int $value - Value you want to track @throws \Exception
[ "Send", "a", "value", "using", "the", "EZ", "API", "." ]
b030fbe81eddfe5e06af142e053af418b8aa549d
https://github.com/DoSomething/stathat-php/blob/b030fbe81eddfe5e06af142e053af418b8aa549d/src/Client.php#L95-L107
236,696
DoSomething/stathat-php
src/Client.php
Client.listAlerts
public function listAlerts() { if (! isset($this->config['access_token'])) { throw new Exception('StatHat Alerts API Access Token not set.'); } $result = $this->deleteAlertCurl('x/'.$this->config['access_token'].'/alerts/'.$alert_id); return $result; }
php
public function listAlerts() { if (! isset($this->config['access_token'])) { throw new Exception('StatHat Alerts API Access Token not set.'); } $result = $this->deleteAlertCurl('x/'.$this->config['access_token'].'/alerts/'.$alert_id); return $result; }
[ "public", "function", "listAlerts", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'access_token'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'StatHat Alerts API Access Token not set.'", ")", ";", "}", "$", "result", "=", "$", "this", "->", "deleteAlertCurl", "(", "'x/'", ".", "$", "this", "->", "config", "[", "'access_token'", "]", ".", "'/alerts/'", ".", "$", "alert_id", ")", ";", "return", "$", "result", ";", "}" ]
List stat alerts using the Alerts API. Used to look up alert IDs of alerts assigned to certain stats. @see https://www.stathat.com/manual/alerts_api @throws \Exception
[ "List", "stat", "alerts", "using", "the", "Alerts", "API", ".", "Used", "to", "look", "up", "alert", "IDs", "of", "alerts", "assigned", "to", "certain", "stats", "." ]
b030fbe81eddfe5e06af142e053af418b8aa549d
https://github.com/DoSomething/stathat-php/blob/b030fbe81eddfe5e06af142e053af418b8aa549d/src/Client.php#L116-L125
236,697
DoSomething/stathat-php
src/Client.php
Client.getAlerts
public function getAlerts() { if (! isset($this->config['access_token'])) { throw new Exception('StatHat Alerts API Access Token not set.'); } $result = $this->curlGet($this->alerts_url.'/x/'.$this->config['access_token'].'/alerts'); return $result; }
php
public function getAlerts() { if (! isset($this->config['access_token'])) { throw new Exception('StatHat Alerts API Access Token not set.'); } $result = $this->curlGet($this->alerts_url.'/x/'.$this->config['access_token'].'/alerts'); return $result; }
[ "public", "function", "getAlerts", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'access_token'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'StatHat Alerts API Access Token not set.'", ")", ";", "}", "$", "result", "=", "$", "this", "->", "curlGet", "(", "$", "this", "->", "alerts_url", ".", "'/x/'", ".", "$", "this", "->", "config", "[", "'access_token'", "]", ".", "'/alerts'", ")", ";", "return", "$", "result", ";", "}" ]
Get listing of all stat alerts using the Alerts API. @see https://www.stathat.com/manual/alerts_api @throws \Exception
[ "Get", "listing", "of", "all", "stat", "alerts", "using", "the", "Alerts", "API", "." ]
b030fbe81eddfe5e06af142e053af418b8aa549d
https://github.com/DoSomething/stathat-php/blob/b030fbe81eddfe5e06af142e053af418b8aa549d/src/Client.php#L133-L142
236,698
DoSomething/stathat-php
src/Client.php
Client.deleteAlert
public function deleteAlert($alert_id) { if (! isset($this->config['access_token'])) { throw new Exception('StatHat Alerts API Access Token not set.'); } $result = $this->curlDelete($this->alerts_url.'/x/'.$this->config['access_token'].'/alerts/'.$alert_id); return $result; }
php
public function deleteAlert($alert_id) { if (! isset($this->config['access_token'])) { throw new Exception('StatHat Alerts API Access Token not set.'); } $result = $this->curlDelete($this->alerts_url.'/x/'.$this->config['access_token'].'/alerts/'.$alert_id); return $result; }
[ "public", "function", "deleteAlert", "(", "$", "alert_id", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "'access_token'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'StatHat Alerts API Access Token not set.'", ")", ";", "}", "$", "result", "=", "$", "this", "->", "curlDelete", "(", "$", "this", "->", "alerts_url", ".", "'/x/'", ".", "$", "this", "->", "config", "[", "'access_token'", "]", ".", "'/alerts/'", ".", "$", "alert_id", ")", ";", "return", "$", "result", ";", "}" ]
Delete a stat alert using the Alerts API. @see https://www.stathat.com/manual/alerts_api @param string $alert_id - Unique id of alert to be deleted @throws \Exception
[ "Delete", "a", "stat", "alert", "using", "the", "Alerts", "API", "." ]
b030fbe81eddfe5e06af142e053af418b8aa549d
https://github.com/DoSomething/stathat-php/blob/b030fbe81eddfe5e06af142e053af418b8aa549d/src/Client.php#L151-L160
236,699
DoSomething/stathat-php
src/Client.php
Client.post
private function post($route = '', array $body = []) { // Don't send requests in debug mode. if ($this->config['debug']) { return; } $contents = http_build_query($body); $parts = parse_url($this->url.'/'.$route); $err_num = null; $err_str = null; $fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $err_num, $err_str, 30); // Y'know back in my day we had to write our HTTP requests by // hand, and uphill both ways. Now these kids with their Guzzles... $out = 'POST '.$parts['path'].' HTTP/1.1'."\r\n"; $out .= 'Host: '.$parts['host']."\r\n"; $out .= 'Content-Type: application/x-www-form-urlencoded'."\r\n"; $out .= 'Content-Length: '.strlen($contents)."\r\n"; $out .= 'Connection: Close'."\r\n\r\n"; if (isset($contents)) { $out .= $contents; } // Fly away, little packet! fwrite($fp, $out); fclose($fp); }
php
private function post($route = '', array $body = []) { // Don't send requests in debug mode. if ($this->config['debug']) { return; } $contents = http_build_query($body); $parts = parse_url($this->url.'/'.$route); $err_num = null; $err_str = null; $fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $err_num, $err_str, 30); // Y'know back in my day we had to write our HTTP requests by // hand, and uphill both ways. Now these kids with their Guzzles... $out = 'POST '.$parts['path'].' HTTP/1.1'."\r\n"; $out .= 'Host: '.$parts['host']."\r\n"; $out .= 'Content-Type: application/x-www-form-urlencoded'."\r\n"; $out .= 'Content-Length: '.strlen($contents)."\r\n"; $out .= 'Connection: Close'."\r\n\r\n"; if (isset($contents)) { $out .= $contents; } // Fly away, little packet! fwrite($fp, $out); fclose($fp); }
[ "private", "function", "post", "(", "$", "route", "=", "''", ",", "array", "$", "body", "=", "[", "]", ")", "{", "// Don't send requests in debug mode.", "if", "(", "$", "this", "->", "config", "[", "'debug'", "]", ")", "{", "return", ";", "}", "$", "contents", "=", "http_build_query", "(", "$", "body", ")", ";", "$", "parts", "=", "parse_url", "(", "$", "this", "->", "url", ".", "'/'", ".", "$", "route", ")", ";", "$", "err_num", "=", "null", ";", "$", "err_str", "=", "null", ";", "$", "fp", "=", "fsockopen", "(", "$", "parts", "[", "'host'", "]", ",", "isset", "(", "$", "parts", "[", "'port'", "]", ")", "?", "$", "parts", "[", "'port'", "]", ":", "80", ",", "$", "err_num", ",", "$", "err_str", ",", "30", ")", ";", "// Y'know back in my day we had to write our HTTP requests by", "// hand, and uphill both ways. Now these kids with their Guzzles...", "$", "out", "=", "'POST '", ".", "$", "parts", "[", "'path'", "]", ".", "' HTTP/1.1'", ".", "\"\\r\\n\"", ";", "$", "out", ".=", "'Host: '", ".", "$", "parts", "[", "'host'", "]", ".", "\"\\r\\n\"", ";", "$", "out", ".=", "'Content-Type: application/x-www-form-urlencoded'", ".", "\"\\r\\n\"", ";", "$", "out", ".=", "'Content-Length: '", ".", "strlen", "(", "$", "contents", ")", ".", "\"\\r\\n\"", ";", "$", "out", ".=", "'Connection: Close'", ".", "\"\\r\\n\\r\\n\"", ";", "if", "(", "isset", "(", "$", "contents", ")", ")", "{", "$", "out", ".=", "$", "contents", ";", "}", "// Fly away, little packet!", "fwrite", "(", "$", "fp", ",", "$", "out", ")", ";", "fclose", "(", "$", "fp", ")", ";", "}" ]
Perform an asynchronous POST request to the given route. @param string $route @param array $body
[ "Perform", "an", "asynchronous", "POST", "request", "to", "the", "given", "route", "." ]
b030fbe81eddfe5e06af142e053af418b8aa549d
https://github.com/DoSomething/stathat-php/blob/b030fbe81eddfe5e06af142e053af418b8aa549d/src/Client.php#L168-L196