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
partition
stringclasses
1 value
jamiehannaford/php-opencloud-zf2
src/Factory/AbstractProviderFactory.php
AbstractProviderFactory.extractAuthEndpoint
private function extractAuthEndpoint() { $auth = empty($this->config['auth_endpoint']) ? self::DEFAULT_AUTH_ENDPOINT : $this->config['auth_endpoint']; switch ($auth) { case Endpoint::UK: $endpoint = Rackspace::UK_IDENTITY_ENDPOINT; break; case Endpoint::US: $endpoint = Rackspace::US_IDENTITY_ENDPOINT; break; default: $endpoint = $auth; break; } return Url::factory($endpoint); }
php
private function extractAuthEndpoint() { $auth = empty($this->config['auth_endpoint']) ? self::DEFAULT_AUTH_ENDPOINT : $this->config['auth_endpoint']; switch ($auth) { case Endpoint::UK: $endpoint = Rackspace::UK_IDENTITY_ENDPOINT; break; case Endpoint::US: $endpoint = Rackspace::US_IDENTITY_ENDPOINT; break; default: $endpoint = $auth; break; } return Url::factory($endpoint); }
[ "private", "function", "extractAuthEndpoint", "(", ")", "{", "$", "auth", "=", "empty", "(", "$", "this", "->", "config", "[", "'auth_endpoint'", "]", ")", "?", "self", "::", "DEFAULT_AUTH_ENDPOINT", ":", "$", "this", "->", "config", "[", "'auth_endpoint'", ...
Searchs the configuration values provided and attempts to build a suitable URL for authentication. @return \Guzzle\Http\Url
[ "Searchs", "the", "configuration", "values", "provided", "and", "attempts", "to", "build", "a", "suitable", "URL", "for", "authentication", "." ]
74140adaffc0b46d7bbe1d7b3441c61f2cf6a656
https://github.com/jamiehannaford/php-opencloud-zf2/blob/74140adaffc0b46d7bbe1d7b3441c61f2cf6a656/src/Factory/AbstractProviderFactory.php#L83-L100
train
emaphp/eMapper
lib/eMapper/Cache/Key/CacheKeyFormatter.php
CacheKeyFormatter.getDefaultTypeHandler
protected function getDefaultTypeHandler($value) { //get value type $type = gettype($value); switch ($type) { case 'null': return null; case 'array': //check empty array if (count($value) == 0) return null; elseif (count($value) == 1) //get first value type hanlder return $this->getDefaultTypeHandler(current($value)); $typeHandler = null; //obtain type by checking inner values foreach ($value as $val) { $typeHandler = $this->getDefaultTypeHandler($val); //get type of the first not null value if (!is_null($typeHandler)) break; } return $typeHandler; case 'object': //get object class $classname = get_class($value); //use class as type $typeHandler = $this->typeManager->getTypeHandler($classname); if ($typeHandler !== false) return $typeHandler; //no typehandler found, throw exception throw new \RuntimeException("No default type handler found for class '$classname'"); case 'resource': //unsupported, throw exception throw new \RuntimeException("Argument of type 'resource' is not supported"); default: //generic type return $this->typeManager->getTypeHandler($type); } }
php
protected function getDefaultTypeHandler($value) { //get value type $type = gettype($value); switch ($type) { case 'null': return null; case 'array': //check empty array if (count($value) == 0) return null; elseif (count($value) == 1) //get first value type hanlder return $this->getDefaultTypeHandler(current($value)); $typeHandler = null; //obtain type by checking inner values foreach ($value as $val) { $typeHandler = $this->getDefaultTypeHandler($val); //get type of the first not null value if (!is_null($typeHandler)) break; } return $typeHandler; case 'object': //get object class $classname = get_class($value); //use class as type $typeHandler = $this->typeManager->getTypeHandler($classname); if ($typeHandler !== false) return $typeHandler; //no typehandler found, throw exception throw new \RuntimeException("No default type handler found for class '$classname'"); case 'resource': //unsupported, throw exception throw new \RuntimeException("Argument of type 'resource' is not supported"); default: //generic type return $this->typeManager->getTypeHandler($type); } }
[ "protected", "function", "getDefaultTypeHandler", "(", "$", "value", ")", "{", "//get value type", "$", "type", "=", "gettype", "(", "$", "value", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'null'", ":", "return", "null", ";", "case", "'arr...
Obtains the default type handler for a given value @param mixed $value @throws \RuntimeException @return NULL | TypeHandler
[ "Obtains", "the", "default", "type", "handler", "for", "a", "given", "value" ]
df7100e601d2a1363d07028a786b6ceb22271829
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Cache/Key/CacheKeyFormatter.php#L66-L110
train
emaphp/eMapper
lib/eMapper/Cache/Key/CacheKeyFormatter.php
CacheKeyFormatter.castArray
protected function castArray($value, TypeHandler $typeHandler, $join_string = ',') { $list = []; //build expression list foreach ($value as $val) { $val = $typeHandler->castParameter($val); if (is_null($val)) $new_elem = 'NULL'; else { $new_elem = $typeHandler->setParameter($val); if (is_null($new_elem)) $new_elem = 'NULL'; elseif (!is_string($new_elem)) $new_elem = strval($new_elem); } $list[] = $new_elem; } //return joined expression return implode($join_string, $list); }
php
protected function castArray($value, TypeHandler $typeHandler, $join_string = ',') { $list = []; //build expression list foreach ($value as $val) { $val = $typeHandler->castParameter($val); if (is_null($val)) $new_elem = 'NULL'; else { $new_elem = $typeHandler->setParameter($val); if (is_null($new_elem)) $new_elem = 'NULL'; elseif (!is_string($new_elem)) $new_elem = strval($new_elem); } $list[] = $new_elem; } //return joined expression return implode($join_string, $list); }
[ "protected", "function", "castArray", "(", "$", "value", ",", "TypeHandler", "$", "typeHandler", ",", "$", "join_string", "=", "','", ")", "{", "$", "list", "=", "[", "]", ";", "//build expression list", "foreach", "(", "$", "value", "as", "$", "val", ")...
Casts all elements in an array with the given type handler @param array $value @param TypeHandler $typeHandler @param string $join_string @return string
[ "Casts", "all", "elements", "in", "an", "array", "with", "the", "given", "type", "handler" ]
df7100e601d2a1363d07028a786b6ceb22271829
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Cache/Key/CacheKeyFormatter.php#L119-L141
train
emaphp/eMapper
lib/eMapper/Cache/Key/CacheKeyFormatter.php
CacheKeyFormatter.castParameter
protected function castParameter($value, $type = null) { //check null value if (is_null($value)) return 'NULL'; elseif (is_null($type)) { //obtain default type handler $typeHandler = $this->getDefaultTypeHandler($value); if (is_null($typeHandler)) return 'NULL'; if (is_array($value)) return $this->castArray($value, $typeHandler, '_'); } else { //cast value to the specified type $typeHandler = $this->typeManager->getTypeHandler($type); if ($typeHandler === false) throw new \RuntimeException("No type handler found for type '$type'"); if (is_array($value)) return $this->castArray($value, $typeHandler, '_'); //check if returned value is null $value = $typeHandler->castParameter($value); if (is_null($value)) return 'NULL'; } //get parameter expression $value = $typeHandler->setParameter($value); //check null value if (is_null($value)) return 'NULL'; //cast to string if (!is_string($value)) $value = strval($value); return $value; }
php
protected function castParameter($value, $type = null) { //check null value if (is_null($value)) return 'NULL'; elseif (is_null($type)) { //obtain default type handler $typeHandler = $this->getDefaultTypeHandler($value); if (is_null($typeHandler)) return 'NULL'; if (is_array($value)) return $this->castArray($value, $typeHandler, '_'); } else { //cast value to the specified type $typeHandler = $this->typeManager->getTypeHandler($type); if ($typeHandler === false) throw new \RuntimeException("No type handler found for type '$type'"); if (is_array($value)) return $this->castArray($value, $typeHandler, '_'); //check if returned value is null $value = $typeHandler->castParameter($value); if (is_null($value)) return 'NULL'; } //get parameter expression $value = $typeHandler->setParameter($value); //check null value if (is_null($value)) return 'NULL'; //cast to string if (!is_string($value)) $value = strval($value); return $value; }
[ "protected", "function", "castParameter", "(", "$", "value", ",", "$", "type", "=", "null", ")", "{", "//check null value", "if", "(", "is_null", "(", "$", "value", ")", ")", "return", "'NULL'", ";", "elseif", "(", "is_null", "(", "$", "type", ")", ")"...
Casts a value to a given type @param mixed $value @param string $type @return string @throws \RuntimeException
[ "Casts", "a", "value", "to", "a", "given", "type" ]
df7100e601d2a1363d07028a786b6ceb22271829
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Cache/Key/CacheKeyFormatter.php#L150-L188
train
emaphp/eMapper
lib/eMapper/Cache/Key/CacheKeyFormatter.php
CacheKeyFormatter.replaceConfigExpression
protected function replaceConfigExpression($matches) { $property = $matches[1]; //check key existence if (!array_key_exists($property, $this->config)) return ''; //convert to string, if possible if (($str = $this->toString($this->config[$property])) === false) return ''; return $str; }
php
protected function replaceConfigExpression($matches) { $property = $matches[1]; //check key existence if (!array_key_exists($property, $this->config)) return ''; //convert to string, if possible if (($str = $this->toString($this->config[$property])) === false) return ''; return $str; }
[ "protected", "function", "replaceConfigExpression", "(", "$", "matches", ")", "{", "$", "property", "=", "$", "matches", "[", "1", "]", ";", "//check key existence", "if", "(", "!", "array_key_exists", "(", "$", "property", ",", "$", "this", "->", "config", ...
Returns a string that replaces a configuration expression within a string @param array $matches @return string
[ "Returns", "a", "string", "that", "replaces", "a", "configuration", "expression", "within", "a", "string" ]
df7100e601d2a1363d07028a786b6ceb22271829
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Cache/Key/CacheKeyFormatter.php#L360-L369
train
emaphp/eMapper
lib/eMapper/Cache/Key/CacheKeyFormatter.php
CacheKeyFormatter.replacePropertyExpression
protected function replacePropertyExpression($matches) { //count available matches //this indicates the type of expression to replace $total_matches = count($matches); $type = $subindex = null; switch ($total_matches) { /* * Property */ case 4: //#{PROPERTY@1[INDEX]@2?:TYPE@3} $type = substr($matches[3], 1); case 3: //#{PROPERTY@1[INDEX]@2} $subindex = empty($matches[2]) ? null : substr($matches[2], 1, -1); case 2: //#{PROPERTY@1} $key = $matches[1]; //obtain type from annotation (when possible) if (is_null($type) && $this->wrappedArg instanceof ObjectArgumentWrapper) { if ($this->wrappedArg->getClassProfile()->isEntity()) { $property = $this->wrappedArg->getClassProfile()->getProperty($key); $type = $property->getType(); } } return $this->getIndex($key, $subindex, $type); break; /* * Interval */ case 9: //#{PROPERTY@4[LEFT_INDEX@6..RIGHT_INDEX@7]:TYPE@8} $type = substr($matches[8], 1); case 8: //#{PROPERTY@4[LEFT_INDEX@6..RIGHT_INDEX@7]} $key = $matches[4]; //obtain type from annotation (when possible) if (is_null($type) && $this->wrappedArg instanceof ObjectArgumentWrapper) { if ($this->wrappedArg->getClassProfile()->isEntity()) { $property = $this->wrappedArg->getClassProfile()->getProperty($key); $type = $property->getType(); } } return $this->getRange($key, $matches[6], $matches[7], $type); break; } }
php
protected function replacePropertyExpression($matches) { //count available matches //this indicates the type of expression to replace $total_matches = count($matches); $type = $subindex = null; switch ($total_matches) { /* * Property */ case 4: //#{PROPERTY@1[INDEX]@2?:TYPE@3} $type = substr($matches[3], 1); case 3: //#{PROPERTY@1[INDEX]@2} $subindex = empty($matches[2]) ? null : substr($matches[2], 1, -1); case 2: //#{PROPERTY@1} $key = $matches[1]; //obtain type from annotation (when possible) if (is_null($type) && $this->wrappedArg instanceof ObjectArgumentWrapper) { if ($this->wrappedArg->getClassProfile()->isEntity()) { $property = $this->wrappedArg->getClassProfile()->getProperty($key); $type = $property->getType(); } } return $this->getIndex($key, $subindex, $type); break; /* * Interval */ case 9: //#{PROPERTY@4[LEFT_INDEX@6..RIGHT_INDEX@7]:TYPE@8} $type = substr($matches[8], 1); case 8: //#{PROPERTY@4[LEFT_INDEX@6..RIGHT_INDEX@7]} $key = $matches[4]; //obtain type from annotation (when possible) if (is_null($type) && $this->wrappedArg instanceof ObjectArgumentWrapper) { if ($this->wrappedArg->getClassProfile()->isEntity()) { $property = $this->wrappedArg->getClassProfile()->getProperty($key); $type = $property->getType(); } } return $this->getRange($key, $matches[6], $matches[7], $type); break; } }
[ "protected", "function", "replacePropertyExpression", "(", "$", "matches", ")", "{", "//count available matches", "//this indicates the type of expression to replace", "$", "total_matches", "=", "count", "(", "$", "matches", ")", ";", "$", "type", "=", "$", "subindex", ...
Returns a string that replaces a property expression @param array $matches @return string
[ "Returns", "a", "string", "that", "replaces", "a", "property", "expression" ]
df7100e601d2a1363d07028a786b6ceb22271829
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Cache/Key/CacheKeyFormatter.php#L376-L423
train
emaphp/eMapper
lib/eMapper/Cache/Key/CacheKeyFormatter.php
CacheKeyFormatter.replaceArgumentExpression
protected function replaceArgumentExpression($matches) { //count available matches //this indicates the type of expression to replace $total_matches = count($matches); $type = $subindex = null; //%{TYPE|CLASS@1} if ($total_matches == 2) { //check if there are arguments left if ($this->counter >= count($this->args)) throw new \OutOfBoundsException("No arguments left for expression '{$matches[0]}'"); return $this->castParameter($this->args[$this->counter++], $matches[1]); } switch ($total_matches) { /* * Simple index */ case 5: //%{NUMBER@2[INDEX]@3?:TYPE@4} $type = substr($matches[4], 1); case 4: //%{NUMBER@2[INDEX]@3} $subindex = empty($matches[3]) ? null : substr($matches[3], 1, -1); case 3: //%{NUMBER@2} $index = intval($matches[2]); if (!array_key_exists($index, $this->args)) throw new \InvalidArgumentException("No value found on index $index"); if ($index == 0 && !is_null($subindex)) return $this->getIndex($subindex, null, $type); return $this->getSubIndex($this->args[$index], $subindex, $type); /* * Interval */ case 10: //%{NUMBER@5[LEFT@7?..RIGHT@8?]:TYPE@9} $type = substr($matches[9], 1); case 9: //%{NUMBER@5[LEFT@7?..RIGHT@8?]} $index = intval($matches[5]); if (!array_key_exists($index, $this->args)) throw new \InvalidArgumentException("No value found on index $index"); return $this->getSubRange($this->args[$index], $matches[7], $matches[8], $type); } }
php
protected function replaceArgumentExpression($matches) { //count available matches //this indicates the type of expression to replace $total_matches = count($matches); $type = $subindex = null; //%{TYPE|CLASS@1} if ($total_matches == 2) { //check if there are arguments left if ($this->counter >= count($this->args)) throw new \OutOfBoundsException("No arguments left for expression '{$matches[0]}'"); return $this->castParameter($this->args[$this->counter++], $matches[1]); } switch ($total_matches) { /* * Simple index */ case 5: //%{NUMBER@2[INDEX]@3?:TYPE@4} $type = substr($matches[4], 1); case 4: //%{NUMBER@2[INDEX]@3} $subindex = empty($matches[3]) ? null : substr($matches[3], 1, -1); case 3: //%{NUMBER@2} $index = intval($matches[2]); if (!array_key_exists($index, $this->args)) throw new \InvalidArgumentException("No value found on index $index"); if ($index == 0 && !is_null($subindex)) return $this->getIndex($subindex, null, $type); return $this->getSubIndex($this->args[$index], $subindex, $type); /* * Interval */ case 10: //%{NUMBER@5[LEFT@7?..RIGHT@8?]:TYPE@9} $type = substr($matches[9], 1); case 9: //%{NUMBER@5[LEFT@7?..RIGHT@8?]} $index = intval($matches[5]); if (!array_key_exists($index, $this->args)) throw new \InvalidArgumentException("No value found on index $index"); return $this->getSubRange($this->args[$index], $matches[7], $matches[8], $type); } }
[ "protected", "function", "replaceArgumentExpression", "(", "$", "matches", ")", "{", "//count available matches", "//this indicates the type of expression to replace", "$", "total_matches", "=", "count", "(", "$", "matches", ")", ";", "$", "type", "=", "$", "subindex", ...
Returns a string that replaces an argument expression @param array$matches @throws \OutOfBoundsException @throws \InvalidArgumentException @return string
[ "Returns", "a", "string", "that", "replaces", "an", "argument", "expression" ]
df7100e601d2a1363d07028a786b6ceb22271829
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Cache/Key/CacheKeyFormatter.php#L432-L479
train
novuso/system
src/Utility/Validate.php
Validate.isEmail
public static function isEmail($value): bool { if (!static::isStringCastable($value)) { return false; } return filter_var((string) $value, FILTER_VALIDATE_EMAIL) !== false; }
php
public static function isEmail($value): bool { if (!static::isStringCastable($value)) { return false; } return filter_var((string) $value, FILTER_VALIDATE_EMAIL) !== false; }
[ "public", "static", "function", "isEmail", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "filter_var", "(", "(", "string", ")", "...
Checks if value is an email address @param mixed $value The value @return bool
[ "Checks", "if", "value", "is", "an", "email", "address" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L338-L345
train
novuso/system
src/Utility/Validate.php
Validate.isIpAddress
public static function isIpAddress($value): bool { if (!static::isStringCastable($value)) { return false; } return filter_var((string) $value, FILTER_VALIDATE_IP) !== false; }
php
public static function isIpAddress($value): bool { if (!static::isStringCastable($value)) { return false; } return filter_var((string) $value, FILTER_VALIDATE_IP) !== false; }
[ "public", "static", "function", "isIpAddress", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "filter_var", "(", "(", "string", ")",...
Checks if value is an IP address @param mixed $value The value @return bool
[ "Checks", "if", "value", "is", "an", "IP", "address" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L354-L361
train
novuso/system
src/Utility/Validate.php
Validate.isIpV4Address
public static function isIpV4Address($value): bool { if (!static::isStringCastable($value)) { return false; } return filter_var((string) $value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false; }
php
public static function isIpV4Address($value): bool { if (!static::isStringCastable($value)) { return false; } return filter_var((string) $value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false; }
[ "public", "static", "function", "isIpV4Address", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "filter_var", "(", "(", "string", ")...
Checks if value is an IPv4 address @param mixed $value The value @return bool
[ "Checks", "if", "value", "is", "an", "IPv4", "address" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L370-L377
train
novuso/system
src/Utility/Validate.php
Validate.isIpV6Address
public static function isIpV6Address($value): bool { if (!static::isStringCastable($value)) { return false; } return filter_var((string) $value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false; }
php
public static function isIpV6Address($value): bool { if (!static::isStringCastable($value)) { return false; } return filter_var((string) $value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false; }
[ "public", "static", "function", "isIpV6Address", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "filter_var", "(", "(", "string", ")...
Checks if value is an IPv6 address @param mixed $value The value @return bool
[ "Checks", "if", "value", "is", "an", "IPv6", "address" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L386-L393
train
novuso/system
src/Utility/Validate.php
Validate.isUri
public static function isUri($value): bool { if (!static::isStringCastable($value)) { return false; } // http://tools.ietf.org/html/rfc3986 // // URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] // hier-part = "//" authority path-abempty // / path-absolute // / path-rootless // / path-empty $pattern = sprintf( '/\A%s%s%s%s%s\z/', '(?:([^:\/?#]+)(:))?', '(?:(\/\/)([^\/?#]*))?', '([^?#]*)', '(?:(\?)([^#]*))?', '(?:(#)(.*))?' ); preg_match($pattern, (string) $value, $matches); $uri = self::uriComponentsFromMatches($matches); return self::isValidUri($uri); }
php
public static function isUri($value): bool { if (!static::isStringCastable($value)) { return false; } // http://tools.ietf.org/html/rfc3986 // // URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] // hier-part = "//" authority path-abempty // / path-absolute // / path-rootless // / path-empty $pattern = sprintf( '/\A%s%s%s%s%s\z/', '(?:([^:\/?#]+)(:))?', '(?:(\/\/)([^\/?#]*))?', '([^?#]*)', '(?:(\?)([^#]*))?', '(?:(#)(.*))?' ); preg_match($pattern, (string) $value, $matches); $uri = self::uriComponentsFromMatches($matches); return self::isValidUri($uri); }
[ "public", "static", "function", "isUri", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "// http://tools.ietf.org/html/rfc3986", "//", "// URI ...
Checks if value is a URI @param mixed $value The value @return bool
[ "Checks", "if", "value", "is", "a", "URI" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L402-L428
train
novuso/system
src/Utility/Validate.php
Validate.isUrn
public static function isUrn($value): bool { if (!static::isStringCastable($value)) { return false; } // http://tools.ietf.org/html/rfc2141#section-2.1 // To avoid confusion with the "urn:" identifier, the NID "urn" is // reserved and MUST NOT be used if (substr((string) $value, 0, 8) === "urn:urn:") { return false; } // http://tools.ietf.org/html/rfc2141 // // <URN> ::= "urn:" <NID> ":" <NSS> // // <NID> ::= <let-num> [ 1,31<let-num-hyp> ] // <let-num-hyp> ::= <upper> | <lower> | <number> | "-" // <let-num> ::= <upper> | <lower> | <number> // <upper> ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | // "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | // "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | // "Y" | "Z" // <lower> ::= "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | // "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | // "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | // "y" | "z" // <number> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | // "8" | "9" // // <NSS> ::= 1*<URN chars> // <URN chars> ::= <trans> | "%" <hex> <hex> // <trans> ::= <upper> | <lower> | <number> | <other> | <reserved> // <hex> ::= <number> | "A" | "B" | "C" | "D" | "E" | "F" | // "a" | "b" | "c" | "d" | "e" | "f" // <other> ::= "(" | ")" | "+" | "," | "-" | "." | // ":" | "=" | "@" | ";" | "$" | // "_" | "!" | "*" | "'" // // Therefore, these characters are RESERVED for future developments. // Namespace developers SHOULD NOT use these characters in unencoded // form, but rather use the appropriate %-encoding for each character. // // In addition, octet 0 (0 hex) should NEVER be used, in either // unencoded or %-encoded form. $pattern = sprintf( '/\Aurn:%s:%s\z/i', '[a-z0-9](?:[a-z0-9\-]{1,31})?', '(?:[a-z0-9()+,\-.:=@;$_!*\']|%(?:0[a-f1-9]|[a-f1-9][a-f0-9]))+' ); return !!preg_match($pattern, (string) $value); }
php
public static function isUrn($value): bool { if (!static::isStringCastable($value)) { return false; } // http://tools.ietf.org/html/rfc2141#section-2.1 // To avoid confusion with the "urn:" identifier, the NID "urn" is // reserved and MUST NOT be used if (substr((string) $value, 0, 8) === "urn:urn:") { return false; } // http://tools.ietf.org/html/rfc2141 // // <URN> ::= "urn:" <NID> ":" <NSS> // // <NID> ::= <let-num> [ 1,31<let-num-hyp> ] // <let-num-hyp> ::= <upper> | <lower> | <number> | "-" // <let-num> ::= <upper> | <lower> | <number> // <upper> ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | // "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | // "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | // "Y" | "Z" // <lower> ::= "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | // "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | // "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | // "y" | "z" // <number> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | // "8" | "9" // // <NSS> ::= 1*<URN chars> // <URN chars> ::= <trans> | "%" <hex> <hex> // <trans> ::= <upper> | <lower> | <number> | <other> | <reserved> // <hex> ::= <number> | "A" | "B" | "C" | "D" | "E" | "F" | // "a" | "b" | "c" | "d" | "e" | "f" // <other> ::= "(" | ")" | "+" | "," | "-" | "." | // ":" | "=" | "@" | ";" | "$" | // "_" | "!" | "*" | "'" // // Therefore, these characters are RESERVED for future developments. // Namespace developers SHOULD NOT use these characters in unencoded // form, but rather use the appropriate %-encoding for each character. // // In addition, octet 0 (0 hex) should NEVER be used, in either // unencoded or %-encoded form. $pattern = sprintf( '/\Aurn:%s:%s\z/i', '[a-z0-9](?:[a-z0-9\-]{1,31})?', '(?:[a-z0-9()+,\-.:=@;$_!*\']|%(?:0[a-f1-9]|[a-f1-9][a-f0-9]))+' ); return !!preg_match($pattern, (string) $value); }
[ "public", "static", "function", "isUrn", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "// http://tools.ietf.org/html/rfc2141#section-2.1", "// To av...
Checks if value is a URN @param mixed $value The value @return bool
[ "Checks", "if", "value", "is", "a", "URN" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L437-L490
train
novuso/system
src/Utility/Validate.php
Validate.isUuid
public static function isUuid($value): bool { if (!static::isStringCastable($value)) { return false; } // http://tools.ietf.org/html/rfc4122 // // UUID = time-low "-" time-mid "-" // time-high-and-version "-" // clock-seq-and-reserved // clock-seq-low "-" node // time-low = 4hexOctet // time-mid = 2hexOctet // time-high-and-version = 2hexOctet // clock-seq-and-reserved = hexOctet // clock-seq-low = hexOctet // node = 6hexOctet // hexOctet = hexDigit hexDigit // hexDigit = // "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9" / // "a" / "b" / "c" / "d" / "e" / "f" / // "A" / "B" / "C" / "D" / "E" / "F" $pattern = sprintf( '/\A%s-%s-%s-%s%s-%s\z/i', '[a-f0-9]{8}', '[a-f0-9]{4}', '[a-f0-9]{4}', '[a-f0-9]{2}', '[a-f0-9]{2}', '[a-f0-9]{12}' ); $value = str_replace(['urn:', 'uuid:', '{', '}'], '', (string) $value); return !!preg_match($pattern, $value); }
php
public static function isUuid($value): bool { if (!static::isStringCastable($value)) { return false; } // http://tools.ietf.org/html/rfc4122 // // UUID = time-low "-" time-mid "-" // time-high-and-version "-" // clock-seq-and-reserved // clock-seq-low "-" node // time-low = 4hexOctet // time-mid = 2hexOctet // time-high-and-version = 2hexOctet // clock-seq-and-reserved = hexOctet // clock-seq-low = hexOctet // node = 6hexOctet // hexOctet = hexDigit hexDigit // hexDigit = // "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9" / // "a" / "b" / "c" / "d" / "e" / "f" / // "A" / "B" / "C" / "D" / "E" / "F" $pattern = sprintf( '/\A%s-%s-%s-%s%s-%s\z/i', '[a-f0-9]{8}', '[a-f0-9]{4}', '[a-f0-9]{4}', '[a-f0-9]{2}', '[a-f0-9]{2}', '[a-f0-9]{12}' ); $value = str_replace(['urn:', 'uuid:', '{', '}'], '', (string) $value); return !!preg_match($pattern, $value); }
[ "public", "static", "function", "isUuid", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "// http://tools.ietf.org/html/rfc4122", "//", "// UUID ...
Checks if value is a UUID @param mixed $value The value @return bool
[ "Checks", "if", "value", "is", "a", "UUID" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L499-L535
train
novuso/system
src/Utility/Validate.php
Validate.isTimezone
public static function isTimezone($value): bool { if ($value instanceof DateTimeZone) { return true; } if (!static::isStringCastable($value)) { return false; } return self::isValidTimezone((string) $value); }
php
public static function isTimezone($value): bool { if ($value instanceof DateTimeZone) { return true; } if (!static::isStringCastable($value)) { return false; } return self::isValidTimezone((string) $value); }
[ "public", "static", "function", "isTimezone", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "$", "value", "instanceof", "DateTimeZone", ")", "{", "return", "true", ";", "}", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ...
Checks if value is a timezone @param mixed $value The value @return bool
[ "Checks", "if", "value", "is", "a", "timezone" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L544-L555
train
novuso/system
src/Utility/Validate.php
Validate.isJson
public static function isJson($value): bool { if (!static::isStringCastable($value)) { return false; } if (((string) $value) === 'null') { return true; } return (json_decode((string) $value) !== null && json_last_error() === JSON_ERROR_NONE); }
php
public static function isJson($value): bool { if (!static::isStringCastable($value)) { return false; } if (((string) $value) === 'null') { return true; } return (json_decode((string) $value) !== null && json_last_error() === JSON_ERROR_NONE); }
[ "public", "static", "function", "isJson", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "if", "(", "(", "(", "string", ")", "$", "value",...
Checks if value is a JSON string @param mixed $value The value @return bool
[ "Checks", "if", "value", "is", "a", "JSON", "string" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L564-L575
train
novuso/system
src/Utility/Validate.php
Validate.isMatch
public static function isMatch($value, string $pattern): bool { if (!static::isStringCastable($value)) { return false; } return !!preg_match($pattern, (string) $value); }
php
public static function isMatch($value, string $pattern): bool { if (!static::isStringCastable($value)) { return false; } return !!preg_match($pattern, (string) $value); }
[ "public", "static", "function", "isMatch", "(", "$", "value", ",", "string", "$", "pattern", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "!", "!",...
Checks if value matches a regular expression @param mixed $value The value @param string $pattern The regex pattern @return bool
[ "Checks", "if", "value", "matches", "a", "regular", "expression" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L585-L592
train
novuso/system
src/Utility/Validate.php
Validate.contains
public static function contains($value, string $search, string $encoding = 'UTF-8'): bool { if (!static::isStringCastable($value)) { return false; } return mb_strpos((string) $value, $search, 0, $encoding) !== false; }
php
public static function contains($value, string $search, string $encoding = 'UTF-8'): bool { if (!static::isStringCastable($value)) { return false; } return mb_strpos((string) $value, $search, 0, $encoding) !== false; }
[ "public", "static", "function", "contains", "(", "$", "value", ",", "string", "$", "search", ",", "string", "$", "encoding", "=", "'UTF-8'", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", ...
Checks if value contains a search string @param mixed $value The value @param string $search The search string @param string $encoding The string encoding @return bool
[ "Checks", "if", "value", "contains", "a", "search", "string" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L603-L610
train
novuso/system
src/Utility/Validate.php
Validate.startsWith
public static function startsWith($value, string $search, string $encoding = 'UTF-8'): bool { if (!static::isStringCastable($value)) { return false; } $searchlen = (int) mb_strlen($search, $encoding); $start = mb_substr((string) $value, 0, $searchlen, $encoding); return $search === $start; }
php
public static function startsWith($value, string $search, string $encoding = 'UTF-8'): bool { if (!static::isStringCastable($value)) { return false; } $searchlen = (int) mb_strlen($search, $encoding); $start = mb_substr((string) $value, 0, $searchlen, $encoding); return $search === $start; }
[ "public", "static", "function", "startsWith", "(", "$", "value", ",", "string", "$", "search", ",", "string", "$", "encoding", "=", "'UTF-8'", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", ...
Checks if value starts with a search string @param mixed $value The value @param string $search The search string @param string $encoding The string encoding @return bool
[ "Checks", "if", "value", "starts", "with", "a", "search", "string" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L621-L631
train
novuso/system
src/Utility/Validate.php
Validate.endsWith
public static function endsWith($value, string $search, string $encoding = 'UTF-8'): bool { if (!static::isStringCastable($value)) { return false; } $searchlen = (int) mb_strlen($search, $encoding); $length = (int) mb_strlen((string) $value, $encoding); $end = mb_substr((string) $value, $length - $searchlen, $searchlen, $encoding); return $search === $end; }
php
public static function endsWith($value, string $search, string $encoding = 'UTF-8'): bool { if (!static::isStringCastable($value)) { return false; } $searchlen = (int) mb_strlen($search, $encoding); $length = (int) mb_strlen((string) $value, $encoding); $end = mb_substr((string) $value, $length - $searchlen, $searchlen, $encoding); return $search === $end; }
[ "public", "static", "function", "endsWith", "(", "$", "value", ",", "string", "$", "search", ",", "string", "$", "encoding", "=", "'UTF-8'", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", ...
Checks if value ends with a search string @param mixed $value The value @param string $search The search string @param string $encoding The string encoding @return bool
[ "Checks", "if", "value", "ends", "with", "a", "search", "string" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L642-L653
train
novuso/system
src/Utility/Validate.php
Validate.exactLength
public static function exactLength($value, int $length, string $encoding = 'UTF-8'): bool { if (!static::isStringCastable($value)) { return false; } $strlen = (int) mb_strlen((string) $value, $encoding); return $strlen === $length; }
php
public static function exactLength($value, int $length, string $encoding = 'UTF-8'): bool { if (!static::isStringCastable($value)) { return false; } $strlen = (int) mb_strlen((string) $value, $encoding); return $strlen === $length; }
[ "public", "static", "function", "exactLength", "(", "$", "value", ",", "int", "$", "length", ",", "string", "$", "encoding", "=", "'UTF-8'", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", ...
Checks if value has an exact string length @param mixed $value The value @param int $length The string length @param string $encoding The string encoding @return bool
[ "Checks", "if", "value", "has", "an", "exact", "string", "length" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L664-L673
train
novuso/system
src/Utility/Validate.php
Validate.minLength
public static function minLength($value, int $minLength, string $encoding = 'UTF-8'): bool { if (!static::isStringCastable($value)) { return false; } $strlen = (int) mb_strlen((string) $value, $encoding); return $strlen >= $minLength; }
php
public static function minLength($value, int $minLength, string $encoding = 'UTF-8'): bool { if (!static::isStringCastable($value)) { return false; } $strlen = (int) mb_strlen((string) $value, $encoding); return $strlen >= $minLength; }
[ "public", "static", "function", "minLength", "(", "$", "value", ",", "int", "$", "minLength", ",", "string", "$", "encoding", "=", "'UTF-8'", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", ...
Checks if value has a string length greater or equal to a minimum @param mixed $value The value @param int $minLength The minimum length @param string $encoding The string encoding @return bool
[ "Checks", "if", "value", "has", "a", "string", "length", "greater", "or", "equal", "to", "a", "minimum" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L684-L693
train
novuso/system
src/Utility/Validate.php
Validate.rangeLength
public static function rangeLength($value, int $minLength, int $maxLength, string $encoding = 'UTF-8'): bool { if (!static::isStringCastable($value)) { return false; } $strlen = (int) mb_strlen((string) $value, $encoding); if ($strlen < $minLength) { return false; } if ($strlen > $maxLength) { return false; } return true; }
php
public static function rangeLength($value, int $minLength, int $maxLength, string $encoding = 'UTF-8'): bool { if (!static::isStringCastable($value)) { return false; } $strlen = (int) mb_strlen((string) $value, $encoding); if ($strlen < $minLength) { return false; } if ($strlen > $maxLength) { return false; } return true; }
[ "public", "static", "function", "rangeLength", "(", "$", "value", ",", "int", "$", "minLength", ",", "int", "$", "maxLength", ",", "string", "$", "encoding", "=", "'UTF-8'", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", ...
Checks if value has a string length within a range @param mixed $value The value @param int $minLength The minimum length @param int $maxLength The maximum length @param string $encoding The string encoding @return bool
[ "Checks", "if", "value", "has", "a", "string", "length", "within", "a", "range" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L725-L741
train
novuso/system
src/Utility/Validate.php
Validate.rangeNumber
public static function rangeNumber($value, $minNumber, $maxNumber): bool { if (!is_numeric($value)) { return false; } if ($value < $minNumber) { return false; } if ($value > $maxNumber) { return false; } return true; }
php
public static function rangeNumber($value, $minNumber, $maxNumber): bool { if (!is_numeric($value)) { return false; } if ($value < $minNumber) { return false; } if ($value > $maxNumber) { return false; } return true; }
[ "public", "static", "function", "rangeNumber", "(", "$", "value", ",", "$", "minNumber", ",", "$", "maxNumber", ")", ":", "bool", "{", "if", "(", "!", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "val...
Checks if value is within a numeric range @param mixed $value The value @param int|float $minNumber The minimum number @param int|float $maxNumber The maximum number @return bool
[ "Checks", "if", "value", "is", "within", "a", "numeric", "range" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L803-L817
train
novuso/system
src/Utility/Validate.php
Validate.intValue
public static function intValue($value): bool { if (!is_numeric($value)) { return false; } return strval(intval($value)) == $value; }
php
public static function intValue($value): bool { if (!is_numeric($value)) { return false; } return strval(intval($value)) == $value; }
[ "public", "static", "function", "intValue", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "strval", "(", "intval", "(", "$", "value", ")", ")", "==",...
Checks if value can be cast to an integer without changing value Passing values include integers, integer strings, and floating-point numbers with integer values. @param mixed $value The value @return bool
[ "Checks", "if", "value", "can", "be", "cast", "to", "an", "integer", "without", "changing", "value" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L865-L872
train
novuso/system
src/Utility/Validate.php
Validate.exactCount
public static function exactCount($value, int $count): bool { if (!static::isCountable($value)) { return false; } return count($value) == $count; }
php
public static function exactCount($value, int $count): bool { if (!static::isCountable($value)) { return false; } return count($value) == $count; }
[ "public", "static", "function", "exactCount", "(", "$", "value", ",", "int", "$", "count", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isCountable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "count", "(", ...
Checks if value has an exact count @param mixed $value The value @param int $count The count @return bool
[ "Checks", "if", "value", "has", "an", "exact", "count" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L882-L889
train
novuso/system
src/Utility/Validate.php
Validate.minCount
public static function minCount($value, int $minCount): bool { if (!static::isCountable($value)) { return false; } return count($value) >= $minCount; }
php
public static function minCount($value, int $minCount): bool { if (!static::isCountable($value)) { return false; } return count($value) >= $minCount; }
[ "public", "static", "function", "minCount", "(", "$", "value", ",", "int", "$", "minCount", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isCountable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "count", "(", ...
Checks if value has a count greater or equal to a minimum @param mixed $value The value @param int $minCount The minimum count @return bool
[ "Checks", "if", "value", "has", "a", "count", "greater", "or", "equal", "to", "a", "minimum" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L899-L906
train
novuso/system
src/Utility/Validate.php
Validate.maxCount
public static function maxCount($value, int $maxCount): bool { if (!static::isCountable($value)) { return false; } return count($value) <= $maxCount; }
php
public static function maxCount($value, int $maxCount): bool { if (!static::isCountable($value)) { return false; } return count($value) <= $maxCount; }
[ "public", "static", "function", "maxCount", "(", "$", "value", ",", "int", "$", "maxCount", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isCountable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "count", "(", ...
Checks if value has a count less or equal to a maximum @param mixed $value The value @param int $maxCount The maximum count @return bool
[ "Checks", "if", "value", "has", "a", "count", "less", "or", "equal", "to", "a", "maximum" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L916-L923
train
novuso/system
src/Utility/Validate.php
Validate.rangeCount
public static function rangeCount($value, int $minCount, int $maxCount): bool { if (!static::isCountable($value)) { return false; } $count = count($value); if ($count < $minCount) { return false; } if ($count > $maxCount) { return false; } return true; }
php
public static function rangeCount($value, int $minCount, int $maxCount): bool { if (!static::isCountable($value)) { return false; } $count = count($value); if ($count < $minCount) { return false; } if ($count > $maxCount) { return false; } return true; }
[ "public", "static", "function", "rangeCount", "(", "$", "value", ",", "int", "$", "minCount", ",", "int", "$", "maxCount", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isCountable", "(", "$", "value", ")", ")", "{", "return", "false", ";",...
Checks if value has a count within a range @param mixed $value The value @param int $minCount The minimum count @param int $maxCount The maximum count @return bool
[ "Checks", "if", "value", "has", "a", "count", "within", "a", "range" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L934-L950
train
novuso/system
src/Utility/Validate.php
Validate.isOneOf
public static function isOneOf($value, iterable $choices): bool { foreach ($choices as $choice) { if ($value === $choice) { return true; } } return false; }
php
public static function isOneOf($value, iterable $choices): bool { foreach ($choices as $choice) { if ($value === $choice) { return true; } } return false; }
[ "public", "static", "function", "isOneOf", "(", "$", "value", ",", "iterable", "$", "choices", ")", ":", "bool", "{", "foreach", "(", "$", "choices", "as", "$", "choice", ")", "{", "if", "(", "$", "value", "===", "$", "choice", ")", "{", "return", ...
Checks if value is one of a set of choices @param mixed $value The value @param iterable $choices The choices @return bool
[ "Checks", "if", "value", "is", "one", "of", "a", "set", "of", "choices" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L960-L969
train
novuso/system
src/Utility/Validate.php
Validate.keyIsset
public static function keyIsset($value, $key): bool { if (!static::isArrayAccessible($value)) { return false; } return isset($value[$key]); }
php
public static function keyIsset($value, $key): bool { if (!static::isArrayAccessible($value)) { return false; } return isset($value[$key]); }
[ "public", "static", "function", "keyIsset", "(", "$", "value", ",", "$", "key", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isArrayAccessible", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "isset", "(", "$", ...
Checks if value is array accessible with a non-null key @param mixed $value The value @param mixed $key The key @return bool
[ "Checks", "if", "value", "is", "array", "accessible", "with", "a", "non", "-", "null", "key" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L979-L986
train
novuso/system
src/Utility/Validate.php
Validate.keyNotEmpty
public static function keyNotEmpty($value, $key): bool { if (!static::isArrayAccessible($value)) { return false; } return isset($value[$key]) && !empty($value[$key]); }
php
public static function keyNotEmpty($value, $key): bool { if (!static::isArrayAccessible($value)) { return false; } return isset($value[$key]) && !empty($value[$key]); }
[ "public", "static", "function", "keyNotEmpty", "(", "$", "value", ",", "$", "key", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isArrayAccessible", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "isset", "(", "$",...
Checks if value is array accessible with a non-empty key @param mixed $value The value @param mixed $key The key @return bool
[ "Checks", "if", "value", "is", "array", "accessible", "with", "a", "non", "-", "empty", "key" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L996-L1003
train
novuso/system
src/Utility/Validate.php
Validate.areEqual
public static function areEqual($value1, $value2): bool { if (static::isEquatable($value1) && static::areSameType($value1, $value2)) { return $value1->equals($value2); } return $value1 == $value2; }
php
public static function areEqual($value1, $value2): bool { if (static::isEquatable($value1) && static::areSameType($value1, $value2)) { return $value1->equals($value2); } return $value1 == $value2; }
[ "public", "static", "function", "areEqual", "(", "$", "value1", ",", "$", "value2", ")", ":", "bool", "{", "if", "(", "static", "::", "isEquatable", "(", "$", "value1", ")", "&&", "static", "::", "areSameType", "(", "$", "value1", ",", "$", "value2", ...
Checks if two values are equal @param mixed $value1 The first value @param mixed $value2 The second value @return bool
[ "Checks", "if", "two", "values", "are", "equal" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1013-L1020
train
novuso/system
src/Utility/Validate.php
Validate.areNotEqual
public static function areNotEqual($value1, $value2): bool { if (static::isEquatable($value1) && static::areSameType($value1, $value2)) { return !$value1->equals($value2); } return $value1 != $value2; }
php
public static function areNotEqual($value1, $value2): bool { if (static::isEquatable($value1) && static::areSameType($value1, $value2)) { return !$value1->equals($value2); } return $value1 != $value2; }
[ "public", "static", "function", "areNotEqual", "(", "$", "value1", ",", "$", "value2", ")", ":", "bool", "{", "if", "(", "static", "::", "isEquatable", "(", "$", "value1", ")", "&&", "static", "::", "areSameType", "(", "$", "value1", ",", "$", "value2"...
Checks if two values are not equal @param mixed $value1 The first value @param mixed $value2 The second value @return bool
[ "Checks", "if", "two", "values", "are", "not", "equal" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1030-L1037
train
novuso/system
src/Utility/Validate.php
Validate.areSameType
public static function areSameType($value1, $value2): bool { if (!is_object($value1) || !is_object($value2)) { return gettype($value1) === gettype($value2); } return get_class($value1) === get_class($value2); }
php
public static function areSameType($value1, $value2): bool { if (!is_object($value1) || !is_object($value2)) { return gettype($value1) === gettype($value2); } return get_class($value1) === get_class($value2); }
[ "public", "static", "function", "areSameType", "(", "$", "value1", ",", "$", "value2", ")", ":", "bool", "{", "if", "(", "!", "is_object", "(", "$", "value1", ")", "||", "!", "is_object", "(", "$", "value2", ")", ")", "{", "return", "gettype", "(", ...
Checks if two values are the same type @param mixed $value1 The first value @param mixed $value2 The second value @return bool
[ "Checks", "if", "two", "values", "are", "the", "same", "type" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1073-L1080
train
novuso/system
src/Utility/Validate.php
Validate.isType
public static function isType($value, ?string $type): bool { if ($type === null) { return true; } $result = self::isSimpleType($value, $type); if ($result !== null) { return $result; } return ($value instanceof $type); }
php
public static function isType($value, ?string $type): bool { if ($type === null) { return true; } $result = self::isSimpleType($value, $type); if ($result !== null) { return $result; } return ($value instanceof $type); }
[ "public", "static", "function", "isType", "(", "$", "value", ",", "?", "string", "$", "type", ")", ":", "bool", "{", "if", "(", "$", "type", "===", "null", ")", "{", "return", "true", ";", "}", "$", "result", "=", "self", "::", "isSimpleType", "(",...
Checks if value is a given type The type can be any fully-qualified class or interface name, or one of the following type strings: [array, object, bool, int, float, string, callable] @param mixed $value The value @param string|null $type The type or null to accept all types @return bool
[ "Checks", "if", "value", "is", "a", "given", "type" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1094-L1107
train
novuso/system
src/Utility/Validate.php
Validate.isListOf
public static function isListOf($value, ?string $type): bool { if (!static::isTraversable($value)) { return false; } if ($type === null) { return true; } $result = true; foreach ($value as $val) { if (!static::isType($val, $type)) { $result = false; break; } } return $result; }
php
public static function isListOf($value, ?string $type): bool { if (!static::isTraversable($value)) { return false; } if ($type === null) { return true; } $result = true; foreach ($value as $val) { if (!static::isType($val, $type)) { $result = false; break; } } return $result; }
[ "public", "static", "function", "isListOf", "(", "$", "value", ",", "?", "string", "$", "type", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isTraversable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", ...
Checks if value is a list of a given type The type can be any fully-qualified class or interface name, or one of the following type strings: [array, object, bool, int, float, string] @param mixed $value The value @param string|null $type The type or null to accept all types @return bool
[ "Checks", "if", "value", "is", "a", "list", "of", "a", "given", "type" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1121-L1141
train
novuso/system
src/Utility/Validate.php
Validate.isStringCastable
public static function isStringCastable($value): bool { $result = false; $type = strtolower(gettype($value)); switch ($type) { case 'string': case 'null': case 'boolean': case 'integer': case 'double': $result = true; break; case 'object': if (method_exists($value, '__toString')) { $result = true; } break; default: break; } return $result; }
php
public static function isStringCastable($value): bool { $result = false; $type = strtolower(gettype($value)); switch ($type) { case 'string': case 'null': case 'boolean': case 'integer': case 'double': $result = true; break; case 'object': if (method_exists($value, '__toString')) { $result = true; } break; default: break; } return $result; }
[ "public", "static", "function", "isStringCastable", "(", "$", "value", ")", ":", "bool", "{", "$", "result", "=", "false", ";", "$", "type", "=", "strtolower", "(", "gettype", "(", "$", "value", ")", ")", ";", "switch", "(", "$", "type", ")", "{", ...
Checks if value can be cast to a string @param mixed $value The value @return bool
[ "Checks", "if", "value", "can", "be", "cast", "to", "a", "string" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1150-L1172
train
novuso/system
src/Utility/Validate.php
Validate.isJsonEncodable
public static function isJsonEncodable($value): bool { if ($value === null || is_scalar($value) || is_array($value)) { return true; } if (is_object($value) && ($value instanceof JsonSerializable)) { return true; } return false; }
php
public static function isJsonEncodable($value): bool { if ($value === null || is_scalar($value) || is_array($value)) { return true; } if (is_object($value) && ($value instanceof JsonSerializable)) { return true; } return false; }
[ "public", "static", "function", "isJsonEncodable", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "$", "value", "===", "null", "||", "is_scalar", "(", "$", "value", ")", "||", "is_array", "(", "$", "value", ")", ")", "{", "return", "true", ";",...
Checks if value can be JSON encoded @param mixed $value The value @return bool
[ "Checks", "if", "value", "can", "be", "JSON", "encoded" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1181-L1192
train
novuso/system
src/Utility/Validate.php
Validate.isSerializable
public static function isSerializable($value): bool { if ($value === null || is_scalar($value) || is_array($value)) { return true; } if (is_object($value) && ($value instanceof Serializable)) { return true; } return false; }
php
public static function isSerializable($value): bool { if ($value === null || is_scalar($value) || is_array($value)) { return true; } if (is_object($value) && ($value instanceof Serializable)) { return true; } return false; }
[ "public", "static", "function", "isSerializable", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "$", "value", "===", "null", "||", "is_scalar", "(", "$", "value", ")", "||", "is_array", "(", "$", "value", ")", ")", "{", "return", "true", ";", ...
Checks if value can be serialized @param mixed $value The value @return bool
[ "Checks", "if", "value", "can", "be", "serialized" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1201-L1212
train
novuso/system
src/Utility/Validate.php
Validate.isTraversable
public static function isTraversable($value): bool { if (is_array($value)) { return true; } if (is_object($value) && ($value instanceof Traversable)) { return true; } return false; }
php
public static function isTraversable($value): bool { if (is_array($value)) { return true; } if (is_object($value) && ($value instanceof Traversable)) { return true; } return false; }
[ "public", "static", "function", "isTraversable", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "true", ";", "}", "if", "(", "is_object", "(", "$", "value", ")", "&&", "(", "$", "value",...
Checks if value is traversable @param mixed $value The value @return bool
[ "Checks", "if", "value", "is", "traversable" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1221-L1232
train
novuso/system
src/Utility/Validate.php
Validate.isCountable
public static function isCountable($value): bool { if (is_array($value)) { return true; } if (is_object($value) && ($value instanceof Countable)) { return true; } return false; }
php
public static function isCountable($value): bool { if (is_array($value)) { return true; } if (is_object($value) && ($value instanceof Countable)) { return true; } return false; }
[ "public", "static", "function", "isCountable", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "true", ";", "}", "if", "(", "is_object", "(", "$", "value", ")", "&&", "(", "$", "value", ...
Checks if value is countable @param mixed $value The value @return bool
[ "Checks", "if", "value", "is", "countable" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1241-L1252
train
novuso/system
src/Utility/Validate.php
Validate.isArrayAccessible
public static function isArrayAccessible($value): bool { if (is_array($value)) { return true; } if (is_object($value) && ($value instanceof ArrayAccess)) { return true; } return false; }
php
public static function isArrayAccessible($value): bool { if (is_array($value)) { return true; } if (is_object($value) && ($value instanceof ArrayAccess)) { return true; } return false; }
[ "public", "static", "function", "isArrayAccessible", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "true", ";", "}", "if", "(", "is_object", "(", "$", "value", ")", "&&", "(", "$", "val...
Checks if value is array accessible @param mixed $value The value @return bool
[ "Checks", "if", "value", "is", "array", "accessible" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1261-L1272
train
novuso/system
src/Utility/Validate.php
Validate.implementsInterface
public static function implementsInterface($value, string $interface): bool { if (!is_object($value)) { if (!(static::classExists($value) || static::interfaceExists($value))) { return false; } $value = (string) $value; } $reflection = new ReflectionClass($value); return $reflection->implementsInterface($interface); }
php
public static function implementsInterface($value, string $interface): bool { if (!is_object($value)) { if (!(static::classExists($value) || static::interfaceExists($value))) { return false; } $value = (string) $value; } $reflection = new ReflectionClass($value); return $reflection->implementsInterface($interface); }
[ "public", "static", "function", "implementsInterface", "(", "$", "value", ",", "string", "$", "interface", ")", ":", "bool", "{", "if", "(", "!", "is_object", "(", "$", "value", ")", ")", "{", "if", "(", "!", "(", "static", "::", "classExists", "(", ...
Checks if value implements a given interface @param mixed $value The value @param string $interface The fully qualified interface name @return bool
[ "Checks", "if", "value", "implements", "a", "given", "interface" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1314-L1326
train
novuso/system
src/Utility/Validate.php
Validate.methodExists
public static function methodExists($value, $object): bool { if (!static::isStringCastable($value)) { return false; } return method_exists($object, (string) $value); }
php
public static function methodExists($value, $object): bool { if (!static::isStringCastable($value)) { return false; } return method_exists($object, (string) $value); }
[ "public", "static", "function", "methodExists", "(", "$", "value", ",", "$", "object", ")", ":", "bool", "{", "if", "(", "!", "static", "::", "isStringCastable", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "method_exists", ...
Checks if value is a method name for an object or class @param mixed $value The value @param object|string $object The object or fully qualified class name @return bool
[ "Checks", "if", "value", "is", "a", "method", "name", "for", "an", "object", "or", "class" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1394-L1401
train
novuso/system
src/Utility/Validate.php
Validate.isValidTimezone
private static function isValidTimezone(string $timezone): bool { // @codeCoverageIgnoreStart if (self::$timezones === null) { self::$timezones = []; foreach (timezone_identifiers_list() as $zone) { self::$timezones[$zone] = true; } } // @codeCoverageIgnoreEnd return isset(self::$timezones[$timezone]); }
php
private static function isValidTimezone(string $timezone): bool { // @codeCoverageIgnoreStart if (self::$timezones === null) { self::$timezones = []; foreach (timezone_identifiers_list() as $zone) { self::$timezones[$zone] = true; } } // @codeCoverageIgnoreEnd return isset(self::$timezones[$timezone]); }
[ "private", "static", "function", "isValidTimezone", "(", "string", "$", "timezone", ")", ":", "bool", "{", "// @codeCoverageIgnoreStart", "if", "(", "self", "::", "$", "timezones", "===", "null", ")", "{", "self", "::", "$", "timezones", "=", "[", "]", ";"...
Checks if a timezone string is valid @param string $timezone The timezone string @return bool
[ "Checks", "if", "a", "timezone", "string", "is", "valid" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1490-L1502
train
novuso/system
src/Utility/Validate.php
Validate.isValidUri
private static function isValidUri(array $uri): bool { if (!self::isValidUriScheme($uri['scheme'])) { return false; } if (!self::isValidUriPath($uri['path'])) { return false; } if (!self::isValidUriQuery($uri['query'])) { return false; } if (!self::isValidUriFragment($uri['fragment'])) { return false; } if (!self::isValidUriAuthority($uri['authority'])) { return false; } return true; }
php
private static function isValidUri(array $uri): bool { if (!self::isValidUriScheme($uri['scheme'])) { return false; } if (!self::isValidUriPath($uri['path'])) { return false; } if (!self::isValidUriQuery($uri['query'])) { return false; } if (!self::isValidUriFragment($uri['fragment'])) { return false; } if (!self::isValidUriAuthority($uri['authority'])) { return false; } return true; }
[ "private", "static", "function", "isValidUri", "(", "array", "$", "uri", ")", ":", "bool", "{", "if", "(", "!", "self", "::", "isValidUriScheme", "(", "$", "uri", "[", "'scheme'", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "se...
Checks if URI components are valid @param array $uri an associated array of URI components @return bool
[ "Checks", "if", "URI", "components", "are", "valid" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1551-L1570
train
novuso/system
src/Utility/Validate.php
Validate.isValidUriScheme
private static function isValidUriScheme(?string $scheme): bool { // http://tools.ietf.org/html/rfc3986#section-3 // The scheme and path components are required, though the path may be // empty (no characters) if ($scheme === null || $scheme === '') { return false; } // http://tools.ietf.org/html/rfc3986#section-3.1 // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) $pattern = '/\A[a-z][a-z0-9+.\-]*\z/i'; return !!preg_match($pattern, $scheme); }
php
private static function isValidUriScheme(?string $scheme): bool { // http://tools.ietf.org/html/rfc3986#section-3 // The scheme and path components are required, though the path may be // empty (no characters) if ($scheme === null || $scheme === '') { return false; } // http://tools.ietf.org/html/rfc3986#section-3.1 // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) $pattern = '/\A[a-z][a-z0-9+.\-]*\z/i'; return !!preg_match($pattern, $scheme); }
[ "private", "static", "function", "isValidUriScheme", "(", "?", "string", "$", "scheme", ")", ":", "bool", "{", "// http://tools.ietf.org/html/rfc3986#section-3", "// The scheme and path components are required, though the path may be", "// empty (no characters)", "if", "(", "$", ...
Checks if a URI scheme is valid @param string|null $scheme The URI scheme @return bool
[ "Checks", "if", "a", "URI", "scheme", "is", "valid" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1579-L1593
train
novuso/system
src/Utility/Validate.php
Validate.isValidUriAuthority
private static function isValidUriAuthority(?string $authority): bool { if ($authority === null || $authority === '') { return true; } // http://tools.ietf.org/html/rfc3986#section-3.2 // authority = [ userinfo "@" ] host [ ":" port ] $pattern = '/\A(?:([^@]*)@)?(\[[^\]]*\]|[^:]*)(?::(?:\d*))?\z/'; preg_match($pattern, $authority, $matches); if (!self::isValidAuthUser((isset($matches[1]) && $matches[1]) ? $matches[1] : null)) { return false; } if (!self::isValidAuthHost((isset($matches[2]) && $matches[2]) ? $matches[2] : '')) { return false; } return true; }
php
private static function isValidUriAuthority(?string $authority): bool { if ($authority === null || $authority === '') { return true; } // http://tools.ietf.org/html/rfc3986#section-3.2 // authority = [ userinfo "@" ] host [ ":" port ] $pattern = '/\A(?:([^@]*)@)?(\[[^\]]*\]|[^:]*)(?::(?:\d*))?\z/'; preg_match($pattern, $authority, $matches); if (!self::isValidAuthUser((isset($matches[1]) && $matches[1]) ? $matches[1] : null)) { return false; } if (!self::isValidAuthHost((isset($matches[2]) && $matches[2]) ? $matches[2] : '')) { return false; } return true; }
[ "private", "static", "function", "isValidUriAuthority", "(", "?", "string", "$", "authority", ")", ":", "bool", "{", "if", "(", "$", "authority", "===", "null", "||", "$", "authority", "===", "''", ")", "{", "return", "true", ";", "}", "// http://tools.iet...
Checks if a URI authority is valid @param string|null $authority The URI authority @return bool
[ "Checks", "if", "a", "URI", "authority", "is", "valid" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1602-L1621
train
novuso/system
src/Utility/Validate.php
Validate.isValidUriPath
private static function isValidUriPath(string $path): bool { // http://tools.ietf.org/html/rfc3986#section-3 // The scheme and path components are required, though the path may be // empty (no characters) if ($path === '') { return true; } // path = path-abempty ; begins with "/" or is empty // / path-absolute ; begins with "/" but not "//" // / path-noscheme ; begins with a non-colon segment // / path-rootless ; begins with a segment // / path-empty ; zero characters // // path-abempty = *( "/" segment ) // path-absolute = "/" [ segment-nz *( "/" segment ) ] // path-noscheme = segment-nz-nc *( "/" segment ) // path-rootless = segment-nz *( "/" segment ) // path-empty = 0<pchar> // segment = *pchar // segment-nz = 1*pchar // segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" ) // ; non-zero-length segment without any colon ":" // pchar = unreserved / pct-encoded / sub-delims / ":" / "@" $pattern = sprintf( '/\A(?:(?:[%s%s:@]|(?:%s))*\/?)*\z/i', 'a-z0-9\-._~', '!$&\'()*+,;=', '%[a-f0-9]{2}' ); return !!preg_match($pattern, $path); }
php
private static function isValidUriPath(string $path): bool { // http://tools.ietf.org/html/rfc3986#section-3 // The scheme and path components are required, though the path may be // empty (no characters) if ($path === '') { return true; } // path = path-abempty ; begins with "/" or is empty // / path-absolute ; begins with "/" but not "//" // / path-noscheme ; begins with a non-colon segment // / path-rootless ; begins with a segment // / path-empty ; zero characters // // path-abempty = *( "/" segment ) // path-absolute = "/" [ segment-nz *( "/" segment ) ] // path-noscheme = segment-nz-nc *( "/" segment ) // path-rootless = segment-nz *( "/" segment ) // path-empty = 0<pchar> // segment = *pchar // segment-nz = 1*pchar // segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" ) // ; non-zero-length segment without any colon ":" // pchar = unreserved / pct-encoded / sub-delims / ":" / "@" $pattern = sprintf( '/\A(?:(?:[%s%s:@]|(?:%s))*\/?)*\z/i', 'a-z0-9\-._~', '!$&\'()*+,;=', '%[a-f0-9]{2}' ); return !!preg_match($pattern, $path); }
[ "private", "static", "function", "isValidUriPath", "(", "string", "$", "path", ")", ":", "bool", "{", "// http://tools.ietf.org/html/rfc3986#section-3", "// The scheme and path components are required, though the path may be", "// empty (no characters)", "if", "(", "$", "path", ...
Checks if a URI path is valid @param string $path The URI path @return bool
[ "Checks", "if", "a", "URI", "path", "is", "valid" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1630-L1663
train
novuso/system
src/Utility/Validate.php
Validate.isValidUriQuery
private static function isValidUriQuery(?string $query): bool { if ($query === null || $query === '') { return true; } // http://tools.ietf.org/html/rfc3986#section-3.4 // query = *( pchar / "/" / "?" ) // pchar = unreserved / pct-encoded / sub-delims / ":" / "@" $pattern = sprintf( '/\A(?:[%s%s\/?:@]|(?:%s))*\z/i', 'a-z0-9\-._~', '!$&\'()*+,;=', '%[a-f0-9]{2}' ); return !!preg_match($pattern, $query); }
php
private static function isValidUriQuery(?string $query): bool { if ($query === null || $query === '') { return true; } // http://tools.ietf.org/html/rfc3986#section-3.4 // query = *( pchar / "/" / "?" ) // pchar = unreserved / pct-encoded / sub-delims / ":" / "@" $pattern = sprintf( '/\A(?:[%s%s\/?:@]|(?:%s))*\z/i', 'a-z0-9\-._~', '!$&\'()*+,;=', '%[a-f0-9]{2}' ); return !!preg_match($pattern, $query); }
[ "private", "static", "function", "isValidUriQuery", "(", "?", "string", "$", "query", ")", ":", "bool", "{", "if", "(", "$", "query", "===", "null", "||", "$", "query", "===", "''", ")", "{", "return", "true", ";", "}", "// http://tools.ietf.org/html/rfc39...
Checks if a URI query is valid @param string|null $query The URI query @return bool
[ "Checks", "if", "a", "URI", "query", "is", "valid" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1672-L1689
train
novuso/system
src/Utility/Validate.php
Validate.isValidUriFragment
private static function isValidUriFragment(?string $fragment): bool { if ($fragment === null || $fragment === '') { return true; } // http://tools.ietf.org/html/rfc3986#section-3.5 // fragment = *( pchar / "/" / "?" ) // pchar = unreserved / pct-encoded / sub-delims / ":" / "@" $pattern = sprintf( '/\A(?:[%s%s\/?:@]|(?:%s))*\z/i', 'a-z0-9\-._~', '!$&\'()*+,;=', '%[a-f0-9]{2}' ); return !!preg_match($pattern, $fragment); }
php
private static function isValidUriFragment(?string $fragment): bool { if ($fragment === null || $fragment === '') { return true; } // http://tools.ietf.org/html/rfc3986#section-3.5 // fragment = *( pchar / "/" / "?" ) // pchar = unreserved / pct-encoded / sub-delims / ":" / "@" $pattern = sprintf( '/\A(?:[%s%s\/?:@]|(?:%s))*\z/i', 'a-z0-9\-._~', '!$&\'()*+,;=', '%[a-f0-9]{2}' ); return !!preg_match($pattern, $fragment); }
[ "private", "static", "function", "isValidUriFragment", "(", "?", "string", "$", "fragment", ")", ":", "bool", "{", "if", "(", "$", "fragment", "===", "null", "||", "$", "fragment", "===", "''", ")", "{", "return", "true", ";", "}", "// http://tools.ietf.or...
Checks if a URI fragment is valid @param string|null $fragment The URI fragment @return bool
[ "Checks", "if", "a", "URI", "fragment", "is", "valid" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1698-L1715
train
novuso/system
src/Utility/Validate.php
Validate.isValidAuthUser
private static function isValidAuthUser(?string $userinfo): bool { if ($userinfo === null) { return true; } // http://tools.ietf.org/html/rfc3986#section-3.2.1 // userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) $pattern = sprintf( '/\A(?:[%s%s:]|(?:%s))*\z/i', 'a-z0-9\-._~', '!$&\'()*+,;=', '%[a-f0-9]{2}' ); return !!preg_match($pattern, $userinfo); }
php
private static function isValidAuthUser(?string $userinfo): bool { if ($userinfo === null) { return true; } // http://tools.ietf.org/html/rfc3986#section-3.2.1 // userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) $pattern = sprintf( '/\A(?:[%s%s:]|(?:%s))*\z/i', 'a-z0-9\-._~', '!$&\'()*+,;=', '%[a-f0-9]{2}' ); return !!preg_match($pattern, $userinfo); }
[ "private", "static", "function", "isValidAuthUser", "(", "?", "string", "$", "userinfo", ")", ":", "bool", "{", "if", "(", "$", "userinfo", "===", "null", ")", "{", "return", "true", ";", "}", "// http://tools.ietf.org/html/rfc3986#section-3.2.1", "// userinfo = *...
Checks if authority userinfo is valid @param string|null $userinfo The userinfo @return bool
[ "Checks", "if", "authority", "userinfo", "is", "valid" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1724-L1740
train
novuso/system
src/Utility/Validate.php
Validate.isValidAuthHost
private static function isValidAuthHost(string $host): bool { if ($host === '') { return true; } // http://tools.ietf.org/html/rfc3986#section-3.2.2 // A host identified by an Internet Protocol literal address, version 6 // [RFC3513] or later, is distinguished by enclosing the IP literal // within square brackets ("[" and "]"). This is the only place where // square bracket characters are allowed in the URI syntax. if (strpos($host, '[') !== false) { return self::isValidIpLiteral($host); } // IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet $dec = '(?:(?:2[0-4]|1[0-9]|[1-9])?[0-9]|25[0-5])'; $ipV4 = sprintf('/\A(?:%s\.){3}%s\z/', $dec, $dec); if (preg_match($ipV4, $host)) { return true; } // reg-name = *( unreserved / pct-encoded / sub-delims ) $pattern = sprintf( '/\A(?:[%s%s]|(?:%s))*\z/i', 'a-z0-9\-._~', '!$&\'()*+,;=', '%[a-f0-9]{2}' ); return !!preg_match($pattern, $host); }
php
private static function isValidAuthHost(string $host): bool { if ($host === '') { return true; } // http://tools.ietf.org/html/rfc3986#section-3.2.2 // A host identified by an Internet Protocol literal address, version 6 // [RFC3513] or later, is distinguished by enclosing the IP literal // within square brackets ("[" and "]"). This is the only place where // square bracket characters are allowed in the URI syntax. if (strpos($host, '[') !== false) { return self::isValidIpLiteral($host); } // IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet $dec = '(?:(?:2[0-4]|1[0-9]|[1-9])?[0-9]|25[0-5])'; $ipV4 = sprintf('/\A(?:%s\.){3}%s\z/', $dec, $dec); if (preg_match($ipV4, $host)) { return true; } // reg-name = *( unreserved / pct-encoded / sub-delims ) $pattern = sprintf( '/\A(?:[%s%s]|(?:%s))*\z/i', 'a-z0-9\-._~', '!$&\'()*+,;=', '%[a-f0-9]{2}' ); return !!preg_match($pattern, $host); }
[ "private", "static", "function", "isValidAuthHost", "(", "string", "$", "host", ")", ":", "bool", "{", "if", "(", "$", "host", "===", "''", ")", "{", "return", "true", ";", "}", "// http://tools.ietf.org/html/rfc3986#section-3.2.2", "// A host identified by an Inter...
Checks if authority host is valid @param string $host The host @return bool
[ "Checks", "if", "authority", "host", "is", "valid" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1749-L1780
train
novuso/system
src/Utility/Validate.php
Validate.isSimpleType
private static function isSimpleType($value, string $type): ?bool { switch ($type) { case 'array': return static::isArray($value); break; case 'object': return static::isObject($value); break; case 'bool': return static::isBool($value); break; case 'int': return static::isInt($value); break; case 'float': return static::isFloat($value); break; case 'string': return static::isString($value); break; case 'callable': return static::isCallable($value); break; default: break; } return null; }
php
private static function isSimpleType($value, string $type): ?bool { switch ($type) { case 'array': return static::isArray($value); break; case 'object': return static::isObject($value); break; case 'bool': return static::isBool($value); break; case 'int': return static::isInt($value); break; case 'float': return static::isFloat($value); break; case 'string': return static::isString($value); break; case 'callable': return static::isCallable($value); break; default: break; } return null; }
[ "private", "static", "function", "isSimpleType", "(", "$", "value", ",", "string", "$", "type", ")", ":", "?", "bool", "{", "switch", "(", "$", "type", ")", "{", "case", "'array'", ":", "return", "static", "::", "isArray", "(", "$", "value", ")", ";"...
Checks if a value matches a simple type Returns null if the type is not supported @param mixed $value The value @param string $type The type @return bool|null
[ "Checks", "if", "a", "value", "matches", "a", "simple", "type" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/Validate.php#L1824-L1853
train
laradic/service-provider
src/BaseServiceProvider.php
BaseServiceProvider.startPluginTraits
private function startPluginTraits() { foreach ($this->getPluginTraits() as $trait) { if (method_exists(get_called_class(), $method = 'start' . class_basename($trait) . 'Plugin')) { call_user_func([ $this, $method ], $this->app); } } }
php
private function startPluginTraits() { foreach ($this->getPluginTraits() as $trait) { if (method_exists(get_called_class(), $method = 'start' . class_basename($trait) . 'Plugin')) { call_user_func([ $this, $method ], $this->app); } } }
[ "private", "function", "startPluginTraits", "(", ")", "{", "foreach", "(", "$", "this", "->", "getPluginTraits", "(", ")", "as", "$", "trait", ")", "{", "if", "(", "method_exists", "(", "get_called_class", "(", ")", ",", "$", "method", "=", "'start'", "....
startPluginTraits method.
[ "startPluginTraits", "method", "." ]
b1428d566b97b3662b405c64ff0cad8a89102033
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L200-L207
train
laradic/service-provider
src/BaseServiceProvider.php
BaseServiceProvider.requiresPlugins
public function requiresPlugins() { $has = class_uses_recursive(get_called_class()); $check = array_combine(func_get_args(), func_get_args()); $missing = array_values(array_diff($check, $has)); if (isset($missing[ 0 ])) { $plugin = collect(debug_backtrace())->where('function', 'requiresPlugins')->first(); throw ProviderPluginDependencyException::plugin($plugin[ 'file' ], implode(', ', $missing)); } }
php
public function requiresPlugins() { $has = class_uses_recursive(get_called_class()); $check = array_combine(func_get_args(), func_get_args()); $missing = array_values(array_diff($check, $has)); if (isset($missing[ 0 ])) { $plugin = collect(debug_backtrace())->where('function', 'requiresPlugins')->first(); throw ProviderPluginDependencyException::plugin($plugin[ 'file' ], implode(', ', $missing)); } }
[ "public", "function", "requiresPlugins", "(", ")", "{", "$", "has", "=", "class_uses_recursive", "(", "get_called_class", "(", ")", ")", ";", "$", "check", "=", "array_combine", "(", "func_get_args", "(", ")", ",", "func_get_args", "(", ")", ")", ";", "$",...
requiresPlugins method.
[ "requiresPlugins", "method", "." ]
b1428d566b97b3662b405c64ff0cad8a89102033
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L222-L231
train
laradic/service-provider
src/BaseServiceProvider.php
BaseServiceProvider.resolveDirectories
private function resolveDirectories() { if ($this->scanDirs !== true) { return; } if ($this->rootDir === null) { $class = new ReflectionClass(get_called_class()); $filePath = $class->getFileName(); $this->dir = $rootDir = path_get_directory($filePath); $found = false; for ($i = 0; $i < $this->scanDirsMaxLevel; ++$i) { if (file_exists($composerPath = path_join($rootDir, 'composer.json'))) { $found = true; break; } else { $rootDir = path_get_directory($rootDir); // go 1 up } } if ($found === false) { throw new \OutOfBoundsException("Could not determinse composer.json file location in [{$this->dir}] or in {$this->scanDirsMaxLevel} parents of [$this->rootDir}]"); } $this->rootDir = $rootDir; } $this->dir = $this->dir ?: path_join($this->rootDir, 'src'); }
php
private function resolveDirectories() { if ($this->scanDirs !== true) { return; } if ($this->rootDir === null) { $class = new ReflectionClass(get_called_class()); $filePath = $class->getFileName(); $this->dir = $rootDir = path_get_directory($filePath); $found = false; for ($i = 0; $i < $this->scanDirsMaxLevel; ++$i) { if (file_exists($composerPath = path_join($rootDir, 'composer.json'))) { $found = true; break; } else { $rootDir = path_get_directory($rootDir); // go 1 up } } if ($found === false) { throw new \OutOfBoundsException("Could not determinse composer.json file location in [{$this->dir}] or in {$this->scanDirsMaxLevel} parents of [$this->rootDir}]"); } $this->rootDir = $rootDir; } $this->dir = $this->dir ?: path_join($this->rootDir, 'src'); }
[ "private", "function", "resolveDirectories", "(", ")", "{", "if", "(", "$", "this", "->", "scanDirs", "!==", "true", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "rootDir", "===", "null", ")", "{", "$", "class", "=", "new", "Reflection...
resolveDirectories method.
[ "resolveDirectories", "method", "." ]
b1428d566b97b3662b405c64ff0cad8a89102033
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L236-L261
train
laradic/service-provider
src/BaseServiceProvider.php
BaseServiceProvider.getPluginPriority
private function getPluginPriority($name, $index = 0) { $priority = 10; if (property_exists($this, "{$name}PluginPriority")) { $value = $this->{$name . 'PluginPriority'}; $priority = is_array($value) ? $value[ $index ] : $value; } return $priority; }
php
private function getPluginPriority($name, $index = 0) { $priority = 10; if (property_exists($this, "{$name}PluginPriority")) { $value = $this->{$name . 'PluginPriority'}; $priority = is_array($value) ? $value[ $index ] : $value; } return $priority; }
[ "private", "function", "getPluginPriority", "(", "$", "name", ",", "$", "index", "=", "0", ")", "{", "$", "priority", "=", "10", ";", "if", "(", "property_exists", "(", "$", "this", ",", "\"{$name}PluginPriority\"", ")", ")", "{", "$", "value", "=", "$...
getPluginPriority method. @param $name @param int $index If a plugin priority is defined as array, the 0 index is for register and 1 for boot @return int|mixed
[ "getPluginPriority", "method", "." ]
b1428d566b97b3662b405c64ff0cad8a89102033
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L282-L291
train
laradic/service-provider
src/BaseServiceProvider.php
BaseServiceProvider.onRegister
public function onRegister($name, Closure $callback) { $priority = $this->getPluginPriority($name); $this->registerCallbacks[] = compact('name', 'priority', 'callback'); }
php
public function onRegister($name, Closure $callback) { $priority = $this->getPluginPriority($name); $this->registerCallbacks[] = compact('name', 'priority', 'callback'); }
[ "public", "function", "onRegister", "(", "$", "name", ",", "Closure", "$", "callback", ")", "{", "$", "priority", "=", "$", "this", "->", "getPluginPriority", "(", "$", "name", ")", ";", "$", "this", "->", "registerCallbacks", "[", "]", "=", "compact", ...
onRegister method. @param $name @param \Closure $callback
[ "onRegister", "method", "." ]
b1428d566b97b3662b405c64ff0cad8a89102033
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L299-L303
train
laradic/service-provider
src/BaseServiceProvider.php
BaseServiceProvider.onBoot
public function onBoot($name, Closure $callback) { $priority = $this->getPluginPriority($name, 1); $this->bootCallbacks[] = compact('name', 'priority', 'callback'); }
php
public function onBoot($name, Closure $callback) { $priority = $this->getPluginPriority($name, 1); $this->bootCallbacks[] = compact('name', 'priority', 'callback'); }
[ "public", "function", "onBoot", "(", "$", "name", ",", "Closure", "$", "callback", ")", "{", "$", "priority", "=", "$", "this", "->", "getPluginPriority", "(", "$", "name", ",", "1", ")", ";", "$", "this", "->", "bootCallbacks", "[", "]", "=", "compa...
onBoot method. @param $name @param \Closure $callback
[ "onBoot", "method", "." ]
b1428d566b97b3662b405c64ff0cad8a89102033
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L311-L315
train
laradic/service-provider
src/BaseServiceProvider.php
BaseServiceProvider.fireCallbacks
private function fireCallbacks($name, Closure $modifier = null, Closure $caller = null) { $list = collect($this->{$name . 'Callbacks'}); if ($modifier) { $list = call_user_func_array($modifier, [ $list ]); } $caller = $caller ?: function (Closure $callback) { $callback->bindTo($this); $callback($this->app); }; $list->pluck('callback')->each($caller); }
php
private function fireCallbacks($name, Closure $modifier = null, Closure $caller = null) { $list = collect($this->{$name . 'Callbacks'}); if ($modifier) { $list = call_user_func_array($modifier, [ $list ]); } $caller = $caller ?: function (Closure $callback) { $callback->bindTo($this); $callback($this->app); }; $list->pluck('callback')->each($caller); }
[ "private", "function", "fireCallbacks", "(", "$", "name", ",", "Closure", "$", "modifier", "=", "null", ",", "Closure", "$", "caller", "=", "null", ")", "{", "$", "list", "=", "collect", "(", "$", "this", "->", "{", "$", "name", ".", "'Callbacks'", "...
fireCallbacks method. @param $name @param \Closure|null $modifier @param \Closure|null $caller
[ "fireCallbacks", "method", "." ]
b1428d566b97b3662b405c64ff0cad8a89102033
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/BaseServiceProvider.php#L324-L335
train
WellCommerce/Form
Elements/Input/FontStyle.php
FontStyle.formatStylesJs
public function formatStylesJs() { $options = []; $options[] = $this->formatStyle('Arial,Arial,Helvetica,sans-serif', 'Arial'); $options[] = $this->formatStyle('Arial Black,Arial Black,Gadget,sans-serif', 'Arial Black'); $options[] = $this->formatStyle('Comic Sans MS,Comic Sans MS,cursive', 'Comic Sans MS'); $options[] = $this->formatStyle('Courier New,Courier New,Courier,monospace', 'Courier New'); $options[] = $this->formatStyle('Georgia,Georgia,serif', 'Georgia'); $options[] = $this->formatStyle('Impact,Charcoal,sans-serif', 'Impact'); $options[] = $this->formatStyle('Lucida Console,Monaco,monospace', 'Lucida Console'); $options[] = $this->formatStyle('Lucida Sans Unicode,Lucida Grande,sans-serif', 'Lucida Sans'); $options[] = $this->formatStyle('Palatino Linotype,Book Antiqua,Palatino,serif', 'Palatino Linotype'); $options[] = $this->formatStyle('Tahoma,Geneva,sans-serif', 'Tahoma'); $options[] = $this->formatStyle('Times New Roman,Times,serif', 'Times New Roman'); $options[] = $this->formatStyle('Trebuchet MS,Helvetica,sans-serif', 'Trebuchet'); $options[] = $this->formatStyle('Verdana,Geneva,sans-serif', 'Verdana'); return 'aoTypes: ['.implode(', ', $options).']'; }
php
public function formatStylesJs() { $options = []; $options[] = $this->formatStyle('Arial,Arial,Helvetica,sans-serif', 'Arial'); $options[] = $this->formatStyle('Arial Black,Arial Black,Gadget,sans-serif', 'Arial Black'); $options[] = $this->formatStyle('Comic Sans MS,Comic Sans MS,cursive', 'Comic Sans MS'); $options[] = $this->formatStyle('Courier New,Courier New,Courier,monospace', 'Courier New'); $options[] = $this->formatStyle('Georgia,Georgia,serif', 'Georgia'); $options[] = $this->formatStyle('Impact,Charcoal,sans-serif', 'Impact'); $options[] = $this->formatStyle('Lucida Console,Monaco,monospace', 'Lucida Console'); $options[] = $this->formatStyle('Lucida Sans Unicode,Lucida Grande,sans-serif', 'Lucida Sans'); $options[] = $this->formatStyle('Palatino Linotype,Book Antiqua,Palatino,serif', 'Palatino Linotype'); $options[] = $this->formatStyle('Tahoma,Geneva,sans-serif', 'Tahoma'); $options[] = $this->formatStyle('Times New Roman,Times,serif', 'Times New Roman'); $options[] = $this->formatStyle('Trebuchet MS,Helvetica,sans-serif', 'Trebuchet'); $options[] = $this->formatStyle('Verdana,Geneva,sans-serif', 'Verdana'); return 'aoTypes: ['.implode(', ', $options).']'; }
[ "public", "function", "formatStylesJs", "(", ")", "{", "$", "options", "=", "[", "]", ";", "$", "options", "[", "]", "=", "$", "this", "->", "formatStyle", "(", "'Arial,Arial,Helvetica,sans-serif'", ",", "'Arial'", ")", ";", "$", "options", "[", "]", "="...
Formats font styles to use them in layout editor @return string
[ "Formats", "font", "styles", "to", "use", "them", "in", "layout", "editor" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Elements/Input/FontStyle.php#L29-L48
train
Silvestra/Silvestra
src/Silvestra/Bundle/Text/NodeBundle/Form/Handler/TextNodeFormHandler.php
TextNodeFormHandler.process
public function process(Request $request, FormInterface $form) { if ($request->isMethod('POST')) { $form->submit($request); if ($form->isValid()) { return true; } } return false; }
php
public function process(Request $request, FormInterface $form) { if ($request->isMethod('POST')) { $form->submit($request); if ($form->isValid()) { return true; } } return false; }
[ "public", "function", "process", "(", "Request", "$", "request", ",", "FormInterface", "$", "form", ")", "{", "if", "(", "$", "request", "->", "isMethod", "(", "'POST'", ")", ")", "{", "$", "form", "->", "submit", "(", "$", "request", ")", ";", "if",...
Process text node form. @param Request $request @param FormInterface $form @return bool
[ "Process", "text", "node", "form", "." ]
b7367601b01495ae3c492b42042f804dee13ab06
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Bundle/Text/NodeBundle/Form/Handler/TextNodeFormHandler.php#L70-L80
train
Silvestra/Silvestra
src/Silvestra/Bundle/Text/NodeBundle/Form/Handler/TextNodeFormHandler.php
TextNodeFormHandler.onSuccess
public function onSuccess($locale, NodeInterface $node) { $this->eventDispatcher->dispatch(TadckaTreeEvents::NODE_EDIT_SUCCESS, new TreeNodeEvent($locale, $node)); $this->textNodeManager->save(); return $this->translator->trans('success.text_node_save', array(), 'SilvestraTextNodeBundle'); }
php
public function onSuccess($locale, NodeInterface $node) { $this->eventDispatcher->dispatch(TadckaTreeEvents::NODE_EDIT_SUCCESS, new TreeNodeEvent($locale, $node)); $this->textNodeManager->save(); return $this->translator->trans('success.text_node_save', array(), 'SilvestraTextNodeBundle'); }
[ "public", "function", "onSuccess", "(", "$", "locale", ",", "NodeInterface", "$", "node", ")", "{", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "TadckaTreeEvents", "::", "NODE_EDIT_SUCCESS", ",", "new", "TreeNodeEvent", "(", "$", "locale", ","...
On edit text node success. @param string $locale @param NodeInterface $node @return string
[ "On", "edit", "text", "node", "success", "." ]
b7367601b01495ae3c492b42042f804dee13ab06
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Bundle/Text/NodeBundle/Form/Handler/TextNodeFormHandler.php#L90-L96
train
popy-dev/popy-calendar
src/ValueObject/AbstractFragmentedDuration.php
AbstractFragmentedDuration.all
public function all() { $res = []; $len = count($this->fragments); for ($index=0; $index < $len; $index++) { $res[] = $this->get($index); } return $res; }
php
public function all() { $res = []; $len = count($this->fragments); for ($index=0; $index < $len; $index++) { $res[] = $this->get($index); } return $res; }
[ "public", "function", "all", "(", ")", "{", "$", "res", "=", "[", "]", ";", "$", "len", "=", "count", "(", "$", "this", "->", "fragments", ")", ";", "for", "(", "$", "index", "=", "0", ";", "$", "index", "<", "$", "len", ";", "$", "index", ...
Get all fragments. @return array<integer|null>
[ "Get", "all", "fragments", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L59-L69
train
popy-dev/popy-calendar
src/ValueObject/AbstractFragmentedDuration.php
AbstractFragmentedDuration.with
public function with($index, $value) { $res = clone $this; $res->fragments = $this->insertInList($res->fragments, $index, $value); return $this; }
php
public function with($index, $value) { $res = clone $this; $res->fragments = $this->insertInList($res->fragments, $index, $value); return $this; }
[ "public", "function", "with", "(", "$", "index", ",", "$", "value", ")", "{", "$", "res", "=", "clone", "$", "this", ";", "$", "res", "->", "fragments", "=", "$", "this", "->", "insertInList", "(", "$", "res", "->", "fragments", ",", "$", "index", ...
Set time fragment, adding null fragments if needed. @param integer $index @param integer|null $value
[ "Set", "time", "fragment", "adding", "null", "fragments", "if", "needed", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L98-L105
train
popy-dev/popy-calendar
src/ValueObject/AbstractFragmentedDuration.php
AbstractFragmentedDuration.withFragments
public function withFragments(array $fragments) { $res = clone $this; $res->fragments = $res->fillArrayInput($fragments); return $res; }
php
public function withFragments(array $fragments) { $res = clone $this; $res->fragments = $res->fillArrayInput($fragments); return $res; }
[ "public", "function", "withFragments", "(", "array", "$", "fragments", ")", "{", "$", "res", "=", "clone", "$", "this", ";", "$", "res", "->", "fragments", "=", "$", "res", "->", "fillArrayInput", "(", "$", "fragments", ")", ";", "return", "$", "res", ...
Set all fragments, adding null fragments if needed. @param array<integer|null> $fragments @return static a new instance.
[ "Set", "all", "fragments", "adding", "null", "fragments", "if", "needed", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L114-L121
train
popy-dev/popy-calendar
src/ValueObject/AbstractFragmentedDuration.php
AbstractFragmentedDuration.withSize
public function withSize($index, $value) { $res = clone $this; $res->sizes = $this->insertInList($res->sizes, $index, $value); return $res; }
php
public function withSize($index, $value) { $res = clone $this; $res->sizes = $this->insertInList($res->sizes, $index, $value); return $res; }
[ "public", "function", "withSize", "(", "$", "index", ",", "$", "value", ")", "{", "$", "res", "=", "clone", "$", "this", ";", "$", "res", "->", "sizes", "=", "$", "this", "->", "insertInList", "(", "$", "res", "->", "sizes", ",", "$", "index", ",...
Set time fragment size, adding null values if needed. @param integer $index @param integer|null $value
[ "Set", "time", "fragment", "size", "adding", "null", "values", "if", "needed", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L153-L160
train
popy-dev/popy-calendar
src/ValueObject/AbstractFragmentedDuration.php
AbstractFragmentedDuration.withSizes
public function withSizes(array $sizes) { $res = clone $this; $res->sizes = $res->fillArrayInput($sizes); return $res; }
php
public function withSizes(array $sizes) { $res = clone $this; $res->sizes = $res->fillArrayInput($sizes); return $res; }
[ "public", "function", "withSizes", "(", "array", "$", "sizes", ")", "{", "$", "res", "=", "clone", "$", "this", ";", "$", "res", "->", "sizes", "=", "$", "res", "->", "fillArrayInput", "(", "$", "sizes", ")", ";", "return", "$", "res", ";", "}" ]
Set all sizes, adding null values if needed. @param array<integer|null> $sizes @return static a new instance.
[ "Set", "all", "sizes", "adding", "null", "values", "if", "needed", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L169-L176
train
popy-dev/popy-calendar
src/ValueObject/AbstractFragmentedDuration.php
AbstractFragmentedDuration.insertInList
public function insertInList(array $values, $index, $value) { for ($i=count($values); $i < $index; $i++) { $values[$i] = null; } $values[$index] = $value; return $values; }
php
public function insertInList(array $values, $index, $value) { for ($i=count($values); $i < $index; $i++) { $values[$i] = null; } $values[$index] = $value; return $values; }
[ "public", "function", "insertInList", "(", "array", "$", "values", ",", "$", "index", ",", "$", "value", ")", "{", "for", "(", "$", "i", "=", "count", "(", "$", "values", ")", ";", "$", "i", "<", "$", "index", ";", "$", "i", "++", ")", "{", "...
Insrt a value in a list, inserting null values if needed to keep a conscutive indexing. @param array $values Actual values. @param integer $index New value index. @param mixed|null $value New value. @return array new value list.
[ "Insrt", "a", "value", "in", "a", "list", "inserting", "null", "values", "if", "needed", "to", "keep", "a", "conscutive", "indexing", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L188-L197
train
popy-dev/popy-calendar
src/ValueObject/AbstractFragmentedDuration.php
AbstractFragmentedDuration.withTransversal
public function withTransversal($index, $value) { $res = clone $this; $res->transversals = $this->insertInList($res->transversals, $index, $value); return $res; }
php
public function withTransversal($index, $value) { $res = clone $this; $res->transversals = $this->insertInList($res->transversals, $index, $value); return $res; }
[ "public", "function", "withTransversal", "(", "$", "index", ",", "$", "value", ")", "{", "$", "res", "=", "clone", "$", "this", ";", "$", "res", "->", "transversals", "=", "$", "this", "->", "insertInList", "(", "$", "res", "->", "transversals", ",", ...
Set transversal unit, adding null values if needed. @param integer $index @param integer|null $value
[ "Set", "transversal", "unit", "adding", "null", "values", "if", "needed", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L229-L236
train
popy-dev/popy-calendar
src/ValueObject/AbstractFragmentedDuration.php
AbstractFragmentedDuration.withTransversals
public function withTransversals(array $transversals) { $res = clone $this; $res->transversals = $res->fillArrayInput($transversals); return $res; }
php
public function withTransversals(array $transversals) { $res = clone $this; $res->transversals = $res->fillArrayInput($transversals); return $res; }
[ "public", "function", "withTransversals", "(", "array", "$", "transversals", ")", "{", "$", "res", "=", "clone", "$", "this", ";", "$", "res", "->", "transversals", "=", "$", "res", "->", "fillArrayInput", "(", "$", "transversals", ")", ";", "return", "$...
Set all transversal units, adding null values if needed. @param array<integer|null> $transversals @return static a new instance.
[ "Set", "all", "transversal", "units", "adding", "null", "values", "if", "needed", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/ValueObject/AbstractFragmentedDuration.php#L245-L252
train
DivideBV/PHPDivideIQ
src/Token.php
Token.expired
public function expired(\DateTime $date = null) { // Check if the token has an expiration date. if (!$this->expire) { return false; } $date = $date ?: new \DateTime('now', new \DateTimezone('UTC')); return ($date > $this->expire); }
php
public function expired(\DateTime $date = null) { // Check if the token has an expiration date. if (!$this->expire) { return false; } $date = $date ?: new \DateTime('now', new \DateTimezone('UTC')); return ($date > $this->expire); }
[ "public", "function", "expired", "(", "\\", "DateTime", "$", "date", "=", "null", ")", "{", "// Check if the token has an expiration date.", "if", "(", "!", "$", "this", "->", "expire", ")", "{", "return", "false", ";", "}", "$", "date", "=", "$", "date", ...
Checks whether the token has expired or is still valid. If the token has no expiration date, assumes the token doesn't expire. @param \DateTime $date (optional) The date to compare with the epiration date of the token. If not provided, the current time is used. @return bool
[ "Checks", "whether", "the", "token", "has", "expired", "or", "is", "still", "valid", "." ]
bd12e3c226b061d7152f93ab1195fbaaf074b20d
https://github.com/DivideBV/PHPDivideIQ/blob/bd12e3c226b061d7152f93ab1195fbaaf074b20d/src/Token.php#L71-L81
train
popy-dev/popy-calendar
src/Converter/UnixTimeConverter/TimeOffset.php
TimeOffset.extractAbbreviation
protected function extractAbbreviation(DateRepresentationInterface $input) { $offset = $input->getOffset(); if (null === $abbr = $offset->getAbbreviation()) { return $input; } $abbr = strtolower($abbr); $list = DateTimeZone::listAbbreviations(); if (!isset($list[$abbr]) || empty($list[$abbr])) { return $input; } $list = $list[$abbr]; $criterias = [ 'offset' => $offset->getValue(), 'timezone_id' => $input->getTimezone()->getName(), 'dst' => $offset->isDst(), ]; foreach ($criterias as $key => $value) { if (null === $value) { continue; } $previous = $list; $list = array_filter($list, function ($infos) use ($key, $value) { return $value === $infos[$key]; }); if (empty($list)) { $list = $previous; } } $infos = reset($list); if (null === $offset->getValue()) { $offset = $offset->withValue($infos['offset']); } return $input ->withOffset($offset->withDst($infos['dst'])) ->withTimezone(new DateTimeZone($infos['timezone_id'])) ; }
php
protected function extractAbbreviation(DateRepresentationInterface $input) { $offset = $input->getOffset(); if (null === $abbr = $offset->getAbbreviation()) { return $input; } $abbr = strtolower($abbr); $list = DateTimeZone::listAbbreviations(); if (!isset($list[$abbr]) || empty($list[$abbr])) { return $input; } $list = $list[$abbr]; $criterias = [ 'offset' => $offset->getValue(), 'timezone_id' => $input->getTimezone()->getName(), 'dst' => $offset->isDst(), ]; foreach ($criterias as $key => $value) { if (null === $value) { continue; } $previous = $list; $list = array_filter($list, function ($infos) use ($key, $value) { return $value === $infos[$key]; }); if (empty($list)) { $list = $previous; } } $infos = reset($list); if (null === $offset->getValue()) { $offset = $offset->withValue($infos['offset']); } return $input ->withOffset($offset->withDst($infos['dst'])) ->withTimezone(new DateTimeZone($infos['timezone_id'])) ; }
[ "protected", "function", "extractAbbreviation", "(", "DateRepresentationInterface", "$", "input", ")", "{", "$", "offset", "=", "$", "input", "->", "getOffset", "(", ")", ";", "if", "(", "null", "===", "$", "abbr", "=", "$", "offset", "->", "getAbbreviation"...
Extract informations from timezone abbreviation. @param DateRepresentationInterface $input @return DateRepresentationInterface
[ "Extract", "informations", "from", "timezone", "abbreviation", "." ]
989048be18451c813cfce926229c6aaddd1b0639
https://github.com/popy-dev/popy-calendar/blob/989048be18451c813cfce926229c6aaddd1b0639/src/Converter/UnixTimeConverter/TimeOffset.php#L130-L178
train
Softpampa/moip-sdk-php
src/Payments/Resources/Customers.php
Customers.setBirthdate
public function setBirthdate($date) { if ($date instanceof DateTime) { $date = $date->format('Y-m-d'); } $this->data->birthDate = $date; return $this; }
php
public function setBirthdate($date) { if ($date instanceof DateTime) { $date = $date->format('Y-m-d'); } $this->data->birthDate = $date; return $this; }
[ "public", "function", "setBirthdate", "(", "$", "date", ")", "{", "if", "(", "$", "date", "instanceof", "DateTime", ")", "{", "$", "date", "=", "$", "date", "->", "format", "(", "'Y-m-d'", ")", ";", "}", "$", "this", "->", "data", "->", "birthDate", ...
Set customer birth date @param string|DateTime $date @return $this
[ "Set", "customer", "birth", "date" ]
621a71bd2ef1f9b690cd3431507af608152f6ad2
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Customers.php#L140-L149
train
Softpampa/moip-sdk-php
src/Payments/Resources/Customers.php
Customers.setTaxDocument
public function setTaxDocument(TaxDocument $taxDocument) { $taxDocument->setContext(Moip::PAYMENT); $this->data->taxDocument = $taxDocument->getData(); return $this; }
php
public function setTaxDocument(TaxDocument $taxDocument) { $taxDocument->setContext(Moip::PAYMENT); $this->data->taxDocument = $taxDocument->getData(); return $this; }
[ "public", "function", "setTaxDocument", "(", "TaxDocument", "$", "taxDocument", ")", "{", "$", "taxDocument", "->", "setContext", "(", "Moip", "::", "PAYMENT", ")", ";", "$", "this", "->", "data", "->", "taxDocument", "=", "$", "taxDocument", "->", "getData"...
Set customer tax document @param \Softpampa\Moip\Helpers\TaxDocument $taxDocument @return $this
[ "Set", "customer", "tax", "document" ]
621a71bd2ef1f9b690cd3431507af608152f6ad2
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Customers.php#L171-L177
train
Softpampa/moip-sdk-php
src/Payments/Resources/Customers.php
Customers.setCreditCard
public function setCreditCard(CreditCard $creditCard) { $creditCard->setContext(Moip::PAYMENT); $fundingInstrument = new stdClass; $fundingInstrument->method = 'CREDIT_CARD'; $fundingInstrument->creditCard = $creditCard->getData(); $this->data->fundingInstrument = $fundingInstrument; unset($this->data->fundingInstruments); return $this; }
php
public function setCreditCard(CreditCard $creditCard) { $creditCard->setContext(Moip::PAYMENT); $fundingInstrument = new stdClass; $fundingInstrument->method = 'CREDIT_CARD'; $fundingInstrument->creditCard = $creditCard->getData(); $this->data->fundingInstrument = $fundingInstrument; unset($this->data->fundingInstruments); return $this; }
[ "public", "function", "setCreditCard", "(", "CreditCard", "$", "creditCard", ")", "{", "$", "creditCard", "->", "setContext", "(", "Moip", "::", "PAYMENT", ")", ";", "$", "fundingInstrument", "=", "new", "stdClass", ";", "$", "fundingInstrument", "->", "method...
Set customer credit card @param \Softpampa\Moip\Helpers\CreditCard $creditCard @return $this
[ "Set", "customer", "credit", "card" ]
621a71bd2ef1f9b690cd3431507af608152f6ad2
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Customers.php#L222-L235
train
Softpampa/moip-sdk-php
src/Payments/Resources/Customers.php
Customers.createNewCreditCard
public function createNewCreditCard(CreditCard $creditCard, $id = null) { if (! $id) { $id = $this->data->id; } $creditCard->setContext(Moip::PAYMENT); $this->data = new stdClass; $this->data->method = 'CREDIT_CARD'; $this->data->creditCard = $creditCard->getData(); $response = $this->client->post('{id}/fundinginstruments', [$id], $this->data); $this->populate($response); return $this; }
php
public function createNewCreditCard(CreditCard $creditCard, $id = null) { if (! $id) { $id = $this->data->id; } $creditCard->setContext(Moip::PAYMENT); $this->data = new stdClass; $this->data->method = 'CREDIT_CARD'; $this->data->creditCard = $creditCard->getData(); $response = $this->client->post('{id}/fundinginstruments', [$id], $this->data); $this->populate($response); return $this; }
[ "public", "function", "createNewCreditCard", "(", "CreditCard", "$", "creditCard", ",", "$", "id", "=", "null", ")", "{", "if", "(", "!", "$", "id", ")", "{", "$", "id", "=", "$", "this", "->", "data", "->", "id", ";", "}", "$", "creditCard", "->",...
Create a new credit card for customer @param \Softpampa\Moip\Helpers\CreditCard $creditCard @param int $id @return $this
[ "Create", "a", "new", "credit", "card", "for", "customer" ]
621a71bd2ef1f9b690cd3431507af608152f6ad2
https://github.com/Softpampa/moip-sdk-php/blob/621a71bd2ef1f9b690cd3431507af608152f6ad2/src/Payments/Resources/Customers.php#L265-L282
train
Joseki/LeanMapper-extension
src/Joseki/LeanMapper/Mapper.php
Mapper.getEntityClass
public function getEntityClass($table, Row $row = null) { $namespace = $this->defaultEntityNamespace . '\\'; return $namespace . ucfirst(Utils::underscoreToCamel($table)); }
php
public function getEntityClass($table, Row $row = null) { $namespace = $this->defaultEntityNamespace . '\\'; return $namespace . ucfirst(Utils::underscoreToCamel($table)); }
[ "public", "function", "getEntityClass", "(", "$", "table", ",", "Row", "$", "row", "=", "null", ")", "{", "$", "namespace", "=", "$", "this", "->", "defaultEntityNamespace", ".", "'\\\\'", ";", "return", "$", "namespace", ".", "ucfirst", "(", "Utils", ":...
some_entity -> App\Entity\SomeEntity @param string $table @param Row $row @return string
[ "some_entity", "-", ">", "App", "\\", "Entity", "\\", "SomeEntity" ]
5f51fed7a770bece15c6dae7f9482706d44ec7e5
https://github.com/Joseki/LeanMapper-extension/blob/5f51fed7a770bece15c6dae7f9482706d44ec7e5/src/Joseki/LeanMapper/Mapper.php#L45-L49
train
Joseki/LeanMapper-extension
src/Joseki/LeanMapper/Mapper.php
Mapper.getEntityField
public function getEntityField($table, $column) { $class = $this->getEntityClass($table); /** @var Entity $entity */ $entity = new $class; $reflection = $entity->getReflection($this); foreach ($reflection->getEntityProperties() as $property) { if ($property->getColumn() == $column) { return Utils::underscoreToCamel($property->getName()); } } throw new InvalidArgumentException(sprintf("Could not find property for table '%s' and column '%s'", $table, $column)); }
php
public function getEntityField($table, $column) { $class = $this->getEntityClass($table); /** @var Entity $entity */ $entity = new $class; $reflection = $entity->getReflection($this); foreach ($reflection->getEntityProperties() as $property) { if ($property->getColumn() == $column) { return Utils::underscoreToCamel($property->getName()); } } throw new InvalidArgumentException(sprintf("Could not find property for table '%s' and column '%s'", $table, $column)); }
[ "public", "function", "getEntityField", "(", "$", "table", ",", "$", "column", ")", "{", "$", "class", "=", "$", "this", "->", "getEntityClass", "(", "$", "table", ")", ";", "/** @var Entity $entity */", "$", "entity", "=", "new", "$", "class", ";", "$",...
some_field -> someField @param string $table @param string $column @return string
[ "some_field", "-", ">", "someField" ]
5f51fed7a770bece15c6dae7f9482706d44ec7e5
https://github.com/Joseki/LeanMapper-extension/blob/5f51fed7a770bece15c6dae7f9482706d44ec7e5/src/Joseki/LeanMapper/Mapper.php#L72-L84
train
arkanmgerges/multi-tier-architecture
src/MultiTierArchitecture/Boundary/Definition/RequestAbstract.php
RequestAbstract.hydrateIfJsonToArray
private function hydrateIfJsonToArray($data) { if (is_array($data)) { return $data; } elseif (is_string($data)) { $attempt = json_decode($data, true); return empty($attempt) ? $data : $attempt; } return []; }
php
private function hydrateIfJsonToArray($data) { if (is_array($data)) { return $data; } elseif (is_string($data)) { $attempt = json_decode($data, true); return empty($attempt) ? $data : $attempt; } return []; }
[ "private", "function", "hydrateIfJsonToArray", "(", "$", "data", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "return", "$", "data", ";", "}", "elseif", "(", "is_string", "(", "$", "data", ")", ")", "{", "$", "attempt", "=", "j...
Hydrate if the passed parameter is json to array @param mixed $data It can be json or array @return array
[ "Hydrate", "if", "the", "passed", "parameter", "is", "json", "to", "array" ]
e8729841db66de7de0bdc9ed79ab73fe2bc262c0
https://github.com/arkanmgerges/multi-tier-architecture/blob/e8729841db66de7de0bdc9ed79ab73fe2bc262c0/src/MultiTierArchitecture/Boundary/Definition/RequestAbstract.php#L49-L60
train
arkanmgerges/multi-tier-architecture
src/MultiTierArchitecture/Boundary/Definition/RequestAbstract.php
RequestAbstract.setData
public function setData($data) { $resultData = $this->hydrateIfJsonToArray($data); if (!empty($resultData)) { $this->data = $resultData; } else { $this->data = []; } }
php
public function setData($data) { $resultData = $this->hydrateIfJsonToArray($data); if (!empty($resultData)) { $this->data = $resultData; } else { $this->data = []; } }
[ "public", "function", "setData", "(", "$", "data", ")", "{", "$", "resultData", "=", "$", "this", "->", "hydrateIfJsonToArray", "(", "$", "data", ")", ";", "if", "(", "!", "empty", "(", "$", "resultData", ")", ")", "{", "$", "this", "->", "data", "...
Set data to data array @param string|array $data Data that need to be set into extra array @return void
[ "Set", "data", "to", "data", "array" ]
e8729841db66de7de0bdc9ed79ab73fe2bc262c0
https://github.com/arkanmgerges/multi-tier-architecture/blob/e8729841db66de7de0bdc9ed79ab73fe2bc262c0/src/MultiTierArchitecture/Boundary/Definition/RequestAbstract.php#L175-L184
train
arkanmgerges/multi-tier-architecture
src/MultiTierArchitecture/Boundary/Definition/RequestAbstract.php
RequestAbstract.setExtra
public function setExtra($extra) { $resultData = $this->hydrateIfJsonToArray($extra); if (!empty($resultData)) { $this->extra = $resultData; } else { $this->extra = []; } }
php
public function setExtra($extra) { $resultData = $this->hydrateIfJsonToArray($extra); if (!empty($resultData)) { $this->extra = $resultData; } else { $this->extra = []; } }
[ "public", "function", "setExtra", "(", "$", "extra", ")", "{", "$", "resultData", "=", "$", "this", "->", "hydrateIfJsonToArray", "(", "$", "extra", ")", ";", "if", "(", "!", "empty", "(", "$", "resultData", ")", ")", "{", "$", "this", "->", "extra",...
Set data to extra array @param string|array $extra Data that need to be set into extra array @return void
[ "Set", "data", "to", "extra", "array" ]
e8729841db66de7de0bdc9ed79ab73fe2bc262c0
https://github.com/arkanmgerges/multi-tier-architecture/blob/e8729841db66de7de0bdc9ed79ab73fe2bc262c0/src/MultiTierArchitecture/Boundary/Definition/RequestAbstract.php#L193-L202
train
lazyguru/toggl
src/TogglService.php
TogglService.saveTimeEntry
public function saveTimeEntry(TimeEntry $entry) { $startTime = strtotime($entry->getEntryDate()); $endTime = $startTime + $entry->getDurationTime(); $this->uri = 'https://www.toggl.com/api/v8/time_entries/' . $entry->getId(); $data = [ 'time_entry' => [ 'description' => $entry->getDescription(), 'start' => substr(strftime('%Y-%m-%dT%H:%M:%S%z', $startTime), 0, 22) . ':00', 'stop' => substr(strftime('%Y-%m-%dT%H:%M:%S%z', $endTime), 0, 22) . ':00', 'billable' => $entry->isBillable(), 'wid' => $this->workspace_id, 'duration' => $entry->getDurationTime(), 'tags' => $entry->getTags(), 'id' => $entry->getId(), 'created_with' => $this->user_agent ] ]; $this->output->debug(print_r($data, true)); $data = json_encode($data); $response = $this->processRequest($data, self::PUT); $this->_handleError($data, $response); return $entry; }
php
public function saveTimeEntry(TimeEntry $entry) { $startTime = strtotime($entry->getEntryDate()); $endTime = $startTime + $entry->getDurationTime(); $this->uri = 'https://www.toggl.com/api/v8/time_entries/' . $entry->getId(); $data = [ 'time_entry' => [ 'description' => $entry->getDescription(), 'start' => substr(strftime('%Y-%m-%dT%H:%M:%S%z', $startTime), 0, 22) . ':00', 'stop' => substr(strftime('%Y-%m-%dT%H:%M:%S%z', $endTime), 0, 22) . ':00', 'billable' => $entry->isBillable(), 'wid' => $this->workspace_id, 'duration' => $entry->getDurationTime(), 'tags' => $entry->getTags(), 'id' => $entry->getId(), 'created_with' => $this->user_agent ] ]; $this->output->debug(print_r($data, true)); $data = json_encode($data); $response = $this->processRequest($data, self::PUT); $this->_handleError($data, $response); return $entry; }
[ "public", "function", "saveTimeEntry", "(", "TimeEntry", "$", "entry", ")", "{", "$", "startTime", "=", "strtotime", "(", "$", "entry", "->", "getEntryDate", "(", ")", ")", ";", "$", "endTime", "=", "$", "startTime", "+", "$", "entry", "->", "getDuration...
Persists a time entry to the Toggl API @param TimeEntry $entry @return TimeEntry
[ "Persists", "a", "time", "entry", "to", "the", "Toggl", "API" ]
5ce8b5f937b38dc5afd40b362db26e93239d7135
https://github.com/lazyguru/toggl/blob/5ce8b5f937b38dc5afd40b362db26e93239d7135/src/TogglService.php#L47-L72
train
lazyguru/toggl
src/TogglService.php
TogglService.processTogglResponse
protected function processTogglResponse($response) { // We only need to do something if results are paginated if ($response->total_count <= 50) { return $response->data; } $reqdata = []; $reqdata = json_encode($reqdata); $pages = ceil($response->total_count / 50); $curr_page = 1; $data = $response->data; $orig_uri = $this->uri; while ($curr_page < $pages) { $curr_page++; $this->uri .= '&page=' . $curr_page; $response = $this->processRequest($reqdata, self::GET); $this->_handleError($reqdata, $response); foreach ($response->data as $entry) { $data[] = $entry; } $this->uri = $orig_uri; } return $data; }
php
protected function processTogglResponse($response) { // We only need to do something if results are paginated if ($response->total_count <= 50) { return $response->data; } $reqdata = []; $reqdata = json_encode($reqdata); $pages = ceil($response->total_count / 50); $curr_page = 1; $data = $response->data; $orig_uri = $this->uri; while ($curr_page < $pages) { $curr_page++; $this->uri .= '&page=' . $curr_page; $response = $this->processRequest($reqdata, self::GET); $this->_handleError($reqdata, $response); foreach ($response->data as $entry) { $data[] = $entry; } $this->uri = $orig_uri; } return $data; }
[ "protected", "function", "processTogglResponse", "(", "$", "response", ")", "{", "// We only need to do something if results are paginated", "if", "(", "$", "response", "->", "total_count", "<=", "50", ")", "{", "return", "$", "response", "->", "data", ";", "}", "...
Process the response from Toggl to create a TimeEntry object @param array $response API response @return array
[ "Process", "the", "response", "from", "Toggl", "to", "create", "a", "TimeEntry", "object" ]
5ce8b5f937b38dc5afd40b362db26e93239d7135
https://github.com/lazyguru/toggl/blob/5ce8b5f937b38dc5afd40b362db26e93239d7135/src/TogglService.php#L124-L151
train
jmpantoja/planb-utils
src/Type/Assurance/AssuranceMethod.php
AssuranceMethod.initialize
private function initialize(object $object, string $original, string $inverted): void { $this->initMethod($object, $original, true); $this->initMethod($object, $inverted, false); }
php
private function initialize(object $object, string $original, string $inverted): void { $this->initMethod($object, $original, true); $this->initMethod($object, $inverted, false); }
[ "private", "function", "initialize", "(", "object", "$", "object", ",", "string", "$", "original", ",", "string", "$", "inverted", ")", ":", "void", "{", "$", "this", "->", "initMethod", "(", "$", "object", ",", "$", "original", ",", "true", ")", ";", ...
Inicializa la instancia calculando los valores para method y expected @param object $object @param string $original @param string $inverted
[ "Inicializa", "la", "instancia", "calculando", "los", "valores", "para", "method", "y", "expected" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Assurance/AssuranceMethod.php#L97-L101
train
mapado/doctrine-blender
lib/ObjectBlender.php
ObjectBlender.mapExternalAssociation
public function mapExternalAssociation( ExternalAssociation $externalAssociation ) { // @See https://github.com/doctrine/common/issues/336 //if (!($referenceManager instanceof DocumentManager || $referenceManager instanceof EntityManagerInterface)) { if (!(method_exists($externalAssociation->getReferenceManager(), 'getReference'))) { $msg = '$referenceManager needs to implements a `getReference` method'; throw new \InvalidArgumentException($msg); } $this->eventListener->addExternalAssoctiation($externalAssociation); $externalAssociation->getObjectManager() ->getEventManager() ->addEventListener(['postLoad'], $this->eventListener); // todo switch to doctrine event when https://github.com/doctrine/common/pull/335 is merged }
php
public function mapExternalAssociation( ExternalAssociation $externalAssociation ) { // @See https://github.com/doctrine/common/issues/336 //if (!($referenceManager instanceof DocumentManager || $referenceManager instanceof EntityManagerInterface)) { if (!(method_exists($externalAssociation->getReferenceManager(), 'getReference'))) { $msg = '$referenceManager needs to implements a `getReference` method'; throw new \InvalidArgumentException($msg); } $this->eventListener->addExternalAssoctiation($externalAssociation); $externalAssociation->getObjectManager() ->getEventManager() ->addEventListener(['postLoad'], $this->eventListener); // todo switch to doctrine event when https://github.com/doctrine/common/pull/335 is merged }
[ "public", "function", "mapExternalAssociation", "(", "ExternalAssociation", "$", "externalAssociation", ")", "{", "// @See https://github.com/doctrine/common/issues/336", "//if (!($referenceManager instanceof DocumentManager || $referenceManager instanceof EntityManagerInterface)) {", "if", ...
Map an external association between two differents Object Manager @param ExternalAssociation $externalAssociation the external association object @access public @return void
[ "Map", "an", "external", "association", "between", "two", "differents", "Object", "Manager" ]
73edac762598d35062d8c220b05459dc7fdae20d
https://github.com/mapado/doctrine-blender/blob/73edac762598d35062d8c220b05459dc7fdae20d/lib/ObjectBlender.php#L44-L61
train
olajoscs/QueryBuilder
src/ConnectionFactory.php
ConnectionFactory.create
public function create(PDO $pdo) { switch ($pdo->getDatabaseType()) { case 'mysql': $connection = new MySqlConnection($pdo); break; case 'pgsql': $connection = new PostgreSqlConnection($pdo); break; case 'sqlite': $connection = new SQLiteConnection($pdo); break; default: throw new InvalidDriverException('Not implemented driver: ' . $pdo->getDatabaseType()); } return $connection; }
php
public function create(PDO $pdo) { switch ($pdo->getDatabaseType()) { case 'mysql': $connection = new MySqlConnection($pdo); break; case 'pgsql': $connection = new PostgreSqlConnection($pdo); break; case 'sqlite': $connection = new SQLiteConnection($pdo); break; default: throw new InvalidDriverException('Not implemented driver: ' . $pdo->getDatabaseType()); } return $connection; }
[ "public", "function", "create", "(", "PDO", "$", "pdo", ")", "{", "switch", "(", "$", "pdo", "->", "getDatabaseType", "(", ")", ")", "{", "case", "'mysql'", ":", "$", "connection", "=", "new", "MySqlConnection", "(", "$", "pdo", ")", ";", "break", ";...
Create a new Connection based on the config @param PDO $pdo @return Connection @throws InvalidDriverException
[ "Create", "a", "new", "Connection", "based", "on", "the", "config" ]
5e1568ced2c2c7f0294cf32f30a290db1e642035
https://github.com/olajoscs/QueryBuilder/blob/5e1568ced2c2c7f0294cf32f30a290db1e642035/src/ConnectionFactory.php#L26-L43
train
webberig/html-utilbelt
src/Generator/GeneratorAbstract.php
GeneratorAbstract.updateElement
public function updateElement(Element $element, array $data) { if (isset($data["id"])) { $element->setId($data["id"]); } if (isset($data["class"])) { $element->addClass($data["class"]); } return $element; }
php
public function updateElement(Element $element, array $data) { if (isset($data["id"])) { $element->setId($data["id"]); } if (isset($data["class"])) { $element->addClass($data["class"]); } return $element; }
[ "public", "function", "updateElement", "(", "Element", "$", "element", ",", "array", "$", "data", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "\"id\"", "]", ")", ")", "{", "$", "element", "->", "setId", "(", "$", "data", "[", "\"id\"", "]"...
Set element properties using a json string @param Element $element array @param $data array @return Element $element
[ "Set", "element", "properties", "using", "a", "json", "string" ]
0f49426e46ff9958e2454c44852a0aa9fd83ff74
https://github.com/webberig/html-utilbelt/blob/0f49426e46ff9958e2454c44852a0aa9fd83ff74/src/Generator/GeneratorAbstract.php#L21-L29
train
it-blaster/uploadable-bundle
Form/Type/UploadableType.php
UploadableType.onPreSetData
public function onPreSetData(FormEvent $event) { if (!$event->getData() || !$event->getForm()->getConfig()->getOption('removable')) { return; } $event->getForm()->add('remove', 'checkbox', array( 'label' => $this->options['remove_label'] )); }
php
public function onPreSetData(FormEvent $event) { if (!$event->getData() || !$event->getForm()->getConfig()->getOption('removable')) { return; } $event->getForm()->add('remove', 'checkbox', array( 'label' => $this->options['remove_label'] )); }
[ "public", "function", "onPreSetData", "(", "FormEvent", "$", "event", ")", "{", "if", "(", "!", "$", "event", "->", "getData", "(", ")", "||", "!", "$", "event", "->", "getForm", "(", ")", "->", "getConfig", "(", ")", "->", "getOption", "(", "'remova...
Adds a remove-field if need @param FormEvent $event
[ "Adds", "a", "remove", "-", "field", "if", "need" ]
76b9a17b292965d334bf3338b2bbc54cd17a7829
https://github.com/it-blaster/uploadable-bundle/blob/76b9a17b292965d334bf3338b2bbc54cd17a7829/Form/Type/UploadableType.php#L93-L102
train
it-blaster/uploadable-bundle
Form/Type/UploadableType.php
UploadableType.onPreSubmit
public function onPreSubmit(FormEvent $event) { $data = $event->getData(); if ($data['file'] instanceof UploadedFile) { $event->getForm()->remove('remove'); } if (empty($data['file']) && (!isset($data['remove']) || !$data['remove'])) { $event->setData($event->getForm()->getViewData()); } }
php
public function onPreSubmit(FormEvent $event) { $data = $event->getData(); if ($data['file'] instanceof UploadedFile) { $event->getForm()->remove('remove'); } if (empty($data['file']) && (!isset($data['remove']) || !$data['remove'])) { $event->setData($event->getForm()->getViewData()); } }
[ "public", "function", "onPreSubmit", "(", "FormEvent", "$", "event", ")", "{", "$", "data", "=", "$", "event", "->", "getData", "(", ")", ";", "if", "(", "$", "data", "[", "'file'", "]", "instanceof", "UploadedFile", ")", "{", "$", "event", "->", "ge...
Forbids to erase a value @param FormEvent $event
[ "Forbids", "to", "erase", "a", "value" ]
76b9a17b292965d334bf3338b2bbc54cd17a7829
https://github.com/it-blaster/uploadable-bundle/blob/76b9a17b292965d334bf3338b2bbc54cd17a7829/Form/Type/UploadableType.php#L109-L120
train
ekyna/GoogleBundle
DependencyInjection/Configuration.php
Configuration.addClientSection
private function addClientSection(ArrayNodeDefinition $node) { $node ->children() ->arrayNode('client') ->children() ->scalarNode('application_name')->isRequired()->cannotBeEmpty()->end() ->scalarNode('client_id')->end() ->scalarNode('client_secret')->end() ->scalarNode('redirect_uri')->end() ->scalarNode('developer_key')->end() ->end() ->end() ->end() ; }
php
private function addClientSection(ArrayNodeDefinition $node) { $node ->children() ->arrayNode('client') ->children() ->scalarNode('application_name')->isRequired()->cannotBeEmpty()->end() ->scalarNode('client_id')->end() ->scalarNode('client_secret')->end() ->scalarNode('redirect_uri')->end() ->scalarNode('developer_key')->end() ->end() ->end() ->end() ; }
[ "private", "function", "addClientSection", "(", "ArrayNodeDefinition", "$", "node", ")", "{", "$", "node", "->", "children", "(", ")", "->", "arrayNode", "(", "'client'", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'application_name'", ")", "-...
Adds the client section. @param ArrayNodeDefinition $node
[ "Adds", "the", "client", "section", "." ]
b6689522de5911b8de332b18c07154eafc5f3589
https://github.com/ekyna/GoogleBundle/blob/b6689522de5911b8de332b18c07154eafc5f3589/DependencyInjection/Configuration.php#L34-L49
train
codebobbly/dvoconnector
Classes/Controller/AssociationStaticController.php
AssociationStaticController.singleAssociationAction
public function singleAssociationAction() { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $this->settings[self::SETTINGS_ASSOCIATION_ID] ], __CLASS__, __FUNCTION__); return $this->view->render(); }
php
public function singleAssociationAction() { $this->checkStaticTemplateIsIncluded(); $this->checkSettings(); $this->slotExtendedAssignMultiple([ self::VIEW_VARIABLE_ASSOCIATION_ID => $this->settings[self::SETTINGS_ASSOCIATION_ID] ], __CLASS__, __FUNCTION__); return $this->view->render(); }
[ "public", "function", "singleAssociationAction", "(", ")", "{", "$", "this", "->", "checkStaticTemplateIsIncluded", "(", ")", ";", "$", "this", "->", "checkSettings", "(", ")", ";", "$", "this", "->", "slotExtendedAssignMultiple", "(", "[", "self", "::", "VIEW...
single association action. @return string
[ "single", "association", "action", "." ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/AssociationStaticController.php#L31-L41
train
lciolecki/zf-extensions-library
library/Extlib/Traits/Logger.php
Logger.getLogger
public function getLogger() { if (null === $this->logger && \Zend_Registry::isRegistered(self::getNamespace())) { $this->setLogger(\Zend_Registry::get(self::getNamespace())); } return $this->logger; }
php
public function getLogger() { if (null === $this->logger && \Zend_Registry::isRegistered(self::getNamespace())) { $this->setLogger(\Zend_Registry::get(self::getNamespace())); } return $this->logger; }
[ "public", "function", "getLogger", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "logger", "&&", "\\", "Zend_Registry", "::", "isRegistered", "(", "self", "::", "getNamespace", "(", ")", ")", ")", "{", "$", "this", "->", "setLogger", "(",...
Get instance of logger @return \Zend_Log
[ "Get", "instance", "of", "logger" ]
f479a63188d17f1488b392d4fc14fe47a417ea55
https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Traits/Logger.php#L34-L41
train
indigophp-archive/fuel-core
classes/Providers/FuelServiceProvider.php
FuelServiceProvider.resolveManager
public function resolveManager($dic, $placement = 'prepend') { $manager = $dic->resolve('Fuel\\Alias\\Manager'); $manager->register($placement); return $manager; }
php
public function resolveManager($dic, $placement = 'prepend') { $manager = $dic->resolve('Fuel\\Alias\\Manager'); $manager->register($placement); return $manager; }
[ "public", "function", "resolveManager", "(", "$", "dic", ",", "$", "placement", "=", "'prepend'", ")", "{", "$", "manager", "=", "$", "dic", "->", "resolve", "(", "'Fuel\\\\Alias\\\\Manager'", ")", ";", "$", "manager", "->", "register", "(", "$", "placemen...
Resolves an Alias Manager @param Container $dic @param string $placement @return Manager
[ "Resolves", "an", "Alias", "Manager" ]
275462154fb7937f8e1c2c541b31d8e7c5760e39
https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/classes/Providers/FuelServiceProvider.php#L49-L56
train
wucdbm/wucdbm-bundle
Twig/ControllerActionName.php
ControllerActionName.controllerName
public function controllerName() { $request = $this->stack->getCurrentRequest(); if ($request instanceof Request) { $string = $request->get('_controller'); $parts = explode('::', $string); $controller = $parts[0]; $pattern = "#Controller\\\([a-zA-Z\\\]*)Controller#"; $matches = array(); preg_match($pattern, $controller, $matches); if (isset($matches[1])) { return strtolower(str_replace('\\', '_', $matches[1])); } return ''; } return ''; }
php
public function controllerName() { $request = $this->stack->getCurrentRequest(); if ($request instanceof Request) { $string = $request->get('_controller'); $parts = explode('::', $string); $controller = $parts[0]; $pattern = "#Controller\\\([a-zA-Z\\\]*)Controller#"; $matches = array(); preg_match($pattern, $controller, $matches); if (isset($matches[1])) { return strtolower(str_replace('\\', '_', $matches[1])); } return ''; } return ''; }
[ "public", "function", "controllerName", "(", ")", "{", "$", "request", "=", "$", "this", "->", "stack", "->", "getCurrentRequest", "(", ")", ";", "if", "(", "$", "request", "instanceof", "Request", ")", "{", "$", "string", "=", "$", "request", "->", "g...
Get current controller name
[ "Get", "current", "controller", "name" ]
7479e7a864b58b03c7b1045d4021f683b5396245
https://github.com/wucdbm/wucdbm-bundle/blob/7479e7a864b58b03c7b1045d4021f683b5396245/Twig/ControllerActionName.php#L43-L60
train
wucdbm/wucdbm-bundle
Twig/ControllerActionName.php
ControllerActionName.actionName
public function actionName() { $request = $this->stack->getCurrentRequest(); if ($request instanceof Request) { $pattern = "#::([a-zA-Z]*)Action#"; $matches = array(); preg_match($pattern, $request->get('_controller'), $matches); if (isset($matches[1])) { return strtolower($matches[1]); } return ''; } return ''; }
php
public function actionName() { $request = $this->stack->getCurrentRequest(); if ($request instanceof Request) { $pattern = "#::([a-zA-Z]*)Action#"; $matches = array(); preg_match($pattern, $request->get('_controller'), $matches); if (isset($matches[1])) { return strtolower($matches[1]); } return ''; } return ''; }
[ "public", "function", "actionName", "(", ")", "{", "$", "request", "=", "$", "this", "->", "stack", "->", "getCurrentRequest", "(", ")", ";", "if", "(", "$", "request", "instanceof", "Request", ")", "{", "$", "pattern", "=", "\"#::([a-zA-Z]*)Action#\"", ";...
Get current action name
[ "Get", "current", "action", "name" ]
7479e7a864b58b03c7b1045d4021f683b5396245
https://github.com/wucdbm/wucdbm-bundle/blob/7479e7a864b58b03c7b1045d4021f683b5396245/Twig/ControllerActionName.php#L65-L79
train
kpacha/php-benchmark-tool
src/Kpacha/BenchmarkTool/Benchmarker/Base.php
Base.run
public function run($target) { $return = $this->exec($this->getCommand($target)); return $this->output[$target] = $this->cleanOutput($target, $return['output']); }
php
public function run($target) { $return = $this->exec($this->getCommand($target)); return $this->output[$target] = $this->cleanOutput($target, $return['output']); }
[ "public", "function", "run", "(", "$", "target", ")", "{", "$", "return", "=", "$", "this", "->", "exec", "(", "$", "this", "->", "getCommand", "(", "$", "target", ")", ")", ";", "return", "$", "this", "->", "output", "[", "$", "target", "]", "="...
Run the command with the given target @param string $target
[ "Run", "the", "command", "with", "the", "given", "target" ]
71c73feadb01ba4c36d9df5ac947c07a7120c732
https://github.com/kpacha/php-benchmark-tool/blob/71c73feadb01ba4c36d9df5ac947c07a7120c732/src/Kpacha/BenchmarkTool/Benchmarker/Base.php#L45-L49
train
drmvc/helpers
src/Helpers/UUID.php
UUID.v5
public static function v5(string $namespace, string $name) { if (!Validate::isValidUUID($namespace)) { return false; } // Get hexadecimal components of namespace $nhex = str_replace(array('-', '{', '}'), '', $namespace); // Binary Value $nstr = ''; // Convert Namespace UUID to bits for ($i = 0; $i < strlen($nhex); $i += 2) { $nstr .= \chr(hexdec($nhex[$i] . $nhex[$i + 1])); } // Calculate hash value $hash = sha1($nstr . $name); return sprintf('%08s-%04s-%04x-%04x-%12s', // 32 bits for "time_low" substr($hash, 0, 8), // 16 bits for "time_mid" substr($hash, 8, 4), // 16 bits for "time_hi_and_version", // four most significant bits holds version number 5 (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000, // 16 bits, 8 bits for "clk_seq_hi_res", // 8 bits for "clk_seq_low", // two most significant bits holds zero and one for variant DCE1.1 (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000, // 48 bits for "node" substr($hash, 20, 12) ); }
php
public static function v5(string $namespace, string $name) { if (!Validate::isValidUUID($namespace)) { return false; } // Get hexadecimal components of namespace $nhex = str_replace(array('-', '{', '}'), '', $namespace); // Binary Value $nstr = ''; // Convert Namespace UUID to bits for ($i = 0; $i < strlen($nhex); $i += 2) { $nstr .= \chr(hexdec($nhex[$i] . $nhex[$i + 1])); } // Calculate hash value $hash = sha1($nstr . $name); return sprintf('%08s-%04s-%04x-%04x-%12s', // 32 bits for "time_low" substr($hash, 0, 8), // 16 bits for "time_mid" substr($hash, 8, 4), // 16 bits for "time_hi_and_version", // four most significant bits holds version number 5 (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000, // 16 bits, 8 bits for "clk_seq_hi_res", // 8 bits for "clk_seq_low", // two most significant bits holds zero and one for variant DCE1.1 (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000, // 48 bits for "node" substr($hash, 20, 12) ); }
[ "public", "static", "function", "v5", "(", "string", "$", "namespace", ",", "string", "$", "name", ")", "{", "if", "(", "!", "Validate", "::", "isValidUUID", "(", "$", "namespace", ")", ")", "{", "return", "false", ";", "}", "// Get hexadecimal components ...
Generate identifier of 5th version @param string $namespace @param string $name @return bool|string
[ "Generate", "identifier", "of", "5th", "version" ]
1a9a3f8d4c655b48ddbd61a81eb15688ad207d7b
https://github.com/drmvc/helpers/blob/1a9a3f8d4c655b48ddbd61a81eb15688ad207d7b/src/Helpers/UUID.php#L96-L136
train