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
232,500
Speicher210/Reflection
src/Annotation/TagMapper.php
TagMapper.mapTag
public function mapTag($tag, $class) { if (preg_match('/^[A-Za-z0-9]+$/', $tag) <= 0) { throw new InvalidArgumentException('The name of the tag annotation is invalid.'); } if (in_array('Wingu\OctopusCore\Reflection\Annotation\Tags\TagInterface', class_implements($class)) === false) { throw new InvalidArgumentException('The class "' . $class . '" must implement "' . __NAMESPACE__ . '\Tags\TagInterface".'); } $this->mappedTags[$tag] = $class; return $this; }
php
public function mapTag($tag, $class) { if (preg_match('/^[A-Za-z0-9]+$/', $tag) <= 0) { throw new InvalidArgumentException('The name of the tag annotation is invalid.'); } if (in_array('Wingu\OctopusCore\Reflection\Annotation\Tags\TagInterface', class_implements($class)) === false) { throw new InvalidArgumentException('The class "' . $class . '" must implement "' . __NAMESPACE__ . '\Tags\TagInterface".'); } $this->mappedTags[$tag] = $class; return $this; }
[ "public", "function", "mapTag", "(", "$", "tag", ",", "$", "class", ")", "{", "if", "(", "preg_match", "(", "'/^[A-Za-z0-9]+$/'", ",", "$", "tag", ")", "<=", "0", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'The name of the tag annotation is invalid.'", ")", ";", "}", "if", "(", "in_array", "(", "'Wingu\\OctopusCore\\Reflection\\Annotation\\Tags\\TagInterface'", ",", "class_implements", "(", "$", "class", ")", ")", "===", "false", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'The class \"'", ".", "$", "class", ".", "'\" must implement \"'", ".", "__NAMESPACE__", ".", "'\\Tags\\TagInterface\".'", ")", ";", "}", "$", "this", "->", "mappedTags", "[", "$", "tag", "]", "=", "$", "class", ";", "return", "$", "this", ";", "}" ]
Map an annotation tag to a class. @param string $tag The name of the annotation tag. @param string $class The class name to handle the annotation. It must implement \Wingu\OctopusCore\Reflection\Annotation\Tags\TagInterface. @return \Wingu\OctopusCore\Reflection\Annotation\TagMapper @throws \Wingu\OctopusCore\Reflection\Annotation\Exceptions\InvalidArgumentException If tag is invalid or class doesn't implement TagInterface.
[ "Map", "an", "annotation", "tag", "to", "a", "class", "." ]
3d0f5033077b6a3f47cebbeded6538caeb0a1909
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/Annotation/TagMapper.php#L29-L42
232,501
Speicher210/Reflection
src/Annotation/TagMapper.php
TagMapper.getMappedTag
public function getMappedTag($tag) { if (isset($this->mappedTags[$tag]) === true) { return $this->mappedTags[$tag]; } else { throw new OutOfBoundsException('Annotation tag "' . $tag . '" was not mapped.'); } }
php
public function getMappedTag($tag) { if (isset($this->mappedTags[$tag]) === true) { return $this->mappedTags[$tag]; } else { throw new OutOfBoundsException('Annotation tag "' . $tag . '" was not mapped.'); } }
[ "public", "function", "getMappedTag", "(", "$", "tag", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "mappedTags", "[", "$", "tag", "]", ")", "===", "true", ")", "{", "return", "$", "this", "->", "mappedTags", "[", "$", "tag", "]", ";", "}", "else", "{", "throw", "new", "OutOfBoundsException", "(", "'Annotation tag \"'", ".", "$", "tag", ".", "'\" was not mapped.'", ")", ";", "}", "}" ]
Get the class to handle a specific annotation tag. @param string $tag The name of the annotation tag. @return string @throws \Wingu\OctopusCore\Reflection\Annotation\Exceptions\OutOfBoundsException If the annotation tag was not mapped.
[ "Get", "the", "class", "to", "handle", "a", "specific", "annotation", "tag", "." ]
3d0f5033077b6a3f47cebbeded6538caeb0a1909
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/Annotation/TagMapper.php#L72-L79
232,502
Speicher210/Reflection
src/Annotation/TagMapper.php
TagMapper.mergeTagMapper
public function mergeTagMapper(TagMapper $tagMapper, $overwrite = true) { if ($overwrite === true) { $this->mappedTags = array_merge($this->mappedTags, $tagMapper->getMappedTags()); } else { $this->mappedTags = array_merge($tagMapper->getMappedTags(), $this->mappedTags); } return $this; }
php
public function mergeTagMapper(TagMapper $tagMapper, $overwrite = true) { if ($overwrite === true) { $this->mappedTags = array_merge($this->mappedTags, $tagMapper->getMappedTags()); } else { $this->mappedTags = array_merge($tagMapper->getMappedTags(), $this->mappedTags); } return $this; }
[ "public", "function", "mergeTagMapper", "(", "TagMapper", "$", "tagMapper", ",", "$", "overwrite", "=", "true", ")", "{", "if", "(", "$", "overwrite", "===", "true", ")", "{", "$", "this", "->", "mappedTags", "=", "array_merge", "(", "$", "this", "->", "mappedTags", ",", "$", "tagMapper", "->", "getMappedTags", "(", ")", ")", ";", "}", "else", "{", "$", "this", "->", "mappedTags", "=", "array_merge", "(", "$", "tagMapper", "->", "getMappedTags", "(", ")", ",", "$", "this", "->", "mappedTags", ")", ";", "}", "return", "$", "this", ";", "}" ]
Merge an annotation tag mapper into the current one. @param \Wingu\OctopusCore\Reflection\Annotation\TagMapper $tagMapper The annotations tag mapper to merge. @param boolean $overwrite Flag if the existing found annotations tags should be overwritten. @return \Wingu\OctopusCore\Reflection\Annotation\TagMapper
[ "Merge", "an", "annotation", "tag", "mapper", "into", "the", "current", "one", "." ]
3d0f5033077b6a3f47cebbeded6538caeb0a1909
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/Annotation/TagMapper.php#L88-L97
232,503
Ikimea/Browser
lib/Ikimea/Browser/Browser.php
Browser.reset
public function reset() { $this->_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $this->_browser_name = self::BROWSER_UNKNOWN; $this->_version = self::VERSION_UNKNOWN; $this->_platform = self::PLATFORM_UNKNOWN; $this->_os = self::OPERATING_SYSTEM_UNKNOWN; $this->_is_aol = false; $this->_is_mobile = false; $this->_is_robot = false; $this->_aol_version = self::VERSION_UNKNOWN; }
php
public function reset() { $this->_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $this->_browser_name = self::BROWSER_UNKNOWN; $this->_version = self::VERSION_UNKNOWN; $this->_platform = self::PLATFORM_UNKNOWN; $this->_os = self::OPERATING_SYSTEM_UNKNOWN; $this->_is_aol = false; $this->_is_mobile = false; $this->_is_robot = false; $this->_aol_version = self::VERSION_UNKNOWN; }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "_agent", "=", "isset", "(", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ")", "?", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ":", "''", ";", "$", "this", "->", "_browser_name", "=", "self", "::", "BROWSER_UNKNOWN", ";", "$", "this", "->", "_version", "=", "self", "::", "VERSION_UNKNOWN", ";", "$", "this", "->", "_platform", "=", "self", "::", "PLATFORM_UNKNOWN", ";", "$", "this", "->", "_os", "=", "self", "::", "OPERATING_SYSTEM_UNKNOWN", ";", "$", "this", "->", "_is_aol", "=", "false", ";", "$", "this", "->", "_is_mobile", "=", "false", ";", "$", "this", "->", "_is_robot", "=", "false", ";", "$", "this", "->", "_aol_version", "=", "self", "::", "VERSION_UNKNOWN", ";", "}" ]
Reset all properties.
[ "Reset", "all", "properties", "." ]
774a9b7c5f10c5ae01402994bedaf34dd9a0ccf6
https://github.com/Ikimea/Browser/blob/774a9b7c5f10c5ae01402994bedaf34dd9a0ccf6/lib/Ikimea/Browser/Browser.php#L101-L112
232,504
Ikimea/Browser
lib/Ikimea/Browser/Browser.php
Browser.checkBrowserYandex
protected function checkBrowserYandex() { if (stripos($this->_agent, 'YaBrowser') !== false) { $aresult = explode('/', stristr($this->_agent, 'YaBrowser')); $aversion = explode(' ', $aresult[1]); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_YANDEX); return true; } return false; }
php
protected function checkBrowserYandex() { if (stripos($this->_agent, 'YaBrowser') !== false) { $aresult = explode('/', stristr($this->_agent, 'YaBrowser')); $aversion = explode(' ', $aresult[1]); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_YANDEX); return true; } return false; }
[ "protected", "function", "checkBrowserYandex", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "'YaBrowser'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "$", "this", "->", "_agent", ",", "'YaBrowser'", ")", ")", ";", "$", "aversion", "=", "explode", "(", "' '", ",", "$", "aresult", "[", "1", "]", ")", ";", "$", "this", "->", "setVersion", "(", "$", "aversion", "[", "0", "]", ")", ";", "$", "this", "->", "setBrowser", "(", "self", "::", "BROWSER_YANDEX", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Determine if the browser is Yandex browser or not. @return bool True if the browser is Yandex otherwise false
[ "Determine", "if", "the", "browser", "is", "Yandex", "browser", "or", "not", "." ]
774a9b7c5f10c5ae01402994bedaf34dd9a0ccf6
https://github.com/Ikimea/Browser/blob/774a9b7c5f10c5ae01402994bedaf34dd9a0ccf6/lib/Ikimea/Browser/Browser.php#L403-L415
232,505
Ikimea/Browser
lib/Ikimea/Browser/Browser.php
Browser.checkBrowserEdge
protected function checkBrowserEdge() { if (stripos($this->_agent, 'edge') !== false) { $aresult = explode('/', stristr($this->_agent, 'Edge')); $aversion = explode(' ', $aresult[1]); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_EDGE); return true; } return false; }
php
protected function checkBrowserEdge() { if (stripos($this->_agent, 'edge') !== false) { $aresult = explode('/', stristr($this->_agent, 'Edge')); $aversion = explode(' ', $aresult[1]); $this->setVersion($aversion[0]); $this->setBrowser(self::BROWSER_EDGE); return true; } return false; }
[ "protected", "function", "checkBrowserEdge", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "_agent", ",", "'edge'", ")", "!==", "false", ")", "{", "$", "aresult", "=", "explode", "(", "'/'", ",", "stristr", "(", "$", "this", "->", "_agent", ",", "'Edge'", ")", ")", ";", "$", "aversion", "=", "explode", "(", "' '", ",", "$", "aresult", "[", "1", "]", ")", ";", "$", "this", "->", "setVersion", "(", "$", "aversion", "[", "0", "]", ")", ";", "$", "this", "->", "setBrowser", "(", "self", "::", "BROWSER_EDGE", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Determine if the browser is Microsoft Edge or not @return bool True if the browser is Edge otherwise false
[ "Determine", "if", "the", "browser", "is", "Microsoft", "Edge", "or", "not" ]
774a9b7c5f10c5ae01402994bedaf34dd9a0ccf6
https://github.com/Ikimea/Browser/blob/774a9b7c5f10c5ae01402994bedaf34dd9a0ccf6/lib/Ikimea/Browser/Browser.php#L608-L621
232,506
shawm11/hawk-auth-php
src/Server/UnauthorizedException.php
UnauthorizedException.getWwwAuthenticateHeader
public function getWwwAuthenticateHeader() { $wwwAuthenticateHeader = 'Hawk'; foreach ($this->wwwAuthenticateHeaderAttributes as $key => $value) { $value = $value === null ? '': $value; $wwwAuthenticateHeader .= " $key=\"$value\","; } if ($this->message) { $wwwAuthenticateHeader .= " error=\"$this->message\""; } else { // Remove comma at the end $wwwAuthenticateHeader = rtrim($wwwAuthenticateHeader, ','); } return $wwwAuthenticateHeader; }
php
public function getWwwAuthenticateHeader() { $wwwAuthenticateHeader = 'Hawk'; foreach ($this->wwwAuthenticateHeaderAttributes as $key => $value) { $value = $value === null ? '': $value; $wwwAuthenticateHeader .= " $key=\"$value\","; } if ($this->message) { $wwwAuthenticateHeader .= " error=\"$this->message\""; } else { // Remove comma at the end $wwwAuthenticateHeader = rtrim($wwwAuthenticateHeader, ','); } return $wwwAuthenticateHeader; }
[ "public", "function", "getWwwAuthenticateHeader", "(", ")", "{", "$", "wwwAuthenticateHeader", "=", "'Hawk'", ";", "foreach", "(", "$", "this", "->", "wwwAuthenticateHeaderAttributes", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "value", "=", "$", "value", "===", "null", "?", "''", ":", "$", "value", ";", "$", "wwwAuthenticateHeader", ".=", "\" $key=\\\"$value\\\",\"", ";", "}", "if", "(", "$", "this", "->", "message", ")", "{", "$", "wwwAuthenticateHeader", ".=", "\" error=\\\"$this->message\\\"\"", ";", "}", "else", "{", "// Remove comma at the end", "$", "wwwAuthenticateHeader", "=", "rtrim", "(", "$", "wwwAuthenticateHeader", ",", "','", ")", ";", "}", "return", "$", "wwwAuthenticateHeader", ";", "}" ]
Get the value the HTTP `WWW-Authenticate` header should be set to in the server's response. @return string
[ "Get", "the", "value", "the", "HTTP", "WWW", "-", "Authenticate", "header", "should", "be", "set", "to", "in", "the", "server", "s", "response", "." ]
c3629078a86a65745f8f8ce47a962184da3492bb
https://github.com/shawm11/hawk-auth-php/blob/c3629078a86a65745f8f8ce47a962184da3492bb/src/Server/UnauthorizedException.php#L50-L68
232,507
tricki/laravel-notification
src/Tricki/Notification/Models/AbstractEloquent.php
AbstractEloquent.mapData
public function mapData(array $attributes) { if (!$this->isSuperType) { return $this->newInstance(); } else { if (!isset($attributes[$this->typeField])) { throw new \DomainException($this->typeField . ' not present in the records of a Super Model'); } else { $class = $this->getClass($attributes[$this->typeField]); return new $class; } } }
php
public function mapData(array $attributes) { if (!$this->isSuperType) { return $this->newInstance(); } else { if (!isset($attributes[$this->typeField])) { throw new \DomainException($this->typeField . ' not present in the records of a Super Model'); } else { $class = $this->getClass($attributes[$this->typeField]); return new $class; } } }
[ "public", "function", "mapData", "(", "array", "$", "attributes", ")", "{", "if", "(", "!", "$", "this", "->", "isSuperType", ")", "{", "return", "$", "this", "->", "newInstance", "(", ")", ";", "}", "else", "{", "if", "(", "!", "isset", "(", "$", "attributes", "[", "$", "this", "->", "typeField", "]", ")", ")", "{", "throw", "new", "\\", "DomainException", "(", "$", "this", "->", "typeField", ".", "' not present in the records of a Super Model'", ")", ";", "}", "else", "{", "$", "class", "=", "$", "this", "->", "getClass", "(", "$", "attributes", "[", "$", "this", "->", "typeField", "]", ")", ";", "return", "new", "$", "class", ";", "}", "}", "}" ]
Provide an attributes to object map @return Model
[ "Provide", "an", "attributes", "to", "object", "map" ]
b8b72273e01faaf15f91cc528b4643ceaffd4709
https://github.com/tricki/laravel-notification/blob/b8b72273e01faaf15f91cc528b4643ceaffd4709/src/Tricki/Notification/Models/AbstractEloquent.php#L25-L43
232,508
tricki/laravel-notification
src/Tricki/Notification/Models/AbstractEloquent.php
AbstractEloquent.newFromBuilder
public function newFromBuilder($attributes = array()) { $m = $this->mapData((array) $attributes)->newInstance(array(), true); $m->setRawAttributes((array) $attributes, true); return $m; }
php
public function newFromBuilder($attributes = array()) { $m = $this->mapData((array) $attributes)->newInstance(array(), true); $m->setRawAttributes((array) $attributes, true); return $m; }
[ "public", "function", "newFromBuilder", "(", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "m", "=", "$", "this", "->", "mapData", "(", "(", "array", ")", "$", "attributes", ")", "->", "newInstance", "(", "array", "(", ")", ",", "true", ")", ";", "$", "m", "->", "setRawAttributes", "(", "(", "array", ")", "$", "attributes", ",", "true", ")", ";", "return", "$", "m", ";", "}" ]
Create a new model instance requested by the builder. @param array $attributes @return Illuminate\Database\Eloquent\Model
[ "Create", "a", "new", "model", "instance", "requested", "by", "the", "builder", "." ]
b8b72273e01faaf15f91cc528b4643ceaffd4709
https://github.com/tricki/laravel-notification/blob/b8b72273e01faaf15f91cc528b4643ceaffd4709/src/Tricki/Notification/Models/AbstractEloquent.php#L51-L56
232,509
tricki/laravel-notification
src/Tricki/Notification/Models/AbstractEloquent.php
AbstractEloquent.newQuery
public function newQuery($excludeDeleted = true) { $builder = parent::newQuery($excludeDeleted); if ($this->isSubType()) { $builder->where($this->typeField, $this->getClass($this->typeField)); } return $builder; }
php
public function newQuery($excludeDeleted = true) { $builder = parent::newQuery($excludeDeleted); if ($this->isSubType()) { $builder->where($this->typeField, $this->getClass($this->typeField)); } return $builder; }
[ "public", "function", "newQuery", "(", "$", "excludeDeleted", "=", "true", ")", "{", "$", "builder", "=", "parent", "::", "newQuery", "(", "$", "excludeDeleted", ")", ";", "if", "(", "$", "this", "->", "isSubType", "(", ")", ")", "{", "$", "builder", "->", "where", "(", "$", "this", "->", "typeField", ",", "$", "this", "->", "getClass", "(", "$", "this", "->", "typeField", ")", ")", ";", "}", "return", "$", "builder", ";", "}" ]
Get a new query builder for the model. set any type of scope you want on this builder in a child class, and it'll keep applying the scope on any read-queries on this model @return Reposed\Builder
[ "Get", "a", "new", "query", "builder", "for", "the", "model", ".", "set", "any", "type", "of", "scope", "you", "want", "on", "this", "builder", "in", "a", "child", "class", "and", "it", "ll", "keep", "applying", "the", "scope", "on", "any", "read", "-", "queries", "on", "this", "model" ]
b8b72273e01faaf15f91cc528b4643ceaffd4709
https://github.com/tricki/laravel-notification/blob/b8b72273e01faaf15f91cc528b4643ceaffd4709/src/Tricki/Notification/Models/AbstractEloquent.php#L82-L92
232,510
youngguns-nl/moneybird_php_api
TaxRate/Service.php
Service.getAll
public function getAll($filter = null) { $filters = array('all', 'sales', 'purchase', 'inactive'); if (!in_array($filter, $filters)) { $message = 'Unknown filter "' . $filter . '" for TaxRates'; $message .= '; available filters: ' . implode(', ', $filters); throw new InvalidFilterException($message); } $rates = new ArrayObject; foreach ($this->connector->getAll(__NAMESPACE__) as $rate) { if (($filter == 'inactive' && $rate->active) || ($filter != 'inactive' && !$rate->active)) { continue; } if ($filter == 'sales' && $rate->taxRateType != TaxRate::RATE_TYPE_SALES) { continue; } elseif ($filter == 'purchase' && $rate->taxRateType != TaxRate::RATE_TYPE_PURCHASE) { continue; } $rates->append($rate); } return $rates; }
php
public function getAll($filter = null) { $filters = array('all', 'sales', 'purchase', 'inactive'); if (!in_array($filter, $filters)) { $message = 'Unknown filter "' . $filter . '" for TaxRates'; $message .= '; available filters: ' . implode(', ', $filters); throw new InvalidFilterException($message); } $rates = new ArrayObject; foreach ($this->connector->getAll(__NAMESPACE__) as $rate) { if (($filter == 'inactive' && $rate->active) || ($filter != 'inactive' && !$rate->active)) { continue; } if ($filter == 'sales' && $rate->taxRateType != TaxRate::RATE_TYPE_SALES) { continue; } elseif ($filter == 'purchase' && $rate->taxRateType != TaxRate::RATE_TYPE_PURCHASE) { continue; } $rates->append($rate); } return $rates; }
[ "public", "function", "getAll", "(", "$", "filter", "=", "null", ")", "{", "$", "filters", "=", "array", "(", "'all'", ",", "'sales'", ",", "'purchase'", ",", "'inactive'", ")", ";", "if", "(", "!", "in_array", "(", "$", "filter", ",", "$", "filters", ")", ")", "{", "$", "message", "=", "'Unknown filter \"'", ".", "$", "filter", ".", "'\" for TaxRates'", ";", "$", "message", ".=", "'; available filters: '", ".", "implode", "(", "', '", ",", "$", "filters", ")", ";", "throw", "new", "InvalidFilterException", "(", "$", "message", ")", ";", "}", "$", "rates", "=", "new", "ArrayObject", ";", "foreach", "(", "$", "this", "->", "connector", "->", "getAll", "(", "__NAMESPACE__", ")", "as", "$", "rate", ")", "{", "if", "(", "(", "$", "filter", "==", "'inactive'", "&&", "$", "rate", "->", "active", ")", "||", "(", "$", "filter", "!=", "'inactive'", "&&", "!", "$", "rate", "->", "active", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "filter", "==", "'sales'", "&&", "$", "rate", "->", "taxRateType", "!=", "TaxRate", "::", "RATE_TYPE_SALES", ")", "{", "continue", ";", "}", "elseif", "(", "$", "filter", "==", "'purchase'", "&&", "$", "rate", "->", "taxRateType", "!=", "TaxRate", "::", "RATE_TYPE_PURCHASE", ")", "{", "continue", ";", "}", "$", "rates", "->", "append", "(", "$", "rate", ")", ";", "}", "return", "$", "rates", ";", "}" ]
Get all tax rates @param string $filter Filter name (all, sales, purchase, inactive) @return ArrayObject @throws InvalidFilterException
[ "Get", "all", "tax", "rates" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/TaxRate/Service.php#L37-L59
232,511
funivan/PhpTokenizer
src/Helper.php
Helper.getTokensFromString
public static function getTokensFromString($code) { try { $tokens = token_get_all($code, TOKEN_PARSE); } catch (\ParseError $e) { // with TOKEN_PARSE flag, the function throws on invalid code // let's just ignore the error and tokenize the code without the flag $tokens = token_get_all($code); } foreach ($tokens as $index => $tokenData) { if (!is_array($tokenData)) { $previousIndex = $index - 1; /** @var Token $previousToken */ $previousToken = $tokens[$previousIndex]; $line = $previousToken->getLine() + substr_count($previousToken->getValue(), "\n"); $tokenData = [ Token::INVALID_TYPE, $tokenData, $line, ]; } $token = new Token($tokenData); $token->setIndex($index); $tokens[$index] = $token; } return $tokens; }
php
public static function getTokensFromString($code) { try { $tokens = token_get_all($code, TOKEN_PARSE); } catch (\ParseError $e) { // with TOKEN_PARSE flag, the function throws on invalid code // let's just ignore the error and tokenize the code without the flag $tokens = token_get_all($code); } foreach ($tokens as $index => $tokenData) { if (!is_array($tokenData)) { $previousIndex = $index - 1; /** @var Token $previousToken */ $previousToken = $tokens[$previousIndex]; $line = $previousToken->getLine() + substr_count($previousToken->getValue(), "\n"); $tokenData = [ Token::INVALID_TYPE, $tokenData, $line, ]; } $token = new Token($tokenData); $token->setIndex($index); $tokens[$index] = $token; } return $tokens; }
[ "public", "static", "function", "getTokensFromString", "(", "$", "code", ")", "{", "try", "{", "$", "tokens", "=", "token_get_all", "(", "$", "code", ",", "TOKEN_PARSE", ")", ";", "}", "catch", "(", "\\", "ParseError", "$", "e", ")", "{", "// with TOKEN_PARSE flag, the function throws on invalid code", "// let's just ignore the error and tokenize the code without the flag", "$", "tokens", "=", "token_get_all", "(", "$", "code", ")", ";", "}", "foreach", "(", "$", "tokens", "as", "$", "index", "=>", "$", "tokenData", ")", "{", "if", "(", "!", "is_array", "(", "$", "tokenData", ")", ")", "{", "$", "previousIndex", "=", "$", "index", "-", "1", ";", "/** @var Token $previousToken */", "$", "previousToken", "=", "$", "tokens", "[", "$", "previousIndex", "]", ";", "$", "line", "=", "$", "previousToken", "->", "getLine", "(", ")", "+", "substr_count", "(", "$", "previousToken", "->", "getValue", "(", ")", ",", "\"\\n\"", ")", ";", "$", "tokenData", "=", "[", "Token", "::", "INVALID_TYPE", ",", "$", "tokenData", ",", "$", "line", ",", "]", ";", "}", "$", "token", "=", "new", "Token", "(", "$", "tokenData", ")", ";", "$", "token", "->", "setIndex", "(", "$", "index", ")", ";", "$", "tokens", "[", "$", "index", "]", "=", "$", "token", ";", "}", "return", "$", "tokens", ";", "}" ]
Convert php code to array of tokens @param string $code @return Token[] @throws Exception
[ "Convert", "php", "code", "to", "array", "of", "tokens" ]
f31ec8f1440708518c2a785b3f129f130621e966
https://github.com/funivan/PhpTokenizer/blob/f31ec8f1440708518c2a785b3f129f130621e966/src/Helper.php#L21-L52
232,512
Speicher210/Reflection
src/ReflectionDocCommentTrait.php
ReflectionDocCommentTrait.getReflectionDocComment
public function getReflectionDocComment($trimLinePattern = " \t\n\r\0\x0B") { if ($this->reflectionDocComment === null) { $this->reflectionDocComment = new ReflectionDocComment((string)$this->getDocComment(), $trimLinePattern); } return $this->reflectionDocComment; }
php
public function getReflectionDocComment($trimLinePattern = " \t\n\r\0\x0B") { if ($this->reflectionDocComment === null) { $this->reflectionDocComment = new ReflectionDocComment((string)$this->getDocComment(), $trimLinePattern); } return $this->reflectionDocComment; }
[ "public", "function", "getReflectionDocComment", "(", "$", "trimLinePattern", "=", "\" \\t\\n\\r\\0\\x0B\"", ")", "{", "if", "(", "$", "this", "->", "reflectionDocComment", "===", "null", ")", "{", "$", "this", "->", "reflectionDocComment", "=", "new", "ReflectionDocComment", "(", "(", "string", ")", "$", "this", "->", "getDocComment", "(", ")", ",", "$", "trimLinePattern", ")", ";", "}", "return", "$", "this", "->", "reflectionDocComment", ";", "}" ]
Get the document of the method. @param string $trimLinePattern Pattern for trim() function applied to each line. Usefull to leave spaces or tabs. The default is the same as calling trim() without the argument. @return \Wingu\OctopusCore\Reflection\ReflectionDocComment
[ "Get", "the", "document", "of", "the", "method", "." ]
3d0f5033077b6a3f47cebbeded6538caeb0a1909
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionDocCommentTrait.php#L24-L31
232,513
rezzza/alice-extension
src/Rezzza/AliceExtension/Context/EventSubscriber/HookListener.php
HookListener.beforeFeature
public function beforeFeature(BeforeFeatureTested $event) { if ('feature' !== $this->lifetime) { return; } list($adapter, $fixtureClass) = $this->extractAdapterConfig($event->getFeature()->getTags()); $this->executor->changeAdapter($adapter, $fixtureClass); $this->executor->purge(); }
php
public function beforeFeature(BeforeFeatureTested $event) { if ('feature' !== $this->lifetime) { return; } list($adapter, $fixtureClass) = $this->extractAdapterConfig($event->getFeature()->getTags()); $this->executor->changeAdapter($adapter, $fixtureClass); $this->executor->purge(); }
[ "public", "function", "beforeFeature", "(", "BeforeFeatureTested", "$", "event", ")", "{", "if", "(", "'feature'", "!==", "$", "this", "->", "lifetime", ")", "{", "return", ";", "}", "list", "(", "$", "adapter", ",", "$", "fixtureClass", ")", "=", "$", "this", "->", "extractAdapterConfig", "(", "$", "event", "->", "getFeature", "(", ")", "->", "getTags", "(", ")", ")", ";", "$", "this", "->", "executor", "->", "changeAdapter", "(", "$", "adapter", ",", "$", "fixtureClass", ")", ";", "$", "this", "->", "executor", "->", "purge", "(", ")", ";", "}" ]
Listens to "feature.before" event. @param BeforeFeatureTested $event
[ "Listens", "to", "feature", ".", "before", "event", "." ]
323948e66cff962b209f62b9b528e80d68ff5942
https://github.com/rezzza/alice-extension/blob/323948e66cff962b209f62b9b528e80d68ff5942/src/Rezzza/AliceExtension/Context/EventSubscriber/HookListener.php#L44-L54
232,514
rezzza/alice-extension
src/Rezzza/AliceExtension/Context/EventSubscriber/HookListener.php
HookListener.beforeScenario
public function beforeScenario(BeforeScenarioTested $event) { if ('scenario' !== $this->lifetime) { return; } list($adapter, $fixtureClass) = $this->extractAdapterConfig($event->getFeature()->getTags()); $this->executor->changeAdapter($adapter, $fixtureClass); $this->executor->purge(); }
php
public function beforeScenario(BeforeScenarioTested $event) { if ('scenario' !== $this->lifetime) { return; } list($adapter, $fixtureClass) = $this->extractAdapterConfig($event->getFeature()->getTags()); $this->executor->changeAdapter($adapter, $fixtureClass); $this->executor->purge(); }
[ "public", "function", "beforeScenario", "(", "BeforeScenarioTested", "$", "event", ")", "{", "if", "(", "'scenario'", "!==", "$", "this", "->", "lifetime", ")", "{", "return", ";", "}", "list", "(", "$", "adapter", ",", "$", "fixtureClass", ")", "=", "$", "this", "->", "extractAdapterConfig", "(", "$", "event", "->", "getFeature", "(", ")", "->", "getTags", "(", ")", ")", ";", "$", "this", "->", "executor", "->", "changeAdapter", "(", "$", "adapter", ",", "$", "fixtureClass", ")", ";", "$", "this", "->", "executor", "->", "purge", "(", ")", ";", "}" ]
Listens to "scenario.before" event. @param BeforeScenarioTested $event
[ "Listens", "to", "scenario", ".", "before", "event", "." ]
323948e66cff962b209f62b9b528e80d68ff5942
https://github.com/rezzza/alice-extension/blob/323948e66cff962b209f62b9b528e80d68ff5942/src/Rezzza/AliceExtension/Context/EventSubscriber/HookListener.php#L61-L71
232,515
ARCANEDEV/Robots
src/RobotsServiceProvider.php
RobotsServiceProvider.registerRobotsService
private function registerRobotsService() { $this->app->singleton('arcanedev.robots', Robots::class); $this->app->bind( \Arcanedev\Robots\Contracts\Robots::class, 'arcanedev.robots' ); }
php
private function registerRobotsService() { $this->app->singleton('arcanedev.robots', Robots::class); $this->app->bind( \Arcanedev\Robots\Contracts\Robots::class, 'arcanedev.robots' ); }
[ "private", "function", "registerRobotsService", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'arcanedev.robots'", ",", "Robots", "::", "class", ")", ";", "$", "this", "->", "app", "->", "bind", "(", "\\", "Arcanedev", "\\", "Robots", "\\", "Contracts", "\\", "Robots", "::", "class", ",", "'arcanedev.robots'", ")", ";", "}" ]
Register Robots service.
[ "Register", "Robots", "service", "." ]
ee5b3fdaa44a62d321af1168cb12a3c037dbc98e
https://github.com/ARCANEDEV/Robots/blob/ee5b3fdaa44a62d321af1168cb12a3c037dbc98e/src/RobotsServiceProvider.php#L98-L106
232,516
jack-theripper/transcoder
src/Stream/VideoStream.php
VideoStream.setFrameRate
protected function setFrameRate($frameRate) { if ( ! is_float($frameRate) || $frameRate < 0) { throw new \InvalidArgumentException('Wrong frame rate value.'); } $this->frameRate = $frameRate; return $this; }
php
protected function setFrameRate($frameRate) { if ( ! is_float($frameRate) || $frameRate < 0) { throw new \InvalidArgumentException('Wrong frame rate value.'); } $this->frameRate = $frameRate; return $this; }
[ "protected", "function", "setFrameRate", "(", "$", "frameRate", ")", "{", "if", "(", "!", "is_float", "(", "$", "frameRate", ")", "||", "$", "frameRate", "<", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Wrong frame rate value.'", ")", ";", "}", "$", "this", "->", "frameRate", "=", "$", "frameRate", ";", "return", "$", "this", ";", "}" ]
Set frame rate value. @param float $frameRate @return VideoStreamInterface @throws \InvalidArgumentException
[ "Set", "frame", "rate", "value", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Stream/VideoStream.php#L56-L66
232,517
youngguns-nl/moneybird_php_api
ApiConnector.php
ApiConnector.request
protected function request($url, $method, $data = null) { $this->testLogin(); try { $response = $this->transport->send( $url, $method, $data, array( 'Content-Type: ' . $this->mapper->getContentType(), ) ); } catch (HttpStatusException $e) { $message = $e->getMessage(); if ($e->getCode() == 403 || $e->getCode() == 422) { $this->errors = $this->mapper->mapFromStorage($this->transport->getLastResponse()); if ($this->errors instanceof ErrorArray && count($this->errors) > 0) { $message .= PHP_EOL . 'Errors:' . PHP_EOL . $this->errors; } } if (self::$debug) { printf( 'Url: %s' . PHP_EOL . 'Method: %s' . PHP_EOL . 'Data: %s', $url, $method, $data ); } switch ($e->getCode()) { case 401: throw new NotLoggedInException($message, 0, $e); break; case 403: throw new ForbiddenException($message, 0, $e); break; case 404: throw new NotFoundException($message, 0, $e); break; case 406: case 422: throw new NotValidException($message, 0, $e); break; default: $message = 'Unknown error; check https://github.com/bluetools/moneybird_php_api/wiki/Common-errors'; // no break case 500: case 501: throw new ServerErrorException($message, 0, $e); break; } } return $response; }
php
protected function request($url, $method, $data = null) { $this->testLogin(); try { $response = $this->transport->send( $url, $method, $data, array( 'Content-Type: ' . $this->mapper->getContentType(), ) ); } catch (HttpStatusException $e) { $message = $e->getMessage(); if ($e->getCode() == 403 || $e->getCode() == 422) { $this->errors = $this->mapper->mapFromStorage($this->transport->getLastResponse()); if ($this->errors instanceof ErrorArray && count($this->errors) > 0) { $message .= PHP_EOL . 'Errors:' . PHP_EOL . $this->errors; } } if (self::$debug) { printf( 'Url: %s' . PHP_EOL . 'Method: %s' . PHP_EOL . 'Data: %s', $url, $method, $data ); } switch ($e->getCode()) { case 401: throw new NotLoggedInException($message, 0, $e); break; case 403: throw new ForbiddenException($message, 0, $e); break; case 404: throw new NotFoundException($message, 0, $e); break; case 406: case 422: throw new NotValidException($message, 0, $e); break; default: $message = 'Unknown error; check https://github.com/bluetools/moneybird_php_api/wiki/Common-errors'; // no break case 500: case 501: throw new ServerErrorException($message, 0, $e); break; } } return $response; }
[ "protected", "function", "request", "(", "$", "url", ",", "$", "method", ",", "$", "data", "=", "null", ")", "{", "$", "this", "->", "testLogin", "(", ")", ";", "try", "{", "$", "response", "=", "$", "this", "->", "transport", "->", "send", "(", "$", "url", ",", "$", "method", ",", "$", "data", ",", "array", "(", "'Content-Type: '", ".", "$", "this", "->", "mapper", "->", "getContentType", "(", ")", ",", ")", ")", ";", "}", "catch", "(", "HttpStatusException", "$", "e", ")", "{", "$", "message", "=", "$", "e", "->", "getMessage", "(", ")", ";", "if", "(", "$", "e", "->", "getCode", "(", ")", "==", "403", "||", "$", "e", "->", "getCode", "(", ")", "==", "422", ")", "{", "$", "this", "->", "errors", "=", "$", "this", "->", "mapper", "->", "mapFromStorage", "(", "$", "this", "->", "transport", "->", "getLastResponse", "(", ")", ")", ";", "if", "(", "$", "this", "->", "errors", "instanceof", "ErrorArray", "&&", "count", "(", "$", "this", "->", "errors", ")", ">", "0", ")", "{", "$", "message", ".=", "PHP_EOL", ".", "'Errors:'", ".", "PHP_EOL", ".", "$", "this", "->", "errors", ";", "}", "}", "if", "(", "self", "::", "$", "debug", ")", "{", "printf", "(", "'Url: %s'", ".", "PHP_EOL", ".", "'Method: %s'", ".", "PHP_EOL", ".", "'Data: %s'", ",", "$", "url", ",", "$", "method", ",", "$", "data", ")", ";", "}", "switch", "(", "$", "e", "->", "getCode", "(", ")", ")", "{", "case", "401", ":", "throw", "new", "NotLoggedInException", "(", "$", "message", ",", "0", ",", "$", "e", ")", ";", "break", ";", "case", "403", ":", "throw", "new", "ForbiddenException", "(", "$", "message", ",", "0", ",", "$", "e", ")", ";", "break", ";", "case", "404", ":", "throw", "new", "NotFoundException", "(", "$", "message", ",", "0", ",", "$", "e", ")", ";", "break", ";", "case", "406", ":", "case", "422", ":", "throw", "new", "NotValidException", "(", "$", "message", ",", "0", ",", "$", "e", ")", ";", "break", ";", "default", ":", "$", "message", "=", "'Unknown error; check https://github.com/bluetools/moneybird_php_api/wiki/Common-errors'", ";", "// no break", "case", "500", ":", "case", "501", ":", "throw", "new", "ServerErrorException", "(", "$", "message", ",", "0", ",", "$", "e", ")", ";", "break", ";", "}", "}", "return", "$", "response", ";", "}" ]
Send request to Moneybird @access protected @return string @param string $url @param string $method (GET|POST|PUT|DELETE) @param string $data
[ "Send", "request", "to", "Moneybird" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ApiConnector.php#L200-L249
232,518
youngguns-nl/moneybird_php_api
ApiConnector.php
ApiConnector.send
public function send(Sendable $model, AbstractEnvelope $envelope) { $classname = $this->getType($model); if (intval($model->getId()) == 0) { $model->save($this->getService($classname)); } $response = $this->request( $this->buildUrl($model, null, '/send_' . strtolower($classname)), 'PUT', $this->mapper->mapToStorage($envelope) ); return $this->mapper->mapFromStorage($response); }
php
public function send(Sendable $model, AbstractEnvelope $envelope) { $classname = $this->getType($model); if (intval($model->getId()) == 0) { $model->save($this->getService($classname)); } $response = $this->request( $this->buildUrl($model, null, '/send_' . strtolower($classname)), 'PUT', $this->mapper->mapToStorage($envelope) ); return $this->mapper->mapFromStorage($response); }
[ "public", "function", "send", "(", "Sendable", "$", "model", ",", "AbstractEnvelope", "$", "envelope", ")", "{", "$", "classname", "=", "$", "this", "->", "getType", "(", "$", "model", ")", ";", "if", "(", "intval", "(", "$", "model", "->", "getId", "(", ")", ")", "==", "0", ")", "{", "$", "model", "->", "save", "(", "$", "this", "->", "getService", "(", "$", "classname", ")", ")", ";", "}", "$", "response", "=", "$", "this", "->", "request", "(", "$", "this", "->", "buildUrl", "(", "$", "model", ",", "null", ",", "'/send_'", ".", "strtolower", "(", "$", "classname", ")", ")", ",", "'PUT'", ",", "$", "this", "->", "mapper", "->", "mapToStorage", "(", "$", "envelope", ")", ")", ";", "return", "$", "this", "->", "mapper", "->", "mapFromStorage", "(", "$", "response", ")", ";", "}" ]
Send invoice or estimate @param Sendable $model @param AbstractEnvelope $envelope @return Sendable
[ "Send", "invoice", "or", "estimate" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ApiConnector.php#L298-L311
232,519
youngguns-nl/moneybird_php_api
ApiConnector.php
ApiConnector.getPdf
public function getPdf(PdfDocument $model, AbstractModel $parent = null) { return $this->request($this->buildUrl($model, $parent, null, 'pdf'), 'GET'); }
php
public function getPdf(PdfDocument $model, AbstractModel $parent = null) { return $this->request($this->buildUrl($model, $parent, null, 'pdf'), 'GET'); }
[ "public", "function", "getPdf", "(", "PdfDocument", "$", "model", ",", "AbstractModel", "$", "parent", "=", "null", ")", "{", "return", "$", "this", "->", "request", "(", "$", "this", "->", "buildUrl", "(", "$", "model", ",", "$", "parent", ",", "null", ",", "'pdf'", ")", ",", "'GET'", ")", ";", "}" ]
Get raw PDF content @return string @param PdfDocument $model @param AbstractModel $parent
[ "Get", "raw", "PDF", "content" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ApiConnector.php#L367-L370
232,520
youngguns-nl/moneybird_php_api
ApiConnector.php
ApiConnector.buildUrl
protected function buildUrl(AbstractModel $subject, AbstractModel $parent = null, $appendUrl = null, $docType = null) { if (is_null($docType)) { $docType = substr($this->mapper->getContentType(), strpos($this->mapper->getContentType(), '/') + 1); } $url = $this->baseUri; if (!is_null($parent) && intval($parent->getId()) > 0) { $url .= '/' . $this->mapTypeName($parent) . '/' . $parent->getId(); } $url .= '/' . $this->mapTypeName($subject); if (intval($subject->getId()) > 0) { $url .= '/' . $subject->getId(); } if (!is_null($appendUrl)) { $url .= $appendUrl; } return $url . '.' . $docType; }
php
protected function buildUrl(AbstractModel $subject, AbstractModel $parent = null, $appendUrl = null, $docType = null) { if (is_null($docType)) { $docType = substr($this->mapper->getContentType(), strpos($this->mapper->getContentType(), '/') + 1); } $url = $this->baseUri; if (!is_null($parent) && intval($parent->getId()) > 0) { $url .= '/' . $this->mapTypeName($parent) . '/' . $parent->getId(); } $url .= '/' . $this->mapTypeName($subject); if (intval($subject->getId()) > 0) { $url .= '/' . $subject->getId(); } if (!is_null($appendUrl)) { $url .= $appendUrl; } return $url . '.' . $docType; }
[ "protected", "function", "buildUrl", "(", "AbstractModel", "$", "subject", ",", "AbstractModel", "$", "parent", "=", "null", ",", "$", "appendUrl", "=", "null", ",", "$", "docType", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "docType", ")", ")", "{", "$", "docType", "=", "substr", "(", "$", "this", "->", "mapper", "->", "getContentType", "(", ")", ",", "strpos", "(", "$", "this", "->", "mapper", "->", "getContentType", "(", ")", ",", "'/'", ")", "+", "1", ")", ";", "}", "$", "url", "=", "$", "this", "->", "baseUri", ";", "if", "(", "!", "is_null", "(", "$", "parent", ")", "&&", "intval", "(", "$", "parent", "->", "getId", "(", ")", ")", ">", "0", ")", "{", "$", "url", ".=", "'/'", ".", "$", "this", "->", "mapTypeName", "(", "$", "parent", ")", ".", "'/'", ".", "$", "parent", "->", "getId", "(", ")", ";", "}", "$", "url", ".=", "'/'", ".", "$", "this", "->", "mapTypeName", "(", "$", "subject", ")", ";", "if", "(", "intval", "(", "$", "subject", "->", "getId", "(", ")", ")", ">", "0", ")", "{", "$", "url", ".=", "'/'", ".", "$", "subject", "->", "getId", "(", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "appendUrl", ")", ")", "{", "$", "url", ".=", "$", "appendUrl", ";", "}", "return", "$", "url", ".", "'.'", ".", "$", "docType", ";", "}" ]
Build the url for the request @param AbstractModel $subject @param AbstractModel $parent @param string $appendUrl Filter url @param string $docType (pdf|xml|json) @return string
[ "Build", "the", "url", "for", "the", "request" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ApiConnector.php#L381-L399
232,521
youngguns-nl/moneybird_php_api
ApiConnector.php
ApiConnector.mapTypeName
protected function mapTypeName(AbstractModel $model) { if ($model instanceof CurrentSession) { $mapped = 'current_session'; } else { $classname = $this->getType($model); $mapped = str_replace( array( '\\', 'invoice_History', 'contact_Note', ), array( '_', 'historie', 'note', ), lcfirst($classname) ); if (false !== ($pos = strpos($mapped, '_'))) { $mapped = substr($mapped, 0, $pos); } $mapped = strtolower( preg_replace_callback('/([A-Z])/', array($this, 'classnameToUrlpartCallback'), $mapped) ) . 's'; } return $mapped; }
php
protected function mapTypeName(AbstractModel $model) { if ($model instanceof CurrentSession) { $mapped = 'current_session'; } else { $classname = $this->getType($model); $mapped = str_replace( array( '\\', 'invoice_History', 'contact_Note', ), array( '_', 'historie', 'note', ), lcfirst($classname) ); if (false !== ($pos = strpos($mapped, '_'))) { $mapped = substr($mapped, 0, $pos); } $mapped = strtolower( preg_replace_callback('/([A-Z])/', array($this, 'classnameToUrlpartCallback'), $mapped) ) . 's'; } return $mapped; }
[ "protected", "function", "mapTypeName", "(", "AbstractModel", "$", "model", ")", "{", "if", "(", "$", "model", "instanceof", "CurrentSession", ")", "{", "$", "mapped", "=", "'current_session'", ";", "}", "else", "{", "$", "classname", "=", "$", "this", "->", "getType", "(", "$", "model", ")", ";", "$", "mapped", "=", "str_replace", "(", "array", "(", "'\\\\'", ",", "'invoice_History'", ",", "'contact_Note'", ",", ")", ",", "array", "(", "'_'", ",", "'historie'", ",", "'note'", ",", ")", ",", "lcfirst", "(", "$", "classname", ")", ")", ";", "if", "(", "false", "!==", "(", "$", "pos", "=", "strpos", "(", "$", "mapped", ",", "'_'", ")", ")", ")", "{", "$", "mapped", "=", "substr", "(", "$", "mapped", ",", "0", ",", "$", "pos", ")", ";", "}", "$", "mapped", "=", "strtolower", "(", "preg_replace_callback", "(", "'/([A-Z])/'", ",", "array", "(", "$", "this", ",", "'classnameToUrlpartCallback'", ")", ",", "$", "mapped", ")", ")", ".", "'s'", ";", "}", "return", "$", "mapped", ";", "}" ]
Maps object to an url-part @access protected @param AbstractModel $model @return string
[ "Maps", "object", "to", "an", "url", "-", "part" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ApiConnector.php#L421-L446
232,522
youngguns-nl/moneybird_php_api
ApiConnector.php
ApiConnector.getCurrentSession
public function getCurrentSession() { if (is_null($this->currentSession)) { $this->currentSession = $this->mapper->mapFromStorage( $this->request($this->buildUrl(new CurrentSession()), 'GET') ); } if (!($this->currentSession instanceof CurrentSession)) { $this->currentSession = null; throw new NotLoggedInException('Authorization required'); } return $this->currentSession; }
php
public function getCurrentSession() { if (is_null($this->currentSession)) { $this->currentSession = $this->mapper->mapFromStorage( $this->request($this->buildUrl(new CurrentSession()), 'GET') ); } if (!($this->currentSession instanceof CurrentSession)) { $this->currentSession = null; throw new NotLoggedInException('Authorization required'); } return $this->currentSession; }
[ "public", "function", "getCurrentSession", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "currentSession", ")", ")", "{", "$", "this", "->", "currentSession", "=", "$", "this", "->", "mapper", "->", "mapFromStorage", "(", "$", "this", "->", "request", "(", "$", "this", "->", "buildUrl", "(", "new", "CurrentSession", "(", ")", ")", ",", "'GET'", ")", ")", ";", "}", "if", "(", "!", "(", "$", "this", "->", "currentSession", "instanceof", "CurrentSession", ")", ")", "{", "$", "this", "->", "currentSession", "=", "null", ";", "throw", "new", "NotLoggedInException", "(", "'Authorization required'", ")", ";", "}", "return", "$", "this", "->", "currentSession", ";", "}" ]
Get current session @return CurrentSession
[ "Get", "current", "session" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ApiConnector.php#L465-L477
232,523
youngguns-nl/moneybird_php_api
ApiConnector.php
ApiConnector.getSyncList
public function getSyncList($classname) { $classname = $classname . '\Sync'; $response = $this->request($this->buildUrl(new $classname(), null, '/sync_list_ids'), 'GET'); return $this->mapper->mapFromStorage($response); }
php
public function getSyncList($classname) { $classname = $classname . '\Sync'; $response = $this->request($this->buildUrl(new $classname(), null, '/sync_list_ids'), 'GET'); return $this->mapper->mapFromStorage($response); }
[ "public", "function", "getSyncList", "(", "$", "classname", ")", "{", "$", "classname", "=", "$", "classname", ".", "'\\Sync'", ";", "$", "response", "=", "$", "this", "->", "request", "(", "$", "this", "->", "buildUrl", "(", "new", "$", "classname", "(", ")", ",", "null", ",", "'/sync_list_ids'", ")", ",", "'GET'", ")", ";", "return", "$", "this", "->", "mapper", "->", "mapFromStorage", "(", "$", "response", ")", ";", "}" ]
Get sync status @param string $classname @return ArrayObject
[ "Get", "sync", "status" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ApiConnector.php#L485-L490
232,524
youngguns-nl/moneybird_php_api
ApiConnector.php
ApiConnector.getById
public function getById($classname, $id) { if (!preg_match('/^[0-9]+$/D', $id)) { throw new InvalidIdException('Invalid id: ' . $id); } $response = $this->request($this->buildUrl(new $classname(array('id' => $id))), 'GET'); return $this->mapper->mapFromStorage($response); }
php
public function getById($classname, $id) { if (!preg_match('/^[0-9]+$/D', $id)) { throw new InvalidIdException('Invalid id: ' . $id); } $response = $this->request($this->buildUrl(new $classname(array('id' => $id))), 'GET'); return $this->mapper->mapFromStorage($response); }
[ "public", "function", "getById", "(", "$", "classname", ",", "$", "id", ")", "{", "if", "(", "!", "preg_match", "(", "'/^[0-9]+$/D'", ",", "$", "id", ")", ")", "{", "throw", "new", "InvalidIdException", "(", "'Invalid id: '", ".", "$", "id", ")", ";", "}", "$", "response", "=", "$", "this", "->", "request", "(", "$", "this", "->", "buildUrl", "(", "new", "$", "classname", "(", "array", "(", "'id'", "=>", "$", "id", ")", ")", ")", ",", "'GET'", ")", ";", "return", "$", "this", "->", "mapper", "->", "mapFromStorage", "(", "$", "response", ")", ";", "}" ]
Get object by id @param string $classname @param int $id @return AbstractModel
[ "Get", "object", "by", "id" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ApiConnector.php#L519-L526
232,525
youngguns-nl/moneybird_php_api
ApiConnector.php
ApiConnector.getAll
public function getAll($classname, $filter = null, AbstractModel $parent = null) { $filterUrl = ''; if (!is_null($filter)) { if ( isset($this->filters[$classname]) && in_array($filter, $this->filters[$classname])) { $filterUrl = '/filter/' . $filter; } elseif ( isset($this->filters[$classname]) && preg_match('/^[0-9]+$/D', $filter)) { $filterUrl = '/filter/' . $filter; } else { $message = 'Unknown filter "' . $filter . '" for ' . $classname; if (isset($this->filters[$classname])) { $message .= '; available filters: ' . implode(', ', $this->filters[$classname]); } throw new InvalidFilterException($message); } } $response = $this->request($this->buildUrl(new $classname(), $parent, $filterUrl), 'GET'); return $this->mapper->mapFromStorage($response); }
php
public function getAll($classname, $filter = null, AbstractModel $parent = null) { $filterUrl = ''; if (!is_null($filter)) { if ( isset($this->filters[$classname]) && in_array($filter, $this->filters[$classname])) { $filterUrl = '/filter/' . $filter; } elseif ( isset($this->filters[$classname]) && preg_match('/^[0-9]+$/D', $filter)) { $filterUrl = '/filter/' . $filter; } else { $message = 'Unknown filter "' . $filter . '" for ' . $classname; if (isset($this->filters[$classname])) { $message .= '; available filters: ' . implode(', ', $this->filters[$classname]); } throw new InvalidFilterException($message); } } $response = $this->request($this->buildUrl(new $classname(), $parent, $filterUrl), 'GET'); return $this->mapper->mapFromStorage($response); }
[ "public", "function", "getAll", "(", "$", "classname", ",", "$", "filter", "=", "null", ",", "AbstractModel", "$", "parent", "=", "null", ")", "{", "$", "filterUrl", "=", "''", ";", "if", "(", "!", "is_null", "(", "$", "filter", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "filters", "[", "$", "classname", "]", ")", "&&", "in_array", "(", "$", "filter", ",", "$", "this", "->", "filters", "[", "$", "classname", "]", ")", ")", "{", "$", "filterUrl", "=", "'/filter/'", ".", "$", "filter", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "filters", "[", "$", "classname", "]", ")", "&&", "preg_match", "(", "'/^[0-9]+$/D'", ",", "$", "filter", ")", ")", "{", "$", "filterUrl", "=", "'/filter/'", ".", "$", "filter", ";", "}", "else", "{", "$", "message", "=", "'Unknown filter \"'", ".", "$", "filter", ".", "'\" for '", ".", "$", "classname", ";", "if", "(", "isset", "(", "$", "this", "->", "filters", "[", "$", "classname", "]", ")", ")", "{", "$", "message", ".=", "'; available filters: '", ".", "implode", "(", "', '", ",", "$", "this", "->", "filters", "[", "$", "classname", "]", ")", ";", "}", "throw", "new", "InvalidFilterException", "(", "$", "message", ")", ";", "}", "}", "$", "response", "=", "$", "this", "->", "request", "(", "$", "this", "->", "buildUrl", "(", "new", "$", "classname", "(", ")", ",", "$", "parent", ",", "$", "filterUrl", ")", ",", "'GET'", ")", ";", "return", "$", "this", "->", "mapper", "->", "mapFromStorage", "(", "$", "response", ")", ";", "}" ]
Get all objects @param string $classname @param string|integer $filter Filter name or id (advanced filters) @param AbstractModel $parent @return ArrayObject @throws InvalidFilterException
[ "Get", "all", "objects" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ApiConnector.php#L537-L562
232,526
youngguns-nl/moneybird_php_api
ApiConnector.php
ApiConnector.getService
public function getService($type) { if (!isset($this->services[$type])) { if (!file_exists(__DIR__ . '/' . $type . '/Service.php')) { throw new InvalidServiceTypeException('No service for type ' . $type); } $classname = __NAMESPACE__ . '\\' . $type . '\Service'; $this->services[$type] = new $classname($this); } return $this->services[$type]; }
php
public function getService($type) { if (!isset($this->services[$type])) { if (!file_exists(__DIR__ . '/' . $type . '/Service.php')) { throw new InvalidServiceTypeException('No service for type ' . $type); } $classname = __NAMESPACE__ . '\\' . $type . '\Service'; $this->services[$type] = new $classname($this); } return $this->services[$type]; }
[ "public", "function", "getService", "(", "$", "type", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "services", "[", "$", "type", "]", ")", ")", "{", "if", "(", "!", "file_exists", "(", "__DIR__", ".", "'/'", ".", "$", "type", ".", "'/Service.php'", ")", ")", "{", "throw", "new", "InvalidServiceTypeException", "(", "'No service for type '", ".", "$", "type", ")", ";", "}", "$", "classname", "=", "__NAMESPACE__", ".", "'\\\\'", ".", "$", "type", ".", "'\\Service'", ";", "$", "this", "->", "services", "[", "$", "type", "]", "=", "new", "$", "classname", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "services", "[", "$", "type", "]", ";", "}" ]
Build a service object for contacts, invoices, etc @param string $type @return Service
[ "Build", "a", "service", "object", "for", "contacts", "invoices", "etc" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ApiConnector.php#L642-L652
232,527
youngguns-nl/moneybird_php_api
ApiConnector.php
ApiConnector.hasService
public function hasService($type) { if (!isset($this->services[$type])) { if (!file_exists(__DIR__.'/'.$type.'/Service.php')) { return false; } } return true; }
php
public function hasService($type) { if (!isset($this->services[$type])) { if (!file_exists(__DIR__.'/'.$type.'/Service.php')) { return false; } } return true; }
[ "public", "function", "hasService", "(", "$", "type", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "services", "[", "$", "type", "]", ")", ")", "{", "if", "(", "!", "file_exists", "(", "__DIR__", ".", "'/'", ".", "$", "type", ".", "'/Service.php'", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if service name is a valid service @param string $type @return boolean
[ "Checks", "if", "service", "name", "is", "a", "valid", "service" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ApiConnector.php#L659-L667
232,528
jack-theripper/transcoder
src/Service/Encoder.php
Encoder.resolveOptions
protected function resolveOptions(array $options) { $options += [ 'ffmpeg.path' => 'ffmpeg', 'ffmpeg.threads' => 0, 'timeout' => 0 ]; if ( ! file_exists($options['ffmpeg.path']) || ! is_executable($options['ffmpeg.path'])) { $options['ffmpeg.path'] = (new ExecutableFinder())->find('ffmpeg', false); if ( ! $options['ffmpeg.path']) { throw new ExecutableNotFoundException('Executable not found, proposed ffmpeg', 'ffmpeg'); } } return $options; }
php
protected function resolveOptions(array $options) { $options += [ 'ffmpeg.path' => 'ffmpeg', 'ffmpeg.threads' => 0, 'timeout' => 0 ]; if ( ! file_exists($options['ffmpeg.path']) || ! is_executable($options['ffmpeg.path'])) { $options['ffmpeg.path'] = (new ExecutableFinder())->find('ffmpeg', false); if ( ! $options['ffmpeg.path']) { throw new ExecutableNotFoundException('Executable not found, proposed ffmpeg', 'ffmpeg'); } } return $options; }
[ "protected", "function", "resolveOptions", "(", "array", "$", "options", ")", "{", "$", "options", "+=", "[", "'ffmpeg.path'", "=>", "'ffmpeg'", ",", "'ffmpeg.threads'", "=>", "0", ",", "'timeout'", "=>", "0", "]", ";", "if", "(", "!", "file_exists", "(", "$", "options", "[", "'ffmpeg.path'", "]", ")", "||", "!", "is_executable", "(", "$", "options", "[", "'ffmpeg.path'", "]", ")", ")", "{", "$", "options", "[", "'ffmpeg.path'", "]", "=", "(", "new", "ExecutableFinder", "(", ")", ")", "->", "find", "(", "'ffmpeg'", ",", "false", ")", ";", "if", "(", "!", "$", "options", "[", "'ffmpeg.path'", "]", ")", "{", "throw", "new", "ExecutableNotFoundException", "(", "'Executable not found, proposed ffmpeg'", ",", "'ffmpeg'", ")", ";", "}", "}", "return", "$", "options", ";", "}" ]
The options processing. @param array $options @return array @throws \Arhitector\Transcoder\Exception\ExecutableNotFoundException
[ "The", "options", "processing", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Service/Encoder.php#L244-L263
232,529
jack-theripper/transcoder
src/Service/Encoder.php
Encoder.resolveOptionsAlias
protected function resolveOptionsAlias(array $options) { $haystack = array_diff_key($options, $this->getAliasOptions() + ['output' => null]); foreach ($this->getAliasOptions() as $option => $value) { if (isset($options[$option])) { $haystack[$value] = $options[$option]; if (is_bool($options[$option])) { $haystack[$value] = ''; } } } return $haystack; }
php
protected function resolveOptionsAlias(array $options) { $haystack = array_diff_key($options, $this->getAliasOptions() + ['output' => null]); foreach ($this->getAliasOptions() as $option => $value) { if (isset($options[$option])) { $haystack[$value] = $options[$option]; if (is_bool($options[$option])) { $haystack[$value] = ''; } } } return $haystack; }
[ "protected", "function", "resolveOptionsAlias", "(", "array", "$", "options", ")", "{", "$", "haystack", "=", "array_diff_key", "(", "$", "options", ",", "$", "this", "->", "getAliasOptions", "(", ")", "+", "[", "'output'", "=>", "null", "]", ")", ";", "foreach", "(", "$", "this", "->", "getAliasOptions", "(", ")", "as", "$", "option", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "$", "option", "]", ")", ")", "{", "$", "haystack", "[", "$", "value", "]", "=", "$", "options", "[", "$", "option", "]", ";", "if", "(", "is_bool", "(", "$", "options", "[", "$", "option", "]", ")", ")", "{", "$", "haystack", "[", "$", "value", "]", "=", "''", ";", "}", "}", "}", "return", "$", "haystack", ";", "}" ]
Returns the options without aliases. @param array $options @return array
[ "Returns", "the", "options", "without", "aliases", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Service/Encoder.php#L272-L290
232,530
jack-theripper/transcoder
src/Service/Encoder.php
Encoder.getFormatOptions
protected function getFormatOptions(FormatInterface $format) { $options = $format->getOptions(); if ($format instanceof AudioFormatInterface) { $options['audio_codec'] = (string) $format->getAudioCodec() ?: 'copy'; if ($format->getAudioBitrate() > 0) { $options['audio_bitrate'] = $format->getAudioBitrate(); } if ($format->getFrequency() > 0) { $options['audio_sample_frequency'] = $format->getFrequency(); } if ($format->getChannels() > 0) { $options['audio_channels'] = $format->getChannels(); } } if ($format instanceof FrameFormatInterface) { $options['video_codec'] = (string) $format->getVideoCodec() ?: 'copy'; } if ($format instanceof VideoFormatInterface) { if ($format->getFrameRate() > 0) { $options['video_frame_rate'] = $format->getFrameRate(); } if ($format->getVideoBitrate() > 0) { $options['video_bitrate'] = $format->getVideoBitrate(); } $options['movflags'] = '+faststart'; } return $options; }
php
protected function getFormatOptions(FormatInterface $format) { $options = $format->getOptions(); if ($format instanceof AudioFormatInterface) { $options['audio_codec'] = (string) $format->getAudioCodec() ?: 'copy'; if ($format->getAudioBitrate() > 0) { $options['audio_bitrate'] = $format->getAudioBitrate(); } if ($format->getFrequency() > 0) { $options['audio_sample_frequency'] = $format->getFrequency(); } if ($format->getChannels() > 0) { $options['audio_channels'] = $format->getChannels(); } } if ($format instanceof FrameFormatInterface) { $options['video_codec'] = (string) $format->getVideoCodec() ?: 'copy'; } if ($format instanceof VideoFormatInterface) { if ($format->getFrameRate() > 0) { $options['video_frame_rate'] = $format->getFrameRate(); } if ($format->getVideoBitrate() > 0) { $options['video_bitrate'] = $format->getVideoBitrate(); } $options['movflags'] = '+faststart'; } return $options; }
[ "protected", "function", "getFormatOptions", "(", "FormatInterface", "$", "format", ")", "{", "$", "options", "=", "$", "format", "->", "getOptions", "(", ")", ";", "if", "(", "$", "format", "instanceof", "AudioFormatInterface", ")", "{", "$", "options", "[", "'audio_codec'", "]", "=", "(", "string", ")", "$", "format", "->", "getAudioCodec", "(", ")", "?", ":", "'copy'", ";", "if", "(", "$", "format", "->", "getAudioBitrate", "(", ")", ">", "0", ")", "{", "$", "options", "[", "'audio_bitrate'", "]", "=", "$", "format", "->", "getAudioBitrate", "(", ")", ";", "}", "if", "(", "$", "format", "->", "getFrequency", "(", ")", ">", "0", ")", "{", "$", "options", "[", "'audio_sample_frequency'", "]", "=", "$", "format", "->", "getFrequency", "(", ")", ";", "}", "if", "(", "$", "format", "->", "getChannels", "(", ")", ">", "0", ")", "{", "$", "options", "[", "'audio_channels'", "]", "=", "$", "format", "->", "getChannels", "(", ")", ";", "}", "}", "if", "(", "$", "format", "instanceof", "FrameFormatInterface", ")", "{", "$", "options", "[", "'video_codec'", "]", "=", "(", "string", ")", "$", "format", "->", "getVideoCodec", "(", ")", "?", ":", "'copy'", ";", "}", "if", "(", "$", "format", "instanceof", "VideoFormatInterface", ")", "{", "if", "(", "$", "format", "->", "getFrameRate", "(", ")", ">", "0", ")", "{", "$", "options", "[", "'video_frame_rate'", "]", "=", "$", "format", "->", "getFrameRate", "(", ")", ";", "}", "if", "(", "$", "format", "->", "getVideoBitrate", "(", ")", ">", "0", ")", "{", "$", "options", "[", "'video_bitrate'", "]", "=", "$", "format", "->", "getVideoBitrate", "(", ")", ";", "}", "$", "options", "[", "'movflags'", "]", "=", "'+faststart'", ";", "}", "return", "$", "options", ";", "}" ]
Get options for format. @param FormatInterface $format @return array
[ "Get", "options", "for", "format", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Service/Encoder.php#L331-L376
232,531
praxisnetau/silverstripe-moderno-admin
code/extensions/CMSMainEditFormExtension.php
CMSMainEditFormExtension.updateEditForm
public function updateEditForm($form) { if ($this->isAssetAdmin() && $this->hasSecureAssets()) { if (($record = $form->getRecord()) && $record instanceof Folder) { if ($field = $form->Fields()->dataFieldByName('ViewerGroups')) { // Create Form Object: $dummy = Form::create( $this->owner, 'EditForm', FieldList::create(), FieldList::create() ); // Populate Form Data: $dummy->loadDataFrom($record); // Define Form Action (allows ViewerGroups field to work in asset EditForm): $dummy->setFormAction( sprintf( '%s/field/File/item/%d/ItemEditForm', $form->FormAction(), $record->ID ) ); // Update Field Object: $field->setForm($dummy); } } } }
php
public function updateEditForm($form) { if ($this->isAssetAdmin() && $this->hasSecureAssets()) { if (($record = $form->getRecord()) && $record instanceof Folder) { if ($field = $form->Fields()->dataFieldByName('ViewerGroups')) { // Create Form Object: $dummy = Form::create( $this->owner, 'EditForm', FieldList::create(), FieldList::create() ); // Populate Form Data: $dummy->loadDataFrom($record); // Define Form Action (allows ViewerGroups field to work in asset EditForm): $dummy->setFormAction( sprintf( '%s/field/File/item/%d/ItemEditForm', $form->FormAction(), $record->ID ) ); // Update Field Object: $field->setForm($dummy); } } } }
[ "public", "function", "updateEditForm", "(", "$", "form", ")", "{", "if", "(", "$", "this", "->", "isAssetAdmin", "(", ")", "&&", "$", "this", "->", "hasSecureAssets", "(", ")", ")", "{", "if", "(", "(", "$", "record", "=", "$", "form", "->", "getRecord", "(", ")", ")", "&&", "$", "record", "instanceof", "Folder", ")", "{", "if", "(", "$", "field", "=", "$", "form", "->", "Fields", "(", ")", "->", "dataFieldByName", "(", "'ViewerGroups'", ")", ")", "{", "// Create Form Object:", "$", "dummy", "=", "Form", "::", "create", "(", "$", "this", "->", "owner", ",", "'EditForm'", ",", "FieldList", "::", "create", "(", ")", ",", "FieldList", "::", "create", "(", ")", ")", ";", "// Populate Form Data:", "$", "dummy", "->", "loadDataFrom", "(", "$", "record", ")", ";", "// Define Form Action (allows ViewerGroups field to work in asset EditForm):", "$", "dummy", "->", "setFormAction", "(", "sprintf", "(", "'%s/field/File/item/%d/ItemEditForm'", ",", "$", "form", "->", "FormAction", "(", ")", ",", "$", "record", "->", "ID", ")", ")", ";", "// Update Field Object:", "$", "field", "->", "setForm", "(", "$", "dummy", ")", ";", "}", "}", "}", "}" ]
Updates the edit form object from AssetAdmin to provide a workaround for a bug in Secure Assets. @param Form $form
[ "Updates", "the", "edit", "form", "object", "from", "AssetAdmin", "to", "provide", "a", "workaround", "for", "a", "bug", "in", "Secure", "Assets", "." ]
8e09b43ca84eea6d3d556fe0f459860c2a397703
https://github.com/praxisnetau/silverstripe-moderno-admin/blob/8e09b43ca84eea6d3d556fe0f459860c2a397703/code/extensions/CMSMainEditFormExtension.php#L27-L67
232,532
linkorb/buckaroo
src/LinkORB/Buckaroo/SoapClientWSSEC.php
SoapClientWSSEC.GetReference
private function GetReference($ID, $xPath) { $query = '//*[@Id="'.$ID.'"]'; $nodeset = $xPath->query($query); $Object = $nodeset->item(0); return $Object; }
php
private function GetReference($ID, $xPath) { $query = '//*[@Id="'.$ID.'"]'; $nodeset = $xPath->query($query); $Object = $nodeset->item(0); return $Object; }
[ "private", "function", "GetReference", "(", "$", "ID", ",", "$", "xPath", ")", "{", "$", "query", "=", "'//*[@Id=\"'", ".", "$", "ID", ".", "'\"]'", ";", "$", "nodeset", "=", "$", "xPath", "->", "query", "(", "$", "query", ")", ";", "$", "Object", "=", "$", "nodeset", "->", "item", "(", "0", ")", ";", "return", "$", "Object", ";", "}" ]
Get nodeset based on xpath and ID
[ "Get", "nodeset", "based", "on", "xpath", "and", "ID" ]
bbc66743c55c7d5b6eb5d7ad981ac08de5b5d08a
https://github.com/linkorb/buckaroo/blob/bbc66743c55c7d5b6eb5d7ad981ac08de5b5d08a/src/LinkORB/Buckaroo/SoapClientWSSEC.php#L115-L121
232,533
chippyash/Builder-Pattern
src/Chippyash/BuilderPattern/AbstractDirector.php
AbstractDirector.build
public function build() { $this->modifyPreBuild(); if (!$this->builder->build()) { throw new BuilderPatternException('Unable to build'); } $this->modifyPostBuild(); return $this->renderer->render($this->builder); }
php
public function build() { $this->modifyPreBuild(); if (!$this->builder->build()) { throw new BuilderPatternException('Unable to build'); } $this->modifyPostBuild(); return $this->renderer->render($this->builder); }
[ "public", "function", "build", "(", ")", "{", "$", "this", "->", "modifyPreBuild", "(", ")", ";", "if", "(", "!", "$", "this", "->", "builder", "->", "build", "(", ")", ")", "{", "throw", "new", "BuilderPatternException", "(", "'Unable to build'", ")", ";", "}", "$", "this", "->", "modifyPostBuild", "(", ")", ";", "return", "$", "this", "->", "renderer", "->", "render", "(", "$", "this", "->", "builder", ")", ";", "}" ]
Build and render @return mixed Depends on rendering @throws \Chippyash\BuilderPattern\Exceptions\BuilderPatternException
[ "Build", "and", "render" ]
00be4830438542abe494ac9be0bbd27723a0c984
https://github.com/chippyash/Builder-Pattern/blob/00be4830438542abe494ac9be0bbd27723a0c984/src/Chippyash/BuilderPattern/AbstractDirector.php#L73-L82
232,534
chippyash/Builder-Pattern
src/Chippyash/BuilderPattern/AbstractDirector.php
AbstractDirector.setModifier
public function setModifier(EventManagerAwareInterface $modifier) { $this->modifier = $modifier; $this->builder->setModifier($modifier); return $this; }
php
public function setModifier(EventManagerAwareInterface $modifier) { $this->modifier = $modifier; $this->builder->setModifier($modifier); return $this; }
[ "public", "function", "setModifier", "(", "EventManagerAwareInterface", "$", "modifier", ")", "{", "$", "this", "->", "modifier", "=", "$", "modifier", ";", "$", "this", "->", "builder", "->", "setModifier", "(", "$", "modifier", ")", ";", "return", "$", "this", ";", "}" ]
Set the builder modifier if required @param EventManagerAwareInterface $modifier @return Chippyash\BuilderPattern\AbstractDirector Fluent Interface
[ "Set", "the", "builder", "modifier", "if", "required" ]
00be4830438542abe494ac9be0bbd27723a0c984
https://github.com/chippyash/Builder-Pattern/blob/00be4830438542abe494ac9be0bbd27723a0c984/src/Chippyash/BuilderPattern/AbstractDirector.php#L91-L97
232,535
chippyash/Builder-Pattern
src/Chippyash/BuilderPattern/AbstractDirector.php
AbstractDirector.modifyPreBuild
protected function modifyPreBuild() { foreach ($this->modifications[ModifiableInterface::PHASE_PRE_BUILD] as $mod) { $this->modify($mod, ModifiableInterface::PHASE_PRE_BUILD); } }
php
protected function modifyPreBuild() { foreach ($this->modifications[ModifiableInterface::PHASE_PRE_BUILD] as $mod) { $this->modify($mod, ModifiableInterface::PHASE_PRE_BUILD); } }
[ "protected", "function", "modifyPreBuild", "(", ")", "{", "foreach", "(", "$", "this", "->", "modifications", "[", "ModifiableInterface", "::", "PHASE_PRE_BUILD", "]", "as", "$", "mod", ")", "{", "$", "this", "->", "modify", "(", "$", "mod", ",", "ModifiableInterface", "::", "PHASE_PRE_BUILD", ")", ";", "}", "}" ]
Fire event triggers for pre build modifications
[ "Fire", "event", "triggers", "for", "pre", "build", "modifications" ]
00be4830438542abe494ac9be0bbd27723a0c984
https://github.com/chippyash/Builder-Pattern/blob/00be4830438542abe494ac9be0bbd27723a0c984/src/Chippyash/BuilderPattern/AbstractDirector.php#L142-L147
232,536
chippyash/Builder-Pattern
src/Chippyash/BuilderPattern/AbstractDirector.php
AbstractDirector.modifyPostBuild
protected function modifyPostBuild() { foreach ($this->modifications[ModifiableInterface::PHASE_POST_BUILD] as $mod) { $this->modify($mod); } }
php
protected function modifyPostBuild() { foreach ($this->modifications[ModifiableInterface::PHASE_POST_BUILD] as $mod) { $this->modify($mod); } }
[ "protected", "function", "modifyPostBuild", "(", ")", "{", "foreach", "(", "$", "this", "->", "modifications", "[", "ModifiableInterface", "::", "PHASE_POST_BUILD", "]", "as", "$", "mod", ")", "{", "$", "this", "->", "modify", "(", "$", "mod", ")", ";", "}", "}" ]
Fire event triggers for post build modifications
[ "Fire", "event", "triggers", "for", "post", "build", "modifications" ]
00be4830438542abe494ac9be0bbd27723a0c984
https://github.com/chippyash/Builder-Pattern/blob/00be4830438542abe494ac9be0bbd27723a0c984/src/Chippyash/BuilderPattern/AbstractDirector.php#L152-L157
232,537
jack-theripper/transcoder
src/Stream/Collection.php
Collection.offsetSet
public function offsetSet($index, $value) { if ( ! $value instanceof StreamInterface) { throw new TranscoderException(sprintf('The new value must be an instance of %s', StreamInterface::class)); } $this->streams[$index ?: $this->count()] = $value; return $this; }
php
public function offsetSet($index, $value) { if ( ! $value instanceof StreamInterface) { throw new TranscoderException(sprintf('The new value must be an instance of %s', StreamInterface::class)); } $this->streams[$index ?: $this->count()] = $value; return $this; }
[ "public", "function", "offsetSet", "(", "$", "index", ",", "$", "value", ")", "{", "if", "(", "!", "$", "value", "instanceof", "StreamInterface", ")", "{", "throw", "new", "TranscoderException", "(", "sprintf", "(", "'The new value must be an instance of %s'", ",", "StreamInterface", "::", "class", ")", ")", ";", "}", "$", "this", "->", "streams", "[", "$", "index", "?", ":", "$", "this", "->", "count", "(", ")", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Sets a new stream instance at a specified index. @param int $index The index being set. @param StreamInterface $value The new value for the index. @return Collection @throws TranscoderException
[ "Sets", "a", "new", "stream", "instance", "at", "a", "specified", "index", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Stream/Collection.php#L168-L178
232,538
funivan/PhpTokenizer
src/File.php
File.save
public function save() { if (!$this->isChanged()) { return true; } $newCode = $this->collection->assemble(); return file_put_contents($this->path, $newCode); }
php
public function save() { if (!$this->isChanged()) { return true; } $newCode = $this->collection->assemble(); return file_put_contents($this->path, $newCode); }
[ "public", "function", "save", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isChanged", "(", ")", ")", "{", "return", "true", ";", "}", "$", "newCode", "=", "$", "this", "->", "collection", "->", "assemble", "(", ")", ";", "return", "file_put_contents", "(", "$", "this", "->", "path", ",", "$", "newCode", ")", ";", "}" ]
Save tokens to @return bool|int
[ "Save", "tokens", "to" ]
f31ec8f1440708518c2a785b3f129f130621e966
https://github.com/funivan/PhpTokenizer/blob/f31ec8f1440708518c2a785b3f129f130621e966/src/File.php#L67-L73
232,539
funivan/PhpTokenizer
src/File.php
File.refresh
public function refresh() : self { $newCode = $this->collection->assemble(); $tokens = Helper::getTokensFromString($newCode); $this->collection->setItems($tokens); return $this; }
php
public function refresh() : self { $newCode = $this->collection->assemble(); $tokens = Helper::getTokensFromString($newCode); $this->collection->setItems($tokens); return $this; }
[ "public", "function", "refresh", "(", ")", ":", "self", "{", "$", "newCode", "=", "$", "this", "->", "collection", "->", "assemble", "(", ")", ";", "$", "tokens", "=", "Helper", "::", "getTokensFromString", "(", "$", "newCode", ")", ";", "$", "this", "->", "collection", "->", "setItems", "(", "$", "tokens", ")", ";", "return", "$", "this", ";", "}" ]
Parse current tokens @return self
[ "Parse", "current", "tokens" ]
f31ec8f1440708518c2a785b3f129f130621e966
https://github.com/funivan/PhpTokenizer/blob/f31ec8f1440708518c2a785b3f129f130621e966/src/File.php#L81-L87
232,540
mmanos/laravel-social
src/Mmanos/Social/Social.php
Social.service
public function service($provider, $url = null, $scope = null) { $info = Config::get('laravel-social::providers.' . strtolower($provider)); if (empty($info) || !is_array($info)) { throw new Exception('Missing configuration details for Social service: ' . $provider); } $client_id = array_get($info, 'client_id'); $client_secret = array_get($info, 'client_secret'); $scope = is_null($scope) ? array_get($info, 'scope') : $scope; if (empty($client_id) || empty($client_secret)) { throw new Exception('Missing client id/secret for Social service: ' . $provider); } return $this->factory->createService( ucfirst($provider), new Credentials($client_id, $client_secret, $url ?: URL::current()), $this->storage, $scope ); }
php
public function service($provider, $url = null, $scope = null) { $info = Config::get('laravel-social::providers.' . strtolower($provider)); if (empty($info) || !is_array($info)) { throw new Exception('Missing configuration details for Social service: ' . $provider); } $client_id = array_get($info, 'client_id'); $client_secret = array_get($info, 'client_secret'); $scope = is_null($scope) ? array_get($info, 'scope') : $scope; if (empty($client_id) || empty($client_secret)) { throw new Exception('Missing client id/secret for Social service: ' . $provider); } return $this->factory->createService( ucfirst($provider), new Credentials($client_id, $client_secret, $url ?: URL::current()), $this->storage, $scope ); }
[ "public", "function", "service", "(", "$", "provider", ",", "$", "url", "=", "null", ",", "$", "scope", "=", "null", ")", "{", "$", "info", "=", "Config", "::", "get", "(", "'laravel-social::providers.'", ".", "strtolower", "(", "$", "provider", ")", ")", ";", "if", "(", "empty", "(", "$", "info", ")", "||", "!", "is_array", "(", "$", "info", ")", ")", "{", "throw", "new", "Exception", "(", "'Missing configuration details for Social service: '", ".", "$", "provider", ")", ";", "}", "$", "client_id", "=", "array_get", "(", "$", "info", ",", "'client_id'", ")", ";", "$", "client_secret", "=", "array_get", "(", "$", "info", ",", "'client_secret'", ")", ";", "$", "scope", "=", "is_null", "(", "$", "scope", ")", "?", "array_get", "(", "$", "info", ",", "'scope'", ")", ":", "$", "scope", ";", "if", "(", "empty", "(", "$", "client_id", ")", "||", "empty", "(", "$", "client_secret", ")", ")", "{", "throw", "new", "Exception", "(", "'Missing client id/secret for Social service: '", ".", "$", "provider", ")", ";", "}", "return", "$", "this", "->", "factory", "->", "createService", "(", "ucfirst", "(", "$", "provider", ")", ",", "new", "Credentials", "(", "$", "client_id", ",", "$", "client_secret", ",", "$", "url", "?", ":", "URL", "::", "current", "(", ")", ")", ",", "$", "this", "->", "storage", ",", "$", "scope", ")", ";", "}" ]
Return an instance of the requested service. @param string $provider @param string $url @param array $scope @return \OAuth\Common\Service\AbstractService @throws \Exception
[ "Return", "an", "instance", "of", "the", "requested", "service", "." ]
f3ec7165509825d16cb9d06759a77580a291cb83
https://github.com/mmanos/laravel-social/blob/f3ec7165509825d16cb9d06759a77580a291cb83/src/Mmanos/Social/Social.php#L47-L69
232,541
mmanos/laravel-social
src/Mmanos/Social/Social.php
Social.oauthSpec
public function oauthSpec($provider) { $service = $this->service($provider); if (false !== stristr(get_class($service), 'OAuth1')) { return 1; } else if (false !== stristr(get_class($service), 'OAuth2')) { return 2; } return null; }
php
public function oauthSpec($provider) { $service = $this->service($provider); if (false !== stristr(get_class($service), 'OAuth1')) { return 1; } else if (false !== stristr(get_class($service), 'OAuth2')) { return 2; } return null; }
[ "public", "function", "oauthSpec", "(", "$", "provider", ")", "{", "$", "service", "=", "$", "this", "->", "service", "(", "$", "provider", ")", ";", "if", "(", "false", "!==", "stristr", "(", "get_class", "(", "$", "service", ")", ",", "'OAuth1'", ")", ")", "{", "return", "1", ";", "}", "else", "if", "(", "false", "!==", "stristr", "(", "get_class", "(", "$", "service", ")", ",", "'OAuth2'", ")", ")", "{", "return", "2", ";", "}", "return", "null", ";", "}" ]
Return the OAuth spec used by the given service provider. @param string $provider @return integer
[ "Return", "the", "OAuth", "spec", "used", "by", "the", "given", "service", "provider", "." ]
f3ec7165509825d16cb9d06759a77580a291cb83
https://github.com/mmanos/laravel-social/blob/f3ec7165509825d16cb9d06759a77580a291cb83/src/Mmanos/Social/Social.php#L78-L90
232,542
jack-theripper/transcoder
src/Format/FormatTrait.php
FormatTrait.withPreset
public function withPreset(PresetInterface $preset) { $self = clone $this; $self->setOptions($preset->toArray()); return $self; }
php
public function withPreset(PresetInterface $preset) { $self = clone $this; $self->setOptions($preset->toArray()); return $self; }
[ "public", "function", "withPreset", "(", "PresetInterface", "$", "preset", ")", "{", "$", "self", "=", "clone", "$", "this", ";", "$", "self", "->", "setOptions", "(", "$", "preset", "->", "toArray", "(", ")", ")", ";", "return", "$", "self", ";", "}" ]
Clone format instance with a new parameters from preset. @param PresetInterface $preset @return FormatInterface
[ "Clone", "format", "instance", "with", "a", "new", "parameters", "from", "preset", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Format/FormatTrait.php#L107-L113
232,543
jack-theripper/transcoder
src/Format/FormatTrait.php
FormatTrait.setDuration
protected function setDuration($duration) { if (is_numeric($duration) && $duration >= 0) { $duration = new TimeInterval($duration); } if ( ! $duration instanceof TimeInterval) { throw new \InvalidArgumentException('The duration value must be a positive number value.'); } $this->duration = $duration; return $this; }
php
protected function setDuration($duration) { if (is_numeric($duration) && $duration >= 0) { $duration = new TimeInterval($duration); } if ( ! $duration instanceof TimeInterval) { throw new \InvalidArgumentException('The duration value must be a positive number value.'); } $this->duration = $duration; return $this; }
[ "protected", "function", "setDuration", "(", "$", "duration", ")", "{", "if", "(", "is_numeric", "(", "$", "duration", ")", "&&", "$", "duration", ">=", "0", ")", "{", "$", "duration", "=", "new", "TimeInterval", "(", "$", "duration", ")", ";", "}", "if", "(", "!", "$", "duration", "instanceof", "TimeInterval", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The duration value must be a positive number value.'", ")", ";", "}", "$", "this", "->", "duration", "=", "$", "duration", ";", "return", "$", "this", ";", "}" ]
Set the duration value. @param TimeInterval|float $duration @return $this @throws \InvalidArgumentException
[ "Set", "the", "duration", "value", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Format/FormatTrait.php#L123-L138
232,544
datto/php-json-rpc-validator
src/Validator/Evaluator.php
Evaluator.evaluate
public function evaluate($method, $arguments) { $this->validate($method, $arguments); return $this->evaluator->evaluate($method, $arguments); }
php
public function evaluate($method, $arguments) { $this->validate($method, $arguments); return $this->evaluator->evaluate($method, $arguments); }
[ "public", "function", "evaluate", "(", "$", "method", ",", "$", "arguments", ")", "{", "$", "this", "->", "validate", "(", "$", "method", ",", "$", "arguments", ")", ";", "return", "$", "this", "->", "evaluator", "->", "evaluate", "(", "$", "method", ",", "$", "arguments", ")", ";", "}" ]
Validate method arguments using annotations and pass request to underlying evaluator if successful. @param string $method Method name @param array $arguments Positional or associative argument array @return mixed Return value of the callable
[ "Validate", "method", "arguments", "using", "annotations", "and", "pass", "request", "to", "underlying", "evaluator", "if", "successful", "." ]
d9dde0bc386ff5b7c36ca03d61b6a92be1d02624
https://github.com/datto/php-json-rpc-validator/blob/d9dde0bc386ff5b7c36ca03d61b6a92be1d02624/src/Validator/Evaluator.php#L74-L78
232,545
datto/php-json-rpc-validator
src/Validator/Evaluator.php
Evaluator.validateArguments
private function validateArguments( array $filledArguments, Validate $validateAnnotation, ReflectionMethod $reflectMethod ) { $validator = Validation::createValidatorBuilder()->getValidator(); foreach ($reflectMethod->getParameters() as $param) { $hasConstraints = isset($validateAnnotation->fields) && isset($validateAnnotation->fields[$param->getName()]); if ($hasConstraints) { $value = $filledArguments[$param->getPosition()]; $constraints = $validateAnnotation->fields[$param->getName()]->constraints; $this->validateValue($value, $constraints, $validator); } } }
php
private function validateArguments( array $filledArguments, Validate $validateAnnotation, ReflectionMethod $reflectMethod ) { $validator = Validation::createValidatorBuilder()->getValidator(); foreach ($reflectMethod->getParameters() as $param) { $hasConstraints = isset($validateAnnotation->fields) && isset($validateAnnotation->fields[$param->getName()]); if ($hasConstraints) { $value = $filledArguments[$param->getPosition()]; $constraints = $validateAnnotation->fields[$param->getName()]->constraints; $this->validateValue($value, $constraints, $validator); } } }
[ "private", "function", "validateArguments", "(", "array", "$", "filledArguments", ",", "Validate", "$", "validateAnnotation", ",", "ReflectionMethod", "$", "reflectMethod", ")", "{", "$", "validator", "=", "Validation", "::", "createValidatorBuilder", "(", ")", "->", "getValidator", "(", ")", ";", "foreach", "(", "$", "reflectMethod", "->", "getParameters", "(", ")", "as", "$", "param", ")", "{", "$", "hasConstraints", "=", "isset", "(", "$", "validateAnnotation", "->", "fields", ")", "&&", "isset", "(", "$", "validateAnnotation", "->", "fields", "[", "$", "param", "->", "getName", "(", ")", "]", ")", ";", "if", "(", "$", "hasConstraints", ")", "{", "$", "value", "=", "$", "filledArguments", "[", "$", "param", "->", "getPosition", "(", ")", "]", ";", "$", "constraints", "=", "$", "validateAnnotation", "->", "fields", "[", "$", "param", "->", "getName", "(", ")", "]", "->", "constraints", ";", "$", "this", "->", "validateValue", "(", "$", "value", ",", "$", "constraints", ",", "$", "validator", ")", ";", "}", "}", "}" ]
Validates each method arguments against the constraints specified in the Validator\Validate annotation. @param array $filledArguments Positional array of all arguments (including not provided optional arguments) @param Validate $validateAnnotation Annotation containing the argument constraints @param ReflectionMethod $reflectMethod Reflection method to be used to retrieve parameters @throws JsonRpc\Exception\Argument If the validation fails on any of the arguments
[ "Validates", "each", "method", "arguments", "against", "the", "constraints", "specified", "in", "the", "Validator", "\\", "Validate", "annotation", "." ]
d9dde0bc386ff5b7c36ca03d61b6a92be1d02624
https://github.com/datto/php-json-rpc-validator/blob/d9dde0bc386ff5b7c36ca03d61b6a92be1d02624/src/Validator/Evaluator.php#L122-L140
232,546
datto/php-json-rpc-validator
src/Validator/Evaluator.php
Evaluator.validateValue
private function validateValue($value, array $constraints, ValidatorInterface $validator) { $violations = $validator->validate($value, $constraints); if (count($violations) > 0) { throw new JsonRpc\Exception\Argument(); } }
php
private function validateValue($value, array $constraints, ValidatorInterface $validator) { $violations = $validator->validate($value, $constraints); if (count($violations) > 0) { throw new JsonRpc\Exception\Argument(); } }
[ "private", "function", "validateValue", "(", "$", "value", ",", "array", "$", "constraints", ",", "ValidatorInterface", "$", "validator", ")", "{", "$", "violations", "=", "$", "validator", "->", "validate", "(", "$", "value", ",", "$", "constraints", ")", ";", "if", "(", "count", "(", "$", "violations", ")", ">", "0", ")", "{", "throw", "new", "JsonRpc", "\\", "Exception", "\\", "Argument", "(", ")", ";", "}", "}" ]
Validate a single value using the given constraints array and validator. If any of the constraints are violated, an exception is thrown. @param mixed $value Argument value @param Constraint[] $constraints List of constraints for the given argument @param ValidatorInterface $validator Validator to be used for validation @throws JsonRpc\Exception\Argument If the validation fails on the given argument
[ "Validate", "a", "single", "value", "using", "the", "given", "constraints", "array", "and", "validator", ".", "If", "any", "of", "the", "constraints", "are", "violated", "an", "exception", "is", "thrown", "." ]
d9dde0bc386ff5b7c36ca03d61b6a92be1d02624
https://github.com/datto/php-json-rpc-validator/blob/d9dde0bc386ff5b7c36ca03d61b6a92be1d02624/src/Validator/Evaluator.php#L155-L162
232,547
datto/php-json-rpc-validator
src/Validator/Evaluator.php
Evaluator.registerAnnotations
private function registerAnnotations($namespaces) { if (self::$loader === null) { self::$loader = new Loader(); AnnotationRegistry::registerLoader(self::$loader); } if ($namespaces !== null) { self::$loader->addAll($namespaces); } else { self::$loader->add(self::CONSTRAINT_ANNOTATIONS_NAMESPACE); self::$loader->add(__NAMESPACE__); } }
php
private function registerAnnotations($namespaces) { if (self::$loader === null) { self::$loader = new Loader(); AnnotationRegistry::registerLoader(self::$loader); } if ($namespaces !== null) { self::$loader->addAll($namespaces); } else { self::$loader->add(self::CONSTRAINT_ANNOTATIONS_NAMESPACE); self::$loader->add(__NAMESPACE__); } }
[ "private", "function", "registerAnnotations", "(", "$", "namespaces", ")", "{", "if", "(", "self", "::", "$", "loader", "===", "null", ")", "{", "self", "::", "$", "loader", "=", "new", "Loader", "(", ")", ";", "AnnotationRegistry", "::", "registerLoader", "(", "self", "::", "$", "loader", ")", ";", "}", "if", "(", "$", "namespaces", "!==", "null", ")", "{", "self", "::", "$", "loader", "->", "addAll", "(", "$", "namespaces", ")", ";", "}", "else", "{", "self", "::", "$", "loader", "->", "add", "(", "self", "::", "CONSTRAINT_ANNOTATIONS_NAMESPACE", ")", ";", "self", "::", "$", "loader", "->", "add", "(", "__NAMESPACE__", ")", ";", "}", "}" ]
Register annotation namespaces with Doctrine. This is necessary because Doctrine is autoloader-agnostic. This little hack makes it use the regular Composer autoloader for the passed namespaces. To register annotations, a custom Loader is registered with Doctrine. Each namespace is added to that loader. @param array $namespaces List of namespaces containing valid annotations
[ "Register", "annotation", "namespaces", "with", "Doctrine", "." ]
d9dde0bc386ff5b7c36ca03d61b6a92be1d02624
https://github.com/datto/php-json-rpc-validator/blob/d9dde0bc386ff5b7c36ca03d61b6a92be1d02624/src/Validator/Evaluator.php#L176-L189
232,548
mmanos/laravel-api
src/Mmanos/Api/ControllerTrait.php
ControllerTrait.response
protected function response() { if (!isset($this->response)) { $this->response = Response::make(); } return $this->response; }
php
protected function response() { if (!isset($this->response)) { $this->response = Response::make(); } return $this->response; }
[ "protected", "function", "response", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "response", ")", ")", "{", "$", "this", "->", "response", "=", "Response", "::", "make", "(", ")", ";", "}", "return", "$", "this", "->", "response", ";", "}" ]
Return the current response instance. @return Response
[ "Return", "the", "current", "response", "instance", "." ]
8fac248d91c797f4a8f960e7cd7466df5a814975
https://github.com/mmanos/laravel-api/blob/8fac248d91c797f4a8f960e7cd7466df5a814975/src/Mmanos/Api/ControllerTrait.php#L18-L25
232,549
mmanos/laravel-api
src/Mmanos/Api/ControllerTrait.php
ControllerTrait.callAction
public function callAction($method, $parameters) { $response = $this->response(); $action_response = parent::callAction($method, $parameters); switch (true) { case $action_response instanceof Model: $response->setContent(Api::transform($action_response)); break; case $action_response instanceof Collection: $output = array(); foreach ($action_response as $model) { $output[] = Api::transform($model); } $response->setContent($output); break; case $action_response instanceof Paginator: $output = array(); foreach ($action_response->getCollection() as $model) { $output[] = Api::transform($model); } $response->setContent($output) ->header('Pagination-Page', $action_response->currentPage()) ->header('Pagination-Num', $action_response->perPage()) ->header('Pagination-Total', $action_response->total()) ->header('Pagination-Last-Page', $action_response->lastPage()); break; case $action_response instanceof Response: $response = $action_response; break; default: $response->setContent($action_response); } return $response; }
php
public function callAction($method, $parameters) { $response = $this->response(); $action_response = parent::callAction($method, $parameters); switch (true) { case $action_response instanceof Model: $response->setContent(Api::transform($action_response)); break; case $action_response instanceof Collection: $output = array(); foreach ($action_response as $model) { $output[] = Api::transform($model); } $response->setContent($output); break; case $action_response instanceof Paginator: $output = array(); foreach ($action_response->getCollection() as $model) { $output[] = Api::transform($model); } $response->setContent($output) ->header('Pagination-Page', $action_response->currentPage()) ->header('Pagination-Num', $action_response->perPage()) ->header('Pagination-Total', $action_response->total()) ->header('Pagination-Last-Page', $action_response->lastPage()); break; case $action_response instanceof Response: $response = $action_response; break; default: $response->setContent($action_response); } return $response; }
[ "public", "function", "callAction", "(", "$", "method", ",", "$", "parameters", ")", "{", "$", "response", "=", "$", "this", "->", "response", "(", ")", ";", "$", "action_response", "=", "parent", "::", "callAction", "(", "$", "method", ",", "$", "parameters", ")", ";", "switch", "(", "true", ")", "{", "case", "$", "action_response", "instanceof", "Model", ":", "$", "response", "->", "setContent", "(", "Api", "::", "transform", "(", "$", "action_response", ")", ")", ";", "break", ";", "case", "$", "action_response", "instanceof", "Collection", ":", "$", "output", "=", "array", "(", ")", ";", "foreach", "(", "$", "action_response", "as", "$", "model", ")", "{", "$", "output", "[", "]", "=", "Api", "::", "transform", "(", "$", "model", ")", ";", "}", "$", "response", "->", "setContent", "(", "$", "output", ")", ";", "break", ";", "case", "$", "action_response", "instanceof", "Paginator", ":", "$", "output", "=", "array", "(", ")", ";", "foreach", "(", "$", "action_response", "->", "getCollection", "(", ")", "as", "$", "model", ")", "{", "$", "output", "[", "]", "=", "Api", "::", "transform", "(", "$", "model", ")", ";", "}", "$", "response", "->", "setContent", "(", "$", "output", ")", "->", "header", "(", "'Pagination-Page'", ",", "$", "action_response", "->", "currentPage", "(", ")", ")", "->", "header", "(", "'Pagination-Num'", ",", "$", "action_response", "->", "perPage", "(", ")", ")", "->", "header", "(", "'Pagination-Total'", ",", "$", "action_response", "->", "total", "(", ")", ")", "->", "header", "(", "'Pagination-Last-Page'", ",", "$", "action_response", "->", "lastPage", "(", ")", ")", ";", "break", ";", "case", "$", "action_response", "instanceof", "Response", ":", "$", "response", "=", "$", "action_response", ";", "break", ";", "default", ":", "$", "response", "->", "setContent", "(", "$", "action_response", ")", ";", "}", "return", "$", "response", ";", "}" ]
Execute an action on the controller. Overridden to perform output transformations. @param string $method @param array $parameters @return \Symfony\Component\HttpFoundation\Response
[ "Execute", "an", "action", "on", "the", "controller", ".", "Overridden", "to", "perform", "output", "transformations", "." ]
8fac248d91c797f4a8f960e7cd7466df5a814975
https://github.com/mmanos/laravel-api/blob/8fac248d91c797f4a8f960e7cd7466df5a814975/src/Mmanos/Api/ControllerTrait.php#L35-L76
232,550
nineinchnick/yii2-usr
components/FormModelBehavior.php
FormModelBehavior.applyRuleOptions
public function applyRuleOptions($rules) { foreach ($rules as $key => $rule) { foreach ($this->_ruleOptions as $name => $value) { $rules[$key][$name] = $value; } } return $rules; }
php
public function applyRuleOptions($rules) { foreach ($rules as $key => $rule) { foreach ($this->_ruleOptions as $name => $value) { $rules[$key][$name] = $value; } } return $rules; }
[ "public", "function", "applyRuleOptions", "(", "$", "rules", ")", "{", "foreach", "(", "$", "rules", "as", "$", "key", "=>", "$", "rule", ")", "{", "foreach", "(", "$", "this", "->", "_ruleOptions", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "rules", "[", "$", "key", "]", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "return", "$", "rules", ";", "}" ]
Adds current rule options to the given set of rules. @param array $rules @return array
[ "Adds", "current", "rule", "options", "to", "the", "given", "set", "of", "rules", "." ]
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/components/FormModelBehavior.php#L83-L92
232,551
axypro/sourcemap
parsing/Context.php
Context.getMappings
public function getMappings() { if ($this->mappings === null) { $this->mappings = new Mappings($this->data['mappings'], $this); } return $this->mappings; }
php
public function getMappings() { if ($this->mappings === null) { $this->mappings = new Mappings($this->data['mappings'], $this); } return $this->mappings; }
[ "public", "function", "getMappings", "(", ")", "{", "if", "(", "$", "this", "->", "mappings", "===", "null", ")", "{", "$", "this", "->", "mappings", "=", "new", "Mappings", "(", "$", "this", "->", "data", "[", "'mappings'", "]", ",", "$", "this", ")", ";", "}", "return", "$", "this", "->", "mappings", ";", "}" ]
Returns the mappings wrapper @return \axy\sourcemap\parsing\Mappings
[ "Returns", "the", "mappings", "wrapper" ]
f5793e5d166bf2a1735e27676007a21c121e20af
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/parsing/Context.php#L62-L68
232,552
iwyg/jitimage
src/Thapp/JitImage/Driver/GdDriver.php
GdDriver.process
public function process() { parent::process(); if (is_int($this->background)) { extract($this->getBackgroundCoordinates($this->getGravity())); imagefill($this->resource, $x1, $y1, $this->background); imagefill($this->resource, $x2, $y2, $this->background); } }
php
public function process() { parent::process(); if (is_int($this->background)) { extract($this->getBackgroundCoordinates($this->getGravity())); imagefill($this->resource, $x1, $y1, $this->background); imagefill($this->resource, $x2, $y2, $this->background); } }
[ "public", "function", "process", "(", ")", "{", "parent", "::", "process", "(", ")", ";", "if", "(", "is_int", "(", "$", "this", "->", "background", ")", ")", "{", "extract", "(", "$", "this", "->", "getBackgroundCoordinates", "(", "$", "this", "->", "getGravity", "(", ")", ")", ")", ";", "imagefill", "(", "$", "this", "->", "resource", ",", "$", "x1", ",", "$", "y1", ",", "$", "this", "->", "background", ")", ";", "imagefill", "(", "$", "this", "->", "resource", ",", "$", "x2", ",", "$", "y2", ",", "$", "this", "->", "background", ")", ";", "}", "}" ]
post process background color if any {@inheritDoc}
[ "post", "process", "background", "color", "if", "any" ]
25300cc5bb17835634ec60d71f5ac2ba870abbe4
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Driver/GdDriver.php#L350-L361
232,553
jack-theripper/transcoder
src/Format/AudioFormat.php
AudioFormat.setChannels
public function setChannels($channels) { if ( ! is_numeric($channels) || $channels < 1) { throw new \InvalidArgumentException('Wrong audio channels value.'); } $this->audioChannels = $channels; return $this; }
php
public function setChannels($channels) { if ( ! is_numeric($channels) || $channels < 1) { throw new \InvalidArgumentException('Wrong audio channels value.'); } $this->audioChannels = $channels; return $this; }
[ "public", "function", "setChannels", "(", "$", "channels", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "channels", ")", "||", "$", "channels", "<", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Wrong audio channels value.'", ")", ";", "}", "$", "this", "->", "audioChannels", "=", "$", "channels", ";", "return", "$", "this", ";", "}" ]
Sets the channels value. @param int $channels @return AudioFormatInterface @throws \InvalidArgumentException
[ "Sets", "the", "channels", "value", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Format/AudioFormat.php#L91-L101
232,554
jack-theripper/transcoder
src/Format/AudioFormat.php
AudioFormat.setAudioCodec
public function setAudioCodec(Codec $codec) { if ($this->getAvailableAudioCodecs() && ! in_array((string) $codec, $this->getAvailableAudioCodecs(), false)) { throw new \InvalidArgumentException(sprintf('Wrong audio codec value for "%s", available values are %s', $codec, implode(', ', $this->getAvailableAudioCodecs()))); } $this->audioCodec = $codec; return $this; }
php
public function setAudioCodec(Codec $codec) { if ($this->getAvailableAudioCodecs() && ! in_array((string) $codec, $this->getAvailableAudioCodecs(), false)) { throw new \InvalidArgumentException(sprintf('Wrong audio codec value for "%s", available values are %s', $codec, implode(', ', $this->getAvailableAudioCodecs()))); } $this->audioCodec = $codec; return $this; }
[ "public", "function", "setAudioCodec", "(", "Codec", "$", "codec", ")", "{", "if", "(", "$", "this", "->", "getAvailableAudioCodecs", "(", ")", "&&", "!", "in_array", "(", "(", "string", ")", "$", "codec", ",", "$", "this", "->", "getAvailableAudioCodecs", "(", ")", ",", "false", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Wrong audio codec value for \"%s\", available values are %s'", ",", "$", "codec", ",", "implode", "(", "', '", ",", "$", "this", "->", "getAvailableAudioCodecs", "(", ")", ")", ")", ")", ";", "}", "$", "this", "->", "audioCodec", "=", "$", "codec", ";", "return", "$", "this", ";", "}" ]
Sets the audio codec, Should be in the available ones, otherwise an exception is thrown. @param Codec $codec @return AudioFormatInterface @throws \InvalidArgumentException
[ "Sets", "the", "audio", "codec", "Should", "be", "in", "the", "available", "ones", "otherwise", "an", "exception", "is", "thrown", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Format/AudioFormat.php#L121-L132
232,555
jack-theripper/transcoder
src/Format/AudioFormat.php
AudioFormat.setAudioBitrate
public function setAudioBitrate($bitrate) { if ( ! is_numeric($bitrate) || $bitrate < 0) { throw new \InvalidArgumentException('The audio bitrate value must be a integer type.'); } $this->audioBitrate = (int) $bitrate; return $this; }
php
public function setAudioBitrate($bitrate) { if ( ! is_numeric($bitrate) || $bitrate < 0) { throw new \InvalidArgumentException('The audio bitrate value must be a integer type.'); } $this->audioBitrate = (int) $bitrate; return $this; }
[ "public", "function", "setAudioBitrate", "(", "$", "bitrate", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "bitrate", ")", "||", "$", "bitrate", "<", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The audio bitrate value must be a integer type.'", ")", ";", "}", "$", "this", "->", "audioBitrate", "=", "(", "int", ")", "$", "bitrate", ";", "return", "$", "this", ";", "}" ]
Sets the audio bitrate value. @param int $bitrate @return AudioFormatInterface @throws \InvalidArgumentException
[ "Sets", "the", "audio", "bitrate", "value", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Format/AudioFormat.php#L152-L162
232,556
tricki/laravel-notification
src/Tricki/Notification/Notification.php
Notification.create
public function create($type, Model $sender, Model $object = NULL, $users = array(), $data = NULL) { $class = $this->getClass($type); $notification = new $class(); if ($data) { $notification->data = $data; } $notification->sender()->associate($sender); if ($object) { $notification->object()->associate($object); } $notification->save(); $notification_users = array(); foreach ($users as $user) { $notification_user = new Models\NotificationUser($notification); $notification_user->user_id = $user->id; $notification_users[] = $notification_user; } $notification->users()->saveMany($notification_users); return $notification; }
php
public function create($type, Model $sender, Model $object = NULL, $users = array(), $data = NULL) { $class = $this->getClass($type); $notification = new $class(); if ($data) { $notification->data = $data; } $notification->sender()->associate($sender); if ($object) { $notification->object()->associate($object); } $notification->save(); $notification_users = array(); foreach ($users as $user) { $notification_user = new Models\NotificationUser($notification); $notification_user->user_id = $user->id; $notification_users[] = $notification_user; } $notification->users()->saveMany($notification_users); return $notification; }
[ "public", "function", "create", "(", "$", "type", ",", "Model", "$", "sender", ",", "Model", "$", "object", "=", "NULL", ",", "$", "users", "=", "array", "(", ")", ",", "$", "data", "=", "NULL", ")", "{", "$", "class", "=", "$", "this", "->", "getClass", "(", "$", "type", ")", ";", "$", "notification", "=", "new", "$", "class", "(", ")", ";", "if", "(", "$", "data", ")", "{", "$", "notification", "->", "data", "=", "$", "data", ";", "}", "$", "notification", "->", "sender", "(", ")", "->", "associate", "(", "$", "sender", ")", ";", "if", "(", "$", "object", ")", "{", "$", "notification", "->", "object", "(", ")", "->", "associate", "(", "$", "object", ")", ";", "}", "$", "notification", "->", "save", "(", ")", ";", "$", "notification_users", "=", "array", "(", ")", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "notification_user", "=", "new", "Models", "\\", "NotificationUser", "(", "$", "notification", ")", ";", "$", "notification_user", "->", "user_id", "=", "$", "user", "->", "id", ";", "$", "notification_users", "[", "]", "=", "$", "notification_user", ";", "}", "$", "notification", "->", "users", "(", ")", "->", "saveMany", "(", "$", "notification_users", ")", ";", "return", "$", "notification", ";", "}" ]
Creates a notification and assigns it to some users @param string $type The notification type @param Model $sender The object that initiated the notification (a user, a group, a web service etc.) @param Model|NULL $object An object that was changed (a post that has been liked). @param mixed $users The user(s) which should receive this notification. @param mixed|NULL $data Any additional data @return \Tricki\Notification\Models\Notification
[ "Creates", "a", "notification", "and", "assigns", "it", "to", "some", "users" ]
b8b72273e01faaf15f91cc528b4643ceaffd4709
https://github.com/tricki/laravel-notification/blob/b8b72273e01faaf15f91cc528b4643ceaffd4709/src/Tricki/Notification/Notification.php#L40-L66
232,557
traderinteractive/solvemedia-client-php
src/Service.php
Service.getSignupUrl
public function getSignupUrl(string $domain = null, string $appname = null) : string { return self::ADCOPY_SIGNUP . '?' . http_build_query(['domain' => $domain, 'app' => $appname]); }
php
public function getSignupUrl(string $domain = null, string $appname = null) : string { return self::ADCOPY_SIGNUP . '?' . http_build_query(['domain' => $domain, 'app' => $appname]); }
[ "public", "function", "getSignupUrl", "(", "string", "$", "domain", "=", "null", ",", "string", "$", "appname", "=", "null", ")", ":", "string", "{", "return", "self", "::", "ADCOPY_SIGNUP", ".", "'?'", ".", "http_build_query", "(", "[", "'domain'", "=>", "$", "domain", ",", "'app'", "=>", "$", "appname", "]", ")", ";", "}" ]
Gets a URL where the user can sign up for solvemedia. If your application has a configuration page where you enter a key, you should provide a link using this function. @param string $domain The domain where the page is hosted @param string $appname The name of your application @return string url for signup page
[ "Gets", "a", "URL", "where", "the", "user", "can", "sign", "up", "for", "solvemedia", ".", "If", "your", "application", "has", "a", "configuration", "page", "where", "you", "enter", "a", "key", "you", "should", "provide", "a", "link", "using", "this", "function", "." ]
2f2994a75f64be9fe25b938239054f15e29a57e5
https://github.com/traderinteractive/solvemedia-client-php/blob/2f2994a75f64be9fe25b938239054f15e29a57e5/src/Service.php#L155-L158
232,558
jack-theripper/transcoder
src/Service/Decoder.php
Decoder.ensureFormatProperties
protected function ensureFormatProperties(array $properties) { // defaults keys for transforming $properties += [ 'bit_rate' => 0, 'duration' => 0.0, 'format_name' => '', 'tags' => [], 'codecs' => [] ]; if ( ! empty($this->options[ServiceFactoryInterface::OPTION_TEST_CODECS])) { $properties['codecs'] = $this->getAvailableCodecs(); } $properties['metadata'] = (array) $properties['tags']; $properties['format'] = $properties['format_name']; $properties['bitrate'] = $properties['bit_rate']; unset($properties['tags'], $properties['bit_rate']); return $properties; }
php
protected function ensureFormatProperties(array $properties) { // defaults keys for transforming $properties += [ 'bit_rate' => 0, 'duration' => 0.0, 'format_name' => '', 'tags' => [], 'codecs' => [] ]; if ( ! empty($this->options[ServiceFactoryInterface::OPTION_TEST_CODECS])) { $properties['codecs'] = $this->getAvailableCodecs(); } $properties['metadata'] = (array) $properties['tags']; $properties['format'] = $properties['format_name']; $properties['bitrate'] = $properties['bit_rate']; unset($properties['tags'], $properties['bit_rate']); return $properties; }
[ "protected", "function", "ensureFormatProperties", "(", "array", "$", "properties", ")", "{", "// defaults keys for transforming", "$", "properties", "+=", "[", "'bit_rate'", "=>", "0", ",", "'duration'", "=>", "0.0", ",", "'format_name'", "=>", "''", ",", "'tags'", "=>", "[", "]", ",", "'codecs'", "=>", "[", "]", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "options", "[", "ServiceFactoryInterface", "::", "OPTION_TEST_CODECS", "]", ")", ")", "{", "$", "properties", "[", "'codecs'", "]", "=", "$", "this", "->", "getAvailableCodecs", "(", ")", ";", "}", "$", "properties", "[", "'metadata'", "]", "=", "(", "array", ")", "$", "properties", "[", "'tags'", "]", ";", "$", "properties", "[", "'format'", "]", "=", "$", "properties", "[", "'format_name'", "]", ";", "$", "properties", "[", "'bitrate'", "]", "=", "$", "properties", "[", "'bit_rate'", "]", ";", "unset", "(", "$", "properties", "[", "'tags'", "]", ",", "$", "properties", "[", "'bit_rate'", "]", ")", ";", "return", "$", "properties", ";", "}" ]
Returns the format properties. @param array $properties @return array
[ "Returns", "the", "format", "properties", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Service/Decoder.php#L148-L171
232,559
jack-theripper/transcoder
src/Service/Decoder.php
Decoder.resolveStreamProperties
protected function resolveStreamProperties(array $properties) { // defaults keys for transforming $properties += [ 'tags' => [], 'sample_rate' => 0, 'codec_name' => null, 'codec_long_name' => '', 'type' => $properties['codec_type'], 'frequency' => 0, 'channels' => 1 ]; $properties['metadata'] = (array) $properties['tags']; $properties['frequency'] = (int) $properties['sample_rate']; $properties['codec'] = new Codec($properties['codec_name'], $properties['codec_long_name']); $properties['frame_rate'] = isset($properties['r_frame_rate']) ? $properties['r_frame_rate'] : 0.0; if (strpos($properties['frame_rate'], '/') > 0) { list($val1, $val2) = explode('/', $properties['frame_rate']); if ($val1 > 0 && $val2 > 0) { $properties['frame_rate'] = (float) $val1 / (float) $val2; } } return $properties; }
php
protected function resolveStreamProperties(array $properties) { // defaults keys for transforming $properties += [ 'tags' => [], 'sample_rate' => 0, 'codec_name' => null, 'codec_long_name' => '', 'type' => $properties['codec_type'], 'frequency' => 0, 'channels' => 1 ]; $properties['metadata'] = (array) $properties['tags']; $properties['frequency'] = (int) $properties['sample_rate']; $properties['codec'] = new Codec($properties['codec_name'], $properties['codec_long_name']); $properties['frame_rate'] = isset($properties['r_frame_rate']) ? $properties['r_frame_rate'] : 0.0; if (strpos($properties['frame_rate'], '/') > 0) { list($val1, $val2) = explode('/', $properties['frame_rate']); if ($val1 > 0 && $val2 > 0) { $properties['frame_rate'] = (float) $val1 / (float) $val2; } } return $properties; }
[ "protected", "function", "resolveStreamProperties", "(", "array", "$", "properties", ")", "{", "// defaults keys for transforming", "$", "properties", "+=", "[", "'tags'", "=>", "[", "]", ",", "'sample_rate'", "=>", "0", ",", "'codec_name'", "=>", "null", ",", "'codec_long_name'", "=>", "''", ",", "'type'", "=>", "$", "properties", "[", "'codec_type'", "]", ",", "'frequency'", "=>", "0", ",", "'channels'", "=>", "1", "]", ";", "$", "properties", "[", "'metadata'", "]", "=", "(", "array", ")", "$", "properties", "[", "'tags'", "]", ";", "$", "properties", "[", "'frequency'", "]", "=", "(", "int", ")", "$", "properties", "[", "'sample_rate'", "]", ";", "$", "properties", "[", "'codec'", "]", "=", "new", "Codec", "(", "$", "properties", "[", "'codec_name'", "]", ",", "$", "properties", "[", "'codec_long_name'", "]", ")", ";", "$", "properties", "[", "'frame_rate'", "]", "=", "isset", "(", "$", "properties", "[", "'r_frame_rate'", "]", ")", "?", "$", "properties", "[", "'r_frame_rate'", "]", ":", "0.0", ";", "if", "(", "strpos", "(", "$", "properties", "[", "'frame_rate'", "]", ",", "'/'", ")", ">", "0", ")", "{", "list", "(", "$", "val1", ",", "$", "val2", ")", "=", "explode", "(", "'/'", ",", "$", "properties", "[", "'frame_rate'", "]", ")", ";", "if", "(", "$", "val1", ">", "0", "&&", "$", "val2", ">", "0", ")", "{", "$", "properties", "[", "'frame_rate'", "]", "=", "(", "float", ")", "$", "val1", "/", "(", "float", ")", "$", "val2", ";", "}", "}", "return", "$", "properties", ";", "}" ]
Returns the stream properties. @param array $properties @return array @throws \InvalidArgumentException
[ "Returns", "the", "stream", "properties", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Service/Decoder.php#L181-L210
232,560
jack-theripper/transcoder
src/Service/Decoder.php
Decoder.getAvailableCodecs
public function getAvailableCodecs() { $codecs = []; $bit = ['.' => 0, 'A' => 1, 'V' => 2, 'S' => 4, 'E' => 8, 'D' => 16]; try { foreach (['encoders', 'codecs'] as $command) { $process = new Process(sprintf('"%s" "-%s"', $this->options['ffprobe.path'], $command)); $process->start(); while ($process->getStatus() !== Process::STATUS_TERMINATED) { usleep(200000); } if (preg_match_all('/\s([VASFXBDEIL\.]{6})\s(\S{3,20})\s/', $process->getOutput(), $matches)) { if ($command == 'encoders') { foreach ($matches[2] as $key => $value) { $codecs[$value] = $bit[$matches[1][$key]{0}] | $bit['E']; } } else // codecs, encoders + decoders { foreach ($matches[2] as $key => $value) { $key = $matches[1][$key]; $codecs[$value] = $bit[$key{2}] | $bit[$key{0}] | $bit[$key{1}]; } } } } } catch (\Exception $exception) { } return $codecs; }
php
public function getAvailableCodecs() { $codecs = []; $bit = ['.' => 0, 'A' => 1, 'V' => 2, 'S' => 4, 'E' => 8, 'D' => 16]; try { foreach (['encoders', 'codecs'] as $command) { $process = new Process(sprintf('"%s" "-%s"', $this->options['ffprobe.path'], $command)); $process->start(); while ($process->getStatus() !== Process::STATUS_TERMINATED) { usleep(200000); } if (preg_match_all('/\s([VASFXBDEIL\.]{6})\s(\S{3,20})\s/', $process->getOutput(), $matches)) { if ($command == 'encoders') { foreach ($matches[2] as $key => $value) { $codecs[$value] = $bit[$matches[1][$key]{0}] | $bit['E']; } } else // codecs, encoders + decoders { foreach ($matches[2] as $key => $value) { $key = $matches[1][$key]; $codecs[$value] = $bit[$key{2}] | $bit[$key{0}] | $bit[$key{1}]; } } } } } catch (\Exception $exception) { } return $codecs; }
[ "public", "function", "getAvailableCodecs", "(", ")", "{", "$", "codecs", "=", "[", "]", ";", "$", "bit", "=", "[", "'.'", "=>", "0", ",", "'A'", "=>", "1", ",", "'V'", "=>", "2", ",", "'S'", "=>", "4", ",", "'E'", "=>", "8", ",", "'D'", "=>", "16", "]", ";", "try", "{", "foreach", "(", "[", "'encoders'", ",", "'codecs'", "]", "as", "$", "command", ")", "{", "$", "process", "=", "new", "Process", "(", "sprintf", "(", "'\"%s\" \"-%s\"'", ",", "$", "this", "->", "options", "[", "'ffprobe.path'", "]", ",", "$", "command", ")", ")", ";", "$", "process", "->", "start", "(", ")", ";", "while", "(", "$", "process", "->", "getStatus", "(", ")", "!==", "Process", "::", "STATUS_TERMINATED", ")", "{", "usleep", "(", "200000", ")", ";", "}", "if", "(", "preg_match_all", "(", "'/\\s([VASFXBDEIL\\.]{6})\\s(\\S{3,20})\\s/'", ",", "$", "process", "->", "getOutput", "(", ")", ",", "$", "matches", ")", ")", "{", "if", "(", "$", "command", "==", "'encoders'", ")", "{", "foreach", "(", "$", "matches", "[", "2", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "codecs", "[", "$", "value", "]", "=", "$", "bit", "[", "$", "matches", "[", "1", "]", "[", "$", "key", "]", "{", "0", "}", "]", "|", "$", "bit", "[", "'E'", "]", ";", "}", "}", "else", "// codecs, encoders + decoders", "{", "foreach", "(", "$", "matches", "[", "2", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "$", "matches", "[", "1", "]", "[", "$", "key", "]", ";", "$", "codecs", "[", "$", "value", "]", "=", "$", "bit", "[", "$", "key", "{", "2", "}", "]", "|", "$", "bit", "[", "$", "key", "{", "0", "}", "]", "|", "$", "bit", "[", "$", "key", "{", "1", "}", "]", ";", "}", "}", "}", "}", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "}", "return", "$", "codecs", ";", "}" ]
Supported codecs. @return int[]
[ "Supported", "codecs", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Service/Decoder.php#L217-L260
232,561
chippyash/Monad
src/chippyash/Monad/Match.php
Match.any
public function any(\Closure $function = null, array $args = []) { if ($this->isMatched) { return new static($this->value, $this->isMatched); } if (is_null($function)) { return new static($this->value, true); } return new static($this->callFunction($function, $this->value, $args), true); }
php
public function any(\Closure $function = null, array $args = []) { if ($this->isMatched) { return new static($this->value, $this->isMatched); } if (is_null($function)) { return new static($this->value, true); } return new static($this->callFunction($function, $this->value, $args), true); }
[ "public", "function", "any", "(", "\\", "Closure", "$", "function", "=", "null", ",", "array", "$", "args", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "isMatched", ")", "{", "return", "new", "static", "(", "$", "this", "->", "value", ",", "$", "this", "->", "isMatched", ")", ";", "}", "if", "(", "is_null", "(", "$", "function", ")", ")", "{", "return", "new", "static", "(", "$", "this", "->", "value", ",", "true", ")", ";", "}", "return", "new", "static", "(", "$", "this", "->", "callFunction", "(", "$", "function", ",", "$", "this", "->", "value", ",", "$", "args", ")", ",", "true", ")", ";", "}" ]
Match anything. Usually called last in Match chain @param callable|\Closure $function @param array $args Optional additional arguments to function @return Match
[ "Match", "anything", ".", "Usually", "called", "last", "in", "Match", "chain" ]
56b0d0177880932448e41b07c1d8e4ba16f8804f
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Match.php#L82-L93
232,562
chippyash/Monad
src/chippyash/Monad/Match.php
Match.bind
public function bind(\Closure $function, array $args = []) { return new static($this->callFunction($function, $this->value, $args), $this->isMatched); }
php
public function bind(\Closure $function, array $args = []) { return new static($this->callFunction($function, $this->value, $args), $this->isMatched); }
[ "public", "function", "bind", "(", "\\", "Closure", "$", "function", ",", "array", "$", "args", "=", "[", "]", ")", "{", "return", "new", "static", "(", "$", "this", "->", "callFunction", "(", "$", "function", ",", "$", "this", "->", "value", ",", "$", "args", ")", ",", "$", "this", "->", "isMatched", ")", ";", "}" ]
Bind match value with function. Function is in form f($value) {} You can pass additional parameters in the $args array in which case your function should be in the form f($value, $arg1, ..., $argN) {} @param \Closure $function @param array $args additional arguments to pass to function @return Match
[ "Bind", "match", "value", "with", "function", "." ]
56b0d0177880932448e41b07c1d8e4ba16f8804f
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Match.php#L146-L149
232,563
jack-theripper/transcoder
src/Filter/Text.php
Text.setPositionExpression
public function setPositionExpression($xCoord, $yCoord) { $this->position = [ 'x' => (string) $xCoord, 'y' => (string) $yCoord ]; return $this; }
php
public function setPositionExpression($xCoord, $yCoord) { $this->position = [ 'x' => (string) $xCoord, 'y' => (string) $yCoord ]; return $this; }
[ "public", "function", "setPositionExpression", "(", "$", "xCoord", ",", "$", "yCoord", ")", "{", "$", "this", "->", "position", "=", "[", "'x'", "=>", "(", "string", ")", "$", "xCoord", ",", "'y'", "=>", "(", "string", ")", "$", "yCoord", "]", ";", "return", "$", "this", ";", "}" ]
Sets the expressions which specify the offsets where text will be drawn within the video frame. @param string $xCoord @param string $yCoord @return Text
[ "Sets", "the", "expressions", "which", "specify", "the", "offsets", "where", "text", "will", "be", "drawn", "within", "the", "video", "frame", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Filter/Text.php#L160-L168
232,564
hussainweb/drupal-api-client
src/Client.php
Client.getEntity
public function getEntity(Request $request) { $response = $this->send($request); $entity_class = $request->getEntityClass(); return $entity_class::fromResponse($response); }
php
public function getEntity(Request $request) { $response = $this->send($request); $entity_class = $request->getEntityClass(); return $entity_class::fromResponse($response); }
[ "public", "function", "getEntity", "(", "Request", "$", "request", ")", "{", "$", "response", "=", "$", "this", "->", "send", "(", "$", "request", ")", ";", "$", "entity_class", "=", "$", "request", "->", "getEntityClass", "(", ")", ";", "return", "$", "entity_class", "::", "fromResponse", "(", "$", "response", ")", ";", "}" ]
Send an API request and wrap it in the corresponding Entity object. @param \Hussainweb\DrupalApi\Request\Request $request The request to send. @return Entity|EntityCollection The entity or the collection for the request.
[ "Send", "an", "API", "request", "and", "wrap", "it", "in", "the", "corresponding", "Entity", "object", "." ]
d15de9591a3d5181b4d44c2e50235fb98b3d3448
https://github.com/hussainweb/drupal-api-client/blob/d15de9591a3d5181b4d44c2e50235fb98b3d3448/src/Client.php#L22-L27
232,565
prooph/mongodb-snapshot-store
src/MongoDbSnapshotStore.php
MongoDbSnapshotStore.createStream
private function createStream(string $data = '') { $stream = fopen('php://temp', 'w+b'); fwrite($stream, $data); rewind($stream); return $stream; }
php
private function createStream(string $data = '') { $stream = fopen('php://temp', 'w+b'); fwrite($stream, $data); rewind($stream); return $stream; }
[ "private", "function", "createStream", "(", "string", "$", "data", "=", "''", ")", "{", "$", "stream", "=", "fopen", "(", "'php://temp'", ",", "'w+b'", ")", ";", "fwrite", "(", "$", "stream", ",", "$", "data", ")", ";", "rewind", "(", "$", "stream", ")", ";", "return", "$", "stream", ";", "}" ]
Creates an in-memory stream with the given data. @return resource
[ "Creates", "an", "in", "-", "memory", "stream", "with", "the", "given", "data", "." ]
964576b989fae8e666531493e882220964eda09b
https://github.com/prooph/mongodb-snapshot-store/blob/964576b989fae8e666531493e882220964eda09b/src/MongoDbSnapshotStore.php#L199-L206
232,566
cawaphp/cawa
src/Log/Event.php
Event.onEmit
public function onEmit() { $microtime = explode('.', (string) microtime(true)); $this->date = DateTime::parse(date('Y-m-d\TH:i:s') . '.' . ($microtime[1] ?? '0000')); }
php
public function onEmit() { $microtime = explode('.', (string) microtime(true)); $this->date = DateTime::parse(date('Y-m-d\TH:i:s') . '.' . ($microtime[1] ?? '0000')); }
[ "public", "function", "onEmit", "(", ")", "{", "$", "microtime", "=", "explode", "(", "'.'", ",", "(", "string", ")", "microtime", "(", "true", ")", ")", ";", "$", "this", "->", "date", "=", "DateTime", "::", "parse", "(", "date", "(", "'Y-m-d\\TH:i:s'", ")", ".", "'.'", ".", "(", "$", "microtime", "[", "1", "]", "??", "'0000'", ")", ")", ";", "}" ]
Add current date.
[ "Add", "current", "date", "." ]
bd250532200121e7aa1da44e547c04c4c148fb37
https://github.com/cawaphp/cawa/blob/bd250532200121e7aa1da44e547c04c4c148fb37/src/Log/Event.php#L173-L179
232,567
jack-theripper/transcoder
src/TranscodeTrait.php
TranscodeTrait.getStreams
public function getStreams($filter = null) { if ($filter !== null) { if ( ! is_callable($filter)) { $filter = function (StreamInterface $stream) use ($filter) { return (bool) ($filter & $stream->getType()); }; } $streams = clone $this->streams; foreach ($streams as $index => $stream) { if ($filter($stream) === false) { $streams->offsetUnset($index); } } return $streams; } return $this->streams; }
php
public function getStreams($filter = null) { if ($filter !== null) { if ( ! is_callable($filter)) { $filter = function (StreamInterface $stream) use ($filter) { return (bool) ($filter & $stream->getType()); }; } $streams = clone $this->streams; foreach ($streams as $index => $stream) { if ($filter($stream) === false) { $streams->offsetUnset($index); } } return $streams; } return $this->streams; }
[ "public", "function", "getStreams", "(", "$", "filter", "=", "null", ")", "{", "if", "(", "$", "filter", "!==", "null", ")", "{", "if", "(", "!", "is_callable", "(", "$", "filter", ")", ")", "{", "$", "filter", "=", "function", "(", "StreamInterface", "$", "stream", ")", "use", "(", "$", "filter", ")", "{", "return", "(", "bool", ")", "(", "$", "filter", "&", "$", "stream", "->", "getType", "(", ")", ")", ";", "}", ";", "}", "$", "streams", "=", "clone", "$", "this", "->", "streams", ";", "foreach", "(", "$", "streams", "as", "$", "index", "=>", "$", "stream", ")", "{", "if", "(", "$", "filter", "(", "$", "stream", ")", "===", "false", ")", "{", "$", "streams", "->", "offsetUnset", "(", "$", "index", ")", ";", "}", "}", "return", "$", "streams", ";", "}", "return", "$", "this", "->", "streams", ";", "}" ]
Get a list of streams. @param int|callable $filter @return Collection|StreamInterface[]
[ "Get", "a", "list", "of", "streams", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/TranscodeTrait.php#L105-L130
232,568
jack-theripper/transcoder
src/TranscodeTrait.php
TranscodeTrait.findFormatClass
protected function findFormatClass($possibleFormat = null, $default = null) { static $mimeTypes = null; if ($possibleFormat !== null) { $className = __NAMESPACE__.'\\Format\\'.ucfirst($possibleFormat); if (class_exists($className)) { return $className; } } if ( ! $mimeTypes) { $mimeTypes = new MimeTypes(); } $extensions = $mimeTypes->getAllExtensions($this->getMimeType()); $extensions[] = pathinfo($this->getFilePath(), PATHINFO_EXTENSION); foreach ($extensions as $extension) { $classString = __NAMESPACE__.'\\Format\\'.ucfirst($extension); if (class_exists($classString)) { return $classString; } } return $default; }
php
protected function findFormatClass($possibleFormat = null, $default = null) { static $mimeTypes = null; if ($possibleFormat !== null) { $className = __NAMESPACE__.'\\Format\\'.ucfirst($possibleFormat); if (class_exists($className)) { return $className; } } if ( ! $mimeTypes) { $mimeTypes = new MimeTypes(); } $extensions = $mimeTypes->getAllExtensions($this->getMimeType()); $extensions[] = pathinfo($this->getFilePath(), PATHINFO_EXTENSION); foreach ($extensions as $extension) { $classString = __NAMESPACE__.'\\Format\\'.ucfirst($extension); if (class_exists($classString)) { return $classString; } } return $default; }
[ "protected", "function", "findFormatClass", "(", "$", "possibleFormat", "=", "null", ",", "$", "default", "=", "null", ")", "{", "static", "$", "mimeTypes", "=", "null", ";", "if", "(", "$", "possibleFormat", "!==", "null", ")", "{", "$", "className", "=", "__NAMESPACE__", ".", "'\\\\Format\\\\'", ".", "ucfirst", "(", "$", "possibleFormat", ")", ";", "if", "(", "class_exists", "(", "$", "className", ")", ")", "{", "return", "$", "className", ";", "}", "}", "if", "(", "!", "$", "mimeTypes", ")", "{", "$", "mimeTypes", "=", "new", "MimeTypes", "(", ")", ";", "}", "$", "extensions", "=", "$", "mimeTypes", "->", "getAllExtensions", "(", "$", "this", "->", "getMimeType", "(", ")", ")", ";", "$", "extensions", "[", "]", "=", "pathinfo", "(", "$", "this", "->", "getFilePath", "(", ")", ",", "PATHINFO_EXTENSION", ")", ";", "foreach", "(", "$", "extensions", "as", "$", "extension", ")", "{", "$", "classString", "=", "__NAMESPACE__", ".", "'\\\\Format\\\\'", ".", "ucfirst", "(", "$", "extension", ")", ";", "if", "(", "class_exists", "(", "$", "classString", ")", ")", "{", "return", "$", "classString", ";", "}", "}", "return", "$", "default", ";", "}" ]
Find a format class. @param string $possibleFormat @param mixed $default @return string|mixed
[ "Find", "a", "format", "class", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/TranscodeTrait.php#L268-L301
232,569
jack-theripper/transcoder
src/TranscodeTrait.php
TranscodeTrait.ensureStreams
protected function ensureStreams(array $rawStreams) { $streams = []; foreach ($rawStreams as $stream) { $stream['type'] = isset($stream['type']) ? strtolower($stream['type']) : null; if ($stream['type'] == 'audio') { $streams[] = AudioStream::create($this, $stream); } else if ($stream['type'] == 'video') { if ($this instanceof AudioInterface && $this instanceof VideoInterface) { $streams[] = VideoStream::create($this, $stream); } else { $streams[] = FrameStream::create($this, $stream); } } else if ($stream['type'] == 'subtitle') { $streams[] = SubtitleStream::create($this, $stream); } else { throw new TranscoderException('This stream unsupported.'); } } return $streams; }
php
protected function ensureStreams(array $rawStreams) { $streams = []; foreach ($rawStreams as $stream) { $stream['type'] = isset($stream['type']) ? strtolower($stream['type']) : null; if ($stream['type'] == 'audio') { $streams[] = AudioStream::create($this, $stream); } else if ($stream['type'] == 'video') { if ($this instanceof AudioInterface && $this instanceof VideoInterface) { $streams[] = VideoStream::create($this, $stream); } else { $streams[] = FrameStream::create($this, $stream); } } else if ($stream['type'] == 'subtitle') { $streams[] = SubtitleStream::create($this, $stream); } else { throw new TranscoderException('This stream unsupported.'); } } return $streams; }
[ "protected", "function", "ensureStreams", "(", "array", "$", "rawStreams", ")", "{", "$", "streams", "=", "[", "]", ";", "foreach", "(", "$", "rawStreams", "as", "$", "stream", ")", "{", "$", "stream", "[", "'type'", "]", "=", "isset", "(", "$", "stream", "[", "'type'", "]", ")", "?", "strtolower", "(", "$", "stream", "[", "'type'", "]", ")", ":", "null", ";", "if", "(", "$", "stream", "[", "'type'", "]", "==", "'audio'", ")", "{", "$", "streams", "[", "]", "=", "AudioStream", "::", "create", "(", "$", "this", ",", "$", "stream", ")", ";", "}", "else", "if", "(", "$", "stream", "[", "'type'", "]", "==", "'video'", ")", "{", "if", "(", "$", "this", "instanceof", "AudioInterface", "&&", "$", "this", "instanceof", "VideoInterface", ")", "{", "$", "streams", "[", "]", "=", "VideoStream", "::", "create", "(", "$", "this", ",", "$", "stream", ")", ";", "}", "else", "{", "$", "streams", "[", "]", "=", "FrameStream", "::", "create", "(", "$", "this", ",", "$", "stream", ")", ";", "}", "}", "else", "if", "(", "$", "stream", "[", "'type'", "]", "==", "'subtitle'", ")", "{", "$", "streams", "[", "]", "=", "SubtitleStream", "::", "create", "(", "$", "this", ",", "$", "stream", ")", ";", "}", "else", "{", "throw", "new", "TranscoderException", "(", "'This stream unsupported.'", ")", ";", "}", "}", "return", "$", "streams", ";", "}" ]
Returns the stream instances. @param array $rawStreams @return StreamInterface[] @throws \InvalidArgumentException @throws TranscoderException
[ "Returns", "the", "stream", "instances", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/TranscodeTrait.php#L340-L374
232,570
chippyash/Monad
src/chippyash/Monad/FTry/Success.php
Success.bind
public function bind(\Closure $function, array $args = []) { try { return FTry::create($this->callFunction($function, $this->value, $args)); } catch (\Exception $e) { return new Failure($e); } }
php
public function bind(\Closure $function, array $args = []) { try { return FTry::create($this->callFunction($function, $this->value, $args)); } catch (\Exception $e) { return new Failure($e); } }
[ "public", "function", "bind", "(", "\\", "Closure", "$", "function", ",", "array", "$", "args", "=", "[", "]", ")", "{", "try", "{", "return", "FTry", "::", "create", "(", "$", "this", "->", "callFunction", "(", "$", "function", ",", "$", "this", "->", "value", ",", "$", "args", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "new", "Failure", "(", "$", "e", ")", ";", "}", "}" ]
Return Success or Failure as a result of bind @param \Closure $function Ignored @param array $args Ignored @return Success|Failure
[ "Return", "Success", "or", "Failure", "as", "a", "result", "of", "bind" ]
56b0d0177880932448e41b07c1d8e4ba16f8804f
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/FTry/Success.php#L38-L45
232,571
iwyg/jitimage
src/Thapp/JitImage/Driver/AbstractDriver.php
AbstractDriver.filter
public function filter($name, array $options = []) { if (method_exists($this, $filter = 'filter' . ucfirst($name))) { call_user_func_array([$this, $filter], is_array($options) ? $options : []); return static::INT_FILTER; } return static::EXT_FILTER; }
php
public function filter($name, array $options = []) { if (method_exists($this, $filter = 'filter' . ucfirst($name))) { call_user_func_array([$this, $filter], is_array($options) ? $options : []); return static::INT_FILTER; } return static::EXT_FILTER; }
[ "public", "function", "filter", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "method_exists", "(", "$", "this", ",", "$", "filter", "=", "'filter'", ".", "ucfirst", "(", "$", "name", ")", ")", ")", "{", "call_user_func_array", "(", "[", "$", "this", ",", "$", "filter", "]", ",", "is_array", "(", "$", "options", ")", "?", "$", "options", ":", "[", "]", ")", ";", "return", "static", "::", "INT_FILTER", ";", "}", "return", "static", "::", "EXT_FILTER", ";", "}" ]
Call a filter on the driver. if the filter method exists on the driver the method will be called, otherwise it will return a flag to indecate that the filter is an external one. @param string $name @param array $options @access public @return int
[ "Call", "a", "filter", "on", "the", "driver", "." ]
25300cc5bb17835634ec60d71f5ac2ba870abbe4
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Driver/AbstractDriver.php#L203-L212
232,572
iwyg/jitimage
src/Thapp/JitImage/Driver/AbstractDriver.php
AbstractDriver.filterCropScale
protected function filterCropScale($gravity) { $this ->resize($this->targetSize['width'], $this->targetSize['height'], static::FL_FILL_AREA) ->gravity($gravity) ->extent($this->targetSize['width'], $this->targetSize['height']); }
php
protected function filterCropScale($gravity) { $this ->resize($this->targetSize['width'], $this->targetSize['height'], static::FL_FILL_AREA) ->gravity($gravity) ->extent($this->targetSize['width'], $this->targetSize['height']); }
[ "protected", "function", "filterCropScale", "(", "$", "gravity", ")", "{", "$", "this", "->", "resize", "(", "$", "this", "->", "targetSize", "[", "'width'", "]", ",", "$", "this", "->", "targetSize", "[", "'height'", "]", ",", "static", "::", "FL_FILL_AREA", ")", "->", "gravity", "(", "$", "gravity", ")", "->", "extent", "(", "$", "this", "->", "targetSize", "[", "'width'", "]", ",", "$", "this", "->", "targetSize", "[", "'height'", "]", ")", ";", "}" ]
Crop and resize filter. @param int $width @param int $height @param int $gravity @access protected @return void
[ "Crop", "and", "resize", "filter", "." ]
25300cc5bb17835634ec60d71f5ac2ba870abbe4
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Driver/AbstractDriver.php#L369-L375
232,573
iwyg/jitimage
src/Thapp/JitImage/Driver/AbstractDriver.php
AbstractDriver.filterCrop
protected function filterCrop($gravity, $background = null) { $this ->background($background) ->gravity($gravity) ->extent($this->targetSize['width'], $this->targetSize['height']); }
php
protected function filterCrop($gravity, $background = null) { $this ->background($background) ->gravity($gravity) ->extent($this->targetSize['width'], $this->targetSize['height']); }
[ "protected", "function", "filterCrop", "(", "$", "gravity", ",", "$", "background", "=", "null", ")", "{", "$", "this", "->", "background", "(", "$", "background", ")", "->", "gravity", "(", "$", "gravity", ")", "->", "extent", "(", "$", "this", "->", "targetSize", "[", "'width'", "]", ",", "$", "this", "->", "targetSize", "[", "'height'", "]", ")", ";", "}" ]
Crop filter. @param int $with @param int $height @param int $gravity @access protected @return void
[ "Crop", "filter", "." ]
25300cc5bb17835634ec60d71f5ac2ba870abbe4
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Driver/AbstractDriver.php#L387-L393
232,574
jack-theripper/transcoder
src/Service/ServiceFactory.php
ServiceFactory.getEncoderService
public function getEncoderService(array $options = []) { $options = $options ?: $this->getOptions(); if (isset($options[static::OPTION_USE_QUEUE]) && $options[static::OPTION_USE_QUEUE]) { /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ return new EncoderQueue($this->options[static::OPTION_USE_QUEUE], $options); } /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ return new Encoder($options); }
php
public function getEncoderService(array $options = []) { $options = $options ?: $this->getOptions(); if (isset($options[static::OPTION_USE_QUEUE]) && $options[static::OPTION_USE_QUEUE]) { /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ return new EncoderQueue($this->options[static::OPTION_USE_QUEUE], $options); } /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ return new Encoder($options); }
[ "public", "function", "getEncoderService", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "$", "options", "?", ":", "$", "this", "->", "getOptions", "(", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "static", "::", "OPTION_USE_QUEUE", "]", ")", "&&", "$", "options", "[", "static", "::", "OPTION_USE_QUEUE", "]", ")", "{", "/** @noinspection ExceptionsAnnotatingAndHandlingInspection */", "return", "new", "EncoderQueue", "(", "$", "this", "->", "options", "[", "static", "::", "OPTION_USE_QUEUE", "]", ",", "$", "options", ")", ";", "}", "/** @noinspection ExceptionsAnnotatingAndHandlingInspection */", "return", "new", "Encoder", "(", "$", "options", ")", ";", "}" ]
Get the encoder instance. @param array $options @return EncoderInterface
[ "Get", "the", "encoder", "instance", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Service/ServiceFactory.php#L56-L68
232,575
igorw/reasoned-php
reasoned.php
ConstraintStore.purify
function purify(Substitution $r) { return new ConstraintStore(array_filter($this->constraints, function ($c) use ($r) { return !any_var($c->values, $r); })); }
php
function purify(Substitution $r) { return new ConstraintStore(array_filter($this->constraints, function ($c) use ($r) { return !any_var($c->values, $r); })); }
[ "function", "purify", "(", "Substitution", "$", "r", ")", "{", "return", "new", "ConstraintStore", "(", "array_filter", "(", "$", "this", "->", "constraints", ",", "function", "(", "$", "c", ")", "use", "(", "$", "r", ")", "{", "return", "!", "any_var", "(", "$", "c", "->", "values", ",", "$", "r", ")", ";", "}", ")", ")", ";", "}" ]
r = reified name substitution
[ "r", "=", "reified", "name", "substitution" ]
d84eaee1894b03e1d4d425fce1d71fa683d07e1e
https://github.com/igorw/reasoned-php/blob/d84eaee1894b03e1d4d425fce1d71fa683d07e1e/reasoned.php#L124-L128
232,576
cawaphp/cawa
src/Events/Dispatcher.php
Dispatcher.addListener
public function addListener(string $event, $listener) { if (!isset($this->listeners[$event])) { $this->listeners[$event] = []; } $this->listeners[$event][] = $listener; }
php
public function addListener(string $event, $listener) { if (!isset($this->listeners[$event])) { $this->listeners[$event] = []; } $this->listeners[$event][] = $listener; }
[ "public", "function", "addListener", "(", "string", "$", "event", ",", "$", "listener", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", ")", ")", "{", "$", "this", "->", "listeners", "[", "$", "event", "]", "=", "[", "]", ";", "}", "$", "this", "->", "listeners", "[", "$", "event", "]", "[", "]", "=", "$", "listener", ";", "}" ]
Listen to a specific event name. @param string $event @param callable $listener
[ "Listen", "to", "a", "specific", "event", "name", "." ]
bd250532200121e7aa1da44e547c04c4c148fb37
https://github.com/cawaphp/cawa/blob/bd250532200121e7aa1da44e547c04c4c148fb37/src/Events/Dispatcher.php#L34-L40
232,577
OzanKurt/google-analytics
src/Traits/Handlers/ParamsHandler.php
ParamsHandler.getParams
public function getParams() { return [ 'metrics' => $this->metrics, 'dimensions' => $this->dimensions, 'sort' => $this->sort, 'filters' => $this->filters, 'segment' => $this->segment, ]; }
php
public function getParams() { return [ 'metrics' => $this->metrics, 'dimensions' => $this->dimensions, 'sort' => $this->sort, 'filters' => $this->filters, 'segment' => $this->segment, ]; }
[ "public", "function", "getParams", "(", ")", "{", "return", "[", "'metrics'", "=>", "$", "this", "->", "metrics", ",", "'dimensions'", "=>", "$", "this", "->", "dimensions", ",", "'sort'", "=>", "$", "this", "->", "sort", ",", "'filters'", "=>", "$", "this", "->", "filters", ",", "'segment'", "=>", "$", "this", "->", "segment", ",", "]", ";", "}" ]
Get all the parameters that will be reflected to current query. @return array
[ "Get", "all", "the", "parameters", "that", "will", "be", "reflected", "to", "current", "query", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Handlers/ParamsHandler.php#L20-L29
232,578
OzanKurt/google-analytics
src/Traits/Handlers/ParamsHandler.php
ParamsHandler.setParams
public function setParams(array $params) { foreach ($this->params as $param) { if (!array_key_exists($param, $params)) { $methodName = 'unset'.ucfirst($param); if (method_exists($this, $methodName)) { call_user_func( [$this, $methodName] ); continue; } } if (property_exists($this, $param)) { $methodName = 'set'.ucfirst($param); if (method_exists($this, $methodName)) { call_user_func( [$this, $methodName], $params[$param] ); } } } return $this; }
php
public function setParams(array $params) { foreach ($this->params as $param) { if (!array_key_exists($param, $params)) { $methodName = 'unset'.ucfirst($param); if (method_exists($this, $methodName)) { call_user_func( [$this, $methodName] ); continue; } } if (property_exists($this, $param)) { $methodName = 'set'.ucfirst($param); if (method_exists($this, $methodName)) { call_user_func( [$this, $methodName], $params[$param] ); } } } return $this; }
[ "public", "function", "setParams", "(", "array", "$", "params", ")", "{", "foreach", "(", "$", "this", "->", "params", "as", "$", "param", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "param", ",", "$", "params", ")", ")", "{", "$", "methodName", "=", "'unset'", ".", "ucfirst", "(", "$", "param", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "methodName", ")", ")", "{", "call_user_func", "(", "[", "$", "this", ",", "$", "methodName", "]", ")", ";", "continue", ";", "}", "}", "if", "(", "property_exists", "(", "$", "this", ",", "$", "param", ")", ")", "{", "$", "methodName", "=", "'set'", ".", "ucfirst", "(", "$", "param", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "methodName", ")", ")", "{", "call_user_func", "(", "[", "$", "this", ",", "$", "methodName", "]", ",", "$", "params", "[", "$", "param", "]", ")", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Set by overwriting existing parameters. @return array
[ "Set", "by", "overwriting", "existing", "parameters", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Handlers/ParamsHandler.php#L36-L63
232,579
DuckThom/laravel-importer
src/Runners/BaseRunner.php
BaseRunner.removeStale
public function removeStale() { /** @var \Illuminate\Database\Eloquent\Builder $query */ $query = $this->importer->getModelInstance() ->where('updated_at', '<', $this->now) ->orWhereNull('updated_at'); $this->deleted = $query->count(); $query->delete(); }
php
public function removeStale() { /** @var \Illuminate\Database\Eloquent\Builder $query */ $query = $this->importer->getModelInstance() ->where('updated_at', '<', $this->now) ->orWhereNull('updated_at'); $this->deleted = $query->count(); $query->delete(); }
[ "public", "function", "removeStale", "(", ")", "{", "/** @var \\Illuminate\\Database\\Eloquent\\Builder $query */", "$", "query", "=", "$", "this", "->", "importer", "->", "getModelInstance", "(", ")", "->", "where", "(", "'updated_at'", ",", "'<'", ",", "$", "this", "->", "now", ")", "->", "orWhereNull", "(", "'updated_at'", ")", ";", "$", "this", "->", "deleted", "=", "$", "query", "->", "count", "(", ")", ";", "$", "query", "->", "delete", "(", ")", ";", "}" ]
Determine which lines need to be removed by the importer. By default, the lines that were not present in the import file are removed after the other lines are updated, added or remained unchanged @return void
[ "Determine", "which", "lines", "need", "to", "be", "removed", "by", "the", "importer", "." ]
64bad083a7af35396199f342b57c3e619f2968c6
https://github.com/DuckThom/laravel-importer/blob/64bad083a7af35396199f342b57c3e619f2968c6/src/Runners/BaseRunner.php#L116-L126
232,580
DuckThom/laravel-importer
src/Runners/BaseRunner.php
BaseRunner.beforeImport
public function beforeImport() { if (!File::exists($this->importer->getFilePath())) { throw new FileNotFoundException($this->importer->getFilePath()); } $this->file = fopen($this->importer->getFilePath(), 'r'); if (!$this->validateFile()) { throw new InvalidFileException; } }
php
public function beforeImport() { if (!File::exists($this->importer->getFilePath())) { throw new FileNotFoundException($this->importer->getFilePath()); } $this->file = fopen($this->importer->getFilePath(), 'r'); if (!$this->validateFile()) { throw new InvalidFileException; } }
[ "public", "function", "beforeImport", "(", ")", "{", "if", "(", "!", "File", "::", "exists", "(", "$", "this", "->", "importer", "->", "getFilePath", "(", ")", ")", ")", "{", "throw", "new", "FileNotFoundException", "(", "$", "this", "->", "importer", "->", "getFilePath", "(", ")", ")", ";", "}", "$", "this", "->", "file", "=", "fopen", "(", "$", "this", "->", "importer", "->", "getFilePath", "(", ")", ",", "'r'", ")", ";", "if", "(", "!", "$", "this", "->", "validateFile", "(", ")", ")", "{", "throw", "new", "InvalidFileException", ";", "}", "}" ]
Things to run before the import @return void @throws InvalidFileException @throws FileNotFoundException
[ "Things", "to", "run", "before", "the", "import" ]
64bad083a7af35396199f342b57c3e619f2968c6
https://github.com/DuckThom/laravel-importer/blob/64bad083a7af35396199f342b57c3e619f2968c6/src/Runners/BaseRunner.php#L145-L156
232,581
networkteam/Networkteam.SentryClient
Classes/ErrorHandler.php
ErrorHandler.setTagsContext
protected function setTagsContext() { $objectManager = Bootstrap::$staticObjectManager; $environment = $objectManager->get(Environment::class); $tags = [ 'php_version' => phpversion(), 'flow_context' => (string)$environment->getContext(), 'flow_version' => FLOW_VERSION_BRANCH ]; $this->client->tags_context($tags); }
php
protected function setTagsContext() { $objectManager = Bootstrap::$staticObjectManager; $environment = $objectManager->get(Environment::class); $tags = [ 'php_version' => phpversion(), 'flow_context' => (string)$environment->getContext(), 'flow_version' => FLOW_VERSION_BRANCH ]; $this->client->tags_context($tags); }
[ "protected", "function", "setTagsContext", "(", ")", "{", "$", "objectManager", "=", "Bootstrap", "::", "$", "staticObjectManager", ";", "$", "environment", "=", "$", "objectManager", "->", "get", "(", "Environment", "::", "class", ")", ";", "$", "tags", "=", "[", "'php_version'", "=>", "phpversion", "(", ")", ",", "'flow_context'", "=>", "(", "string", ")", "$", "environment", "->", "getContext", "(", ")", ",", "'flow_version'", "=>", "FLOW_VERSION_BRANCH", "]", ";", "$", "this", "->", "client", "->", "tags_context", "(", "$", "tags", ")", ";", "}" ]
Set tags on the raven context
[ "Set", "tags", "on", "the", "raven", "context" ]
ad5f7e0e32b0fd11da21b3e37a1ae8dc5e6c2cbc
https://github.com/networkteam/Networkteam.SentryClient/blob/ad5f7e0e32b0fd11da21b3e37a1ae8dc5e6c2cbc/Classes/ErrorHandler.php#L117-L129
232,582
ncaneldiee/rajaongkir
src/International.php
International.origin
public function origin($province = null, $id = null) { return $this->request($this->api_version . '/internationalOrigin', [ 'province' => $province, 'id' => $id, ]); }
php
public function origin($province = null, $id = null) { return $this->request($this->api_version . '/internationalOrigin', [ 'province' => $province, 'id' => $id, ]); }
[ "public", "function", "origin", "(", "$", "province", "=", "null", ",", "$", "id", "=", "null", ")", "{", "return", "$", "this", "->", "request", "(", "$", "this", "->", "api_version", ".", "'/internationalOrigin'", ",", "[", "'province'", "=>", "$", "province", ",", "'id'", "=>", "$", "id", ",", "]", ")", ";", "}" ]
Get a list or detail of the origin city. @param int|null $province @param int|null $id @return object
[ "Get", "a", "list", "or", "detail", "of", "the", "origin", "city", "." ]
98e5c40a1b359953dcc913dd5070b8e8560a86a5
https://github.com/ncaneldiee/rajaongkir/blob/98e5c40a1b359953dcc913dd5070b8e8560a86a5/src/International.php#L91-L97
232,583
silverstripe-archive/deploynaut
code/model/DNCommit.php
DNCommit.Name
public function Name() { if($this->name == null) { $this->name = $this->commit->getFixedShortHash(8); } return htmlentities($this->name); }
php
public function Name() { if($this->name == null) { $this->name = $this->commit->getFixedShortHash(8); } return htmlentities($this->name); }
[ "public", "function", "Name", "(", ")", "{", "if", "(", "$", "this", "->", "name", "==", "null", ")", "{", "$", "this", "->", "name", "=", "$", "this", "->", "commit", "->", "getFixedShortHash", "(", "8", ")", ";", "}", "return", "htmlentities", "(", "$", "this", "->", "name", ")", ";", "}" ]
Return the hash of the commit, used to name this commit. @return string
[ "Return", "the", "hash", "of", "the", "commit", "used", "to", "name", "this", "commit", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNCommit.php#L45-L51
232,584
silverstripe-archive/deploynaut
code/model/DNCommit.php
DNCommit.SubjectMessage
public function SubjectMessage() { if($this->subjectMessage == null) { $this->subjectMessage = $this->commit->getSubjectMessage(); } return htmlentities($this->subjectMessage); }
php
public function SubjectMessage() { if($this->subjectMessage == null) { $this->subjectMessage = $this->commit->getSubjectMessage(); } return htmlentities($this->subjectMessage); }
[ "public", "function", "SubjectMessage", "(", ")", "{", "if", "(", "$", "this", "->", "subjectMessage", "==", "null", ")", "{", "$", "this", "->", "subjectMessage", "=", "$", "this", "->", "commit", "->", "getSubjectMessage", "(", ")", ";", "}", "return", "htmlentities", "(", "$", "this", "->", "subjectMessage", ")", ";", "}" ]
Return the first line of the commit message. @return string
[ "Return", "the", "first", "line", "of", "the", "commit", "message", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNCommit.php#L57-L63
232,585
mcustiel/php-simple-request
src/ParserGenerator.php
ParserGenerator.populateRequestParser
public function populateRequestParser( $className, RequestParser $parserObject, RequestBuilder $requestBuilder ) { $parserObject->setRequestObject(new $className); foreach ($this->reflectionService->getClassProperties($className) as $property) { $parserObject->addPropertyParser( $this->getPropertyParserBuilder($property)->build($requestBuilder) ); } return $parserObject; }
php
public function populateRequestParser( $className, RequestParser $parserObject, RequestBuilder $requestBuilder ) { $parserObject->setRequestObject(new $className); foreach ($this->reflectionService->getClassProperties($className) as $property) { $parserObject->addPropertyParser( $this->getPropertyParserBuilder($property)->build($requestBuilder) ); } return $parserObject; }
[ "public", "function", "populateRequestParser", "(", "$", "className", ",", "RequestParser", "$", "parserObject", ",", "RequestBuilder", "$", "requestBuilder", ")", "{", "$", "parserObject", "->", "setRequestObject", "(", "new", "$", "className", ")", ";", "foreach", "(", "$", "this", "->", "reflectionService", "->", "getClassProperties", "(", "$", "className", ")", "as", "$", "property", ")", "{", "$", "parserObject", "->", "addPropertyParser", "(", "$", "this", "->", "getPropertyParserBuilder", "(", "$", "property", ")", "->", "build", "(", "$", "requestBuilder", ")", ")", ";", "}", "return", "$", "parserObject", ";", "}" ]
Populates the parser object with the properties parser and the class object. @param string $className @param RequestParser $parserObject @param RequestBuilder $requestBuilder @return RequestParser
[ "Populates", "the", "parser", "object", "with", "the", "properties", "parser", "and", "the", "class", "object", "." ]
4d0fc06092ccdff3ea488c67b394225c7243428f
https://github.com/mcustiel/php-simple-request/blob/4d0fc06092ccdff3ea488c67b394225c7243428f/src/ParserGenerator.php#L65-L77
232,586
bav-php/bav
classes/validator/validators/ValidatorB8.php
ValidatorB8.useValidator
protected function useValidator(Validator $validator) { if ($validator !== $this->validator9) { return true; } $set1 = substr($this->account, 0, 2); $set2 = substr($this->account, 0, 3); return ($set1 >= 51 && $set1 <= 59) || ($set2 >= 901 && $set2 <= 910); }
php
protected function useValidator(Validator $validator) { if ($validator !== $this->validator9) { return true; } $set1 = substr($this->account, 0, 2); $set2 = substr($this->account, 0, 3); return ($set1 >= 51 && $set1 <= 59) || ($set2 >= 901 && $set2 <= 910); }
[ "protected", "function", "useValidator", "(", "Validator", "$", "validator", ")", "{", "if", "(", "$", "validator", "!==", "$", "this", "->", "validator9", ")", "{", "return", "true", ";", "}", "$", "set1", "=", "substr", "(", "$", "this", "->", "account", ",", "0", ",", "2", ")", ";", "$", "set2", "=", "substr", "(", "$", "this", "->", "account", ",", "0", ",", "3", ")", ";", "return", "(", "$", "set1", ">=", "51", "&&", "$", "set1", "<=", "59", ")", "||", "(", "$", "set2", ">=", "901", "&&", "$", "set2", "<=", "910", ")", ";", "}" ]
Limits Validator09 to the accounts @return bool
[ "Limits", "Validator09", "to", "the", "accounts" ]
2ad288cfc065d5c1ce31184de05aa0693e94bdb9
https://github.com/bav-php/bav/blob/2ad288cfc065d5c1ce31184de05aa0693e94bdb9/classes/validator/validators/ValidatorB8.php#L50-L60
232,587
silverstripe-archive/deploynaut
code/model/Pipeline.php
Pipeline.getReplacements
public function getReplacements() { // Get member who began this request $author = $this->Author(); $environment = $this->Environment(); return array( '<abortlink>' => Director::absoluteURL($this->Environment()->Link()), '<pipelinelink>' => Director::absoluteURL($this->Link()), '<requester>' => $author->Title, '<requester-email>' => $author->Email, '<environment>' => $environment->Name, '<project>' => $environment->Project()->Name, '<commitsha>' => $this->SHA ); }
php
public function getReplacements() { // Get member who began this request $author = $this->Author(); $environment = $this->Environment(); return array( '<abortlink>' => Director::absoluteURL($this->Environment()->Link()), '<pipelinelink>' => Director::absoluteURL($this->Link()), '<requester>' => $author->Title, '<requester-email>' => $author->Email, '<environment>' => $environment->Name, '<project>' => $environment->Project()->Name, '<commitsha>' => $this->SHA ); }
[ "public", "function", "getReplacements", "(", ")", "{", "// Get member who began this request", "$", "author", "=", "$", "this", "->", "Author", "(", ")", ";", "$", "environment", "=", "$", "this", "->", "Environment", "(", ")", ";", "return", "array", "(", "'<abortlink>'", "=>", "Director", "::", "absoluteURL", "(", "$", "this", "->", "Environment", "(", ")", "->", "Link", "(", ")", ")", ",", "'<pipelinelink>'", "=>", "Director", "::", "absoluteURL", "(", "$", "this", "->", "Link", "(", ")", ")", ",", "'<requester>'", "=>", "$", "author", "->", "Title", ",", "'<requester-email>'", "=>", "$", "author", "->", "Email", ",", "'<environment>'", "=>", "$", "environment", "->", "Name", ",", "'<project>'", "=>", "$", "environment", "->", "Project", "(", ")", "->", "Name", ",", "'<commitsha>'", "=>", "$", "this", "->", "SHA", ")", ";", "}" ]
Retrieve message template replacements @return array
[ "Retrieve", "message", "template", "replacements" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/Pipeline.php#L208-L221
232,588
silverstripe-archive/deploynaut
code/model/Pipeline.php
Pipeline.getRunningDescription
public function getRunningDescription() { if(!$this->isActive()) { return 'This pipeline is not currently running'; } $result = ''; if($step = $this->CurrentStep()) { $result = $step->getRunningDescription(); } return $result ?: 'This pipeline is currently running'; }
php
public function getRunningDescription() { if(!$this->isActive()) { return 'This pipeline is not currently running'; } $result = ''; if($step = $this->CurrentStep()) { $result = $step->getRunningDescription(); } return $result ?: 'This pipeline is currently running'; }
[ "public", "function", "getRunningDescription", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isActive", "(", ")", ")", "{", "return", "'This pipeline is not currently running'", ";", "}", "$", "result", "=", "''", ";", "if", "(", "$", "step", "=", "$", "this", "->", "CurrentStep", "(", ")", ")", "{", "$", "result", "=", "$", "step", "->", "getRunningDescription", "(", ")", ";", "}", "return", "$", "result", "?", ":", "'This pipeline is currently running'", ";", "}" ]
Get status of currently running step @return string Status description (html format)
[ "Get", "status", "of", "currently", "running", "step" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/Pipeline.php#L247-L256
232,589
silverstripe-archive/deploynaut
code/model/Pipeline.php
Pipeline.RunningOptions
public function RunningOptions() { if(!$this->isActive()) return null; $actions = array(); // Let current step update the current list of options if(($step = $this->CurrentStep()) && ($step->isRunning())) { $actions = $step->allowedActions(); } return new ArrayList($actions); }
php
public function RunningOptions() { if(!$this->isActive()) return null; $actions = array(); // Let current step update the current list of options if(($step = $this->CurrentStep()) && ($step->isRunning())) { $actions = $step->allowedActions(); } return new ArrayList($actions); }
[ "public", "function", "RunningOptions", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isActive", "(", ")", ")", "return", "null", ";", "$", "actions", "=", "array", "(", ")", ";", "// Let current step update the current list of options", "if", "(", "(", "$", "step", "=", "$", "this", "->", "CurrentStep", "(", ")", ")", "&&", "(", "$", "step", "->", "isRunning", "(", ")", ")", ")", "{", "$", "actions", "=", "$", "step", "->", "allowedActions", "(", ")", ";", "}", "return", "new", "ArrayList", "(", "$", "actions", ")", ";", "}" ]
Get options for the currently running pipeline, if and only if it is currently running @return ArrayList List of items with a Link and Title attribute
[ "Get", "options", "for", "the", "currently", "running", "pipeline", "if", "and", "only", "if", "it", "is", "currently", "running" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/Pipeline.php#L263-L272
232,590
silverstripe-archive/deploynaut
code/model/Pipeline.php
Pipeline.LogOptions
public function LogOptions() { if(!$this->isActive()) return null; $logs[] = array( 'ButtonText' => 'Pipeline Log', 'Link' => $this->Link() ); if($this->PreviousSnapshotID > 0) { $logs[] = array( 'ButtonText' => 'Snapshot Log', 'Link' => $this->PreviousSnapshot()->Link() ); } if($this->CurrentDeploymentID > 0) { $logs[] = array( 'ButtonText' => 'Deployment Log', 'Link' => $this->CurrentDeployment()->Link() ); } // Get logs from rollback steps (only for RollbackSteps). $rollbackSteps = array($this->RollbackStep1(), $this->RollbackStep2()); foreach ($rollbackSteps as $rollback) { if($rollback->exists() && $rollback->ClassName=='RollbackStep') { if($rollback->RollbackDeploymentID > 0) { $logs[] = array( 'ButtonText' => 'Rollback Log', 'Link' => $rollback->RollbackDeployment()->Link() ); } if($rollback->RollbackDatabaseID > 0) { $logs[] = array( 'ButtonText' => 'Rollback DB Log', 'Link' => $rollback->RollbackDatabase()->Link() ); } } } return new ArrayList($logs); }
php
public function LogOptions() { if(!$this->isActive()) return null; $logs[] = array( 'ButtonText' => 'Pipeline Log', 'Link' => $this->Link() ); if($this->PreviousSnapshotID > 0) { $logs[] = array( 'ButtonText' => 'Snapshot Log', 'Link' => $this->PreviousSnapshot()->Link() ); } if($this->CurrentDeploymentID > 0) { $logs[] = array( 'ButtonText' => 'Deployment Log', 'Link' => $this->CurrentDeployment()->Link() ); } // Get logs from rollback steps (only for RollbackSteps). $rollbackSteps = array($this->RollbackStep1(), $this->RollbackStep2()); foreach ($rollbackSteps as $rollback) { if($rollback->exists() && $rollback->ClassName=='RollbackStep') { if($rollback->RollbackDeploymentID > 0) { $logs[] = array( 'ButtonText' => 'Rollback Log', 'Link' => $rollback->RollbackDeployment()->Link() ); } if($rollback->RollbackDatabaseID > 0) { $logs[] = array( 'ButtonText' => 'Rollback DB Log', 'Link' => $rollback->RollbackDatabase()->Link() ); } } } return new ArrayList($logs); }
[ "public", "function", "LogOptions", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isActive", "(", ")", ")", "return", "null", ";", "$", "logs", "[", "]", "=", "array", "(", "'ButtonText'", "=>", "'Pipeline Log'", ",", "'Link'", "=>", "$", "this", "->", "Link", "(", ")", ")", ";", "if", "(", "$", "this", "->", "PreviousSnapshotID", ">", "0", ")", "{", "$", "logs", "[", "]", "=", "array", "(", "'ButtonText'", "=>", "'Snapshot Log'", ",", "'Link'", "=>", "$", "this", "->", "PreviousSnapshot", "(", ")", "->", "Link", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "CurrentDeploymentID", ">", "0", ")", "{", "$", "logs", "[", "]", "=", "array", "(", "'ButtonText'", "=>", "'Deployment Log'", ",", "'Link'", "=>", "$", "this", "->", "CurrentDeployment", "(", ")", "->", "Link", "(", ")", ")", ";", "}", "// Get logs from rollback steps (only for RollbackSteps).", "$", "rollbackSteps", "=", "array", "(", "$", "this", "->", "RollbackStep1", "(", ")", ",", "$", "this", "->", "RollbackStep2", "(", ")", ")", ";", "foreach", "(", "$", "rollbackSteps", "as", "$", "rollback", ")", "{", "if", "(", "$", "rollback", "->", "exists", "(", ")", "&&", "$", "rollback", "->", "ClassName", "==", "'RollbackStep'", ")", "{", "if", "(", "$", "rollback", "->", "RollbackDeploymentID", ">", "0", ")", "{", "$", "logs", "[", "]", "=", "array", "(", "'ButtonText'", "=>", "'Rollback Log'", ",", "'Link'", "=>", "$", "rollback", "->", "RollbackDeployment", "(", ")", "->", "Link", "(", ")", ")", ";", "}", "if", "(", "$", "rollback", "->", "RollbackDatabaseID", ">", "0", ")", "{", "$", "logs", "[", "]", "=", "array", "(", "'ButtonText'", "=>", "'Rollback DB Log'", ",", "'Link'", "=>", "$", "rollback", "->", "RollbackDatabase", "(", ")", "->", "Link", "(", ")", ")", ";", "}", "}", "}", "return", "new", "ArrayList", "(", "$", "logs", ")", ";", "}" ]
Get possible logs for the currently pipeline @return ArrayList List of logs with a Link and Title attribute
[ "Get", "possible", "logs", "for", "the", "currently", "pipeline" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/Pipeline.php#L279-L321
232,591
silverstripe-archive/deploynaut
code/model/Pipeline.php
Pipeline.getConfigData
public function getConfigData() { // Lazy load if necessary $data = null; if(!$this->Config && ($data = $this->Environment()->loadPipelineConfig())) { $this->Config = serialize($data); } // Merge with defaults if($this->Config) { if(!$this->mergedConfig) { $this->mergedConfig = $data ?: unserialize($this->Config); if($default = self::config()->default_config) { Config::merge_array_low_into_high($this->mergedConfig, $default); } } return $this->mergedConfig; } // Fail if no data available $path = $this->Environment()->getPipelineFilename(); throw new Exception(sprintf('YAML configuration for pipeline not found at path "%s"', $path)); }
php
public function getConfigData() { // Lazy load if necessary $data = null; if(!$this->Config && ($data = $this->Environment()->loadPipelineConfig())) { $this->Config = serialize($data); } // Merge with defaults if($this->Config) { if(!$this->mergedConfig) { $this->mergedConfig = $data ?: unserialize($this->Config); if($default = self::config()->default_config) { Config::merge_array_low_into_high($this->mergedConfig, $default); } } return $this->mergedConfig; } // Fail if no data available $path = $this->Environment()->getPipelineFilename(); throw new Exception(sprintf('YAML configuration for pipeline not found at path "%s"', $path)); }
[ "public", "function", "getConfigData", "(", ")", "{", "// Lazy load if necessary", "$", "data", "=", "null", ";", "if", "(", "!", "$", "this", "->", "Config", "&&", "(", "$", "data", "=", "$", "this", "->", "Environment", "(", ")", "->", "loadPipelineConfig", "(", ")", ")", ")", "{", "$", "this", "->", "Config", "=", "serialize", "(", "$", "data", ")", ";", "}", "// Merge with defaults", "if", "(", "$", "this", "->", "Config", ")", "{", "if", "(", "!", "$", "this", "->", "mergedConfig", ")", "{", "$", "this", "->", "mergedConfig", "=", "$", "data", "?", ":", "unserialize", "(", "$", "this", "->", "Config", ")", ";", "if", "(", "$", "default", "=", "self", "::", "config", "(", ")", "->", "default_config", ")", "{", "Config", "::", "merge_array_low_into_high", "(", "$", "this", "->", "mergedConfig", ",", "$", "default", ")", ";", "}", "}", "return", "$", "this", "->", "mergedConfig", ";", "}", "// Fail if no data available", "$", "path", "=", "$", "this", "->", "Environment", "(", ")", "->", "getPipelineFilename", "(", ")", ";", "throw", "new", "Exception", "(", "sprintf", "(", "'YAML configuration for pipeline not found at path \"%s\"'", ",", "$", "path", ")", ")", ";", "}" ]
Get this pipeline configuration. If the configuration has been serialized and saved into the Config field, it'll use that. If that field is empty, it'll read the YAML file directly and return that instead. @return array
[ "Get", "this", "pipeline", "configuration", ".", "If", "the", "configuration", "has", "been", "serialized", "and", "saved", "into", "the", "Config", "field", "it", "ll", "use", "that", ".", "If", "that", "field", "is", "empty", "it", "ll", "read", "the", "YAML", "file", "directly", "and", "return", "that", "instead", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/Pipeline.php#L337-L358
232,592
silverstripe-archive/deploynaut
code/model/Pipeline.php
Pipeline.getConfigSetting
public function getConfigSetting($setting) { $source = $this->getConfigData(); foreach(func_get_args() as $setting) { if(empty($source[$setting])) return null; $source = $source[$setting]; } return $source; }
php
public function getConfigSetting($setting) { $source = $this->getConfigData(); foreach(func_get_args() as $setting) { if(empty($source[$setting])) return null; $source = $source[$setting]; } return $source; }
[ "public", "function", "getConfigSetting", "(", "$", "setting", ")", "{", "$", "source", "=", "$", "this", "->", "getConfigData", "(", ")", ";", "foreach", "(", "func_get_args", "(", ")", "as", "$", "setting", ")", "{", "if", "(", "empty", "(", "$", "source", "[", "$", "setting", "]", ")", ")", "return", "null", ";", "$", "source", "=", "$", "source", "[", "$", "setting", "]", ";", "}", "return", "$", "source", ";", "}" ]
Retrieve the value of a specific config setting @param string $setting Settings @param string $setting,... Sub-settings @return mixed Value of setting, or null if not set
[ "Retrieve", "the", "value", "of", "a", "specific", "config", "setting" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/Pipeline.php#L372-L379
232,593
silverstripe-archive/deploynaut
code/model/Pipeline.php
Pipeline.generateStep
protected function generateStep($name, $stepConfig, $order = 0) { $stepClass = isset($stepConfig['Class']) ? $stepConfig['Class'] : $stepConfig; if(empty($stepClass)) { throw new Exception( sprintf('Missing or empty Class specifier for step "%s"', $name) ); } if(!is_subclass_of($stepClass, 'PipelineStep')) { throw new Exception( sprintf('%s is not a valid "Class" field name for step "%s"', var_export($stepClass, true), $name) ); } $step = $stepClass::create(); $step->Name = $name; $step->PipelineID = $this->ID; $step->Order = $order; $step->Status = 'Queued'; $step->Config = serialize($stepConfig); $step->write(); return $step; }
php
protected function generateStep($name, $stepConfig, $order = 0) { $stepClass = isset($stepConfig['Class']) ? $stepConfig['Class'] : $stepConfig; if(empty($stepClass)) { throw new Exception( sprintf('Missing or empty Class specifier for step "%s"', $name) ); } if(!is_subclass_of($stepClass, 'PipelineStep')) { throw new Exception( sprintf('%s is not a valid "Class" field name for step "%s"', var_export($stepClass, true), $name) ); } $step = $stepClass::create(); $step->Name = $name; $step->PipelineID = $this->ID; $step->Order = $order; $step->Status = 'Queued'; $step->Config = serialize($stepConfig); $step->write(); return $step; }
[ "protected", "function", "generateStep", "(", "$", "name", ",", "$", "stepConfig", ",", "$", "order", "=", "0", ")", "{", "$", "stepClass", "=", "isset", "(", "$", "stepConfig", "[", "'Class'", "]", ")", "?", "$", "stepConfig", "[", "'Class'", "]", ":", "$", "stepConfig", ";", "if", "(", "empty", "(", "$", "stepClass", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Missing or empty Class specifier for step \"%s\"'", ",", "$", "name", ")", ")", ";", "}", "if", "(", "!", "is_subclass_of", "(", "$", "stepClass", ",", "'PipelineStep'", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'%s is not a valid \"Class\" field name for step \"%s\"'", ",", "var_export", "(", "$", "stepClass", ",", "true", ")", ",", "$", "name", ")", ")", ";", "}", "$", "step", "=", "$", "stepClass", "::", "create", "(", ")", ";", "$", "step", "->", "Name", "=", "$", "name", ";", "$", "step", "->", "PipelineID", "=", "$", "this", "->", "ID", ";", "$", "step", "->", "Order", "=", "$", "order", ";", "$", "step", "->", "Status", "=", "'Queued'", ";", "$", "step", "->", "Config", "=", "serialize", "(", "$", "stepConfig", ")", ";", "$", "step", "->", "write", "(", ")", ";", "return", "$", "step", ";", "}" ]
Generate a step from a name, config, and sort order @param string $name @param array $stepConfig @param int $order @return PipelineStep @throws Exception
[ "Generate", "a", "step", "from", "a", "name", "config", "and", "sort", "order" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/Pipeline.php#L480-L503
232,594
silverstripe-archive/deploynaut
code/model/Pipeline.php
Pipeline.start
public function start() { // Ensure there are no other running {@link Pipeline} objects for this {@link DNEnvironment} // Requires that $this->EnvironmentID has been set $env = $this->Environment(); if(!($env && $env->exists())) { throw new LogicException("This pipeline needs a valid environment to run on."); } if($env->HasCurrentPipeline()) { throw new LogicException("You can only run one pipeline at a time on this environment."); } $this->write(); // ensure we've written this record first // Instantiate steps. foreach($this->getConfigSetting('Steps') as $name => $stepConfig) { $this->pushPipelineStep($name, $stepConfig); } $this->Status = 'Running'; $this->write(); $this->log('Started logging for this pipeline!'); return true; }
php
public function start() { // Ensure there are no other running {@link Pipeline} objects for this {@link DNEnvironment} // Requires that $this->EnvironmentID has been set $env = $this->Environment(); if(!($env && $env->exists())) { throw new LogicException("This pipeline needs a valid environment to run on."); } if($env->HasCurrentPipeline()) { throw new LogicException("You can only run one pipeline at a time on this environment."); } $this->write(); // ensure we've written this record first // Instantiate steps. foreach($this->getConfigSetting('Steps') as $name => $stepConfig) { $this->pushPipelineStep($name, $stepConfig); } $this->Status = 'Running'; $this->write(); $this->log('Started logging for this pipeline!'); return true; }
[ "public", "function", "start", "(", ")", "{", "// Ensure there are no other running {@link Pipeline} objects for this {@link DNEnvironment}", "// Requires that $this->EnvironmentID has been set", "$", "env", "=", "$", "this", "->", "Environment", "(", ")", ";", "if", "(", "!", "(", "$", "env", "&&", "$", "env", "->", "exists", "(", ")", ")", ")", "{", "throw", "new", "LogicException", "(", "\"This pipeline needs a valid environment to run on.\"", ")", ";", "}", "if", "(", "$", "env", "->", "HasCurrentPipeline", "(", ")", ")", "{", "throw", "new", "LogicException", "(", "\"You can only run one pipeline at a time on this environment.\"", ")", ";", "}", "$", "this", "->", "write", "(", ")", ";", "// ensure we've written this record first", "// Instantiate steps.", "foreach", "(", "$", "this", "->", "getConfigSetting", "(", "'Steps'", ")", "as", "$", "name", "=>", "$", "stepConfig", ")", "{", "$", "this", "->", "pushPipelineStep", "(", "$", "name", ",", "$", "stepConfig", ")", ";", "}", "$", "this", "->", "Status", "=", "'Running'", ";", "$", "this", "->", "write", "(", ")", ";", "$", "this", "->", "log", "(", "'Started logging for this pipeline!'", ")", ";", "return", "true", ";", "}" ]
Starts the pipeline process. Reads a YAML configuration from the linked {@link DNEnvironment} and builds the {@link PipelineStep} objects and runs them. Note that this method doesn't actually start any {@link PipelineStep} objects, that is handled by {@link self::checkPipelineStatus()}, and the daemon running the process.
[ "Starts", "the", "pipeline", "process", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/Pipeline.php#L514-L539
232,595
silverstripe-archive/deploynaut
code/model/Pipeline.php
Pipeline.markComplete
public function markComplete() { $this->Status = "Complete"; $this->log("Pipeline completed successfully."); $this->write(); // Some steps may pre-emptively send a success message before the pipeline itself has completed if($this->LastMessageSent !== self::ALERT_SUCCESS) { $this->sendMessage(self::ALERT_SUCCESS); } }
php
public function markComplete() { $this->Status = "Complete"; $this->log("Pipeline completed successfully."); $this->write(); // Some steps may pre-emptively send a success message before the pipeline itself has completed if($this->LastMessageSent !== self::ALERT_SUCCESS) { $this->sendMessage(self::ALERT_SUCCESS); } }
[ "public", "function", "markComplete", "(", ")", "{", "$", "this", "->", "Status", "=", "\"Complete\"", ";", "$", "this", "->", "log", "(", "\"Pipeline completed successfully.\"", ")", ";", "$", "this", "->", "write", "(", ")", ";", "// Some steps may pre-emptively send a success message before the pipeline itself has completed", "if", "(", "$", "this", "->", "LastMessageSent", "!==", "self", "::", "ALERT_SUCCESS", ")", "{", "$", "this", "->", "sendMessage", "(", "self", "::", "ALERT_SUCCESS", ")", ";", "}", "}" ]
Mark this Pipeline as completed. @return void
[ "Mark", "this", "Pipeline", "as", "completed", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/Pipeline.php#L546-L554
232,596
silverstripe-archive/deploynaut
code/model/Pipeline.php
Pipeline.pushPipelineStep
private function pushPipelineStep($name, $stepConfig) { $lastStep = $this->Steps()->sort("Order DESC")->first(); $order = $lastStep ? $lastStep->Order + 1 : 1; return $this->generateStep($name, $stepConfig, $order); }
php
private function pushPipelineStep($name, $stepConfig) { $lastStep = $this->Steps()->sort("Order DESC")->first(); $order = $lastStep ? $lastStep->Order + 1 : 1; return $this->generateStep($name, $stepConfig, $order); }
[ "private", "function", "pushPipelineStep", "(", "$", "name", ",", "$", "stepConfig", ")", "{", "$", "lastStep", "=", "$", "this", "->", "Steps", "(", ")", "->", "sort", "(", "\"Order DESC\"", ")", "->", "first", "(", ")", ";", "$", "order", "=", "$", "lastStep", "?", "$", "lastStep", "->", "Order", "+", "1", ":", "1", ";", "return", "$", "this", "->", "generateStep", "(", "$", "name", ",", "$", "stepConfig", ",", "$", "order", ")", ";", "}" ]
Push a step to the end of a pipeline
[ "Push", "a", "step", "to", "the", "end", "of", "a", "pipeline" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/Pipeline.php#L584-L588
232,597
silverstripe-archive/deploynaut
code/model/Pipeline.php
Pipeline.finaliseRollback
protected function finaliseRollback() { // Figure out the status by inspecting specific rollback steps. $success = true; $rollback1 = $this->RollbackStep1(); $rollback2 = $this->RollbackStep2(); if (!empty($rollback1) && $rollback1->Status=='Failed') $success = false; if (!empty($rollback2) && $rollback2->Status=='Failed') $success = false; // Send messages. if ($success) { $this->log("Pipeline failed, but rollback completed successfully."); $this->sendMessage(self::ALERT_ROLLBACK_SUCCESS); } else { $this->log("Pipeline failed, rollback failed."); $this->sendMessage(self::ALERT_ROLLBACK_FAILURE); } // Finish off the pipeline - rollback will only be triggered on a failed pipeline. $this->Status = 'Failed'; $this->write(); }
php
protected function finaliseRollback() { // Figure out the status by inspecting specific rollback steps. $success = true; $rollback1 = $this->RollbackStep1(); $rollback2 = $this->RollbackStep2(); if (!empty($rollback1) && $rollback1->Status=='Failed') $success = false; if (!empty($rollback2) && $rollback2->Status=='Failed') $success = false; // Send messages. if ($success) { $this->log("Pipeline failed, but rollback completed successfully."); $this->sendMessage(self::ALERT_ROLLBACK_SUCCESS); } else { $this->log("Pipeline failed, rollback failed."); $this->sendMessage(self::ALERT_ROLLBACK_FAILURE); } // Finish off the pipeline - rollback will only be triggered on a failed pipeline. $this->Status = 'Failed'; $this->write(); }
[ "protected", "function", "finaliseRollback", "(", ")", "{", "// Figure out the status by inspecting specific rollback steps.", "$", "success", "=", "true", ";", "$", "rollback1", "=", "$", "this", "->", "RollbackStep1", "(", ")", ";", "$", "rollback2", "=", "$", "this", "->", "RollbackStep2", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "rollback1", ")", "&&", "$", "rollback1", "->", "Status", "==", "'Failed'", ")", "$", "success", "=", "false", ";", "if", "(", "!", "empty", "(", "$", "rollback2", ")", "&&", "$", "rollback2", "->", "Status", "==", "'Failed'", ")", "$", "success", "=", "false", ";", "// Send messages.", "if", "(", "$", "success", ")", "{", "$", "this", "->", "log", "(", "\"Pipeline failed, but rollback completed successfully.\"", ")", ";", "$", "this", "->", "sendMessage", "(", "self", "::", "ALERT_ROLLBACK_SUCCESS", ")", ";", "}", "else", "{", "$", "this", "->", "log", "(", "\"Pipeline failed, rollback failed.\"", ")", ";", "$", "this", "->", "sendMessage", "(", "self", "::", "ALERT_ROLLBACK_FAILURE", ")", ";", "}", "// Finish off the pipeline - rollback will only be triggered on a failed pipeline.", "$", "this", "->", "Status", "=", "'Failed'", ";", "$", "this", "->", "write", "(", ")", ";", "}" ]
The rollback has finished - close the pipeline and send relevant messages.
[ "The", "rollback", "has", "finished", "-", "close", "the", "pipeline", "and", "send", "relevant", "messages", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/Pipeline.php#L593-L614
232,598
silverstripe-archive/deploynaut
code/model/Pipeline.php
Pipeline.beginRollback
protected function beginRollback() { $this->log("Beginning rollback..."); $this->sendMessage(self::ALERT_ROLLBACK_STARTED); // Add rollback step. $configRollback1 = $this->getConfigSetting('RollbackStep1'); $stepRollback1 = $this->pushPipelineStep('RollbackStep1', $configRollback1); $this->RollbackStep1ID = $stepRollback1->ID; $this->CurrentStepID = $stepRollback1->ID; $this->Status = 'Rollback'; // Add smoke test step, if available, for later processing. $configRollback2 = $this->getConfigSetting('RollbackStep2'); if ($configRollback2) { $stepRollback2 = $this->pushPipelineStep('RollbackStep2', $configRollback2); $this->RollbackStep2ID = $stepRollback2->ID; } $this->write(); $stepRollback1->start(); }
php
protected function beginRollback() { $this->log("Beginning rollback..."); $this->sendMessage(self::ALERT_ROLLBACK_STARTED); // Add rollback step. $configRollback1 = $this->getConfigSetting('RollbackStep1'); $stepRollback1 = $this->pushPipelineStep('RollbackStep1', $configRollback1); $this->RollbackStep1ID = $stepRollback1->ID; $this->CurrentStepID = $stepRollback1->ID; $this->Status = 'Rollback'; // Add smoke test step, if available, for later processing. $configRollback2 = $this->getConfigSetting('RollbackStep2'); if ($configRollback2) { $stepRollback2 = $this->pushPipelineStep('RollbackStep2', $configRollback2); $this->RollbackStep2ID = $stepRollback2->ID; } $this->write(); $stepRollback1->start(); }
[ "protected", "function", "beginRollback", "(", ")", "{", "$", "this", "->", "log", "(", "\"Beginning rollback...\"", ")", ";", "$", "this", "->", "sendMessage", "(", "self", "::", "ALERT_ROLLBACK_STARTED", ")", ";", "// Add rollback step.", "$", "configRollback1", "=", "$", "this", "->", "getConfigSetting", "(", "'RollbackStep1'", ")", ";", "$", "stepRollback1", "=", "$", "this", "->", "pushPipelineStep", "(", "'RollbackStep1'", ",", "$", "configRollback1", ")", ";", "$", "this", "->", "RollbackStep1ID", "=", "$", "stepRollback1", "->", "ID", ";", "$", "this", "->", "CurrentStepID", "=", "$", "stepRollback1", "->", "ID", ";", "$", "this", "->", "Status", "=", "'Rollback'", ";", "// Add smoke test step, if available, for later processing.", "$", "configRollback2", "=", "$", "this", "->", "getConfigSetting", "(", "'RollbackStep2'", ")", ";", "if", "(", "$", "configRollback2", ")", "{", "$", "stepRollback2", "=", "$", "this", "->", "pushPipelineStep", "(", "'RollbackStep2'", ",", "$", "configRollback2", ")", ";", "$", "this", "->", "RollbackStep2ID", "=", "$", "stepRollback2", "->", "ID", ";", "}", "$", "this", "->", "write", "(", ")", ";", "$", "stepRollback1", "->", "start", "(", ")", ";", "}" ]
Initiate a rollback. Moves the pipeline to the 'Rollback' status.
[ "Initiate", "a", "rollback", ".", "Moves", "the", "pipeline", "to", "the", "Rollback", "status", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/Pipeline.php#L619-L640
232,599
silverstripe-archive/deploynaut
code/model/Pipeline.php
Pipeline.canStartRollback
protected function canStartRollback() { // The rollback cannot run twice. if ($this->isRollback()) return false; // Rollbacks must be configured. if (!$this->getConfigSetting('RollbackStep1')) return false; // On dryrun let rollback run if($this->DryRun) return true; // Pipeline must have ran a deployment to be able to rollback. $deploy = $this->CurrentDeployment(); $previous = $this->PreviousDeployment(); if (!$deploy->exists() || !$previous->exists()) return false; return true; }
php
protected function canStartRollback() { // The rollback cannot run twice. if ($this->isRollback()) return false; // Rollbacks must be configured. if (!$this->getConfigSetting('RollbackStep1')) return false; // On dryrun let rollback run if($this->DryRun) return true; // Pipeline must have ran a deployment to be able to rollback. $deploy = $this->CurrentDeployment(); $previous = $this->PreviousDeployment(); if (!$deploy->exists() || !$previous->exists()) return false; return true; }
[ "protected", "function", "canStartRollback", "(", ")", "{", "// The rollback cannot run twice.", "if", "(", "$", "this", "->", "isRollback", "(", ")", ")", "return", "false", ";", "// Rollbacks must be configured.", "if", "(", "!", "$", "this", "->", "getConfigSetting", "(", "'RollbackStep1'", ")", ")", "return", "false", ";", "// On dryrun let rollback run", "if", "(", "$", "this", "->", "DryRun", ")", "return", "true", ";", "// Pipeline must have ran a deployment to be able to rollback.", "$", "deploy", "=", "$", "this", "->", "CurrentDeployment", "(", ")", ";", "$", "previous", "=", "$", "this", "->", "PreviousDeployment", "(", ")", ";", "if", "(", "!", "$", "deploy", "->", "exists", "(", ")", "||", "!", "$", "previous", "->", "exists", "(", ")", ")", "return", "false", ";", "return", "true", ";", "}" ]
Check if pipeline currently permits a rollback. This could be influenced by both the current state and by the specific configuration.
[ "Check", "if", "pipeline", "currently", "permits", "a", "rollback", ".", "This", "could", "be", "influenced", "by", "both", "the", "current", "state", "and", "by", "the", "specific", "configuration", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/Pipeline.php#L646-L662