id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
21,400
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/ConstantConverter.php
ConstantConverter.convert
public function convert(\DOMElement $parent, ConstantDescriptor $constant) { $fullyQualifiedNamespaceName = $constant->getNamespace() instanceof NamespaceDescriptor ? $constant->getNamespace()->getFullyQualifiedStructuralElementName() : $parent->getAttribute('namespace'); $child = new \DOMElement('constant'); $parent->appendChild($child); $child->setAttribute('namespace', ltrim($fullyQualifiedNamespaceName, '\\')); $child->setAttribute('line', $constant->getLine()); $child->appendChild(new \DOMElement('name', $constant->getName())); $child->appendChild(new \DOMElement('full_name', $constant->getFullyQualifiedStructuralElementName())); $child->appendChild(new \DOMElement('value'))->appendChild(new \DOMText($constant->getValue())); $this->docBlockConverter->convert($child, $constant); return $child; }
php
public function convert(\DOMElement $parent, ConstantDescriptor $constant) { $fullyQualifiedNamespaceName = $constant->getNamespace() instanceof NamespaceDescriptor ? $constant->getNamespace()->getFullyQualifiedStructuralElementName() : $parent->getAttribute('namespace'); $child = new \DOMElement('constant'); $parent->appendChild($child); $child->setAttribute('namespace', ltrim($fullyQualifiedNamespaceName, '\\')); $child->setAttribute('line', $constant->getLine()); $child->appendChild(new \DOMElement('name', $constant->getName())); $child->appendChild(new \DOMElement('full_name', $constant->getFullyQualifiedStructuralElementName())); $child->appendChild(new \DOMElement('value'))->appendChild(new \DOMText($constant->getValue())); $this->docBlockConverter->convert($child, $constant); return $child; }
[ "public", "function", "convert", "(", "\\", "DOMElement", "$", "parent", ",", "ConstantDescriptor", "$", "constant", ")", "{", "$", "fullyQualifiedNamespaceName", "=", "$", "constant", "->", "getNamespace", "(", ")", "instanceof", "NamespaceDescriptor", "?", "$", "constant", "->", "getNamespace", "(", ")", "->", "getFullyQualifiedStructuralElementName", "(", ")", ":", "$", "parent", "->", "getAttribute", "(", "'namespace'", ")", ";", "$", "child", "=", "new", "\\", "DOMElement", "(", "'constant'", ")", ";", "$", "parent", "->", "appendChild", "(", "$", "child", ")", ";", "$", "child", "->", "setAttribute", "(", "'namespace'", ",", "ltrim", "(", "$", "fullyQualifiedNamespaceName", ",", "'\\\\'", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'line'", ",", "$", "constant", "->", "getLine", "(", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'name'", ",", "$", "constant", "->", "getName", "(", ")", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'full_name'", ",", "$", "constant", "->", "getFullyQualifiedStructuralElementName", "(", ")", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'value'", ")", ")", "->", "appendChild", "(", "new", "\\", "DOMText", "(", "$", "constant", "->", "getValue", "(", ")", ")", ")", ";", "$", "this", "->", "docBlockConverter", "->", "convert", "(", "$", "child", ",", "$", "constant", ")", ";", "return", "$", "child", ";", "}" ]
Export the given reflected constant definition to the provided parent element. @param \DOMElement $parent Element to augment. @param ConstantDescriptor $constant Element to export. @return \DOMElement
[ "Export", "the", "given", "reflected", "constant", "definition", "to", "the", "provided", "parent", "element", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/ConstantConverter.php#L45-L64
21,401
raideer/twitch-api
src/OAuth.php
OAuth.setScope
public function setScope($scope) { if (!is_array($scope)) { $this->scopes = explode(' ', $scope); } else { $this->scopes = $scope; } return $this; }
php
public function setScope($scope) { if (!is_array($scope)) { $this->scopes = explode(' ', $scope); } else { $this->scopes = $scope; } return $this; }
[ "public", "function", "setScope", "(", "$", "scope", ")", "{", "if", "(", "!", "is_array", "(", "$", "scope", ")", ")", "{", "$", "this", "->", "scopes", "=", "explode", "(", "' '", ",", "$", "scope", ")", ";", "}", "else", "{", "$", "this", "->", "scopes", "=", "$", "scope", ";", "}", "return", "$", "this", ";", "}" ]
Sets the scope. @param string or array $scope Space seperated string or array
[ "Sets", "the", "scope", "." ]
27ebf1dcb0315206300d507600b6a82ebe33d57e
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/OAuth.php#L91-L100
21,402
raideer/twitch-api
src/OAuth.php
OAuth.addScope
public function addScope($scope) { if (!is_array($scope)) { $scope = explode(' ', $scope); } $this->scopes = array_unique(array_merge($this->scopes, $scope)); return $this; }
php
public function addScope($scope) { if (!is_array($scope)) { $scope = explode(' ', $scope); } $this->scopes = array_unique(array_merge($this->scopes, $scope)); return $this; }
[ "public", "function", "addScope", "(", "$", "scope", ")", "{", "if", "(", "!", "is_array", "(", "$", "scope", ")", ")", "{", "$", "scope", "=", "explode", "(", "' '", ",", "$", "scope", ")", ";", "}", "$", "this", "->", "scopes", "=", "array_unique", "(", "array_merge", "(", "$", "this", "->", "scopes", ",", "$", "scope", ")", ")", ";", "return", "$", "this", ";", "}" ]
Adds a scope. @param string $scope https://github.com/justintv/Twitch-API/blob/master/authentication.md#scopes
[ "Adds", "a", "scope", "." ]
27ebf1dcb0315206300d507600b6a82ebe33d57e
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/OAuth.php#L117-L126
21,403
raideer/twitch-api
src/OAuth.php
OAuth.getResponse
public function getResponse($code, $forceNew = false) { if (!$this->oauthResponse || $forceNew) { $form_params = [ 'client_id' => $this->getClientId(), 'client_secret' => $this->clientSecret, 'grant_type' => 'authorization_code', 'redirect_uri' => $this->getRedirectUri(), 'code' => $code, 'state' => $this->getState(), ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->authURL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $form_params); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, 5); $result = curl_exec($ch); curl_close($ch); $data = json_decode($result, true); if (json_last_error() != JSON_ERROR_NONE) { throw new \UnexpectedValueException('Received data is not json'); return; } $status = $data['status']; if (strrpos($status, 20, -strlen($status)) === false) { throw new Exceptions\BadResponseException('Received bad response ('.$data['status'].'): '.$data['message']); return; } $this->OAuthResponse = new OAuthResponse($data); } return $this->OAuthResponse; }
php
public function getResponse($code, $forceNew = false) { if (!$this->oauthResponse || $forceNew) { $form_params = [ 'client_id' => $this->getClientId(), 'client_secret' => $this->clientSecret, 'grant_type' => 'authorization_code', 'redirect_uri' => $this->getRedirectUri(), 'code' => $code, 'state' => $this->getState(), ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->authURL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $form_params); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, 5); $result = curl_exec($ch); curl_close($ch); $data = json_decode($result, true); if (json_last_error() != JSON_ERROR_NONE) { throw new \UnexpectedValueException('Received data is not json'); return; } $status = $data['status']; if (strrpos($status, 20, -strlen($status)) === false) { throw new Exceptions\BadResponseException('Received bad response ('.$data['status'].'): '.$data['message']); return; } $this->OAuthResponse = new OAuthResponse($data); } return $this->OAuthResponse; }
[ "public", "function", "getResponse", "(", "$", "code", ",", "$", "forceNew", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "oauthResponse", "||", "$", "forceNew", ")", "{", "$", "form_params", "=", "[", "'client_id'", "=>", "$", "this", "->", "getClientId", "(", ")", ",", "'client_secret'", "=>", "$", "this", "->", "clientSecret", ",", "'grant_type'", "=>", "'authorization_code'", ",", "'redirect_uri'", "=>", "$", "this", "->", "getRedirectUri", "(", ")", ",", "'code'", "=>", "$", "code", ",", "'state'", "=>", "$", "this", "->", "getState", "(", ")", ",", "]", ";", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "this", "->", "authURL", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "$", "form_params", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "crl", ",", "CURLOPT_CONNECTTIMEOUT", ",", "5", ")", ";", "$", "result", "=", "curl_exec", "(", "$", "ch", ")", ";", "curl_close", "(", "$", "ch", ")", ";", "$", "data", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "if", "(", "json_last_error", "(", ")", "!=", "JSON_ERROR_NONE", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Received data is not json'", ")", ";", "return", ";", "}", "$", "status", "=", "$", "data", "[", "'status'", "]", ";", "if", "(", "strrpos", "(", "$", "status", ",", "20", ",", "-", "strlen", "(", "$", "status", ")", ")", "===", "false", ")", "{", "throw", "new", "Exceptions", "\\", "BadResponseException", "(", "'Received bad response ('", ".", "$", "data", "[", "'status'", "]", ".", "'): '", ".", "$", "data", "[", "'message'", "]", ")", ";", "return", ";", "}", "$", "this", "->", "OAuthResponse", "=", "new", "OAuthResponse", "(", "$", "data", ")", ";", "}", "return", "$", "this", "->", "OAuthResponse", ";", "}" ]
Returns the OAuthResponse object that contains the access_token, registered scopes and the refresh_token. @param string $code Code returned by OAuth @param bool $forceNew Force new token @return Raideer\TwitchApi\OAuthResponse
[ "Returns", "the", "OAuthResponse", "object", "that", "contains", "the", "access_token", "registered", "scopes", "and", "the", "refresh_token", "." ]
27ebf1dcb0315206300d507600b6a82ebe33d57e
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/OAuth.php#L159-L199
21,404
raideer/twitch-api
src/OAuth.php
OAuth.checkScope
public function checkScope($scope) { if ($this->OAuthResponse) { return $this->OAuthResponse->hasScope($scope); } return in_array($scope, $this->getScope()); }
php
public function checkScope($scope) { if ($this->OAuthResponse) { return $this->OAuthResponse->hasScope($scope); } return in_array($scope, $this->getScope()); }
[ "public", "function", "checkScope", "(", "$", "scope", ")", "{", "if", "(", "$", "this", "->", "OAuthResponse", ")", "{", "return", "$", "this", "->", "OAuthResponse", "->", "hasScope", "(", "$", "scope", ")", ";", "}", "return", "in_array", "(", "$", "scope", ",", "$", "this", "->", "getScope", "(", ")", ")", ";", "}" ]
Checks if the scope is registered. @param string $scope Scope name @return bool
[ "Checks", "if", "the", "scope", "is", "registered", "." ]
27ebf1dcb0315206300d507600b6a82ebe33d57e
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/OAuth.php#L208-L215
21,405
raideer/twitch-api
src/OAuth.php
OAuth.getUrl
public function getUrl() { $url = $this->baseAuthUrl; $url .= '?response_type=code'; $url .= '&client_id='.$this->clientId; $url .= '&redirect_uri='.$this->redirectUri; $url .= '&scope='.implode(' ', $this->scopes); $url .= '&state='.$this->state; return $url; }
php
public function getUrl() { $url = $this->baseAuthUrl; $url .= '?response_type=code'; $url .= '&client_id='.$this->clientId; $url .= '&redirect_uri='.$this->redirectUri; $url .= '&scope='.implode(' ', $this->scopes); $url .= '&state='.$this->state; return $url; }
[ "public", "function", "getUrl", "(", ")", "{", "$", "url", "=", "$", "this", "->", "baseAuthUrl", ";", "$", "url", ".=", "'?response_type=code'", ";", "$", "url", ".=", "'&client_id='", ".", "$", "this", "->", "clientId", ";", "$", "url", ".=", "'&redirect_uri='", ".", "$", "this", "->", "redirectUri", ";", "$", "url", ".=", "'&scope='", ".", "implode", "(", "' '", ",", "$", "this", "->", "scopes", ")", ";", "$", "url", ".=", "'&state='", ".", "$", "this", "->", "state", ";", "return", "$", "url", ";", "}" ]
Builds the OAuth URL. @return string URL
[ "Builds", "the", "OAuth", "URL", "." ]
27ebf1dcb0315206300d507600b6a82ebe33d57e
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/OAuth.php#L222-L232
21,406
kenphp/ken
src/Helpers/Route.php
Route.group
public static function group($route, $callback, $options = []) { app()->router->group($route, $callback, $options); }
php
public static function group($route, $callback, $options = []) { app()->router->group($route, $callback, $options); }
[ "public", "static", "function", "group", "(", "$", "route", ",", "$", "callback", ",", "$", "options", "=", "[", "]", ")", "{", "app", "(", ")", "->", "router", "->", "group", "(", "$", "route", ",", "$", "callback", ",", "$", "options", ")", ";", "}" ]
Adds group route. @param string $route Group base route @param callable $callback @param array $options
[ "Adds", "group", "route", "." ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Helpers/Route.php#L93-L96
21,407
cirrusidentity/simplesamlphp-test-utils
src/InMemoryStore.php
InMemoryStore.get
public function get($type, $key) { if (array_key_exists($key, self::$store)) { //TODO: implement expiration check // implement data type check? return self::$store[$key]['value']; } return null; }
php
public function get($type, $key) { if (array_key_exists($key, self::$store)) { //TODO: implement expiration check // implement data type check? return self::$store[$key]['value']; } return null; }
[ "public", "function", "get", "(", "$", "type", ",", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "self", "::", "$", "store", ")", ")", "{", "//TODO: implement expiration check", "// implement data type check?", "return", "self", "::", "$", "store", "[", "$", "key", "]", "[", "'value'", "]", ";", "}", "return", "null", ";", "}" ]
Retrieve a value from the data store. @param string $type The data type. @param string $key The key. @return mixed|null The value.
[ "Retrieve", "a", "value", "from", "the", "data", "store", "." ]
79150efb8bca89c180b604dc1d6194f819ebe2b2
https://github.com/cirrusidentity/simplesamlphp-test-utils/blob/79150efb8bca89c180b604dc1d6194f819ebe2b2/src/InMemoryStore.php#L32-L40
21,408
cirrusidentity/simplesamlphp-test-utils
src/InMemoryStore.php
InMemoryStore.set
public function set($type, $key, $value, $expire = null) { self::$store[$key] = [ 'type' => $type, 'value' => $value, 'expire' => $expire ]; }
php
public function set($type, $key, $value, $expire = null) { self::$store[$key] = [ 'type' => $type, 'value' => $value, 'expire' => $expire ]; }
[ "public", "function", "set", "(", "$", "type", ",", "$", "key", ",", "$", "value", ",", "$", "expire", "=", "null", ")", "{", "self", "::", "$", "store", "[", "$", "key", "]", "=", "[", "'type'", "=>", "$", "type", ",", "'value'", "=>", "$", "value", ",", "'expire'", "=>", "$", "expire", "]", ";", "}" ]
Save a value to the data store. @param string $type The data type. @param string $key The key. @param mixed $value The value. @param int|null $expire The expiration time (unix timestamp), or null if it never expires.
[ "Save", "a", "value", "to", "the", "data", "store", "." ]
79150efb8bca89c180b604dc1d6194f819ebe2b2
https://github.com/cirrusidentity/simplesamlphp-test-utils/blob/79150efb8bca89c180b604dc1d6194f819ebe2b2/src/InMemoryStore.php#L50-L57
21,409
willhoffmann/domuserp-php
src/Resources/CommercialSector/CommercialSector.php
CommercialSector.customers
public function customers($id) { $customers = $this->execute( self::HTTP_GET, self::DOMUSERP_API_OPERACIONAL . '/setorcomercial/' . $id . '/clientes' ); return $customers; }
php
public function customers($id) { $customers = $this->execute( self::HTTP_GET, self::DOMUSERP_API_OPERACIONAL . '/setorcomercial/' . $id . '/clientes' ); return $customers; }
[ "public", "function", "customers", "(", "$", "id", ")", "{", "$", "customers", "=", "$", "this", "->", "execute", "(", "self", "::", "HTTP_GET", ",", "self", "::", "DOMUSERP_API_OPERACIONAL", ".", "'/setorcomercial/'", ".", "$", "id", ".", "'/clientes'", ")", ";", "return", "$", "customers", ";", "}" ]
Lists all customers linked to the commercial sector @param $id @return string @throws \GuzzleHttp\Exception\GuzzleException
[ "Lists", "all", "customers", "linked", "to", "the", "commercial", "sector" ]
44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6
https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/CommercialSector/CommercialSector.php#L48-L56
21,410
nikolaposa/ZfOpenGraph
src/ZfOpenGraph/View/Helper/OpenGraph.php
OpenGraph.setLocale
public function setLocale($locale, array $alternates = array()) { $this->insertMeta('set', 'locale', $locale); if (!empty($alternates)) { foreach ($alternates as $alternate) { $this->insertStructure('append', 'locale', array( 'alternate' => $alternate )); } } return $this; }
php
public function setLocale($locale, array $alternates = array()) { $this->insertMeta('set', 'locale', $locale); if (!empty($alternates)) { foreach ($alternates as $alternate) { $this->insertStructure('append', 'locale', array( 'alternate' => $alternate )); } } return $this; }
[ "public", "function", "setLocale", "(", "$", "locale", ",", "array", "$", "alternates", "=", "array", "(", ")", ")", "{", "$", "this", "->", "insertMeta", "(", "'set'", ",", "'locale'", ",", "$", "locale", ")", ";", "if", "(", "!", "empty", "(", "$", "alternates", ")", ")", "{", "foreach", "(", "$", "alternates", "as", "$", "alternate", ")", "{", "$", "this", "->", "insertStructure", "(", "'append'", ",", "'locale'", ",", "array", "(", "'alternate'", "=>", "$", "alternate", ")", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set 'locale' property. @param string $locale Default locale @param array $alternates Alternate locales array @return self
[ "Set", "locale", "property", "." ]
5e1a9b6ff8d2e149dc9d949635f39786f6acc347
https://github.com/nikolaposa/ZfOpenGraph/blob/5e1a9b6ff8d2e149dc9d949635f39786f6acc347/src/ZfOpenGraph/View/Helper/OpenGraph.php#L200-L213
21,411
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_Manager_Main.onRequestTerminate
public function onRequestTerminate() { // lets see if there were unhandled fatal errors $lasterror=error_get_last(); if(!is_null($lasterror)){ if($lasterror['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR)){ // fatal error occured // increase memory limit so we we can at least complete our error handling (in case it was Allowed memory size exhausted) // (adding 1MB, unless already unlimited) $memlim=Web2All_PHP_INI::getBytes(ini_get('memory_limit')); if($memlim!=-1){ ini_set('memory_limit',$memlim+1000000); } // then add this error to the observers $error = Web2All_Manager_Error::getInstance(); $exception = new Web2All_Manager_TriggerException($lasterror['type'], $lasterror['message'], $lasterror['file'], $lasterror['line'], array()); if ($error) { $error->setState($exception,$lasterror['type']); } } } }
php
public function onRequestTerminate() { // lets see if there were unhandled fatal errors $lasterror=error_get_last(); if(!is_null($lasterror)){ if($lasterror['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR)){ // fatal error occured // increase memory limit so we we can at least complete our error handling (in case it was Allowed memory size exhausted) // (adding 1MB, unless already unlimited) $memlim=Web2All_PHP_INI::getBytes(ini_get('memory_limit')); if($memlim!=-1){ ini_set('memory_limit',$memlim+1000000); } // then add this error to the observers $error = Web2All_Manager_Error::getInstance(); $exception = new Web2All_Manager_TriggerException($lasterror['type'], $lasterror['message'], $lasterror['file'], $lasterror['line'], array()); if ($error) { $error->setState($exception,$lasterror['type']); } } } }
[ "public", "function", "onRequestTerminate", "(", ")", "{", "// lets see if there were unhandled fatal errors\r", "$", "lasterror", "=", "error_get_last", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "lasterror", ")", ")", "{", "if", "(", "$", "lasterror", "[", "'type'", "]", "&", "(", "E_ERROR", "|", "E_PARSE", "|", "E_CORE_ERROR", "|", "E_COMPILE_ERROR", "|", "E_USER_ERROR", "|", "E_RECOVERABLE_ERROR", ")", ")", "{", "// fatal error occured\r", "// increase memory limit so we we can at least complete our error handling (in case it was Allowed memory size exhausted)\r", "// (adding 1MB, unless already unlimited)\r", "$", "memlim", "=", "Web2All_PHP_INI", "::", "getBytes", "(", "ini_get", "(", "'memory_limit'", ")", ")", ";", "if", "(", "$", "memlim", "!=", "-", "1", ")", "{", "ini_set", "(", "'memory_limit'", ",", "$", "memlim", "+", "1000000", ")", ";", "}", "// then add this error to the observers\r", "$", "error", "=", "Web2All_Manager_Error", "::", "getInstance", "(", ")", ";", "$", "exception", "=", "new", "Web2All_Manager_TriggerException", "(", "$", "lasterror", "[", "'type'", "]", ",", "$", "lasterror", "[", "'message'", "]", ",", "$", "lasterror", "[", "'file'", "]", ",", "$", "lasterror", "[", "'line'", "]", ",", "array", "(", ")", ")", ";", "if", "(", "$", "error", ")", "{", "$", "error", "->", "setState", "(", "$", "exception", ",", "$", "lasterror", "[", "'type'", "]", ")", ";", "}", "}", "}", "}" ]
Gets executed when request terminates WARNING: do not call exit() or errorhandling will break
[ "Gets", "executed", "when", "request", "terminates" ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L508-L529
21,412
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_Manager_Main.error_log_wrap
public static function error_log_wrap($message) { // msglen is the remain length of the message that needs to be written. $msglen=strlen($message); $i=0; while($msglen>0){ if($msglen>8000){ // the remaining message that needs to be written is still longer than 8000 bytes // so error_log only a chunk (start at offset: number of itereations * 8000) error_log(substr($message,$i*8000,8000)); $msglen=$msglen-8000; }else{ // less than 8000 bytes left, write the remainder (end) error_log(substr($message,$i*8000)); $msglen=0; } $i++; } }
php
public static function error_log_wrap($message) { // msglen is the remain length of the message that needs to be written. $msglen=strlen($message); $i=0; while($msglen>0){ if($msglen>8000){ // the remaining message that needs to be written is still longer than 8000 bytes // so error_log only a chunk (start at offset: number of itereations * 8000) error_log(substr($message,$i*8000,8000)); $msglen=$msglen-8000; }else{ // less than 8000 bytes left, write the remainder (end) error_log(substr($message,$i*8000)); $msglen=0; } $i++; } }
[ "public", "static", "function", "error_log_wrap", "(", "$", "message", ")", "{", "// msglen is the remain length of the message that needs to be written.\r", "$", "msglen", "=", "strlen", "(", "$", "message", ")", ";", "$", "i", "=", "0", ";", "while", "(", "$", "msglen", ">", "0", ")", "{", "if", "(", "$", "msglen", ">", "8000", ")", "{", "// the remaining message that needs to be written is still longer than 8000 bytes\r", "// so error_log only a chunk (start at offset: number of itereations * 8000)\r", "error_log", "(", "substr", "(", "$", "message", ",", "$", "i", "*", "8000", ",", "8000", ")", ")", ";", "$", "msglen", "=", "$", "msglen", "-", "8000", ";", "}", "else", "{", "// less than 8000 bytes left, write the remainder (end)\r", "error_log", "(", "substr", "(", "$", "message", ",", "$", "i", "*", "8000", ")", ")", ";", "$", "msglen", "=", "0", ";", "}", "$", "i", "++", ";", "}", "}" ]
Log the message to the error_log, but wrap at 8000 bytes to prevent automatic cutoff by the PHP error_log function @param string $message
[ "Log", "the", "message", "to", "the", "error_log", "but", "wrap", "at", "8000", "bytes", "to", "prevent", "automatic", "cutoff", "by", "the", "PHP", "error_log", "function" ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L641-L659
21,413
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_Manager_Main.debugLogCPU
public function debugLogCPU($message='') { // get resource usage $dat = getrusage(); $message.='[u:'.substr(($dat["ru_utime.tv_sec"]*1e6+$dat["ru_utime.tv_usec"])-$this->startUserCPU,0,-3).'ms / s:'.substr(($dat["ru_stime.tv_sec"]*1e6+$dat["ru_stime.tv_usec"])-$this->startSystemCPU,0,-3).'ms]'; $this->debugLog($message); }
php
public function debugLogCPU($message='') { // get resource usage $dat = getrusage(); $message.='[u:'.substr(($dat["ru_utime.tv_sec"]*1e6+$dat["ru_utime.tv_usec"])-$this->startUserCPU,0,-3).'ms / s:'.substr(($dat["ru_stime.tv_sec"]*1e6+$dat["ru_stime.tv_usec"])-$this->startSystemCPU,0,-3).'ms]'; $this->debugLog($message); }
[ "public", "function", "debugLogCPU", "(", "$", "message", "=", "''", ")", "{", "// get resource usage\r", "$", "dat", "=", "getrusage", "(", ")", ";", "$", "message", ".=", "'[u:'", ".", "substr", "(", "(", "$", "dat", "[", "\"ru_utime.tv_sec\"", "]", "*", "1e6", "+", "$", "dat", "[", "\"ru_utime.tv_usec\"", "]", ")", "-", "$", "this", "->", "startUserCPU", ",", "0", ",", "-", "3", ")", ".", "'ms / s:'", ".", "substr", "(", "(", "$", "dat", "[", "\"ru_stime.tv_sec\"", "]", "*", "1e6", "+", "$", "dat", "[", "\"ru_stime.tv_usec\"", "]", ")", "-", "$", "this", "->", "startSystemCPU", ",", "0", ",", "-", "3", ")", ".", "'ms]'", ";", "$", "this", "->", "debugLog", "(", "$", "message", ")", ";", "}" ]
Debug log the CPU used by the script Please note its only updated every 10ms. output: <user message>[u: <user time>ms / s:<system time>ms] @param string $message [optional message to prepend]
[ "Debug", "log", "the", "CPU", "used", "by", "the", "script" ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L684-L690
21,414
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_Manager_Main.getGlobalStorage
public function getGlobalStorage($name) { if (!$this->GlobalStorageExists($name)) { return false; } return $this->global_data->get($name); }
php
public function getGlobalStorage($name) { if (!$this->GlobalStorageExists($name)) { return false; } return $this->global_data->get($name); }
[ "public", "function", "getGlobalStorage", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "GlobalStorageExists", "(", "$", "name", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "global_data", "->", "get", "(", "$", "name", ")", ";", "}" ]
Retrieve from Global storage @param string $name @return mixed pointer to Plugin or false when not found
[ "Retrieve", "from", "Global", "storage" ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L721-L726
21,415
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_Manager_Main.includeClass
public static function includeClass($classname, $loadscheme='Web2All', $package='', $set_includedir=false) { // $path will be the relative path to the classfile by exploding the namespace $path = ''; $filename = $classname; // support namespaces if(strpos($classname,'\\')){ // ok, contains namespace $path_parts = explode('\\',$classname); $part_count=count($path_parts); $filename = $path_parts[$part_count-1]; $classname_without_namespaces = $filename; for ($i=0;($i<$part_count-1);$i++) { $path.=$path_parts[$i].DIRECTORY_SEPARATOR; } }else{ $classname_without_namespaces = $classname; } if ($loadscheme!='PLAIN') { $path_parts = explode("_",$classname_without_namespaces); $part_count=count($path_parts); $filename = $path_parts[$part_count-1]; for ($i=0;($i<$part_count-1);$i++) { $path.=$path_parts[$i].DIRECTORY_SEPARATOR; } } // depending on the scheme, select the suffix // PEAR class files do not have the .class in the name. // The Web2All scheme historically used ".class.php", but for // better compatibility we now also support the plain ".php". $classfilesuffixes=array('.class.php','.php'); switch($loadscheme){ case 'PEAR': case 'PLAIN': $classfilesuffixes=array('.php'); break; case 'INC': $classfilesuffixes=array('.inc.php'); break; } foreach(self::$frameworkRoots as $include_path){ if ($package) { $include_path.=$package.DIRECTORY_SEPARATOR; } foreach($classfilesuffixes as $classfilesuffix){ if(is_readable($include_path.$path.$filename.$classfilesuffix)){ // if set_includedir is true, then we have the include path of the package to // the PHP environment include path if ($set_includedir) { $pathArray = explode( PATH_SEPARATOR, get_include_path() ); // only add the path if its not already in the include path if (!in_array($include_path,$pathArray)) { $pathArray[]=$include_path; set_include_path(implode(PATH_SEPARATOR,$pathArray)); } } include_once($include_path.$path.$filename.$classfilesuffix); // ok once we found a file, we are done return; } } } }
php
public static function includeClass($classname, $loadscheme='Web2All', $package='', $set_includedir=false) { // $path will be the relative path to the classfile by exploding the namespace $path = ''; $filename = $classname; // support namespaces if(strpos($classname,'\\')){ // ok, contains namespace $path_parts = explode('\\',$classname); $part_count=count($path_parts); $filename = $path_parts[$part_count-1]; $classname_without_namespaces = $filename; for ($i=0;($i<$part_count-1);$i++) { $path.=$path_parts[$i].DIRECTORY_SEPARATOR; } }else{ $classname_without_namespaces = $classname; } if ($loadscheme!='PLAIN') { $path_parts = explode("_",$classname_without_namespaces); $part_count=count($path_parts); $filename = $path_parts[$part_count-1]; for ($i=0;($i<$part_count-1);$i++) { $path.=$path_parts[$i].DIRECTORY_SEPARATOR; } } // depending on the scheme, select the suffix // PEAR class files do not have the .class in the name. // The Web2All scheme historically used ".class.php", but for // better compatibility we now also support the plain ".php". $classfilesuffixes=array('.class.php','.php'); switch($loadscheme){ case 'PEAR': case 'PLAIN': $classfilesuffixes=array('.php'); break; case 'INC': $classfilesuffixes=array('.inc.php'); break; } foreach(self::$frameworkRoots as $include_path){ if ($package) { $include_path.=$package.DIRECTORY_SEPARATOR; } foreach($classfilesuffixes as $classfilesuffix){ if(is_readable($include_path.$path.$filename.$classfilesuffix)){ // if set_includedir is true, then we have the include path of the package to // the PHP environment include path if ($set_includedir) { $pathArray = explode( PATH_SEPARATOR, get_include_path() ); // only add the path if its not already in the include path if (!in_array($include_path,$pathArray)) { $pathArray[]=$include_path; set_include_path(implode(PATH_SEPARATOR,$pathArray)); } } include_once($include_path.$path.$filename.$classfilesuffix); // ok once we found a file, we are done return; } } } }
[ "public", "static", "function", "includeClass", "(", "$", "classname", ",", "$", "loadscheme", "=", "'Web2All'", ",", "$", "package", "=", "''", ",", "$", "set_includedir", "=", "false", ")", "{", "// $path will be the relative path to the classfile by exploding the namespace\r", "$", "path", "=", "''", ";", "$", "filename", "=", "$", "classname", ";", "// support namespaces\r", "if", "(", "strpos", "(", "$", "classname", ",", "'\\\\'", ")", ")", "{", "// ok, contains namespace\r", "$", "path_parts", "=", "explode", "(", "'\\\\'", ",", "$", "classname", ")", ";", "$", "part_count", "=", "count", "(", "$", "path_parts", ")", ";", "$", "filename", "=", "$", "path_parts", "[", "$", "part_count", "-", "1", "]", ";", "$", "classname_without_namespaces", "=", "$", "filename", ";", "for", "(", "$", "i", "=", "0", ";", "(", "$", "i", "<", "$", "part_count", "-", "1", ")", ";", "$", "i", "++", ")", "{", "$", "path", ".=", "$", "path_parts", "[", "$", "i", "]", ".", "DIRECTORY_SEPARATOR", ";", "}", "}", "else", "{", "$", "classname_without_namespaces", "=", "$", "classname", ";", "}", "if", "(", "$", "loadscheme", "!=", "'PLAIN'", ")", "{", "$", "path_parts", "=", "explode", "(", "\"_\"", ",", "$", "classname_without_namespaces", ")", ";", "$", "part_count", "=", "count", "(", "$", "path_parts", ")", ";", "$", "filename", "=", "$", "path_parts", "[", "$", "part_count", "-", "1", "]", ";", "for", "(", "$", "i", "=", "0", ";", "(", "$", "i", "<", "$", "part_count", "-", "1", ")", ";", "$", "i", "++", ")", "{", "$", "path", ".=", "$", "path_parts", "[", "$", "i", "]", ".", "DIRECTORY_SEPARATOR", ";", "}", "}", "// depending on the scheme, select the suffix\r", "// PEAR class files do not have the .class in the name.\r", "// The Web2All scheme historically used \".class.php\", but for \r", "// better compatibility we now also support the plain \".php\".\r", "$", "classfilesuffixes", "=", "array", "(", "'.class.php'", ",", "'.php'", ")", ";", "switch", "(", "$", "loadscheme", ")", "{", "case", "'PEAR'", ":", "case", "'PLAIN'", ":", "$", "classfilesuffixes", "=", "array", "(", "'.php'", ")", ";", "break", ";", "case", "'INC'", ":", "$", "classfilesuffixes", "=", "array", "(", "'.inc.php'", ")", ";", "break", ";", "}", "foreach", "(", "self", "::", "$", "frameworkRoots", "as", "$", "include_path", ")", "{", "if", "(", "$", "package", ")", "{", "$", "include_path", ".=", "$", "package", ".", "DIRECTORY_SEPARATOR", ";", "}", "foreach", "(", "$", "classfilesuffixes", "as", "$", "classfilesuffix", ")", "{", "if", "(", "is_readable", "(", "$", "include_path", ".", "$", "path", ".", "$", "filename", ".", "$", "classfilesuffix", ")", ")", "{", "// if set_includedir is true, then we have the include path of the package to\r", "// the PHP environment include path\r", "if", "(", "$", "set_includedir", ")", "{", "$", "pathArray", "=", "explode", "(", "PATH_SEPARATOR", ",", "get_include_path", "(", ")", ")", ";", "// only add the path if its not already in the include path\r", "if", "(", "!", "in_array", "(", "$", "include_path", ",", "$", "pathArray", ")", ")", "{", "$", "pathArray", "[", "]", "=", "$", "include_path", ";", "set_include_path", "(", "implode", "(", "PATH_SEPARATOR", ",", "$", "pathArray", ")", ")", ";", "}", "}", "include_once", "(", "$", "include_path", ".", "$", "path", ".", "$", "filename", ".", "$", "classfilesuffix", ")", ";", "// ok once we found a file, we are done\r", "return", ";", "}", "}", "}", "}" ]
Load the classfile for the given class This method will blindly include the first php file which it finds for the given classname. It will not throw exceptions and won't indicate if the operation succeeded. It is used by both the autoloader and the loadClass() method, which is historically the method used to load a class. @param string $classname @param string $loadscheme [optional (Web2All|PEAR|INC|PLAIN) defaults to Web2All] @param string $package [optional packagename] @param boolean $set_includedir [optional bool, set true to add the package dir to include path]
[ "Load", "the", "classfile", "for", "the", "given", "class" ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L764-L829
21,416
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_Manager_Main.loadClass
public static function loadClass($classname, $loadscheme='Web2All', $package='', $set_includedir=false) { $class_exists=class_exists($classname) || interface_exists($classname); if ($class_exists && !$set_includedir) { // if class already exists, we don't need to do a thing // but one CAVEAT: if the class was loaded with $set_includedir==false and now the $set_includedir==true // then we do not add the path to the include path. return; } self::includeClass($classname, $loadscheme, $package, $set_includedir); }
php
public static function loadClass($classname, $loadscheme='Web2All', $package='', $set_includedir=false) { $class_exists=class_exists($classname) || interface_exists($classname); if ($class_exists && !$set_includedir) { // if class already exists, we don't need to do a thing // but one CAVEAT: if the class was loaded with $set_includedir==false and now the $set_includedir==true // then we do not add the path to the include path. return; } self::includeClass($classname, $loadscheme, $package, $set_includedir); }
[ "public", "static", "function", "loadClass", "(", "$", "classname", ",", "$", "loadscheme", "=", "'Web2All'", ",", "$", "package", "=", "''", ",", "$", "set_includedir", "=", "false", ")", "{", "$", "class_exists", "=", "class_exists", "(", "$", "classname", ")", "||", "interface_exists", "(", "$", "classname", ")", ";", "if", "(", "$", "class_exists", "&&", "!", "$", "set_includedir", ")", "{", "// if class already exists, we don't need to do a thing\r", "// but one CAVEAT: if the class was loaded with $set_includedir==false and now the $set_includedir==true\r", "// then we do not add the path to the include path. \r", "return", ";", "}", "self", "::", "includeClass", "(", "$", "classname", ",", "$", "loadscheme", ",", "$", "package", ",", "$", "set_includedir", ")", ";", "}" ]
Include php file for Web2All_Manager_Plugin @param string $classname @param string $loadscheme [optional (Web2All|PEAR|INC|PLAIN) defaults to Web2All] @param string $package [optional packagename] @param boolean $set_includedir [optional bool, set true to add the package dir to include path]
[ "Include", "php", "file", "for", "Web2All_Manager_Plugin" ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L839-L849
21,417
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_Manager_Main.initClass
public function initClass($classname,$arguments=array(),$isplugin=true) { // when we no longer have any PHP 5.2 we can replace below with static::loadClass($classname); // we cannot use self::loadClass($classname); because it will break extending Main classes which // redefine the loadClass method. (we need late static binding) /* * If class cannot be found, include corresponding file */ $this->loadClass($classname); /* * If $classname still doesn't exists, the class cannot be started */ if (!class_exists($classname)) { throw new Exception("Class whith name '$classname' does not exists. Cannot initialise $classname",E_USER_ERROR); } /* * Start class and return object */ $reflectionObj = new ReflectionClass($classname); if($reflectionObj->isSubclassOf('Web2All_Manager_Plugin') || $isplugin){ // directly extends Web2All_Manager_Plugin so it expects the Web2All_Manager_Main object // as first constructor param. Or the $isplugin is set true so force first param to // Web2All_Manager_Main object. array_unshift($arguments,$this); }elseif($reflectionObj->implementsInterface('Web2All_Manager_PluginInterface')){ // class does not extend Web2All_Manager_Plugin, but the class still implements // the Web2All_Manager_PluginInterface so we can call the setWeb2All method to // init the object after construction. $obj=call_user_func_array(array(&$reflectionObj, 'newInstance'), $arguments); $obj->setWeb2All($this); return $obj; } return call_user_func_array(array(&$reflectionObj, 'newInstance'), $arguments); }
php
public function initClass($classname,$arguments=array(),$isplugin=true) { // when we no longer have any PHP 5.2 we can replace below with static::loadClass($classname); // we cannot use self::loadClass($classname); because it will break extending Main classes which // redefine the loadClass method. (we need late static binding) /* * If class cannot be found, include corresponding file */ $this->loadClass($classname); /* * If $classname still doesn't exists, the class cannot be started */ if (!class_exists($classname)) { throw new Exception("Class whith name '$classname' does not exists. Cannot initialise $classname",E_USER_ERROR); } /* * Start class and return object */ $reflectionObj = new ReflectionClass($classname); if($reflectionObj->isSubclassOf('Web2All_Manager_Plugin') || $isplugin){ // directly extends Web2All_Manager_Plugin so it expects the Web2All_Manager_Main object // as first constructor param. Or the $isplugin is set true so force first param to // Web2All_Manager_Main object. array_unshift($arguments,$this); }elseif($reflectionObj->implementsInterface('Web2All_Manager_PluginInterface')){ // class does not extend Web2All_Manager_Plugin, but the class still implements // the Web2All_Manager_PluginInterface so we can call the setWeb2All method to // init the object after construction. $obj=call_user_func_array(array(&$reflectionObj, 'newInstance'), $arguments); $obj->setWeb2All($this); return $obj; } return call_user_func_array(array(&$reflectionObj, 'newInstance'), $arguments); }
[ "public", "function", "initClass", "(", "$", "classname", ",", "$", "arguments", "=", "array", "(", ")", ",", "$", "isplugin", "=", "true", ")", "{", "// when we no longer have any PHP 5.2 we can replace below with static::loadClass($classname);\r", "// we cannot use self::loadClass($classname); because it will break extending Main classes which\r", "// redefine the loadClass method. (we need late static binding)\r", "/*\r\n * If class cannot be found, include corresponding file\r\n */", "$", "this", "->", "loadClass", "(", "$", "classname", ")", ";", "/*\r\n * If $classname still doesn't exists, the class cannot be started\r\n */", "if", "(", "!", "class_exists", "(", "$", "classname", ")", ")", "{", "throw", "new", "Exception", "(", "\"Class whith name '$classname' does not exists. Cannot initialise $classname\"", ",", "E_USER_ERROR", ")", ";", "}", "/*\r\n * Start class and return object\r\n */", "$", "reflectionObj", "=", "new", "ReflectionClass", "(", "$", "classname", ")", ";", "if", "(", "$", "reflectionObj", "->", "isSubclassOf", "(", "'Web2All_Manager_Plugin'", ")", "||", "$", "isplugin", ")", "{", "// directly extends Web2All_Manager_Plugin so it expects the Web2All_Manager_Main object\r", "// as first constructor param. Or the $isplugin is set true so force first param to\r", "// Web2All_Manager_Main object.\r", "array_unshift", "(", "$", "arguments", ",", "$", "this", ")", ";", "}", "elseif", "(", "$", "reflectionObj", "->", "implementsInterface", "(", "'Web2All_Manager_PluginInterface'", ")", ")", "{", "// class does not extend Web2All_Manager_Plugin, but the class still implements \r", "// the Web2All_Manager_PluginInterface so we can call the setWeb2All method to \r", "// init the object after construction.\r", "$", "obj", "=", "call_user_func_array", "(", "array", "(", "&", "$", "reflectionObj", ",", "'newInstance'", ")", ",", "$", "arguments", ")", ";", "$", "obj", "->", "setWeb2All", "(", "$", "this", ")", ";", "return", "$", "obj", ";", "}", "return", "call_user_func_array", "(", "array", "(", "&", "$", "reflectionObj", ",", "'newInstance'", ")", ",", "$", "arguments", ")", ";", "}" ]
Initialize Web2All_Manager_Plugin returns Web2All_Manager_Plugin object @param string $classname @param array $arguments @param boolean $isplugin Force the first constructor param to be the Web2All_Manager_Main object. Set false for automatically detection if this is required. @return object
[ "Initialize", "Web2All_Manager_Plugin", "returns", "Web2All_Manager_Plugin", "object" ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L862-L897
21,418
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_Manager_Main.registerIncludeRoot
public static function registerIncludeRoot($root=null) { if(is_null($root)){ $root = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; } if(!in_array($root, self::$frameworkRoots)){ self::$frameworkRoots[] = $root; return true; } return false; }
php
public static function registerIncludeRoot($root=null) { if(is_null($root)){ $root = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; } if(!in_array($root, self::$frameworkRoots)){ self::$frameworkRoots[] = $root; return true; } return false; }
[ "public", "static", "function", "registerIncludeRoot", "(", "$", "root", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "root", ")", ")", "{", "$", "root", "=", "dirname", "(", "__FILE__", ")", ".", "DIRECTORY_SEPARATOR", ".", "'..'", ".", "DIRECTORY_SEPARATOR", ".", "'..'", ".", "DIRECTORY_SEPARATOR", ";", "}", "if", "(", "!", "in_array", "(", "$", "root", ",", "self", "::", "$", "frameworkRoots", ")", ")", "{", "self", "::", "$", "frameworkRoots", "[", "]", "=", "$", "root", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Registers an include root directory Used by autoloader and loadClass() @param string $root directory path @return boolean was the directory added
[ "Registers", "an", "include", "root", "directory" ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L1005-L1015
21,419
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_Manager_Main.unregisterIncludeRoot
public static function unregisterIncludeRoot($root) { $found_key=array_search($root, self::$frameworkRoots, true); if($found_key!==false){ unset(self::$frameworkRoots[$found_key]); return true; } return false; }
php
public static function unregisterIncludeRoot($root) { $found_key=array_search($root, self::$frameworkRoots, true); if($found_key!==false){ unset(self::$frameworkRoots[$found_key]); return true; } return false; }
[ "public", "static", "function", "unregisterIncludeRoot", "(", "$", "root", ")", "{", "$", "found_key", "=", "array_search", "(", "$", "root", ",", "self", "::", "$", "frameworkRoots", ",", "true", ")", ";", "if", "(", "$", "found_key", "!==", "false", ")", "{", "unset", "(", "self", "::", "$", "frameworkRoots", "[", "$", "found_key", "]", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Unregisters an include root directory @param string $root directory path @return boolean was the directory removed
[ "Unregisters", "an", "include", "root", "directory" ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L1023-L1031
21,420
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_Manager_Main.registerAutoloader
public static function registerAutoloader($root=null) { self::registerIncludeRoot($root); if(!self::$autoloaderAdded){ self::$autoloaderAdded = true; return spl_autoload_register(array('Web2All_Manager_Main','loadClass')); } return true; }
php
public static function registerAutoloader($root=null) { self::registerIncludeRoot($root); if(!self::$autoloaderAdded){ self::$autoloaderAdded = true; return spl_autoload_register(array('Web2All_Manager_Main','loadClass')); } return true; }
[ "public", "static", "function", "registerAutoloader", "(", "$", "root", "=", "null", ")", "{", "self", "::", "registerIncludeRoot", "(", "$", "root", ")", ";", "if", "(", "!", "self", "::", "$", "autoloaderAdded", ")", "{", "self", "::", "$", "autoloaderAdded", "=", "true", ";", "return", "spl_autoload_register", "(", "array", "(", "'Web2All_Manager_Main'", ",", "'loadClass'", ")", ")", ";", "}", "return", "true", ";", "}" ]
Registers an autoloader for the Web2All framework it will call the Web2All_Manager_Main::loadClass @return boolean
[ "Registers", "an", "autoloader", "for", "the", "Web2All", "framework" ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L1050-L1058
21,421
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_Manager_ErrorObserverable.notifyObservers
public function notifyObservers() { /** * restore original error handler, to avoid problems when errors occurres * in handling other errors */ $this->Web2All->restoreErrorHandlers(); foreach($this->observers as $observer) { $observer->update($this); } foreach($this->observer_names as $classname) { $this->Web2All->PluginGlobal->$classname->update($this); } // set custom error handlers back $this->Web2All->setErrorHandlers(); }
php
public function notifyObservers() { /** * restore original error handler, to avoid problems when errors occurres * in handling other errors */ $this->Web2All->restoreErrorHandlers(); foreach($this->observers as $observer) { $observer->update($this); } foreach($this->observer_names as $classname) { $this->Web2All->PluginGlobal->$classname->update($this); } // set custom error handlers back $this->Web2All->setErrorHandlers(); }
[ "public", "function", "notifyObservers", "(", ")", "{", "/**\r\n * restore original error handler, to avoid problems when errors occurres\r\n * in handling other errors\r\n */", "$", "this", "->", "Web2All", "->", "restoreErrorHandlers", "(", ")", ";", "foreach", "(", "$", "this", "->", "observers", "as", "$", "observer", ")", "{", "$", "observer", "->", "update", "(", "$", "this", ")", ";", "}", "foreach", "(", "$", "this", "->", "observer_names", "as", "$", "classname", ")", "{", "$", "this", "->", "Web2All", "->", "PluginGlobal", "->", "$", "classname", "->", "update", "(", "$", "this", ")", ";", "}", "// set custom error handlers back\r", "$", "this", "->", "Web2All", "->", "setErrorHandlers", "(", ")", ";", "}" ]
If this object has changed, as indicated by the hasChanged method, then start observers as needed and notify them, and then call the clearChanged method to indicate that this object has no longer changed.
[ "If", "this", "object", "has", "changed", "as", "indicated", "by", "the", "hasChanged", "method", "then", "start", "observers", "as", "needed", "and", "notify", "them", "and", "then", "call", "the", "clearChanged", "method", "to", "indicate", "that", "this", "object", "has", "no", "longer", "changed", "." ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L1173-L1187
21,422
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_Manager_ErrorObserverable.flushEmailErrors
public function flushEmailErrors() { foreach($this->observers as $observer) { if(get_class($observer)=='Web2All_ErrorObserver_Email'){ $observer->flushErrors(); } } foreach($this->observer_names as $classname) { if($classname=='Web2All_ErrorObserver_Email'){ $this->Web2All->PluginGlobal->$classname->flushErrors(); } } }
php
public function flushEmailErrors() { foreach($this->observers as $observer) { if(get_class($observer)=='Web2All_ErrorObserver_Email'){ $observer->flushErrors(); } } foreach($this->observer_names as $classname) { if($classname=='Web2All_ErrorObserver_Email'){ $this->Web2All->PluginGlobal->$classname->flushErrors(); } } }
[ "public", "function", "flushEmailErrors", "(", ")", "{", "foreach", "(", "$", "this", "->", "observers", "as", "$", "observer", ")", "{", "if", "(", "get_class", "(", "$", "observer", ")", "==", "'Web2All_ErrorObserver_Email'", ")", "{", "$", "observer", "->", "flushErrors", "(", ")", ";", "}", "}", "foreach", "(", "$", "this", "->", "observer_names", "as", "$", "classname", ")", "{", "if", "(", "$", "classname", "==", "'Web2All_ErrorObserver_Email'", ")", "{", "$", "this", "->", "Web2All", "->", "PluginGlobal", "->", "$", "classname", "->", "flushErrors", "(", ")", ";", "}", "}", "}" ]
flush e-mail errors if any If there are any errors queued for emailing they will be e-mailed and the errorstate will be reset. This is useful for long running processes like daemons.
[ "flush", "e", "-", "mail", "errors", "if", "any" ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L1195-L1206
21,423
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_Manager_ClassInclude.loadClassname
public static function loadClassname($classname,$loadscheme='Web2All', $package='', $set_includedir=false) { Web2All_Manager_Main::loadClass($classname,$loadscheme,$package,$set_includedir); }
php
public static function loadClassname($classname,$loadscheme='Web2All', $package='', $set_includedir=false) { Web2All_Manager_Main::loadClass($classname,$loadscheme,$package,$set_includedir); }
[ "public", "static", "function", "loadClassname", "(", "$", "classname", ",", "$", "loadscheme", "=", "'Web2All'", ",", "$", "package", "=", "''", ",", "$", "set_includedir", "=", "false", ")", "{", "Web2All_Manager_Main", "::", "loadClass", "(", "$", "classname", ",", "$", "loadscheme", ",", "$", "package", ",", "$", "set_includedir", ")", ";", "}" ]
Include php file @param string $classname @param string $loadscheme [optional (Web2All|PEAR|INC|PLAIN) defaults to Web2All] @param string $package [optional packagename] @param boolean $set_includedir [optional bool, set true to add the package dir to include path]
[ "Include", "php", "file" ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L2035-L2037
21,424
web2all/framework
src/Web2All/Manager/Main.class.php
Web2All_PHP_INI.getBytes
public static function getBytes($size_str) { switch (substr ($size_str, -1)) { case 'M': case 'm': return (int)$size_str * 1048576; case 'K': case 'k': return (int)$size_str * 1024; case 'G': case 'g': return (int)$size_str * 1073741824; default: return $size_str; } }
php
public static function getBytes($size_str) { switch (substr ($size_str, -1)) { case 'M': case 'm': return (int)$size_str * 1048576; case 'K': case 'k': return (int)$size_str * 1024; case 'G': case 'g': return (int)$size_str * 1073741824; default: return $size_str; } }
[ "public", "static", "function", "getBytes", "(", "$", "size_str", ")", "{", "switch", "(", "substr", "(", "$", "size_str", ",", "-", "1", ")", ")", "{", "case", "'M'", ":", "case", "'m'", ":", "return", "(", "int", ")", "$", "size_str", "*", "1048576", ";", "case", "'K'", ":", "case", "'k'", ":", "return", "(", "int", ")", "$", "size_str", "*", "1024", ";", "case", "'G'", ":", "case", "'g'", ":", "return", "(", "int", ")", "$", "size_str", "*", "1073741824", ";", "default", ":", "return", "$", "size_str", ";", "}", "}" ]
converts possible shorthand notations from the php ini to bytes. see: http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes original code from: http://nl2.php.net/manual/en/function.ini-get.php#96996 @return int
[ "converts", "possible", "shorthand", "notations", "from", "the", "php", "ini", "to", "bytes", "." ]
6990dc3700efad3207ec6e710124f7ba18891b31
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Manager/Main.class.php#L2106-L2115
21,425
flowcode/AmulenUserBundle
src/Flowcode/UserBundle/Service/UserNotificationService.php
UserNotificationService.notifyPasswordReset
public function notifyPasswordReset(User $user, $plainPassword) { $fromEmail = $this->container->getParameter("default_mail_from"); $fromName = $this->container->getParameter("default_mail_from_name"); $appName = $this->container->getParameter("default_app_name"); $subject = "[$appName] Cambio de datos"; $toEmail = $user->getEmail(); $toName = $user->getFirstname(); $body = $this->container->get('templating')->render('FlowcodeUserBundle:Email:notifyPasswordReset.html.twig', array('user' => $user, 'plainPassword' => $plainPassword)); $this->mailSender->send($toEmail, $toName, $fromEmail, $fromName, $subject, $body, true); }
php
public function notifyPasswordReset(User $user, $plainPassword) { $fromEmail = $this->container->getParameter("default_mail_from"); $fromName = $this->container->getParameter("default_mail_from_name"); $appName = $this->container->getParameter("default_app_name"); $subject = "[$appName] Cambio de datos"; $toEmail = $user->getEmail(); $toName = $user->getFirstname(); $body = $this->container->get('templating')->render('FlowcodeUserBundle:Email:notifyPasswordReset.html.twig', array('user' => $user, 'plainPassword' => $plainPassword)); $this->mailSender->send($toEmail, $toName, $fromEmail, $fromName, $subject, $body, true); }
[ "public", "function", "notifyPasswordReset", "(", "User", "$", "user", ",", "$", "plainPassword", ")", "{", "$", "fromEmail", "=", "$", "this", "->", "container", "->", "getParameter", "(", "\"default_mail_from\"", ")", ";", "$", "fromName", "=", "$", "this", "->", "container", "->", "getParameter", "(", "\"default_mail_from_name\"", ")", ";", "$", "appName", "=", "$", "this", "->", "container", "->", "getParameter", "(", "\"default_app_name\"", ")", ";", "$", "subject", "=", "\"[$appName] Cambio de datos\"", ";", "$", "toEmail", "=", "$", "user", "->", "getEmail", "(", ")", ";", "$", "toName", "=", "$", "user", "->", "getFirstname", "(", ")", ";", "$", "body", "=", "$", "this", "->", "container", "->", "get", "(", "'templating'", ")", "->", "render", "(", "'FlowcodeUserBundle:Email:notifyPasswordReset.html.twig'", ",", "array", "(", "'user'", "=>", "$", "user", ",", "'plainPassword'", "=>", "$", "plainPassword", ")", ")", ";", "$", "this", "->", "mailSender", "->", "send", "(", "$", "toEmail", ",", "$", "toName", ",", "$", "fromEmail", ",", "$", "fromName", ",", "$", "subject", ",", "$", "body", ",", "true", ")", ";", "}" ]
Notify Password reset. @param User $user [description] @param [type] $plainPassword [description]
[ "Notify", "Password", "reset", "." ]
00055834d9f094e63dcd8d66e2fedb822fcddee0
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Service/UserNotificationService.php#L43-L54
21,426
stk2k/net-driver
src/NetDriver/AbstractNetDriver.php
AbstractNetDriver.fireOnSendingRequest
public function fireOnSendingRequest(HttpRequest $request) { $event = EnumEvent::REQUEST; if (isset($this->listeners[$event]) && is_array($this->listeners[$event])) { foreach($this->listeners[$event] as $l) { $ret = $l($request); if ($ret instanceof HttpRequest){ $request = $ret; } } } return $request; }
php
public function fireOnSendingRequest(HttpRequest $request) { $event = EnumEvent::REQUEST; if (isset($this->listeners[$event]) && is_array($this->listeners[$event])) { foreach($this->listeners[$event] as $l) { $ret = $l($request); if ($ret instanceof HttpRequest){ $request = $ret; } } } return $request; }
[ "public", "function", "fireOnSendingRequest", "(", "HttpRequest", "$", "request", ")", "{", "$", "event", "=", "EnumEvent", "::", "REQUEST", ";", "if", "(", "isset", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", ")", "&&", "is_array", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", "as", "$", "l", ")", "{", "$", "ret", "=", "$", "l", "(", "$", "request", ")", ";", "if", "(", "$", "ret", "instanceof", "HttpRequest", ")", "{", "$", "request", "=", "$", "ret", ";", "}", "}", "}", "return", "$", "request", ";", "}" ]
Fire event before sending HTTP request @param HttpRequest $request @return HttpRequest
[ "Fire", "event", "before", "sending", "HTTP", "request" ]
75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c
https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/NetDriver/AbstractNetDriver.php#L120-L134
21,427
stk2k/net-driver
src/NetDriver/AbstractNetDriver.php
AbstractNetDriver.fireOnReceivedVerbose
public function fireOnReceivedVerbose($strerr, $header, $output) { $event = EnumEvent::VERBOSE; if (isset($this->listeners[$event]) && is_array($this->listeners[$event])) { foreach($this->listeners[$event] as $l) { $l($strerr, $header, $output); } } }
php
public function fireOnReceivedVerbose($strerr, $header, $output) { $event = EnumEvent::VERBOSE; if (isset($this->listeners[$event]) && is_array($this->listeners[$event])) { foreach($this->listeners[$event] as $l) { $l($strerr, $header, $output); } } }
[ "public", "function", "fireOnReceivedVerbose", "(", "$", "strerr", ",", "$", "header", ",", "$", "output", ")", "{", "$", "event", "=", "EnumEvent", "::", "VERBOSE", ";", "if", "(", "isset", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", ")", "&&", "is_array", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", "as", "$", "l", ")", "{", "$", "l", "(", "$", "strerr", ",", "$", "header", ",", "$", "output", ")", ";", "}", "}", "}" ]
Fire event after received verbose @param string $strerr @param string $header @param string $output
[ "Fire", "event", "after", "received", "verbose" ]
75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c
https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/NetDriver/AbstractNetDriver.php#L143-L153
21,428
stk2k/net-driver
src/NetDriver/AbstractNetDriver.php
AbstractNetDriver.fireOnReceivedResponse
public function fireOnReceivedResponse(HttpResponse $response) { $event = EnumEvent::RESPONSE; if (isset($this->listeners[$event]) && is_array($this->listeners[$event])) { foreach($this->listeners[$event] as $l) { $l($response); } } }
php
public function fireOnReceivedResponse(HttpResponse $response) { $event = EnumEvent::RESPONSE; if (isset($this->listeners[$event]) && is_array($this->listeners[$event])) { foreach($this->listeners[$event] as $l) { $l($response); } } }
[ "public", "function", "fireOnReceivedResponse", "(", "HttpResponse", "$", "response", ")", "{", "$", "event", "=", "EnumEvent", "::", "RESPONSE", ";", "if", "(", "isset", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", ")", "&&", "is_array", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", "as", "$", "l", ")", "{", "$", "l", "(", "$", "response", ")", ";", "}", "}", "}" ]
Fire event after received HTTP response @param HttpResponse $response
[ "Fire", "event", "after", "received", "HTTP", "response" ]
75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c
https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/NetDriver/AbstractNetDriver.php#L160-L170
21,429
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.filterByCustomerCustomerGroup
public function filterByCustomerCustomerGroup($customerCustomerGroup, $comparison = null) { if ($customerCustomerGroup instanceof \CustomerGroup\Model\CustomerCustomerGroup) { return $this ->addUsingAlias(CustomerGroupTableMap::ID, $customerCustomerGroup->getCustomerGroupId(), $comparison); } elseif ($customerCustomerGroup instanceof ObjectCollection) { return $this ->useCustomerCustomerGroupQuery() ->filterByPrimaryKeys($customerCustomerGroup->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByCustomerCustomerGroup() only accepts arguments of type \CustomerGroup\Model\CustomerCustomerGroup or Collection'); } }
php
public function filterByCustomerCustomerGroup($customerCustomerGroup, $comparison = null) { if ($customerCustomerGroup instanceof \CustomerGroup\Model\CustomerCustomerGroup) { return $this ->addUsingAlias(CustomerGroupTableMap::ID, $customerCustomerGroup->getCustomerGroupId(), $comparison); } elseif ($customerCustomerGroup instanceof ObjectCollection) { return $this ->useCustomerCustomerGroupQuery() ->filterByPrimaryKeys($customerCustomerGroup->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByCustomerCustomerGroup() only accepts arguments of type \CustomerGroup\Model\CustomerCustomerGroup or Collection'); } }
[ "public", "function", "filterByCustomerCustomerGroup", "(", "$", "customerCustomerGroup", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "customerCustomerGroup", "instanceof", "\\", "CustomerGroup", "\\", "Model", "\\", "CustomerCustomerGroup", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "CustomerGroupTableMap", "::", "ID", ",", "$", "customerCustomerGroup", "->", "getCustomerGroupId", "(", ")", ",", "$", "comparison", ")", ";", "}", "elseif", "(", "$", "customerCustomerGroup", "instanceof", "ObjectCollection", ")", "{", "return", "$", "this", "->", "useCustomerCustomerGroupQuery", "(", ")", "->", "filterByPrimaryKeys", "(", "$", "customerCustomerGroup", "->", "getPrimaryKeys", "(", ")", ")", "->", "endUse", "(", ")", ";", "}", "else", "{", "throw", "new", "PropelException", "(", "'filterByCustomerCustomerGroup() only accepts arguments of type \\CustomerGroup\\Model\\CustomerCustomerGroup or Collection'", ")", ";", "}", "}" ]
Filter the query by a related \CustomerGroup\Model\CustomerCustomerGroup object @param \CustomerGroup\Model\CustomerCustomerGroup|ObjectCollection $customerCustomerGroup the related object to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildCustomerGroupQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "\\", "CustomerGroup", "\\", "Model", "\\", "CustomerCustomerGroup", "object" ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L476-L489
21,430
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.useCustomerCustomerGroupQuery
public function useCustomerCustomerGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinCustomerCustomerGroup($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'CustomerCustomerGroup', '\CustomerGroup\Model\CustomerCustomerGroupQuery'); }
php
public function useCustomerCustomerGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinCustomerCustomerGroup($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'CustomerCustomerGroup', '\CustomerGroup\Model\CustomerCustomerGroupQuery'); }
[ "public", "function", "useCustomerCustomerGroupQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinCustomerCustomerGroup", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'CustomerCustomerGroup'", ",", "'\\CustomerGroup\\Model\\CustomerCustomerGroupQuery'", ")", ";", "}" ]
Use the CustomerCustomerGroup relation CustomerCustomerGroup object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \CustomerGroup\Model\CustomerCustomerGroupQuery A secondary query class using the current class as primary query
[ "Use", "the", "CustomerCustomerGroup", "relation", "CustomerCustomerGroup", "object" ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L534-L539
21,431
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.filterByCustomerGroupI18n
public function filterByCustomerGroupI18n($customerGroupI18n, $comparison = null) { if ($customerGroupI18n instanceof \CustomerGroup\Model\CustomerGroupI18n) { return $this ->addUsingAlias(CustomerGroupTableMap::ID, $customerGroupI18n->getId(), $comparison); } elseif ($customerGroupI18n instanceof ObjectCollection) { return $this ->useCustomerGroupI18nQuery() ->filterByPrimaryKeys($customerGroupI18n->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByCustomerGroupI18n() only accepts arguments of type \CustomerGroup\Model\CustomerGroupI18n or Collection'); } }
php
public function filterByCustomerGroupI18n($customerGroupI18n, $comparison = null) { if ($customerGroupI18n instanceof \CustomerGroup\Model\CustomerGroupI18n) { return $this ->addUsingAlias(CustomerGroupTableMap::ID, $customerGroupI18n->getId(), $comparison); } elseif ($customerGroupI18n instanceof ObjectCollection) { return $this ->useCustomerGroupI18nQuery() ->filterByPrimaryKeys($customerGroupI18n->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByCustomerGroupI18n() only accepts arguments of type \CustomerGroup\Model\CustomerGroupI18n or Collection'); } }
[ "public", "function", "filterByCustomerGroupI18n", "(", "$", "customerGroupI18n", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "customerGroupI18n", "instanceof", "\\", "CustomerGroup", "\\", "Model", "\\", "CustomerGroupI18n", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "CustomerGroupTableMap", "::", "ID", ",", "$", "customerGroupI18n", "->", "getId", "(", ")", ",", "$", "comparison", ")", ";", "}", "elseif", "(", "$", "customerGroupI18n", "instanceof", "ObjectCollection", ")", "{", "return", "$", "this", "->", "useCustomerGroupI18nQuery", "(", ")", "->", "filterByPrimaryKeys", "(", "$", "customerGroupI18n", "->", "getPrimaryKeys", "(", ")", ")", "->", "endUse", "(", ")", ";", "}", "else", "{", "throw", "new", "PropelException", "(", "'filterByCustomerGroupI18n() only accepts arguments of type \\CustomerGroup\\Model\\CustomerGroupI18n or Collection'", ")", ";", "}", "}" ]
Filter the query by a related \CustomerGroup\Model\CustomerGroupI18n object @param \CustomerGroup\Model\CustomerGroupI18n|ObjectCollection $customerGroupI18n the related object to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildCustomerGroupQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "\\", "CustomerGroup", "\\", "Model", "\\", "CustomerGroupI18n", "object" ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L549-L562
21,432
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.useCustomerGroupI18nQuery
public function useCustomerGroupI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') { return $this ->joinCustomerGroupI18n($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'CustomerGroupI18n', '\CustomerGroup\Model\CustomerGroupI18nQuery'); }
php
public function useCustomerGroupI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') { return $this ->joinCustomerGroupI18n($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'CustomerGroupI18n', '\CustomerGroup\Model\CustomerGroupI18nQuery'); }
[ "public", "function", "useCustomerGroupI18nQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "'LEFT JOIN'", ")", "{", "return", "$", "this", "->", "joinCustomerGroupI18n", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'CustomerGroupI18n'", ",", "'\\CustomerGroup\\Model\\CustomerGroupI18nQuery'", ")", ";", "}" ]
Use the CustomerGroupI18n relation CustomerGroupI18n object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \CustomerGroup\Model\CustomerGroupI18nQuery A secondary query class using the current class as primary query
[ "Use", "the", "CustomerGroupI18n", "relation", "CustomerGroupI18n", "object" ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L607-L612
21,433
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.filterByCustomer
public function filterByCustomer($customer, $comparison = Criteria::EQUAL) { return $this ->useCustomerCustomerGroupQuery() ->filterByCustomer($customer, $comparison) ->endUse(); }
php
public function filterByCustomer($customer, $comparison = Criteria::EQUAL) { return $this ->useCustomerCustomerGroupQuery() ->filterByCustomer($customer, $comparison) ->endUse(); }
[ "public", "function", "filterByCustomer", "(", "$", "customer", ",", "$", "comparison", "=", "Criteria", "::", "EQUAL", ")", "{", "return", "$", "this", "->", "useCustomerCustomerGroupQuery", "(", ")", "->", "filterByCustomer", "(", "$", "customer", ",", "$", "comparison", ")", "->", "endUse", "(", ")", ";", "}" ]
Filter the query by a related Customer object using the customer_customer_group table as cross reference @param Customer $customer the related object to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildCustomerGroupQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "Customer", "object", "using", "the", "customer_customer_group", "table", "as", "cross", "reference" ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L623-L629
21,434
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.getMaxRank
public function getMaxRank(ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getReadConnection(CustomerGroupTableMap::DATABASE_NAME); } // shift the objects with a position lower than the one of object $this->addSelectColumn('MAX(' . CustomerGroupTableMap::RANK_COL . ')'); $stmt = $this->doSelect($con); return $stmt->fetchColumn(); }
php
public function getMaxRank(ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getReadConnection(CustomerGroupTableMap::DATABASE_NAME); } // shift the objects with a position lower than the one of object $this->addSelectColumn('MAX(' . CustomerGroupTableMap::RANK_COL . ')'); $stmt = $this->doSelect($con); return $stmt->fetchColumn(); }
[ "public", "function", "getMaxRank", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getReadConnection", "(", "CustomerGroupTableMap", "::", "DATABASE_NAME", ")", ";", "}", "// shift the objects with a position lower than the one of object", "$", "this", "->", "addSelectColumn", "(", "'MAX('", ".", "CustomerGroupTableMap", "::", "RANK_COL", ".", "')'", ")", ";", "$", "stmt", "=", "$", "this", "->", "doSelect", "(", "$", "con", ")", ";", "return", "$", "stmt", "->", "fetchColumn", "(", ")", ";", "}" ]
Get the highest rank @param ConnectionInterface optional connection @return integer highest position
[ "Get", "the", "highest", "rank" ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L922-L932
21,435
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.getMaxRankArray
public function getMaxRankArray(ConnectionInterface $con = null) { if ($con === null) { $con = Propel::getConnection(CustomerGroupTableMap::DATABASE_NAME); } // shift the objects with a position lower than the one of object $this->addSelectColumn('MAX(' . CustomerGroupTableMap::RANK_COL . ')'); $stmt = $this->doSelect($con); return $stmt->fetchColumn(); }
php
public function getMaxRankArray(ConnectionInterface $con = null) { if ($con === null) { $con = Propel::getConnection(CustomerGroupTableMap::DATABASE_NAME); } // shift the objects with a position lower than the one of object $this->addSelectColumn('MAX(' . CustomerGroupTableMap::RANK_COL . ')'); $stmt = $this->doSelect($con); return $stmt->fetchColumn(); }
[ "public", "function", "getMaxRankArray", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "$", "con", "===", "null", ")", "{", "$", "con", "=", "Propel", "::", "getConnection", "(", "CustomerGroupTableMap", "::", "DATABASE_NAME", ")", ";", "}", "// shift the objects with a position lower than the one of object", "$", "this", "->", "addSelectColumn", "(", "'MAX('", ".", "CustomerGroupTableMap", "::", "RANK_COL", ".", "')'", ")", ";", "$", "stmt", "=", "$", "this", "->", "doSelect", "(", "$", "con", ")", ";", "return", "$", "stmt", "->", "fetchColumn", "(", ")", ";", "}" ]
Get the highest rank by a scope with a array format. @param ConnectionInterface optional connection @return integer highest position
[ "Get", "the", "highest", "rank", "by", "a", "scope", "with", "a", "array", "format", "." ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L941-L951
21,436
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.doSelectOrderByRank
static public function doSelectOrderByRank(Criteria $criteria = null, $order = Criteria::ASC, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getReadConnection(CustomerGroupTableMap::DATABASE_NAME); } if (null === $criteria) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->clearOrderByColumns(); if (Criteria::ASC == $order) { $criteria->addAscendingOrderByColumn(CustomerGroupTableMap::RANK_COL); } else { $criteria->addDescendingOrderByColumn(CustomerGroupTableMap::RANK_COL); } return ChildCustomerGroupQuery::create(null, $criteria)->find($con); }
php
static public function doSelectOrderByRank(Criteria $criteria = null, $order = Criteria::ASC, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getReadConnection(CustomerGroupTableMap::DATABASE_NAME); } if (null === $criteria) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->clearOrderByColumns(); if (Criteria::ASC == $order) { $criteria->addAscendingOrderByColumn(CustomerGroupTableMap::RANK_COL); } else { $criteria->addDescendingOrderByColumn(CustomerGroupTableMap::RANK_COL); } return ChildCustomerGroupQuery::create(null, $criteria)->find($con); }
[ "static", "public", "function", "doSelectOrderByRank", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "order", "=", "Criteria", "::", "ASC", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getReadConnection", "(", "CustomerGroupTableMap", "::", "DATABASE_NAME", ")", ";", "}", "if", "(", "null", "===", "$", "criteria", ")", "{", "$", "criteria", "=", "new", "Criteria", "(", ")", ";", "}", "elseif", "(", "$", "criteria", "instanceof", "Criteria", ")", "{", "$", "criteria", "=", "clone", "$", "criteria", ";", "}", "$", "criteria", "->", "clearOrderByColumns", "(", ")", ";", "if", "(", "Criteria", "::", "ASC", "==", "$", "order", ")", "{", "$", "criteria", "->", "addAscendingOrderByColumn", "(", "CustomerGroupTableMap", "::", "RANK_COL", ")", ";", "}", "else", "{", "$", "criteria", "->", "addDescendingOrderByColumn", "(", "CustomerGroupTableMap", "::", "RANK_COL", ")", ";", "}", "return", "ChildCustomerGroupQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", "->", "find", "(", "$", "con", ")", ";", "}" ]
Return an array of sortable objects ordered by position @param Criteria $criteria optional criteria object @param string $order sorting order, to be chosen between Criteria::ASC (default) and Criteria::DESC @param ConnectionInterface $con optional connection @return array list of sortable objects
[ "Return", "an", "array", "of", "sortable", "objects", "ordered", "by", "position" ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L1018-L1039
21,437
flowcode/AmulenUserBundle
src/Flowcode/UserBundle/Controller/UserGroupController.php
UserGroupController.createEditForm
private function createEditForm(UserGroup $entity) { $form = $this->createForm(new UserGroupType(), $entity, array( 'action' => $this->generateUrl('admin_usergroup_update', array('id' => $entity->getId())), 'method' => 'PUT', )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
php
private function createEditForm(UserGroup $entity) { $form = $this->createForm(new UserGroupType(), $entity, array( 'action' => $this->generateUrl('admin_usergroup_update', array('id' => $entity->getId())), 'method' => 'PUT', )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
[ "private", "function", "createEditForm", "(", "UserGroup", "$", "entity", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "UserGroupType", "(", ")", ",", "$", "entity", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_usergroup_update'", ",", "array", "(", "'id'", "=>", "$", "entity", "->", "getId", "(", ")", ")", ")", ",", "'method'", "=>", "'PUT'", ",", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Update'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to edit a UserGroup entity. @param UserGroup $entity The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "edit", "a", "UserGroup", "entity", "." ]
00055834d9f094e63dcd8d66e2fedb822fcddee0
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Controller/UserGroupController.php#L141-L150
21,438
flowcode/AmulenUserBundle
src/Flowcode/UserBundle/Controller/UserGroupController.php
UserGroupController.deleteAction
public function deleteAction(Request $request, $id) { $form = $this->createDeleteForm($id); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $userGroup = $em->getRepository('AmulenUserBundle:UserGroup')->find($id); if (!$userGroup) { throw $this->createNotFoundException('Unable to find UserGroup entity.'); } $var = $em->getRepository('AmulenUserBundle:User')->findByGroup($userGroup); echo $var; die("123"); $users = $this->getUsersByUserGroup($userGroup); if (count($users) == 0) { $em->remove($userGroup); $em->flush(); } else { $this->get('session')->getFlashBag()->add('warning', "El grupo de roles no pude eliminarse debido a que posee usuarios asociados."); return $this->redirect($request->getUri()); } } return $this->redirect($this->generateUrl('admin_usergroup')); }
php
public function deleteAction(Request $request, $id) { $form = $this->createDeleteForm($id); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $userGroup = $em->getRepository('AmulenUserBundle:UserGroup')->find($id); if (!$userGroup) { throw $this->createNotFoundException('Unable to find UserGroup entity.'); } $var = $em->getRepository('AmulenUserBundle:User')->findByGroup($userGroup); echo $var; die("123"); $users = $this->getUsersByUserGroup($userGroup); if (count($users) == 0) { $em->remove($userGroup); $em->flush(); } else { $this->get('session')->getFlashBag()->add('warning', "El grupo de roles no pude eliminarse debido a que posee usuarios asociados."); return $this->redirect($request->getUri()); } } return $this->redirect($this->generateUrl('admin_usergroup')); }
[ "public", "function", "deleteAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "form", "=", "$", "this", "->", "createDeleteForm", "(", "$", "id", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "userGroup", "=", "$", "em", "->", "getRepository", "(", "'AmulenUserBundle:UserGroup'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "userGroup", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find UserGroup entity.'", ")", ";", "}", "$", "var", "=", "$", "em", "->", "getRepository", "(", "'AmulenUserBundle:User'", ")", "->", "findByGroup", "(", "$", "userGroup", ")", ";", "echo", "$", "var", ";", "die", "(", "\"123\"", ")", ";", "$", "users", "=", "$", "this", "->", "getUsersByUserGroup", "(", "$", "userGroup", ")", ";", "if", "(", "count", "(", "$", "users", ")", "==", "0", ")", "{", "$", "em", "->", "remove", "(", "$", "userGroup", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "}", "else", "{", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'warning'", ",", "\"El grupo de roles no pude eliminarse debido a que posee usuarios asociados.\"", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "request", "->", "getUri", "(", ")", ")", ";", "}", "}", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_usergroup'", ")", ")", ";", "}" ]
Deletes a UserGroup entity. @Route("/{id}", name="admin_usergroup_delete") @Method("DELETE")
[ "Deletes", "a", "UserGroup", "entity", "." ]
00055834d9f094e63dcd8d66e2fedb822fcddee0
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Controller/UserGroupController.php#L191-L224
21,439
flowcode/AmulenUserBundle
src/Flowcode/UserBundle/Controller/UserGroupController.php
UserGroupController.createCreateForm
private function createCreateForm(UserGroup $entity) { $options = array ('action' => $this->generateUrl('admin_usergroup_create'), 'method' => 'POST' ); $form = $this->createForm(new UserGroupType(), $entity, $options); return $form; }
php
private function createCreateForm(UserGroup $entity) { $options = array ('action' => $this->generateUrl('admin_usergroup_create'), 'method' => 'POST' ); $form = $this->createForm(new UserGroupType(), $entity, $options); return $form; }
[ "private", "function", "createCreateForm", "(", "UserGroup", "$", "entity", ")", "{", "$", "options", "=", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_usergroup_create'", ")", ",", "'method'", "=>", "'POST'", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "UserGroupType", "(", ")", ",", "$", "entity", ",", "$", "options", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to create a UserGroup entity. @param UserGroup $entity The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "create", "a", "UserGroup", "entity", "." ]
00055834d9f094e63dcd8d66e2fedb822fcddee0
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Controller/UserGroupController.php#L253-L262
21,440
flowcode/AmulenUserBundle
src/Flowcode/UserBundle/Controller/UserGroupController.php
UserGroupController.getUsersByUserGroup
private function getUsersByUserGroup(UserGroup $userGroup) { return 10; $em = $this->getDoctrine()->getEntityManager(); $query = $em->createQuery('SELECT ' . ' u, g ' . ' FROM Flowcode\UserBundle\Entity\User u' . ' join u.groups g ' . ' WHERE ' . ' g.name = '.$userGroup->getName().''); $users = $query->getResult(); return $users; }
php
private function getUsersByUserGroup(UserGroup $userGroup) { return 10; $em = $this->getDoctrine()->getEntityManager(); $query = $em->createQuery('SELECT ' . ' u, g ' . ' FROM Flowcode\UserBundle\Entity\User u' . ' join u.groups g ' . ' WHERE ' . ' g.name = '.$userGroup->getName().''); $users = $query->getResult(); return $users; }
[ "private", "function", "getUsersByUserGroup", "(", "UserGroup", "$", "userGroup", ")", "{", "return", "10", ";", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getEntityManager", "(", ")", ";", "$", "query", "=", "$", "em", "->", "createQuery", "(", "'SELECT '", ".", "' u, g '", ".", "' FROM Flowcode\\UserBundle\\Entity\\User u'", ".", "' join u.groups g '", ".", "' WHERE '", ".", "' g.name = '", ".", "$", "userGroup", "->", "getName", "(", ")", ".", "''", ")", ";", "$", "users", "=", "$", "query", "->", "getResult", "(", ")", ";", "return", "$", "users", ";", "}" ]
Get Users by user group. Dado un grupo de roles de usuario, retorna todos los usuarios que pertenecen al grupo. @param UserGroup $userGroup El grupo. @return array() Los usuarios.
[ "Get", "Users", "by", "user", "group", ".", "Dado", "un", "grupo", "de", "roles", "de", "usuario", "retorna", "todos", "los", "usuarios", "que", "pertenecen", "al", "grupo", "." ]
00055834d9f094e63dcd8d66e2fedb822fcddee0
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Controller/UserGroupController.php#L273-L287
21,441
mvccore/ext-router-module
src/MvcCore/Ext/Routers/Module/RewriteRoutingChecks.php
RewriteRoutingChecks.rewriteRoutingCheckRoute
protected function rewriteRoutingCheckRoute (\MvcCore\IRoute & $route, array $additionalInfo) { list ($requestMethod) = $additionalInfo; $routeMethod = $route->GetMethod(); if ($routeMethod !== NULL && $routeMethod !== $requestMethod) return TRUE; $modules = $route->GetAdvancedConfigProperty(\MvcCore\Ext\Routers\Modules\IRoute::CONFIG_ALLOWED_MODULES); if (is_array($modules) && !in_array($this->currentModule, $modules)) return TRUE; return FALSE; }
php
protected function rewriteRoutingCheckRoute (\MvcCore\IRoute & $route, array $additionalInfo) { list ($requestMethod) = $additionalInfo; $routeMethod = $route->GetMethod(); if ($routeMethod !== NULL && $routeMethod !== $requestMethod) return TRUE; $modules = $route->GetAdvancedConfigProperty(\MvcCore\Ext\Routers\Modules\IRoute::CONFIG_ALLOWED_MODULES); if (is_array($modules) && !in_array($this->currentModule, $modules)) return TRUE; return FALSE; }
[ "protected", "function", "rewriteRoutingCheckRoute", "(", "\\", "MvcCore", "\\", "IRoute", "&", "$", "route", ",", "array", "$", "additionalInfo", ")", "{", "list", "(", "$", "requestMethod", ")", "=", "$", "additionalInfo", ";", "$", "routeMethod", "=", "$", "route", "->", "GetMethod", "(", ")", ";", "if", "(", "$", "routeMethod", "!==", "NULL", "&&", "$", "routeMethod", "!==", "$", "requestMethod", ")", "return", "TRUE", ";", "$", "modules", "=", "$", "route", "->", "GetAdvancedConfigProperty", "(", "\\", "MvcCore", "\\", "Ext", "\\", "Routers", "\\", "Modules", "\\", "IRoute", "::", "CONFIG_ALLOWED_MODULES", ")", ";", "if", "(", "is_array", "(", "$", "modules", ")", "&&", "!", "in_array", "(", "$", "this", "->", "currentModule", ",", "$", "modules", ")", ")", "return", "TRUE", ";", "return", "FALSE", ";", "}" ]
Return `TRUE` if there is possible by additional info array records to route request by given route as first argument. For example if route object has defined http method and request has the same method or not or if route is allowed in currently routed module. @param \MvcCore\IRoute $route @param array $additionalInfo @return bool
[ "Return", "TRUE", "if", "there", "is", "possible", "by", "additional", "info", "array", "records", "to", "route", "request", "by", "given", "route", "as", "first", "argument", ".", "For", "example", "if", "route", "object", "has", "defined", "http", "method", "and", "request", "has", "the", "same", "method", "or", "not", "or", "if", "route", "is", "allowed", "in", "currently", "routed", "module", "." ]
7695784a451db86cca6a43c98d076803cd0a50a7
https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/RewriteRoutingChecks.php#L27-L37
21,442
phPoirot/psr7
UploadedFile.php
UploadedFile.getStream
function getStream() { if ($err = $this->getError() !== UPLOAD_ERR_OK) // TODO Handle Upload With Exception Error throw new \RuntimeException(sprintf( 'Cannot retrieve stream due to upload error. error: (%s).' , getUploadErrorMessageFromCode($err) )); if ($this->isFileMoved) throw new \RuntimeException('Cannot retrieve stream after it has already been moved'); if ($this->stream) return $this->stream; $givenFileResource = $this->_c_givenResource; if (!$givenFileResource instanceof StreamInterface) $givenFileResource = new Stream($givenFileResource, 'r'); return $this->stream = $givenFileResource; }
php
function getStream() { if ($err = $this->getError() !== UPLOAD_ERR_OK) // TODO Handle Upload With Exception Error throw new \RuntimeException(sprintf( 'Cannot retrieve stream due to upload error. error: (%s).' , getUploadErrorMessageFromCode($err) )); if ($this->isFileMoved) throw new \RuntimeException('Cannot retrieve stream after it has already been moved'); if ($this->stream) return $this->stream; $givenFileResource = $this->_c_givenResource; if (!$givenFileResource instanceof StreamInterface) $givenFileResource = new Stream($givenFileResource, 'r'); return $this->stream = $givenFileResource; }
[ "function", "getStream", "(", ")", "{", "if", "(", "$", "err", "=", "$", "this", "->", "getError", "(", ")", "!==", "UPLOAD_ERR_OK", ")", "// TODO Handle Upload With Exception Error", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Cannot retrieve stream due to upload error. error: (%s).'", ",", "getUploadErrorMessageFromCode", "(", "$", "err", ")", ")", ")", ";", "if", "(", "$", "this", "->", "isFileMoved", ")", "throw", "new", "\\", "RuntimeException", "(", "'Cannot retrieve stream after it has already been moved'", ")", ";", "if", "(", "$", "this", "->", "stream", ")", "return", "$", "this", "->", "stream", ";", "$", "givenFileResource", "=", "$", "this", "->", "_c_givenResource", ";", "if", "(", "!", "$", "givenFileResource", "instanceof", "StreamInterface", ")", "$", "givenFileResource", "=", "new", "Stream", "(", "$", "givenFileResource", ",", "'r'", ")", ";", "return", "$", "this", "->", "stream", "=", "$", "givenFileResource", ";", "}" ]
Get Streamed Object Of Uploaded File @return StreamInterface
[ "Get", "Streamed", "Object", "Of", "Uploaded", "File" ]
e90295e806dc2eb0cc422f315075f673c63a0780
https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/UploadedFile.php#L99-L119
21,443
phPoirot/psr7
UploadedFile.php
UploadedFile.setTmpName
protected function setTmpName($filepath) { $this->tmpName = (string) $filepath; $this->stream = null; $this->_c_givenResource = $filepath; # stream will made of this when requested return $this; }
php
protected function setTmpName($filepath) { $this->tmpName = (string) $filepath; $this->stream = null; $this->_c_givenResource = $filepath; # stream will made of this when requested return $this; }
[ "protected", "function", "setTmpName", "(", "$", "filepath", ")", "{", "$", "this", "->", "tmpName", "=", "(", "string", ")", "$", "filepath", ";", "$", "this", "->", "stream", "=", "null", ";", "$", "this", "->", "_c_givenResource", "=", "$", "filepath", ";", "# stream will made of this when requested", "return", "$", "this", ";", "}" ]
Set tmp_name of Uploaded File @param string $filepath @return $this
[ "Set", "tmp_name", "of", "Uploaded", "File" ]
e90295e806dc2eb0cc422f315075f673c63a0780
https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/UploadedFile.php#L194-L201
21,444
phPoirot/psr7
UploadedFile.php
UploadedFile.setType
protected function setType($type) { if ($type == '*/*' || $type == 'application/octet-stream') { $type = \Module\HttpFoundation\getMimeTypeOfFile($this->getTmpName(), false); if ( empty($type) ) if ( null !== $solved = \Module\HttpFoundation\getMimeTypeOfFile($this->getClientFilename()) ) $type = $solved; else $type = 'application/octet-stream'; } $this->type = (string) $type; return $this; }
php
protected function setType($type) { if ($type == '*/*' || $type == 'application/octet-stream') { $type = \Module\HttpFoundation\getMimeTypeOfFile($this->getTmpName(), false); if ( empty($type) ) if ( null !== $solved = \Module\HttpFoundation\getMimeTypeOfFile($this->getClientFilename()) ) $type = $solved; else $type = 'application/octet-stream'; } $this->type = (string) $type; return $this; }
[ "protected", "function", "setType", "(", "$", "type", ")", "{", "if", "(", "$", "type", "==", "'*/*'", "||", "$", "type", "==", "'application/octet-stream'", ")", "{", "$", "type", "=", "\\", "Module", "\\", "HttpFoundation", "\\", "getMimeTypeOfFile", "(", "$", "this", "->", "getTmpName", "(", ")", ",", "false", ")", ";", "if", "(", "empty", "(", "$", "type", ")", ")", "if", "(", "null", "!==", "$", "solved", "=", "\\", "Module", "\\", "HttpFoundation", "\\", "getMimeTypeOfFile", "(", "$", "this", "->", "getClientFilename", "(", ")", ")", ")", "$", "type", "=", "$", "solved", ";", "else", "$", "type", "=", "'application/octet-stream'", ";", "}", "$", "this", "->", "type", "=", "(", "string", ")", "$", "type", ";", "return", "$", "this", ";", "}" ]
Set File Type @param string $type @return $this
[ "Set", "File", "Type" ]
e90295e806dc2eb0cc422f315075f673c63a0780
https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/UploadedFile.php#L243-L257
21,445
phPoirot/psr7
UploadedFile.php
UploadedFile.setError
protected function setError($errorStatus) { # error status if (! is_int($errorStatus) || 0 > $errorStatus || 8 < $errorStatus ) throw new \InvalidArgumentException( 'Invalid error status for UploadedFile; must be an UPLOAD_ERR_* constant' ); $this->error = $errorStatus; return $this; }
php
protected function setError($errorStatus) { # error status if (! is_int($errorStatus) || 0 > $errorStatus || 8 < $errorStatus ) throw new \InvalidArgumentException( 'Invalid error status for UploadedFile; must be an UPLOAD_ERR_* constant' ); $this->error = $errorStatus; return $this; }
[ "protected", "function", "setError", "(", "$", "errorStatus", ")", "{", "# error status", "if", "(", "!", "is_int", "(", "$", "errorStatus", ")", "||", "0", ">", "$", "errorStatus", "||", "8", "<", "$", "errorStatus", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid error status for UploadedFile; must be an UPLOAD_ERR_* constant'", ")", ";", "$", "this", "->", "error", "=", "$", "errorStatus", ";", "return", "$", "this", ";", "}" ]
Set Error Status Code @param int $errorStatus @return $this
[ "Set", "Error", "Status", "Code" ]
e90295e806dc2eb0cc422f315075f673c63a0780
https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/UploadedFile.php#L293-L306
21,446
unclecheese/silverstripe-blubber
code/CSSBlubberTask.php
CSSBlubberTask.gatherCSSFiles
protected function gatherCSSFiles() { $this->output->writeln('Scanning theme "'.$this->theme.'" for CSS files'); $this->finder ->files() ->in($this->themeDir) ->name('*.css') ->notName('*.blubber.css') ->notName('*.lean.css'); foreach($this->finder as $file) { $filename = basename($file->getRealPath()); if($this->output->ask("Include the file <caution>$filename</caution>?")) { $this->cssFiles[] = $file->getRealPath(); } } }
php
protected function gatherCSSFiles() { $this->output->writeln('Scanning theme "'.$this->theme.'" for CSS files'); $this->finder ->files() ->in($this->themeDir) ->name('*.css') ->notName('*.blubber.css') ->notName('*.lean.css'); foreach($this->finder as $file) { $filename = basename($file->getRealPath()); if($this->output->ask("Include the file <caution>$filename</caution>?")) { $this->cssFiles[] = $file->getRealPath(); } } }
[ "protected", "function", "gatherCSSFiles", "(", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "'Scanning theme \"'", ".", "$", "this", "->", "theme", ".", "'\" for CSS files'", ")", ";", "$", "this", "->", "finder", "->", "files", "(", ")", "->", "in", "(", "$", "this", "->", "themeDir", ")", "->", "name", "(", "'*.css'", ")", "->", "notName", "(", "'*.blubber.css'", ")", "->", "notName", "(", "'*.lean.css'", ")", ";", "foreach", "(", "$", "this", "->", "finder", "as", "$", "file", ")", "{", "$", "filename", "=", "basename", "(", "$", "file", "->", "getRealPath", "(", ")", ")", ";", "if", "(", "$", "this", "->", "output", "->", "ask", "(", "\"Include the file <caution>$filename</caution>?\"", ")", ")", "{", "$", "this", "->", "cssFiles", "[", "]", "=", "$", "file", "->", "getRealPath", "(", ")", ";", "}", "}", "}" ]
Collects all the CSS files per the user's approval
[ "Collects", "all", "the", "CSS", "files", "per", "the", "user", "s", "approval" ]
f2549bd5eddeb0ca0303a3c09be4a8136fcc6661
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/CSSBlubberTask.php#L159-L175
21,447
unclecheese/silverstripe-blubber
code/CSSBlubberTask.php
CSSBlubberTask.loadTemplates
protected function loadTemplates() { $manifest = SS_TemplateLoader::instance()->getManifest(); $templates = $manifest->getTemplates(); $total = sizeof($templates); $count = 0; $this->output->clearProgress(); foreach($templates as $name => $data) { foreach($manifest->getCandidateTemplate($name, $this->theme) as $template) { $this->samples[] = $template; } $count++; $this->output->updateProgressPercent($count, $total); } $this->output->writeln(); }
php
protected function loadTemplates() { $manifest = SS_TemplateLoader::instance()->getManifest(); $templates = $manifest->getTemplates(); $total = sizeof($templates); $count = 0; $this->output->clearProgress(); foreach($templates as $name => $data) { foreach($manifest->getCandidateTemplate($name, $this->theme) as $template) { $this->samples[] = $template; } $count++; $this->output->updateProgressPercent($count, $total); } $this->output->writeln(); }
[ "protected", "function", "loadTemplates", "(", ")", "{", "$", "manifest", "=", "SS_TemplateLoader", "::", "instance", "(", ")", "->", "getManifest", "(", ")", ";", "$", "templates", "=", "$", "manifest", "->", "getTemplates", "(", ")", ";", "$", "total", "=", "sizeof", "(", "$", "templates", ")", ";", "$", "count", "=", "0", ";", "$", "this", "->", "output", "->", "clearProgress", "(", ")", ";", "foreach", "(", "$", "templates", "as", "$", "name", "=>", "$", "data", ")", "{", "foreach", "(", "$", "manifest", "->", "getCandidateTemplate", "(", "$", "name", ",", "$", "this", "->", "theme", ")", "as", "$", "template", ")", "{", "$", "this", "->", "samples", "[", "]", "=", "$", "template", ";", "}", "$", "count", "++", ";", "$", "this", "->", "output", "->", "updateProgressPercent", "(", "$", "count", ",", "$", "total", ")", ";", "}", "$", "this", "->", "output", "->", "writeln", "(", ")", ";", "}" ]
Loads all the static .ss templates as HTML into memory
[ "Loads", "all", "the", "static", ".", "ss", "templates", "as", "HTML", "into", "memory" ]
f2549bd5eddeb0ca0303a3c09be4a8136fcc6661
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/CSSBlubberTask.php#L180-L196
21,448
unclecheese/silverstripe-blubber
code/CSSBlubberTask.php
CSSBlubberTask.loadURLs
protected function loadURLs() { $omissions = self::config()->omit; $dataobjects = self::config()->extra_dataobjects; $i = 0; $classes = ClassInfo::subclassesFor('SiteTree'); array_shift($classes); $sampler = Sampler::create($classes) ->setDefaultLimit(self::config()->default_limit) ->setOmissions(self::config()->omit) ->setLimits(self::config()->limits); $list = $sampler->execute(); $totalPages = $list->count(); $this->output->clearProgress(); foreach($list as $page) { $i++; if($html = $this->getSampleForObject($page)) { $this->samples[] = $html; } $this->output->updateProgress("$i / $totalPages"); } $this->output->writeln(); if(!empty($dataobjects)) { $this->output->clearProgress(); $i = 0; $sampler->setClasses($dataobjects); $list = $sampler->execute(); $totalPages = $list->count(); $this->output->write("Loading $totalPages DataObject URLs..."); foreach($list as $object) { if(!$object->hasMethod('Link')) { $this->output->writeln("<error>{$object->ClassName} has no Link() method. Skipping.</error>"); continue; } if($html = $this->getSampleForObject($object)) { $this->samples[] = $html; } $i++; $this->output->updateProgressPercent($i, $totalPages); } $this->output->writeln(); } }
php
protected function loadURLs() { $omissions = self::config()->omit; $dataobjects = self::config()->extra_dataobjects; $i = 0; $classes = ClassInfo::subclassesFor('SiteTree'); array_shift($classes); $sampler = Sampler::create($classes) ->setDefaultLimit(self::config()->default_limit) ->setOmissions(self::config()->omit) ->setLimits(self::config()->limits); $list = $sampler->execute(); $totalPages = $list->count(); $this->output->clearProgress(); foreach($list as $page) { $i++; if($html = $this->getSampleForObject($page)) { $this->samples[] = $html; } $this->output->updateProgress("$i / $totalPages"); } $this->output->writeln(); if(!empty($dataobjects)) { $this->output->clearProgress(); $i = 0; $sampler->setClasses($dataobjects); $list = $sampler->execute(); $totalPages = $list->count(); $this->output->write("Loading $totalPages DataObject URLs..."); foreach($list as $object) { if(!$object->hasMethod('Link')) { $this->output->writeln("<error>{$object->ClassName} has no Link() method. Skipping.</error>"); continue; } if($html = $this->getSampleForObject($object)) { $this->samples[] = $html; } $i++; $this->output->updateProgressPercent($i, $totalPages); } $this->output->writeln(); } }
[ "protected", "function", "loadURLs", "(", ")", "{", "$", "omissions", "=", "self", "::", "config", "(", ")", "->", "omit", ";", "$", "dataobjects", "=", "self", "::", "config", "(", ")", "->", "extra_dataobjects", ";", "$", "i", "=", "0", ";", "$", "classes", "=", "ClassInfo", "::", "subclassesFor", "(", "'SiteTree'", ")", ";", "array_shift", "(", "$", "classes", ")", ";", "$", "sampler", "=", "Sampler", "::", "create", "(", "$", "classes", ")", "->", "setDefaultLimit", "(", "self", "::", "config", "(", ")", "->", "default_limit", ")", "->", "setOmissions", "(", "self", "::", "config", "(", ")", "->", "omit", ")", "->", "setLimits", "(", "self", "::", "config", "(", ")", "->", "limits", ")", ";", "$", "list", "=", "$", "sampler", "->", "execute", "(", ")", ";", "$", "totalPages", "=", "$", "list", "->", "count", "(", ")", ";", "$", "this", "->", "output", "->", "clearProgress", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "page", ")", "{", "$", "i", "++", ";", "if", "(", "$", "html", "=", "$", "this", "->", "getSampleForObject", "(", "$", "page", ")", ")", "{", "$", "this", "->", "samples", "[", "]", "=", "$", "html", ";", "}", "$", "this", "->", "output", "->", "updateProgress", "(", "\"$i / $totalPages\"", ")", ";", "}", "$", "this", "->", "output", "->", "writeln", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "dataobjects", ")", ")", "{", "$", "this", "->", "output", "->", "clearProgress", "(", ")", ";", "$", "i", "=", "0", ";", "$", "sampler", "->", "setClasses", "(", "$", "dataobjects", ")", ";", "$", "list", "=", "$", "sampler", "->", "execute", "(", ")", ";", "$", "totalPages", "=", "$", "list", "->", "count", "(", ")", ";", "$", "this", "->", "output", "->", "write", "(", "\"Loading $totalPages DataObject URLs...\"", ")", ";", "foreach", "(", "$", "list", "as", "$", "object", ")", "{", "if", "(", "!", "$", "object", "->", "hasMethod", "(", "'Link'", ")", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "\"<error>{$object->ClassName} has no Link() method. Skipping.</error>\"", ")", ";", "continue", ";", "}", "if", "(", "$", "html", "=", "$", "this", "->", "getSampleForObject", "(", "$", "object", ")", ")", "{", "$", "this", "->", "samples", "[", "]", "=", "$", "html", ";", "}", "$", "i", "++", ";", "$", "this", "->", "output", "->", "updateProgressPercent", "(", "$", "i", ",", "$", "totalPages", ")", ";", "}", "$", "this", "->", "output", "->", "writeln", "(", ")", ";", "}", "}" ]
Loads all URLs to sample rendered content, per confirguration
[ "Loads", "all", "URLs", "to", "sample", "rendered", "content", "per", "confirguration" ]
f2549bd5eddeb0ca0303a3c09be4a8136fcc6661
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/CSSBlubberTask.php#L201-L254
21,449
unclecheese/silverstripe-blubber
code/CSSBlubberTask.php
CSSBlubberTask.getSampleForObject
protected function getSampleForObject(DataObject $record) { $response = Director::test($record->Link()); if($response->getStatusCode() === 200) { return $response->getBody(); } return false; }
php
protected function getSampleForObject(DataObject $record) { $response = Director::test($record->Link()); if($response->getStatusCode() === 200) { return $response->getBody(); } return false; }
[ "protected", "function", "getSampleForObject", "(", "DataObject", "$", "record", ")", "{", "$", "response", "=", "Director", "::", "test", "(", "$", "record", "->", "Link", "(", ")", ")", ";", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "===", "200", ")", "{", "return", "$", "response", "->", "getBody", "(", ")", ";", "}", "return", "false", ";", "}" ]
Given a DataObject, get an actual SS_HTTPResponse of rendered HTML @param DataObject $record @return string The rendered HTML
[ "Given", "a", "DataObject", "get", "an", "actual", "SS_HTTPResponse", "of", "rendered", "HTML" ]
f2549bd5eddeb0ca0303a3c09be4a8136fcc6661
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/CSSBlubberTask.php#L261-L269
21,450
nabab/bbn
src/bbn/models/tts/optional.php
optional.get_appui_option_id
public static function get_appui_option_id(){ return bbn\appui\options::get_instance()->from_code(...self::_treat_args(func_get_args(), true)); }
php
public static function get_appui_option_id(){ return bbn\appui\options::get_instance()->from_code(...self::_treat_args(func_get_args(), true)); }
[ "public", "static", "function", "get_appui_option_id", "(", ")", "{", "return", "bbn", "\\", "appui", "\\", "options", "::", "get_instance", "(", ")", "->", "from_code", "(", "...", "self", "::", "_treat_args", "(", "func_get_args", "(", ")", ",", "true", ")", ")", ";", "}" ]
Returns The option's ID of a category, i.e. direct children of option's root @param string $code @return int|false
[ "Returns", "The", "option", "s", "ID", "of", "a", "category", "i", ".", "e", ".", "direct", "children", "of", "option", "s", "root" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/models/tts/optional.php#L115-L117
21,451
kusanagi/katana-sdk-php7
src/Api/TypeCatalog.php
TypeCatalog.getDefault
public function getDefault(string $type) { switch ($type) { case self::TYPE_NULL: return null; case self::TYPE_BOOLEAN: return false; case self::TYPE_INTEGER: case self::TYPE_FLOAT: return 0; case self::TYPE_STRING: case self::TYPE_BINARY: return ''; case self::TYPE_ARRAY: case self::TYPE_OBJECT: return []; } throw new InvalidValueException("Invalid value type: $type"); }
php
public function getDefault(string $type) { switch ($type) { case self::TYPE_NULL: return null; case self::TYPE_BOOLEAN: return false; case self::TYPE_INTEGER: case self::TYPE_FLOAT: return 0; case self::TYPE_STRING: case self::TYPE_BINARY: return ''; case self::TYPE_ARRAY: case self::TYPE_OBJECT: return []; } throw new InvalidValueException("Invalid value type: $type"); }
[ "public", "function", "getDefault", "(", "string", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "self", "::", "TYPE_NULL", ":", "return", "null", ";", "case", "self", "::", "TYPE_BOOLEAN", ":", "return", "false", ";", "case", "self", "::", "TYPE_INTEGER", ":", "case", "self", "::", "TYPE_FLOAT", ":", "return", "0", ";", "case", "self", "::", "TYPE_STRING", ":", "case", "self", "::", "TYPE_BINARY", ":", "return", "''", ";", "case", "self", "::", "TYPE_ARRAY", ":", "case", "self", "::", "TYPE_OBJECT", ":", "return", "[", "]", ";", "}", "throw", "new", "InvalidValueException", "(", "\"Invalid value type: $type\"", ")", ";", "}" ]
Return the default value for a given type. @param string $type @return mixed @throws InvalidValueException
[ "Return", "the", "default", "value", "for", "a", "given", "type", "." ]
91e7860a1852c3ce79a7034f8c36f41840e69e1f
https://github.com/kusanagi/katana-sdk-php7/blob/91e7860a1852c3ce79a7034f8c36f41840e69e1f/src/Api/TypeCatalog.php#L63-L82
21,452
kusanagi/katana-sdk-php7
src/Api/TypeCatalog.php
TypeCatalog.validate
public function validate(string $type, $value): bool { switch ($type) { case self::TYPE_NULL: return is_null($value); case self::TYPE_BOOLEAN: return is_bool($value); case self::TYPE_INTEGER: return is_integer($value); case self::TYPE_FLOAT: return is_float($value); case self::TYPE_STRING: return is_string($value); case self::TYPE_ARRAY: if (!is_array($value)) { return false; } return $this->isArrayType($value); case self::TYPE_OBJECT: if (!is_array($value)) { return false; } return $this->isObjectType($value); case self::TYPE_BINARY: return is_string($value); } throw new InvalidValueException("Invalid value type: $type"); }
php
public function validate(string $type, $value): bool { switch ($type) { case self::TYPE_NULL: return is_null($value); case self::TYPE_BOOLEAN: return is_bool($value); case self::TYPE_INTEGER: return is_integer($value); case self::TYPE_FLOAT: return is_float($value); case self::TYPE_STRING: return is_string($value); case self::TYPE_ARRAY: if (!is_array($value)) { return false; } return $this->isArrayType($value); case self::TYPE_OBJECT: if (!is_array($value)) { return false; } return $this->isObjectType($value); case self::TYPE_BINARY: return is_string($value); } throw new InvalidValueException("Invalid value type: $type"); }
[ "public", "function", "validate", "(", "string", "$", "type", ",", "$", "value", ")", ":", "bool", "{", "switch", "(", "$", "type", ")", "{", "case", "self", "::", "TYPE_NULL", ":", "return", "is_null", "(", "$", "value", ")", ";", "case", "self", "::", "TYPE_BOOLEAN", ":", "return", "is_bool", "(", "$", "value", ")", ";", "case", "self", "::", "TYPE_INTEGER", ":", "return", "is_integer", "(", "$", "value", ")", ";", "case", "self", "::", "TYPE_FLOAT", ":", "return", "is_float", "(", "$", "value", ")", ";", "case", "self", "::", "TYPE_STRING", ":", "return", "is_string", "(", "$", "value", ")", ";", "case", "self", "::", "TYPE_ARRAY", ":", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "isArrayType", "(", "$", "value", ")", ";", "case", "self", "::", "TYPE_OBJECT", ":", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "isObjectType", "(", "$", "value", ")", ";", "case", "self", "::", "TYPE_BINARY", ":", "return", "is_string", "(", "$", "value", ")", ";", "}", "throw", "new", "InvalidValueException", "(", "\"Invalid value type: $type\"", ")", ";", "}" ]
Validates a value against a type. @param mixed $value @param string $type @return bool @throws InvalidValueException
[ "Validates", "a", "value", "against", "a", "type", "." ]
91e7860a1852c3ce79a7034f8c36f41840e69e1f
https://github.com/kusanagi/katana-sdk-php7/blob/91e7860a1852c3ce79a7034f8c36f41840e69e1f/src/Api/TypeCatalog.php#L92-L120
21,453
crysalead/inflector
src/Inflector.php
Inflector.camelize
public static function camelize($word) { $upper = function($matches) { return strtoupper($matches[0]); }; $word = preg_replace('/([a-z])([A-Z])/', '$1_$2', $word); $camelized = str_replace(' ', '', ucwords(str_replace(['_', '-'], ' ', strtolower($word)))); return preg_replace_callback('/(\\\[a-z])/', $upper, $camelized); }
php
public static function camelize($word) { $upper = function($matches) { return strtoupper($matches[0]); }; $word = preg_replace('/([a-z])([A-Z])/', '$1_$2', $word); $camelized = str_replace(' ', '', ucwords(str_replace(['_', '-'], ' ', strtolower($word)))); return preg_replace_callback('/(\\\[a-z])/', $upper, $camelized); }
[ "public", "static", "function", "camelize", "(", "$", "word", ")", "{", "$", "upper", "=", "function", "(", "$", "matches", ")", "{", "return", "strtoupper", "(", "$", "matches", "[", "0", "]", ")", ";", "}", ";", "$", "word", "=", "preg_replace", "(", "'/([a-z])([A-Z])/'", ",", "'$1_$2'", ",", "$", "word", ")", ";", "$", "camelized", "=", "str_replace", "(", "' '", ",", "''", ",", "ucwords", "(", "str_replace", "(", "[", "'_'", ",", "'-'", "]", ",", "' '", ",", "strtolower", "(", "$", "word", ")", ")", ")", ")", ";", "return", "preg_replace_callback", "(", "'/(\\\\\\[a-z])/'", ",", "$", "upper", ",", "$", "camelized", ")", ";", "}" ]
Takes a under_scored word and turns it into a camelcased word. @param string $word An underscored or slugged word (i.e. `'red_bike'` or `'red-bike'`). @param array $on List of characters to camelize on. @return string Camel cased version of the word (i.e. `'RedBike'`).
[ "Takes", "a", "under_scored", "word", "and", "turns", "it", "into", "a", "camelcased", "word", "." ]
07a890c43debebcfaeffe1c30a504f954e9a463c
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L29-L37
21,454
crysalead/inflector
src/Inflector.php
Inflector.slug
public static function slug($string, $replacement = '-') { $transliterated = static::transliterate($string); $spaced = preg_replace('/[^\w\s]/', ' ', $transliterated); return preg_replace('/\\s+/', $replacement, trim($spaced)); }
php
public static function slug($string, $replacement = '-') { $transliterated = static::transliterate($string); $spaced = preg_replace('/[^\w\s]/', ' ', $transliterated); return preg_replace('/\\s+/', $replacement, trim($spaced)); }
[ "public", "static", "function", "slug", "(", "$", "string", ",", "$", "replacement", "=", "'-'", ")", "{", "$", "transliterated", "=", "static", "::", "transliterate", "(", "$", "string", ")", ";", "$", "spaced", "=", "preg_replace", "(", "'/[^\\w\\s]/'", ",", "' '", ",", "$", "transliterated", ")", ";", "return", "preg_replace", "(", "'/\\\\s+/'", ",", "$", "replacement", ",", "trim", "(", "$", "spaced", ")", ")", ";", "}" ]
Returns a string with all spaces converted to given replacement and non word characters removed. Maps special characters to ASCII using `transliterator_transliterate`. @param string $string An arbitrary string to convert. @param string $replacement The replacement to use for spaces. @return string The converted string.
[ "Returns", "a", "string", "with", "all", "spaces", "converted", "to", "given", "replacement", "and", "non", "word", "characters", "removed", ".", "Maps", "special", "characters", "to", "ASCII", "using", "transliterator_transliterate", "." ]
07a890c43debebcfaeffe1c30a504f954e9a463c
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L81-L86
21,455
crysalead/inflector
src/Inflector.php
Inflector.parameterize
public static function parameterize($string, $replacement = '-') { $transliterated = static::transliterate($string); return strtolower(static::slug($string, $replacement)); }
php
public static function parameterize($string, $replacement = '-') { $transliterated = static::transliterate($string); return strtolower(static::slug($string, $replacement)); }
[ "public", "static", "function", "parameterize", "(", "$", "string", ",", "$", "replacement", "=", "'-'", ")", "{", "$", "transliterated", "=", "static", "::", "transliterate", "(", "$", "string", ")", ";", "return", "strtolower", "(", "static", "::", "slug", "(", "$", "string", ",", "$", "replacement", ")", ")", ";", "}" ]
Returns a lowercased string with all spaces converted to given replacement and non word characters removed. Maps special characters to ASCII using `transliterator_transliterate`. @param string $string An arbitrary string to convert. @param string $replacement The replacement to use for spaces. @return string The converted lowercased string.
[ "Returns", "a", "lowercased", "string", "with", "all", "spaces", "converted", "to", "given", "replacement", "and", "non", "word", "characters", "removed", ".", "Maps", "special", "characters", "to", "ASCII", "using", "transliterator_transliterate", "." ]
07a890c43debebcfaeffe1c30a504f954e9a463c
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L96-L100
21,456
crysalead/inflector
src/Inflector.php
Inflector._inflect
protected static function _inflect($type, $rule, $replacement, $locale) { $rules = & static::${$type}; if (!isset($rules[$locale])) { $rules[$locale] = []; } $rules[$locale] = [$rule => $replacement] + $rules[$locale]; }
php
protected static function _inflect($type, $rule, $replacement, $locale) { $rules = & static::${$type}; if (!isset($rules[$locale])) { $rules[$locale] = []; } $rules[$locale] = [$rule => $replacement] + $rules[$locale]; }
[ "protected", "static", "function", "_inflect", "(", "$", "type", ",", "$", "rule", ",", "$", "replacement", ",", "$", "locale", ")", "{", "$", "rules", "=", "&", "static", "::", "$", "{", "$", "type", "}", ";", "if", "(", "!", "isset", "(", "$", "rules", "[", "$", "locale", "]", ")", ")", "{", "$", "rules", "[", "$", "locale", "]", "=", "[", "]", ";", "}", "$", "rules", "[", "$", "locale", "]", "=", "[", "$", "rule", "=>", "$", "replacement", "]", "+", "$", "rules", "[", "$", "locale", "]", ";", "}" ]
Set a new inflection rule and its replacement. @param string $type The inflection type. @param string $rule A regular expression. @param string $replacement The replacement expression. @param string $locale The locale where this rule will be applied.
[ "Set", "a", "new", "inflection", "rule", "and", "its", "replacement", "." ]
07a890c43debebcfaeffe1c30a504f954e9a463c
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L159-L166
21,457
crysalead/inflector
src/Inflector.php
Inflector._inflectize
protected static function _inflectize($rules, $word, $locale) { if (!$word || !isset($rules[$locale])) { return $word; } $result = $word; foreach ($rules[$locale] as $rule => $replacement) { $result = preg_replace($rule, $replacement, $word, -1, $count); if ($count) { return $result; } } return $result; }
php
protected static function _inflectize($rules, $word, $locale) { if (!$word || !isset($rules[$locale])) { return $word; } $result = $word; foreach ($rules[$locale] as $rule => $replacement) { $result = preg_replace($rule, $replacement, $word, -1, $count); if ($count) { return $result; } } return $result; }
[ "protected", "static", "function", "_inflectize", "(", "$", "rules", ",", "$", "word", ",", "$", "locale", ")", "{", "if", "(", "!", "$", "word", "||", "!", "isset", "(", "$", "rules", "[", "$", "locale", "]", ")", ")", "{", "return", "$", "word", ";", "}", "$", "result", "=", "$", "word", ";", "foreach", "(", "$", "rules", "[", "$", "locale", "]", "as", "$", "rule", "=>", "$", "replacement", ")", "{", "$", "result", "=", "preg_replace", "(", "$", "rule", ",", "$", "replacement", ",", "$", "word", ",", "-", "1", ",", "$", "count", ")", ";", "if", "(", "$", "count", ")", "{", "return", "$", "result", ";", "}", "}", "return", "$", "result", ";", "}" ]
Changes the form of a word. @param string $rules The inflection rules array. @param string $word A word. @param string $locale The locale to use for rules. @return string The inflectized word.
[ "Changes", "the", "form", "of", "a", "word", "." ]
07a890c43debebcfaeffe1c30a504f954e9a463c
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L202-L215
21,458
crysalead/inflector
src/Inflector.php
Inflector.irregular
public static function irregular($singular, $plural, $locale = 'default') { $rules = !is_array($singular) ? [$singular => $plural] : $singular; $len = min(strlen($singular), strlen($plural)); $prefix = ''; $index = 0; while ($index < $len && ($singular[$index] === $plural[$index])) { $prefix .= $singular[$index]; $index++; } if (!$sSuffix = substr($singular, $index)) { $sSuffix = ''; } if (!$pSuffix = substr($plural, $index)) { $pSuffix = ''; } static::singular("/({$singular})$/i", "\\1", $locale); static::singular("/({$prefix}){$pSuffix}$/i", "\\1{$sSuffix}", $locale); static::plural("/({$plural})$/i", "\\1", $locale); static::plural("/({$prefix}){$sSuffix}$/i", "\\1{$pSuffix}", $locale); }
php
public static function irregular($singular, $plural, $locale = 'default') { $rules = !is_array($singular) ? [$singular => $plural] : $singular; $len = min(strlen($singular), strlen($plural)); $prefix = ''; $index = 0; while ($index < $len && ($singular[$index] === $plural[$index])) { $prefix .= $singular[$index]; $index++; } if (!$sSuffix = substr($singular, $index)) { $sSuffix = ''; } if (!$pSuffix = substr($plural, $index)) { $pSuffix = ''; } static::singular("/({$singular})$/i", "\\1", $locale); static::singular("/({$prefix}){$pSuffix}$/i", "\\1{$sSuffix}", $locale); static::plural("/({$plural})$/i", "\\1", $locale); static::plural("/({$prefix}){$sSuffix}$/i", "\\1{$pSuffix}", $locale); }
[ "public", "static", "function", "irregular", "(", "$", "singular", ",", "$", "plural", ",", "$", "locale", "=", "'default'", ")", "{", "$", "rules", "=", "!", "is_array", "(", "$", "singular", ")", "?", "[", "$", "singular", "=>", "$", "plural", "]", ":", "$", "singular", ";", "$", "len", "=", "min", "(", "strlen", "(", "$", "singular", ")", ",", "strlen", "(", "$", "plural", ")", ")", ";", "$", "prefix", "=", "''", ";", "$", "index", "=", "0", ";", "while", "(", "$", "index", "<", "$", "len", "&&", "(", "$", "singular", "[", "$", "index", "]", "===", "$", "plural", "[", "$", "index", "]", ")", ")", "{", "$", "prefix", ".=", "$", "singular", "[", "$", "index", "]", ";", "$", "index", "++", ";", "}", "if", "(", "!", "$", "sSuffix", "=", "substr", "(", "$", "singular", ",", "$", "index", ")", ")", "{", "$", "sSuffix", "=", "''", ";", "}", "if", "(", "!", "$", "pSuffix", "=", "substr", "(", "$", "plural", ",", "$", "index", ")", ")", "{", "$", "pSuffix", "=", "''", ";", "}", "static", "::", "singular", "(", "\"/({$singular})$/i\"", ",", "\"\\\\1\"", ",", "$", "locale", ")", ";", "static", "::", "singular", "(", "\"/({$prefix}){$pSuffix}$/i\"", ",", "\"\\\\1{$sSuffix}\"", ",", "$", "locale", ")", ";", "static", "::", "plural", "(", "\"/({$plural})$/i\"", ",", "\"\\\\1\"", ",", "$", "locale", ")", ";", "static", "::", "plural", "(", "\"/({$prefix}){$sSuffix}$/i\"", ",", "\"\\\\1{$pSuffix}\"", ",", "$", "locale", ")", ";", "}" ]
Set a new exception in inflection. @param string $singular The singular form of the word. @param string $plural The plural form of the word. @param string $locale The locale where this irregularity will be applied.
[ "Set", "a", "new", "exception", "in", "inflection", "." ]
07a890c43debebcfaeffe1c30a504f954e9a463c
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L224-L247
21,459
crysalead/inflector
src/Inflector.php
Inflector.reset
public static function reset($lang = null) { if (is_string($lang)) { unset(static::$_singular[$lang]); unset(static::$_plural[$lang]); return; } static::$_singular = []; static::$_plural = []; if ($lang === true) { return; } /** * Initilalize the class with english inflector rules. */ Inflector::singular('/([^s])s$/i', '\1', 'default'); Inflector::plural('/([^s])$/i', '\1s', 'default'); Inflector::singular('/(x|z|s|ss|ch|sh)es$/i', '\1', 'default'); Inflector::plural('/(x|z|ss|ch|sh)$/i', '\1es', 'default'); Inflector::singular('/ies$/i', 'y', 'default'); Inflector::plural('/([^aeiouy]|qu)y$/i', '\1ies', 'default'); Inflector::plural('/(meta|data)$/i', '\1', 'default'); Inflector::irregular('child', 'children', 'default'); Inflector::irregular('equipment', 'equipment', 'default'); Inflector::irregular('information', 'information', 'default'); Inflector::irregular('man', 'men', 'default'); Inflector::irregular('news', 'news', 'default'); Inflector::irregular('person', 'people', 'default'); Inflector::irregular('woman', 'women', 'default'); /** * Warning, using an "exhastive" list of rules will slow * down all singularizations/pluralizations generations. * So it may be preferable to only add the ones you are actually needed. * * Anyhow bellow a list english exceptions which are not covered by the above rules. */ // Inflector::irregular('advice', 'advice', 'default'); // Inflector::irregular('aircraft', 'aircraft', 'default'); // Inflector::irregular('alias', 'aliases', 'default'); // Inflector::irregular('alga', 'algae', 'default'); // Inflector::irregular('alumna', 'alumnae', 'default'); // Inflector::irregular('alumnus', 'alumni', 'default'); // Inflector::irregular('analysis', 'analyses', 'default'); // Inflector::irregular('antenna', 'antennae', 'default'); // Inflector::irregular('automaton', 'automata', 'default'); // Inflector::irregular('axis', 'axes', 'default'); // Inflector::irregular('bacillus', 'bacilli', 'default'); // Inflector::irregular('bacterium', 'bacteria', 'default'); // Inflector::irregular('barracks', 'barracks', 'default'); // Inflector::irregular('basis', 'bases', 'default'); // Inflector::irregular('bellows', 'bellows', 'default'); // Inflector::irregular('buffalo', 'buffaloes', 'default'); // Inflector::irregular('bus', 'buses', 'default'); // Inflector::irregular('bison', 'bison', 'default'); // Inflector::irregular('cactus', 'cacti', 'default'); // Inflector::irregular('cafe', 'cafes', 'default'); // Inflector::irregular('calf', 'calves', 'default'); // Inflector::irregular('cargo', 'cargoes', 'default'); // Inflector::irregular('cattle', 'cattle', 'default'); // Inflector::irregular('child', 'children', 'default'); // Inflector::irregular('congratulations', 'congratulations', 'default'); // Inflector::irregular('corn', 'corn', 'default'); // Inflector::irregular('crisis', 'crises', 'default'); // Inflector::irregular('criteria', 'criterion', 'default'); // Inflector::irregular('curriculum', 'curricula', 'default'); // Inflector::irregular('datum', 'data', 'default'); // Inflector::irregular('deer', 'deer', 'default'); // Inflector::irregular('die', 'dice', 'default'); // Inflector::irregular('dregs', 'dregs', 'default'); // Inflector::irregular('duck', 'duck', 'default'); // Inflector::irregular('echo', 'echos', 'default'); // Inflector::irregular('elf', 'elves', 'default'); // Inflector::irregular('ellipsis', 'ellipses', 'default'); // Inflector::irregular('embargo', 'embargoes', 'default'); // Inflector::irregular('equipment', 'equipment', 'default'); // Inflector::irregular('erratum', 'errata', 'default'); // Inflector::irregular('evidence', 'evidence', 'default'); // Inflector::irregular('eyeglasses', 'eyeglasses', 'default'); // Inflector::irregular('fish', 'fish', 'default'); // Inflector::irregular('focus', 'foci', 'default'); // Inflector::irregular('foot', 'feet', 'default'); // Inflector::irregular('fungus', 'fungi', 'default'); // Inflector::irregular('gallows', 'gallows', 'default'); // Inflector::irregular('genus', 'genera', 'default'); // Inflector::irregular('goose', 'geese', 'default'); // Inflector::irregular('gold', 'gold', 'default'); // Inflector::irregular('grotto', 'grottoes', 'default'); // Inflector::irregular('gymnasium', 'gymnasia', 'default'); // Inflector::irregular('half', 'halves', 'default'); // Inflector::irregular('headquarters', 'headquarters', 'default'); // Inflector::irregular('hoof', 'hooves', 'default'); // Inflector::irregular('hypothesis', 'hypotheses', 'default'); // Inflector::irregular('information', 'information', 'default'); // Inflector::irregular('graffito', 'graffiti', 'default'); // Inflector::irregular('half', 'halves', 'default'); // Inflector::irregular('hero', 'heroes', 'default'); // Inflector::irregular('jewelry', 'jewelry', 'default'); // Inflector::irregular('kin', 'kin', 'default'); // Inflector::irregular('knife', 'knives', 'default'); // Inflector::irregular('larva', 'larvae', 'default'); // Inflector::irregular('leaf', 'leaves', 'default'); // Inflector::irregular('legislation', 'legislation', 'default'); // Inflector::irregular('life', 'lives', 'default'); // Inflector::irregular('loaf', 'loaves', 'default'); // Inflector::irregular('locus', 'loci', 'default'); // Inflector::irregular('louse', 'lice', 'default'); // Inflector::irregular('luck', 'luck', 'default'); // Inflector::irregular('luggage', 'luggage', 'default'); // Inflector::irregular('man', 'men', 'default'); // Inflector::irregular('mathematics', 'mathematics', 'default'); // Inflector::irregular('matrix', 'matrices', 'default'); // Inflector::irregular('means', 'means', 'default'); // Inflector::irregular('measles', 'measles', 'default'); // Inflector::irregular('medium', 'media', 'default'); // Inflector::irregular('memorandum', 'memoranda', 'default'); // Inflector::irregular('money', 'monies', 'default'); // Inflector::irregular('moose', 'moose', 'default'); // Inflector::irregular('mosquito', 'mosquitoes', 'default'); // Inflector::irregular('motto', 'mottoes', 'default'); // Inflector::irregular('mouse', 'mice', 'default'); // Inflector::irregular('mumps', 'mumps', 'default'); // Inflector::irregular('music', 'music', 'default'); // Inflector::irregular('mythos', 'mythoi', 'default'); // Inflector::irregular('nebula', 'nebulae', 'default'); // Inflector::irregular('neurosis', 'neuroses', 'default'); // Inflector::irregular('news', 'news', 'default'); // Inflector::irregular('nucleus', 'nuclei', 'default'); // Inflector::irregular('numen', 'numina', 'default'); // Inflector::irregular('oasis', 'oases', 'default'); // Inflector::irregular('oats', 'oats', 'default'); // Inflector::irregular('octopus', 'octopuses', 'default'); // Inflector::irregular('offspring', 'offspring', 'default'); // Inflector::irregular('ovum', 'ova', 'default'); // Inflector::irregular('ox', 'oxen', 'default'); // Inflector::irregular('pajamas', 'pajamas', 'default'); // Inflector::irregular('pants', 'pants', 'default'); // Inflector::irregular('paralysis', 'paralyses', 'default'); // Inflector::irregular('parenthesis', 'parentheses', 'default'); // Inflector::irregular('person', 'people', 'default'); // Inflector::irregular('phenomenon', 'phenomena', 'default'); // Inflector::irregular('pike', 'pike', 'default'); // Inflector::irregular('plankton', 'plankton', 'default'); // Inflector::irregular('pliers', 'pliers', 'default'); // Inflector::irregular('polyhedron', 'polyhedra', 'default'); // Inflector::irregular('potato', 'potatoes', 'default'); // Inflector::irregular('quiz', 'quizzes', 'default'); // Inflector::irregular('radius', 'radii', 'default'); // Inflector::irregular('roof', 'roofs', 'default'); // Inflector::irregular('salmon', 'salmon', 'default'); // Inflector::irregular('scarf', 'scarves', 'default'); // Inflector::irregular('scissors', 'scissors', 'default'); // Inflector::irregular('self', 'selves', 'default'); // Inflector::irregular('series', 'series', 'default'); // Inflector::irregular('shears', 'shears', 'default'); // Inflector::irregular('sheep', 'sheep', 'default'); // Inflector::irregular('shelf', 'shelves', 'default'); // Inflector::irregular('shorts', 'shorts', 'default'); // Inflector::irregular('silver', 'silver', 'default'); // Inflector::irregular('species', 'species', 'default'); // Inflector::irregular('squid', 'squid', 'default'); // Inflector::irregular('stimulus', 'stimuli', 'default'); // Inflector::irregular('stratum', 'strata', 'default'); // Inflector::irregular('swine', 'swine', 'default'); // Inflector::irregular('syllabus', 'syllabi', 'default'); // Inflector::irregular('synopsis', 'synopses', 'default'); // Inflector::irregular('synthesis', 'syntheses', 'default'); // Inflector::irregular('tax', 'taxes', 'default'); // Inflector::irregular('terminus', 'termini', 'default'); // Inflector::irregular('thesis', 'theses', 'default'); // Inflector::irregular('thief', 'thieves', 'default'); // Inflector::irregular('tomato', 'tomatoes', 'default'); // Inflector::irregular('tongs', 'tongs', 'default'); // Inflector::irregular('tooth', 'teeth', 'default'); // Inflector::irregular('torpedo', 'torpedoes', 'default'); // Inflector::irregular('torus', 'tori', 'default'); // Inflector::irregular('trousers', 'trousers', 'default'); // Inflector::irregular('trout', 'trout', 'default'); // Inflector::irregular('tweezers', 'tweezers', 'default'); // Inflector::irregular('vertebra', 'vertebrae', 'default'); // Inflector::irregular('vertex', 'vertices', 'default'); // Inflector::irregular('vespers', 'vespers', 'default'); // Inflector::irregular('veto', 'vetoes', 'default'); // Inflector::irregular('volcano', 'volcanoes', 'default'); // Inflector::irregular('vortex', 'vortices', 'default'); // Inflector::irregular('vita', 'vitae', 'default'); // Inflector::irregular('virus', 'viri', 'default'); // Inflector::irregular('wheat', 'wheat', 'default'); // Inflector::irregular('wife', 'wives', 'default'); // Inflector::irregular('wolf', 'wolves', 'default'); // Inflector::irregular('woman', 'women', 'default'); // Inflector::irregular('zero', 'zeros', 'default'); }
php
public static function reset($lang = null) { if (is_string($lang)) { unset(static::$_singular[$lang]); unset(static::$_plural[$lang]); return; } static::$_singular = []; static::$_plural = []; if ($lang === true) { return; } /** * Initilalize the class with english inflector rules. */ Inflector::singular('/([^s])s$/i', '\1', 'default'); Inflector::plural('/([^s])$/i', '\1s', 'default'); Inflector::singular('/(x|z|s|ss|ch|sh)es$/i', '\1', 'default'); Inflector::plural('/(x|z|ss|ch|sh)$/i', '\1es', 'default'); Inflector::singular('/ies$/i', 'y', 'default'); Inflector::plural('/([^aeiouy]|qu)y$/i', '\1ies', 'default'); Inflector::plural('/(meta|data)$/i', '\1', 'default'); Inflector::irregular('child', 'children', 'default'); Inflector::irregular('equipment', 'equipment', 'default'); Inflector::irregular('information', 'information', 'default'); Inflector::irregular('man', 'men', 'default'); Inflector::irregular('news', 'news', 'default'); Inflector::irregular('person', 'people', 'default'); Inflector::irregular('woman', 'women', 'default'); /** * Warning, using an "exhastive" list of rules will slow * down all singularizations/pluralizations generations. * So it may be preferable to only add the ones you are actually needed. * * Anyhow bellow a list english exceptions which are not covered by the above rules. */ // Inflector::irregular('advice', 'advice', 'default'); // Inflector::irregular('aircraft', 'aircraft', 'default'); // Inflector::irregular('alias', 'aliases', 'default'); // Inflector::irregular('alga', 'algae', 'default'); // Inflector::irregular('alumna', 'alumnae', 'default'); // Inflector::irregular('alumnus', 'alumni', 'default'); // Inflector::irregular('analysis', 'analyses', 'default'); // Inflector::irregular('antenna', 'antennae', 'default'); // Inflector::irregular('automaton', 'automata', 'default'); // Inflector::irregular('axis', 'axes', 'default'); // Inflector::irregular('bacillus', 'bacilli', 'default'); // Inflector::irregular('bacterium', 'bacteria', 'default'); // Inflector::irregular('barracks', 'barracks', 'default'); // Inflector::irregular('basis', 'bases', 'default'); // Inflector::irregular('bellows', 'bellows', 'default'); // Inflector::irregular('buffalo', 'buffaloes', 'default'); // Inflector::irregular('bus', 'buses', 'default'); // Inflector::irregular('bison', 'bison', 'default'); // Inflector::irregular('cactus', 'cacti', 'default'); // Inflector::irregular('cafe', 'cafes', 'default'); // Inflector::irregular('calf', 'calves', 'default'); // Inflector::irregular('cargo', 'cargoes', 'default'); // Inflector::irregular('cattle', 'cattle', 'default'); // Inflector::irregular('child', 'children', 'default'); // Inflector::irregular('congratulations', 'congratulations', 'default'); // Inflector::irregular('corn', 'corn', 'default'); // Inflector::irregular('crisis', 'crises', 'default'); // Inflector::irregular('criteria', 'criterion', 'default'); // Inflector::irregular('curriculum', 'curricula', 'default'); // Inflector::irregular('datum', 'data', 'default'); // Inflector::irregular('deer', 'deer', 'default'); // Inflector::irregular('die', 'dice', 'default'); // Inflector::irregular('dregs', 'dregs', 'default'); // Inflector::irregular('duck', 'duck', 'default'); // Inflector::irregular('echo', 'echos', 'default'); // Inflector::irregular('elf', 'elves', 'default'); // Inflector::irregular('ellipsis', 'ellipses', 'default'); // Inflector::irregular('embargo', 'embargoes', 'default'); // Inflector::irregular('equipment', 'equipment', 'default'); // Inflector::irregular('erratum', 'errata', 'default'); // Inflector::irregular('evidence', 'evidence', 'default'); // Inflector::irregular('eyeglasses', 'eyeglasses', 'default'); // Inflector::irregular('fish', 'fish', 'default'); // Inflector::irregular('focus', 'foci', 'default'); // Inflector::irregular('foot', 'feet', 'default'); // Inflector::irregular('fungus', 'fungi', 'default'); // Inflector::irregular('gallows', 'gallows', 'default'); // Inflector::irregular('genus', 'genera', 'default'); // Inflector::irregular('goose', 'geese', 'default'); // Inflector::irregular('gold', 'gold', 'default'); // Inflector::irregular('grotto', 'grottoes', 'default'); // Inflector::irregular('gymnasium', 'gymnasia', 'default'); // Inflector::irregular('half', 'halves', 'default'); // Inflector::irregular('headquarters', 'headquarters', 'default'); // Inflector::irregular('hoof', 'hooves', 'default'); // Inflector::irregular('hypothesis', 'hypotheses', 'default'); // Inflector::irregular('information', 'information', 'default'); // Inflector::irregular('graffito', 'graffiti', 'default'); // Inflector::irregular('half', 'halves', 'default'); // Inflector::irregular('hero', 'heroes', 'default'); // Inflector::irregular('jewelry', 'jewelry', 'default'); // Inflector::irregular('kin', 'kin', 'default'); // Inflector::irregular('knife', 'knives', 'default'); // Inflector::irregular('larva', 'larvae', 'default'); // Inflector::irregular('leaf', 'leaves', 'default'); // Inflector::irregular('legislation', 'legislation', 'default'); // Inflector::irregular('life', 'lives', 'default'); // Inflector::irregular('loaf', 'loaves', 'default'); // Inflector::irregular('locus', 'loci', 'default'); // Inflector::irregular('louse', 'lice', 'default'); // Inflector::irregular('luck', 'luck', 'default'); // Inflector::irregular('luggage', 'luggage', 'default'); // Inflector::irregular('man', 'men', 'default'); // Inflector::irregular('mathematics', 'mathematics', 'default'); // Inflector::irregular('matrix', 'matrices', 'default'); // Inflector::irregular('means', 'means', 'default'); // Inflector::irregular('measles', 'measles', 'default'); // Inflector::irregular('medium', 'media', 'default'); // Inflector::irregular('memorandum', 'memoranda', 'default'); // Inflector::irregular('money', 'monies', 'default'); // Inflector::irregular('moose', 'moose', 'default'); // Inflector::irregular('mosquito', 'mosquitoes', 'default'); // Inflector::irregular('motto', 'mottoes', 'default'); // Inflector::irregular('mouse', 'mice', 'default'); // Inflector::irregular('mumps', 'mumps', 'default'); // Inflector::irregular('music', 'music', 'default'); // Inflector::irregular('mythos', 'mythoi', 'default'); // Inflector::irregular('nebula', 'nebulae', 'default'); // Inflector::irregular('neurosis', 'neuroses', 'default'); // Inflector::irregular('news', 'news', 'default'); // Inflector::irregular('nucleus', 'nuclei', 'default'); // Inflector::irregular('numen', 'numina', 'default'); // Inflector::irregular('oasis', 'oases', 'default'); // Inflector::irregular('oats', 'oats', 'default'); // Inflector::irregular('octopus', 'octopuses', 'default'); // Inflector::irregular('offspring', 'offspring', 'default'); // Inflector::irregular('ovum', 'ova', 'default'); // Inflector::irregular('ox', 'oxen', 'default'); // Inflector::irregular('pajamas', 'pajamas', 'default'); // Inflector::irregular('pants', 'pants', 'default'); // Inflector::irregular('paralysis', 'paralyses', 'default'); // Inflector::irregular('parenthesis', 'parentheses', 'default'); // Inflector::irregular('person', 'people', 'default'); // Inflector::irregular('phenomenon', 'phenomena', 'default'); // Inflector::irregular('pike', 'pike', 'default'); // Inflector::irregular('plankton', 'plankton', 'default'); // Inflector::irregular('pliers', 'pliers', 'default'); // Inflector::irregular('polyhedron', 'polyhedra', 'default'); // Inflector::irregular('potato', 'potatoes', 'default'); // Inflector::irregular('quiz', 'quizzes', 'default'); // Inflector::irregular('radius', 'radii', 'default'); // Inflector::irregular('roof', 'roofs', 'default'); // Inflector::irregular('salmon', 'salmon', 'default'); // Inflector::irregular('scarf', 'scarves', 'default'); // Inflector::irregular('scissors', 'scissors', 'default'); // Inflector::irregular('self', 'selves', 'default'); // Inflector::irregular('series', 'series', 'default'); // Inflector::irregular('shears', 'shears', 'default'); // Inflector::irregular('sheep', 'sheep', 'default'); // Inflector::irregular('shelf', 'shelves', 'default'); // Inflector::irregular('shorts', 'shorts', 'default'); // Inflector::irregular('silver', 'silver', 'default'); // Inflector::irregular('species', 'species', 'default'); // Inflector::irregular('squid', 'squid', 'default'); // Inflector::irregular('stimulus', 'stimuli', 'default'); // Inflector::irregular('stratum', 'strata', 'default'); // Inflector::irregular('swine', 'swine', 'default'); // Inflector::irregular('syllabus', 'syllabi', 'default'); // Inflector::irregular('synopsis', 'synopses', 'default'); // Inflector::irregular('synthesis', 'syntheses', 'default'); // Inflector::irregular('tax', 'taxes', 'default'); // Inflector::irregular('terminus', 'termini', 'default'); // Inflector::irregular('thesis', 'theses', 'default'); // Inflector::irregular('thief', 'thieves', 'default'); // Inflector::irregular('tomato', 'tomatoes', 'default'); // Inflector::irregular('tongs', 'tongs', 'default'); // Inflector::irregular('tooth', 'teeth', 'default'); // Inflector::irregular('torpedo', 'torpedoes', 'default'); // Inflector::irregular('torus', 'tori', 'default'); // Inflector::irregular('trousers', 'trousers', 'default'); // Inflector::irregular('trout', 'trout', 'default'); // Inflector::irregular('tweezers', 'tweezers', 'default'); // Inflector::irregular('vertebra', 'vertebrae', 'default'); // Inflector::irregular('vertex', 'vertices', 'default'); // Inflector::irregular('vespers', 'vespers', 'default'); // Inflector::irregular('veto', 'vetoes', 'default'); // Inflector::irregular('volcano', 'volcanoes', 'default'); // Inflector::irregular('vortex', 'vortices', 'default'); // Inflector::irregular('vita', 'vitae', 'default'); // Inflector::irregular('virus', 'viri', 'default'); // Inflector::irregular('wheat', 'wheat', 'default'); // Inflector::irregular('wife', 'wives', 'default'); // Inflector::irregular('wolf', 'wolves', 'default'); // Inflector::irregular('woman', 'women', 'default'); // Inflector::irregular('zero', 'zeros', 'default'); }
[ "public", "static", "function", "reset", "(", "$", "lang", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "lang", ")", ")", "{", "unset", "(", "static", "::", "$", "_singular", "[", "$", "lang", "]", ")", ";", "unset", "(", "static", "::", "$", "_plural", "[", "$", "lang", "]", ")", ";", "return", ";", "}", "static", "::", "$", "_singular", "=", "[", "]", ";", "static", "::", "$", "_plural", "=", "[", "]", ";", "if", "(", "$", "lang", "===", "true", ")", "{", "return", ";", "}", "/**\n * Initilalize the class with english inflector rules.\n */", "Inflector", "::", "singular", "(", "'/([^s])s$/i'", ",", "'\\1'", ",", "'default'", ")", ";", "Inflector", "::", "plural", "(", "'/([^s])$/i'", ",", "'\\1s'", ",", "'default'", ")", ";", "Inflector", "::", "singular", "(", "'/(x|z|s|ss|ch|sh)es$/i'", ",", "'\\1'", ",", "'default'", ")", ";", "Inflector", "::", "plural", "(", "'/(x|z|ss|ch|sh)$/i'", ",", "'\\1es'", ",", "'default'", ")", ";", "Inflector", "::", "singular", "(", "'/ies$/i'", ",", "'y'", ",", "'default'", ")", ";", "Inflector", "::", "plural", "(", "'/([^aeiouy]|qu)y$/i'", ",", "'\\1ies'", ",", "'default'", ")", ";", "Inflector", "::", "plural", "(", "'/(meta|data)$/i'", ",", "'\\1'", ",", "'default'", ")", ";", "Inflector", "::", "irregular", "(", "'child'", ",", "'children'", ",", "'default'", ")", ";", "Inflector", "::", "irregular", "(", "'equipment'", ",", "'equipment'", ",", "'default'", ")", ";", "Inflector", "::", "irregular", "(", "'information'", ",", "'information'", ",", "'default'", ")", ";", "Inflector", "::", "irregular", "(", "'man'", ",", "'men'", ",", "'default'", ")", ";", "Inflector", "::", "irregular", "(", "'news'", ",", "'news'", ",", "'default'", ")", ";", "Inflector", "::", "irregular", "(", "'person'", ",", "'people'", ",", "'default'", ")", ";", "Inflector", "::", "irregular", "(", "'woman'", ",", "'women'", ",", "'default'", ")", ";", "/**\n * Warning, using an \"exhastive\" list of rules will slow\n * down all singularizations/pluralizations generations.\n * So it may be preferable to only add the ones you are actually needed.\n *\n * Anyhow bellow a list english exceptions which are not covered by the above rules.\n */", "// Inflector::irregular('advice', 'advice', 'default');", "// Inflector::irregular('aircraft', 'aircraft', 'default');", "// Inflector::irregular('alias', 'aliases', 'default');", "// Inflector::irregular('alga', 'algae', 'default');", "// Inflector::irregular('alumna', 'alumnae', 'default');", "// Inflector::irregular('alumnus', 'alumni', 'default');", "// Inflector::irregular('analysis', 'analyses', 'default');", "// Inflector::irregular('antenna', 'antennae', 'default');", "// Inflector::irregular('automaton', 'automata', 'default');", "// Inflector::irregular('axis', 'axes', 'default');", "// Inflector::irregular('bacillus', 'bacilli', 'default');", "// Inflector::irregular('bacterium', 'bacteria', 'default');", "// Inflector::irregular('barracks', 'barracks', 'default');", "// Inflector::irregular('basis', 'bases', 'default');", "// Inflector::irregular('bellows', 'bellows', 'default');", "// Inflector::irregular('buffalo', 'buffaloes', 'default');", "// Inflector::irregular('bus', 'buses', 'default');", "// Inflector::irregular('bison', 'bison', 'default');", "// Inflector::irregular('cactus', 'cacti', 'default');", "// Inflector::irregular('cafe', 'cafes', 'default');", "// Inflector::irregular('calf', 'calves', 'default');", "// Inflector::irregular('cargo', 'cargoes', 'default');", "// Inflector::irregular('cattle', 'cattle', 'default');", "// Inflector::irregular('child', 'children', 'default');", "// Inflector::irregular('congratulations', 'congratulations', 'default');", "// Inflector::irregular('corn', 'corn', 'default');", "// Inflector::irregular('crisis', 'crises', 'default');", "// Inflector::irregular('criteria', 'criterion', 'default');", "// Inflector::irregular('curriculum', 'curricula', 'default');", "// Inflector::irregular('datum', 'data', 'default');", "// Inflector::irregular('deer', 'deer', 'default');", "// Inflector::irregular('die', 'dice', 'default');", "// Inflector::irregular('dregs', 'dregs', 'default');", "// Inflector::irregular('duck', 'duck', 'default');", "// Inflector::irregular('echo', 'echos', 'default');", "// Inflector::irregular('elf', 'elves', 'default');", "// Inflector::irregular('ellipsis', 'ellipses', 'default');", "// Inflector::irregular('embargo', 'embargoes', 'default');", "// Inflector::irregular('equipment', 'equipment', 'default');", "// Inflector::irregular('erratum', 'errata', 'default');", "// Inflector::irregular('evidence', 'evidence', 'default');", "// Inflector::irregular('eyeglasses', 'eyeglasses', 'default');", "// Inflector::irregular('fish', 'fish', 'default');", "// Inflector::irregular('focus', 'foci', 'default');", "// Inflector::irregular('foot', 'feet', 'default');", "// Inflector::irregular('fungus', 'fungi', 'default');", "// Inflector::irregular('gallows', 'gallows', 'default');", "// Inflector::irregular('genus', 'genera', 'default');", "// Inflector::irregular('goose', 'geese', 'default');", "// Inflector::irregular('gold', 'gold', 'default');", "// Inflector::irregular('grotto', 'grottoes', 'default');", "// Inflector::irregular('gymnasium', 'gymnasia', 'default');", "// Inflector::irregular('half', 'halves', 'default');", "// Inflector::irregular('headquarters', 'headquarters', 'default');", "// Inflector::irregular('hoof', 'hooves', 'default');", "// Inflector::irregular('hypothesis', 'hypotheses', 'default');", "// Inflector::irregular('information', 'information', 'default');", "// Inflector::irregular('graffito', 'graffiti', 'default');", "// Inflector::irregular('half', 'halves', 'default');", "// Inflector::irregular('hero', 'heroes', 'default');", "// Inflector::irregular('jewelry', 'jewelry', 'default');", "// Inflector::irregular('kin', 'kin', 'default');", "// Inflector::irregular('knife', 'knives', 'default');", "// Inflector::irregular('larva', 'larvae', 'default');", "// Inflector::irregular('leaf', 'leaves', 'default');", "// Inflector::irregular('legislation', 'legislation', 'default');", "// Inflector::irregular('life', 'lives', 'default');", "// Inflector::irregular('loaf', 'loaves', 'default');", "// Inflector::irregular('locus', 'loci', 'default');", "// Inflector::irregular('louse', 'lice', 'default');", "// Inflector::irregular('luck', 'luck', 'default');", "// Inflector::irregular('luggage', 'luggage', 'default');", "// Inflector::irregular('man', 'men', 'default');", "// Inflector::irregular('mathematics', 'mathematics', 'default');", "// Inflector::irregular('matrix', 'matrices', 'default');", "// Inflector::irregular('means', 'means', 'default');", "// Inflector::irregular('measles', 'measles', 'default');", "// Inflector::irregular('medium', 'media', 'default');", "// Inflector::irregular('memorandum', 'memoranda', 'default');", "// Inflector::irregular('money', 'monies', 'default');", "// Inflector::irregular('moose', 'moose', 'default');", "// Inflector::irregular('mosquito', 'mosquitoes', 'default');", "// Inflector::irregular('motto', 'mottoes', 'default');", "// Inflector::irregular('mouse', 'mice', 'default');", "// Inflector::irregular('mumps', 'mumps', 'default');", "// Inflector::irregular('music', 'music', 'default');", "// Inflector::irregular('mythos', 'mythoi', 'default');", "// Inflector::irregular('nebula', 'nebulae', 'default');", "// Inflector::irregular('neurosis', 'neuroses', 'default');", "// Inflector::irregular('news', 'news', 'default');", "// Inflector::irregular('nucleus', 'nuclei', 'default');", "// Inflector::irregular('numen', 'numina', 'default');", "// Inflector::irregular('oasis', 'oases', 'default');", "// Inflector::irregular('oats', 'oats', 'default');", "// Inflector::irregular('octopus', 'octopuses', 'default');", "// Inflector::irregular('offspring', 'offspring', 'default');", "// Inflector::irregular('ovum', 'ova', 'default');", "// Inflector::irregular('ox', 'oxen', 'default');", "// Inflector::irregular('pajamas', 'pajamas', 'default');", "// Inflector::irregular('pants', 'pants', 'default');", "// Inflector::irregular('paralysis', 'paralyses', 'default');", "// Inflector::irregular('parenthesis', 'parentheses', 'default');", "// Inflector::irregular('person', 'people', 'default');", "// Inflector::irregular('phenomenon', 'phenomena', 'default');", "// Inflector::irregular('pike', 'pike', 'default');", "// Inflector::irregular('plankton', 'plankton', 'default');", "// Inflector::irregular('pliers', 'pliers', 'default');", "// Inflector::irregular('polyhedron', 'polyhedra', 'default');", "// Inflector::irregular('potato', 'potatoes', 'default');", "// Inflector::irregular('quiz', 'quizzes', 'default');", "// Inflector::irregular('radius', 'radii', 'default');", "// Inflector::irregular('roof', 'roofs', 'default');", "// Inflector::irregular('salmon', 'salmon', 'default');", "// Inflector::irregular('scarf', 'scarves', 'default');", "// Inflector::irregular('scissors', 'scissors', 'default');", "// Inflector::irregular('self', 'selves', 'default');", "// Inflector::irregular('series', 'series', 'default');", "// Inflector::irregular('shears', 'shears', 'default');", "// Inflector::irregular('sheep', 'sheep', 'default');", "// Inflector::irregular('shelf', 'shelves', 'default');", "// Inflector::irregular('shorts', 'shorts', 'default');", "// Inflector::irregular('silver', 'silver', 'default');", "// Inflector::irregular('species', 'species', 'default');", "// Inflector::irregular('squid', 'squid', 'default');", "// Inflector::irregular('stimulus', 'stimuli', 'default');", "// Inflector::irregular('stratum', 'strata', 'default');", "// Inflector::irregular('swine', 'swine', 'default');", "// Inflector::irregular('syllabus', 'syllabi', 'default');", "// Inflector::irregular('synopsis', 'synopses', 'default');", "// Inflector::irregular('synthesis', 'syntheses', 'default');", "// Inflector::irregular('tax', 'taxes', 'default');", "// Inflector::irregular('terminus', 'termini', 'default');", "// Inflector::irregular('thesis', 'theses', 'default');", "// Inflector::irregular('thief', 'thieves', 'default');", "// Inflector::irregular('tomato', 'tomatoes', 'default');", "// Inflector::irregular('tongs', 'tongs', 'default');", "// Inflector::irregular('tooth', 'teeth', 'default');", "// Inflector::irregular('torpedo', 'torpedoes', 'default');", "// Inflector::irregular('torus', 'tori', 'default');", "// Inflector::irregular('trousers', 'trousers', 'default');", "// Inflector::irregular('trout', 'trout', 'default');", "// Inflector::irregular('tweezers', 'tweezers', 'default');", "// Inflector::irregular('vertebra', 'vertebrae', 'default');", "// Inflector::irregular('vertex', 'vertices', 'default');", "// Inflector::irregular('vespers', 'vespers', 'default');", "// Inflector::irregular('veto', 'vetoes', 'default');", "// Inflector::irregular('volcano', 'volcanoes', 'default');", "// Inflector::irregular('vortex', 'vortices', 'default');", "// Inflector::irregular('vita', 'vitae', 'default');", "// Inflector::irregular('virus', 'viri', 'default');", "// Inflector::irregular('wheat', 'wheat', 'default');", "// Inflector::irregular('wife', 'wives', 'default');", "// Inflector::irregular('wolf', 'wolves', 'default');", "// Inflector::irregular('woman', 'women', 'default');", "// Inflector::irregular('zero', 'zeros', 'default');", "}" ]
Clears all inflection rules. @param string|boolean $lang The language name to reset or `true` to reset all even defaults.
[ "Clears", "all", "inflection", "rules", "." ]
07a890c43debebcfaeffe1c30a504f954e9a463c
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L266-L464
21,460
ShaoZeMing/laravel-merchant
src/Form/Field/HasMany.php
HasMany.setupScriptForDefaultView
protected function setupScriptForDefaultView($templateScript) { $removeClass = NestedForm::REMOVE_FLAG_CLASS; $defaultKey = NestedForm::DEFAULT_KEY_NAME; /** * When add a new sub form, replace all element key in new sub form. * * @example comments[new___key__][title] => comments[new_{index}][title] * * {count} is increment number of current sub form count. */ $script = <<<EOT var index = 0; $('#has-many-{$this->column}').on('click', '.add', function () { var tpl = $('template.{$this->column}-tpl'); index++; var template = tpl.html().replace(/{$defaultKey}/g, index); $('.has-many-{$this->column}-forms').append(template); {$templateScript} }); $('#has-many-{$this->column}').on('click', '.remove', function () { $(this).closest('.has-many-{$this->column}-form').hide(); $(this).closest('.has-many-{$this->column}-form').find('.$removeClass').val(1); }); EOT; Merchant::script($script); }
php
protected function setupScriptForDefaultView($templateScript) { $removeClass = NestedForm::REMOVE_FLAG_CLASS; $defaultKey = NestedForm::DEFAULT_KEY_NAME; /** * When add a new sub form, replace all element key in new sub form. * * @example comments[new___key__][title] => comments[new_{index}][title] * * {count} is increment number of current sub form count. */ $script = <<<EOT var index = 0; $('#has-many-{$this->column}').on('click', '.add', function () { var tpl = $('template.{$this->column}-tpl'); index++; var template = tpl.html().replace(/{$defaultKey}/g, index); $('.has-many-{$this->column}-forms').append(template); {$templateScript} }); $('#has-many-{$this->column}').on('click', '.remove', function () { $(this).closest('.has-many-{$this->column}-form').hide(); $(this).closest('.has-many-{$this->column}-form').find('.$removeClass').val(1); }); EOT; Merchant::script($script); }
[ "protected", "function", "setupScriptForDefaultView", "(", "$", "templateScript", ")", "{", "$", "removeClass", "=", "NestedForm", "::", "REMOVE_FLAG_CLASS", ";", "$", "defaultKey", "=", "NestedForm", "::", "DEFAULT_KEY_NAME", ";", "/**\n * When add a new sub form, replace all element key in new sub form.\n *\n * @example comments[new___key__][title] => comments[new_{index}][title]\n *\n * {count} is increment number of current sub form count.\n */", "$", "script", "=", " <<<EOT\nvar index = 0;\n$('#has-many-{$this->column}').on('click', '.add', function () {\n\n var tpl = $('template.{$this->column}-tpl');\n\n index++;\n\n var template = tpl.html().replace(/{$defaultKey}/g, index);\n $('.has-many-{$this->column}-forms').append(template);\n {$templateScript}\n});\n\n$('#has-many-{$this->column}').on('click', '.remove', function () {\n $(this).closest('.has-many-{$this->column}-form').hide();\n $(this).closest('.has-many-{$this->column}-form').find('.$removeClass').val(1);\n});\n\nEOT", ";", "Merchant", "::", "script", "(", "$", "script", ")", ";", "}" ]
Setup default template script. @param string $templateScript @return void
[ "Setup", "default", "template", "script", "." ]
20801b1735e7832a6e58b37c2c391328f8d626fa
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Form/Field/HasMany.php#L391-L424
21,461
dragonmantank/fillet
src/Fillet/Parser/WordpressExport.php
WordpressExport.parse
public function parse($inputFile) { $DCNamespace = 'http://purl.org/rss/1.0/modules/content/'; $WPNamespace = 'http://wordpress.org/export/1.2/'; $reader = new \XMLReader(); $dom = new \DOMDocument('1.0', 'UTF-8'); $reader->open($inputFile); while ($reader->read() && $reader->name !== 'item'); while($reader->name == 'item') { $xml = simplexml_import_dom($dom->importNode($reader->expand(), true)); $wpItems = $xml->children($WPNamespace); $content = $xml->children($DCNamespace)->encoded; $categories = []; $tags = []; foreach($xml->category as $category) { if('category' == $category->attributes()->domain) { $categories[] = (string)$category; } if('post_tag' == $category->attributes()->domain) { $tags[] = (string)$category; } } if($wpItems) { $post_type = (string)$wpItems->post_type; $data = [ 'type' => $post_type, 'post_date' => new \DateTime((string)$wpItems->post_date), 'title' => (string)$xml->title, 'content' => (string)$content, 'tags' => $tags, 'categories' => $categories, ]; yield $data; } $reader->next('item'); } }
php
public function parse($inputFile) { $DCNamespace = 'http://purl.org/rss/1.0/modules/content/'; $WPNamespace = 'http://wordpress.org/export/1.2/'; $reader = new \XMLReader(); $dom = new \DOMDocument('1.0', 'UTF-8'); $reader->open($inputFile); while ($reader->read() && $reader->name !== 'item'); while($reader->name == 'item') { $xml = simplexml_import_dom($dom->importNode($reader->expand(), true)); $wpItems = $xml->children($WPNamespace); $content = $xml->children($DCNamespace)->encoded; $categories = []; $tags = []; foreach($xml->category as $category) { if('category' == $category->attributes()->domain) { $categories[] = (string)$category; } if('post_tag' == $category->attributes()->domain) { $tags[] = (string)$category; } } if($wpItems) { $post_type = (string)$wpItems->post_type; $data = [ 'type' => $post_type, 'post_date' => new \DateTime((string)$wpItems->post_date), 'title' => (string)$xml->title, 'content' => (string)$content, 'tags' => $tags, 'categories' => $categories, ]; yield $data; } $reader->next('item'); } }
[ "public", "function", "parse", "(", "$", "inputFile", ")", "{", "$", "DCNamespace", "=", "'http://purl.org/rss/1.0/modules/content/'", ";", "$", "WPNamespace", "=", "'http://wordpress.org/export/1.2/'", ";", "$", "reader", "=", "new", "\\", "XMLReader", "(", ")", ";", "$", "dom", "=", "new", "\\", "DOMDocument", "(", "'1.0'", ",", "'UTF-8'", ")", ";", "$", "reader", "->", "open", "(", "$", "inputFile", ")", ";", "while", "(", "$", "reader", "->", "read", "(", ")", "&&", "$", "reader", "->", "name", "!==", "'item'", ")", ";", "while", "(", "$", "reader", "->", "name", "==", "'item'", ")", "{", "$", "xml", "=", "simplexml_import_dom", "(", "$", "dom", "->", "importNode", "(", "$", "reader", "->", "expand", "(", ")", ",", "true", ")", ")", ";", "$", "wpItems", "=", "$", "xml", "->", "children", "(", "$", "WPNamespace", ")", ";", "$", "content", "=", "$", "xml", "->", "children", "(", "$", "DCNamespace", ")", "->", "encoded", ";", "$", "categories", "=", "[", "]", ";", "$", "tags", "=", "[", "]", ";", "foreach", "(", "$", "xml", "->", "category", "as", "$", "category", ")", "{", "if", "(", "'category'", "==", "$", "category", "->", "attributes", "(", ")", "->", "domain", ")", "{", "$", "categories", "[", "]", "=", "(", "string", ")", "$", "category", ";", "}", "if", "(", "'post_tag'", "==", "$", "category", "->", "attributes", "(", ")", "->", "domain", ")", "{", "$", "tags", "[", "]", "=", "(", "string", ")", "$", "category", ";", "}", "}", "if", "(", "$", "wpItems", ")", "{", "$", "post_type", "=", "(", "string", ")", "$", "wpItems", "->", "post_type", ";", "$", "data", "=", "[", "'type'", "=>", "$", "post_type", ",", "'post_date'", "=>", "new", "\\", "DateTime", "(", "(", "string", ")", "$", "wpItems", "->", "post_date", ")", ",", "'title'", "=>", "(", "string", ")", "$", "xml", "->", "title", ",", "'content'", "=>", "(", "string", ")", "$", "content", ",", "'tags'", "=>", "$", "tags", ",", "'categories'", "=>", "$", "categories", ",", "]", ";", "yield", "$", "data", ";", "}", "$", "reader", "->", "next", "(", "'item'", ")", ";", "}", "}" ]
Parses a specific XML file @param string $inputFile File to parse @return \Generator
[ "Parses", "a", "specific", "XML", "file" ]
b197947608c05ac2318e8f6b296345494004d9c6
https://github.com/dragonmantank/fillet/blob/b197947608c05ac2318e8f6b296345494004d9c6/src/Fillet/Parser/WordpressExport.php#L18-L61
21,462
david-mk/mail-map
src/MailMap/MailMap.php
MailMap.query
public function query($inbox = 'INBOX', callable $queryCall = null) { $query = new Query; if (!is_null($queryCall)) { $query = $queryCall($query); } return $query->get($this->factory->create($inbox), $this->mailFactory); }
php
public function query($inbox = 'INBOX', callable $queryCall = null) { $query = new Query; if (!is_null($queryCall)) { $query = $queryCall($query); } return $query->get($this->factory->create($inbox), $this->mailFactory); }
[ "public", "function", "query", "(", "$", "inbox", "=", "'INBOX'", ",", "callable", "$", "queryCall", "=", "null", ")", "{", "$", "query", "=", "new", "Query", ";", "if", "(", "!", "is_null", "(", "$", "queryCall", ")", ")", "{", "$", "query", "=", "$", "queryCall", "(", "$", "query", ")", ";", "}", "return", "$", "query", "->", "get", "(", "$", "this", "->", "factory", "->", "create", "(", "$", "inbox", ")", ",", "$", "this", "->", "mailFactory", ")", ";", "}" ]
Execute query on a new connection and wrap results in Mail wrappers. Provide a callable to set conditions, sorting, and limits on query. The query instance will be provided as the single arguement to the callable. @param string $inbox @param callable $queryCall @return array
[ "Execute", "query", "on", "a", "new", "connection", "and", "wrap", "results", "in", "Mail", "wrappers", "." ]
4eea346ece9fa35c0d309b5a909f657ad83e1e6a
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailMap.php#L53-L62
21,463
ekuiter/feature-php
FeaturePhp/Model/XmlConfiguration.php
XmlConfiguration.fromString
public static function fromString($str, $directory = null) { return new self((new fphp\Helper\XmlParser())->parseString($str)); }
php
public static function fromString($str, $directory = null) { return new self((new fphp\Helper\XmlParser())->parseString($str)); }
[ "public", "static", "function", "fromString", "(", "$", "str", ",", "$", "directory", "=", "null", ")", "{", "return", "new", "self", "(", "(", "new", "fphp", "\\", "Helper", "\\", "XmlParser", "(", ")", ")", "->", "parseString", "(", "$", "str", ")", ")", ";", "}" ]
Creates an XML configuration from an XML string. @param string $str @param string $directory ignored @return XmlConfiguration
[ "Creates", "an", "XML", "configuration", "from", "an", "XML", "string", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/XmlConfiguration.php#L85-L87
21,464
shabbyrobe/amiss
src/Sql/Type/Date.php
Date.prepareDateTime
protected function prepareDateTime($value) { if ($this->requireAppTimeZone && !static::timeZoneEqual($value->getTimeZone(), $this->appTimeZone)) { // Actually performing this conversion may not be an issue. Wait // until it is raised before making a decision. throw new \UnexpectedValueException( "Incoming time zone {$value->getTimeZone()->getName()} did not match app time zone {$this->appTimeZone->getName()}" ); } $value = clone $value; $value = $value->setTimeZone($this->dbTimeZone); if ($this->forceTime) { $value = $value->setTime(...$this->forceTime); } return $value; }
php
protected function prepareDateTime($value) { if ($this->requireAppTimeZone && !static::timeZoneEqual($value->getTimeZone(), $this->appTimeZone)) { // Actually performing this conversion may not be an issue. Wait // until it is raised before making a decision. throw new \UnexpectedValueException( "Incoming time zone {$value->getTimeZone()->getName()} did not match app time zone {$this->appTimeZone->getName()}" ); } $value = clone $value; $value = $value->setTimeZone($this->dbTimeZone); if ($this->forceTime) { $value = $value->setTime(...$this->forceTime); } return $value; }
[ "protected", "function", "prepareDateTime", "(", "$", "value", ")", "{", "if", "(", "$", "this", "->", "requireAppTimeZone", "&&", "!", "static", "::", "timeZoneEqual", "(", "$", "value", "->", "getTimeZone", "(", ")", ",", "$", "this", "->", "appTimeZone", ")", ")", "{", "// Actually performing this conversion may not be an issue. Wait", "// until it is raised before making a decision.", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Incoming time zone {$value->getTimeZone()->getName()} did not match app time zone {$this->appTimeZone->getName()}\"", ")", ";", "}", "$", "value", "=", "clone", "$", "value", ";", "$", "value", "=", "$", "value", "->", "setTimeZone", "(", "$", "this", "->", "dbTimeZone", ")", ";", "if", "(", "$", "this", "->", "forceTime", ")", "{", "$", "value", "=", "$", "value", "->", "setTime", "(", "...", "$", "this", "->", "forceTime", ")", ";", "}", "return", "$", "value", ";", "}" ]
Don't type hint here - there's no common interface between DateTime and DateTimeImmutable at 5.6 that supports all the methods we are using, though both objects remain largely interchangeable.
[ "Don", "t", "type", "hint", "here", "-", "there", "s", "no", "common", "interface", "between", "DateTime", "and", "DateTimeImmutable", "at", "5", ".", "6", "that", "supports", "all", "the", "methods", "we", "are", "using", "though", "both", "objects", "remain", "largely", "interchangeable", "." ]
ba261f0d1f985ed36e9fd2903ac0df86c5b9498d
https://github.com/shabbyrobe/amiss/blob/ba261f0d1f985ed36e9fd2903ac0df86c5b9498d/src/Sql/Type/Date.php#L140-L155
21,465
soloproyectos-php/text-parser
src/text/parser/TextParser.php
TextParser.is
protected function is($methodName /*, $arg1, $arg2, $arg3 ... */) { if (!method_exists($this, $methodName)) { throw new TextParserException( "The method `$methodName` does not exist" ); } if (!is_callable(array($this, $methodName))) { throw new TextParserException( "The method `$methodName` is inaccessible" ); } // saves offset $offset = $this->offset; // calls user function $ret = call_user_func_array( array($this, $methodName), array_slice(func_get_args(), 1) ); // restores offset if (!$ret) { $this->offset = $offset; } return $ret; }
php
protected function is($methodName /*, $arg1, $arg2, $arg3 ... */) { if (!method_exists($this, $methodName)) { throw new TextParserException( "The method `$methodName` does not exist" ); } if (!is_callable(array($this, $methodName))) { throw new TextParserException( "The method `$methodName` is inaccessible" ); } // saves offset $offset = $this->offset; // calls user function $ret = call_user_func_array( array($this, $methodName), array_slice(func_get_args(), 1) ); // restores offset if (!$ret) { $this->offset = $offset; } return $ret; }
[ "protected", "function", "is", "(", "$", "methodName", "/*, $arg1, $arg2, $arg3 ... */", ")", "{", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "methodName", ")", ")", "{", "throw", "new", "TextParserException", "(", "\"The method `$methodName` does not exist\"", ")", ";", "}", "if", "(", "!", "is_callable", "(", "array", "(", "$", "this", ",", "$", "methodName", ")", ")", ")", "{", "throw", "new", "TextParserException", "(", "\"The method `$methodName` is inaccessible\"", ")", ";", "}", "// saves offset", "$", "offset", "=", "$", "this", "->", "offset", ";", "// calls user function", "$", "ret", "=", "call_user_func_array", "(", "array", "(", "$", "this", ",", "$", "methodName", ")", ",", "array_slice", "(", "func_get_args", "(", ")", ",", "1", ")", ")", ";", "// restores offset", "if", "(", "!", "$", "ret", ")", "{", "$", "this", "->", "offset", "=", "$", "offset", ";", "}", "return", "$", "ret", ";", "}" ]
Does the next thing satisfies a given method? Matches the string against a function and moves the offset forward if the function returns true. @param string $methodName Method name @throws TextParserException @return mixed
[ "Does", "the", "next", "thing", "satisfies", "a", "given", "method?" ]
3ef2e8a26f7c53b170383d74ccf4106b0f3dd8b1
https://github.com/soloproyectos-php/text-parser/blob/3ef2e8a26f7c53b170383d74ccf4106b0f3dd8b1/src/text/parser/TextParser.php#L132-L161
21,466
activecollab/controller
src/Controller.php
Controller.getControllerName
public function getControllerName() { if (empty($this->controller_name)) { $controller_class = get_class($this); if (($pos = strrpos($controller_class, '\\')) !== false) { $this->controller_name = substr($controller_class, $pos + 1); } else { $this->controller_name = $controller_class; } } return $this->controller_name; }
php
public function getControllerName() { if (empty($this->controller_name)) { $controller_class = get_class($this); if (($pos = strrpos($controller_class, '\\')) !== false) { $this->controller_name = substr($controller_class, $pos + 1); } else { $this->controller_name = $controller_class; } } return $this->controller_name; }
[ "public", "function", "getControllerName", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "controller_name", ")", ")", "{", "$", "controller_class", "=", "get_class", "(", "$", "this", ")", ";", "if", "(", "(", "$", "pos", "=", "strrpos", "(", "$", "controller_class", ",", "'\\\\'", ")", ")", "!==", "false", ")", "{", "$", "this", "->", "controller_name", "=", "substr", "(", "$", "controller_class", ",", "$", "pos", "+", "1", ")", ";", "}", "else", "{", "$", "this", "->", "controller_name", "=", "$", "controller_class", ";", "}", "}", "return", "$", "this", "->", "controller_name", ";", "}" ]
Return controller name, without namespace. @return string
[ "Return", "controller", "name", "without", "namespace", "." ]
51d24f3f203f7f5ae56edde2e35b5ef2d9293caa
https://github.com/activecollab/controller/blob/51d24f3f203f7f5ae56edde2e35b5ef2d9293caa/src/Controller.php#L165-L178
21,467
activecollab/controller
src/Controller.php
Controller.getParsedBodyParam
protected function getParsedBodyParam(ServerRequestInterface $request, $param_name, $default = null) { $parsed_body = $request->getParsedBody(); if ($parsed_body) { if (is_array($parsed_body) && array_key_exists($param_name, $parsed_body)) { return $parsed_body[$param_name]; } elseif (is_object($parsed_body) && property_exists($parsed_body, $param_name)) { return $parsed_body->$param_name; } } return $default; }
php
protected function getParsedBodyParam(ServerRequestInterface $request, $param_name, $default = null) { $parsed_body = $request->getParsedBody(); if ($parsed_body) { if (is_array($parsed_body) && array_key_exists($param_name, $parsed_body)) { return $parsed_body[$param_name]; } elseif (is_object($parsed_body) && property_exists($parsed_body, $param_name)) { return $parsed_body->$param_name; } } return $default; }
[ "protected", "function", "getParsedBodyParam", "(", "ServerRequestInterface", "$", "request", ",", "$", "param_name", ",", "$", "default", "=", "null", ")", "{", "$", "parsed_body", "=", "$", "request", "->", "getParsedBody", "(", ")", ";", "if", "(", "$", "parsed_body", ")", "{", "if", "(", "is_array", "(", "$", "parsed_body", ")", "&&", "array_key_exists", "(", "$", "param_name", ",", "$", "parsed_body", ")", ")", "{", "return", "$", "parsed_body", "[", "$", "param_name", "]", ";", "}", "elseif", "(", "is_object", "(", "$", "parsed_body", ")", "&&", "property_exists", "(", "$", "parsed_body", ",", "$", "param_name", ")", ")", "{", "return", "$", "parsed_body", "->", "$", "param_name", ";", "}", "}", "return", "$", "default", ";", "}" ]
Return a param from a parsed body. This method is NULL or object safe - it will check for body type, and do it's best to return a value without breaking or throwing a warning. @param ServerRequestInterface $request @param $param_name @param null $default @return mixed|null
[ "Return", "a", "param", "from", "a", "parsed", "body", "." ]
51d24f3f203f7f5ae56edde2e35b5ef2d9293caa
https://github.com/activecollab/controller/blob/51d24f3f203f7f5ae56edde2e35b5ef2d9293caa/src/Controller.php#L230-L243
21,468
eghojansu/moe
src/tools/web/Geo.php
Geo.tzinfo
function tzinfo($zone) { $ref=new DateTimeZone($zone); $loc=$ref->getLocation(); $trn=$ref->getTransitions($now=time(),$now); $out=array( 'offset'=>$ref-> getOffset(new DateTime('now',new DateTimeZone('GMT')))/3600, 'country'=>$loc['country_code'], 'latitude'=>$loc['latitude'], 'longitude'=>$loc['longitude'], 'dst'=>$trn[0]['isdst'] ); unset($ref); return $out; }
php
function tzinfo($zone) { $ref=new DateTimeZone($zone); $loc=$ref->getLocation(); $trn=$ref->getTransitions($now=time(),$now); $out=array( 'offset'=>$ref-> getOffset(new DateTime('now',new DateTimeZone('GMT')))/3600, 'country'=>$loc['country_code'], 'latitude'=>$loc['latitude'], 'longitude'=>$loc['longitude'], 'dst'=>$trn[0]['isdst'] ); unset($ref); return $out; }
[ "function", "tzinfo", "(", "$", "zone", ")", "{", "$", "ref", "=", "new", "DateTimeZone", "(", "$", "zone", ")", ";", "$", "loc", "=", "$", "ref", "->", "getLocation", "(", ")", ";", "$", "trn", "=", "$", "ref", "->", "getTransitions", "(", "$", "now", "=", "time", "(", ")", ",", "$", "now", ")", ";", "$", "out", "=", "array", "(", "'offset'", "=>", "$", "ref", "->", "getOffset", "(", "new", "DateTime", "(", "'now'", ",", "new", "DateTimeZone", "(", "'GMT'", ")", ")", ")", "/", "3600", ",", "'country'", "=>", "$", "loc", "[", "'country_code'", "]", ",", "'latitude'", "=>", "$", "loc", "[", "'latitude'", "]", ",", "'longitude'", "=>", "$", "loc", "[", "'longitude'", "]", ",", "'dst'", "=>", "$", "trn", "[", "0", "]", "[", "'isdst'", "]", ")", ";", "unset", "(", "$", "ref", ")", ";", "return", "$", "out", ";", "}" ]
Return information about specified Unix time zone @return array @param $zone string
[ "Return", "information", "about", "specified", "Unix", "time", "zone" ]
f58ec75a3116d1a572782256e2b38bb9aab95e3c
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/web/Geo.php#L19-L33
21,469
surebert/surebert-framework
src/sb/Controller/Google/Auth.php
Auth.login
public function login(){ if ($this->getGet('code')) { $this->client->authenticate($this->getGet('code')); $this->setSession('token', $this->client->getAccessToken()); $redirect = $this->config->redirect_uris[0]; header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); return; } $token = $this->getSession('token'); if ($token) { $this->client->setAccessToken($token); } if ($this->client->getAccessToken()) { $user = $this->oauth2_service->userinfo->get(); $this->setSession('token', $this->client->getAccessToken()); return $user; } }
php
public function login(){ if ($this->getGet('code')) { $this->client->authenticate($this->getGet('code')); $this->setSession('token', $this->client->getAccessToken()); $redirect = $this->config->redirect_uris[0]; header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); return; } $token = $this->getSession('token'); if ($token) { $this->client->setAccessToken($token); } if ($this->client->getAccessToken()) { $user = $this->oauth2_service->userinfo->get(); $this->setSession('token', $this->client->getAccessToken()); return $user; } }
[ "public", "function", "login", "(", ")", "{", "if", "(", "$", "this", "->", "getGet", "(", "'code'", ")", ")", "{", "$", "this", "->", "client", "->", "authenticate", "(", "$", "this", "->", "getGet", "(", "'code'", ")", ")", ";", "$", "this", "->", "setSession", "(", "'token'", ",", "$", "this", "->", "client", "->", "getAccessToken", "(", ")", ")", ";", "$", "redirect", "=", "$", "this", "->", "config", "->", "redirect_uris", "[", "0", "]", ";", "header", "(", "'Location: '", ".", "filter_var", "(", "$", "redirect", ",", "FILTER_SANITIZE_URL", ")", ")", ";", "return", ";", "}", "$", "token", "=", "$", "this", "->", "getSession", "(", "'token'", ")", ";", "if", "(", "$", "token", ")", "{", "$", "this", "->", "client", "->", "setAccessToken", "(", "$", "token", ")", ";", "}", "if", "(", "$", "this", "->", "client", "->", "getAccessToken", "(", ")", ")", "{", "$", "user", "=", "$", "this", "->", "oauth2_service", "->", "userinfo", "->", "get", "(", ")", ";", "$", "this", "->", "setSession", "(", "'token'", ",", "$", "this", "->", "client", "->", "getAccessToken", "(", ")", ")", ";", "return", "$", "user", ";", "}", "}" ]
Logs in the user @return \stdClass @servable true
[ "Logs", "in", "the", "user" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/Google/Auth.php#L98-L119
21,470
dlundgren/php-css-splitter
src/Splitter.php
Splitter.countSelectors
public function countSelectors($css = null) { $count = 0; if ($css !== null && $this->css !== $css) { $this->css = $css; $this->parsedCss = $this->splitIntoBlocks($this->css); } foreach ($this->parsedCss as $rules) { $count += $rules['count']; } return $count; }
php
public function countSelectors($css = null) { $count = 0; if ($css !== null && $this->css !== $css) { $this->css = $css; $this->parsedCss = $this->splitIntoBlocks($this->css); } foreach ($this->parsedCss as $rules) { $count += $rules['count']; } return $count; }
[ "public", "function", "countSelectors", "(", "$", "css", "=", "null", ")", "{", "$", "count", "=", "0", ";", "if", "(", "$", "css", "!==", "null", "&&", "$", "this", "->", "css", "!==", "$", "css", ")", "{", "$", "this", "->", "css", "=", "$", "css", ";", "$", "this", "->", "parsedCss", "=", "$", "this", "->", "splitIntoBlocks", "(", "$", "this", "->", "css", ")", ";", "}", "foreach", "(", "$", "this", "->", "parsedCss", "as", "$", "rules", ")", "{", "$", "count", "+=", "$", "rules", "[", "'count'", "]", ";", "}", "return", "$", "count", ";", "}" ]
Counts the selectors in the given css @param string $css @return int The count of selectors in the CSS
[ "Counts", "the", "selectors", "in", "the", "given", "css" ]
5a130eee3141b3e2631e1d9fcee388546b216790
https://github.com/dlundgren/php-css-splitter/blob/5a130eee3141b3e2631e1d9fcee388546b216790/src/Splitter.php#L57-L69
21,471
dlundgren/php-css-splitter
src/Splitter.php
Splitter.split
public function split($css = null, $part = 1, $maxSelectors = self::MAX_SELECTORS_DEFAULT) { if (empty($css) && empty($this->css)) { return null; } if (!empty($css) && $this->css !== $css) { $this->css = $css; } $charset = $this->extractCharset($this->css); isset($charset) && $this->css = str_replace($charset, '', $this->css); if (empty($this->css)) { return null; } $this->parsedCss = $this->splitIntoBlocks($this->css); if (empty($this->parsedCss)) { return null; } $output = $charset ? : ''; $count = 0; $partCount = 1; foreach ($this->parsedCss as $block) { $appliedMedia = false; foreach ($block['rules'] as $rule) { $tmpCount = $rule['count']; // we have a new part so let's reset and increase if (($count + $tmpCount) > $maxSelectors) { $partCount++; $count = 0; } $count += $tmpCount; if ($partCount < $part) { continue; } if ($partCount > $part) { break; } if (!$appliedMedia && isset($block['at-rule'])) { $output .= $block['at-rule'] . ' {'; $appliedMedia = true; } $output .= $rule['rule']; } $appliedMedia && $output .= '}'; } return $output; }
php
public function split($css = null, $part = 1, $maxSelectors = self::MAX_SELECTORS_DEFAULT) { if (empty($css) && empty($this->css)) { return null; } if (!empty($css) && $this->css !== $css) { $this->css = $css; } $charset = $this->extractCharset($this->css); isset($charset) && $this->css = str_replace($charset, '', $this->css); if (empty($this->css)) { return null; } $this->parsedCss = $this->splitIntoBlocks($this->css); if (empty($this->parsedCss)) { return null; } $output = $charset ? : ''; $count = 0; $partCount = 1; foreach ($this->parsedCss as $block) { $appliedMedia = false; foreach ($block['rules'] as $rule) { $tmpCount = $rule['count']; // we have a new part so let's reset and increase if (($count + $tmpCount) > $maxSelectors) { $partCount++; $count = 0; } $count += $tmpCount; if ($partCount < $part) { continue; } if ($partCount > $part) { break; } if (!$appliedMedia && isset($block['at-rule'])) { $output .= $block['at-rule'] . ' {'; $appliedMedia = true; } $output .= $rule['rule']; } $appliedMedia && $output .= '}'; } return $output; }
[ "public", "function", "split", "(", "$", "css", "=", "null", ",", "$", "part", "=", "1", ",", "$", "maxSelectors", "=", "self", "::", "MAX_SELECTORS_DEFAULT", ")", "{", "if", "(", "empty", "(", "$", "css", ")", "&&", "empty", "(", "$", "this", "->", "css", ")", ")", "{", "return", "null", ";", "}", "if", "(", "!", "empty", "(", "$", "css", ")", "&&", "$", "this", "->", "css", "!==", "$", "css", ")", "{", "$", "this", "->", "css", "=", "$", "css", ";", "}", "$", "charset", "=", "$", "this", "->", "extractCharset", "(", "$", "this", "->", "css", ")", ";", "isset", "(", "$", "charset", ")", "&&", "$", "this", "->", "css", "=", "str_replace", "(", "$", "charset", ",", "''", ",", "$", "this", "->", "css", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "css", ")", ")", "{", "return", "null", ";", "}", "$", "this", "->", "parsedCss", "=", "$", "this", "->", "splitIntoBlocks", "(", "$", "this", "->", "css", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "parsedCss", ")", ")", "{", "return", "null", ";", "}", "$", "output", "=", "$", "charset", "?", ":", "''", ";", "$", "count", "=", "0", ";", "$", "partCount", "=", "1", ";", "foreach", "(", "$", "this", "->", "parsedCss", "as", "$", "block", ")", "{", "$", "appliedMedia", "=", "false", ";", "foreach", "(", "$", "block", "[", "'rules'", "]", "as", "$", "rule", ")", "{", "$", "tmpCount", "=", "$", "rule", "[", "'count'", "]", ";", "// we have a new part so let's reset and increase", "if", "(", "(", "$", "count", "+", "$", "tmpCount", ")", ">", "$", "maxSelectors", ")", "{", "$", "partCount", "++", ";", "$", "count", "=", "0", ";", "}", "$", "count", "+=", "$", "tmpCount", ";", "if", "(", "$", "partCount", "<", "$", "part", ")", "{", "continue", ";", "}", "if", "(", "$", "partCount", ">", "$", "part", ")", "{", "break", ";", "}", "if", "(", "!", "$", "appliedMedia", "&&", "isset", "(", "$", "block", "[", "'at-rule'", "]", ")", ")", "{", "$", "output", ".=", "$", "block", "[", "'at-rule'", "]", ".", "' {'", ";", "$", "appliedMedia", "=", "true", ";", "}", "$", "output", ".=", "$", "rule", "[", "'rule'", "]", ";", "}", "$", "appliedMedia", "&&", "$", "output", ".=", "'}'", ";", "}", "return", "$", "output", ";", "}" ]
Returns the requested part of the split css @param string $css @param int $part @param int $maxSelectors @return null|string
[ "Returns", "the", "requested", "part", "of", "the", "split", "css" ]
5a130eee3141b3e2631e1d9fcee388546b216790
https://github.com/dlundgren/php-css-splitter/blob/5a130eee3141b3e2631e1d9fcee388546b216790/src/Splitter.php#L79-L132
21,472
dlundgren/php-css-splitter
src/Splitter.php
Splitter.summarizeBlock
private function summarizeBlock($block) { $block = array( 'rules' => is_array($block) ? $block : $this->splitIntoRules(trim($block)), 'count' => 0 ); foreach ($block['rules'] as $key => $rule) { $block['rules'][$key] = array( 'rule' => $rule, 'count' => $this->countSelectorsInRule($rule), ); $block['count'] += $block['rules'][$key]['count']; } return $block; }
php
private function summarizeBlock($block) { $block = array( 'rules' => is_array($block) ? $block : $this->splitIntoRules(trim($block)), 'count' => 0 ); foreach ($block['rules'] as $key => $rule) { $block['rules'][$key] = array( 'rule' => $rule, 'count' => $this->countSelectorsInRule($rule), ); $block['count'] += $block['rules'][$key]['count']; } return $block; }
[ "private", "function", "summarizeBlock", "(", "$", "block", ")", "{", "$", "block", "=", "array", "(", "'rules'", "=>", "is_array", "(", "$", "block", ")", "?", "$", "block", ":", "$", "this", "->", "splitIntoRules", "(", "trim", "(", "$", "block", ")", ")", ",", "'count'", "=>", "0", ")", ";", "foreach", "(", "$", "block", "[", "'rules'", "]", "as", "$", "key", "=>", "$", "rule", ")", "{", "$", "block", "[", "'rules'", "]", "[", "$", "key", "]", "=", "array", "(", "'rule'", "=>", "$", "rule", ",", "'count'", "=>", "$", "this", "->", "countSelectorsInRule", "(", "$", "rule", ")", ",", ")", ";", "$", "block", "[", "'count'", "]", "+=", "$", "block", "[", "'rules'", "]", "[", "$", "key", "]", "[", "'count'", "]", ";", "}", "return", "$", "block", ";", "}" ]
Summarizes the block of CSS This splits the block into it's css rules and then counts the selectors in the rule @param $block @return array Array(rules,count)
[ "Summarizes", "the", "block", "of", "CSS" ]
5a130eee3141b3e2631e1d9fcee388546b216790
https://github.com/dlundgren/php-css-splitter/blob/5a130eee3141b3e2631e1d9fcee388546b216790/src/Splitter.php#L142-L157
21,473
dlundgren/php-css-splitter
src/Splitter.php
Splitter.splitIntoBlocks
private function splitIntoBlocks($css) { if (is_array($css)) { return $css; } $blocks = array(); $css = $this->stripComments($css); $offset = 0; // catch all @feature {...} blocks if (preg_match_all('/(@[^{]+){([^{}]*{[^}]*})*\s*}/ism', $css, $matches, PREG_OFFSET_CAPTURE) > 0) { foreach ($matches[0] as $key => $match) { $atRule = trim($matches[1][$key][0]); list($rules, $start) = $match; if ($start > $offset) { // make previous selectors into their own block $block = trim(substr($css, $offset, $start - $offset)); if (!empty($block)) { $blocks[] = $this->summarizeBlock($block); } } $offset = $start + strlen($rules); // currently only @media rules need to be parsed and counted for IE9 selectors if (strpos($atRule, '@media') === 0) { $block = $this->summarizeBlock(substr($rules, strpos($rules, '{') + 1, -1)); } else { $block = array( 'count' => 1, 'rules' => array( array( 'rule' => substr($rules, strpos($rules, '{') + 1, -1), 'count' => 1, ) ), ); } $block['at-rule'] = $atRule; $blocks[] = $block; } // catch any remaining as it's own block $block = trim(substr($css, $offset)); if (!empty($block)) { $blocks[] = $this->summarizeBlock($block); } } else { $blocks[] = $this->summarizeBlock($css); } return $blocks; }
php
private function splitIntoBlocks($css) { if (is_array($css)) { return $css; } $blocks = array(); $css = $this->stripComments($css); $offset = 0; // catch all @feature {...} blocks if (preg_match_all('/(@[^{]+){([^{}]*{[^}]*})*\s*}/ism', $css, $matches, PREG_OFFSET_CAPTURE) > 0) { foreach ($matches[0] as $key => $match) { $atRule = trim($matches[1][$key][0]); list($rules, $start) = $match; if ($start > $offset) { // make previous selectors into their own block $block = trim(substr($css, $offset, $start - $offset)); if (!empty($block)) { $blocks[] = $this->summarizeBlock($block); } } $offset = $start + strlen($rules); // currently only @media rules need to be parsed and counted for IE9 selectors if (strpos($atRule, '@media') === 0) { $block = $this->summarizeBlock(substr($rules, strpos($rules, '{') + 1, -1)); } else { $block = array( 'count' => 1, 'rules' => array( array( 'rule' => substr($rules, strpos($rules, '{') + 1, -1), 'count' => 1, ) ), ); } $block['at-rule'] = $atRule; $blocks[] = $block; } // catch any remaining as it's own block $block = trim(substr($css, $offset)); if (!empty($block)) { $blocks[] = $this->summarizeBlock($block); } } else { $blocks[] = $this->summarizeBlock($css); } return $blocks; }
[ "private", "function", "splitIntoBlocks", "(", "$", "css", ")", "{", "if", "(", "is_array", "(", "$", "css", ")", ")", "{", "return", "$", "css", ";", "}", "$", "blocks", "=", "array", "(", ")", ";", "$", "css", "=", "$", "this", "->", "stripComments", "(", "$", "css", ")", ";", "$", "offset", "=", "0", ";", "// catch all @feature {...} blocks", "if", "(", "preg_match_all", "(", "'/(@[^{]+){([^{}]*{[^}]*})*\\s*}/ism'", ",", "$", "css", ",", "$", "matches", ",", "PREG_OFFSET_CAPTURE", ")", ">", "0", ")", "{", "foreach", "(", "$", "matches", "[", "0", "]", "as", "$", "key", "=>", "$", "match", ")", "{", "$", "atRule", "=", "trim", "(", "$", "matches", "[", "1", "]", "[", "$", "key", "]", "[", "0", "]", ")", ";", "list", "(", "$", "rules", ",", "$", "start", ")", "=", "$", "match", ";", "if", "(", "$", "start", ">", "$", "offset", ")", "{", "// make previous selectors into their own block", "$", "block", "=", "trim", "(", "substr", "(", "$", "css", ",", "$", "offset", ",", "$", "start", "-", "$", "offset", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "block", ")", ")", "{", "$", "blocks", "[", "]", "=", "$", "this", "->", "summarizeBlock", "(", "$", "block", ")", ";", "}", "}", "$", "offset", "=", "$", "start", "+", "strlen", "(", "$", "rules", ")", ";", "// currently only @media rules need to be parsed and counted for IE9 selectors", "if", "(", "strpos", "(", "$", "atRule", ",", "'@media'", ")", "===", "0", ")", "{", "$", "block", "=", "$", "this", "->", "summarizeBlock", "(", "substr", "(", "$", "rules", ",", "strpos", "(", "$", "rules", ",", "'{'", ")", "+", "1", ",", "-", "1", ")", ")", ";", "}", "else", "{", "$", "block", "=", "array", "(", "'count'", "=>", "1", ",", "'rules'", "=>", "array", "(", "array", "(", "'rule'", "=>", "substr", "(", "$", "rules", ",", "strpos", "(", "$", "rules", ",", "'{'", ")", "+", "1", ",", "-", "1", ")", ",", "'count'", "=>", "1", ",", ")", ")", ",", ")", ";", "}", "$", "block", "[", "'at-rule'", "]", "=", "$", "atRule", ";", "$", "blocks", "[", "]", "=", "$", "block", ";", "}", "// catch any remaining as it's own block", "$", "block", "=", "trim", "(", "substr", "(", "$", "css", ",", "$", "offset", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "block", ")", ")", "{", "$", "blocks", "[", "]", "=", "$", "this", "->", "summarizeBlock", "(", "$", "block", ")", ";", "}", "}", "else", "{", "$", "blocks", "[", "]", "=", "$", "this", "->", "summarizeBlock", "(", "$", "css", ")", ";", "}", "return", "$", "blocks", ";", "}" ]
Splits the css into blocks maintaining the order of the rules and media queries This makes it easier to split the CSS into files when a media query might be split @param $css @return array
[ "Splits", "the", "css", "into", "blocks", "maintaining", "the", "order", "of", "the", "rules", "and", "media", "queries" ]
5a130eee3141b3e2631e1d9fcee388546b216790
https://github.com/dlundgren/php-css-splitter/blob/5a130eee3141b3e2631e1d9fcee388546b216790/src/Splitter.php#L167-L224
21,474
dlundgren/php-css-splitter
src/Splitter.php
Splitter.splitIntoRules
private function splitIntoRules($css) { $rules = preg_split('/}/', trim($this->stripComments($css))); // complete any rules by append } to them array_walk($rules, function (&$s) { !empty($s) && $s = trim("$s}"); }); // clears out any empty rules return array_filter($rules); }
php
private function splitIntoRules($css) { $rules = preg_split('/}/', trim($this->stripComments($css))); // complete any rules by append } to them array_walk($rules, function (&$s) { !empty($s) && $s = trim("$s}"); }); // clears out any empty rules return array_filter($rules); }
[ "private", "function", "splitIntoRules", "(", "$", "css", ")", "{", "$", "rules", "=", "preg_split", "(", "'/}/'", ",", "trim", "(", "$", "this", "->", "stripComments", "(", "$", "css", ")", ")", ")", ";", "// complete any rules by append } to them", "array_walk", "(", "$", "rules", ",", "function", "(", "&", "$", "s", ")", "{", "!", "empty", "(", "$", "s", ")", "&&", "$", "s", "=", "trim", "(", "\"$s}\"", ")", ";", "}", ")", ";", "// clears out any empty rules", "return", "array_filter", "(", "$", "rules", ")", ";", "}" ]
Splits the css into it's rules @param $css @return array
[ "Splits", "the", "css", "into", "it", "s", "rules" ]
5a130eee3141b3e2631e1d9fcee388546b216790
https://github.com/dlundgren/php-css-splitter/blob/5a130eee3141b3e2631e1d9fcee388546b216790/src/Splitter.php#L232-L244
21,475
wenbinye/PhalconX
src/Db/Schema/Table.php
Table.describeTable
public static function describeTable(AdapterInterface $db, $table, $schema = null) { $columns = $db->describeColumns($table, $schema); $indexes = $db->describeIndexes($table, $schema); $references = $db->describeReferences($table, $schema); $options = $db->tableOptions($table, $schema); return new self([ 'name' => $table, 'schema' => $schema, 'columns' => array_map([Column::class, 'fromColumn'], $columns), 'indexes' => array_map([Index::class, 'fromIndex'], $indexes), 'references' => array_map([Reference::class, 'fromReference'], $references), 'options' => $options, ]); }
php
public static function describeTable(AdapterInterface $db, $table, $schema = null) { $columns = $db->describeColumns($table, $schema); $indexes = $db->describeIndexes($table, $schema); $references = $db->describeReferences($table, $schema); $options = $db->tableOptions($table, $schema); return new self([ 'name' => $table, 'schema' => $schema, 'columns' => array_map([Column::class, 'fromColumn'], $columns), 'indexes' => array_map([Index::class, 'fromIndex'], $indexes), 'references' => array_map([Reference::class, 'fromReference'], $references), 'options' => $options, ]); }
[ "public", "static", "function", "describeTable", "(", "AdapterInterface", "$", "db", ",", "$", "table", ",", "$", "schema", "=", "null", ")", "{", "$", "columns", "=", "$", "db", "->", "describeColumns", "(", "$", "table", ",", "$", "schema", ")", ";", "$", "indexes", "=", "$", "db", "->", "describeIndexes", "(", "$", "table", ",", "$", "schema", ")", ";", "$", "references", "=", "$", "db", "->", "describeReferences", "(", "$", "table", ",", "$", "schema", ")", ";", "$", "options", "=", "$", "db", "->", "tableOptions", "(", "$", "table", ",", "$", "schema", ")", ";", "return", "new", "self", "(", "[", "'name'", "=>", "$", "table", ",", "'schema'", "=>", "$", "schema", ",", "'columns'", "=>", "array_map", "(", "[", "Column", "::", "class", ",", "'fromColumn'", "]", ",", "$", "columns", ")", ",", "'indexes'", "=>", "array_map", "(", "[", "Index", "::", "class", ",", "'fromIndex'", "]", ",", "$", "indexes", ")", ",", "'references'", "=>", "array_map", "(", "[", "Reference", "::", "class", ",", "'fromReference'", "]", ",", "$", "references", ")", ",", "'options'", "=>", "$", "options", ",", "]", ")", ";", "}" ]
Gets table description @return Table
[ "Gets", "table", "description" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/Schema/Table.php#L40-L55
21,476
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validators/index_fields.php
ezcDbSchemaIndexFieldsValidator.validate
static public function validate( ezcDbSchema $schema ) { $errors = array(); /* For each table we first retrieve all the field names, and then check * per index whether the fields it references exist */ foreach ( $schema->getSchema() as $tableName => $table ) { $fields = array_keys( $table->fields ); foreach ( $table->indexes as $indexName => $index ) { foreach ( $index->indexFields as $indexFieldName => $dummy ) { if ( !in_array( $indexFieldName, $fields ) ) { $errors[] = "Index '$tableName:$indexName' references unknown field name '$tableName:$indexFieldName'."; } } } } return $errors; }
php
static public function validate( ezcDbSchema $schema ) { $errors = array(); /* For each table we first retrieve all the field names, and then check * per index whether the fields it references exist */ foreach ( $schema->getSchema() as $tableName => $table ) { $fields = array_keys( $table->fields ); foreach ( $table->indexes as $indexName => $index ) { foreach ( $index->indexFields as $indexFieldName => $dummy ) { if ( !in_array( $indexFieldName, $fields ) ) { $errors[] = "Index '$tableName:$indexName' references unknown field name '$tableName:$indexFieldName'."; } } } } return $errors; }
[ "static", "public", "function", "validate", "(", "ezcDbSchema", "$", "schema", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "/* For each table we first retrieve all the field names, and then check\n * per index whether the fields it references exist */", "foreach", "(", "$", "schema", "->", "getSchema", "(", ")", "as", "$", "tableName", "=>", "$", "table", ")", "{", "$", "fields", "=", "array_keys", "(", "$", "table", "->", "fields", ")", ";", "foreach", "(", "$", "table", "->", "indexes", "as", "$", "indexName", "=>", "$", "index", ")", "{", "foreach", "(", "$", "index", "->", "indexFields", "as", "$", "indexFieldName", "=>", "$", "dummy", ")", "{", "if", "(", "!", "in_array", "(", "$", "indexFieldName", ",", "$", "fields", ")", ")", "{", "$", "errors", "[", "]", "=", "\"Index '$tableName:$indexName' references unknown field name '$tableName:$indexFieldName'.\"", ";", "}", "}", "}", "}", "return", "$", "errors", ";", "}" ]
Validates if all the fields used in all indexes exist. This method loops over all the fields in the indexes of each table and checks whether the fields that is used in an index is also defined in the table definition. It will return an array containing error strings for each non-supported type that it finds. @param ezcDbSchema $schema @return array(string)
[ "Validates", "if", "all", "the", "fields", "used", "in", "all", "indexes", "exist", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validators/index_fields.php#L31-L54
21,477
j-d/draggy
src/Draggy/Log.php
Log.prepend
public function prepend($message) { $this->log = [$message] + $this->log; $this->extendedLog = [$message] + $this->extendedLog; }
php
public function prepend($message) { $this->log = [$message] + $this->log; $this->extendedLog = [$message] + $this->extendedLog; }
[ "public", "function", "prepend", "(", "$", "message", ")", "{", "$", "this", "->", "log", "=", "[", "$", "message", "]", "+", "$", "this", "->", "log", ";", "$", "this", "->", "extendedLog", "=", "[", "$", "message", "]", "+", "$", "this", "->", "extendedLog", ";", "}" ]
Prepend a message to the log @param $message
[ "Prepend", "a", "message", "to", "the", "log" ]
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Log.php#L43-L47
21,478
primipilus/fileinfo
src/MimeType.php
MimeType.getExtensions
public static function getExtensions(string $mime) : array { $extensions = []; foreach (static::$_types as $extension => $mimeType) { if ($mimeType === $mime) { $extensions[] = $extension; } } return $extensions; }
php
public static function getExtensions(string $mime) : array { $extensions = []; foreach (static::$_types as $extension => $mimeType) { if ($mimeType === $mime) { $extensions[] = $extension; } } return $extensions; }
[ "public", "static", "function", "getExtensions", "(", "string", "$", "mime", ")", ":", "array", "{", "$", "extensions", "=", "[", "]", ";", "foreach", "(", "static", "::", "$", "_types", "as", "$", "extension", "=>", "$", "mimeType", ")", "{", "if", "(", "$", "mimeType", "===", "$", "mime", ")", "{", "$", "extensions", "[", "]", "=", "$", "extension", ";", "}", "}", "return", "$", "extensions", ";", "}" ]
Get extensions for one mime @param string $mime @return array
[ "Get", "extensions", "for", "one", "mime" ]
734fd25b3dfd3b0706f9ef07499663578c0fa56e
https://github.com/primipilus/fileinfo/blob/734fd25b3dfd3b0706f9ef07499663578c0fa56e/src/MimeType.php#L1023-L1034
21,479
ronaldborla/chikka
src/Borla/Chikka/Models/Notification.php
Notification.onSetAttribute
protected function onSetAttribute($name, $value) { // Listen to these attributes $listen = [ 'message_type'=> 'type', 'message_id' => 'id', 'credits_cost'=> 'credits', 'rb_cost' => 'cost', ]; // If set if (isset($listen[$name])) { // If not yet set if ( ! isset($this->{$listen[$name]})) { // Set corresponding attribute $this->{$listen[$name]} = $value; } } }
php
protected function onSetAttribute($name, $value) { // Listen to these attributes $listen = [ 'message_type'=> 'type', 'message_id' => 'id', 'credits_cost'=> 'credits', 'rb_cost' => 'cost', ]; // If set if (isset($listen[$name])) { // If not yet set if ( ! isset($this->{$listen[$name]})) { // Set corresponding attribute $this->{$listen[$name]} = $value; } } }
[ "protected", "function", "onSetAttribute", "(", "$", "name", ",", "$", "value", ")", "{", "// Listen to these attributes", "$", "listen", "=", "[", "'message_type'", "=>", "'type'", ",", "'message_id'", "=>", "'id'", ",", "'credits_cost'", "=>", "'credits'", ",", "'rb_cost'", "=>", "'cost'", ",", "]", ";", "// If set", "if", "(", "isset", "(", "$", "listen", "[", "$", "name", "]", ")", ")", "{", "// If not yet set", "if", "(", "!", "isset", "(", "$", "this", "->", "{", "$", "listen", "[", "$", "name", "]", "}", ")", ")", "{", "// Set corresponding attribute", "$", "this", "->", "{", "$", "listen", "[", "$", "name", "]", "}", "=", "$", "value", ";", "}", "}", "}" ]
When an attribute is set
[ "When", "an", "attribute", "is", "set" ]
446987706f81d5a0efbc8bd6b7d3b259d0527719
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Models/Notification.php#L56-L72
21,480
nabab/bbn
src/bbn/api/virtualmin.php
virtualmin.delete_cache
public function delete_cache($command_name = '', $arguments= false){ $uid = $this->hostname; if ( !empty($arguments) ){ $uid .= md5(json_encode($arguments)); } if ( !empty($this->cache_delete($uid, $command_name)) ){ \bbn\x::log([$uid, $command_name], 'cache_delete'); return true; } return false; }
php
public function delete_cache($command_name = '', $arguments= false){ $uid = $this->hostname; if ( !empty($arguments) ){ $uid .= md5(json_encode($arguments)); } if ( !empty($this->cache_delete($uid, $command_name)) ){ \bbn\x::log([$uid, $command_name], 'cache_delete'); return true; } return false; }
[ "public", "function", "delete_cache", "(", "$", "command_name", "=", "''", ",", "$", "arguments", "=", "false", ")", "{", "$", "uid", "=", "$", "this", "->", "hostname", ";", "if", "(", "!", "empty", "(", "$", "arguments", ")", ")", "{", "$", "uid", ".=", "md5", "(", "json_encode", "(", "$", "arguments", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "cache_delete", "(", "$", "uid", ",", "$", "command_name", ")", ")", ")", "{", "\\", "bbn", "\\", "x", "::", "log", "(", "[", "$", "uid", ",", "$", "command_name", "]", ",", "'cache_delete'", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
This function allows the cancellation of the cache of the used commands @param $uid file cache @param $method name @return bool
[ "This", "function", "allows", "the", "cancellation", "of", "the", "cache", "of", "the", "used", "commands" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/virtualmin.php#L186-L196
21,481
nabab/bbn
src/bbn/api/virtualmin.php
virtualmin.get_header_url
private function get_header_url(){ return "wget -O - --quiet --http-user=" . $this->user . " --http-passwd=" . escapeshellarg($this->pass) . " --no-check-certificate 'https://" . $this->hostname . ":10000/".( $this->mode === 'cloudmin' ? 'server-manager' : 'virtual-server' )."/remote.cgi?json=1&multiline=&program="; }
php
private function get_header_url(){ return "wget -O - --quiet --http-user=" . $this->user . " --http-passwd=" . escapeshellarg($this->pass) . " --no-check-certificate 'https://" . $this->hostname . ":10000/".( $this->mode === 'cloudmin' ? 'server-manager' : 'virtual-server' )."/remote.cgi?json=1&multiline=&program="; }
[ "private", "function", "get_header_url", "(", ")", "{", "return", "\"wget -O - --quiet --http-user=\"", ".", "$", "this", "->", "user", ".", "\" --http-passwd=\"", ".", "escapeshellarg", "(", "$", "this", "->", "pass", ")", ".", "\" --no-check-certificate 'https://\"", ".", "$", "this", "->", "hostname", ".", "\":10000/\"", ".", "(", "$", "this", "->", "mode", "===", "'cloudmin'", "?", "'server-manager'", ":", "'virtual-server'", ")", ".", "\"/remote.cgi?json=1&multiline=&program=\"", ";", "}" ]
This function is used to get the header url part to be executed @return string The the header url part to be executed
[ "This", "function", "is", "used", "to", "get", "the", "header", "url", "part", "to", "be", "executed" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/virtualmin.php#L260-L264
21,482
glynnforrest/blockade
src/Blockade/Resolver/RedirectResolver.php
RedirectResolver.createUrl
protected function createUrl(BlockadeException $exception, Request $request) { //decide where to redirect. login_url for unauthenticated or //bad credentials, deny_url for unauthorized or anything else if ($exception instanceof AuthenticationException || $exception instanceof CredentialsException) { return $this->login_url.'/to'.$request->getPathInfo(); } return $this->deny_url; }
php
protected function createUrl(BlockadeException $exception, Request $request) { //decide where to redirect. login_url for unauthenticated or //bad credentials, deny_url for unauthorized or anything else if ($exception instanceof AuthenticationException || $exception instanceof CredentialsException) { return $this->login_url.'/to'.$request->getPathInfo(); } return $this->deny_url; }
[ "protected", "function", "createUrl", "(", "BlockadeException", "$", "exception", ",", "Request", "$", "request", ")", "{", "//decide where to redirect. login_url for unauthenticated or", "//bad credentials, deny_url for unauthorized or anything else", "if", "(", "$", "exception", "instanceof", "AuthenticationException", "||", "$", "exception", "instanceof", "CredentialsException", ")", "{", "return", "$", "this", "->", "login_url", ".", "'/to'", ".", "$", "request", "->", "getPathInfo", "(", ")", ";", "}", "return", "$", "this", "->", "deny_url", ";", "}" ]
Create the url to redirect to. @param BlockadeException $exception The exception @param Request $request The request that caused the exception
[ "Create", "the", "url", "to", "redirect", "to", "." ]
5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b
https://github.com/glynnforrest/blockade/blob/5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b/src/Blockade/Resolver/RedirectResolver.php#L41-L50
21,483
glynnforrest/blockade
src/Blockade/Resolver/RedirectResolver.php
RedirectResolver.createXmlHttpResponse
protected function createXmlHttpResponse(BlockadeException $exception, Request $request) { if ($exception instanceof AuthenticationException || $exception instanceof CredentialsException) { return new Response('Authentication required', Response::HTTP_UNAUTHORIZED); } return new Response('Access denied', Response::HTTP_FORBIDDEN); }
php
protected function createXmlHttpResponse(BlockadeException $exception, Request $request) { if ($exception instanceof AuthenticationException || $exception instanceof CredentialsException) { return new Response('Authentication required', Response::HTTP_UNAUTHORIZED); } return new Response('Access denied', Response::HTTP_FORBIDDEN); }
[ "protected", "function", "createXmlHttpResponse", "(", "BlockadeException", "$", "exception", ",", "Request", "$", "request", ")", "{", "if", "(", "$", "exception", "instanceof", "AuthenticationException", "||", "$", "exception", "instanceof", "CredentialsException", ")", "{", "return", "new", "Response", "(", "'Authentication required'", ",", "Response", "::", "HTTP_UNAUTHORIZED", ")", ";", "}", "return", "new", "Response", "(", "'Access denied'", ",", "Response", "::", "HTTP_FORBIDDEN", ")", ";", "}" ]
Create a response for XmlHttpRequests. @param BlockadeException $exception The exception @param Request $request The request that caused the exception
[ "Create", "a", "response", "for", "XmlHttpRequests", "." ]
5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b
https://github.com/glynnforrest/blockade/blob/5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b/src/Blockade/Resolver/RedirectResolver.php#L58-L65
21,484
codeburnerframework/container
src/Container.php
Container.call
public function call($function, array $parameters = []) { $inspector = new ReflectionFunction($function); $dependencies = $inspector->getParameters(); $dependencies = $this->process('', $parameters, $dependencies); return call_user_func_array($function, $dependencies); }
php
public function call($function, array $parameters = []) { $inspector = new ReflectionFunction($function); $dependencies = $inspector->getParameters(); $dependencies = $this->process('', $parameters, $dependencies); return call_user_func_array($function, $dependencies); }
[ "public", "function", "call", "(", "$", "function", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "inspector", "=", "new", "ReflectionFunction", "(", "$", "function", ")", ";", "$", "dependencies", "=", "$", "inspector", "->", "getParameters", "(", ")", ";", "$", "dependencies", "=", "$", "this", "->", "process", "(", "''", ",", "$", "parameters", ",", "$", "dependencies", ")", ";", "return", "call_user_func_array", "(", "$", "function", ",", "$", "dependencies", ")", ";", "}" ]
Call a user function injecting the dependencies. @param string|Closure $function The function or the user function name. @param array $parameters The predefined dependencies. @return mixed
[ "Call", "a", "user", "function", "injecting", "the", "dependencies", "." ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L75-L83
21,485
codeburnerframework/container
src/Container.php
Container.make
public function make(string $abstract, array $parameters = []) { try { if (! isset($this->resolving[$abstract])) { $this->resolving[$abstract] = $this->construct($abstract); } return $this->resolving[$abstract]($abstract, $parameters); } catch (ReflectionException $e) { throw new ContainerException("Fail while attempt to make '$abstract'", 0, $e); } }
php
public function make(string $abstract, array $parameters = []) { try { if (! isset($this->resolving[$abstract])) { $this->resolving[$abstract] = $this->construct($abstract); } return $this->resolving[$abstract]($abstract, $parameters); } catch (ReflectionException $e) { throw new ContainerException("Fail while attempt to make '$abstract'", 0, $e); } }
[ "public", "function", "make", "(", "string", "$", "abstract", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "try", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "resolving", "[", "$", "abstract", "]", ")", ")", "{", "$", "this", "->", "resolving", "[", "$", "abstract", "]", "=", "$", "this", "->", "construct", "(", "$", "abstract", ")", ";", "}", "return", "$", "this", "->", "resolving", "[", "$", "abstract", "]", "(", "$", "abstract", ",", "$", "parameters", ")", ";", "}", "catch", "(", "ReflectionException", "$", "e", ")", "{", "throw", "new", "ContainerException", "(", "\"Fail while attempt to make '$abstract'\"", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Makes an element or class injecting automatically all the dependencies. @param string $abstract The class name or container element name to make. @param array $parameters Specific parameters definition. @throws ContainerException @return object|null
[ "Makes", "an", "element", "or", "class", "injecting", "automatically", "all", "the", "dependencies", "." ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L95-L106
21,486
codeburnerframework/container
src/Container.php
Container.construct
protected function construct(string $abstract) : Closure { $inspector = new ReflectionClass($abstract); if (($constructor = $inspector->getConstructor()) && ($dependencies = $constructor->getParameters())) { // if, and only if, a class has a constructor with parameters, we try to solve then // creating a resolving callback that in every call will recalculate all dependencies // for the given class, and offcourse, using a cached resolving callback if exists. return function (string $abstract, array $parameters) use ($inspector, $dependencies) { return $inspector->newInstanceArgs( $this->process($abstract, $parameters, $dependencies) ); }; } return function (string $abstract) { return new $abstract; }; }
php
protected function construct(string $abstract) : Closure { $inspector = new ReflectionClass($abstract); if (($constructor = $inspector->getConstructor()) && ($dependencies = $constructor->getParameters())) { // if, and only if, a class has a constructor with parameters, we try to solve then // creating a resolving callback that in every call will recalculate all dependencies // for the given class, and offcourse, using a cached resolving callback if exists. return function (string $abstract, array $parameters) use ($inspector, $dependencies) { return $inspector->newInstanceArgs( $this->process($abstract, $parameters, $dependencies) ); }; } return function (string $abstract) { return new $abstract; }; }
[ "protected", "function", "construct", "(", "string", "$", "abstract", ")", ":", "Closure", "{", "$", "inspector", "=", "new", "ReflectionClass", "(", "$", "abstract", ")", ";", "if", "(", "(", "$", "constructor", "=", "$", "inspector", "->", "getConstructor", "(", ")", ")", "&&", "(", "$", "dependencies", "=", "$", "constructor", "->", "getParameters", "(", ")", ")", ")", "{", "// if, and only if, a class has a constructor with parameters, we try to solve then", "// creating a resolving callback that in every call will recalculate all dependencies", "// for the given class, and offcourse, using a cached resolving callback if exists.", "return", "function", "(", "string", "$", "abstract", ",", "array", "$", "parameters", ")", "use", "(", "$", "inspector", ",", "$", "dependencies", ")", "{", "return", "$", "inspector", "->", "newInstanceArgs", "(", "$", "this", "->", "process", "(", "$", "abstract", ",", "$", "parameters", ",", "$", "dependencies", ")", ")", ";", "}", ";", "}", "return", "function", "(", "string", "$", "abstract", ")", "{", "return", "new", "$", "abstract", ";", "}", ";", "}" ]
Construct a class and all the dependencies using the reflection library of PHP. @param string $abstract The class name or container element name to make. @throws ReflectionException @return Closure
[ "Construct", "a", "class", "and", "all", "the", "dependencies", "using", "the", "reflection", "library", "of", "PHP", "." ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L117-L137
21,487
codeburnerframework/container
src/Container.php
Container.process
protected function process(string $abstract, array $parameters, array $dependencies) : array { foreach ($dependencies as &$dependency) { if (isset($parameters[$dependency->name])) { $dependency = $parameters[$dependency->name]; } else $dependency = $this->resolve($abstract, $dependency); } return $dependencies; }
php
protected function process(string $abstract, array $parameters, array $dependencies) : array { foreach ($dependencies as &$dependency) { if (isset($parameters[$dependency->name])) { $dependency = $parameters[$dependency->name]; } else $dependency = $this->resolve($abstract, $dependency); } return $dependencies; }
[ "protected", "function", "process", "(", "string", "$", "abstract", ",", "array", "$", "parameters", ",", "array", "$", "dependencies", ")", ":", "array", "{", "foreach", "(", "$", "dependencies", "as", "&", "$", "dependency", ")", "{", "if", "(", "isset", "(", "$", "parameters", "[", "$", "dependency", "->", "name", "]", ")", ")", "{", "$", "dependency", "=", "$", "parameters", "[", "$", "dependency", "->", "name", "]", ";", "}", "else", "$", "dependency", "=", "$", "this", "->", "resolve", "(", "$", "abstract", ",", "$", "dependency", ")", ";", "}", "return", "$", "dependencies", ";", "}" ]
Process all dependencies @param string $abstract The class name or container element name to make @param array $parameters User defined parameters that must be used instead of resolved ones @param array $dependencies Array of ReflectionParameter @throws ContainerException When a dependency cannot be solved. @return array
[ "Process", "all", "dependencies" ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L150-L159
21,488
codeburnerframework/container
src/Container.php
Container.resolve
protected function resolve(string $abstract, ReflectionParameter $dependency) { $key = $abstract.$dependency->name; if (! isset($this->resolved[$key])) { $this->resolved[$key] = $this->generate($abstract, $dependency); } return $this->resolved[$key]($this); }
php
protected function resolve(string $abstract, ReflectionParameter $dependency) { $key = $abstract.$dependency->name; if (! isset($this->resolved[$key])) { $this->resolved[$key] = $this->generate($abstract, $dependency); } return $this->resolved[$key]($this); }
[ "protected", "function", "resolve", "(", "string", "$", "abstract", ",", "ReflectionParameter", "$", "dependency", ")", "{", "$", "key", "=", "$", "abstract", ".", "$", "dependency", "->", "name", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "resolved", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "resolved", "[", "$", "key", "]", "=", "$", "this", "->", "generate", "(", "$", "abstract", ",", "$", "dependency", ")", ";", "}", "return", "$", "this", "->", "resolved", "[", "$", "key", "]", "(", "$", "this", ")", ";", "}" ]
Resolve all the given class reflected dependencies. @param string $abstract The class name or container element name to resolve dependencies. @param ReflectionParameter $dependency The class dependency to be resolved. @throws ContainerException When a dependency cannot be solved. @return Object
[ "Resolve", "all", "the", "given", "class", "reflected", "dependencies", "." ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L171-L180
21,489
codeburnerframework/container
src/Container.php
Container.generate
protected function generate(string $abstract, ReflectionParameter $dependency) : Closure { if ($class = $dependency->getClass()) { return $this->build($class->name, "{$abstract}{$class->name}"); } try { $value = $dependency->getDefaultValue(); return function () use ($value) { return $value; }; } catch (ReflectionException $e) { throw new ContainerException("Cannot resolve '$dependency->name' of '$abstract'", 0, $e); } }
php
protected function generate(string $abstract, ReflectionParameter $dependency) : Closure { if ($class = $dependency->getClass()) { return $this->build($class->name, "{$abstract}{$class->name}"); } try { $value = $dependency->getDefaultValue(); return function () use ($value) { return $value; }; } catch (ReflectionException $e) { throw new ContainerException("Cannot resolve '$dependency->name' of '$abstract'", 0, $e); } }
[ "protected", "function", "generate", "(", "string", "$", "abstract", ",", "ReflectionParameter", "$", "dependency", ")", ":", "Closure", "{", "if", "(", "$", "class", "=", "$", "dependency", "->", "getClass", "(", ")", ")", "{", "return", "$", "this", "->", "build", "(", "$", "class", "->", "name", ",", "\"{$abstract}{$class->name}\"", ")", ";", "}", "try", "{", "$", "value", "=", "$", "dependency", "->", "getDefaultValue", "(", ")", ";", "return", "function", "(", ")", "use", "(", "$", "value", ")", "{", "return", "$", "value", ";", "}", ";", "}", "catch", "(", "ReflectionException", "$", "e", ")", "{", "throw", "new", "ContainerException", "(", "\"Cannot resolve '$dependency->name' of '$abstract'\"", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Generate the dependencies callbacks to jump some conditions in every dependency creation. @param string $abstract The class name or container element name to resolve dependencies. @param ReflectionParameter $dependency The class dependency to be resolved. @throws ContainerException When a dependency cannot be solved. @return Closure
[ "Generate", "the", "dependencies", "callbacks", "to", "jump", "some", "conditions", "in", "every", "dependency", "creation", "." ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L192-L207
21,490
codeburnerframework/container
src/Container.php
Container.build
protected function build(string $classname, string $entry) : Closure { if (isset($this->dependencies[$entry])) { return $this->dependencies[$entry]; } return function () use ($classname) { return $this->make($classname); }; }
php
protected function build(string $classname, string $entry) : Closure { if (isset($this->dependencies[$entry])) { return $this->dependencies[$entry]; } return function () use ($classname) { return $this->make($classname); }; }
[ "protected", "function", "build", "(", "string", "$", "classname", ",", "string", "$", "entry", ")", ":", "Closure", "{", "if", "(", "isset", "(", "$", "this", "->", "dependencies", "[", "$", "entry", "]", ")", ")", "{", "return", "$", "this", "->", "dependencies", "[", "$", "entry", "]", ";", "}", "return", "function", "(", ")", "use", "(", "$", "classname", ")", "{", "return", "$", "this", "->", "make", "(", "$", "classname", ")", ";", "}", ";", "}" ]
Create a build closure for a given class @param string $classname The class that need to be build @param string $entry Cache entry to search @return Closure
[ "Create", "a", "build", "closure", "for", "a", "given", "class" ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L218-L227
21,491
codeburnerframework/container
src/Container.php
Container.flush
public function flush() : ContainerInterface { $this->collection = []; $this->dependencies = []; $this->resolving = []; $this->resolved = []; return $this; }
php
public function flush() : ContainerInterface { $this->collection = []; $this->dependencies = []; $this->resolving = []; $this->resolved = []; return $this; }
[ "public", "function", "flush", "(", ")", ":", "ContainerInterface", "{", "$", "this", "->", "collection", "=", "[", "]", ";", "$", "this", "->", "dependencies", "=", "[", "]", ";", "$", "this", "->", "resolving", "=", "[", "]", ";", "$", "this", "->", "resolved", "=", "[", "]", ";", "return", "$", "this", ";", "}" ]
Reset the container, removing all the elements, cache and options. @return ContainerInterface
[ "Reset", "the", "container", "removing", "all", "the", "elements", "cache", "and", "options", "." ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L235-L243
21,492
codeburnerframework/container
src/Container.php
Container.isSingleton
public function isSingleton(string $abstract) : bool { if (! $this->has($abstract)) { throw new NotFoundException("Element '$abstract' not found"); } return $this->collection[$abstract] instanceof Closure === false; }
php
public function isSingleton(string $abstract) : bool { if (! $this->has($abstract)) { throw new NotFoundException("Element '$abstract' not found"); } return $this->collection[$abstract] instanceof Closure === false; }
[ "public", "function", "isSingleton", "(", "string", "$", "abstract", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "abstract", ")", ")", "{", "throw", "new", "NotFoundException", "(", "\"Element '$abstract' not found\"", ")", ";", "}", "return", "$", "this", "->", "collection", "[", "$", "abstract", "]", "instanceof", "Closure", "===", "false", ";", "}" ]
Verify if an element has a singleton instance. @param string The class name or container element name to resolve dependencies. @throws NotFoundException When $abstract does not exists @return bool
[ "Verify", "if", "an", "element", "has", "a", "singleton", "instance", "." ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L298-L305
21,493
codeburnerframework/container
src/Container.php
Container.set
public function set(string $abstract, $concrete, bool $shared = false) : ContainerInterface { if (is_object($concrete)) { return $this->instance($abstract, $concrete); } if ($concrete instanceof Closure === false) { $concrete = function (Container $container) use ($concrete) { return $container->make($concrete); }; } if ($shared === true) { $this->collection[$abstract] = $concrete($this); } else $this->collection[$abstract] = $concrete; return $this; }
php
public function set(string $abstract, $concrete, bool $shared = false) : ContainerInterface { if (is_object($concrete)) { return $this->instance($abstract, $concrete); } if ($concrete instanceof Closure === false) { $concrete = function (Container $container) use ($concrete) { return $container->make($concrete); }; } if ($shared === true) { $this->collection[$abstract] = $concrete($this); } else $this->collection[$abstract] = $concrete; return $this; }
[ "public", "function", "set", "(", "string", "$", "abstract", ",", "$", "concrete", ",", "bool", "$", "shared", "=", "false", ")", ":", "ContainerInterface", "{", "if", "(", "is_object", "(", "$", "concrete", ")", ")", "{", "return", "$", "this", "->", "instance", "(", "$", "abstract", ",", "$", "concrete", ")", ";", "}", "if", "(", "$", "concrete", "instanceof", "Closure", "===", "false", ")", "{", "$", "concrete", "=", "function", "(", "Container", "$", "container", ")", "use", "(", "$", "concrete", ")", "{", "return", "$", "container", "->", "make", "(", "$", "concrete", ")", ";", "}", ";", "}", "if", "(", "$", "shared", "===", "true", ")", "{", "$", "this", "->", "collection", "[", "$", "abstract", "]", "=", "$", "concrete", "(", "$", "this", ")", ";", "}", "else", "$", "this", "->", "collection", "[", "$", "abstract", "]", "=", "$", "concrete", ";", "return", "$", "this", ";", "}" ]
Bind a new element to the container. @param string $abstract The alias name that will be used to call the element. @param string|closure|object $concrete The element class name, or an closure that makes the element, or the object itself. @param bool $shared Define if the element will be a singleton instance. @return ContainerInterface
[ "Bind", "a", "new", "element", "to", "the", "container", "." ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L335-L352
21,494
codeburnerframework/container
src/Container.php
Container.setIf
public function setIf(string $abstract, $concrete, bool $shared = false) : ContainerInterface { if (! $this->has($abstract)) { $this->set($abstract, $concrete, $shared); } return $this; }
php
public function setIf(string $abstract, $concrete, bool $shared = false) : ContainerInterface { if (! $this->has($abstract)) { $this->set($abstract, $concrete, $shared); } return $this; }
[ "public", "function", "setIf", "(", "string", "$", "abstract", ",", "$", "concrete", ",", "bool", "$", "shared", "=", "false", ")", ":", "ContainerInterface", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "abstract", ")", ")", "{", "$", "this", "->", "set", "(", "$", "abstract", ",", "$", "concrete", ",", "$", "shared", ")", ";", "}", "return", "$", "this", ";", "}" ]
Bind a new element to the container IF the element name not exists in the container. @param string $abstract The alias name that will be used to call the element. @param string|closure $concrete The element class name, or an closure that makes the element. @param bool $shared Define if the element will be a singleton instance. @return ContainerInterface
[ "Bind", "a", "new", "element", "to", "the", "container", "IF", "the", "element", "name", "not", "exists", "in", "the", "container", "." ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L364-L371
21,495
codeburnerframework/container
src/Container.php
Container.setTo
public function setTo(string $class, string $dependencyName, $dependency) : ContainerInterface { $key = "$class$dependencyName"; if ($dependency instanceof Closure === false) { // let's use temporarily the set method to resolve // the $dependency if it is not a closure ready to use. $this->set($key, $dependency); $resolved = $this->collection[$key]; // now we already have a resolved version of $dependency // we just need to ensure the dependencies type, a closure. $dependency = function () use ($resolved) { return $resolved; }; // we have used the set method to resolve the $dependency // now that we have done all the process let's clear the memory. unset($resolved, $this->collection[$key]); } $this->dependencies[$key] = $dependency; return $this; }
php
public function setTo(string $class, string $dependencyName, $dependency) : ContainerInterface { $key = "$class$dependencyName"; if ($dependency instanceof Closure === false) { // let's use temporarily the set method to resolve // the $dependency if it is not a closure ready to use. $this->set($key, $dependency); $resolved = $this->collection[$key]; // now we already have a resolved version of $dependency // we just need to ensure the dependencies type, a closure. $dependency = function () use ($resolved) { return $resolved; }; // we have used the set method to resolve the $dependency // now that we have done all the process let's clear the memory. unset($resolved, $this->collection[$key]); } $this->dependencies[$key] = $dependency; return $this; }
[ "public", "function", "setTo", "(", "string", "$", "class", ",", "string", "$", "dependencyName", ",", "$", "dependency", ")", ":", "ContainerInterface", "{", "$", "key", "=", "\"$class$dependencyName\"", ";", "if", "(", "$", "dependency", "instanceof", "Closure", "===", "false", ")", "{", "// let's use temporarily the set method to resolve", "// the $dependency if it is not a closure ready to use.", "$", "this", "->", "set", "(", "$", "key", ",", "$", "dependency", ")", ";", "$", "resolved", "=", "$", "this", "->", "collection", "[", "$", "key", "]", ";", "// now we already have a resolved version of $dependency", "// we just need to ensure the dependencies type, a closure.", "$", "dependency", "=", "function", "(", ")", "use", "(", "$", "resolved", ")", "{", "return", "$", "resolved", ";", "}", ";", "// we have used the set method to resolve the $dependency", "// now that we have done all the process let's clear the memory.", "unset", "(", "$", "resolved", ",", "$", "this", "->", "collection", "[", "$", "key", "]", ")", ";", "}", "$", "this", "->", "dependencies", "[", "$", "key", "]", "=", "$", "dependency", ";", "return", "$", "this", ";", "}" ]
Bind an specific instance to a class dependency. @param string $class The class full name. @param string $dependencyName The dependency full name. @param string|closure $dependency The specific object class name or a classure that makes the element. @return ContainerInterface
[ "Bind", "an", "specific", "instance", "to", "a", "class", "dependency", "." ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L383-L411
21,496
codeburnerframework/container
src/Container.php
Container.instance
public function instance(string $abstract, $instance) : ContainerInterface { if (! is_object($instance)) { throw new ContainerException('Trying to store ' . gettype($instance) . ' as object.'); } $this->collection[$abstract] = $instance; return $this; }
php
public function instance(string $abstract, $instance) : ContainerInterface { if (! is_object($instance)) { throw new ContainerException('Trying to store ' . gettype($instance) . ' as object.'); } $this->collection[$abstract] = $instance; return $this; }
[ "public", "function", "instance", "(", "string", "$", "abstract", ",", "$", "instance", ")", ":", "ContainerInterface", "{", "if", "(", "!", "is_object", "(", "$", "instance", ")", ")", "{", "throw", "new", "ContainerException", "(", "'Trying to store '", ".", "gettype", "(", "$", "instance", ")", ".", "' as object.'", ")", ";", "}", "$", "this", "->", "collection", "[", "$", "abstract", "]", "=", "$", "instance", ";", "return", "$", "this", ";", "}" ]
Bind an object to the container. @param string $abstract The alias name that will be used to call the object. @param object $instance The object that will be inserted. @throws ContainerException When $instance is not an object. @return ContainerInterface
[ "Bind", "an", "object", "to", "the", "container", "." ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L440-L449
21,497
codeburnerframework/container
src/Container.php
Container.extend
public function extend(string $abstract, closure $extension) : ContainerInterface { $object = $this->get($abstract); $this->collection[$abstract] = $extension($object, $this); return $this; }
php
public function extend(string $abstract, closure $extension) : ContainerInterface { $object = $this->get($abstract); $this->collection[$abstract] = $extension($object, $this); return $this; }
[ "public", "function", "extend", "(", "string", "$", "abstract", ",", "closure", "$", "extension", ")", ":", "ContainerInterface", "{", "$", "object", "=", "$", "this", "->", "get", "(", "$", "abstract", ")", ";", "$", "this", "->", "collection", "[", "$", "abstract", "]", "=", "$", "extension", "(", "$", "object", ",", "$", "this", ")", ";", "return", "$", "this", ";", "}" ]
Modify an element with a given function that receive the old element as argument. @param string $abstract The alias name that will be used to call the element. @param closure $extension The function that receives the old element and return a new or modified one. @throws NotFoundException When no element was found with $abstract key. @return ContainerInterface
[ "Modify", "an", "element", "with", "a", "given", "function", "that", "receive", "the", "old", "element", "as", "argument", "." ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L461-L468
21,498
codeburnerframework/container
src/Container.php
Container.share
public function share(string $abstract) : ContainerInterface { $object = $this->get($abstract); $this->collection[$abstract] = $object; return $this; }
php
public function share(string $abstract) : ContainerInterface { $object = $this->get($abstract); $this->collection[$abstract] = $object; return $this; }
[ "public", "function", "share", "(", "string", "$", "abstract", ")", ":", "ContainerInterface", "{", "$", "object", "=", "$", "this", "->", "get", "(", "$", "abstract", ")", ";", "$", "this", "->", "collection", "[", "$", "abstract", "]", "=", "$", "object", ";", "return", "$", "this", ";", "}" ]
Makes an resolvable element an singleton. @param string $abstract The alias name that will be used to call the element. @throws NotFoundException When no element was found with $abstract key. @throws ContainerException When the element on $abstract key is not resolvable. @return ContainerInterface
[ "Makes", "an", "resolvable", "element", "an", "singleton", "." ]
aab42fdf1fa5d2043696dcc9d886cef4532b31b5
https://github.com/codeburnerframework/container/blob/aab42fdf1fa5d2043696dcc9d886cef4532b31b5/src/Container.php#L481-L488
21,499
nabab/bbn
src/bbn/util/timer.php
timer.start
public function start($key='default') { if ( !isset($this->measures[$key]) ){ $this->measures[$key] = [ 'num' => 0, 'sum' => 0, 'start' => microtime(1) ]; } else{ $this->measures[$key]['start'] = microtime(1); } }
php
public function start($key='default') { if ( !isset($this->measures[$key]) ){ $this->measures[$key] = [ 'num' => 0, 'sum' => 0, 'start' => microtime(1) ]; } else{ $this->measures[$key]['start'] = microtime(1); } }
[ "public", "function", "start", "(", "$", "key", "=", "'default'", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "measures", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "measures", "[", "$", "key", "]", "=", "[", "'num'", "=>", "0", ",", "'sum'", "=>", "0", ",", "'start'", "=>", "microtime", "(", "1", ")", "]", ";", "}", "else", "{", "$", "this", "->", "measures", "[", "$", "key", "]", "[", "'start'", "]", "=", "microtime", "(", "1", ")", ";", "}", "}" ]
Starts a timer for a given key @return void
[ "Starts", "a", "timer", "for", "a", "given", "key" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/util/timer.php#L34-L46