repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
php-lug/lug
src/Component/Translation/Repository/Doctrine/ORM/TranslatableRepository.php
TranslatableRepository.createQueryBuilder
public function createQueryBuilder($alias = null, $indexBy = null) { $queryBuilder = parent::createQueryBuilder($alias, $indexBy); $queryBuilder ->addSelect($alias = $this->getTranslationAlias($queryBuilder)) ->leftJoin($this->getProperty('translations', $queryBuilder), $alias); return $queryBuilder; }
php
public function createQueryBuilder($alias = null, $indexBy = null) { $queryBuilder = parent::createQueryBuilder($alias, $indexBy); $queryBuilder ->addSelect($alias = $this->getTranslationAlias($queryBuilder)) ->leftJoin($this->getProperty('translations', $queryBuilder), $alias); return $queryBuilder; }
[ "public", "function", "createQueryBuilder", "(", "$", "alias", "=", "null", ",", "$", "indexBy", "=", "null", ")", "{", "$", "queryBuilder", "=", "parent", "::", "createQueryBuilder", "(", "$", "alias", ",", "$", "indexBy", ")", ";", "$", "queryBuilder", "->", "addSelect", "(", "$", "alias", "=", "$", "this", "->", "getTranslationAlias", "(", "$", "queryBuilder", ")", ")", "->", "leftJoin", "(", "$", "this", "->", "getProperty", "(", "'translations'", ",", "$", "queryBuilder", ")", ",", "$", "alias", ")", ";", "return", "$", "queryBuilder", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Translation/Repository/Doctrine/ORM/TranslatableRepository.php#L57-L65
php-lug/lug
src/Component/Translation/Repository/Doctrine/ORM/TranslatableRepository.php
TranslatableRepository.createQueryBuilderForCollection
public function createQueryBuilderForCollection($alias = null, $indexBy = null) { $queryBuilder = parent::createQueryBuilder($alias, $indexBy); $queryBuilder ->addSelect($alias = $this->getTranslationAlias($queryBuilder)) ->innerJoin( $this->getProperty('translations', $queryBuilder), $alias, Join::WITH, $queryBuilder->expr()->in($this->getProperty('locale', $queryBuilder), $this->getLocales()) ); return $queryBuilder; }
php
public function createQueryBuilderForCollection($alias = null, $indexBy = null) { $queryBuilder = parent::createQueryBuilder($alias, $indexBy); $queryBuilder ->addSelect($alias = $this->getTranslationAlias($queryBuilder)) ->innerJoin( $this->getProperty('translations', $queryBuilder), $alias, Join::WITH, $queryBuilder->expr()->in($this->getProperty('locale', $queryBuilder), $this->getLocales()) ); return $queryBuilder; }
[ "public", "function", "createQueryBuilderForCollection", "(", "$", "alias", "=", "null", ",", "$", "indexBy", "=", "null", ")", "{", "$", "queryBuilder", "=", "parent", "::", "createQueryBuilder", "(", "$", "alias", ",", "$", "indexBy", ")", ";", "$", "queryBuilder", "->", "addSelect", "(", "$", "alias", "=", "$", "this", "->", "getTranslationAlias", "(", "$", "queryBuilder", ")", ")", "->", "innerJoin", "(", "$", "this", "->", "getProperty", "(", "'translations'", ",", "$", "queryBuilder", ")", ",", "$", "alias", ",", "Join", "::", "WITH", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "$", "this", "->", "getProperty", "(", "'locale'", ",", "$", "queryBuilder", ")", ",", "$", "this", "->", "getLocales", "(", ")", ")", ")", ";", "return", "$", "queryBuilder", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Translation/Repository/Doctrine/ORM/TranslatableRepository.php#L70-L83
php-lug/lug
src/Component/Translation/Repository/Doctrine/ORM/TranslatableRepository.php
TranslatableRepository.getProperty
public function getProperty($property, $root = null) { if ($this->cache === null) { $translationMetadata = $this ->getEntityManager() ->getClassMetadata($this->getClassMetadata()->getAssociationMapping('translations')['targetEntity']); $this->cache = array_diff( $this->getProperties($translationMetadata), $this->getProperties($this->getClassMetadata()) ); } if (in_array($this->getRootProperty($property), $this->cache, true)) { $root = $this->getTranslationAlias($root); } return parent::getProperty($property, $root); }
php
public function getProperty($property, $root = null) { if ($this->cache === null) { $translationMetadata = $this ->getEntityManager() ->getClassMetadata($this->getClassMetadata()->getAssociationMapping('translations')['targetEntity']); $this->cache = array_diff( $this->getProperties($translationMetadata), $this->getProperties($this->getClassMetadata()) ); } if (in_array($this->getRootProperty($property), $this->cache, true)) { $root = $this->getTranslationAlias($root); } return parent::getProperty($property, $root); }
[ "public", "function", "getProperty", "(", "$", "property", ",", "$", "root", "=", "null", ")", "{", "if", "(", "$", "this", "->", "cache", "===", "null", ")", "{", "$", "translationMetadata", "=", "$", "this", "->", "getEntityManager", "(", ")", "->", "getClassMetadata", "(", "$", "this", "->", "getClassMetadata", "(", ")", "->", "getAssociationMapping", "(", "'translations'", ")", "[", "'targetEntity'", "]", ")", ";", "$", "this", "->", "cache", "=", "array_diff", "(", "$", "this", "->", "getProperties", "(", "$", "translationMetadata", ")", ",", "$", "this", "->", "getProperties", "(", "$", "this", "->", "getClassMetadata", "(", ")", ")", ")", ";", "}", "if", "(", "in_array", "(", "$", "this", "->", "getRootProperty", "(", "$", "property", ")", ",", "$", "this", "->", "cache", ",", "true", ")", ")", "{", "$", "root", "=", "$", "this", "->", "getTranslationAlias", "(", "$", "root", ")", ";", "}", "return", "parent", "::", "getProperty", "(", "$", "property", ",", "$", "root", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Translation/Repository/Doctrine/ORM/TranslatableRepository.php#L88-L106
php-lug/lug
src/Component/Translation/Repository/Doctrine/ORM/TranslatableRepository.php
TranslatableRepository.getRootProperty
private function getRootProperty($property) { return ($pos = strpos($property, '.')) !== false ? substr($property, 0, $pos) : $property; }
php
private function getRootProperty($property) { return ($pos = strpos($property, '.')) !== false ? substr($property, 0, $pos) : $property; }
[ "private", "function", "getRootProperty", "(", "$", "property", ")", "{", "return", "(", "$", "pos", "=", "strpos", "(", "$", "property", ",", "'.'", ")", ")", "!==", "false", "?", "substr", "(", "$", "property", ",", "0", ",", "$", "pos", ")", ":", "$", "property", ";", "}" ]
@param string $property @return string
[ "@param", "string", "$property" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Translation/Repository/Doctrine/ORM/TranslatableRepository.php#L150-L153
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", "." ]
train
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Service/UserNotificationService.php#L43-L54
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" ]
train
https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/NetDriver/AbstractNetDriver.php#L120-L134
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" ]
train
https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/NetDriver/AbstractNetDriver.php#L143-L153
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" ]
train
https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/NetDriver/AbstractNetDriver.php#L160-L170
zicht/z
src/Zicht/Tool/Script/Token.php
Token.match
public function match($type, $value = null) { if ($this->type === $type || (is_array($type) && in_array($this->type, $type))) { if (null === $value || $this->value == $value || (is_array($value) && in_array($this->value, $value))) { return true; } } return false; }
php
public function match($type, $value = null) { if ($this->type === $type || (is_array($type) && in_array($this->type, $type))) { if (null === $value || $this->value == $value || (is_array($value) && in_array($this->value, $value))) { return true; } } return false; }
[ "public", "function", "match", "(", "$", "type", ",", "$", "value", "=", "null", ")", "{", "if", "(", "$", "this", "->", "type", "===", "$", "type", "||", "(", "is_array", "(", "$", "type", ")", "&&", "in_array", "(", "$", "this", "->", "type", ",", "$", "type", ")", ")", ")", "{", "if", "(", "null", "===", "$", "value", "||", "$", "this", "->", "value", "==", "$", "value", "||", "(", "is_array", "(", "$", "value", ")", "&&", "in_array", "(", "$", "this", "->", "value", ",", "$", "value", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if the token matches the passed type and/or value @param mixed $type @param mixed $value @return bool
[ "Checks", "if", "the", "token", "matches", "the", "passed", "type", "and", "/", "or", "value" ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Script/Token.php#L91-L99
gromver/yii2-models
DynamicModel.php
DynamicModel.defineAttribute
public function defineAttribute($name, $field) { $field = BaseField::createField($field); $field->link($this, $name); $this->_attributes[$name] = $field; }
php
public function defineAttribute($name, $field) { $field = BaseField::createField($field); $field->link($this, $name); $this->_attributes[$name] = $field; }
[ "public", "function", "defineAttribute", "(", "$", "name", ",", "$", "field", ")", "{", "$", "field", "=", "BaseField", "::", "createField", "(", "$", "field", ")", ";", "$", "field", "->", "link", "(", "$", "this", ",", "$", "name", ")", ";", "$", "this", "->", "_attributes", "[", "$", "name", "]", "=", "$", "field", ";", "}" ]
Defines an attribute. @param string $name the attribute name @param BaseField|string|array $field the attribute value
[ "Defines", "an", "attribute", "." ]
train
https://github.com/gromver/yii2-models/blob/1be954f19ebf90f330d89974ffd6022c766332e1/DynamicModel.php#L81-L88
maestroprog/saw-php
src/Config/ApplicationConfig.php
ApplicationConfig.getApplicationIdByClass
public function getApplicationIdByClass(string $class): string { foreach ($this->applications as $appId => $appConfig) { if ($appConfig['class'] === $class) { return $appId; } } throw new \RuntimeException('Application id not found.', Saw::ERROR_APPLICATION_CLASS_NOT_EXISTS); }
php
public function getApplicationIdByClass(string $class): string { foreach ($this->applications as $appId => $appConfig) { if ($appConfig['class'] === $class) { return $appId; } } throw new \RuntimeException('Application id not found.', Saw::ERROR_APPLICATION_CLASS_NOT_EXISTS); }
[ "public", "function", "getApplicationIdByClass", "(", "string", "$", "class", ")", ":", "string", "{", "foreach", "(", "$", "this", "->", "applications", "as", "$", "appId", "=>", "$", "appConfig", ")", "{", "if", "(", "$", "appConfig", "[", "'class'", "]", "===", "$", "class", ")", "{", "return", "$", "appId", ";", "}", "}", "throw", "new", "\\", "RuntimeException", "(", "'Application id not found.'", ",", "Saw", "::", "ERROR_APPLICATION_CLASS_NOT_EXISTS", ")", ";", "}" ]
Вернёт id приложения по его классу. Если одному классу приложения соответсвует несколько id, то лучше этот метод не использовать. @param string $class @return string
[ "Вернёт", "id", "приложения", "по", "его", "классу", ".", "Если", "одному", "классу", "приложения", "соответсвует", "несколько", "id", "то", "лучше", "этот", "метод", "не", "использовать", "." ]
train
https://github.com/maestroprog/saw-php/blob/159215a4d7a951cca2a9c2eed3e1aa4f5b624cfb/src/Config/ApplicationConfig.php#L59-L67
maestroprog/saw-php
src/Config/ApplicationConfig.php
ApplicationConfig.getApplicationArguments
public function getApplicationArguments(string $applicationId): array { if (!isset($this->applications[$applicationId])) { throw new \UnexpectedValueException('Unexpected application id: ' . $applicationId); } return $this->applications[$applicationId]['arguments'] ?? []; }
php
public function getApplicationArguments(string $applicationId): array { if (!isset($this->applications[$applicationId])) { throw new \UnexpectedValueException('Unexpected application id: ' . $applicationId); } return $this->applications[$applicationId]['arguments'] ?? []; }
[ "public", "function", "getApplicationArguments", "(", "string", "$", "applicationId", ")", ":", "array", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "applications", "[", "$", "applicationId", "]", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Unexpected application id: '", ".", "$", "applicationId", ")", ";", "}", "return", "$", "this", "->", "applications", "[", "$", "applicationId", "]", "[", "'arguments'", "]", "??", "[", "]", ";", "}" ]
Вернёт в виде массива список аргументов, необходимых для создания инстанса объекта приложения. @param string $applicationId @return array
[ "Вернёт", "в", "виде", "массива", "список", "аргументов", "необходимых", "для", "создания", "инстанса", "объекта", "приложения", "." ]
train
https://github.com/maestroprog/saw-php/blob/159215a4d7a951cca2a9c2eed3e1aa4f5b624cfb/src/Config/ApplicationConfig.php#L86-L92
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.filterByIsDefault
public function filterByIsDefault($isDefault = null, $comparison = null) { if (is_string($isDefault)) { $is_default = in_array(strtolower($isDefault), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; } return $this->addUsingAlias(CustomerGroupTableMap::IS_DEFAULT, $isDefault, $comparison); }
php
public function filterByIsDefault($isDefault = null, $comparison = null) { if (is_string($isDefault)) { $is_default = in_array(strtolower($isDefault), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; } return $this->addUsingAlias(CustomerGroupTableMap::IS_DEFAULT, $isDefault, $comparison); }
[ "public", "function", "filterByIsDefault", "(", "$", "isDefault", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "isDefault", ")", ")", "{", "$", "is_default", "=", "in_array", "(", "strtolower", "(", "$", "isDefault", ")", ",", "array", "(", "'false'", ",", "'off'", ",", "'-'", ",", "'no'", ",", "'n'", ",", "'0'", ",", "''", ")", ")", "?", "false", ":", "true", ";", "}", "return", "$", "this", "->", "addUsingAlias", "(", "CustomerGroupTableMap", "::", "IS_DEFAULT", ",", "$", "isDefault", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the is_default column Example usage: <code> $query->filterByIsDefault(true); // WHERE is_default = true $query->filterByIsDefault('yes'); // WHERE is_default = true </code> @param boolean|string $isDefault The value to use as filter. Non-boolean arguments are converted using the following rules: * 1, '1', 'true', 'on', and 'yes' are converted to boolean true * 0, '0', 'false', 'off', and 'no' are converted to boolean false Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). @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", "on", "the", "is_default", "column" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L291-L298
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" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L476-L489
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" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L534-L539
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" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L549-L562
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" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L607-L612
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" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L623-L629
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.prune
public function prune($customerGroup = null) { if ($customerGroup) { $this->addUsingAlias(CustomerGroupTableMap::ID, $customerGroup->getId(), Criteria::NOT_EQUAL); } return $this; }
php
public function prune($customerGroup = null) { if ($customerGroup) { $this->addUsingAlias(CustomerGroupTableMap::ID, $customerGroup->getId(), Criteria::NOT_EQUAL); } return $this; }
[ "public", "function", "prune", "(", "$", "customerGroup", "=", "null", ")", "{", "if", "(", "$", "customerGroup", ")", "{", "$", "this", "->", "addUsingAlias", "(", "CustomerGroupTableMap", "::", "ID", ",", "$", "customerGroup", "->", "getId", "(", ")", ",", "Criteria", "::", "NOT_EQUAL", ")", ";", "}", "return", "$", "this", ";", "}" ]
Exclude object from result @param ChildCustomerGroup $customerGroup Object to remove from the list of results @return ChildCustomerGroupQuery The current query, for fluid interface
[ "Exclude", "object", "from", "result" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L638-L645
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.orderByRank
public function orderByRank($order = Criteria::ASC) { $order = strtoupper($order); switch ($order) { case Criteria::ASC: return $this->addAscendingOrderByColumn($this->getAliasedColName(CustomerGroupTableMap::RANK_COL)); break; case Criteria::DESC: return $this->addDescendingOrderByColumn($this->getAliasedColName(CustomerGroupTableMap::RANK_COL)); break; default: throw new \Propel\Runtime\Exception\PropelException('ChildCustomerGroupQuery::orderBy() only accepts "asc" or "desc" as argument'); } }
php
public function orderByRank($order = Criteria::ASC) { $order = strtoupper($order); switch ($order) { case Criteria::ASC: return $this->addAscendingOrderByColumn($this->getAliasedColName(CustomerGroupTableMap::RANK_COL)); break; case Criteria::DESC: return $this->addDescendingOrderByColumn($this->getAliasedColName(CustomerGroupTableMap::RANK_COL)); break; default: throw new \Propel\Runtime\Exception\PropelException('ChildCustomerGroupQuery::orderBy() only accepts "asc" or "desc" as argument'); } }
[ "public", "function", "orderByRank", "(", "$", "order", "=", "Criteria", "::", "ASC", ")", "{", "$", "order", "=", "strtoupper", "(", "$", "order", ")", ";", "switch", "(", "$", "order", ")", "{", "case", "Criteria", "::", "ASC", ":", "return", "$", "this", "->", "addAscendingOrderByColumn", "(", "$", "this", "->", "getAliasedColName", "(", "CustomerGroupTableMap", "::", "RANK_COL", ")", ")", ";", "break", ";", "case", "Criteria", "::", "DESC", ":", "return", "$", "this", "->", "addDescendingOrderByColumn", "(", "$", "this", "->", "getAliasedColName", "(", "CustomerGroupTableMap", "::", "RANK_COL", ")", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "Propel", "\\", "Runtime", "\\", "Exception", "\\", "PropelException", "(", "'ChildCustomerGroupQuery::orderBy() only accepts \"asc\" or \"desc\" as argument'", ")", ";", "}", "}" ]
Order the query based on the rank in the list. Using the default $order, returns the item with the lowest rank first @param string $order either Criteria::ASC (default) or Criteria::DESC @return ChildCustomerGroupQuery The current query, for fluid interface
[ "Order", "the", "query", "based", "on", "the", "rank", "in", "the", "list", ".", "Using", "the", "default", "$order", "returns", "the", "item", "with", "the", "lowest", "rank", "first" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L869-L882
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.findOneByRank
public function findOneByRank($rank, ConnectionInterface $con = null) { return $this ->filterByRank($rank) ->findOne($con); }
php
public function findOneByRank($rank, ConnectionInterface $con = null) { return $this ->filterByRank($rank) ->findOne($con); }
[ "public", "function", "findOneByRank", "(", "$", "rank", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "return", "$", "this", "->", "filterByRank", "(", "$", "rank", ")", "->", "findOne", "(", "$", "con", ")", ";", "}" ]
Get an item from the list based on its rank @param integer $rank rank @param ConnectionInterface $con optional connection @return ChildCustomerGroup
[ "Get", "an", "item", "from", "the", "list", "based", "on", "its", "rank" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L892-L898
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" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L922-L932
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", "." ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L941-L951
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.retrieveByRank
static public function retrieveByRank($rank, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getReadConnection(CustomerGroupTableMap::DATABASE_NAME); } $c = new Criteria; $c->add(CustomerGroupTableMap::RANK_COL, $rank); return static::create(null, $c)->findOne($con); }
php
static public function retrieveByRank($rank, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getReadConnection(CustomerGroupTableMap::DATABASE_NAME); } $c = new Criteria; $c->add(CustomerGroupTableMap::RANK_COL, $rank); return static::create(null, $c)->findOne($con); }
[ "static", "public", "function", "retrieveByRank", "(", "$", "rank", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getReadConnection", "(", "CustomerGroupTableMap", "::", "DATABASE_NAME", ")", ";", "}", "$", "c", "=", "new", "Criteria", ";", "$", "c", "->", "add", "(", "CustomerGroupTableMap", "::", "RANK_COL", ",", "$", "rank", ")", ";", "return", "static", "::", "create", "(", "null", ",", "$", "c", ")", "->", "findOne", "(", "$", "con", ")", ";", "}" ]
Get an item from the list based on its rank @param integer $rank rank @param ConnectionInterface $con optional connection @return ChildCustomerGroup
[ "Get", "an", "item", "from", "the", "list", "based", "on", "its", "rank" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L961-L971
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.reorder
public function reorder($order, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getReadConnection(CustomerGroupTableMap::DATABASE_NAME); } $con->beginTransaction(); try { $ids = array_keys($order); $objects = $this->findPks($ids, $con); foreach ($objects as $object) { $pk = $object->getPrimaryKey(); if ($object->getPosition() != $order[$pk]) { $object->setPosition($order[$pk]); $object->save($con); } } $con->commit(); return true; } catch (\Propel\Runtime\Exception\PropelException $e) { $con->rollback(); throw $e; } }
php
public function reorder($order, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getReadConnection(CustomerGroupTableMap::DATABASE_NAME); } $con->beginTransaction(); try { $ids = array_keys($order); $objects = $this->findPks($ids, $con); foreach ($objects as $object) { $pk = $object->getPrimaryKey(); if ($object->getPosition() != $order[$pk]) { $object->setPosition($order[$pk]); $object->save($con); } } $con->commit(); return true; } catch (\Propel\Runtime\Exception\PropelException $e) { $con->rollback(); throw $e; } }
[ "public", "function", "reorder", "(", "$", "order", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getReadConnection", "(", "CustomerGroupTableMap", "::", "DATABASE_NAME", ")", ";", "}", "$", "con", "->", "beginTransaction", "(", ")", ";", "try", "{", "$", "ids", "=", "array_keys", "(", "$", "order", ")", ";", "$", "objects", "=", "$", "this", "->", "findPks", "(", "$", "ids", ",", "$", "con", ")", ";", "foreach", "(", "$", "objects", "as", "$", "object", ")", "{", "$", "pk", "=", "$", "object", "->", "getPrimaryKey", "(", ")", ";", "if", "(", "$", "object", "->", "getPosition", "(", ")", "!=", "$", "order", "[", "$", "pk", "]", ")", "{", "$", "object", "->", "setPosition", "(", "$", "order", "[", "$", "pk", "]", ")", ";", "$", "object", "->", "save", "(", "$", "con", ")", ";", "}", "}", "$", "con", "->", "commit", "(", ")", ";", "return", "true", ";", "}", "catch", "(", "\\", "Propel", "\\", "Runtime", "\\", "Exception", "\\", "PropelException", "$", "e", ")", "{", "$", "con", "->", "rollback", "(", ")", ";", "throw", "$", "e", ";", "}", "}" ]
Reorder a set of sortable objects based on a list of id/position Beware that there is no check made on the positions passed So incoherent positions will result in an incoherent list @param mixed $order id => rank pairs @param ConnectionInterface $con optional connection @return boolean true if the reordering took place, false if a database problem prevented it
[ "Reorder", "a", "set", "of", "sortable", "objects", "based", "on", "a", "list", "of", "id", "/", "position", "Beware", "that", "there", "is", "no", "check", "made", "on", "the", "positions", "passed", "So", "incoherent", "positions", "will", "result", "in", "an", "incoherent", "list" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L983-L1007
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" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L1018-L1039
thelia-modules/CustomerGroup
Model/Base/CustomerGroupQuery.php
CustomerGroupQuery.sortableShiftRank
static public function sortableShiftRank($delta, $first, $last = null, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME); } $whereCriteria = new Criteria(CustomerGroupTableMap::DATABASE_NAME); $criterion = $whereCriteria->getNewCriterion(CustomerGroupTableMap::RANK_COL, $first, Criteria::GREATER_EQUAL); if (null !== $last) { $criterion->addAnd($whereCriteria->getNewCriterion(CustomerGroupTableMap::RANK_COL, $last, Criteria::LESS_EQUAL)); } $whereCriteria->add($criterion); $valuesCriteria = new Criteria(CustomerGroupTableMap::DATABASE_NAME); $valuesCriteria->add(CustomerGroupTableMap::RANK_COL, array('raw' => CustomerGroupTableMap::RANK_COL . ' + ?', 'value' => $delta), Criteria::CUSTOM_EQUAL); $whereCriteria->doUpdate($valuesCriteria, $con); CustomerGroupTableMap::clearInstancePool(); }
php
static public function sortableShiftRank($delta, $first, $last = null, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupTableMap::DATABASE_NAME); } $whereCriteria = new Criteria(CustomerGroupTableMap::DATABASE_NAME); $criterion = $whereCriteria->getNewCriterion(CustomerGroupTableMap::RANK_COL, $first, Criteria::GREATER_EQUAL); if (null !== $last) { $criterion->addAnd($whereCriteria->getNewCriterion(CustomerGroupTableMap::RANK_COL, $last, Criteria::LESS_EQUAL)); } $whereCriteria->add($criterion); $valuesCriteria = new Criteria(CustomerGroupTableMap::DATABASE_NAME); $valuesCriteria->add(CustomerGroupTableMap::RANK_COL, array('raw' => CustomerGroupTableMap::RANK_COL . ' + ?', 'value' => $delta), Criteria::CUSTOM_EQUAL); $whereCriteria->doUpdate($valuesCriteria, $con); CustomerGroupTableMap::clearInstancePool(); }
[ "static", "public", "function", "sortableShiftRank", "(", "$", "delta", ",", "$", "first", ",", "$", "last", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getWriteConnection", "(", "CustomerGroupTableMap", "::", "DATABASE_NAME", ")", ";", "}", "$", "whereCriteria", "=", "new", "Criteria", "(", "CustomerGroupTableMap", "::", "DATABASE_NAME", ")", ";", "$", "criterion", "=", "$", "whereCriteria", "->", "getNewCriterion", "(", "CustomerGroupTableMap", "::", "RANK_COL", ",", "$", "first", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "if", "(", "null", "!==", "$", "last", ")", "{", "$", "criterion", "->", "addAnd", "(", "$", "whereCriteria", "->", "getNewCriterion", "(", "CustomerGroupTableMap", "::", "RANK_COL", ",", "$", "last", ",", "Criteria", "::", "LESS_EQUAL", ")", ")", ";", "}", "$", "whereCriteria", "->", "add", "(", "$", "criterion", ")", ";", "$", "valuesCriteria", "=", "new", "Criteria", "(", "CustomerGroupTableMap", "::", "DATABASE_NAME", ")", ";", "$", "valuesCriteria", "->", "add", "(", "CustomerGroupTableMap", "::", "RANK_COL", ",", "array", "(", "'raw'", "=>", "CustomerGroupTableMap", "::", "RANK_COL", ".", "' + ?'", ",", "'value'", "=>", "$", "delta", ")", ",", "Criteria", "::", "CUSTOM_EQUAL", ")", ";", "$", "whereCriteria", "->", "doUpdate", "(", "$", "valuesCriteria", ",", "$", "con", ")", ";", "CustomerGroupTableMap", "::", "clearInstancePool", "(", ")", ";", "}" ]
Adds $delta to all Rank values that are >= $first and <= $last. '$delta' can also be negative. @param int $delta Value to be shifted by, can be negative @param int $first First node to be shifted @param int $last Last node to be shifted @param ConnectionInterface $con Connection to use.
[ "Adds", "$delta", "to", "all", "Rank", "values", "that", "are", ">", "=", "$first", "and", "<", "=", "$last", ".", "$delta", "can", "also", "be", "negative", "." ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupQuery.php#L1050-L1068
php-lug/lug
src/Component/Grid/Model/Builder/SortBuilder.php
SortBuilder.build
public function build(array $config) { return new Sort( $this->buildName($config), $this->buildType($config), $this->buildOptions($config) ); }
php
public function build(array $config) { return new Sort( $this->buildName($config), $this->buildType($config), $this->buildOptions($config) ); }
[ "public", "function", "build", "(", "array", "$", "config", ")", "{", "return", "new", "Sort", "(", "$", "this", "->", "buildName", "(", "$", "config", ")", ",", "$", "this", "->", "buildType", "(", "$", "config", ")", ",", "$", "this", "->", "buildOptions", "(", "$", "config", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Model/Builder/SortBuilder.php#L24-L31
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", "." ]
train
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Controller/UserGroupController.php#L141-L150
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", "." ]
train
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Controller/UserGroupController.php#L191-L224
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", "." ]
train
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Controller/UserGroupController.php#L253-L262
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", "." ]
train
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Controller/UserGroupController.php#L273-L287
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", "." ]
train
https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/RewriteRoutingChecks.php#L27-L37
xiewulong/yii2-fileupload
oss/libs/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php
GenericEvent.getArgument
public function getArgument($key) { if ($this->hasArgument($key)) { return $this->arguments[$key]; } throw new \InvalidArgumentException(sprintf('%s not found in %s', $key, $this->getName())); }
php
public function getArgument($key) { if ($this->hasArgument($key)) { return $this->arguments[$key]; } throw new \InvalidArgumentException(sprintf('%s not found in %s', $key, $this->getName())); }
[ "public", "function", "getArgument", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "hasArgument", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "arguments", "[", "$", "key", "]", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'%s not found in %s'", ",", "$", "key", ",", "$", "this", "->", "getName", "(", ")", ")", ")", ";", "}" ]
Get argument by key. @param string $key Key. @throws \InvalidArgumentException If key is not found. @return mixed Contents of array key.
[ "Get", "argument", "by", "key", "." ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php#L68-L75
phPoirot/psr7
UploadedFile.php
UploadedFile.moveTo
function moveTo($targetPath) { if ($this->isFileMoved) throw new \RuntimeException('Cannot move file; already moved!'); $targetPath = (string) $targetPath; if (empty($targetPath)) throw new \InvalidArgumentException( 'Invalid path provided for move operation; must be a non-empty string' ); if (strpos(PHP_SAPI, 'cli') === 0 || !$this->getTmpName()) $this->_writeFileToGivenPath($targetPath); elseif (move_uploaded_file($this->getTmpName(), $targetPath) === false) throw new \RuntimeException('Error occurred while moving uploaded file'); $this->isFileMoved = true; }
php
function moveTo($targetPath) { if ($this->isFileMoved) throw new \RuntimeException('Cannot move file; already moved!'); $targetPath = (string) $targetPath; if (empty($targetPath)) throw new \InvalidArgumentException( 'Invalid path provided for move operation; must be a non-empty string' ); if (strpos(PHP_SAPI, 'cli') === 0 || !$this->getTmpName()) $this->_writeFileToGivenPath($targetPath); elseif (move_uploaded_file($this->getTmpName(), $targetPath) === false) throw new \RuntimeException('Error occurred while moving uploaded file'); $this->isFileMoved = true; }
[ "function", "moveTo", "(", "$", "targetPath", ")", "{", "if", "(", "$", "this", "->", "isFileMoved", ")", "throw", "new", "\\", "RuntimeException", "(", "'Cannot move file; already moved!'", ")", ";", "$", "targetPath", "=", "(", "string", ")", "$", "targetPath", ";", "if", "(", "empty", "(", "$", "targetPath", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid path provided for move operation; must be a non-empty string'", ")", ";", "if", "(", "strpos", "(", "PHP_SAPI", ",", "'cli'", ")", "===", "0", "||", "!", "$", "this", "->", "getTmpName", "(", ")", ")", "$", "this", "->", "_writeFileToGivenPath", "(", "$", "targetPath", ")", ";", "elseif", "(", "move_uploaded_file", "(", "$", "this", "->", "getTmpName", "(", ")", ",", "$", "targetPath", ")", "===", "false", ")", "throw", "new", "\\", "RuntimeException", "(", "'Error occurred while moving uploaded file'", ")", ";", "$", "this", "->", "isFileMoved", "=", "true", ";", "}" ]
{@inheritdoc} @see http://php.net/is_uploaded_file @see http://php.net/move_uploaded_file @param string $targetPath Path to which to move the uploaded file. @throws \InvalidArgumentException if the $path specified is invalid. @throws \RuntimeException on any error during the move operation, or on the second or subsequent call to the method.
[ "{", "@inheritdoc", "}" ]
train
https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/UploadedFile.php#L73-L92
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" ]
train
https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/UploadedFile.php#L99-L119
phPoirot/psr7
UploadedFile.php
UploadedFile.setStream
protected function setStream($resource) { if (!$resource instanceof StreamInterface && ! is_resource($resource)) throw new \InvalidArgumentException( 'Stream must instance of StreamInterface or php resource.' .' given: "%s"' , \Poirot\Std\flatten($resource) ); /** @see self::getStream */ $this->stream = null; # reset stream fot getStream $this->_c_givenResource = $resource; # stream will made of this when requested return $this; }
php
protected function setStream($resource) { if (!$resource instanceof StreamInterface && ! is_resource($resource)) throw new \InvalidArgumentException( 'Stream must instance of StreamInterface or php resource.' .' given: "%s"' , \Poirot\Std\flatten($resource) ); /** @see self::getStream */ $this->stream = null; # reset stream fot getStream $this->_c_givenResource = $resource; # stream will made of this when requested return $this; }
[ "protected", "function", "setStream", "(", "$", "resource", ")", "{", "if", "(", "!", "$", "resource", "instanceof", "StreamInterface", "&&", "!", "is_resource", "(", "$", "resource", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "'Stream must instance of StreamInterface or php resource.'", ".", "' given: \"%s\"'", ",", "\\", "Poirot", "\\", "Std", "\\", "flatten", "(", "$", "resource", ")", ")", ";", "/** @see self::getStream */", "$", "this", "->", "stream", "=", "null", ";", "# reset stream fot getStream", "$", "this", "->", "_c_givenResource", "=", "$", "resource", ";", "# stream will made of this when requested", "return", "$", "this", ";", "}" ]
Set Stream @param StreamInterface|resource $resource @return $this
[ "Set", "Stream" ]
train
https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/UploadedFile.php#L171-L185
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" ]
train
https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/UploadedFile.php#L194-L201
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" ]
train
https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/UploadedFile.php#L243-L257
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" ]
train
https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/UploadedFile.php#L293-L306
unclecheese/silverstripe-blubber
code/CSSBlubberTask.php
CSSBlubberTask.index
public function index() { $this->theme = Config::inst()->get('SSViewer', 'theme'); $this->cssDir = self::config()->theme_css_dir ? Controller::join_links(BASE_PATH, self::config()->theme_css_dir) : Controller::join_links(BASE_PATH, $this->ThemeDir()); $this->gatherCSSFiles(); $this->output->writeln(); $this->output->write('Loading templates...'); $this->loadTemplates(); $this->output->write('Loading page URLs...'); $this->output->clearProgress(); $this->loadURLs(); foreach($this->cssFiles as $css) { $file = CSSBlubberFile::create($css); $this->output->writeln(); $this->output->write("Parsing file <caution>" . basename($css) . "</caution>..."); $file->parse(); $this->output->writeln(); $blocks = $file->getBlocks(); $totalBlocks = sizeof($blocks); $totalSamples = sizeof($this->samples); $used = $unused = 0; $this->output->writeln("==> Checking $totalBlocks declaration blocks against $totalSamples html samples... "); foreach($blocks as $block) { $found = false; foreach($block->getSelectors() as $selector) { $s = $selector->getSelector(); // no pseudo elements if(stristr($selector,':')) continue; foreach($this->samples as $html) { $this->crawler->clear(); $this->crawler->addContent($html); $dom = $this->crawler->filter($s); if(sizeof($dom) > 0) { $used++; $found = true; $file->removeBlubber($block); break 2; } } } if(!$found) { $unused++; $file->removeLean($block); } $this->output->updateProgress(sprintf( " %s%% complete [Used: <success>%s</success> | Unused: <error>%s</error> | %s%% lean]", floor((($used+$unused)/$totalBlocks)*100), $used, $unused, floor(($used/($used+$unused))*100) )); } $this->output->writeln(); $this->output->writeln(); $this->output->writeln("Writing $unused rules to <info>{$file->getBlubberName()}</info>"); $file->saveBlubber(); $this->output->writeln("Writing $used rules to <info>{$file->getLeanName()}</info>"); $file->saveLean(); } }
php
public function index() { $this->theme = Config::inst()->get('SSViewer', 'theme'); $this->cssDir = self::config()->theme_css_dir ? Controller::join_links(BASE_PATH, self::config()->theme_css_dir) : Controller::join_links(BASE_PATH, $this->ThemeDir()); $this->gatherCSSFiles(); $this->output->writeln(); $this->output->write('Loading templates...'); $this->loadTemplates(); $this->output->write('Loading page URLs...'); $this->output->clearProgress(); $this->loadURLs(); foreach($this->cssFiles as $css) { $file = CSSBlubberFile::create($css); $this->output->writeln(); $this->output->write("Parsing file <caution>" . basename($css) . "</caution>..."); $file->parse(); $this->output->writeln(); $blocks = $file->getBlocks(); $totalBlocks = sizeof($blocks); $totalSamples = sizeof($this->samples); $used = $unused = 0; $this->output->writeln("==> Checking $totalBlocks declaration blocks against $totalSamples html samples... "); foreach($blocks as $block) { $found = false; foreach($block->getSelectors() as $selector) { $s = $selector->getSelector(); // no pseudo elements if(stristr($selector,':')) continue; foreach($this->samples as $html) { $this->crawler->clear(); $this->crawler->addContent($html); $dom = $this->crawler->filter($s); if(sizeof($dom) > 0) { $used++; $found = true; $file->removeBlubber($block); break 2; } } } if(!$found) { $unused++; $file->removeLean($block); } $this->output->updateProgress(sprintf( " %s%% complete [Used: <success>%s</success> | Unused: <error>%s</error> | %s%% lean]", floor((($used+$unused)/$totalBlocks)*100), $used, $unused, floor(($used/($used+$unused))*100) )); } $this->output->writeln(); $this->output->writeln(); $this->output->writeln("Writing $unused rules to <info>{$file->getBlubberName()}</info>"); $file->saveBlubber(); $this->output->writeln("Writing $used rules to <info>{$file->getLeanName()}</info>"); $file->saveLean(); } }
[ "public", "function", "index", "(", ")", "{", "$", "this", "->", "theme", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "'SSViewer'", ",", "'theme'", ")", ";", "$", "this", "->", "cssDir", "=", "self", "::", "config", "(", ")", "->", "theme_css_dir", "?", "Controller", "::", "join_links", "(", "BASE_PATH", ",", "self", "::", "config", "(", ")", "->", "theme_css_dir", ")", ":", "Controller", "::", "join_links", "(", "BASE_PATH", ",", "$", "this", "->", "ThemeDir", "(", ")", ")", ";", "$", "this", "->", "gatherCSSFiles", "(", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", ")", ";", "$", "this", "->", "output", "->", "write", "(", "'Loading templates...'", ")", ";", "$", "this", "->", "loadTemplates", "(", ")", ";", "$", "this", "->", "output", "->", "write", "(", "'Loading page URLs...'", ")", ";", "$", "this", "->", "output", "->", "clearProgress", "(", ")", ";", "$", "this", "->", "loadURLs", "(", ")", ";", "foreach", "(", "$", "this", "->", "cssFiles", "as", "$", "css", ")", "{", "$", "file", "=", "CSSBlubberFile", "::", "create", "(", "$", "css", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", ")", ";", "$", "this", "->", "output", "->", "write", "(", "\"Parsing file <caution>\"", ".", "basename", "(", "$", "css", ")", ".", "\"</caution>...\"", ")", ";", "$", "file", "->", "parse", "(", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", ")", ";", "$", "blocks", "=", "$", "file", "->", "getBlocks", "(", ")", ";", "$", "totalBlocks", "=", "sizeof", "(", "$", "blocks", ")", ";", "$", "totalSamples", "=", "sizeof", "(", "$", "this", "->", "samples", ")", ";", "$", "used", "=", "$", "unused", "=", "0", ";", "$", "this", "->", "output", "->", "writeln", "(", "\"==> Checking $totalBlocks declaration blocks against $totalSamples html samples... \"", ")", ";", "foreach", "(", "$", "blocks", "as", "$", "block", ")", "{", "$", "found", "=", "false", ";", "foreach", "(", "$", "block", "->", "getSelectors", "(", ")", "as", "$", "selector", ")", "{", "$", "s", "=", "$", "selector", "->", "getSelector", "(", ")", ";", "// no pseudo elements", "if", "(", "stristr", "(", "$", "selector", ",", "':'", ")", ")", "continue", ";", "foreach", "(", "$", "this", "->", "samples", "as", "$", "html", ")", "{", "$", "this", "->", "crawler", "->", "clear", "(", ")", ";", "$", "this", "->", "crawler", "->", "addContent", "(", "$", "html", ")", ";", "$", "dom", "=", "$", "this", "->", "crawler", "->", "filter", "(", "$", "s", ")", ";", "if", "(", "sizeof", "(", "$", "dom", ")", ">", "0", ")", "{", "$", "used", "++", ";", "$", "found", "=", "true", ";", "$", "file", "->", "removeBlubber", "(", "$", "block", ")", ";", "break", "2", ";", "}", "}", "}", "if", "(", "!", "$", "found", ")", "{", "$", "unused", "++", ";", "$", "file", "->", "removeLean", "(", "$", "block", ")", ";", "}", "$", "this", "->", "output", "->", "updateProgress", "(", "sprintf", "(", "\" %s%% complete [Used: <success>%s</success> | Unused: <error>%s</error> | %s%% lean]\"", ",", "floor", "(", "(", "(", "$", "used", "+", "$", "unused", ")", "/", "$", "totalBlocks", ")", "*", "100", ")", ",", "$", "used", ",", "$", "unused", ",", "floor", "(", "(", "$", "used", "/", "(", "$", "used", "+", "$", "unused", ")", ")", "*", "100", ")", ")", ")", ";", "}", "$", "this", "->", "output", "->", "writeln", "(", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", "\"Writing $unused rules to <info>{$file->getBlubberName()}</info>\"", ")", ";", "$", "file", "->", "saveBlubber", "(", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", "\"Writing $used rules to <info>{$file->getLeanName()}</info>\"", ")", ";", "$", "file", "->", "saveLean", "(", ")", ";", "}", "}" ]
Runs the task
[ "Runs", "the", "task" ]
train
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/CSSBlubberTask.php#L83-L154
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" ]
train
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/CSSBlubberTask.php#L159-L175
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" ]
train
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/CSSBlubberTask.php#L180-L196
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" ]
train
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/CSSBlubberTask.php#L201-L254
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" ]
train
https://github.com/unclecheese/silverstripe-blubber/blob/f2549bd5eddeb0ca0303a3c09be4a8136fcc6661/code/CSSBlubberTask.php#L261-L269
GrupaZero/social
src/Gzero/Social/ServiceProvider.php
ServiceProvider.boot
public function boot() { $viewPath = __DIR__ . '/../../resources/views'; $translationPath = __DIR__ . '/../../resources/lang'; $this->loadMigrationsFrom(__DIR__ . '/../../../database/migrations'); $this->loadViewsFrom($viewPath, 'gzero-social'); $this->loadTranslationsFrom($translationPath, 'gzero-social'); $this->loadRoutesFrom(__DIR__ . '/../../../routes/routes.php'); $this->addLinksToUserMenu(); $this->publishes( [ $viewPath => base_path('resources/views/vendor/gzero-social') ], 'views' ); $this->publishes( [ $translationPath => base_path('resources/lang/vendor/gzero-social'), ], 'lang' ); $this->registerHelpers(); }
php
public function boot() { $viewPath = __DIR__ . '/../../resources/views'; $translationPath = __DIR__ . '/../../resources/lang'; $this->loadMigrationsFrom(__DIR__ . '/../../../database/migrations'); $this->loadViewsFrom($viewPath, 'gzero-social'); $this->loadTranslationsFrom($translationPath, 'gzero-social'); $this->loadRoutesFrom(__DIR__ . '/../../../routes/routes.php'); $this->addLinksToUserMenu(); $this->publishes( [ $viewPath => base_path('resources/views/vendor/gzero-social') ], 'views' ); $this->publishes( [ $translationPath => base_path('resources/lang/vendor/gzero-social'), ], 'lang' ); $this->registerHelpers(); }
[ "public", "function", "boot", "(", ")", "{", "$", "viewPath", "=", "__DIR__", ".", "'/../../resources/views'", ";", "$", "translationPath", "=", "__DIR__", ".", "'/../../resources/lang'", ";", "$", "this", "->", "loadMigrationsFrom", "(", "__DIR__", ".", "'/../../../database/migrations'", ")", ";", "$", "this", "->", "loadViewsFrom", "(", "$", "viewPath", ",", "'gzero-social'", ")", ";", "$", "this", "->", "loadTranslationsFrom", "(", "$", "translationPath", ",", "'gzero-social'", ")", ";", "$", "this", "->", "loadRoutesFrom", "(", "__DIR__", ".", "'/../../../routes/routes.php'", ")", ";", "$", "this", "->", "addLinksToUserMenu", "(", ")", ";", "$", "this", "->", "publishes", "(", "[", "$", "viewPath", "=>", "base_path", "(", "'resources/views/vendor/gzero-social'", ")", "]", ",", "'views'", ")", ";", "$", "this", "->", "publishes", "(", "[", "$", "translationPath", "=>", "base_path", "(", "'resources/lang/vendor/gzero-social'", ")", ",", "]", ",", "'lang'", ")", ";", "$", "this", "->", "registerHelpers", "(", ")", ";", "}" ]
Bootstrap the application events. WARNING: Order of execution functions in boot is important, because we're using translations in our routes @return void
[ "Bootstrap", "the", "application", "events", ".", "WARNING", ":", "Order", "of", "execution", "functions", "in", "boot", "is", "important", "because", "we", "re", "using", "translations", "in", "our", "routes" ]
train
https://github.com/GrupaZero/social/blob/f7cbf50765bd228010a2c61d950f915828306cf7/src/Gzero/Social/ServiceProvider.php#L53-L75
nabab/bbn
src/bbn/models/tts/optional.php
optional.optional_init
protected static function optional_init(){ if ( !self::$optional_is_init ){ $opt = bbn\appui\options::get_instance(); if ( !$opt ){ die("There is no options object as needed by ".__CLASS__); } if ( !\defined("BBN_APPUI") ){ \define('BBN_APPUI', $opt->from_code('appui')); } if ( !\defined("BBN_APPUI_ROOT") ){ \define('BBN_APPUI_ROOT', $opt->from_root_code('appui')); } if ( !BBN_APPUI || !BBN_APPUI_ROOT ){ die('Impossible to find the option appui for '.__CLASS__); } $tmp = explode('\\', __CLASS__); $cls = end($tmp); self::$option_appui_id = $opt->from_code($cls, BBN_APPUI_ROOT); self::$option_root_id = $opt->from_code($cls, BBN_APPUI); if ( !self::$option_appui_id || !self::$option_root_id ){ if ( defined('BBN_IS_DEV') && BBN_IS_DEV ){ die(bbn\x::hdump("Impossible to find the option $cls for ".__CLASS__)); } die("Impossible to find the option $cls for ".__CLASS__); } self::$optional_is_init = true; } }
php
protected static function optional_init(){ if ( !self::$optional_is_init ){ $opt = bbn\appui\options::get_instance(); if ( !$opt ){ die("There is no options object as needed by ".__CLASS__); } if ( !\defined("BBN_APPUI") ){ \define('BBN_APPUI', $opt->from_code('appui')); } if ( !\defined("BBN_APPUI_ROOT") ){ \define('BBN_APPUI_ROOT', $opt->from_root_code('appui')); } if ( !BBN_APPUI || !BBN_APPUI_ROOT ){ die('Impossible to find the option appui for '.__CLASS__); } $tmp = explode('\\', __CLASS__); $cls = end($tmp); self::$option_appui_id = $opt->from_code($cls, BBN_APPUI_ROOT); self::$option_root_id = $opt->from_code($cls, BBN_APPUI); if ( !self::$option_appui_id || !self::$option_root_id ){ if ( defined('BBN_IS_DEV') && BBN_IS_DEV ){ die(bbn\x::hdump("Impossible to find the option $cls for ".__CLASS__)); } die("Impossible to find the option $cls for ".__CLASS__); } self::$optional_is_init = true; } }
[ "protected", "static", "function", "optional_init", "(", ")", "{", "if", "(", "!", "self", "::", "$", "optional_is_init", ")", "{", "$", "opt", "=", "bbn", "\\", "appui", "\\", "options", "::", "get_instance", "(", ")", ";", "if", "(", "!", "$", "opt", ")", "{", "die", "(", "\"There is no options object as needed by \"", ".", "__CLASS__", ")", ";", "}", "if", "(", "!", "\\", "defined", "(", "\"BBN_APPUI\"", ")", ")", "{", "\\", "define", "(", "'BBN_APPUI'", ",", "$", "opt", "->", "from_code", "(", "'appui'", ")", ")", ";", "}", "if", "(", "!", "\\", "defined", "(", "\"BBN_APPUI_ROOT\"", ")", ")", "{", "\\", "define", "(", "'BBN_APPUI_ROOT'", ",", "$", "opt", "->", "from_root_code", "(", "'appui'", ")", ")", ";", "}", "if", "(", "!", "BBN_APPUI", "||", "!", "BBN_APPUI_ROOT", ")", "{", "die", "(", "'Impossible to find the option appui for '", ".", "__CLASS__", ")", ";", "}", "$", "tmp", "=", "explode", "(", "'\\\\'", ",", "__CLASS__", ")", ";", "$", "cls", "=", "end", "(", "$", "tmp", ")", ";", "self", "::", "$", "option_appui_id", "=", "$", "opt", "->", "from_code", "(", "$", "cls", ",", "BBN_APPUI_ROOT", ")", ";", "self", "::", "$", "option_root_id", "=", "$", "opt", "->", "from_code", "(", "$", "cls", ",", "BBN_APPUI", ")", ";", "if", "(", "!", "self", "::", "$", "option_appui_id", "||", "!", "self", "::", "$", "option_root_id", ")", "{", "if", "(", "defined", "(", "'BBN_IS_DEV'", ")", "&&", "BBN_IS_DEV", ")", "{", "die", "(", "bbn", "\\", "x", "::", "hdump", "(", "\"Impossible to find the option $cls for \"", ".", "__CLASS__", ")", ")", ";", "}", "die", "(", "\"Impossible to find the option $cls for \"", ".", "__CLASS__", ")", ";", "}", "self", "::", "$", "optional_is_init", "=", "true", ";", "}", "}" ]
Returns the option's root ID for the current class based on {@link $option_root_code} @return false|int
[ "Returns", "the", "option", "s", "root", "ID", "for", "the", "current", "class", "based", "on", "{", "@link", "$option_root_code", "}" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/models/tts/optional.php#L36-L63
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" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/models/tts/optional.php#L115-L117
php-lug/lug
src/Component/Grid/Model/Builder/BatchBuilder.php
BatchBuilder.build
public function build(array $config) { return new Batch( $this->buildName($config), $this->buildLabel($config), $this->buildType($config), $this->buildOptions($config) ); }
php
public function build(array $config) { return new Batch( $this->buildName($config), $this->buildLabel($config), $this->buildType($config), $this->buildOptions($config) ); }
[ "public", "function", "build", "(", "array", "$", "config", ")", "{", "return", "new", "Batch", "(", "$", "this", "->", "buildName", "(", "$", "config", ")", ",", "$", "this", "->", "buildLabel", "(", "$", "config", ")", ",", "$", "this", "->", "buildType", "(", "$", "config", ")", ",", "$", "this", "->", "buildOptions", "(", "$", "config", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Model/Builder/BatchBuilder.php#L25-L33
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", "." ]
train
https://github.com/kusanagi/katana-sdk-php7/blob/91e7860a1852c3ce79a7034f8c36f41840e69e1f/src/Api/TypeCatalog.php#L63-L82
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", "." ]
train
https://github.com/kusanagi/katana-sdk-php7/blob/91e7860a1852c3ce79a7034f8c36f41840e69e1f/src/Api/TypeCatalog.php#L92-L120
mustardandrew/muan-laravel-acl
src/Commands/Role/DetachPermissionCommand.php
DetachPermissionCommand.handle
public function handle() { $roleName = $this->argument('role'); if (! $role = Role::whereName($roleName)->first()) { $this->warn("Role {$roleName} not exists."); return 1; } $attachList = array_merge($this->option('id'), $this->option('name')); $role->detachPermission($attachList); echo "Detached permissions. Done!", PHP_EOL; return 0; }
php
public function handle() { $roleName = $this->argument('role'); if (! $role = Role::whereName($roleName)->first()) { $this->warn("Role {$roleName} not exists."); return 1; } $attachList = array_merge($this->option('id'), $this->option('name')); $role->detachPermission($attachList); echo "Detached permissions. Done!", PHP_EOL; return 0; }
[ "public", "function", "handle", "(", ")", "{", "$", "roleName", "=", "$", "this", "->", "argument", "(", "'role'", ")", ";", "if", "(", "!", "$", "role", "=", "Role", "::", "whereName", "(", "$", "roleName", ")", "->", "first", "(", ")", ")", "{", "$", "this", "->", "warn", "(", "\"Role {$roleName} not exists.\"", ")", ";", "return", "1", ";", "}", "$", "attachList", "=", "array_merge", "(", "$", "this", "->", "option", "(", "'id'", ")", ",", "$", "this", "->", "option", "(", "'name'", ")", ")", ";", "$", "role", "->", "detachPermission", "(", "$", "attachList", ")", ";", "echo", "\"Detached permissions. Done!\"", ",", "PHP_EOL", ";", "return", "0", ";", "}" ]
Execute the console command. @return mixed
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Commands/Role/DetachPermissionCommand.php#L36-L51
j-d/draggy
src/Draggy/Autocode/Templates/Java/Entity.php
Entity.getAttributeDocumentationLinesBasePart
public function getAttributeDocumentationLinesBasePart(JavaAttribute $attribute) { $lines = []; if (null !== $attribute->getDescription()) { $lines[] = $attribute->getDescription(); $lines[] = ''; } $lines[] = '@var ' . $attribute->getType() . ' ' . $attribute->getLowerFullName(); return $lines; }
php
public function getAttributeDocumentationLinesBasePart(JavaAttribute $attribute) { $lines = []; if (null !== $attribute->getDescription()) { $lines[] = $attribute->getDescription(); $lines[] = ''; } $lines[] = '@var ' . $attribute->getType() . ' ' . $attribute->getLowerFullName(); return $lines; }
[ "public", "function", "getAttributeDocumentationLinesBasePart", "(", "JavaAttribute", "$", "attribute", ")", "{", "$", "lines", "=", "[", "]", ";", "if", "(", "null", "!==", "$", "attribute", "->", "getDescription", "(", ")", ")", "{", "$", "lines", "[", "]", "=", "$", "attribute", "->", "getDescription", "(", ")", ";", "$", "lines", "[", "]", "=", "''", ";", "}", "$", "lines", "[", "]", "=", "'@var '", ".", "$", "attribute", "->", "getType", "(", ")", ".", "' '", ".", "$", "attribute", "->", "getLowerFullName", "(", ")", ";", "return", "$", "lines", ";", "}" ]
<editor-fold desc="Attributes">
[ "<editor", "-", "fold", "desc", "=", "Attributes", ">" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/Java/Entity.php#L86-L98
j-d/draggy
src/Draggy/Autocode/Templates/Java/Entity.php
Entity.getSetterCodeDocumentationParameterLines
public function getSetterCodeDocumentationParameterLines(JavaAttribute $attribute) { $lines = []; $lines[] = '@param ' . $attribute->getType() . ' ' . $attribute->getLowerFullName(); return $lines; }
php
public function getSetterCodeDocumentationParameterLines(JavaAttribute $attribute) { $lines = []; $lines[] = '@param ' . $attribute->getType() . ' ' . $attribute->getLowerFullName(); return $lines; }
[ "public", "function", "getSetterCodeDocumentationParameterLines", "(", "JavaAttribute", "$", "attribute", ")", "{", "$", "lines", "=", "[", "]", ";", "$", "lines", "[", "]", "=", "'@param '", ".", "$", "attribute", "->", "getType", "(", ")", ".", "' '", ".", "$", "attribute", "->", "getLowerFullName", "(", ")", ";", "return", "$", "lines", ";", "}" ]
<editor-fold desc="Setters">
[ "<editor", "-", "fold", "desc", "=", "Setters", ">" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/Java/Entity.php#L122-L129
j-d/draggy
src/Draggy/Autocode/Templates/Java/Entity.php
Entity.getGetterCodeDocumentationLines
public function getGetterCodeDocumentationLines(JavaAttribute $attribute) { $lines = []; $lines[] = 'Get ' . $attribute->getLowerFullName(); $lines[] = ''; $lines[] = '@return ' . ('object' === $attribute->getType() ? $attribute->getEntitySubtype()->getName() : $attribute->getType()); return $lines; }
php
public function getGetterCodeDocumentationLines(JavaAttribute $attribute) { $lines = []; $lines[] = 'Get ' . $attribute->getLowerFullName(); $lines[] = ''; $lines[] = '@return ' . ('object' === $attribute->getType() ? $attribute->getEntitySubtype()->getName() : $attribute->getType()); return $lines; }
[ "public", "function", "getGetterCodeDocumentationLines", "(", "JavaAttribute", "$", "attribute", ")", "{", "$", "lines", "=", "[", "]", ";", "$", "lines", "[", "]", "=", "'Get '", ".", "$", "attribute", "->", "getLowerFullName", "(", ")", ";", "$", "lines", "[", "]", "=", "''", ";", "$", "lines", "[", "]", "=", "'@return '", ".", "(", "'object'", "===", "$", "attribute", "->", "getType", "(", ")", "?", "$", "attribute", "->", "getEntitySubtype", "(", ")", "->", "getName", "(", ")", ":", "$", "attribute", "->", "getType", "(", ")", ")", ";", "return", "$", "lines", ";", "}" ]
<editor-fold desc="Getters">
[ "<editor", "-", "fold", "desc", "=", "Getters", ">" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/Java/Entity.php#L195-L204
j-d/draggy
src/Draggy/Autocode/Templates/Java/Entity.php
Entity.getEntityToStringDocumentationLines
public function getEntityToStringDocumentationLines() { $lines = []; $line = $this->getEntity()->getName() . ' to string '; $line .= null === $this->getEntity()->getToString() ? '(Default)' : '(' . $this->getEntity()->getToString() . ')'; $lines[] = $line; $lines[] = ''; $lines[] = '@return String'; return $lines; }
php
public function getEntityToStringDocumentationLines() { $lines = []; $line = $this->getEntity()->getName() . ' to string '; $line .= null === $this->getEntity()->getToString() ? '(Default)' : '(' . $this->getEntity()->getToString() . ')'; $lines[] = $line; $lines[] = ''; $lines[] = '@return String'; return $lines; }
[ "public", "function", "getEntityToStringDocumentationLines", "(", ")", "{", "$", "lines", "=", "[", "]", ";", "$", "line", "=", "$", "this", "->", "getEntity", "(", ")", "->", "getName", "(", ")", ".", "' to string '", ";", "$", "line", ".=", "null", "===", "$", "this", "->", "getEntity", "(", ")", "->", "getToString", "(", ")", "?", "'(Default)'", ":", "'('", ".", "$", "this", "->", "getEntity", "(", ")", "->", "getToString", "(", ")", ".", "')'", ";", "$", "lines", "[", "]", "=", "$", "line", ";", "$", "lines", "[", "]", "=", "''", ";", "$", "lines", "[", "]", "=", "'@return String'", ";", "return", "$", "lines", ";", "}" ]
<editor-fold desc="toString">
[ "<editor", "-", "fold", "desc", "=", "toString", ">" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/Java/Entity.php#L231-L248
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", "." ]
train
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L29-L37
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", "." ]
train
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L81-L86
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", "." ]
train
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L96-L100
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", "." ]
train
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L159-L166
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", "." ]
train
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L202-L215
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", "." ]
train
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L224-L247
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", "." ]
train
https://github.com/crysalead/inflector/blob/07a890c43debebcfaeffe1c30a504f954e9a463c/src/Inflector.php#L266-L464
jasny/controller
src/Controller/View/Twig.php
Twig.getViewer
public function getViewer() { if (!isset($this->viewer)) { $this->viewer = $this->createTwigView(['path' => $this->getViewPath()]); $this->viewer->addDefaultExtensions(); } return $this->viewer; }
php
public function getViewer() { if (!isset($this->viewer)) { $this->viewer = $this->createTwigView(['path' => $this->getViewPath()]); $this->viewer->addDefaultExtensions(); } return $this->viewer; }
[ "public", "function", "getViewer", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "viewer", ")", ")", "{", "$", "this", "->", "viewer", "=", "$", "this", "->", "createTwigView", "(", "[", "'path'", "=>", "$", "this", "->", "getViewPath", "(", ")", "]", ")", ";", "$", "this", "->", "viewer", "->", "addDefaultExtensions", "(", ")", ";", "}", "return", "$", "this", "->", "viewer", ";", "}" ]
Get the template engine abstraction @return TwigView
[ "Get", "the", "template", "engine", "abstraction" ]
train
https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/View/Twig.php#L20-L28
Eresus/EresusCMS
src/core/Client/FrontController.php
Eresus_Client_FrontController.dispatch
public function dispatch() { Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'starting...'); /** @var TClientUI $page */ $page = $this->getPage(); $response = $page->render($this->getRequest()); Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'done'); return $response; }
php
public function dispatch() { Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'starting...'); /** @var TClientUI $page */ $page = $this->getPage(); $response = $page->render($this->getRequest()); Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'done'); return $response; }
[ "public", "function", "dispatch", "(", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_DEBUG", ",", "'starting...'", ")", ";", "/** @var TClientUI $page */", "$", "page", "=", "$", "this", "->", "getPage", "(", ")", ";", "$", "response", "=", "$", "page", "->", "render", "(", "$", "this", "->", "getRequest", "(", ")", ")", ";", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_DEBUG", ",", "'done'", ")", ";", "return", "$", "response", ";", "}" ]
Выполняет действия контроллера и возвращает ответ @return Eresus_HTTP_Response @since 3.01
[ "Выполняет", "действия", "контроллера", "и", "возвращает", "ответ" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Client/FrontController.php#L43-L52
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", "." ]
train
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Form/Field/HasMany.php#L391-L424
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" ]
train
https://github.com/dragonmantank/fillet/blob/b197947608c05ac2318e8f6b296345494004d9c6/src/Fillet/Parser/WordpressExport.php#L18-L61
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", "." ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailMap.php#L53-L62
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", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/XmlConfiguration.php#L85-L87
ekuiter/feature-php
FeaturePhp/Model/XmlConfiguration.php
XmlConfiguration.fromRequest
public static function fromRequest($key, $allowEmpty = false) { if (empty($_REQUEST[$key]) && !$allowEmpty) throw new XmlConfigurationException("no configuration in request"); else if (empty($_REQUEST[$key])) return self::emptyInstance(); else $str = $_REQUEST[$key]; return new self((new fphp\Helper\XmlParser())->parseString($str)); }
php
public static function fromRequest($key, $allowEmpty = false) { if (empty($_REQUEST[$key]) && !$allowEmpty) throw new XmlConfigurationException("no configuration in request"); else if (empty($_REQUEST[$key])) return self::emptyInstance(); else $str = $_REQUEST[$key]; return new self((new fphp\Helper\XmlParser())->parseString($str)); }
[ "public", "static", "function", "fromRequest", "(", "$", "key", ",", "$", "allowEmpty", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "_REQUEST", "[", "$", "key", "]", ")", "&&", "!", "$", "allowEmpty", ")", "throw", "new", "XmlConfigurationException", "(", "\"no configuration in request\"", ")", ";", "else", "if", "(", "empty", "(", "$", "_REQUEST", "[", "$", "key", "]", ")", ")", "return", "self", "::", "emptyInstance", "(", ")", ";", "else", "$", "str", "=", "$", "_REQUEST", "[", "$", "key", "]", ";", "return", "new", "self", "(", "(", "new", "fphp", "\\", "Helper", "\\", "XmlParser", "(", ")", ")", "->", "parseString", "(", "$", "str", ")", ")", ";", "}" ]
Creates an XML configuration from a request variable. For simple usage, the configuration can be read from GET, POST or cookie. A note on security: This function is safe to use in production scenarios (assuming the safety of the SimpleXML parser) because a configuration is always validated against the feature model. @param string $key the variable in the request @param bool $allowEmpty whether to throw an exception when no configuration is present @return XmlConfiguration
[ "Creates", "an", "XML", "configuration", "from", "a", "request", "variable", ".", "For", "simple", "usage", "the", "configuration", "can", "be", "read", "from", "GET", "POST", "or", "cookie", ".", "A", "note", "on", "security", ":", "This", "function", "is", "safe", "to", "use", "in", "production", "scenarios", "(", "assuming", "the", "safety", "of", "the", "SimpleXML", "parser", ")", "because", "a", "configuration", "is", "always", "validated", "against", "the", "feature", "model", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/XmlConfiguration.php#L99-L107
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", "." ]
train
https://github.com/shabbyrobe/amiss/blob/ba261f0d1f985ed36e9fd2903ac0df86c5b9498d/src/Sql/Type/Date.php#L140-L155
soloproyectos-php/text-parser
src/text/parser/TextParser.php
TextParser.parse
public function parse($string = "") { if (func_num_args() > 0) { $this->string = $string; $this->offset = 0; } $ungreedy = TextParser::UNGREEDY & $this->_flags; $ret = $this->evaluate(); if ($ret) { if ($this->_target instanceof TextParser) { $this->_target->setOffset($this->offset); } elseif (!$ungreedy && !$this->end()) { throw new TextParserException("Unrecognized expression", $this); } } return $ret; }
php
public function parse($string = "") { if (func_num_args() > 0) { $this->string = $string; $this->offset = 0; } $ungreedy = TextParser::UNGREEDY & $this->_flags; $ret = $this->evaluate(); if ($ret) { if ($this->_target instanceof TextParser) { $this->_target->setOffset($this->offset); } elseif (!$ungreedy && !$this->end()) { throw new TextParserException("Unrecognized expression", $this); } } return $ret; }
[ "public", "function", "parse", "(", "$", "string", "=", "\"\"", ")", "{", "if", "(", "func_num_args", "(", ")", ">", "0", ")", "{", "$", "this", "->", "string", "=", "$", "string", ";", "$", "this", "->", "offset", "=", "0", ";", "}", "$", "ungreedy", "=", "TextParser", "::", "UNGREEDY", "&", "$", "this", "->", "_flags", ";", "$", "ret", "=", "$", "this", "->", "evaluate", "(", ")", ";", "if", "(", "$", "ret", ")", "{", "if", "(", "$", "this", "->", "_target", "instanceof", "TextParser", ")", "{", "$", "this", "->", "_target", "->", "setOffset", "(", "$", "this", "->", "offset", ")", ";", "}", "elseif", "(", "!", "$", "ungreedy", "&&", "!", "$", "this", "->", "end", "(", ")", ")", "{", "throw", "new", "TextParserException", "(", "\"Unrecognized expression\"", ",", "$", "this", ")", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Parses a string. This function parses a string and throws an exception if unsuccessful. For example: ```php // parses a string $p = new MyCustomParser($string); try { $info = $p->parse(); } catch(TextParserException $e) { echo $e->getPrintableMessage(); } if (!$info) { echo "This is not a valid expressión"; } else { print_r($info); } ``` @param string $string String target (default is "") @throws Exception @return mixed
[ "Parses", "a", "string", "." ]
train
https://github.com/soloproyectos-php/text-parser/blob/3ef2e8a26f7c53b170383d74ccf4106b0f3dd8b1/src/text/parser/TextParser.php#L100-L119
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?" ]
train
https://github.com/soloproyectos-php/text-parser/blob/3ef2e8a26f7c53b170383d74ccf4106b0f3dd8b1/src/text/parser/TextParser.php#L132-L161
php-lug/lug
src/Bundle/ResourceBundle/Routing/ParameterResolver.php
ParameterResolver.resolveApi
public function resolveApi() { if (($request = $this->resolveRequest()) === null) { return true; } return $this->resolveParameter('api', false) || $request->getRequestFormat() !== 'html'; }
php
public function resolveApi() { if (($request = $this->resolveRequest()) === null) { return true; } return $this->resolveParameter('api', false) || $request->getRequestFormat() !== 'html'; }
[ "public", "function", "resolveApi", "(", ")", "{", "if", "(", "(", "$", "request", "=", "$", "this", "->", "resolveRequest", "(", ")", ")", "===", "null", ")", "{", "return", "true", ";", "}", "return", "$", "this", "->", "resolveParameter", "(", "'api'", ",", "false", ")", "||", "$", "request", "->", "getRequestFormat", "(", ")", "!==", "'html'", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/ParameterResolver.php#L49-L56
php-lug/lug
src/Bundle/ResourceBundle/Routing/ParameterResolver.php
ParameterResolver.resolveCriteria
public function resolveCriteria($mandatory = false) { if (($request = $this->resolveRequest()) === null) { if ($mandatory) { throw new RequestNotFoundException(); } return []; } $value = $this->resolveParameter('criteria', ['id']); if (empty($value) && $mandatory) { throw new RuntimeException(sprintf( 'The criteria could not be found for the route "%s".', $request->attributes->get('_route') )); } $criteria = []; foreach ($value as $identifier) { $value = $request->get($identifier); if ($value === null) { throw new RuntimeException(sprintf( 'The criteria "%s" could not be found for the route "%s".', $identifier, $request->attributes->get('_route') )); } $criteria[$identifier] = $value; } return $criteria; }
php
public function resolveCriteria($mandatory = false) { if (($request = $this->resolveRequest()) === null) { if ($mandatory) { throw new RequestNotFoundException(); } return []; } $value = $this->resolveParameter('criteria', ['id']); if (empty($value) && $mandatory) { throw new RuntimeException(sprintf( 'The criteria could not be found for the route "%s".', $request->attributes->get('_route') )); } $criteria = []; foreach ($value as $identifier) { $value = $request->get($identifier); if ($value === null) { throw new RuntimeException(sprintf( 'The criteria "%s" could not be found for the route "%s".', $identifier, $request->attributes->get('_route') )); } $criteria[$identifier] = $value; } return $criteria; }
[ "public", "function", "resolveCriteria", "(", "$", "mandatory", "=", "false", ")", "{", "if", "(", "(", "$", "request", "=", "$", "this", "->", "resolveRequest", "(", ")", ")", "===", "null", ")", "{", "if", "(", "$", "mandatory", ")", "{", "throw", "new", "RequestNotFoundException", "(", ")", ";", "}", "return", "[", "]", ";", "}", "$", "value", "=", "$", "this", "->", "resolveParameter", "(", "'criteria'", ",", "[", "'id'", "]", ")", ";", "if", "(", "empty", "(", "$", "value", ")", "&&", "$", "mandatory", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'The criteria could not be found for the route \"%s\".'", ",", "$", "request", "->", "attributes", "->", "get", "(", "'_route'", ")", ")", ")", ";", "}", "$", "criteria", "=", "[", "]", ";", "foreach", "(", "$", "value", "as", "$", "identifier", ")", "{", "$", "value", "=", "$", "request", "->", "get", "(", "$", "identifier", ")", ";", "if", "(", "$", "value", "===", "null", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'The criteria \"%s\" could not be found for the route \"%s\".'", ",", "$", "identifier", ",", "$", "request", "->", "attributes", "->", "get", "(", "'_route'", ")", ")", ")", ";", "}", "$", "criteria", "[", "$", "identifier", "]", "=", "$", "value", ";", "}", "return", "$", "criteria", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/ParameterResolver.php#L61-L97
php-lug/lug
src/Bundle/ResourceBundle/Routing/ParameterResolver.php
ParameterResolver.resolveGrid
public function resolveGrid(ResourceInterface $resource) { if (($request = $this->resolveRequest()) === null) { throw new RequestNotFoundException(); } return array_merge(['resource' => $resource], $this->resolveParameter('grid', [])); }
php
public function resolveGrid(ResourceInterface $resource) { if (($request = $this->resolveRequest()) === null) { throw new RequestNotFoundException(); } return array_merge(['resource' => $resource], $this->resolveParameter('grid', [])); }
[ "public", "function", "resolveGrid", "(", "ResourceInterface", "$", "resource", ")", "{", "if", "(", "(", "$", "request", "=", "$", "this", "->", "resolveRequest", "(", ")", ")", "===", "null", ")", "{", "throw", "new", "RequestNotFoundException", "(", ")", ";", "}", "return", "array_merge", "(", "[", "'resource'", "=>", "$", "resource", "]", ",", "$", "this", "->", "resolveParameter", "(", "'grid'", ",", "[", "]", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/ParameterResolver.php#L124-L131
php-lug/lug
src/Bundle/ResourceBundle/Routing/ParameterResolver.php
ParameterResolver.resolveLocationRoute
public function resolveLocationRoute() { if (($request = $this->resolveRequest()) === null) { throw new RequestNotFoundException(); } $locationRoute = $this->resolveParameter('location_route'); if (empty($locationRoute)) { throw new RuntimeException(sprintf( 'The location route could not be found for the route "%s".', $request->attributes->get('_route') )); } return $locationRoute; }
php
public function resolveLocationRoute() { if (($request = $this->resolveRequest()) === null) { throw new RequestNotFoundException(); } $locationRoute = $this->resolveParameter('location_route'); if (empty($locationRoute)) { throw new RuntimeException(sprintf( 'The location route could not be found for the route "%s".', $request->attributes->get('_route') )); } return $locationRoute; }
[ "public", "function", "resolveLocationRoute", "(", ")", "{", "if", "(", "(", "$", "request", "=", "$", "this", "->", "resolveRequest", "(", ")", ")", "===", "null", ")", "{", "throw", "new", "RequestNotFoundException", "(", ")", ";", "}", "$", "locationRoute", "=", "$", "this", "->", "resolveParameter", "(", "'location_route'", ")", ";", "if", "(", "empty", "(", "$", "locationRoute", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'The location route could not be found for the route \"%s\".'", ",", "$", "request", "->", "attributes", "->", "get", "(", "'_route'", ")", ")", ")", ";", "}", "return", "$", "locationRoute", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/ParameterResolver.php#L144-L160
php-lug/lug
src/Bundle/ResourceBundle/Routing/ParameterResolver.php
ParameterResolver.resolveMaxPerPage
public function resolveMaxPerPage() { $default = $this->resolveParameter('max_per_page', 10); if (($request = $this->resolveRequest()) === null) { return $default; } $maxPerPage = $request->get('limit', $default); if ($maxPerPage <= 0) { return $default; } if ($maxPerPage > 100) { return 100; } return $maxPerPage; }
php
public function resolveMaxPerPage() { $default = $this->resolveParameter('max_per_page', 10); if (($request = $this->resolveRequest()) === null) { return $default; } $maxPerPage = $request->get('limit', $default); if ($maxPerPage <= 0) { return $default; } if ($maxPerPage > 100) { return 100; } return $maxPerPage; }
[ "public", "function", "resolveMaxPerPage", "(", ")", "{", "$", "default", "=", "$", "this", "->", "resolveParameter", "(", "'max_per_page'", ",", "10", ")", ";", "if", "(", "(", "$", "request", "=", "$", "this", "->", "resolveRequest", "(", ")", ")", "===", "null", ")", "{", "return", "$", "default", ";", "}", "$", "maxPerPage", "=", "$", "request", "->", "get", "(", "'limit'", ",", "$", "default", ")", ";", "if", "(", "$", "maxPerPage", "<=", "0", ")", "{", "return", "$", "default", ";", "}", "if", "(", "$", "maxPerPage", ">", "100", ")", "{", "return", "100", ";", "}", "return", "$", "maxPerPage", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/ParameterResolver.php#L173-L192
php-lug/lug
src/Bundle/ResourceBundle/Routing/ParameterResolver.php
ParameterResolver.resolveRedirectRoute
public function resolveRedirectRoute() { if (($request = $this->resolveRequest()) === null) { throw new RequestNotFoundException(); } $redirectRoute = $this->resolveParameter('redirect_route'); if (empty($redirectRoute)) { throw new RuntimeException(sprintf( 'The redirect route could not be found for the route "%s".', $request->attributes->get('_route') )); } return $redirectRoute; }
php
public function resolveRedirectRoute() { if (($request = $this->resolveRequest()) === null) { throw new RequestNotFoundException(); } $redirectRoute = $this->resolveParameter('redirect_route'); if (empty($redirectRoute)) { throw new RuntimeException(sprintf( 'The redirect route could not be found for the route "%s".', $request->attributes->get('_route') )); } return $redirectRoute; }
[ "public", "function", "resolveRedirectRoute", "(", ")", "{", "if", "(", "(", "$", "request", "=", "$", "this", "->", "resolveRequest", "(", ")", ")", "===", "null", ")", "{", "throw", "new", "RequestNotFoundException", "(", ")", ";", "}", "$", "redirectRoute", "=", "$", "this", "->", "resolveParameter", "(", "'redirect_route'", ")", ";", "if", "(", "empty", "(", "$", "redirectRoute", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'The redirect route could not be found for the route \"%s\".'", ",", "$", "request", "->", "attributes", "->", "get", "(", "'_route'", ")", ")", ")", ";", "}", "return", "$", "redirectRoute", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/ParameterResolver.php#L197-L213
php-lug/lug
src/Bundle/ResourceBundle/Routing/ParameterResolver.php
ParameterResolver.resolveRedirectRouteParameters
public function resolveRedirectRouteParameters($object = null, $forwardParameters = false) { $routeParameters = $this->resolveRouteParameter('redirect_route_parameters', $object); if ($forwardParameters && ($request = $this->resolveRequest()) !== null) { return array_replace_recursive($request->query->all(), $routeParameters); } return $routeParameters; }
php
public function resolveRedirectRouteParameters($object = null, $forwardParameters = false) { $routeParameters = $this->resolveRouteParameter('redirect_route_parameters', $object); if ($forwardParameters && ($request = $this->resolveRequest()) !== null) { return array_replace_recursive($request->query->all(), $routeParameters); } return $routeParameters; }
[ "public", "function", "resolveRedirectRouteParameters", "(", "$", "object", "=", "null", ",", "$", "forwardParameters", "=", "false", ")", "{", "$", "routeParameters", "=", "$", "this", "->", "resolveRouteParameter", "(", "'redirect_route_parameters'", ",", "$", "object", ")", ";", "if", "(", "$", "forwardParameters", "&&", "(", "$", "request", "=", "$", "this", "->", "resolveRequest", "(", ")", ")", "!==", "null", ")", "{", "return", "array_replace_recursive", "(", "$", "request", "->", "query", "->", "all", "(", ")", ",", "$", "routeParameters", ")", ";", "}", "return", "$", "routeParameters", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/ParameterResolver.php#L218-L227
php-lug/lug
src/Bundle/ResourceBundle/Routing/ParameterResolver.php
ParameterResolver.resolveTemplate
public function resolveTemplate() { if (($request = $this->resolveRequest()) === null) { throw new RequestNotFoundException(); } $template = $this->resolveParameter('template'); if (empty($template)) { throw new RuntimeException(sprintf( 'The template could not be found for the route "%s".', $request->attributes->get('_route') )); } return $template; }
php
public function resolveTemplate() { if (($request = $this->resolveRequest()) === null) { throw new RequestNotFoundException(); } $template = $this->resolveParameter('template'); if (empty($template)) { throw new RuntimeException(sprintf( 'The template could not be found for the route "%s".', $request->attributes->get('_route') )); } return $template; }
[ "public", "function", "resolveTemplate", "(", ")", "{", "if", "(", "(", "$", "request", "=", "$", "this", "->", "resolveRequest", "(", ")", ")", "===", "null", ")", "{", "throw", "new", "RequestNotFoundException", "(", ")", ";", "}", "$", "template", "=", "$", "this", "->", "resolveParameter", "(", "'template'", ")", ";", "if", "(", "empty", "(", "$", "template", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'The template could not be found for the route \"%s\".'", ",", "$", "request", "->", "attributes", "->", "get", "(", "'_route'", ")", ")", ")", ";", "}", "return", "$", "template", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/ParameterResolver.php#L280-L296
php-lug/lug
src/Bundle/ResourceBundle/Routing/ParameterResolver.php
ParameterResolver.resolveParameter
private function resolveParameter($parameter, $default = null) { if (($request = $this->resolveRequest()) === null) { return $default; } return $request->attributes->get('_lug_'.$parameter, $default); }
php
private function resolveParameter($parameter, $default = null) { if (($request = $this->resolveRequest()) === null) { return $default; } return $request->attributes->get('_lug_'.$parameter, $default); }
[ "private", "function", "resolveParameter", "(", "$", "parameter", ",", "$", "default", "=", "null", ")", "{", "if", "(", "(", "$", "request", "=", "$", "this", "->", "resolveRequest", "(", ")", ")", "===", "null", ")", "{", "return", "$", "default", ";", "}", "return", "$", "request", "->", "attributes", "->", "get", "(", "'_lug_'", ".", "$", "parameter", ",", "$", "default", ")", ";", "}" ]
@param string $parameter @param mixed $default @return mixed
[ "@param", "string", "$parameter", "@param", "mixed", "$default" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/ParameterResolver.php#L339-L346
php-lug/lug
src/Bundle/ResourceBundle/Routing/ParameterResolver.php
ParameterResolver.resolveRouteParameter
private function resolveRouteParameter($parameter, $object = null) { $propertyPaths = $this->resolveParameter($parameter, []); $parameters = []; if ($object === null) { if (!empty($propertyPaths)) { throw new RuntimeException(sprintf( 'The route parameters could not be found for the route "%s".', $parameter )); } return $parameters; } foreach ($propertyPaths as $propertyPath) { $parameters[$propertyPath] = $this->propertyAccessor->getValue($object, $propertyPath); } return $parameters; }
php
private function resolveRouteParameter($parameter, $object = null) { $propertyPaths = $this->resolveParameter($parameter, []); $parameters = []; if ($object === null) { if (!empty($propertyPaths)) { throw new RuntimeException(sprintf( 'The route parameters could not be found for the route "%s".', $parameter )); } return $parameters; } foreach ($propertyPaths as $propertyPath) { $parameters[$propertyPath] = $this->propertyAccessor->getValue($object, $propertyPath); } return $parameters; }
[ "private", "function", "resolveRouteParameter", "(", "$", "parameter", ",", "$", "object", "=", "null", ")", "{", "$", "propertyPaths", "=", "$", "this", "->", "resolveParameter", "(", "$", "parameter", ",", "[", "]", ")", ";", "$", "parameters", "=", "[", "]", ";", "if", "(", "$", "object", "===", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "propertyPaths", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'The route parameters could not be found for the route \"%s\".'", ",", "$", "parameter", ")", ")", ";", "}", "return", "$", "parameters", ";", "}", "foreach", "(", "$", "propertyPaths", "as", "$", "propertyPath", ")", "{", "$", "parameters", "[", "$", "propertyPath", "]", "=", "$", "this", "->", "propertyAccessor", "->", "getValue", "(", "$", "object", ",", "$", "propertyPath", ")", ";", "}", "return", "$", "parameters", ";", "}" ]
@param string $parameter @param object|null $object @return mixed[]
[ "@param", "string", "$parameter", "@param", "object|null", "$object" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Routing/ParameterResolver.php#L362-L383
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", "." ]
train
https://github.com/activecollab/controller/blob/51d24f3f203f7f5ae56edde2e35b5ef2d9293caa/src/Controller.php#L165-L178
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", "." ]
train
https://github.com/activecollab/controller/blob/51d24f3f203f7f5ae56edde2e35b5ef2d9293caa/src/Controller.php#L230-L243
blast-project/BaseEntitiesBundle
src/Entity/Traits/Searchable.php
Searchable.analyseField
public function analyseField($field) { try { $accessor = PropertyAccess::createPropertyAccessor(); $data = $accessor->getValue($this, $field); } catch (\Exception $exc) { throw new \Exception("Property $field does not exist for " . get_class()); } return SearchAnalyser::analyse($data); }
php
public function analyseField($field) { try { $accessor = PropertyAccess::createPropertyAccessor(); $data = $accessor->getValue($this, $field); } catch (\Exception $exc) { throw new \Exception("Property $field does not exist for " . get_class()); } return SearchAnalyser::analyse($data); }
[ "public", "function", "analyseField", "(", "$", "field", ")", "{", "try", "{", "$", "accessor", "=", "PropertyAccess", "::", "createPropertyAccessor", "(", ")", ";", "$", "data", "=", "$", "accessor", "->", "getValue", "(", "$", "this", ",", "$", "field", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exc", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Property $field does not exist for \"", ".", "get_class", "(", ")", ")", ";", "}", "return", "SearchAnalyser", "::", "analyse", "(", "$", "data", ")", ";", "}" ]
@param string $field @return array @throws \Exception
[ "@param", "string", "$field" ]
train
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Entity/Traits/Searchable.php#L63-L74
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" ]
train
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/web/Geo.php#L19-L33
eghojansu/moe
src/tools/web/Geo.php
Geo.location
function location($ip=NULL) { $fw=Base::instance(); $web=Web::instance(); if (!$ip) $ip=$fw->get('IP'); $public=filter_var($ip,FILTER_VALIDATE_IP, FILTER_FLAG_IPV4|FILTER_FLAG_IPV6| FILTER_FLAG_NO_RES_RANGE|FILTER_FLAG_NO_PRIV_RANGE); if (function_exists('geoip_db_avail') && geoip_db_avail(GEOIP_CITY_EDITION_REV1) && $out=@geoip_record_by_name($ip)) { $out['request']=$ip; $out['region_code']=$out['region']; $out['region_name']=geoip_region_name_by_code( $out['country_code'],$out['region']); unset($out['country_code3'],$out['region'],$out['postal_code']); return $out; } if (($req=$web->request('http://www.geoplugin.net/json.gp'. ($public?('?ip='.$ip):''))) && $data=json_decode($req['body'],TRUE)) { $out=array(); foreach ($data as $key=>$val) if (!strpos($key,'currency') && $key!=='geoplugin_status' && $key!=='geoplugin_region') $out[$fw->snakecase(substr($key, 10))]=$val; return $out; } return FALSE; }
php
function location($ip=NULL) { $fw=Base::instance(); $web=Web::instance(); if (!$ip) $ip=$fw->get('IP'); $public=filter_var($ip,FILTER_VALIDATE_IP, FILTER_FLAG_IPV4|FILTER_FLAG_IPV6| FILTER_FLAG_NO_RES_RANGE|FILTER_FLAG_NO_PRIV_RANGE); if (function_exists('geoip_db_avail') && geoip_db_avail(GEOIP_CITY_EDITION_REV1) && $out=@geoip_record_by_name($ip)) { $out['request']=$ip; $out['region_code']=$out['region']; $out['region_name']=geoip_region_name_by_code( $out['country_code'],$out['region']); unset($out['country_code3'],$out['region'],$out['postal_code']); return $out; } if (($req=$web->request('http://www.geoplugin.net/json.gp'. ($public?('?ip='.$ip):''))) && $data=json_decode($req['body'],TRUE)) { $out=array(); foreach ($data as $key=>$val) if (!strpos($key,'currency') && $key!=='geoplugin_status' && $key!=='geoplugin_region') $out[$fw->snakecase(substr($key, 10))]=$val; return $out; } return FALSE; }
[ "function", "location", "(", "$", "ip", "=", "NULL", ")", "{", "$", "fw", "=", "Base", "::", "instance", "(", ")", ";", "$", "web", "=", "Web", "::", "instance", "(", ")", ";", "if", "(", "!", "$", "ip", ")", "$", "ip", "=", "$", "fw", "->", "get", "(", "'IP'", ")", ";", "$", "public", "=", "filter_var", "(", "$", "ip", ",", "FILTER_VALIDATE_IP", ",", "FILTER_FLAG_IPV4", "|", "FILTER_FLAG_IPV6", "|", "FILTER_FLAG_NO_RES_RANGE", "|", "FILTER_FLAG_NO_PRIV_RANGE", ")", ";", "if", "(", "function_exists", "(", "'geoip_db_avail'", ")", "&&", "geoip_db_avail", "(", "GEOIP_CITY_EDITION_REV1", ")", "&&", "$", "out", "=", "@", "geoip_record_by_name", "(", "$", "ip", ")", ")", "{", "$", "out", "[", "'request'", "]", "=", "$", "ip", ";", "$", "out", "[", "'region_code'", "]", "=", "$", "out", "[", "'region'", "]", ";", "$", "out", "[", "'region_name'", "]", "=", "geoip_region_name_by_code", "(", "$", "out", "[", "'country_code'", "]", ",", "$", "out", "[", "'region'", "]", ")", ";", "unset", "(", "$", "out", "[", "'country_code3'", "]", ",", "$", "out", "[", "'region'", "]", ",", "$", "out", "[", "'postal_code'", "]", ")", ";", "return", "$", "out", ";", "}", "if", "(", "(", "$", "req", "=", "$", "web", "->", "request", "(", "'http://www.geoplugin.net/json.gp'", ".", "(", "$", "public", "?", "(", "'?ip='", ".", "$", "ip", ")", ":", "''", ")", ")", ")", "&&", "$", "data", "=", "json_decode", "(", "$", "req", "[", "'body'", "]", ",", "TRUE", ")", ")", "{", "$", "out", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "val", ")", "if", "(", "!", "strpos", "(", "$", "key", ",", "'currency'", ")", "&&", "$", "key", "!==", "'geoplugin_status'", "&&", "$", "key", "!==", "'geoplugin_region'", ")", "$", "out", "[", "$", "fw", "->", "snakecase", "(", "substr", "(", "$", "key", ",", "10", ")", ")", "]", "=", "$", "val", ";", "return", "$", "out", ";", "}", "return", "FALSE", ";", "}" ]
Return geolocation data based on specified/auto-detected IP address @return array|FALSE @param $ip string
[ "Return", "geolocation", "data", "based", "on", "specified", "/", "auto", "-", "detected", "IP", "address" ]
train
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/web/Geo.php#L40-L69
eghojansu/moe
src/tools/web/Geo.php
Geo.weather
function weather($latitude,$longitude) { $fw=Base::instance(); $web=Web::instance(); $query=array( 'lat'=>$latitude, 'lon'=>$longitude ); $req=$web->request( 'http://api.openweathermap.org/data/2.5/weather?'. http_build_query($query)); return ($req=$web->request( 'http://api.openweathermap.org/data/2.5/weather?'. http_build_query($query)))? json_decode($req['body'],TRUE): FALSE; }
php
function weather($latitude,$longitude) { $fw=Base::instance(); $web=Web::instance(); $query=array( 'lat'=>$latitude, 'lon'=>$longitude ); $req=$web->request( 'http://api.openweathermap.org/data/2.5/weather?'. http_build_query($query)); return ($req=$web->request( 'http://api.openweathermap.org/data/2.5/weather?'. http_build_query($query)))? json_decode($req['body'],TRUE): FALSE; }
[ "function", "weather", "(", "$", "latitude", ",", "$", "longitude", ")", "{", "$", "fw", "=", "Base", "::", "instance", "(", ")", ";", "$", "web", "=", "Web", "::", "instance", "(", ")", ";", "$", "query", "=", "array", "(", "'lat'", "=>", "$", "latitude", ",", "'lon'", "=>", "$", "longitude", ")", ";", "$", "req", "=", "$", "web", "->", "request", "(", "'http://api.openweathermap.org/data/2.5/weather?'", ".", "http_build_query", "(", "$", "query", ")", ")", ";", "return", "(", "$", "req", "=", "$", "web", "->", "request", "(", "'http://api.openweathermap.org/data/2.5/weather?'", ".", "http_build_query", "(", "$", "query", ")", ")", ")", "?", "json_decode", "(", "$", "req", "[", "'body'", "]", ",", "TRUE", ")", ":", "FALSE", ";", "}" ]
Return weather data based on specified latitude/longitude @return array|FALSE @param $latitude float @param $longitude float
[ "Return", "weather", "data", "based", "on", "specified", "latitude", "/", "longitude" ]
train
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/web/Geo.php#L77-L92
maestroprog/saw-php
src/Standalone/Controller/ThreadDistributor.php
ThreadDistributor.work
public function work() { while (!$this->threadRunQueue->isEmpty()) { /** @var $thread ControlledThread */ $thread = $this->threadRunQueue->shift(); try { if ($thread instanceof BroadcastThread) { $this->threadBroadcast($thread); } else { $worker = $this->workerBalance->getLowLoadedWorker($thread); $this->threadRun($worker, $thread); } } catch (\RuntimeException $e) { $this->threadRunQueue->push($thread); // откладываем до лучших времён. return; // выходим отсюда до лучших времен } catch (\Throwable $e) { throw new \Exception('Cannot balance thread ' . $thread->getUniqueId(), 0, $e); } } }
php
public function work() { while (!$this->threadRunQueue->isEmpty()) { /** @var $thread ControlledThread */ $thread = $this->threadRunQueue->shift(); try { if ($thread instanceof BroadcastThread) { $this->threadBroadcast($thread); } else { $worker = $this->workerBalance->getLowLoadedWorker($thread); $this->threadRun($worker, $thread); } } catch (\RuntimeException $e) { $this->threadRunQueue->push($thread); // откладываем до лучших времён. return; // выходим отсюда до лучших времен } catch (\Throwable $e) { throw new \Exception('Cannot balance thread ' . $thread->getUniqueId(), 0, $e); } } }
[ "public", "function", "work", "(", ")", "{", "while", "(", "!", "$", "this", "->", "threadRunQueue", "->", "isEmpty", "(", ")", ")", "{", "/** @var $thread ControlledThread */", "$", "thread", "=", "$", "this", "->", "threadRunQueue", "->", "shift", "(", ")", ";", "try", "{", "if", "(", "$", "thread", "instanceof", "BroadcastThread", ")", "{", "$", "this", "->", "threadBroadcast", "(", "$", "thread", ")", ";", "}", "else", "{", "$", "worker", "=", "$", "this", "->", "workerBalance", "->", "getLowLoadedWorker", "(", "$", "thread", ")", ";", "$", "this", "->", "threadRun", "(", "$", "worker", ",", "$", "thread", ")", ";", "}", "}", "catch", "(", "\\", "RuntimeException", "$", "e", ")", "{", "$", "this", "->", "threadRunQueue", "->", "push", "(", "$", "thread", ")", ";", "// откладываем до лучших времён.", "return", ";", "// выходим отсюда до лучших времен", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "throw", "new", "\\", "Exception", "(", "'Cannot balance thread '", ".", "$", "thread", "->", "getUniqueId", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}", "}" ]
Перераспределяет потоки по воркерам. @return void @throws \Exception
[ "Перераспределяет", "потоки", "по", "воркерам", "." ]
train
https://github.com/maestroprog/saw-php/blob/159215a4d7a951cca2a9c2eed3e1aa4f5b624cfb/src/Standalone/Controller/ThreadDistributor.php#L137-L157
maestroprog/saw-php
src/Standalone/Controller/ThreadDistributor.php
ThreadDistributor.threadKnow
public function threadKnow(Worker $worker, AbstractThread $thread) { $this->threadKnownIndex->add($thread); $worker->addThreadToKnownList($thread); }
php
public function threadKnow(Worker $worker, AbstractThread $thread) { $this->threadKnownIndex->add($thread); $worker->addThreadToKnownList($thread); }
[ "public", "function", "threadKnow", "(", "Worker", "$", "worker", ",", "AbstractThread", "$", "thread", ")", "{", "$", "this", "->", "threadKnownIndex", "->", "add", "(", "$", "thread", ")", ";", "$", "worker", "->", "addThreadToKnownList", "(", "$", "thread", ")", ";", "}" ]
Метод, который будет вызван, когда воркер сообщит о новом потоке, который он только что узнал. @param Worker $worker @param AbstractThread $thread @return void
[ "Метод", "который", "будет", "вызван", "когда", "воркер", "сообщит", "о", "новом", "потоке", "который", "он", "только", "что", "узнал", "." ]
train
https://github.com/maestroprog/saw-php/blob/159215a4d7a951cca2a9c2eed3e1aa4f5b624cfb/src/Standalone/Controller/ThreadDistributor.php#L167-L171
maestroprog/saw-php
src/Standalone/Controller/ThreadDistributor.php
ThreadDistributor.threadRun
public function threadRun(Worker $worker, AbstractThread $sourceThread) { static $runId = 0; $runThread = (new ControlledThread( ++$runId, $sourceThread->getApplicationId(), $sourceThread->getUniqueId(), $worker->getClient() ))->setArguments($sourceThread->getArguments()); // todo start check // сообщаем сущности воркера, что он выполняет поток $worker->addThreadToRunList($runThread); $this->threadRunSources->add($worker, $sourceThread); $this->threadRunWork->add($worker, $runThread); // связываем поток для выполнения с исходным потоком $this->threadLinks->linkThreads($runThread, $sourceThread); // todo check --- $thread = (new ThreadRun( $worker->getClient(), $runThread->getId(), $runThread->getApplicationId(), $runThread->getUniqueId(), $runThread->getArguments() )) ->onError(function (ThreadRun $threadResult) use ($sourceThread) { Log::log('Error run task ' . $sourceThread->getUniqueId()); throw new \RuntimeException('Error run thread.' . $threadResult->getAccomplishedResult()); }) ->onSuccess(function () use ($worker, $sourceThread, $runThread) { }); $this->commander->runAsync($thread); }
php
public function threadRun(Worker $worker, AbstractThread $sourceThread) { static $runId = 0; $runThread = (new ControlledThread( ++$runId, $sourceThread->getApplicationId(), $sourceThread->getUniqueId(), $worker->getClient() ))->setArguments($sourceThread->getArguments()); // todo start check // сообщаем сущности воркера, что он выполняет поток $worker->addThreadToRunList($runThread); $this->threadRunSources->add($worker, $sourceThread); $this->threadRunWork->add($worker, $runThread); // связываем поток для выполнения с исходным потоком $this->threadLinks->linkThreads($runThread, $sourceThread); // todo check --- $thread = (new ThreadRun( $worker->getClient(), $runThread->getId(), $runThread->getApplicationId(), $runThread->getUniqueId(), $runThread->getArguments() )) ->onError(function (ThreadRun $threadResult) use ($sourceThread) { Log::log('Error run task ' . $sourceThread->getUniqueId()); throw new \RuntimeException('Error run thread.' . $threadResult->getAccomplishedResult()); }) ->onSuccess(function () use ($worker, $sourceThread, $runThread) { }); $this->commander->runAsync($thread); }
[ "public", "function", "threadRun", "(", "Worker", "$", "worker", ",", "AbstractThread", "$", "sourceThread", ")", "{", "static", "$", "runId", "=", "0", ";", "$", "runThread", "=", "(", "new", "ControlledThread", "(", "++", "$", "runId", ",", "$", "sourceThread", "->", "getApplicationId", "(", ")", ",", "$", "sourceThread", "->", "getUniqueId", "(", ")", ",", "$", "worker", "->", "getClient", "(", ")", ")", ")", "->", "setArguments", "(", "$", "sourceThread", "->", "getArguments", "(", ")", ")", ";", "// todo start check", "// сообщаем сущности воркера, что он выполняет поток", "$", "worker", "->", "addThreadToRunList", "(", "$", "runThread", ")", ";", "$", "this", "->", "threadRunSources", "->", "add", "(", "$", "worker", ",", "$", "sourceThread", ")", ";", "$", "this", "->", "threadRunWork", "->", "add", "(", "$", "worker", ",", "$", "runThread", ")", ";", "// связываем поток для выполнения с исходным потоком", "$", "this", "->", "threadLinks", "->", "linkThreads", "(", "$", "runThread", ",", "$", "sourceThread", ")", ";", "// todo check ---", "$", "thread", "=", "(", "new", "ThreadRun", "(", "$", "worker", "->", "getClient", "(", ")", ",", "$", "runThread", "->", "getId", "(", ")", ",", "$", "runThread", "->", "getApplicationId", "(", ")", ",", "$", "runThread", "->", "getUniqueId", "(", ")", ",", "$", "runThread", "->", "getArguments", "(", ")", ")", ")", "->", "onError", "(", "function", "(", "ThreadRun", "$", "threadResult", ")", "use", "(", "$", "sourceThread", ")", "{", "Log", "::", "log", "(", "'Error run task '", ".", "$", "sourceThread", "->", "getUniqueId", "(", ")", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "'Error run thread.'", ".", "$", "threadResult", "->", "getAccomplishedResult", "(", ")", ")", ";", "}", ")", "->", "onSuccess", "(", "function", "(", ")", "use", "(", "$", "worker", ",", "$", "sourceThread", ",", "$", "runThread", ")", "{", "}", ")", ";", "$", "this", "->", "commander", "->", "runAsync", "(", "$", "thread", ")", ";", "}" ]
Выполняет постановку задачи на выполнение потока указанному воркеру. @param Worker $worker Воркер, которому предстоит передать поток на выполнение @param AbstractThread $sourceThread Исходный поток, который будет передан на выполнение @return void
[ "Выполняет", "постановку", "задачи", "на", "выполнение", "потока", "указанному", "воркеру", "." ]
train
https://github.com/maestroprog/saw-php/blob/159215a4d7a951cca2a9c2eed3e1aa4f5b624cfb/src/Standalone/Controller/ThreadDistributor.php#L180-L216
maestroprog/saw-php
src/Standalone/Controller/ThreadDistributor.php
ThreadDistributor.threadBroadcast
public function threadBroadcast(BroadcastThread $sourceThread) { /** @var Worker $worker */ foreach ($this->workerPool as $worker) { $this->threadRun($worker, $sourceThread); // todo сделать оповещение об успешном выполнении потока } }
php
public function threadBroadcast(BroadcastThread $sourceThread) { /** @var Worker $worker */ foreach ($this->workerPool as $worker) { $this->threadRun($worker, $sourceThread); // todo сделать оповещение об успешном выполнении потока } }
[ "public", "function", "threadBroadcast", "(", "BroadcastThread", "$", "sourceThread", ")", "{", "/** @var Worker $worker */", "foreach", "(", "$", "this", "->", "workerPool", "as", "$", "worker", ")", "{", "$", "this", "->", "threadRun", "(", "$", "worker", ",", "$", "sourceThread", ")", ";", "// todo сделать оповещение об успешном выполнении потока", "}", "}" ]
Выполняет постановку задачи на выполнение потока указанному воркеру. @param BroadcastThread $sourceThread Исходный поток, который будет передан на выполнение @return void
[ "Выполняет", "постановку", "задачи", "на", "выполнение", "потока", "указанному", "воркеру", "." ]
train
https://github.com/maestroprog/saw-php/blob/159215a4d7a951cca2a9c2eed3e1aa4f5b624cfb/src/Standalone/Controller/ThreadDistributor.php#L224-L231
maestroprog/saw-php
src/Standalone/Controller/ThreadDistributor.php
ThreadDistributor.threadResult
public function threadResult(Worker $worker, int $runId, $result) { $runThread = $this->threadRunWork->getThreadById($runId); $sourceThread = $this->threadLinks->getLinkedThread($runThread); // отвязываем поток для выполнения от исходного потока $this->threadLinks->unlinkThreads($runThread); $sourceThread->setResult($result); // удаляем из сущности воркера информацию о завершённом потоке $worker->removeRunThread($runThread); $this->threadRunSources->removeThread($sourceThread); $this->threadRunWork->removeThread($runThread); if (!$sourceThread instanceof ControlledThread) { throw new \LogicException('Unknown thread object!'); } if ($sourceThread instanceof BroadcastThread) { /** * Широковещательные потоки на данный момент * не поддерживают сбор и отправку результатов. */ return; } $resultCommand = new ThreadResult( $sourceThread->getThreadFrom(), $sourceThread->getId(), $sourceThread->getApplicationId(), $sourceThread->getUniqueId(), $sourceThread->getResult() ); $resultCommand ->onError(function () { }) ->onSuccess(function () use ($sourceThread, $runThread) { }); $this->commander->runAsync($resultCommand); }
php
public function threadResult(Worker $worker, int $runId, $result) { $runThread = $this->threadRunWork->getThreadById($runId); $sourceThread = $this->threadLinks->getLinkedThread($runThread); // отвязываем поток для выполнения от исходного потока $this->threadLinks->unlinkThreads($runThread); $sourceThread->setResult($result); // удаляем из сущности воркера информацию о завершённом потоке $worker->removeRunThread($runThread); $this->threadRunSources->removeThread($sourceThread); $this->threadRunWork->removeThread($runThread); if (!$sourceThread instanceof ControlledThread) { throw new \LogicException('Unknown thread object!'); } if ($sourceThread instanceof BroadcastThread) { /** * Широковещательные потоки на данный момент * не поддерживают сбор и отправку результатов. */ return; } $resultCommand = new ThreadResult( $sourceThread->getThreadFrom(), $sourceThread->getId(), $sourceThread->getApplicationId(), $sourceThread->getUniqueId(), $sourceThread->getResult() ); $resultCommand ->onError(function () { }) ->onSuccess(function () use ($sourceThread, $runThread) { }); $this->commander->runAsync($resultCommand); }
[ "public", "function", "threadResult", "(", "Worker", "$", "worker", ",", "int", "$", "runId", ",", "$", "result", ")", "{", "$", "runThread", "=", "$", "this", "->", "threadRunWork", "->", "getThreadById", "(", "$", "runId", ")", ";", "$", "sourceThread", "=", "$", "this", "->", "threadLinks", "->", "getLinkedThread", "(", "$", "runThread", ")", ";", "// отвязываем поток для выполнения от исходного потока", "$", "this", "->", "threadLinks", "->", "unlinkThreads", "(", "$", "runThread", ")", ";", "$", "sourceThread", "->", "setResult", "(", "$", "result", ")", ";", "// удаляем из сущности воркера информацию о завершённом потоке", "$", "worker", "->", "removeRunThread", "(", "$", "runThread", ")", ";", "$", "this", "->", "threadRunSources", "->", "removeThread", "(", "$", "sourceThread", ")", ";", "$", "this", "->", "threadRunWork", "->", "removeThread", "(", "$", "runThread", ")", ";", "if", "(", "!", "$", "sourceThread", "instanceof", "ControlledThread", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Unknown thread object!'", ")", ";", "}", "if", "(", "$", "sourceThread", "instanceof", "BroadcastThread", ")", "{", "/**\n * Широковещательные потоки на данный момент\n * не поддерживают сбор и отправку результатов.\n */", "return", ";", "}", "$", "resultCommand", "=", "new", "ThreadResult", "(", "$", "sourceThread", "->", "getThreadFrom", "(", ")", ",", "$", "sourceThread", "->", "getId", "(", ")", ",", "$", "sourceThread", "->", "getApplicationId", "(", ")", ",", "$", "sourceThread", "->", "getUniqueId", "(", ")", ",", "$", "sourceThread", "->", "getResult", "(", ")", ")", ";", "$", "resultCommand", "->", "onError", "(", "function", "(", ")", "{", "}", ")", "->", "onSuccess", "(", "function", "(", ")", "use", "(", "$", "sourceThread", ",", "$", "runThread", ")", "{", "}", ")", ";", "$", "this", "->", "commander", "->", "runAsync", "(", "$", "resultCommand", ")", ";", "}" ]
Выполняет обработку результата выполнения потока, и перенаправляет его к исходному постановщику задачи. @param Worker $worker От кого пришёл результат @param int $runId По какому потоку пришёл результат @param mixed $result Результат выполнения потока @return void
[ "Выполняет", "обработку", "результата", "выполнения", "потока", "и", "перенаправляет", "его", "к", "исходному", "постановщику", "задачи", "." ]
train
https://github.com/maestroprog/saw-php/blob/159215a4d7a951cca2a9c2eed3e1aa4f5b624cfb/src/Standalone/Controller/ThreadDistributor.php#L242-L283
oroinc/OroLayoutComponent
LayoutFactory.php
LayoutFactory.createLayoutBuilder
public function createLayoutBuilder() { $rawLayoutBuilder = $this->createRawLayoutBuilder(); $layoutManipulator = $this->createLayoutManipulator($rawLayoutBuilder); $blockFactory = $this->createBlockFactory($layoutManipulator); return new LayoutBuilder( $this->registry, $rawLayoutBuilder, $layoutManipulator, $blockFactory, $this->rendererRegistry, $this->expressionProcessor, $this->blockViewCache ); }
php
public function createLayoutBuilder() { $rawLayoutBuilder = $this->createRawLayoutBuilder(); $layoutManipulator = $this->createLayoutManipulator($rawLayoutBuilder); $blockFactory = $this->createBlockFactory($layoutManipulator); return new LayoutBuilder( $this->registry, $rawLayoutBuilder, $layoutManipulator, $blockFactory, $this->rendererRegistry, $this->expressionProcessor, $this->blockViewCache ); }
[ "public", "function", "createLayoutBuilder", "(", ")", "{", "$", "rawLayoutBuilder", "=", "$", "this", "->", "createRawLayoutBuilder", "(", ")", ";", "$", "layoutManipulator", "=", "$", "this", "->", "createLayoutManipulator", "(", "$", "rawLayoutBuilder", ")", ";", "$", "blockFactory", "=", "$", "this", "->", "createBlockFactory", "(", "$", "layoutManipulator", ")", ";", "return", "new", "LayoutBuilder", "(", "$", "this", "->", "registry", ",", "$", "rawLayoutBuilder", ",", "$", "layoutManipulator", ",", "$", "blockFactory", ",", "$", "this", "->", "rendererRegistry", ",", "$", "this", "->", "expressionProcessor", ",", "$", "this", "->", "blockViewCache", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/LayoutFactory.php#L90-L105
ShaoZeMing/laravel-merchant
src/Merchant.php
Merchant.js
public static function js($js = null) { if (!is_null($js)) { self::$js = array_merge(self::$js, (array) $js); return; } $js = array_get(Form::collectFieldAssets(), 'js', []); static::$js = array_merge(static::$js, $js); return view('merchant::partials.js', ['js' => array_unique(static::$js)]); }
php
public static function js($js = null) { if (!is_null($js)) { self::$js = array_merge(self::$js, (array) $js); return; } $js = array_get(Form::collectFieldAssets(), 'js', []); static::$js = array_merge(static::$js, $js); return view('merchant::partials.js', ['js' => array_unique(static::$js)]); }
[ "public", "static", "function", "js", "(", "$", "js", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "js", ")", ")", "{", "self", "::", "$", "js", "=", "array_merge", "(", "self", "::", "$", "js", ",", "(", "array", ")", "$", "js", ")", ";", "return", ";", "}", "$", "js", "=", "array_get", "(", "Form", "::", "collectFieldAssets", "(", ")", ",", "'js'", ",", "[", "]", ")", ";", "static", "::", "$", "js", "=", "array_merge", "(", "static", "::", "$", "js", ",", "$", "js", ")", ";", "return", "view", "(", "'merchant::partials.js'", ",", "[", "'js'", "=>", "array_unique", "(", "static", "::", "$", "js", ")", "]", ")", ";", "}" ]
Add js or get all js. @param null $js @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void
[ "Add", "js", "or", "get", "all", "js", "." ]
train
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Merchant.php#L136-L149
ShaoZeMing/laravel-merchant
src/Merchant.php
Merchant.script
public static function script($script = '') { if (!empty($script)) { self::$script = array_merge(self::$script, (array) $script); return; } return view('merchant::partials.script', ['script' => array_unique(self::$script)]); }
php
public static function script($script = '') { if (!empty($script)) { self::$script = array_merge(self::$script, (array) $script); return; } return view('merchant::partials.script', ['script' => array_unique(self::$script)]); }
[ "public", "static", "function", "script", "(", "$", "script", "=", "''", ")", "{", "if", "(", "!", "empty", "(", "$", "script", ")", ")", "{", "self", "::", "$", "script", "=", "array_merge", "(", "self", "::", "$", "script", ",", "(", "array", ")", "$", "script", ")", ";", "return", ";", "}", "return", "view", "(", "'merchant::partials.script'", ",", "[", "'script'", "=>", "array_unique", "(", "self", "::", "$", "script", ")", "]", ")", ";", "}" ]
@param string $script @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|void
[ "@param", "string", "$script" ]
train
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Merchant.php#L156-L165
ShaoZeMing/laravel-merchant
src/Merchant.php
Merchant.registerAuthRoutes
public function registerAuthRoutes() { $attributes = [ 'prefix' => config('merchant.route.prefix'), 'namespace' => 'ShaoZeMing\Merchant\Controllers', 'middleware' => config('merchant.route.middleware'), ]; Route::group($attributes, function ($router) { /* @var \Illuminate\Routing\Router $router */ $router->group([], function ($router) { /* @var \Illuminate\Routing\Router $router */ $router->resource('auth/users', 'UserController'); $router->resource('auth/roles', 'RoleController'); $router->resource('auth/permissions', 'PermissionController'); $router->resource('auth/menu', 'MenuController', ['except' => ['create']]); $router->resource('auth/logs', 'LogController', ['only' => ['index', 'destroy']]); }); $router->get('auth/forget', 'AuthController@getForget'); $router->get('auth/register', 'AuthController@getRegister'); $router->post('auth/register', 'AuthController@postRegister'); $router->post('auth/forget', 'AuthController@postForget'); $router->get('auth/login', 'AuthController@getLogin'); $router->post('auth/login', 'AuthController@postLogin'); $router->get('auth/logout', 'AuthController@getLogout'); $router->get('auth/setting', 'AuthController@getSetting'); $router->put('auth/setting', 'AuthController@putSetting'); }); $attributes = [ 'prefix' => config('merchant.route.prefix'), 'namespace' => 'ShaoZeMing\Merchant\Controllers', 'middleware' => ['web'], ]; Route::group($attributes, function ($router) { $router->get('auth/forget', 'AuthController@getForget'); $router->get('auth/register', 'AuthController@getRegister'); $router->post('auth/register', 'AuthController@postRegister'); $router->post('auth/forget', 'AuthController@postForget'); }); }
php
public function registerAuthRoutes() { $attributes = [ 'prefix' => config('merchant.route.prefix'), 'namespace' => 'ShaoZeMing\Merchant\Controllers', 'middleware' => config('merchant.route.middleware'), ]; Route::group($attributes, function ($router) { /* @var \Illuminate\Routing\Router $router */ $router->group([], function ($router) { /* @var \Illuminate\Routing\Router $router */ $router->resource('auth/users', 'UserController'); $router->resource('auth/roles', 'RoleController'); $router->resource('auth/permissions', 'PermissionController'); $router->resource('auth/menu', 'MenuController', ['except' => ['create']]); $router->resource('auth/logs', 'LogController', ['only' => ['index', 'destroy']]); }); $router->get('auth/forget', 'AuthController@getForget'); $router->get('auth/register', 'AuthController@getRegister'); $router->post('auth/register', 'AuthController@postRegister'); $router->post('auth/forget', 'AuthController@postForget'); $router->get('auth/login', 'AuthController@getLogin'); $router->post('auth/login', 'AuthController@postLogin'); $router->get('auth/logout', 'AuthController@getLogout'); $router->get('auth/setting', 'AuthController@getSetting'); $router->put('auth/setting', 'AuthController@putSetting'); }); $attributes = [ 'prefix' => config('merchant.route.prefix'), 'namespace' => 'ShaoZeMing\Merchant\Controllers', 'middleware' => ['web'], ]; Route::group($attributes, function ($router) { $router->get('auth/forget', 'AuthController@getForget'); $router->get('auth/register', 'AuthController@getRegister'); $router->post('auth/register', 'AuthController@postRegister'); $router->post('auth/forget', 'AuthController@postForget'); }); }
[ "public", "function", "registerAuthRoutes", "(", ")", "{", "$", "attributes", "=", "[", "'prefix'", "=>", "config", "(", "'merchant.route.prefix'", ")", ",", "'namespace'", "=>", "'ShaoZeMing\\Merchant\\Controllers'", ",", "'middleware'", "=>", "config", "(", "'merchant.route.middleware'", ")", ",", "]", ";", "Route", "::", "group", "(", "$", "attributes", ",", "function", "(", "$", "router", ")", "{", "/* @var \\Illuminate\\Routing\\Router $router */", "$", "router", "->", "group", "(", "[", "]", ",", "function", "(", "$", "router", ")", "{", "/* @var \\Illuminate\\Routing\\Router $router */", "$", "router", "->", "resource", "(", "'auth/users'", ",", "'UserController'", ")", ";", "$", "router", "->", "resource", "(", "'auth/roles'", ",", "'RoleController'", ")", ";", "$", "router", "->", "resource", "(", "'auth/permissions'", ",", "'PermissionController'", ")", ";", "$", "router", "->", "resource", "(", "'auth/menu'", ",", "'MenuController'", ",", "[", "'except'", "=>", "[", "'create'", "]", "]", ")", ";", "$", "router", "->", "resource", "(", "'auth/logs'", ",", "'LogController'", ",", "[", "'only'", "=>", "[", "'index'", ",", "'destroy'", "]", "]", ")", ";", "}", ")", ";", "$", "router", "->", "get", "(", "'auth/forget'", ",", "'AuthController@getForget'", ")", ";", "$", "router", "->", "get", "(", "'auth/register'", ",", "'AuthController@getRegister'", ")", ";", "$", "router", "->", "post", "(", "'auth/register'", ",", "'AuthController@postRegister'", ")", ";", "$", "router", "->", "post", "(", "'auth/forget'", ",", "'AuthController@postForget'", ")", ";", "$", "router", "->", "get", "(", "'auth/login'", ",", "'AuthController@getLogin'", ")", ";", "$", "router", "->", "post", "(", "'auth/login'", ",", "'AuthController@postLogin'", ")", ";", "$", "router", "->", "get", "(", "'auth/logout'", ",", "'AuthController@getLogout'", ")", ";", "$", "router", "->", "get", "(", "'auth/setting'", ",", "'AuthController@getSetting'", ")", ";", "$", "router", "->", "put", "(", "'auth/setting'", ",", "'AuthController@putSetting'", ")", ";", "}", ")", ";", "$", "attributes", "=", "[", "'prefix'", "=>", "config", "(", "'merchant.route.prefix'", ")", ",", "'namespace'", "=>", "'ShaoZeMing\\Merchant\\Controllers'", ",", "'middleware'", "=>", "[", "'web'", "]", ",", "]", ";", "Route", "::", "group", "(", "$", "attributes", ",", "function", "(", "$", "router", ")", "{", "$", "router", "->", "get", "(", "'auth/forget'", ",", "'AuthController@getForget'", ")", ";", "$", "router", "->", "get", "(", "'auth/register'", ",", "'AuthController@getRegister'", ")", ";", "$", "router", "->", "post", "(", "'auth/register'", ",", "'AuthController@postRegister'", ")", ";", "$", "router", "->", "post", "(", "'auth/forget'", ",", "'AuthController@postForget'", ")", ";", "}", ")", ";", "}" ]
Register the auth routes. @return void
[ "Register", "the", "auth", "routes", "." ]
train
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Merchant.php#L232-L275
skeeks-cms/cms-dadata-suggest
src/CmsDadataSuggestComponent.php
CmsDadataSuggestComponent.saveAddress
public function saveAddress($data = []) { \Yii::$app->session->set($this->sessionName, $data); return $this; }
php
public function saveAddress($data = []) { \Yii::$app->session->set($this->sessionName, $data); return $this; }
[ "public", "function", "saveAddress", "(", "$", "data", "=", "[", "]", ")", "{", "\\", "Yii", "::", "$", "app", "->", "session", "->", "set", "(", "$", "this", "->", "sessionName", ",", "$", "data", ")", ";", "return", "$", "this", ";", "}" ]
Сохранение определенных данных @param array $data данные полученные из api dadata @return $this
[ "Сохранение", "определенных", "данных" ]
train
https://github.com/skeeks-cms/cms-dadata-suggest/blob/966b4a3a6e3824deb54fa09b7bfe82494760571e/src/CmsDadataSuggestComponent.php#L118-L122
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" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/Google/Auth.php#L98-L119