repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
cyberspectrum/i18n | src/Job/CopyDictionaryJob.php | CopyDictionaryJob.copySource | private function copySource(TranslationValueInterface $source, WritableTranslationValueInterface $target): void
{
if (self::DO_NOT_COPY === $this->copySource) {
return;
}
if (($oldValue = $target->getSource()) === ($newValue = $source->getSource())) {
$this->logger->log(
$this->logLevel,
'{key}: Source is same, no need to update.',
['key' => $target->getKey(), 'old' => $oldValue, 'new' => $newValue]
);
return;
}
if ((self::COPY_IF_EMPTY === $this->copySource) && !$target->isSourceEmpty()) {
$this->logger->log(
$this->logLevel,
'{key}: Source is not empty, no need to update.',
['key' => $target->getKey(), 'old' => $oldValue, 'new' => $newValue]
);
return;
}
$this->logger->log(
LogLevel::NOTICE,
'{key}: Updating source value.',
['key' => $target->getKey(), 'old' => $oldValue, 'new' => $newValue]
);
if ($this->dryRun) {
return;
}
$target->setSource($newValue);
} | php | private function copySource(TranslationValueInterface $source, WritableTranslationValueInterface $target): void
{
if (self::DO_NOT_COPY === $this->copySource) {
return;
}
if (($oldValue = $target->getSource()) === ($newValue = $source->getSource())) {
$this->logger->log(
$this->logLevel,
'{key}: Source is same, no need to update.',
['key' => $target->getKey(), 'old' => $oldValue, 'new' => $newValue]
);
return;
}
if ((self::COPY_IF_EMPTY === $this->copySource) && !$target->isSourceEmpty()) {
$this->logger->log(
$this->logLevel,
'{key}: Source is not empty, no need to update.',
['key' => $target->getKey(), 'old' => $oldValue, 'new' => $newValue]
);
return;
}
$this->logger->log(
LogLevel::NOTICE,
'{key}: Updating source value.',
['key' => $target->getKey(), 'old' => $oldValue, 'new' => $newValue]
);
if ($this->dryRun) {
return;
}
$target->setSource($newValue);
} | [
"private",
"function",
"copySource",
"(",
"TranslationValueInterface",
"$",
"source",
",",
"WritableTranslationValueInterface",
"$",
"target",
")",
":",
"void",
"{",
"if",
"(",
"self",
"::",
"DO_NOT_COPY",
"===",
"$",
"this",
"->",
"copySource",
")",
"{",
"retur... | Copy the source value.
@param TranslationValueInterface $source The source value.
@param WritableTranslationValueInterface $target The target value.
@return void | [
"Copy",
"the",
"source",
"value",
"."
] | 138e81d7119db82c2420bd33967a566e02b1d2f5 | https://github.com/cyberspectrum/i18n/blob/138e81d7119db82c2420bd33967a566e02b1d2f5/src/Job/CopyDictionaryJob.php#L372-L408 | train |
cyberspectrum/i18n | src/Job/CopyDictionaryJob.php | CopyDictionaryJob.copyTarget | private function copyTarget(TranslationValueInterface $source, WritableTranslationValueInterface $target): void
{
if (self::DO_NOT_COPY === $this->copyTarget) {
return;
}
if ((($oldValue = $target->getTarget()) === ($newValue = $source->getTarget()))
|| ($target->isTargetEmpty() && $source->isTargetEmpty())
) {
$this->logger->log(
$this->logLevel,
'{key}: Target is same, no need to update.',
['key' => $target->getKey(), 'old' => $oldValue, 'new' => $newValue]
);
return;
}
if ((self::COPY_IF_EMPTY === $this->copyTarget) && !$target->isTargetEmpty()) {
$this->logger->log(
$this->logLevel,
'{key}: Target is not empty, no need to update.',
['key' => $target->getKey(), 'old' => $oldValue, 'new' => $newValue]
);
return;
}
$this->logger->log(
LogLevel::NOTICE,
'{key}: Updating target value.',
['key' => $target->getKey(), 'old' => $oldValue, 'new' => $newValue]
);
if ($this->dryRun) {
return;
}
if (null === $value = $source->getTarget()) {
$target->clearTarget();
return;
}
$target->setTarget($value);
} | php | private function copyTarget(TranslationValueInterface $source, WritableTranslationValueInterface $target): void
{
if (self::DO_NOT_COPY === $this->copyTarget) {
return;
}
if ((($oldValue = $target->getTarget()) === ($newValue = $source->getTarget()))
|| ($target->isTargetEmpty() && $source->isTargetEmpty())
) {
$this->logger->log(
$this->logLevel,
'{key}: Target is same, no need to update.',
['key' => $target->getKey(), 'old' => $oldValue, 'new' => $newValue]
);
return;
}
if ((self::COPY_IF_EMPTY === $this->copyTarget) && !$target->isTargetEmpty()) {
$this->logger->log(
$this->logLevel,
'{key}: Target is not empty, no need to update.',
['key' => $target->getKey(), 'old' => $oldValue, 'new' => $newValue]
);
return;
}
$this->logger->log(
LogLevel::NOTICE,
'{key}: Updating target value.',
['key' => $target->getKey(), 'old' => $oldValue, 'new' => $newValue]
);
if ($this->dryRun) {
return;
}
if (null === $value = $source->getTarget()) {
$target->clearTarget();
return;
}
$target->setTarget($value);
} | [
"private",
"function",
"copyTarget",
"(",
"TranslationValueInterface",
"$",
"source",
",",
"WritableTranslationValueInterface",
"$",
"target",
")",
":",
"void",
"{",
"if",
"(",
"self",
"::",
"DO_NOT_COPY",
"===",
"$",
"this",
"->",
"copyTarget",
")",
"{",
"retur... | Copy the target value.
@param TranslationValueInterface $source The source value.
@param WritableTranslationValueInterface $target The target value.
@return void | [
"Copy",
"the",
"target",
"value",
"."
] | 138e81d7119db82c2420bd33967a566e02b1d2f5 | https://github.com/cyberspectrum/i18n/blob/138e81d7119db82c2420bd33967a566e02b1d2f5/src/Job/CopyDictionaryJob.php#L418-L460 | train |
cyberspectrum/i18n | src/Job/CopyDictionaryJob.php | CopyDictionaryJob.cleanTarget | private function cleanTarget(): void
{
foreach ($this->targetDictionary->keys() as $key) {
if (!$this->sourceDictionary->has($key) || $this->sourceDictionary->get($key)->isSourceEmpty()) {
$this->logger->log($this->logLevel, 'Removing obsolete {key}.', ['key' => $key]);
if ($this->dryRun) {
continue;
}
$this->targetDictionary->remove($key);
}
}
} | php | private function cleanTarget(): void
{
foreach ($this->targetDictionary->keys() as $key) {
if (!$this->sourceDictionary->has($key) || $this->sourceDictionary->get($key)->isSourceEmpty()) {
$this->logger->log($this->logLevel, 'Removing obsolete {key}.', ['key' => $key]);
if ($this->dryRun) {
continue;
}
$this->targetDictionary->remove($key);
}
}
} | [
"private",
"function",
"cleanTarget",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"targetDictionary",
"->",
"keys",
"(",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"sourceDictionary",
"->",
"has",
"(",
"$",... | Clean the target language.
@return void | [
"Clean",
"the",
"target",
"language",
"."
] | 138e81d7119db82c2420bd33967a566e02b1d2f5 | https://github.com/cyberspectrum/i18n/blob/138e81d7119db82c2420bd33967a566e02b1d2f5/src/Job/CopyDictionaryJob.php#L467-L479 | train |
cyberspectrum/i18n | src/Job/CopyDictionaryJob.php | CopyDictionaryJob.isFiltered | private function isFiltered($key): bool
{
foreach ($this->filters as $expression) {
if (preg_match($expression, $key)) {
$this->logger->debug(sprintf('"%1$s" is filtered by "%2$s', $key, $expression));
return true;
}
}
return false;
} | php | private function isFiltered($key): bool
{
foreach ($this->filters as $expression) {
if (preg_match($expression, $key)) {
$this->logger->debug(sprintf('"%1$s" is filtered by "%2$s', $key, $expression));
return true;
}
}
return false;
} | [
"private",
"function",
"isFiltered",
"(",
"$",
"key",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"expression",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"expression",
",",
"$",
"key",
")",
")",
"{",
"$",
"thi... | Check if the passed key is filtered by any of the regexes.
@param string $key The key to check.
@return bool | [
"Check",
"if",
"the",
"passed",
"key",
"is",
"filtered",
"by",
"any",
"of",
"the",
"regexes",
"."
] | 138e81d7119db82c2420bd33967a566e02b1d2f5 | https://github.com/cyberspectrum/i18n/blob/138e81d7119db82c2420bd33967a566e02b1d2f5/src/Job/CopyDictionaryJob.php#L488-L498 | train |
dngo-io/steem-api | src/API/Post.php | Post.getContentReplies | public function getContentReplies(string $author, string $permalink)
{
$request = [
'route' => 'get_content_replies',
'query' =>
[
'author' => $author,
'permlink' => $permalink,
]
];
return parent::call($request);
} | php | public function getContentReplies(string $author, string $permalink)
{
$request = [
'route' => 'get_content_replies',
'query' =>
[
'author' => $author,
'permlink' => $permalink,
]
];
return parent::call($request);
} | [
"public",
"function",
"getContentReplies",
"(",
"string",
"$",
"author",
",",
"string",
"$",
"permalink",
")",
"{",
"$",
"request",
"=",
"[",
"'route'",
"=>",
"'get_content_replies'",
",",
"'query'",
"=>",
"[",
"'author'",
"=>",
"$",
"author",
",",
"'permlin... | Get content replies
@param string $author Author's account name
@param string $permalink Post's permalink
@return array | [
"Get",
"content",
"replies"
] | 1117e903a882354ac143b28cbfb9ee00a2351e09 | https://github.com/dngo-io/steem-api/blob/1117e903a882354ac143b28cbfb9ee00a2351e09/src/API/Post.php#L55-L67 | train |
dngo-io/steem-api | src/API/Post.php | Post.getContentAllReplies | public function getContentAllReplies(string $author, string $permalink)
{
$request = $this->getContentReplies($author, $permalink);
if(is_array($request))
{
foreach ($request as $key => $item)
{
if($item['children'] > 0)
$request[$key]['replies'] = $this->getContentAllReplies($item['author'], $item['permlink']);
else
$request[$key]['replies'] = [];
}
}
return $request;
} | php | public function getContentAllReplies(string $author, string $permalink)
{
$request = $this->getContentReplies($author, $permalink);
if(is_array($request))
{
foreach ($request as $key => $item)
{
if($item['children'] > 0)
$request[$key]['replies'] = $this->getContentAllReplies($item['author'], $item['permlink']);
else
$request[$key]['replies'] = [];
}
}
return $request;
} | [
"public",
"function",
"getContentAllReplies",
"(",
"string",
"$",
"author",
",",
"string",
"$",
"permalink",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getContentReplies",
"(",
"$",
"author",
",",
"$",
"permalink",
")",
";",
"if",
"(",
"is_array",
... | Get all content replies
@param string $author Author's account name
@param string $permalink Post's permalink
@return array | [
"Get",
"all",
"content",
"replies"
] | 1117e903a882354ac143b28cbfb9ee00a2351e09 | https://github.com/dngo-io/steem-api/blob/1117e903a882354ac143b28cbfb9ee00a2351e09/src/API/Post.php#L76-L92 | train |
pokap/pool-dbm | src/Pok/PoolDBM/Console/ConsoleRunner.php | ConsoleRunner.run | public static function run(HelperSet $helperSet, $commands = array())
{
$cli = new Application('PoolDBM Command Line Interface', Version::VERSION);
$cli->setCatchExceptions(true);
$cli->setHelperSet(new HelperSet($helperSet));
self::addDefaultCommands($cli);
$cli->addCommands($commands);
$cli->run();
} | php | public static function run(HelperSet $helperSet, $commands = array())
{
$cli = new Application('PoolDBM Command Line Interface', Version::VERSION);
$cli->setCatchExceptions(true);
$cli->setHelperSet(new HelperSet($helperSet));
self::addDefaultCommands($cli);
$cli->addCommands($commands);
$cli->run();
} | [
"public",
"static",
"function",
"run",
"(",
"HelperSet",
"$",
"helperSet",
",",
"$",
"commands",
"=",
"array",
"(",
")",
")",
"{",
"$",
"cli",
"=",
"new",
"Application",
"(",
"'PoolDBM Command Line Interface'",
",",
"Version",
"::",
"VERSION",
")",
";",
"$... | Runs console with the given helperset.
@param HelperSet $helperSet
@param \Symfony\Component\Console\Command\Command[] $commands
@return void | [
"Runs",
"console",
"with",
"the",
"given",
"helperset",
"."
] | cce32d7cb5f13f42c358c8140b2f97ddf1d9435a | https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/Console/ConsoleRunner.php#L52-L60 | train |
pletfix/core | src/Services/Stdio.php | Stdio.block | private function block($textblock)
{
$length = 0;
foreach ($textblock as $line) {
$n = strlen($line);
if ($length < $n) {
$length = $n;
}
}
foreach ($textblock as $i => $line) {
$textblock[$i] .= str_repeat(' ', $length - strlen($line));
}
return $textblock;
} | php | private function block($textblock)
{
$length = 0;
foreach ($textblock as $line) {
$n = strlen($line);
if ($length < $n) {
$length = $n;
}
}
foreach ($textblock as $i => $line) {
$textblock[$i] .= str_repeat(' ', $length - strlen($line));
}
return $textblock;
} | [
"private",
"function",
"block",
"(",
"$",
"textblock",
")",
"{",
"$",
"length",
"=",
"0",
";",
"foreach",
"(",
"$",
"textblock",
"as",
"$",
"line",
")",
"{",
"$",
"n",
"=",
"strlen",
"(",
"$",
"line",
")",
";",
"if",
"(",
"$",
"length",
"<",
"$... | Fill each line with spaces, so that all are equal in length.
@param string[] $textblock
@return string[] | [
"Fill",
"each",
"line",
"with",
"spaces",
"so",
"that",
"all",
"are",
"equal",
"in",
"length",
"."
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Stdio.php#L437-L452 | train |
juanparati/Emoji | src/EmojiDictionary.php | EmojiDictionary.get | public static function get($symbol)
{
$symbol = strtolower($symbol);
if (isset(static::$dictionary[$symbol]))
return static::$dictionary[$symbol];
else
return false;
} | php | public static function get($symbol)
{
$symbol = strtolower($symbol);
if (isset(static::$dictionary[$symbol]))
return static::$dictionary[$symbol];
else
return false;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"symbol",
")",
"{",
"$",
"symbol",
"=",
"strtolower",
"(",
"$",
"symbol",
")",
";",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"dictionary",
"[",
"$",
"symbol",
"]",
")",
")",
"return",
"static",
... | Get symbol by name
@param $symbol
@return mixed | [
"Get",
"symbol",
"by",
"name"
] | 53a34e1d3714f2a11ddc0451030eee06ea2f8f21 | https://github.com/juanparati/Emoji/blob/53a34e1d3714f2a11ddc0451030eee06ea2f8f21/src/EmojiDictionary.php#L1832-L1841 | train |
flowcode/AmulenShopBundle | src/Flowcode/ShopBundle/Controller/AdminProductOrderController.php | AdminProductOrderController.newAction | public function newAction()
{
$entity = new ProductOrder();
$form = $this->createCreateForm($entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
} | php | public function newAction()
{
$entity = new ProductOrder();
$form = $this->createCreateForm($entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
} | [
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"entity",
"=",
"new",
"ProductOrder",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createCreateForm",
"(",
"$",
"entity",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
... | Displays a form to create a new ProductOrder entity.
@Route("/new", name="admin_order_new")
@Method("GET")
@Template() | [
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"ProductOrder",
"entity",
"."
] | 500aaf4364be3c42fca69ecd10a449da03993814 | https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminProductOrderController.php#L107-L116 | train |
monolyth-php/formulaic | src/Validate/Element.php | Element.errors | public function errors() : array
{
$errors = [];
foreach ($this->tests as $error => $test) {
if (!$test($this->getValue())) {
$errors[] = $error;
}
}
return $errors;
} | php | public function errors() : array
{
$errors = [];
foreach ($this->tests as $error => $test) {
if (!$test($this->getValue())) {
$errors[] = $error;
}
}
return $errors;
} | [
"public",
"function",
"errors",
"(",
")",
":",
"array",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"tests",
"as",
"$",
"error",
"=>",
"$",
"test",
")",
"{",
"if",
"(",
"!",
"$",
"test",
"(",
"$",
"this",
"->",
... | Get array of errors for element.
@return array | [
"Get",
"array",
"of",
"errors",
"for",
"element",
"."
] | 4bf7853a0c29cc17957f1b26c79f633867742c14 | https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Validate/Element.php#L22-L31 | train |
JackieDo/Omnipay-Validator | src/Traits/ValidatorTrait.php | ValidatorTrait.validateWithRules | public function validateWithRules(array $validateRules, array $validateMessages = [], array $parametricConverter = [])
{
$this->validateDataWithRules($this->getParameters(), $validateRules, $validateMessages, $parametricConverter);
} | php | public function validateWithRules(array $validateRules, array $validateMessages = [], array $parametricConverter = [])
{
$this->validateDataWithRules($this->getParameters(), $validateRules, $validateMessages, $parametricConverter);
} | [
"public",
"function",
"validateWithRules",
"(",
"array",
"$",
"validateRules",
",",
"array",
"$",
"validateMessages",
"=",
"[",
"]",
",",
"array",
"$",
"parametricConverter",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"validateDataWithRules",
"(",
"$",
"thi... | Validate all parameters of request with defined rules.
This method is called internally by gateways to avoid wasting time with an API call
when the request is clearly invalid.
@param array $validateRules
@param array $validateMessages
@param array $parametricConverter
@throws InvalidRequestException
@throws BadMethodCallException | [
"Validate",
"all",
"parameters",
"of",
"request",
"with",
"defined",
"rules",
"."
] | 5aa780712fb0eddec28d0745a036859c95f96a34 | https://github.com/JackieDo/Omnipay-Validator/blob/5aa780712fb0eddec28d0745a036859c95f96a34/src/Traits/ValidatorTrait.php#L73-L76 | train |
JackieDo/Omnipay-Validator | src/Traits/ValidatorTrait.php | ValidatorTrait.validateDataWithRules | public function validateDataWithRules(array $data, array $validateRules, array $validateMessages = [], array $parametricConverter = [])
{
foreach ($validateRules as $key => $rules) {
$value = array_key_exists($key, $data) ? $data[$key] : null;
if (array_key_exists('nullable', $rules) && $rules['nullable'] && is_null($value)) {
continue;
}
unset($rules['nullable']);
$defaultParametricConverter = (method_exists($this, 'getParametricConverter') && is_array($this->getParametricConverter())) ? $this->getParametricConverter() : [];
$parametricConverter = array_merge($defaultParametricConverter, $parametricConverter);
$parameter = (array_key_exists($key, $parametricConverter)) ? $parametricConverter[$key] : $key;
foreach ($rules as $ruleName => $ruleParameter) {
if ($ruleName === 'callback') {
if (!is_callable($ruleParameter)) {
throw new BadMethodCallException('The reference of rule named `callback` must be a valid callable. You provided ' . $this->getValueDescription($ruleParameter) . '.');
}
call_user_func($ruleParameter, $value, InvalidRequestException::class);
} else {
$method = 'check'.ucfirst(Helper::camelCase($ruleName));
if (!method_exists($this, $method)) {
throw new BadMethodCallException('Call to undefined the ' .get_class($this). '::' .$method. '() validator that associated with the `' .$ruleName. '` rule');
}
if (!$this->$method($value, $ruleParameter)) {
$message = isset($validateMessages[$key][$ruleName]) ? $validateMessages[$key][$ruleName] : null;
throw new InvalidRequestException($this->formatMessage($parameter, $ruleName, $ruleParameter, $message));
}
}
}
}
} | php | public function validateDataWithRules(array $data, array $validateRules, array $validateMessages = [], array $parametricConverter = [])
{
foreach ($validateRules as $key => $rules) {
$value = array_key_exists($key, $data) ? $data[$key] : null;
if (array_key_exists('nullable', $rules) && $rules['nullable'] && is_null($value)) {
continue;
}
unset($rules['nullable']);
$defaultParametricConverter = (method_exists($this, 'getParametricConverter') && is_array($this->getParametricConverter())) ? $this->getParametricConverter() : [];
$parametricConverter = array_merge($defaultParametricConverter, $parametricConverter);
$parameter = (array_key_exists($key, $parametricConverter)) ? $parametricConverter[$key] : $key;
foreach ($rules as $ruleName => $ruleParameter) {
if ($ruleName === 'callback') {
if (!is_callable($ruleParameter)) {
throw new BadMethodCallException('The reference of rule named `callback` must be a valid callable. You provided ' . $this->getValueDescription($ruleParameter) . '.');
}
call_user_func($ruleParameter, $value, InvalidRequestException::class);
} else {
$method = 'check'.ucfirst(Helper::camelCase($ruleName));
if (!method_exists($this, $method)) {
throw new BadMethodCallException('Call to undefined the ' .get_class($this). '::' .$method. '() validator that associated with the `' .$ruleName. '` rule');
}
if (!$this->$method($value, $ruleParameter)) {
$message = isset($validateMessages[$key][$ruleName]) ? $validateMessages[$key][$ruleName] : null;
throw new InvalidRequestException($this->formatMessage($parameter, $ruleName, $ruleParameter, $message));
}
}
}
}
} | [
"public",
"function",
"validateDataWithRules",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"validateRules",
",",
"array",
"$",
"validateMessages",
"=",
"[",
"]",
",",
"array",
"$",
"parametricConverter",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"val... | Validate data with defined rules
@param array $data
@param array $validateRules
@param array $validateMessages
@param array $parametricConverter
@throws InvalidRequestException
@throws BadMethodCallException | [
"Validate",
"data",
"with",
"defined",
"rules"
] | 5aa780712fb0eddec28d0745a036859c95f96a34 | https://github.com/JackieDo/Omnipay-Validator/blob/5aa780712fb0eddec28d0745a036859c95f96a34/src/Traits/ValidatorTrait.php#L88-L125 | train |
JackieDo/Omnipay-Validator | src/Traits/ValidatorTrait.php | ValidatorTrait.formatMessage | protected function formatMessage($parameter, $ruleName, $ruleParameter, $message = null)
{
$message = $message ?: (isset($this->validateMessages[$ruleName]) ? $this->validateMessages[$ruleName] : $this->validateMessages['default']);
$message = str_replace(':parameter', $parameter, $message);
$method = 'format'.ucfirst(Helper::camelCase($ruleName)).'Message';
if (method_exists($this, $method)) {
return $this->$method($ruleParameter, $message);
}
return $message;
} | php | protected function formatMessage($parameter, $ruleName, $ruleParameter, $message = null)
{
$message = $message ?: (isset($this->validateMessages[$ruleName]) ? $this->validateMessages[$ruleName] : $this->validateMessages['default']);
$message = str_replace(':parameter', $parameter, $message);
$method = 'format'.ucfirst(Helper::camelCase($ruleName)).'Message';
if (method_exists($this, $method)) {
return $this->$method($ruleParameter, $message);
}
return $message;
} | [
"protected",
"function",
"formatMessage",
"(",
"$",
"parameter",
",",
"$",
"ruleName",
",",
"$",
"ruleParameter",
",",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"message",
"=",
"$",
"message",
"?",
":",
"(",
"isset",
"(",
"$",
"this",
"->",
"validate... | Format message for special rule
@param string $parameter
@param string $ruleName
@param mixed $ruleParameter
@param string $customMessage
@return string | [
"Format",
"message",
"for",
"special",
"rule"
] | 5aa780712fb0eddec28d0745a036859c95f96a34 | https://github.com/JackieDo/Omnipay-Validator/blob/5aa780712fb0eddec28d0745a036859c95f96a34/src/Traits/ValidatorTrait.php#L137-L148 | train |
JackieDo/Omnipay-Validator | src/Traits/ValidatorTrait.php | ValidatorTrait.getValueDescription | protected function getValueDescription($value)
{
switch (true) {
case (is_numeric($value)):
$value = strval($value);
break;
case (is_bool($value) && $value):
$value = '(boolean) true';
break;
case (is_bool($value) && !$value):
$value = '(boolean) false';
break;
case (is_null($value)):
$value = 'null value';
break;
default:
break;
}
return $value;
} | php | protected function getValueDescription($value)
{
switch (true) {
case (is_numeric($value)):
$value = strval($value);
break;
case (is_bool($value) && $value):
$value = '(boolean) true';
break;
case (is_bool($value) && !$value):
$value = '(boolean) false';
break;
case (is_null($value)):
$value = 'null value';
break;
default:
break;
}
return $value;
} | [
"protected",
"function",
"getValueDescription",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"(",
"is_numeric",
"(",
"$",
"value",
")",
")",
":",
"$",
"value",
"=",
"strval",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",... | Get description of value
@param mixed $value
@return string | [
"Get",
"description",
"of",
"value"
] | 5aa780712fb0eddec28d0745a036859c95f96a34 | https://github.com/JackieDo/Omnipay-Validator/blob/5aa780712fb0eddec28d0745a036859c95f96a34/src/Traits/ValidatorTrait.php#L157-L181 | train |
Dhii/container-helper-base | src/ContainerHasPathCapableTrait.php | ContainerHasPathCapableTrait._containerHasPath | protected function _containerHasPath($container, $path)
{
$originalPath = $path;
$path = $this->_normalizeArray($path);
$pathLength = count($path);
if (!$pathLength) {
throw $this->_createInvalidArgumentException($this->__('Not a valid path'), null, null, $originalPath);
}
$lastSegment = $path[$pathLength - 1];
$service = $container;
foreach ($path as $segment) {
$hasSegment = $this->_containerHas($service, $segment);
if (!$hasSegment) {
return false;
} elseif ($segment !== $lastSegment) {
$service = $this->_containerGet($service, $segment);
}
}
return true;
} | php | protected function _containerHasPath($container, $path)
{
$originalPath = $path;
$path = $this->_normalizeArray($path);
$pathLength = count($path);
if (!$pathLength) {
throw $this->_createInvalidArgumentException($this->__('Not a valid path'), null, null, $originalPath);
}
$lastSegment = $path[$pathLength - 1];
$service = $container;
foreach ($path as $segment) {
$hasSegment = $this->_containerHas($service, $segment);
if (!$hasSegment) {
return false;
} elseif ($segment !== $lastSegment) {
$service = $this->_containerGet($service, $segment);
}
}
return true;
} | [
"protected",
"function",
"_containerHasPath",
"(",
"$",
"container",
",",
"$",
"path",
")",
"{",
"$",
"originalPath",
"=",
"$",
"path",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"_normalizeArray",
"(",
"$",
"path",
")",
";",
"$",
"pathLength",
"=",
"co... | Check that path exists on a chain of nested containers.
@since [*next-version*]
@param array|ArrayAccess|stdClass|BaseContainerInterface $container The container to read from.
@param array|Traversable|stdClass $path The key of the value to retrieve.
@throws ContainerExceptionInterface If an error occurred while reading from the container.
@throws OutOfRangeException If the container or the key is invalid.
@throws NotFoundExceptionInterface If the key was not found in the container.
@return bool True if the container has an entry for the given key, false if not. | [
"Check",
"that",
"path",
"exists",
"on",
"a",
"chain",
"of",
"nested",
"containers",
"."
] | ccb2f56971d70cf203baa596cd14fdf91be6bfae | https://github.com/Dhii/container-helper-base/blob/ccb2f56971d70cf203baa596cd14fdf91be6bfae/src/ContainerHasPathCapableTrait.php#L37-L60 | train |
SamsonIT/DataViewBundle | Guesser/IsserTypeGuesser.php | IsserTypeGuesser.guessType | public function guessType($class, $property)
{
$reflClass = new \ReflectionClass($class);
if ($reflClass->hasProperty($property)) {
$reflProp = $reflClass->getProperty($property);
if ($reflProp->isPublic()) {
return null;
}
}
if (!$reflClass->hasMethod('get' . ucfirst($property)) && ($reflClass->hasMethod('is' . ucfirst($property)) || $reflClass->hasMethod('has' . ucfirst($property)))) {
return new TypeGuess('boolean', array(), Guess::HIGH_CONFIDENCE);
}
} | php | public function guessType($class, $property)
{
$reflClass = new \ReflectionClass($class);
if ($reflClass->hasProperty($property)) {
$reflProp = $reflClass->getProperty($property);
if ($reflProp->isPublic()) {
return null;
}
}
if (!$reflClass->hasMethod('get' . ucfirst($property)) && ($reflClass->hasMethod('is' . ucfirst($property)) || $reflClass->hasMethod('has' . ucfirst($property)))) {
return new TypeGuess('boolean', array(), Guess::HIGH_CONFIDENCE);
}
} | [
"public",
"function",
"guessType",
"(",
"$",
"class",
",",
"$",
"property",
")",
"{",
"$",
"reflClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"reflClass",
"->",
"hasProperty",
"(",
"$",
"property",
")",
")",
... | If a property has an isser or a hasser and not getter, it is assumed to be a boolean type
@param string $class The fully qualified class name
@param string $property The name of the property to guess for
@return TypeGuess|null A guess for the field's type and options | [
"If",
"a",
"property",
"has",
"an",
"isser",
"or",
"a",
"hasser",
"and",
"not",
"getter",
"it",
"is",
"assumed",
"to",
"be",
"a",
"boolean",
"type"
] | 572ea9a31f065f35035b55fa9db7333a49443025 | https://github.com/SamsonIT/DataViewBundle/blob/572ea9a31f065f35035b55fa9db7333a49443025/Guesser/IsserTypeGuesser.php#L19-L32 | train |
99designs/ergo | classes/Ergo/Error/AbstractErrorHandler.php | AbstractErrorHandler.isExceptionRecoverable | protected function isExceptionRecoverable($e)
{
if ($e instanceof \ErrorException)
{
$ignore = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_STRICT;
return (($ignore & $e->getSeverity()) != 0);
}
return false;
} | php | protected function isExceptionRecoverable($e)
{
if ($e instanceof \ErrorException)
{
$ignore = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_STRICT;
return (($ignore & $e->getSeverity()) != 0);
}
return false;
} | [
"protected",
"function",
"isExceptionRecoverable",
"(",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"\\",
"ErrorException",
")",
"{",
"$",
"ignore",
"=",
"E_WARNING",
"|",
"E_NOTICE",
"|",
"E_USER_WARNING",
"|",
"E_USER_NOTICE",
"|",
"E_STRICT",
"... | Determines whether an exception is recoverable
@return bool | [
"Determines",
"whether",
"an",
"exception",
"is",
"recoverable"
] | 8fbcfe683a14572cbf26ff59c3537c2261a7a4eb | https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/Error/AbstractErrorHandler.php#L46-L55 | train |
tzurbaev/api-client | src/Commands/ListResourcesCommand.php | ListResourcesCommand.createResourcesFromJsonData | protected function createResourcesFromJsonData(array $data, ResponseInterface $response, ApiResourceInterface $owner)
{
$items = [];
$className = $this->resourceClass();
foreach ($data as $item) {
$items[] = new $className($owner->getApi(), $item, $owner);
}
return $items;
} | php | protected function createResourcesFromJsonData(array $data, ResponseInterface $response, ApiResourceInterface $owner)
{
$items = [];
$className = $this->resourceClass();
foreach ($data as $item) {
$items[] = new $className($owner->getApi(), $item, $owner);
}
return $items;
} | [
"protected",
"function",
"createResourcesFromJsonData",
"(",
"array",
"$",
"data",
",",
"ResponseInterface",
"$",
"response",
",",
"ApiResourceInterface",
"$",
"owner",
")",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"$",
"className",
"=",
"$",
"this",
"->",
"re... | Create resources list from given JSON response.
@param array $data
@param ResponseInterface $response
@param ApiResourceInterface $owner
@return array | [
"Create",
"resources",
"list",
"from",
"given",
"JSON",
"response",
"."
] | 78cec644c2be7d732f1d826900e22f427de44f3c | https://github.com/tzurbaev/api-client/blob/78cec644c2be7d732f1d826900e22f427de44f3c/src/Commands/ListResourcesCommand.php#L80-L90 | train |
spiral/validation | src/Checker/TypeChecker.php | TypeChecker.datetime | public function datetime($value): bool
{
if (!is_scalar($value)) {
return false;
}
if (is_numeric($value)) {
return true;
}
return (int)strtotime($value) != 0;
} | php | public function datetime($value): bool
{
if (!is_scalar($value)) {
return false;
}
if (is_numeric($value)) {
return true;
}
return (int)strtotime($value) != 0;
} | [
"public",
"function",
"datetime",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"true",
"... | Value has to be valid datetime definition including numeric timestamp.
@param mixed $value
@return bool | [
"Value",
"has",
"to",
"be",
"valid",
"datetime",
"definition",
"including",
"numeric",
"timestamp",
"."
] | aa8977dfe93904acfcce354e000d7d384579e2e3 | https://github.com/spiral/validation/blob/aa8977dfe93904acfcce354e000d7d384579e2e3/src/Checker/TypeChecker.php#L70-L81 | train |
as3io/modlr-persister-mongodb | src/Persister.php | Persister.appendChangeSet | private function appendChangeSet(Model $model, array $obj, Closure $handler)
{
$metadata = $model->getMetadata();
$changeset = $model->getChangeSet();
$formatter = $this->getFormatter();
foreach ($this->changeSetMethods as $setKey => $methods) {
list($metaMethod, $formatMethod) = $methods;
foreach ($changeset[$setKey] as $key => $values) {
$value = $formatter->$formatMethod($metadata->$metaMethod($key), $values['new']);
$obj = $handler($key, $value, $obj);
}
}
return $obj;
} | php | private function appendChangeSet(Model $model, array $obj, Closure $handler)
{
$metadata = $model->getMetadata();
$changeset = $model->getChangeSet();
$formatter = $this->getFormatter();
foreach ($this->changeSetMethods as $setKey => $methods) {
list($metaMethod, $formatMethod) = $methods;
foreach ($changeset[$setKey] as $key => $values) {
$value = $formatter->$formatMethod($metadata->$metaMethod($key), $values['new']);
$obj = $handler($key, $value, $obj);
}
}
return $obj;
} | [
"private",
"function",
"appendChangeSet",
"(",
"Model",
"$",
"model",
",",
"array",
"$",
"obj",
",",
"Closure",
"$",
"handler",
")",
"{",
"$",
"metadata",
"=",
"$",
"model",
"->",
"getMetadata",
"(",
")",
";",
"$",
"changeset",
"=",
"$",
"model",
"->",... | Appends the change set values to a database object based on the provided handler.
@param Model $model
@param array $obj
@param Closure $handler
@return array | [
"Appends",
"the",
"change",
"set",
"values",
"to",
"a",
"database",
"object",
"based",
"on",
"the",
"provided",
"handler",
"."
] | 7f7474d1996167d3b03a72ead42c0662166506a3 | https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Persister.php#L274-L288 | train |
as3io/modlr-persister-mongodb | src/Persister.php | Persister.createInsertObj | private function createInsertObj(Model $model)
{
$metadata = $model->getMetadata();
$insert = [
$this->getIdentifierKey() => $this->convertId($model->getId()),
];
if (true === $metadata->isChildEntity()) {
$insert[$this->getPolymorphicKey()] = $metadata->type;
}
return $this->appendChangeSet($model, $insert, $this->getCreateChangeSetHandler());
} | php | private function createInsertObj(Model $model)
{
$metadata = $model->getMetadata();
$insert = [
$this->getIdentifierKey() => $this->convertId($model->getId()),
];
if (true === $metadata->isChildEntity()) {
$insert[$this->getPolymorphicKey()] = $metadata->type;
}
return $this->appendChangeSet($model, $insert, $this->getCreateChangeSetHandler());
} | [
"private",
"function",
"createInsertObj",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"metadata",
"=",
"$",
"model",
"->",
"getMetadata",
"(",
")",
";",
"$",
"insert",
"=",
"[",
"$",
"this",
"->",
"getIdentifierKey",
"(",
")",
"=>",
"$",
"this",
"->",
... | Creates the database insert object for a Model.
@param Model $model
@return array | [
"Creates",
"the",
"database",
"insert",
"object",
"for",
"a",
"Model",
"."
] | 7f7474d1996167d3b03a72ead42c0662166506a3 | https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Persister.php#L296-L306 | train |
as3io/modlr-persister-mongodb | src/Persister.php | Persister.getCreateChangeSetHandler | private function getCreateChangeSetHandler()
{
return function ($key, $value, $obj) {
if (null !== $value) {
$obj[$key] = $value;
}
return $obj;
};
} | php | private function getCreateChangeSetHandler()
{
return function ($key, $value, $obj) {
if (null !== $value) {
$obj[$key] = $value;
}
return $obj;
};
} | [
"private",
"function",
"getCreateChangeSetHandler",
"(",
")",
"{",
"return",
"function",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"obj",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"value",
")",
"{",
"$",
"obj",
"[",
"$",
"key",
"]",
"=",
"$",
... | Gets the change set handler Closure for create.
@return Closure | [
"Gets",
"the",
"change",
"set",
"handler",
"Closure",
"for",
"create",
"."
] | 7f7474d1996167d3b03a72ead42c0662166506a3 | https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Persister.php#L324-L332 | train |
as3io/modlr-persister-mongodb | src/Persister.php | Persister.getUpdateChangeSetHandler | private function getUpdateChangeSetHandler()
{
return function ($key, $value, $obj) {
$op = '$set';
if (null === $value) {
$op = '$unset';
$value = 1;
}
$obj[$op][$key] = $value;
return $obj;
};
} | php | private function getUpdateChangeSetHandler()
{
return function ($key, $value, $obj) {
$op = '$set';
if (null === $value) {
$op = '$unset';
$value = 1;
}
$obj[$op][$key] = $value;
return $obj;
};
} | [
"private",
"function",
"getUpdateChangeSetHandler",
"(",
")",
"{",
"return",
"function",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"obj",
")",
"{",
"$",
"op",
"=",
"'$set'",
";",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"$",
"op",
"=",... | Gets the change set handler Closure for update.
@return Closure | [
"Gets",
"the",
"change",
"set",
"handler",
"Closure",
"for",
"update",
"."
] | 7f7474d1996167d3b03a72ead42c0662166506a3 | https://github.com/as3io/modlr-persister-mongodb/blob/7f7474d1996167d3b03a72ead42c0662166506a3/src/Persister.php#L339-L350 | train |
jails/li3_access | extensions/adapter/security/access/DbAcl.php | DbAcl.check | public function check($requester, $request, $perms) {
$permission = $this->_classes['permission'];
return $permission::check($requester, $request, $perms);
} | php | public function check($requester, $request, $perms) {
$permission = $this->_classes['permission'];
return $permission::check($requester, $request, $perms);
} | [
"public",
"function",
"check",
"(",
"$",
"requester",
",",
"$",
"request",
",",
"$",
"perms",
")",
"{",
"$",
"permission",
"=",
"$",
"this",
"->",
"_classes",
"[",
"'permission'",
"]",
";",
"return",
"$",
"permission",
"::",
"check",
"(",
"$",
"request... | Check permission access
@param string $requester The requester identifier (Aro).
@param string $controlled The controlled identifier (Aco).
@return boolean Success (true if Aro has access to action in Aco, false otherwise) | [
"Check",
"permission",
"access"
] | aded70dca872ea9237e3eb709099730348008321 | https://github.com/jails/li3_access/blob/aded70dca872ea9237e3eb709099730348008321/extensions/adapter/security/access/DbAcl.php#L38-L41 | train |
axypro/cli-bin | opts/Parser.php | Parser.parse | public static function parse(array $argv, array $format)
{
$result = new Result();
if (empty($argv)) {
$result->error = 'empty argv';
return $result;
}
$result->command = array_shift($argv);
$pArgs = false;
$wait = null;
foreach ($argv as $arg) {
if ($wait) {
$result->options[$wait] = $arg;
$wait = null;
continue;
}
if (substr($arg, 0, 1) === '-') {
if ($pArgs) {
$result->error = 'option '.$arg.' after argument';
return $result;
}
$len = strlen($arg);
if ($len < 2) {
return null;
}
for ($i = 1; $i < $len; $i++) {
$o = substr($arg, $i, 1);
if (!isset($format[$o])) {
$result->error = 'illegal option -- '.$o;
return $result;
}
if ($format[$o]) {
if ($i < $len - 1) {
$result->options[$o] = substr($arg, $i + 1);
} else {
$wait = $o;
}
break;
} else {
$result->options[$o] = true;
}
}
} else {
$pArgs = true;
$result->args[] = $arg;
}
}
if ($wait !== null) {
$result->error = 'option requires an argument -- '.$wait;
return $result;
}
return $result;
} | php | public static function parse(array $argv, array $format)
{
$result = new Result();
if (empty($argv)) {
$result->error = 'empty argv';
return $result;
}
$result->command = array_shift($argv);
$pArgs = false;
$wait = null;
foreach ($argv as $arg) {
if ($wait) {
$result->options[$wait] = $arg;
$wait = null;
continue;
}
if (substr($arg, 0, 1) === '-') {
if ($pArgs) {
$result->error = 'option '.$arg.' after argument';
return $result;
}
$len = strlen($arg);
if ($len < 2) {
return null;
}
for ($i = 1; $i < $len; $i++) {
$o = substr($arg, $i, 1);
if (!isset($format[$o])) {
$result->error = 'illegal option -- '.$o;
return $result;
}
if ($format[$o]) {
if ($i < $len - 1) {
$result->options[$o] = substr($arg, $i + 1);
} else {
$wait = $o;
}
break;
} else {
$result->options[$o] = true;
}
}
} else {
$pArgs = true;
$result->args[] = $arg;
}
}
if ($wait !== null) {
$result->error = 'option requires an argument -- '.$wait;
return $result;
}
return $result;
} | [
"public",
"static",
"function",
"parse",
"(",
"array",
"$",
"argv",
",",
"array",
"$",
"format",
")",
"{",
"$",
"result",
"=",
"new",
"Result",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"argv",
")",
")",
"{",
"$",
"result",
"->",
"error",
"=",... | Parses a command line arguments
Format: allowed options
name => false (flag) / true (required value)
@param string[] $argv
@param array $format
@return \axy\cli\bin\opts\Result
@SuppressWarnings(PHPMD.CyclomaticComplexity)
@SuppressWarnings(PHPMD.NPathComplexity) | [
"Parses",
"a",
"command",
"line",
"arguments"
] | b2212f137ff3bb313fdafc3dfaa6783302d89326 | https://github.com/axypro/cli-bin/blob/b2212f137ff3bb313fdafc3dfaa6783302d89326/opts/Parser.php#L26-L78 | train |
indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/cache/storage/driver.php | Cache_Storage_Driver.set_contents | public function set_contents($contents, $handler = NULL)
{
$this->contents = $contents;
$this->set_content_handler($handler);
$this->contents = $this->handle_writing($contents);
return $this;
} | php | public function set_contents($contents, $handler = NULL)
{
$this->contents = $contents;
$this->set_content_handler($handler);
$this->contents = $this->handle_writing($contents);
return $this;
} | [
"public",
"function",
"set_contents",
"(",
"$",
"contents",
",",
"$",
"handler",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"contents",
"=",
"$",
"contents",
";",
"$",
"this",
"->",
"set_content_handler",
"(",
"$",
"handler",
")",
";",
"$",
"this",
"->"... | Set the contents with optional handler instead of the default
@param mixed
@param string
@return Cache_Storage_Driver | [
"Set",
"the",
"contents",
"with",
"optional",
"handler",
"instead",
"of",
"the",
"default"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/cache/storage/driver.php#L333-L339 | train |
indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/cache/storage/driver.php | Cache_Storage_Driver.set_content_handler | protected function set_content_handler($handler)
{
$this->handler_object = null;
$this->content_handler = (string) $handler;
return $this;
} | php | protected function set_content_handler($handler)
{
$this->handler_object = null;
$this->content_handler = (string) $handler;
return $this;
} | [
"protected",
"function",
"set_content_handler",
"(",
"$",
"handler",
")",
"{",
"$",
"this",
"->",
"handler_object",
"=",
"null",
";",
"$",
"this",
"->",
"content_handler",
"=",
"(",
"string",
")",
"$",
"handler",
";",
"return",
"$",
"this",
";",
"}"
] | Decides a content handler that makes it possible to write non-strings to a file
@param string
@return Cache_Storage_Driver | [
"Decides",
"a",
"content",
"handler",
"that",
"makes",
"it",
"possible",
"to",
"write",
"non",
"-",
"strings",
"to",
"a",
"file"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/cache/storage/driver.php#L357-L362 | train |
indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/cache/storage/driver.php | Cache_Storage_Driver.get_content_handler | public function get_content_handler($handler = null)
{
if ( ! empty($this->handler_object))
{
return $this->handler_object;
}
// When not yet set, use $handler or detect the preferred handler (string = string, otherwise serialize)
if (empty($this->content_handler) && empty($handler))
{
if ( ! empty($handler))
{
$this->content_handler = $handler;
}
if (is_string($this->contents))
{
$this->content_handler = \Config::get('cache.string_handler', 'string');
}
else
{
$type = is_object($this->contents) ? get_class($this->contents) : gettype($this->contents);
$this->content_handler = \Config::get('cache.'.$type.'_handler', 'serialized');
}
}
$class = '\\Cache_Handler_'.ucfirst($this->content_handler);
$this->handler_object = new $class();
return $this->handler_object;
} | php | public function get_content_handler($handler = null)
{
if ( ! empty($this->handler_object))
{
return $this->handler_object;
}
// When not yet set, use $handler or detect the preferred handler (string = string, otherwise serialize)
if (empty($this->content_handler) && empty($handler))
{
if ( ! empty($handler))
{
$this->content_handler = $handler;
}
if (is_string($this->contents))
{
$this->content_handler = \Config::get('cache.string_handler', 'string');
}
else
{
$type = is_object($this->contents) ? get_class($this->contents) : gettype($this->contents);
$this->content_handler = \Config::get('cache.'.$type.'_handler', 'serialized');
}
}
$class = '\\Cache_Handler_'.ucfirst($this->content_handler);
$this->handler_object = new $class();
return $this->handler_object;
} | [
"public",
"function",
"get_content_handler",
"(",
"$",
"handler",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"handler_object",
")",
")",
"{",
"return",
"$",
"this",
"->",
"handler_object",
";",
"}",
"// When not yet set, use $han... | Gets a specific content handler
@param string
@return Cache_Handler_Driver | [
"Gets",
"a",
"specific",
"content",
"handler"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/cache/storage/driver.php#L370-L399 | train |
calgamo/collection | src/Util/PhpArrayTrait.php | PhpArrayTrait._rindex | private function _rindex($index, array $values) : int
{
if (is_int($index) && $index < 0){
return count($values) + $index;
}
return $index;
} | php | private function _rindex($index, array $values) : int
{
if (is_int($index) && $index < 0){
return count($values) + $index;
}
return $index;
} | [
"private",
"function",
"_rindex",
"(",
"$",
"index",
",",
"array",
"$",
"values",
")",
":",
"int",
"{",
"if",
"(",
"is_int",
"(",
"$",
"index",
")",
"&&",
"$",
"index",
"<",
"0",
")",
"{",
"return",
"count",
"(",
"$",
"values",
")",
"+",
"$",
"... | Get reverse index
@param mixed $index
@param array $values
@return int | [
"Get",
"reverse",
"index"
] | 65b2efa612bc8250cbe0e1749c7d77176bd0c3c5 | https://github.com/calgamo/collection/blob/65b2efa612bc8250cbe0e1749c7d77176bd0c3c5/src/Util/PhpArrayTrait.php#L46-L52 | train |
calgamo/collection | src/Util/PhpArrayTrait.php | PhpArrayTrait._get | private function _get($index, $accept_reverse_index)
{
$values = $this->getValues();
if ($accept_reverse_index){
$index = $this->_rindex($index, $values);
}
return $values[$index] ?? null;
} | php | private function _get($index, $accept_reverse_index)
{
$values = $this->getValues();
if ($accept_reverse_index){
$index = $this->_rindex($index, $values);
}
return $values[$index] ?? null;
} | [
"private",
"function",
"_get",
"(",
"$",
"index",
",",
"$",
"accept_reverse_index",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getValues",
"(",
")",
";",
"if",
"(",
"$",
"accept_reverse_index",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"... | Get element value
@param mixed $index
@param bool $accept_reverse_index
@return mixed | [
"Get",
"element",
"value"
] | 65b2efa612bc8250cbe0e1749c7d77176bd0c3c5 | https://github.com/calgamo/collection/blob/65b2efa612bc8250cbe0e1749c7d77176bd0c3c5/src/Util/PhpArrayTrait.php#L97-L104 | train |
calgamo/collection | src/Util/PhpArrayTrait.php | PhpArrayTrait._first | private function _first(callable $callback = null)
{
$values = $this->getValues();
if ($callback){
foreach($values as $key => $value){
if ($callback($value, $key)){
return $value;
}
}
}
else{
return empty($values) ? null : $values[0];
}
return null;
} | php | private function _first(callable $callback = null)
{
$values = $this->getValues();
if ($callback){
foreach($values as $key => $value){
if ($callback($value, $key)){
return $value;
}
}
}
else{
return empty($values) ? null : $values[0];
}
return null;
} | [
"private",
"function",
"_first",
"(",
"callable",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getValues",
"(",
")",
";",
"if",
"(",
"$",
"callback",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>"... | Get head element of the array
@param callable $callback
@return mixed | [
"Get",
"head",
"element",
"of",
"the",
"array"
] | 65b2efa612bc8250cbe0e1749c7d77176bd0c3c5 | https://github.com/calgamo/collection/blob/65b2efa612bc8250cbe0e1749c7d77176bd0c3c5/src/Util/PhpArrayTrait.php#L149-L163 | train |
calgamo/collection | src/Util/PhpArrayTrait.php | PhpArrayTrait._last | private function _last(callable $callback = null)
{
$values = $this->getValues();
if ($callback){
foreach(array_reverse($values) as $key => $value){
if ($callback($value, $key)){
return $value;
}
}
}
else{
return empty($values) ? null : $values[count($values)-1];
}
return null;
} | php | private function _last(callable $callback = null)
{
$values = $this->getValues();
if ($callback){
foreach(array_reverse($values) as $key => $value){
if ($callback($value, $key)){
return $value;
}
}
}
else{
return empty($values) ? null : $values[count($values)-1];
}
return null;
} | [
"private",
"function",
"_last",
"(",
"callable",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getValues",
"(",
")",
";",
"if",
"(",
"$",
"callback",
")",
"{",
"foreach",
"(",
"array_reverse",
"(",
"$",
"values",
")"... | Get tail element of the array
@param callable $callback
@return mixed | [
"Get",
"tail",
"element",
"of",
"the",
"array"
] | 65b2efa612bc8250cbe0e1749c7d77176bd0c3c5 | https://github.com/calgamo/collection/blob/65b2efa612bc8250cbe0e1749c7d77176bd0c3c5/src/Util/PhpArrayTrait.php#L172-L186 | train |
calgamo/collection | src/Util/PhpArrayTrait.php | PhpArrayTrait._pop | private function _pop(& $item) : array
{
$values = $this->getValues();
if (empty($values)) {
$item = null;
return $values;
}
$item = array_pop($values);
return $values;
} | php | private function _pop(& $item) : array
{
$values = $this->getValues();
if (empty($values)) {
$item = null;
return $values;
}
$item = array_pop($values);
return $values;
} | [
"private",
"function",
"_pop",
"(",
"&",
"$",
"item",
")",
":",
"array",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getValues",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"$",
"item",
"=",
"null",
";",
"return",
"$"... | get item from tail
@param mixed &$item
@return mixed | [
"get",
"item",
"from",
"tail"
] | 65b2efa612bc8250cbe0e1749c7d77176bd0c3c5 | https://github.com/calgamo/collection/blob/65b2efa612bc8250cbe0e1749c7d77176bd0c3c5/src/Util/PhpArrayTrait.php#L215-L224 | train |
calgamo/collection | src/Util/PhpArrayTrait.php | PhpArrayTrait._indexOf | private function _indexOf($target, int $start = NULL )
{
$values = $this->getValues();
if ( $start === NULL ){
$start = 0;
}
$size = count($values);
for( $i=$start; $i < $size; $i++ ){
$item = $values[$i];
if ($item instanceof EqualableInterface){
if ( $item->equals($target) ){
return $i;
}
}
else if ($item === $target){
return $i;
}
}
return FALSE;
} | php | private function _indexOf($target, int $start = NULL )
{
$values = $this->getValues();
if ( $start === NULL ){
$start = 0;
}
$size = count($values);
for( $i=$start; $i < $size; $i++ ){
$item = $values[$i];
if ($item instanceof EqualableInterface){
if ( $item->equals($target) ){
return $i;
}
}
else if ($item === $target){
return $i;
}
}
return FALSE;
} | [
"private",
"function",
"_indexOf",
"(",
"$",
"target",
",",
"int",
"$",
"start",
"=",
"NULL",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getValues",
"(",
")",
";",
"if",
"(",
"$",
"start",
"===",
"NULL",
")",
"{",
"$",
"start",
"=",
"0",
... | Find index of element
@param mixed $target
@param int|NULL $start
@return bool|int | [
"Find",
"index",
"of",
"element"
] | 65b2efa612bc8250cbe0e1749c7d77176bd0c3c5 | https://github.com/calgamo/collection/blob/65b2efa612bc8250cbe0e1749c7d77176bd0c3c5/src/Util/PhpArrayTrait.php#L428-L448 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.addObjects | public function addObjects($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass add to internal logic
try {
$this->doAddObjects($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_OBJECTS_ADD, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_OBJECTS_ADD, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | php | public function addObjects($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass add to internal logic
try {
$this->doAddObjects($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_OBJECTS_ADD, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_OBJECTS_ADD, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | [
"public",
"function",
"addObjects",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"// find",
"$",
"model",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"return",
"new",
"NotFound",
"(",
... | Adds Objects to Sport
@param mixed $id
@param mixed $data
@return PayloadInterface | [
"Adds",
"Objects",
"to",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L78-L105 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.addPositions | public function addPositions($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass add to internal logic
try {
$this->doAddPositions($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_POSITIONS_ADD, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_POSITIONS_ADD, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | php | public function addPositions($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass add to internal logic
try {
$this->doAddPositions($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_POSITIONS_ADD, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_POSITIONS_ADD, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | [
"public",
"function",
"addPositions",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"// find",
"$",
"model",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"return",
"new",
"NotFound",
"("... | Adds Positions to Sport
@param mixed $id
@param mixed $data
@return PayloadInterface | [
"Adds",
"Positions",
"to",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L114-L141 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.removeObjects | public function removeObjects($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass remove to internal logic
try {
$this->doRemoveObjects($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_OBJECTS_REMOVE, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_OBJECTS_REMOVE, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | php | public function removeObjects($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass remove to internal logic
try {
$this->doRemoveObjects($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_OBJECTS_REMOVE, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_OBJECTS_REMOVE, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | [
"public",
"function",
"removeObjects",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"// find",
"$",
"model",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"return",
"new",
"NotFound",
"(... | Removes Objects from Sport
@param mixed $id
@param mixed $data
@return PayloadInterface | [
"Removes",
"Objects",
"from",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L336-L363 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.removePositions | public function removePositions($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass remove to internal logic
try {
$this->doRemovePositions($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_POSITIONS_REMOVE, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_POSITIONS_REMOVE, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | php | public function removePositions($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass remove to internal logic
try {
$this->doRemovePositions($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_POSITIONS_REMOVE, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_POSITIONS_REMOVE, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | [
"public",
"function",
"removePositions",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"// find",
"$",
"model",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"return",
"new",
"NotFound",
... | Removes Positions from Sport
@param mixed $id
@param mixed $data
@return PayloadInterface | [
"Removes",
"Positions",
"from",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L372-L399 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.updateGroups | public function updateGroups($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass update to internal logic
try {
$this->doUpdateGroups($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_GROUPS_UPDATE, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_GROUPS_UPDATE, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | php | public function updateGroups($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass update to internal logic
try {
$this->doUpdateGroups($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_GROUPS_UPDATE, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_GROUPS_UPDATE, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | [
"public",
"function",
"updateGroups",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"// find",
"$",
"model",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"return",
"new",
"NotFound",
"("... | Updates Groups on Sport
@param mixed $id
@param mixed $data
@return PayloadInterface | [
"Updates",
"Groups",
"on",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L490-L517 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.updateObjects | public function updateObjects($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass update to internal logic
try {
$this->doUpdateObjects($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_OBJECTS_UPDATE, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_OBJECTS_UPDATE, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | php | public function updateObjects($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass update to internal logic
try {
$this->doUpdateObjects($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_OBJECTS_UPDATE, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_OBJECTS_UPDATE, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | [
"public",
"function",
"updateObjects",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"// find",
"$",
"model",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"return",
"new",
"NotFound",
"(... | Updates Objects on Sport
@param mixed $id
@param mixed $data
@return PayloadInterface | [
"Updates",
"Objects",
"on",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L526-L553 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.updatePositions | public function updatePositions($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass update to internal logic
try {
$this->doUpdatePositions($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_POSITIONS_UPDATE, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_POSITIONS_UPDATE, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | php | public function updatePositions($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Sport not found.']);
}
// pass update to internal logic
try {
$this->doUpdatePositions($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(SportEvent::PRE_POSITIONS_UPDATE, $model, $data);
$this->dispatch(SportEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(SportEvent::POST_POSITIONS_UPDATE, $model, $data);
$this->dispatch(SportEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
} | [
"public",
"function",
"updatePositions",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"// find",
"$",
"model",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"return",
"new",
"NotFound",
... | Updates Positions on Sport
@param mixed $id
@param mixed $data
@return PayloadInterface | [
"Updates",
"Positions",
"on",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L562-L589 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.doAddObjects | protected function doAddObjects(Sport $model, $data) {
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Object';
} else {
$related = ObjectQuery::create()->findOneById($entry['id']);
$model->addObject($related);
}
}
if (count($errors) > 0) {
return new ErrorsException($errors);
}
} | php | protected function doAddObjects(Sport $model, $data) {
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Object';
} else {
$related = ObjectQuery::create()->findOneById($entry['id']);
$model->addObject($related);
}
}
if (count($errors) > 0) {
return new ErrorsException($errors);
}
} | [
"protected",
"function",
"doAddObjects",
"(",
"Sport",
"$",
"model",
",",
"$",
"data",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"entry",
"[",
"'id'"... | Interal mechanism to add Objects to Sport
@param Sport $model
@param mixed $data | [
"Interal",
"mechanism",
"to",
"add",
"Objects",
"to",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L727-L741 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.doAddPositions | protected function doAddPositions(Sport $model, $data) {
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Position';
} else {
$related = PositionQuery::create()->findOneById($entry['id']);
$model->addPosition($related);
}
}
if (count($errors) > 0) {
return new ErrorsException($errors);
}
} | php | protected function doAddPositions(Sport $model, $data) {
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Position';
} else {
$related = PositionQuery::create()->findOneById($entry['id']);
$model->addPosition($related);
}
}
if (count($errors) > 0) {
return new ErrorsException($errors);
}
} | [
"protected",
"function",
"doAddPositions",
"(",
"Sport",
"$",
"model",
",",
"$",
"data",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"entry",
"[",
"'id... | Interal mechanism to add Positions to Sport
@param Sport $model
@param mixed $data | [
"Interal",
"mechanism",
"to",
"add",
"Positions",
"to",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L749-L763 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.doAddSkills | protected function doAddSkills(Sport $model, $data) {
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Skill';
} else {
$related = SkillQuery::create()->findOneById($entry['id']);
$model->addSkill($related);
}
}
if (count($errors) > 0) {
return new ErrorsException($errors);
}
} | php | protected function doAddSkills(Sport $model, $data) {
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Skill';
} else {
$related = SkillQuery::create()->findOneById($entry['id']);
$model->addSkill($related);
}
}
if (count($errors) > 0) {
return new ErrorsException($errors);
}
} | [
"protected",
"function",
"doAddSkills",
"(",
"Sport",
"$",
"model",
",",
"$",
"data",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"entry",
"[",
"'id'",... | Interal mechanism to add Skills to Sport
@param Sport $model
@param mixed $data | [
"Interal",
"mechanism",
"to",
"add",
"Skills",
"to",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L771-L785 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.doRemoveObjects | protected function doRemoveObjects(Sport $model, $data) {
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Object';
} else {
$related = ObjectQuery::create()->findOneById($entry['id']);
$model->removeObject($related);
}
}
if (count($errors) > 0) {
return new ErrorsException($errors);
}
} | php | protected function doRemoveObjects(Sport $model, $data) {
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Object';
} else {
$related = ObjectQuery::create()->findOneById($entry['id']);
$model->removeObject($related);
}
}
if (count($errors) > 0) {
return new ErrorsException($errors);
}
} | [
"protected",
"function",
"doRemoveObjects",
"(",
"Sport",
"$",
"model",
",",
"$",
"data",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"entry",
"[",
"'i... | Interal mechanism to remove Objects from Sport
@param Sport $model
@param mixed $data | [
"Interal",
"mechanism",
"to",
"remove",
"Objects",
"from",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L815-L829 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.doRemovePositions | protected function doRemovePositions(Sport $model, $data) {
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Position';
} else {
$related = PositionQuery::create()->findOneById($entry['id']);
$model->removePosition($related);
}
}
if (count($errors) > 0) {
return new ErrorsException($errors);
}
} | php | protected function doRemovePositions(Sport $model, $data) {
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Position';
} else {
$related = PositionQuery::create()->findOneById($entry['id']);
$model->removePosition($related);
}
}
if (count($errors) > 0) {
return new ErrorsException($errors);
}
} | [
"protected",
"function",
"doRemovePositions",
"(",
"Sport",
"$",
"model",
",",
"$",
"data",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"entry",
"[",
"... | Interal mechanism to remove Positions from Sport
@param Sport $model
@param mixed $data | [
"Interal",
"mechanism",
"to",
"remove",
"Positions",
"from",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L837-L851 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.doUpdateGroups | protected function doUpdateGroups(Sport $model, $data) {
// remove all relationships before
GroupQuery::create()->filterBySport($model)->delete();
// add them
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Group';
} else {
$related = GroupQuery::create()->findOneById($entry['id']);
$model->addGroup($related);
}
}
if (count($errors) > 0) {
throw new ErrorsException($errors);
}
} | php | protected function doUpdateGroups(Sport $model, $data) {
// remove all relationships before
GroupQuery::create()->filterBySport($model)->delete();
// add them
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Group';
} else {
$related = GroupQuery::create()->findOneById($entry['id']);
$model->addGroup($related);
}
}
if (count($errors) > 0) {
throw new ErrorsException($errors);
}
} | [
"protected",
"function",
"doUpdateGroups",
"(",
"Sport",
"$",
"model",
",",
"$",
"data",
")",
"{",
"// remove all relationships before",
"GroupQuery",
"::",
"create",
"(",
")",
"->",
"filterBySport",
"(",
"$",
"model",
")",
"->",
"delete",
"(",
")",
";",
"//... | Internal update mechanism of Groups on Sport
@param Sport $model
@param mixed $data | [
"Internal",
"update",
"mechanism",
"of",
"Groups",
"on",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L881-L899 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.doUpdateObjects | protected function doUpdateObjects(Sport $model, $data) {
// remove all relationships before
ObjectQuery::create()->filterBySport($model)->delete();
// add them
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Object';
} else {
$related = ObjectQuery::create()->findOneById($entry['id']);
$model->addObject($related);
}
}
if (count($errors) > 0) {
throw new ErrorsException($errors);
}
} | php | protected function doUpdateObjects(Sport $model, $data) {
// remove all relationships before
ObjectQuery::create()->filterBySport($model)->delete();
// add them
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Object';
} else {
$related = ObjectQuery::create()->findOneById($entry['id']);
$model->addObject($related);
}
}
if (count($errors) > 0) {
throw new ErrorsException($errors);
}
} | [
"protected",
"function",
"doUpdateObjects",
"(",
"Sport",
"$",
"model",
",",
"$",
"data",
")",
"{",
"// remove all relationships before",
"ObjectQuery",
"::",
"create",
"(",
")",
"->",
"filterBySport",
"(",
"$",
"model",
")",
"->",
"delete",
"(",
")",
";",
"... | Internal update mechanism of Objects on Sport
@param Sport $model
@param mixed $data | [
"Internal",
"update",
"mechanism",
"of",
"Objects",
"on",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L907-L925 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.doUpdatePositions | protected function doUpdatePositions(Sport $model, $data) {
// remove all relationships before
PositionQuery::create()->filterBySport($model)->delete();
// add them
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Position';
} else {
$related = PositionQuery::create()->findOneById($entry['id']);
$model->addPosition($related);
}
}
if (count($errors) > 0) {
throw new ErrorsException($errors);
}
} | php | protected function doUpdatePositions(Sport $model, $data) {
// remove all relationships before
PositionQuery::create()->filterBySport($model)->delete();
// add them
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Position';
} else {
$related = PositionQuery::create()->findOneById($entry['id']);
$model->addPosition($related);
}
}
if (count($errors) > 0) {
throw new ErrorsException($errors);
}
} | [
"protected",
"function",
"doUpdatePositions",
"(",
"Sport",
"$",
"model",
",",
"$",
"data",
")",
"{",
"// remove all relationships before",
"PositionQuery",
"::",
"create",
"(",
")",
"->",
"filterBySport",
"(",
"$",
"model",
")",
"->",
"delete",
"(",
")",
";",... | Internal update mechanism of Positions on Sport
@param Sport $model
@param mixed $data | [
"Internal",
"update",
"mechanism",
"of",
"Positions",
"on",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L933-L951 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.doUpdateSkills | protected function doUpdateSkills(Sport $model, $data) {
// remove all relationships before
SkillQuery::create()->filterBySport($model)->delete();
// add them
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Skill';
} else {
$related = SkillQuery::create()->findOneById($entry['id']);
$model->addSkill($related);
}
}
if (count($errors) > 0) {
throw new ErrorsException($errors);
}
} | php | protected function doUpdateSkills(Sport $model, $data) {
// remove all relationships before
SkillQuery::create()->filterBySport($model)->delete();
// add them
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Skill';
} else {
$related = SkillQuery::create()->findOneById($entry['id']);
$model->addSkill($related);
}
}
if (count($errors) > 0) {
throw new ErrorsException($errors);
}
} | [
"protected",
"function",
"doUpdateSkills",
"(",
"Sport",
"$",
"model",
",",
"$",
"data",
")",
"{",
"// remove all relationships before",
"SkillQuery",
"::",
"create",
"(",
")",
"->",
"filterBySport",
"(",
"$",
"model",
")",
"->",
"delete",
"(",
")",
";",
"//... | Internal update mechanism of Skills on Sport
@param Sport $model
@param mixed $data | [
"Internal",
"update",
"mechanism",
"of",
"Skills",
"on",
"Sport"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L959-L977 | train |
gossi/trixionary | src/domain/base/SportDomainTrait.php | SportDomainTrait.get | protected function get($id) {
if ($this->pool === null) {
$this->pool = new Map();
} else if ($this->pool->has($id)) {
return $this->pool->get($id);
}
$model = SportQuery::create()->findOneById($id);
$this->pool->set($id, $model);
return $model;
} | php | protected function get($id) {
if ($this->pool === null) {
$this->pool = new Map();
} else if ($this->pool->has($id)) {
return $this->pool->get($id);
}
$model = SportQuery::create()->findOneById($id);
$this->pool->set($id, $model);
return $model;
} | [
"protected",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pool",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"pool",
"=",
"new",
"Map",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"pool",
"->",
"ha... | Returns one Sport with the given id from cache
@param mixed $id
@return Sport|null | [
"Returns",
"one",
"Sport",
"with",
"the",
"given",
"id",
"from",
"cache"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/SportDomainTrait.php#L985-L996 | train |
FiveLab/Resource | src/Resource/Error/ErrorCollection.php | ErrorCollection.addErrors | public function addErrors(ErrorResourceInterface ...$errors): void
{
$this->errors = array_merge($this->errors, $errors);
} | php | public function addErrors(ErrorResourceInterface ...$errors): void
{
$this->errors = array_merge($this->errors, $errors);
} | [
"public",
"function",
"addErrors",
"(",
"ErrorResourceInterface",
"...",
"$",
"errors",
")",
":",
"void",
"{",
"$",
"this",
"->",
"errors",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"errors",
",",
"$",
"errors",
")",
";",
"}"
] | Add errors to collection
@param ErrorResourceInterface[] ...$errors | [
"Add",
"errors",
"to",
"collection"
] | f2864924212dd4e2d1a3e7a1ad8a863d9db26127 | https://github.com/FiveLab/Resource/blob/f2864924212dd4e2d1a3e7a1ad8a863d9db26127/src/Resource/Error/ErrorCollection.php#L33-L36 | train |
calgamo/collection | src/Stack.php | Stack.push | public function push(... $items) : Stack
{
$values = $this->_pushAll($items);
$this->setValues($values);
return $this;
} | php | public function push(... $items) : Stack
{
$values = $this->_pushAll($items);
$this->setValues($values);
return $this;
} | [
"public",
"function",
"push",
"(",
"...",
"$",
"items",
")",
":",
"Stack",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"_pushAll",
"(",
"$",
"items",
")",
";",
"$",
"this",
"->",
"setValues",
"(",
"$",
"values",
")",
";",
"return",
"$",
"this",
"... | Push item to the top of stack
@param mixed $items
@return Stack | [
"Push",
"item",
"to",
"the",
"top",
"of",
"stack"
] | 65b2efa612bc8250cbe0e1749c7d77176bd0c3c5 | https://github.com/calgamo/collection/blob/65b2efa612bc8250cbe0e1749c7d77176bd0c3c5/src/Stack.php#L46-L51 | train |
opis-colibri/user-sql | src/Repositories/PermissionRepository.php | PermissionRepository.getAll | public function getAll(): iterable
{
if ($this->permissions === null) {
/** @var array $list */
$list = app()->getCollector()->collect('permissions')->get();
$key = 0;
$names = [];
$permissions = [];
foreach ($list as $name => $description) {
$permissions[] = new Permission($name, $description);
$names[$name] = $key;
$key++;
}
$this->permissions = $permissions;
$this->names = $names;
}
return $this->permissions;
} | php | public function getAll(): iterable
{
if ($this->permissions === null) {
/** @var array $list */
$list = app()->getCollector()->collect('permissions')->get();
$key = 0;
$names = [];
$permissions = [];
foreach ($list as $name => $description) {
$permissions[] = new Permission($name, $description);
$names[$name] = $key;
$key++;
}
$this->permissions = $permissions;
$this->names = $names;
}
return $this->permissions;
} | [
"public",
"function",
"getAll",
"(",
")",
":",
"iterable",
"{",
"if",
"(",
"$",
"this",
"->",
"permissions",
"===",
"null",
")",
"{",
"/** @var array $list */",
"$",
"list",
"=",
"app",
"(",
")",
"->",
"getCollector",
"(",
")",
"->",
"collect",
"(",
"'... | Get all permissions
@return iterable|IPermission[] | [
"Get",
"all",
"permissions"
] | 68c7765cda02992bf2d8302afb2b519b8b0bdf2f | https://github.com/opis-colibri/user-sql/blob/68c7765cda02992bf2d8302afb2b519b8b0bdf2f/src/Repositories/PermissionRepository.php#L40-L62 | train |
opis-colibri/user-sql | src/Repositories/PermissionRepository.php | PermissionRepository.getByName | public function getByName(string $name): ?IPermission
{
if ($this->permissions === null) {
$this->getAll();
}
if (!isset($this->names[$name])) {
return null;
}
return $this->permissions[$this->names[$name]];
} | php | public function getByName(string $name): ?IPermission
{
if ($this->permissions === null) {
$this->getAll();
}
if (!isset($this->names[$name])) {
return null;
}
return $this->permissions[$this->names[$name]];
} | [
"public",
"function",
"getByName",
"(",
"string",
"$",
"name",
")",
":",
"?",
"IPermission",
"{",
"if",
"(",
"$",
"this",
"->",
"permissions",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"getAll",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
... | Get permission by its name
@param string $name
@return null|IPermission | [
"Get",
"permission",
"by",
"its",
"name"
] | 68c7765cda02992bf2d8302afb2b519b8b0bdf2f | https://github.com/opis-colibri/user-sql/blob/68c7765cda02992bf2d8302afb2b519b8b0bdf2f/src/Repositories/PermissionRepository.php#L70-L81 | train |
opis-colibri/user-sql | src/Repositories/PermissionRepository.php | PermissionRepository.getMultipleByName | public function getMultipleByName(array $permissions): array
{
if ($this->permissions === null) {
$this->getAll();
}
$results = [];
foreach ($permissions as $permission) {
if (isset($this->names[$permission])) {
$results[] = $this->permissions[$this->names[$permission]];
}
}
return $results;
} | php | public function getMultipleByName(array $permissions): array
{
if ($this->permissions === null) {
$this->getAll();
}
$results = [];
foreach ($permissions as $permission) {
if (isset($this->names[$permission])) {
$results[] = $this->permissions[$this->names[$permission]];
}
}
return $results;
} | [
"public",
"function",
"getMultipleByName",
"(",
"array",
"$",
"permissions",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"permissions",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"getAll",
"(",
")",
";",
"}",
"$",
"results",
"=",
"[",
"]",... | Get a permissions by their name
@param string[] $permissions
@return IPermission[] | [
"Get",
"a",
"permissions",
"by",
"their",
"name"
] | 68c7765cda02992bf2d8302afb2b519b8b0bdf2f | https://github.com/opis-colibri/user-sql/blob/68c7765cda02992bf2d8302afb2b519b8b0bdf2f/src/Repositories/PermissionRepository.php#L89-L104 | train |
squire-assistant/dependency-injection | Compiler/InlineServiceDefinitionsPass.php | InlineServiceDefinitionsPass.process | public function process(ContainerBuilder $container)
{
$this->compiler = $container->getCompiler();
$this->formatter = $this->compiler->getLoggingFormatter();
$this->graph = $this->compiler->getServiceReferenceGraph();
$container->setDefinitions($this->inlineArguments($container, $container->getDefinitions(), true));
} | php | public function process(ContainerBuilder $container)
{
$this->compiler = $container->getCompiler();
$this->formatter = $this->compiler->getLoggingFormatter();
$this->graph = $this->compiler->getServiceReferenceGraph();
$container->setDefinitions($this->inlineArguments($container, $container->getDefinitions(), true));
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"this",
"->",
"compiler",
"=",
"$",
"container",
"->",
"getCompiler",
"(",
")",
";",
"$",
"this",
"->",
"formatter",
"=",
"$",
"this",
"->",
"compiler",
"->",
"get... | Processes the ContainerBuilder for inline service definitions.
@param ContainerBuilder $container | [
"Processes",
"the",
"ContainerBuilder",
"for",
"inline",
"service",
"definitions",
"."
] | c61d77bf8814369344fd71b015d7238322126041 | https://github.com/squire-assistant/dependency-injection/blob/c61d77bf8814369344fd71b015d7238322126041/Compiler/InlineServiceDefinitionsPass.php#L44-L51 | train |
squire-assistant/dependency-injection | Compiler/InlineServiceDefinitionsPass.php | InlineServiceDefinitionsPass.inlineArguments | private function inlineArguments(ContainerBuilder $container, array $arguments, $isRoot = false)
{
foreach ($arguments as $k => $argument) {
if ($isRoot) {
$this->currentId = $k;
}
if (is_array($argument)) {
$arguments[$k] = $this->inlineArguments($container, $argument);
} elseif ($argument instanceof Reference) {
if (!$container->hasDefinition($id = (string) $argument)) {
continue;
}
if ($this->isInlineableDefinition($id, $definition = $container->getDefinition($id))) {
$this->compiler->addLogMessage($this->formatter->formatInlineService($this, $id, $this->currentId));
if ($definition->isShared()) {
$arguments[$k] = $definition;
} else {
$arguments[$k] = clone $definition;
}
}
} elseif ($argument instanceof Definition) {
$argument->setArguments($this->inlineArguments($container, $argument->getArguments()));
$argument->setMethodCalls($this->inlineArguments($container, $argument->getMethodCalls()));
$argument->setProperties($this->inlineArguments($container, $argument->getProperties()));
$configurator = $this->inlineArguments($container, array($argument->getConfigurator()));
$argument->setConfigurator($configurator[0]);
$factory = $this->inlineArguments($container, array($argument->getFactory()));
$argument->setFactory($factory[0]);
}
}
return $arguments;
} | php | private function inlineArguments(ContainerBuilder $container, array $arguments, $isRoot = false)
{
foreach ($arguments as $k => $argument) {
if ($isRoot) {
$this->currentId = $k;
}
if (is_array($argument)) {
$arguments[$k] = $this->inlineArguments($container, $argument);
} elseif ($argument instanceof Reference) {
if (!$container->hasDefinition($id = (string) $argument)) {
continue;
}
if ($this->isInlineableDefinition($id, $definition = $container->getDefinition($id))) {
$this->compiler->addLogMessage($this->formatter->formatInlineService($this, $id, $this->currentId));
if ($definition->isShared()) {
$arguments[$k] = $definition;
} else {
$arguments[$k] = clone $definition;
}
}
} elseif ($argument instanceof Definition) {
$argument->setArguments($this->inlineArguments($container, $argument->getArguments()));
$argument->setMethodCalls($this->inlineArguments($container, $argument->getMethodCalls()));
$argument->setProperties($this->inlineArguments($container, $argument->getProperties()));
$configurator = $this->inlineArguments($container, array($argument->getConfigurator()));
$argument->setConfigurator($configurator[0]);
$factory = $this->inlineArguments($container, array($argument->getFactory()));
$argument->setFactory($factory[0]);
}
}
return $arguments;
} | [
"private",
"function",
"inlineArguments",
"(",
"ContainerBuilder",
"$",
"container",
",",
"array",
"$",
"arguments",
",",
"$",
"isRoot",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"k",
"=>",
"$",
"argument",
")",
"{",
"if",
"(",... | Processes inline arguments.
@param ContainerBuilder $container The ContainerBuilder
@param array $arguments An array of arguments
@param bool $isRoot If we are processing the root definitions or not
@return array | [
"Processes",
"inline",
"arguments",
"."
] | c61d77bf8814369344fd71b015d7238322126041 | https://github.com/squire-assistant/dependency-injection/blob/c61d77bf8814369344fd71b015d7238322126041/Compiler/InlineServiceDefinitionsPass.php#L62-L98 | train |
DevGroup-ru/dotplant-emails | src/commands/EmailController.php | EmailController.send | private function send($message)
{
$widget = new Widget;
$templateParams = Json::decode($message->packed_json_template_params);
return \Yii::$app->mailer
->compose($message->template->body_view_file, $templateParams)
->setFrom(Module::module()->senderEmail)
->setTo(trim($message->email))
->setSubject(
$widget->render($message->template->subject_view_file, $templateParams)
)
->send();
} | php | private function send($message)
{
$widget = new Widget;
$templateParams = Json::decode($message->packed_json_template_params);
return \Yii::$app->mailer
->compose($message->template->body_view_file, $templateParams)
->setFrom(Module::module()->senderEmail)
->setTo(trim($message->email))
->setSubject(
$widget->render($message->template->subject_view_file, $templateParams)
)
->send();
} | [
"private",
"function",
"send",
"(",
"$",
"message",
")",
"{",
"$",
"widget",
"=",
"new",
"Widget",
";",
"$",
"templateParams",
"=",
"Json",
"::",
"decode",
"(",
"$",
"message",
"->",
"packed_json_template_params",
")",
";",
"return",
"\\",
"Yii",
"::",
"... | Send the message via swift mailer
@param Message $message
@return bool | [
"Send",
"the",
"message",
"via",
"swift",
"mailer"
] | 8ee636f0440b25b5848b50fa05a825635ea18d5f | https://github.com/DevGroup-ru/dotplant-emails/blob/8ee636f0440b25b5848b50fa05a825635ea18d5f/src/commands/EmailController.php#L23-L35 | train |
DevGroup-ru/dotplant-emails | src/commands/EmailController.php | EmailController.actionSend | public function actionSend($id)
{
$message = Message::findOne($id);
if ($message !== null) {
try {
$message->status = $this->send($message) > 0 ? Message::STATUS_SUCCESS : Message::STATUS_ERROR;
$message->save(true, ['status']);
} catch (\Exception $e) {
$message->status = Message::STATUS_ERROR;
$message->save(true, ['status']);
$this->stderr($e->getMessage());
}
} else {
$this->stdout("Message not found\n");
exit(1);
}
} | php | public function actionSend($id)
{
$message = Message::findOne($id);
if ($message !== null) {
try {
$message->status = $this->send($message) > 0 ? Message::STATUS_SUCCESS : Message::STATUS_ERROR;
$message->save(true, ['status']);
} catch (\Exception $e) {
$message->status = Message::STATUS_ERROR;
$message->save(true, ['status']);
$this->stderr($e->getMessage());
}
} else {
$this->stdout("Message not found\n");
exit(1);
}
} | [
"public",
"function",
"actionSend",
"(",
"$",
"id",
")",
"{",
"$",
"message",
"=",
"Message",
"::",
"findOne",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"message",
"!==",
"null",
")",
"{",
"try",
"{",
"$",
"message",
"->",
"status",
"=",
"$",
"th... | Send the message by id
@param int $id the message id | [
"Send",
"the",
"message",
"by",
"id"
] | 8ee636f0440b25b5848b50fa05a825635ea18d5f | https://github.com/DevGroup-ru/dotplant-emails/blob/8ee636f0440b25b5848b50fa05a825635ea18d5f/src/commands/EmailController.php#L50-L66 | train |
DevGroup-ru/dotplant-emails | src/commands/EmailController.php | EmailController.sendFailed | public function sendFailed()
{
$messages = Message::findAll(['status' => Message::STATUS_ERROR]);
foreach ($messages as $message) {
try {
$message->status = $this->send($message) > 0 ? Message::STATUS_SUCCESS : Message::STATUS_ERROR;
$message->save(true, ['status']);
} catch (\Exception $e) {
$message->status = Message::STATUS_FATAL_ERROR;
$message->save(true, ['status']);
$this->stderr($e->getMessage());
}
}
} | php | public function sendFailed()
{
$messages = Message::findAll(['status' => Message::STATUS_ERROR]);
foreach ($messages as $message) {
try {
$message->status = $this->send($message) > 0 ? Message::STATUS_SUCCESS : Message::STATUS_ERROR;
$message->save(true, ['status']);
} catch (\Exception $e) {
$message->status = Message::STATUS_FATAL_ERROR;
$message->save(true, ['status']);
$this->stderr($e->getMessage());
}
}
} | [
"public",
"function",
"sendFailed",
"(",
")",
"{",
"$",
"messages",
"=",
"Message",
"::",
"findAll",
"(",
"[",
"'status'",
"=>",
"Message",
"::",
"STATUS_ERROR",
"]",
")",
";",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"try",
"{"... | Send failed messages | [
"Send",
"failed",
"messages"
] | 8ee636f0440b25b5848b50fa05a825635ea18d5f | https://github.com/DevGroup-ru/dotplant-emails/blob/8ee636f0440b25b5848b50fa05a825635ea18d5f/src/commands/EmailController.php#L71-L84 | train |
easy-system/es-template | src/Renderer.php | Renderer.render | public function render($nameOrModel, array $variables = [])
{
$__module = null;
if ($nameOrModel instanceof ViewModelInterface) {
$model = $nameOrModel;
$nameOrModel = $model->getTemplate();
$__module = $model->getModule();
$variables = array_merge($model->getVariables(), $variables);
unset($model);
} elseif (! is_string($nameOrModel)) {
throw new InvalidArgumentException(sprintf(
'Invalid render source provided; must be a string or instance '
. 'of "%s", "%s" received.',
ViewModelInterface::CLASS,
is_object($nameOrModel) ? get_class($nameOrModel)
: gettype($nameOrModel)
));
}
extract($variables);
$__old = $this->setVariables($variables);
unset($variables);
try {
ob_start();
include $this->getResolver()->resolve($nameOrModel, $__module);
$__return = ob_get_clean();
} catch (Error $e) {
ob_end_clean();
throw $e;
} catch (Exception $e) {
ob_end_clean();
throw $e;
}
$this->setVariables($__old);
return $__return;
} | php | public function render($nameOrModel, array $variables = [])
{
$__module = null;
if ($nameOrModel instanceof ViewModelInterface) {
$model = $nameOrModel;
$nameOrModel = $model->getTemplate();
$__module = $model->getModule();
$variables = array_merge($model->getVariables(), $variables);
unset($model);
} elseif (! is_string($nameOrModel)) {
throw new InvalidArgumentException(sprintf(
'Invalid render source provided; must be a string or instance '
. 'of "%s", "%s" received.',
ViewModelInterface::CLASS,
is_object($nameOrModel) ? get_class($nameOrModel)
: gettype($nameOrModel)
));
}
extract($variables);
$__old = $this->setVariables($variables);
unset($variables);
try {
ob_start();
include $this->getResolver()->resolve($nameOrModel, $__module);
$__return = ob_get_clean();
} catch (Error $e) {
ob_end_clean();
throw $e;
} catch (Exception $e) {
ob_end_clean();
throw $e;
}
$this->setVariables($__old);
return $__return;
} | [
"public",
"function",
"render",
"(",
"$",
"nameOrModel",
",",
"array",
"$",
"variables",
"=",
"[",
"]",
")",
"{",
"$",
"__module",
"=",
"null",
";",
"if",
"(",
"$",
"nameOrModel",
"instanceof",
"ViewModelInterface",
")",
"{",
"$",
"model",
"=",
"$",
"n... | Renders the view model or template.
@param string|Es\Mvc\ViewModelInterface $nameOrModel The name of template
or instance of
view model
@param array $variables Optional; the variables
uses to render
@throws \InvalidArgumentException If invalid type of render source
specified
@return string The result of rendering | [
"Renders",
"the",
"view",
"model",
"or",
"template",
"."
] | d84bd4b3f66a40c97f86ea10e4dbb71a462a725f | https://github.com/easy-system/es-template/blob/d84bd4b3f66a40c97f86ea10e4dbb71a462a725f/src/Renderer.php#L109-L147 | train |
LasseHaslev/image-handler | src/Handlers/CropHandler.php | CropHandler.create | public static function create($baseFolder = null, $cropsFolder = null, $adaptor = null)
{
return new static( $baseFolder, $cropsFolder, $adaptor );
} | php | public static function create($baseFolder = null, $cropsFolder = null, $adaptor = null)
{
return new static( $baseFolder, $cropsFolder, $adaptor );
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"baseFolder",
"=",
"null",
",",
"$",
"cropsFolder",
"=",
"null",
",",
"$",
"adaptor",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"$",
"baseFolder",
",",
"$",
"cropsFolder",
",",
"$",
"adap... | Staticly create instance
@return Crophandler | [
"Staticly",
"create",
"instance"
] | dfc4fc7417617169d2483d62e5d27d3dd6a12235 | https://github.com/LasseHaslev/image-handler/blob/dfc4fc7417617169d2483d62e5d27d3dd6a12235/src/Handlers/CropHandler.php#L24-L27 | train |
LasseHaslev/image-handler | src/Handlers/CropHandler.php | CropHandler.handle | public function handle($data = null)
{
// Handle data with adaptor
$adaptor = $this->getAdaptor();
if ( $adaptor ) {
$data = $adaptor->transform( $data, $this );
}
// Overwrite default data with data
$data = array_merge( [
'name'=>null,
'width'=>null,
'height'=>null,
'focus_point_x'=>0,
'focus_point_y'=>0,
'resize'=>false,
], $data );
// Create variables from array keys
extract( $data );
// Throw error if filename is not set
if ( ! $name ) throw new \Exception( 'You need to set a name in adaptor' );
// Throw error if both width and height is null
if ( ! $width && ! $height ) throw new \Exception( 'The width or the height need to be set' );
// Create handler
$this->handler = ImageHandler::create( $name, $this->getBaseFolder(), $this->getCropsFolder() );
// Check if we should resize or crop
// If one of the width or height is _ This is still a resize
if ( $resize || ( !$width || !$height ) ) {
$this->handler->resize( $width, $height );
}
else {
$this->handler->cropToFit( $width, $height, $focus_point_x, $focus_point_y );
}
// Return this for binding
return $this;
} | php | public function handle($data = null)
{
// Handle data with adaptor
$adaptor = $this->getAdaptor();
if ( $adaptor ) {
$data = $adaptor->transform( $data, $this );
}
// Overwrite default data with data
$data = array_merge( [
'name'=>null,
'width'=>null,
'height'=>null,
'focus_point_x'=>0,
'focus_point_y'=>0,
'resize'=>false,
], $data );
// Create variables from array keys
extract( $data );
// Throw error if filename is not set
if ( ! $name ) throw new \Exception( 'You need to set a name in adaptor' );
// Throw error if both width and height is null
if ( ! $width && ! $height ) throw new \Exception( 'The width or the height need to be set' );
// Create handler
$this->handler = ImageHandler::create( $name, $this->getBaseFolder(), $this->getCropsFolder() );
// Check if we should resize or crop
// If one of the width or height is _ This is still a resize
if ( $resize || ( !$width || !$height ) ) {
$this->handler->resize( $width, $height );
}
else {
$this->handler->cropToFit( $width, $height, $focus_point_x, $focus_point_y );
}
// Return this for binding
return $this;
} | [
"public",
"function",
"handle",
"(",
"$",
"data",
"=",
"null",
")",
"{",
"// Handle data with adaptor",
"$",
"adaptor",
"=",
"$",
"this",
"->",
"getAdaptor",
"(",
")",
";",
"if",
"(",
"$",
"adaptor",
")",
"{",
"$",
"data",
"=",
"$",
"adaptor",
"->",
... | Handle image based on array
@return void | [
"Handle",
"image",
"based",
"on",
"array"
] | dfc4fc7417617169d2483d62e5d27d3dd6a12235 | https://github.com/LasseHaslev/image-handler/blob/dfc4fc7417617169d2483d62e5d27d3dd6a12235/src/Handlers/CropHandler.php#L45-L87 | train |
LasseHaslev/image-handler | src/Handlers/CropHandler.php | CropHandler.getBaseFolder | public function getBaseFolder( $path = null )
{
if ( $path ) {
return sprintf( '%s/%s', $this->baseFolder, $path );
}
return $this->baseFolder;
} | php | public function getBaseFolder( $path = null )
{
if ( $path ) {
return sprintf( '%s/%s', $this->baseFolder, $path );
}
return $this->baseFolder;
} | [
"public",
"function",
"getBaseFolder",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"path",
")",
"{",
"return",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"this",
"->",
"baseFolder",
",",
"$",
"path",
")",
";",
"}",
"return",
"$",
"this",
"->... | Getter for baseFolder
return string | [
"Getter",
"for",
"baseFolder"
] | dfc4fc7417617169d2483d62e5d27d3dd6a12235 | https://github.com/LasseHaslev/image-handler/blob/dfc4fc7417617169d2483d62e5d27d3dd6a12235/src/Handlers/CropHandler.php#L123-L131 | train |
LasseHaslev/image-handler | src/Handlers/CropHandler.php | CropHandler.getCropsFolder | public function getCropsFolder( $path = null )
{
if ( ! $this->cropsFolder ) {
return $this->getBaseFolder($path);
}
if ( $path ) {
return sprintf( '%s/%s', $this->cropsFolder, basename( $path ) );
}
return $this->cropsFolder;
} | php | public function getCropsFolder( $path = null )
{
if ( ! $this->cropsFolder ) {
return $this->getBaseFolder($path);
}
if ( $path ) {
return sprintf( '%s/%s', $this->cropsFolder, basename( $path ) );
}
return $this->cropsFolder;
} | [
"public",
"function",
"getCropsFolder",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"cropsFolder",
")",
"{",
"return",
"$",
"this",
"->",
"getBaseFolder",
"(",
"$",
"path",
")",
";",
"}",
"if",
"(",
"$",
"path",
")",... | Getter for cropsFolder
return string | [
"Getter",
"for",
"cropsFolder"
] | dfc4fc7417617169d2483d62e5d27d3dd6a12235 | https://github.com/LasseHaslev/image-handler/blob/dfc4fc7417617169d2483d62e5d27d3dd6a12235/src/Handlers/CropHandler.php#L152-L163 | train |
LasseHaslev/image-handler | src/Handlers/CropHandler.php | CropHandler.setAdaptor | public function setAdaptor($adaptor = null)
{
// Set the adaptor
$this->adaptor = $adaptor;
// If we just want to reset the adaptor
if ( ! $adaptor ) {
return $this;
}
// Validate the adaptor
if ( ! ( $adaptor instanceof CropAdaptorInterface ) ) {
throw new \Exception( 'The adaptor need to implement LasseHaslev\Image\Adaptors\CropAdaptorInterface' );
}
// Return this for binding
return $this;
} | php | public function setAdaptor($adaptor = null)
{
// Set the adaptor
$this->adaptor = $adaptor;
// If we just want to reset the adaptor
if ( ! $adaptor ) {
return $this;
}
// Validate the adaptor
if ( ! ( $adaptor instanceof CropAdaptorInterface ) ) {
throw new \Exception( 'The adaptor need to implement LasseHaslev\Image\Adaptors\CropAdaptorInterface' );
}
// Return this for binding
return $this;
} | [
"public",
"function",
"setAdaptor",
"(",
"$",
"adaptor",
"=",
"null",
")",
"{",
"// Set the adaptor",
"$",
"this",
"->",
"adaptor",
"=",
"$",
"adaptor",
";",
"// If we just want to reset the adaptor",
"if",
"(",
"!",
"$",
"adaptor",
")",
"{",
"return",
"$",
... | Setter for adaptor
@param CropAdaptorInterface $adaptor
@return CropHandler | [
"Setter",
"for",
"adaptor"
] | dfc4fc7417617169d2483d62e5d27d3dd6a12235 | https://github.com/LasseHaslev/image-handler/blob/dfc4fc7417617169d2483d62e5d27d3dd6a12235/src/Handlers/CropHandler.php#L171-L189 | train |
zerospam/sdk-framework | src/Config/OAuthConfiguration.php | OAuthConfiguration.getProvider | public function getProvider(): AbstractProvider
{
$class = $this->providerClass();
return new $class([
'clientId' => $this->clientId,
'clientSecret' => $this->clientSecret,
'redirectUri' => $this->redirectUrl,
]);
} | php | public function getProvider(): AbstractProvider
{
$class = $this->providerClass();
return new $class([
'clientId' => $this->clientId,
'clientSecret' => $this->clientSecret,
'redirectUri' => $this->redirectUrl,
]);
} | [
"public",
"function",
"getProvider",
"(",
")",
":",
"AbstractProvider",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"providerClass",
"(",
")",
";",
"return",
"new",
"$",
"class",
"(",
"[",
"'clientId'",
"=>",
"$",
"this",
"->",
"clientId",
",",
"'clientSe... | Get a OAuthProvider.
@return AbstractProvider | [
"Get",
"a",
"OAuthProvider",
"."
] | 6780b81584619cb177d5d5e14fd7e87a9d8e48fd | https://github.com/zerospam/sdk-framework/blob/6780b81584619cb177d5d5e14fd7e87a9d8e48fd/src/Config/OAuthConfiguration.php#L93-L102 | train |
face-orm/face | lib/Face/Sql/Query/QueryString.php | QueryString.bindIn | public function bindIn($token, $array)
{
$bindString = "";
foreach ($array as $value) {
$bindString .= ',:fautoIn' . ++$this->whereInCount;
$this->bindValue(':fautoIn' . $this->whereInCount, $value);
}
// TODO saffer replace
$this->sqlString = str_replace($token, ltrim($bindString, ","), $this->sqlString);
return $this;
} | php | public function bindIn($token, $array)
{
$bindString = "";
foreach ($array as $value) {
$bindString .= ',:fautoIn' . ++$this->whereInCount;
$this->bindValue(':fautoIn' . $this->whereInCount, $value);
}
// TODO saffer replace
$this->sqlString = str_replace($token, ltrim($bindString, ","), $this->sqlString);
return $this;
} | [
"public",
"function",
"bindIn",
"(",
"$",
"token",
",",
"$",
"array",
")",
"{",
"$",
"bindString",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"value",
")",
"{",
"$",
"bindString",
".=",
"',:fautoIn'",
".",
"++",
"$",
"this",
"->",
"... | binds an array of value.
Intended to be used in such a case :
<pre>
WHERE something IN (::in::)
</pre>
then ->bindIn("::in::",$arrayOfValues)
@param $token string the bound token
@param $array array list of values to bind
@return $this QueryString | [
"binds",
"an",
"array",
"of",
"value",
"."
] | 85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428 | https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Sql/Query/QueryString.php#L69-L82 | train |
Trellmor/php-framework | Application/Crypto/Utils.php | Utils.compareStr | public static function compareStr($str1, $str2) {
$len1 = static::binaryStrlen($str1);
$len2 = static::binaryStrlen($str2);
$len = min($len1, $len2);
$diff = $len1 ^ $len2;
for ($i = 0; $i < $len; $i++) {
$diff |= ord($str1[$i]) ^ ord($str2[$i]);
}
return $diff === 0;
} | php | public static function compareStr($str1, $str2) {
$len1 = static::binaryStrlen($str1);
$len2 = static::binaryStrlen($str2);
$len = min($len1, $len2);
$diff = $len1 ^ $len2;
for ($i = 0; $i < $len; $i++) {
$diff |= ord($str1[$i]) ^ ord($str2[$i]);
}
return $diff === 0;
} | [
"public",
"static",
"function",
"compareStr",
"(",
"$",
"str1",
",",
"$",
"str2",
")",
"{",
"$",
"len1",
"=",
"static",
"::",
"binaryStrlen",
"(",
"$",
"str1",
")",
";",
"$",
"len2",
"=",
"static",
"::",
"binaryStrlen",
"(",
"$",
"str2",
")",
";",
... | Constant time string comparison
@param string $str1
@param string $str2
@return True if strings are equal | [
"Constant",
"time",
"string",
"comparison"
] | 5fda0dd52e0bc3ac4e0ed3b26125739904b2201e | https://github.com/Trellmor/php-framework/blob/5fda0dd52e0bc3ac4e0ed3b26125739904b2201e/Application/Crypto/Utils.php#L33-L44 | train |
Sowapps/orpheus-webtools | src/File/UploadedFile.php | UploadedFile.validate | public function validate() {
if( $this->error ) {
switch( $this->error ) {
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE: {
throw new UserException('fileTooBig');
break;
}
case UPLOAD_ERR_PARTIAL:
case UPLOAD_ERR_NO_FILE: {
throw new UserException('transfertIssue');
break;
}
default: {
// UPLOAD_ERR_NO_TMP_DIR UPLOAD_ERR_CANT_WRITE UPLOAD_ERR_EXTENSION
// http://php.net/manual/fr/features.file-upload.errors.php
log_error("Server upload error (error={$this->error}, name={$this->fileName})", 'Uploading file', false);
throw new UserException('serverIssue');
}
}
}
if( $this->expectedType !== NULL ) {
if( $this->getType() !== $this->expectedType ) {
throw new UserException('invalidType');
}
}
if( $this->allowedExtensions !== NULL ) {
$ext = $this->getExtension();
if( $ext === $this->allowedExtensions || (is_array($this->allowedExtensions) && !in_array($ext, $this->allowedExtensions)) ) {
throw new UserException('invalidExtension');
}
}
if( $this->allowedMimeTypes !== NULL) {
$mt = $this->getMIMEType();
if( $mt === $this->allowedMimeTypes || (is_array($this->allowedMimeTypes) && !in_array($mt, $this->allowedMimeTypes)) ) {
throw new UserException('invalidMimeType');
}
}
} | php | public function validate() {
if( $this->error ) {
switch( $this->error ) {
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE: {
throw new UserException('fileTooBig');
break;
}
case UPLOAD_ERR_PARTIAL:
case UPLOAD_ERR_NO_FILE: {
throw new UserException('transfertIssue');
break;
}
default: {
// UPLOAD_ERR_NO_TMP_DIR UPLOAD_ERR_CANT_WRITE UPLOAD_ERR_EXTENSION
// http://php.net/manual/fr/features.file-upload.errors.php
log_error("Server upload error (error={$this->error}, name={$this->fileName})", 'Uploading file', false);
throw new UserException('serverIssue');
}
}
}
if( $this->expectedType !== NULL ) {
if( $this->getType() !== $this->expectedType ) {
throw new UserException('invalidType');
}
}
if( $this->allowedExtensions !== NULL ) {
$ext = $this->getExtension();
if( $ext === $this->allowedExtensions || (is_array($this->allowedExtensions) && !in_array($ext, $this->allowedExtensions)) ) {
throw new UserException('invalidExtension');
}
}
if( $this->allowedMimeTypes !== NULL) {
$mt = $this->getMIMEType();
if( $mt === $this->allowedMimeTypes || (is_array($this->allowedMimeTypes) && !in_array($mt, $this->allowedMimeTypes)) ) {
throw new UserException('invalidMimeType');
}
}
} | [
"public",
"function",
"validate",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"error",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"error",
")",
"{",
"case",
"UPLOAD_ERR_INI_SIZE",
":",
"case",
"UPLOAD_ERR_FORM_SIZE",
":",
"{",
"throw",
"new",
"UserExce... | Validate the input file is respecting upload restrictions
@throws UserException
This function throws exception in case of error | [
"Validate",
"the",
"input",
"file",
"is",
"respecting",
"upload",
"restrictions"
] | 653682fcff6327a29c2b3ecbc796fae49e7c03ba | https://github.com/Sowapps/orpheus-webtools/blob/653682fcff6327a29c2b3ecbc796fae49e7c03ba/src/File/UploadedFile.php#L182-L221 | train |
Sowapps/orpheus-webtools | src/File/UploadedFile.php | UploadedFile.loadPath | protected static function loadPath($from, &$files=array(), $path='') {
$fileName = ($path === '') ? $from['name'] : apath_get($from['name'], $path);
// debug('LoadPath('.$path.') - $fileName', $fileName);
if( empty($fileName) ) { return $files; }
if( is_array($fileName) ) {
if( $path!=='' ) { $path .= '/'; }
foreach( $fileName as $index => $fn ) {
static::loadPath($from, $files, $path.$index);
}
// debug('loadPath() Files if name is an array', $files);
return $files;
}
apath_setp($files, $path, new static($fileName, apath_get($from, 'size/'.$path),
apath_get($from, 'tmp_name/'.$path), apath_get($from, 'error/'.$path)));
// debug('loadPath() Files if value is set', $files);
return $files;
// $files[] = ;
} | php | protected static function loadPath($from, &$files=array(), $path='') {
$fileName = ($path === '') ? $from['name'] : apath_get($from['name'], $path);
// debug('LoadPath('.$path.') - $fileName', $fileName);
if( empty($fileName) ) { return $files; }
if( is_array($fileName) ) {
if( $path!=='' ) { $path .= '/'; }
foreach( $fileName as $index => $fn ) {
static::loadPath($from, $files, $path.$index);
}
// debug('loadPath() Files if name is an array', $files);
return $files;
}
apath_setp($files, $path, new static($fileName, apath_get($from, 'size/'.$path),
apath_get($from, 'tmp_name/'.$path), apath_get($from, 'error/'.$path)));
// debug('loadPath() Files if value is set', $files);
return $files;
// $files[] = ;
} | [
"protected",
"static",
"function",
"loadPath",
"(",
"$",
"from",
",",
"&",
"$",
"files",
"=",
"array",
"(",
")",
",",
"$",
"path",
"=",
"''",
")",
"{",
"$",
"fileName",
"=",
"(",
"$",
"path",
"===",
"''",
")",
"?",
"$",
"from",
"[",
"'name'",
"... | Get uploaded file from path
@param array $from
@param array $files
@param string $path
@return UploadedFile | [
"Get",
"uploaded",
"file",
"from",
"path"
] | 653682fcff6327a29c2b3ecbc796fae49e7c03ba | https://github.com/Sowapps/orpheus-webtools/blob/653682fcff6327a29c2b3ecbc796fae49e7c03ba/src/File/UploadedFile.php#L231-L248 | train |
chipaau/support | src/Support/Validation/Validator.php | Validator.addIteratedValidationMessages | protected function addIteratedValidationMessages($attribute, $messages = [])
{
foreach ($messages as $field => $message) {
$field_name = $attribute.$field;
$messages[$field_name] = $message;
}
$this->setCustomMessages($messages);
} | php | protected function addIteratedValidationMessages($attribute, $messages = [])
{
foreach ($messages as $field => $message) {
$field_name = $attribute.$field;
$messages[$field_name] = $message;
}
$this->setCustomMessages($messages);
} | [
"protected",
"function",
"addIteratedValidationMessages",
"(",
"$",
"attribute",
",",
"$",
"messages",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"field",
"=>",
"$",
"message",
")",
"{",
"$",
"field_name",
"=",
"$",
"attribute",
... | Add any custom messages for this ruleSet to the validator
@param $attribute
@param array $messages
@return void | [
"Add",
"any",
"custom",
"messages",
"for",
"this",
"ruleSet",
"to",
"the",
"validator"
] | 2fe3673ed2330bd064d37b2f0bac3e02ca110bef | https://github.com/chipaau/support/blob/2fe3673ed2330bd064d37b2f0bac3e02ca110bef/src/Support/Validation/Validator.php#L73-L80 | train |
edvinaskrucas/counter | src/Krucas/Counter/ArrayRepository.php | ArrayRepository.setFor | public function setFor($key, \DateTime $date, $value)
{
$this->data[$this->keyFor($key, $date)] = $value;
} | php | public function setFor($key, \DateTime $date, $value)
{
$this->data[$this->keyFor($key, $date)] = $value;
} | [
"public",
"function",
"setFor",
"(",
"$",
"key",
",",
"\\",
"DateTime",
"$",
"date",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"this",
"->",
"keyFor",
"(",
"$",
"key",
",",
"$",
"date",
")",
"]",
"=",
"$",
"value",
";",
... | Set value for a key for a given date.
@param string $key Counter key.
@param \DateTime $date Date.
@param float|int $value Value to set.
@return void | [
"Set",
"value",
"for",
"a",
"key",
"for",
"a",
"given",
"date",
"."
] | cf61963b9f90e2801d89f797f73e53edcc67cc19 | https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/ArrayRepository.php#L34-L37 | train |
edvinaskrucas/counter | src/Krucas/Counter/ArrayRepository.php | ArrayRepository.setForRange | public function setForRange($key, \DateTime $start, \DateTime $end, $value)
{
$this->data[$this->keyForRange($key, $start, $end)] = $value;
} | php | public function setForRange($key, \DateTime $start, \DateTime $end, $value)
{
$this->data[$this->keyForRange($key, $start, $end)] = $value;
} | [
"public",
"function",
"setForRange",
"(",
"$",
"key",
",",
"\\",
"DateTime",
"$",
"start",
",",
"\\",
"DateTime",
"$",
"end",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"this",
"->",
"keyForRange",
"(",
"$",
"key",
",",
"$",
... | Set value for a key for a given date range.
@param string $key Counter key.
@param \DateTime $start Start date.
@param \DateTime $end End date.
@param float|int $value Value to set.
@return void | [
"Set",
"value",
"for",
"a",
"key",
"for",
"a",
"given",
"date",
"range",
"."
] | cf61963b9f90e2801d89f797f73e53edcc67cc19 | https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/ArrayRepository.php#L48-L51 | train |
edvinaskrucas/counter | src/Krucas/Counter/ArrayRepository.php | ArrayRepository.getFor | public function getFor($key, \DateTime $date)
{
if (!$this->hasFor($key, $date)) {
return null;
}
return $this->data[$this->keyFor($key, $date)];
} | php | public function getFor($key, \DateTime $date)
{
if (!$this->hasFor($key, $date)) {
return null;
}
return $this->data[$this->keyFor($key, $date)];
} | [
"public",
"function",
"getFor",
"(",
"$",
"key",
",",
"\\",
"DateTime",
"$",
"date",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasFor",
"(",
"$",
"key",
",",
"$",
"date",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->... | Get value for a key for a given date.
@param string $key Counter key.
@param \DateTime $date Date.
@return float|int|null | [
"Get",
"value",
"for",
"a",
"key",
"for",
"a",
"given",
"date",
"."
] | cf61963b9f90e2801d89f797f73e53edcc67cc19 | https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/ArrayRepository.php#L75-L82 | train |
edvinaskrucas/counter | src/Krucas/Counter/ArrayRepository.php | ArrayRepository.getForRange | public function getForRange($key, \DateTime $start, \DateTime $end)
{
if (!$this->hasForRange($key, $start, $end)) {
return null;
}
return $this->data[$this->keyForRange($key, $start, $end)];
} | php | public function getForRange($key, \DateTime $start, \DateTime $end)
{
if (!$this->hasForRange($key, $start, $end)) {
return null;
}
return $this->data[$this->keyForRange($key, $start, $end)];
} | [
"public",
"function",
"getForRange",
"(",
"$",
"key",
",",
"\\",
"DateTime",
"$",
"start",
",",
"\\",
"DateTime",
"$",
"end",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasForRange",
"(",
"$",
"key",
",",
"$",
"start",
",",
"$",
"end",
")",
")... | Get value for a key for a given date range.
@param string $key Counter key.
@param \DateTime $start Start date.
@param \DateTime $end End date.
@return float|int|null | [
"Get",
"value",
"for",
"a",
"key",
"for",
"a",
"given",
"date",
"range",
"."
] | cf61963b9f90e2801d89f797f73e53edcc67cc19 | https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/ArrayRepository.php#L92-L99 | train |
edvinaskrucas/counter | src/Krucas/Counter/ArrayRepository.php | ArrayRepository.hasFor | public function hasFor($key, \DateTime $date)
{
return array_key_exists($this->keyFor($key, $date), $this->data);
} | php | public function hasFor($key, \DateTime $date)
{
return array_key_exists($this->keyFor($key, $date), $this->data);
} | [
"public",
"function",
"hasFor",
"(",
"$",
"key",
",",
"\\",
"DateTime",
"$",
"date",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"this",
"->",
"keyFor",
"(",
"$",
"key",
",",
"$",
"date",
")",
",",
"$",
"this",
"->",
"data",
")",
";",
"}"
] | Determine if value exists for a given date.
@param string $key Counter key.
@param \DateTime $date Date.
@return bool | [
"Determine",
"if",
"value",
"exists",
"for",
"a",
"given",
"date",
"."
] | cf61963b9f90e2801d89f797f73e53edcc67cc19 | https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/ArrayRepository.php#L119-L122 | train |
edvinaskrucas/counter | src/Krucas/Counter/ArrayRepository.php | ArrayRepository.hasForRange | public function hasForRange($key, \DateTime $start, \DateTime $end)
{
return array_key_exists($this->keyForRange($key, $start, $end), $this->data);
} | php | public function hasForRange($key, \DateTime $start, \DateTime $end)
{
return array_key_exists($this->keyForRange($key, $start, $end), $this->data);
} | [
"public",
"function",
"hasForRange",
"(",
"$",
"key",
",",
"\\",
"DateTime",
"$",
"start",
",",
"\\",
"DateTime",
"$",
"end",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"this",
"->",
"keyForRange",
"(",
"$",
"key",
",",
"$",
"start",
",",
"$",
... | Determine if value exists for a given date range.
@param string $key Counter key.
@param \DateTime $start Start date.
@param \DateTime $end End date.
@return bool | [
"Determine",
"if",
"value",
"exists",
"for",
"a",
"given",
"date",
"range",
"."
] | cf61963b9f90e2801d89f797f73e53edcc67cc19 | https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/ArrayRepository.php#L132-L135 | train |
edvinaskrucas/counter | src/Krucas/Counter/ArrayRepository.php | ArrayRepository.keyForRange | protected function keyForRange($key, \DateTime $start, \DateTime $end)
{
return 'range:' . $key . '_' . $this->dateString($start) . '_' . $this->dateString($end);
} | php | protected function keyForRange($key, \DateTime $start, \DateTime $end)
{
return 'range:' . $key . '_' . $this->dateString($start) . '_' . $this->dateString($end);
} | [
"protected",
"function",
"keyForRange",
"(",
"$",
"key",
",",
"\\",
"DateTime",
"$",
"start",
",",
"\\",
"DateTime",
"$",
"end",
")",
"{",
"return",
"'range:'",
".",
"$",
"key",
".",
"'_'",
".",
"$",
"this",
"->",
"dateString",
"(",
"$",
"start",
")"... | Generate key for key and date range.
@param string $key Counter key.
@param \DateTime $start Start date.
@param \DateTime $end End date.
@return string | [
"Generate",
"key",
"for",
"key",
"and",
"date",
"range",
"."
] | cf61963b9f90e2801d89f797f73e53edcc67cc19 | https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/ArrayRepository.php#L258-L261 | train |
edvinaskrucas/counter | src/Krucas/Counter/ArrayRepository.php | ArrayRepository.removeFor | public function removeFor($key, \DateTime $date)
{
unset($this->data[$this->keyFor($key, $date)]);
} | php | public function removeFor($key, \DateTime $date)
{
unset($this->data[$this->keyFor($key, $date)]);
} | [
"public",
"function",
"removeFor",
"(",
"$",
"key",
",",
"\\",
"DateTime",
"$",
"date",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"this",
"->",
"keyFor",
"(",
"$",
"key",
",",
"$",
"date",
")",
"]",
")",
";",
"}"
] | Remove value for a key for a given date.
@param string $key Counter key.
@param \DateTime $date Date.
@return void | [
"Remove",
"value",
"for",
"a",
"key",
"for",
"a",
"given",
"date",
"."
] | cf61963b9f90e2801d89f797f73e53edcc67cc19 | https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/ArrayRepository.php#L292-L295 | train |
edvinaskrucas/counter | src/Krucas/Counter/ArrayRepository.php | ArrayRepository.removeForRange | public function removeForRange($key, \DateTime $start, \DateTime $end)
{
unset($this->data[$this->keyForRange($key, $start, $end)]);
} | php | public function removeForRange($key, \DateTime $start, \DateTime $end)
{
unset($this->data[$this->keyForRange($key, $start, $end)]);
} | [
"public",
"function",
"removeForRange",
"(",
"$",
"key",
",",
"\\",
"DateTime",
"$",
"start",
",",
"\\",
"DateTime",
"$",
"end",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"this",
"->",
"keyForRange",
"(",
"$",
"key",
",",
"$",
"s... | Remove value for a key for a given date range.
@param string $key Counter key.
@param \DateTime $start Start date.
@param \DateTime $end End date.
@return void | [
"Remove",
"value",
"for",
"a",
"key",
"for",
"a",
"given",
"date",
"range",
"."
] | cf61963b9f90e2801d89f797f73e53edcc67cc19 | https://github.com/edvinaskrucas/counter/blob/cf61963b9f90e2801d89f797f73e53edcc67cc19/src/Krucas/Counter/ArrayRepository.php#L305-L308 | train |
phossa2/libs | src/Phossa2/Di/Factory/FactoryHelperTrait.php | FactoryHelperTrait.isTypeMatched | protected function isTypeMatched($class, array $arguments)/*# : bool */
{
if (empty($arguments)) {
return false;
} elseif (null !== $class) {
return is_a($arguments[0], $class->getName());
} else {
return true;
}
} | php | protected function isTypeMatched($class, array $arguments)/*# : bool */
{
if (empty($arguments)) {
return false;
} elseif (null !== $class) {
return is_a($arguments[0], $class->getName());
} else {
return true;
}
} | [
"protected",
"function",
"isTypeMatched",
"(",
"$",
"class",
",",
"array",
"$",
"arguments",
")",
"/*# : bool */",
"{",
"if",
"(",
"empty",
"(",
"$",
"arguments",
")",
")",
"{",
"return",
"false",
";",
"}",
"elseif",
"(",
"null",
"!==",
"$",
"class",
"... | Try best to guess parameter and argument are the same type
@param null|\ReflectionClass $class
@param array $arguments
@return bool
@access protected | [
"Try",
"best",
"to",
"guess",
"parameter",
"and",
"argument",
"are",
"the",
"same",
"type"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Factory/FactoryHelperTrait.php#L126-L135 | train |
phossa2/libs | src/Phossa2/Di/Factory/FactoryHelperTrait.php | FactoryHelperTrait.getCallableParameters | protected function getCallableParameters(callable $callable)/*# : array */
{
// array type
if (is_array($callable)) {
$reflector = new \ReflectionClass($callable[0]);
$method = $reflector->getMethod($callable[1]);
// object with __invoke() defined
} elseif ($this->isInvocable($callable)) {
$reflector = new \ReflectionClass($callable);
$method = $reflector->getMethod('__invoke');
// simple function
} else {
$method = new \ReflectionFunction($callable);
}
return $method->getParameters();
} | php | protected function getCallableParameters(callable $callable)/*# : array */
{
// array type
if (is_array($callable)) {
$reflector = new \ReflectionClass($callable[0]);
$method = $reflector->getMethod($callable[1]);
// object with __invoke() defined
} elseif ($this->isInvocable($callable)) {
$reflector = new \ReflectionClass($callable);
$method = $reflector->getMethod('__invoke');
// simple function
} else {
$method = new \ReflectionFunction($callable);
}
return $method->getParameters();
} | [
"protected",
"function",
"getCallableParameters",
"(",
"callable",
"$",
"callable",
")",
"/*# : array */",
"{",
"// array type",
"if",
"(",
"is_array",
"(",
"$",
"callable",
")",
")",
"{",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"calla... | Get callable parameters
@param callable $callable
@return \ReflectionParameter[]
@throws LogicException if something goes wrong
@access protected | [
"Get",
"callable",
"parameters"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Factory/FactoryHelperTrait.php#L166-L184 | train |
phossa2/libs | src/Phossa2/Di/Factory/FactoryHelperTrait.php | FactoryHelperTrait.getObjectByClass | protected function getObjectByClass(/*# string */ $classname)
{
if ($this->getResolver()->hasService($classname)) {
$serviceId = ObjectResolver::getServiceId($classname);
return $this->getResolver()->get($serviceId);
}
throw new LogicException(
Message::get(Message::DI_CLASS_UNKNOWN, $classname),
Message::DI_CLASS_UNKNOWN
);
} | php | protected function getObjectByClass(/*# string */ $classname)
{
if ($this->getResolver()->hasService($classname)) {
$serviceId = ObjectResolver::getServiceId($classname);
return $this->getResolver()->get($serviceId);
}
throw new LogicException(
Message::get(Message::DI_CLASS_UNKNOWN, $classname),
Message::DI_CLASS_UNKNOWN
);
} | [
"protected",
"function",
"getObjectByClass",
"(",
"/*# string */",
"$",
"classname",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getResolver",
"(",
")",
"->",
"hasService",
"(",
"$",
"classname",
")",
")",
"{",
"$",
"serviceId",
"=",
"ObjectResolver",
"::",
"... | Get an object base on provided classname or interface name
@param string $classname class or interface name
@return object
@throws \Exception if something goes wrong
@access protected | [
"Get",
"an",
"object",
"base",
"on",
"provided",
"classname",
"or",
"interface",
"name"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Factory/FactoryHelperTrait.php#L208-L218 | train |
phossa2/libs | src/Phossa2/Di/Factory/FactoryHelperTrait.php | FactoryHelperTrait.mergeMethods | protected function mergeMethods($nodeData)/*# : array */
{
// no merge
if (empty($nodeData) || isset($nodeData[0])) {
return (array) $nodeData;
}
// in sections
$result = [];
foreach ($nodeData as $data) {
$result = array_merge($result, $data);
}
return $result;
} | php | protected function mergeMethods($nodeData)/*# : array */
{
// no merge
if (empty($nodeData) || isset($nodeData[0])) {
return (array) $nodeData;
}
// in sections
$result = [];
foreach ($nodeData as $data) {
$result = array_merge($result, $data);
}
return $result;
} | [
"protected",
"function",
"mergeMethods",
"(",
"$",
"nodeData",
")",
"/*# : array */",
"{",
"// no merge",
"if",
"(",
"empty",
"(",
"$",
"nodeData",
")",
"||",
"isset",
"(",
"$",
"nodeData",
"[",
"0",
"]",
")",
")",
"{",
"return",
"(",
"array",
")",
"$"... | Merge different sections of a node
convert
`['section1' => [[1], [2]], 'section2' => [[3], [4]]]`
to
`[[1], [2], [3], [4]]`
@param array|null $nodeData
@return array
@access protected | [
"Merge",
"different",
"sections",
"of",
"a",
"node"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Factory/FactoryHelperTrait.php#L255-L268 | train |
phossa2/libs | src/Phossa2/Di/Factory/FactoryHelperTrait.php | FactoryHelperTrait.getCommonMethods | protected function getCommonMethods()/*# : array */
{
// di.common node
$commNode = $this->getResolver()->getSectionId('', 'common');
return $this->mergeMethods(
$this->getResolver()->get($commNode)
);
} | php | protected function getCommonMethods()/*# : array */
{
// di.common node
$commNode = $this->getResolver()->getSectionId('', 'common');
return $this->mergeMethods(
$this->getResolver()->get($commNode)
);
} | [
"protected",
"function",
"getCommonMethods",
"(",
")",
"/*# : array */",
"{",
"// di.common node",
"$",
"commNode",
"=",
"$",
"this",
"->",
"getResolver",
"(",
")",
"->",
"getSectionId",
"(",
"''",
",",
"'common'",
")",
";",
"return",
"$",
"this",
"->",
"mer... | Get common methods
@return array
@access protected | [
"Get",
"common",
"methods"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Di/Factory/FactoryHelperTrait.php#L276-L284 | train |
martinhej/robocloud | src/robocloud/Consumer/Kinesis/Consumer.php | Consumer.getMessages | protected function getMessages($shard_id = NULL, $last_sequence_number = NULL): array
{
$records = [];
// Get the initial iterator.
try {
$shard_iterator = $this->getInitialShardIterator($shard_id, $last_sequence_number);
} catch (\Exception $e) {
$this->processError($e, [
'shard_id' => $shard_id,
'last_sequence_number' => $last_sequence_number,
]);
return $records;
}
do {
$has_records = FALSE;
// Load batch of records.
try {
$res = $this->getClient()->getRecords([
'Limit' => $this->batchSize,
'ShardIterator' => $shard_iterator,
'StreamName' => $this->getStreamName(),
]);
// Get the Shard iterator for next batch.
$shard_iterator = $res->get('NextShardIterator');
$behind_latest = $res->get('MillisBehindLatest');
foreach ($res->search('Records[].[SequenceNumber, Data]') as $event) {
list($sequence_number, $message_data) = $event;
try {
$records[$sequence_number] = $this->getMessageFactory()->unserialize($message_data);
} catch (\Exception $e) {
$this->processError($e, $event);
}
$has_records = TRUE;
}
} catch (\Exception $e) {
$this->processError($e);
}
} while (!empty($shard_iterator) && !empty($behind_latest) && !$has_records);
if (!empty($sequence_number)) {
$this->lastSequenceNumber = $sequence_number;
}
if (!empty($behind_latest)) {
$this->lag = $behind_latest;
}
return $records;
} | php | protected function getMessages($shard_id = NULL, $last_sequence_number = NULL): array
{
$records = [];
// Get the initial iterator.
try {
$shard_iterator = $this->getInitialShardIterator($shard_id, $last_sequence_number);
} catch (\Exception $e) {
$this->processError($e, [
'shard_id' => $shard_id,
'last_sequence_number' => $last_sequence_number,
]);
return $records;
}
do {
$has_records = FALSE;
// Load batch of records.
try {
$res = $this->getClient()->getRecords([
'Limit' => $this->batchSize,
'ShardIterator' => $shard_iterator,
'StreamName' => $this->getStreamName(),
]);
// Get the Shard iterator for next batch.
$shard_iterator = $res->get('NextShardIterator');
$behind_latest = $res->get('MillisBehindLatest');
foreach ($res->search('Records[].[SequenceNumber, Data]') as $event) {
list($sequence_number, $message_data) = $event;
try {
$records[$sequence_number] = $this->getMessageFactory()->unserialize($message_data);
} catch (\Exception $e) {
$this->processError($e, $event);
}
$has_records = TRUE;
}
} catch (\Exception $e) {
$this->processError($e);
}
} while (!empty($shard_iterator) && !empty($behind_latest) && !$has_records);
if (!empty($sequence_number)) {
$this->lastSequenceNumber = $sequence_number;
}
if (!empty($behind_latest)) {
$this->lag = $behind_latest;
}
return $records;
} | [
"protected",
"function",
"getMessages",
"(",
"$",
"shard_id",
"=",
"NULL",
",",
"$",
"last_sequence_number",
"=",
"NULL",
")",
":",
"array",
"{",
"$",
"records",
"=",
"[",
"]",
";",
"// Get the initial iterator.",
"try",
"{",
"$",
"shard_iterator",
"=",
"$",... | Do a single call to a Kinesis stream to get messages.
@param string $shard_id
The shard id from which to start reading.
@param string $last_sequence_number
The last record sequence number the last call of getRecords() ended. The
value will be provided by a subsequent call of getLastSequenceNumber().
@return \robocloud\Message\MessageInterface[]
The messages. | [
"Do",
"a",
"single",
"call",
"to",
"a",
"Kinesis",
"stream",
"to",
"get",
"messages",
"."
] | 108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229 | https://github.com/martinhej/robocloud/blob/108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229/src/robocloud/Consumer/Kinesis/Consumer.php#L155-L214 | train |
martinhej/robocloud | src/robocloud/Consumer/Kinesis/Consumer.php | Consumer.getInitialShardIterator | protected function getInitialShardIterator($shard_id, $starting_sequence_number = NULL)
{
$args = [
'ShardId' => $shard_id,
'StreamName' => $this->getStreamName(),
'ShardIteratorType' => $this->initialShardIteratorType,
];
// If we have the starting sequence number update also the ShardIteratorType
// to start reading just after it.
if (!empty($starting_sequence_number)) {
$args['ShardIteratorType'] = self::ITERATOR_TYPE_AFTER_SEQUENCE_NUMBER;
$args['StartingSequenceNumber'] = $starting_sequence_number;
}
$res = $this->getClient()->getShardIterator($args);
return $res->get('ShardIterator');
} | php | protected function getInitialShardIterator($shard_id, $starting_sequence_number = NULL)
{
$args = [
'ShardId' => $shard_id,
'StreamName' => $this->getStreamName(),
'ShardIteratorType' => $this->initialShardIteratorType,
];
// If we have the starting sequence number update also the ShardIteratorType
// to start reading just after it.
if (!empty($starting_sequence_number)) {
$args['ShardIteratorType'] = self::ITERATOR_TYPE_AFTER_SEQUENCE_NUMBER;
$args['StartingSequenceNumber'] = $starting_sequence_number;
}
$res = $this->getClient()->getShardIterator($args);
return $res->get('ShardIterator');
} | [
"protected",
"function",
"getInitialShardIterator",
"(",
"$",
"shard_id",
",",
"$",
"starting_sequence_number",
"=",
"NULL",
")",
"{",
"$",
"args",
"=",
"[",
"'ShardId'",
"=>",
"$",
"shard_id",
",",
"'StreamName'",
"=>",
"$",
"this",
"->",
"getStreamName",
"("... | Gets the initial shard iterator.
@param string $shard_id
The shard id.
@param string $starting_sequence_number
The starting sequence number.
@return object
The shard iterator. | [
"Gets",
"the",
"initial",
"shard",
"iterator",
"."
] | 108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229 | https://github.com/martinhej/robocloud/blob/108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229/src/robocloud/Consumer/Kinesis/Consumer.php#L246-L265 | train |
martinhej/robocloud | src/robocloud/Consumer/Kinesis/Consumer.php | Consumer.getShardIds | protected function getShardIds(): array
{
$key = $this->getStreamName() . '.shard_ids';
if ($this->cache->has($key)) {
return $this->cache->get($key);
}
$res = $this->getClient()->describeStream(['StreamName' => $this->getStreamName()]);
$shard_ids = $res->search('StreamDescription.Shards[].ShardId');
// Cache shard_ids for a day as overuse of the describeStream
// resource results in LimitExceededException error.
$this->cache->set($key, $shard_ids, 86400);
return $shard_ids;
} | php | protected function getShardIds(): array
{
$key = $this->getStreamName() . '.shard_ids';
if ($this->cache->has($key)) {
return $this->cache->get($key);
}
$res = $this->getClient()->describeStream(['StreamName' => $this->getStreamName()]);
$shard_ids = $res->search('StreamDescription.Shards[].ShardId');
// Cache shard_ids for a day as overuse of the describeStream
// resource results in LimitExceededException error.
$this->cache->set($key, $shard_ids, 86400);
return $shard_ids;
} | [
"protected",
"function",
"getShardIds",
"(",
")",
":",
"array",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getStreamName",
"(",
")",
".",
"'.shard_ids'",
";",
"if",
"(",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"retur... | Gets shard ids.
@return int[]
List of shard ids within the stream. | [
"Gets",
"shard",
"ids",
"."
] | 108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229 | https://github.com/martinhej/robocloud/blob/108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229/src/robocloud/Consumer/Kinesis/Consumer.php#L290-L305 | train |
rinvex/obsolete-taggable | src/Taggable.php | Taggable.bootTaggable | public static function bootTaggable()
{
static::created(function (Model $taggableModel) {
if ($taggableModel->queuedTags) {
$taggableModel->tag($taggableModel->queuedTags);
$taggableModel->queuedTags = [];
}
});
static::deleted(function (Model $taggableModel) {
$taggableModel->tags()->detach();
});
} | php | public static function bootTaggable()
{
static::created(function (Model $taggableModel) {
if ($taggableModel->queuedTags) {
$taggableModel->tag($taggableModel->queuedTags);
$taggableModel->queuedTags = [];
}
});
static::deleted(function (Model $taggableModel) {
$taggableModel->tags()->detach();
});
} | [
"public",
"static",
"function",
"bootTaggable",
"(",
")",
"{",
"static",
"::",
"created",
"(",
"function",
"(",
"Model",
"$",
"taggableModel",
")",
"{",
"if",
"(",
"$",
"taggableModel",
"->",
"queuedTags",
")",
"{",
"$",
"taggableModel",
"->",
"tag",
"(",
... | Boot the taggable trait for a model.
@return void | [
"Boot",
"the",
"taggable",
"trait",
"for",
"a",
"model",
"."
] | 661ae32b70e0721db9e20438eb2ff4f1d2308005 | https://github.com/rinvex/obsolete-taggable/blob/661ae32b70e0721db9e20438eb2ff4f1d2308005/src/Taggable.php#L106-L119 | train |
rinvex/obsolete-taggable | src/Taggable.php | Taggable.tagsWithGroup | public function tagsWithGroup(string $group = null): Collection
{
return $this->tags->filter(function (Tag $tag) use ($group) {
return $tag->group === $group;
});
} | php | public function tagsWithGroup(string $group = null): Collection
{
return $this->tags->filter(function (Tag $tag) use ($group) {
return $tag->group === $group;
});
} | [
"public",
"function",
"tagsWithGroup",
"(",
"string",
"$",
"group",
"=",
"null",
")",
":",
"Collection",
"{",
"return",
"$",
"this",
"->",
"tags",
"->",
"filter",
"(",
"function",
"(",
"Tag",
"$",
"tag",
")",
"use",
"(",
"$",
"group",
")",
"{",
"retu... | Filter tags with group.
@param string|null $group
@return \Illuminate\Database\Eloquent\Collection | [
"Filter",
"tags",
"with",
"group",
"."
] | 661ae32b70e0721db9e20438eb2ff4f1d2308005 | https://github.com/rinvex/obsolete-taggable/blob/661ae32b70e0721db9e20438eb2ff4f1d2308005/src/Taggable.php#L140-L145 | train |
rinvex/obsolete-taggable | src/Taggable.php | Taggable.hasTag | public function hasTag($tags): bool
{
// Single tag slug
if (is_string($tags)) {
return $this->tags->contains('slug', $tags);
}
// Single tag id
if (is_int($tags)) {
return $this->tags->contains('id', $tags);
}
// Single tag model
if ($tags instanceof Tag) {
return $this->tags->contains('slug', $tags->slug);
}
// Array of tag slugs
if (is_array($tags) && isset($tags[0]) && is_string($tags[0])) {
return ! $this->tags->pluck('slug')->intersect($tags)->isEmpty();
}
// Array of tag ids
if (is_array($tags) && isset($tags[0]) && is_int($tags[0])) {
return ! $this->tags->pluck('id')->intersect($tags)->isEmpty();
}
// Collection of tag models
if ($tags instanceof Collection) {
return ! $tags->intersect($this->tags->pluck('slug'))->isEmpty();
}
return false;
} | php | public function hasTag($tags): bool
{
// Single tag slug
if (is_string($tags)) {
return $this->tags->contains('slug', $tags);
}
// Single tag id
if (is_int($tags)) {
return $this->tags->contains('id', $tags);
}
// Single tag model
if ($tags instanceof Tag) {
return $this->tags->contains('slug', $tags->slug);
}
// Array of tag slugs
if (is_array($tags) && isset($tags[0]) && is_string($tags[0])) {
return ! $this->tags->pluck('slug')->intersect($tags)->isEmpty();
}
// Array of tag ids
if (is_array($tags) && isset($tags[0]) && is_int($tags[0])) {
return ! $this->tags->pluck('id')->intersect($tags)->isEmpty();
}
// Collection of tag models
if ($tags instanceof Collection) {
return ! $tags->intersect($this->tags->pluck('slug'))->isEmpty();
}
return false;
} | [
"public",
"function",
"hasTag",
"(",
"$",
"tags",
")",
":",
"bool",
"{",
"// Single tag slug",
"if",
"(",
"is_string",
"(",
"$",
"tags",
")",
")",
"{",
"return",
"$",
"this",
"->",
"tags",
"->",
"contains",
"(",
"'slug'",
",",
"$",
"tags",
")",
";",
... | Determine if the model has any the given tags.
@param int|string|array|\ArrayAccess|\Rinvex\Taggable\Tag $tags
@return bool | [
"Determine",
"if",
"the",
"model",
"has",
"any",
"the",
"given",
"tags",
"."
] | 661ae32b70e0721db9e20438eb2ff4f1d2308005 | https://github.com/rinvex/obsolete-taggable/blob/661ae32b70e0721db9e20438eb2ff4f1d2308005/src/Taggable.php#L290-L323 | train |
rinvex/obsolete-taggable | src/Taggable.php | Taggable.prepareTags | protected function prepareTags($tags)
{
if (is_string($tags) && mb_strpos($tags, static::getTagsDelimiter()) !== false) {
$delimiter = preg_quote(static::getTagsDelimiter(), '#');
$tags = array_map('trim', preg_split("#[{$delimiter}]#", $tags, -1, PREG_SPLIT_NO_EMPTY));
}
return $tags;
} | php | protected function prepareTags($tags)
{
if (is_string($tags) && mb_strpos($tags, static::getTagsDelimiter()) !== false) {
$delimiter = preg_quote(static::getTagsDelimiter(), '#');
$tags = array_map('trim', preg_split("#[{$delimiter}]#", $tags, -1, PREG_SPLIT_NO_EMPTY));
}
return $tags;
} | [
"protected",
"function",
"prepareTags",
"(",
"$",
"tags",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"tags",
")",
"&&",
"mb_strpos",
"(",
"$",
"tags",
",",
"static",
"::",
"getTagsDelimiter",
"(",
")",
")",
"!==",
"false",
")",
"{",
"$",
"delimiter",
... | Prepare tag list.
@param int|string|array|\ArrayAccess|\Rinvex\Taggable\Tag $tags
@return mixed | [
"Prepare",
"tag",
"list",
"."
] | 661ae32b70e0721db9e20438eb2ff4f1d2308005 | https://github.com/rinvex/obsolete-taggable/blob/661ae32b70e0721db9e20438eb2ff4f1d2308005/src/Taggable.php#L388-L396 | train |
rinvex/obsolete-taggable | src/Taggable.php | Taggable.hydrateTags | protected function hydrateTags($tags, bool $createMissing = false): Collection
{
$tags = static::prepareTags($tags);
$isTagsStringBased = static::isTagsStringBased($tags);
$isTagsIntBased = static::isTagsIntBased($tags);
$field = $isTagsStringBased ? 'slug' : 'id';
$className = static::getTagClassName();
if ($isTagsStringBased && $createMissing) {
return $className::findManyByNameOrCreate($tags);
}
return $isTagsStringBased || $isTagsIntBased ? $className::query()->whereIn($field, (array) $tags)->get() : collect($tags);
} | php | protected function hydrateTags($tags, bool $createMissing = false): Collection
{
$tags = static::prepareTags($tags);
$isTagsStringBased = static::isTagsStringBased($tags);
$isTagsIntBased = static::isTagsIntBased($tags);
$field = $isTagsStringBased ? 'slug' : 'id';
$className = static::getTagClassName();
if ($isTagsStringBased && $createMissing) {
return $className::findManyByNameOrCreate($tags);
}
return $isTagsStringBased || $isTagsIntBased ? $className::query()->whereIn($field, (array) $tags)->get() : collect($tags);
} | [
"protected",
"function",
"hydrateTags",
"(",
"$",
"tags",
",",
"bool",
"$",
"createMissing",
"=",
"false",
")",
":",
"Collection",
"{",
"$",
"tags",
"=",
"static",
"::",
"prepareTags",
"(",
"$",
"tags",
")",
";",
"$",
"isTagsStringBased",
"=",
"static",
... | Hydrate tags.
@param int|string|array|\ArrayAccess|\Rinvex\Taggable\Tag $tags
@param bool $createMissing
@return \Illuminate\Support\Collection | [
"Hydrate",
"tags",
"."
] | 661ae32b70e0721db9e20438eb2ff4f1d2308005 | https://github.com/rinvex/obsolete-taggable/blob/661ae32b70e0721db9e20438eb2ff4f1d2308005/src/Taggable.php#L432-L445 | train |
thecodingmachine/utils.package-builder | src/Mouf/Utils/PackageBuilder/Export/ExportController.php | ExportController.index | public function index($instances = "", $selfedit="false") {
$this->instances = $instances;
$this->generatedCode = "";
if ($instances) {
$this->export($instances, $selfedit);
}
$this->content->addFile(dirname(__FILE__)."/../../../../views/exportForm.php", $this);
$this->template->toHtml();
} | php | public function index($instances = "", $selfedit="false") {
$this->instances = $instances;
$this->generatedCode = "";
if ($instances) {
$this->export($instances, $selfedit);
}
$this->content->addFile(dirname(__FILE__)."/../../../../views/exportForm.php", $this);
$this->template->toHtml();
} | [
"public",
"function",
"index",
"(",
"$",
"instances",
"=",
"\"\"",
",",
"$",
"selfedit",
"=",
"\"false\"",
")",
"{",
"$",
"this",
"->",
"instances",
"=",
"$",
"instances",
";",
"$",
"this",
"->",
"generatedCode",
"=",
"\"\"",
";",
"if",
"(",
"$",
"in... | Admin page used to export instances.
@Action | [
"Admin",
"page",
"used",
"to",
"export",
"instances",
"."
] | 14a82a1a0e0fda503e6152d65900623cd73f6202 | https://github.com/thecodingmachine/utils.package-builder/blob/14a82a1a0e0fda503e6152d65900623cd73f6202/src/Mouf/Utils/PackageBuilder/Export/ExportController.php#L37-L46 | train |
thecodingmachine/utils.package-builder | src/Mouf/Utils/PackageBuilder/Export/ExportController.php | ExportController.export | public function export($instances, $selfedit="false") {
if ($selfedit == "true") {
$moufManager = MoufManager::getMoufManager();
} else {
$moufManager = MoufManager::getMoufManagerHiddenInstance();
}
$instancesList = explode("\n", $instances);
$cleaninstancesList = array();
foreach ($instancesList as $instance) {
$instance = trim($instance, "\r ");
if (!empty($instance)) {
$cleaninstancesList[] = $instance;
}
}
$exportService = new ExportService();
$this->generatedCode = $exportService->export($cleaninstancesList, $moufManager);
} | php | public function export($instances, $selfedit="false") {
if ($selfedit == "true") {
$moufManager = MoufManager::getMoufManager();
} else {
$moufManager = MoufManager::getMoufManagerHiddenInstance();
}
$instancesList = explode("\n", $instances);
$cleaninstancesList = array();
foreach ($instancesList as $instance) {
$instance = trim($instance, "\r ");
if (!empty($instance)) {
$cleaninstancesList[] = $instance;
}
}
$exportService = new ExportService();
$this->generatedCode = $exportService->export($cleaninstancesList, $moufManager);
} | [
"public",
"function",
"export",
"(",
"$",
"instances",
",",
"$",
"selfedit",
"=",
"\"false\"",
")",
"{",
"if",
"(",
"$",
"selfedit",
"==",
"\"true\"",
")",
"{",
"$",
"moufManager",
"=",
"MoufManager",
"::",
"getMoufManager",
"(",
")",
";",
"}",
"else",
... | This action generates the objects from the SQL query and creates a new SELECT instance.
@param string $instances
@param string $selfedit | [
"This",
"action",
"generates",
"the",
"objects",
"from",
"the",
"SQL",
"query",
"and",
"creates",
"a",
"new",
"SELECT",
"instance",
"."
] | 14a82a1a0e0fda503e6152d65900623cd73f6202 | https://github.com/thecodingmachine/utils.package-builder/blob/14a82a1a0e0fda503e6152d65900623cd73f6202/src/Mouf/Utils/PackageBuilder/Export/ExportController.php#L54-L72 | train |
Sms-Gate/TurboSmsAdapter | src/TurboSmsAdapterFactory.php | TurboSmsAdapterFactory.soap | public static function soap(string $login, string $password): TurboSmsSoapAdapter
{
$responseParser = (new ResponseParserFactory())->create();
$soapClient = (new SoapClientFactory())->create();
$configuration = new Configuration($login, $password);
$authenticator = new TurboSmsSoapAuthenticator($soapClient, $configuration, $responseParser);
return new TurboSmsSoapAdapter($soapClient, $responseParser, $authenticator);
} | php | public static function soap(string $login, string $password): TurboSmsSoapAdapter
{
$responseParser = (new ResponseParserFactory())->create();
$soapClient = (new SoapClientFactory())->create();
$configuration = new Configuration($login, $password);
$authenticator = new TurboSmsSoapAuthenticator($soapClient, $configuration, $responseParser);
return new TurboSmsSoapAdapter($soapClient, $responseParser, $authenticator);
} | [
"public",
"static",
"function",
"soap",
"(",
"string",
"$",
"login",
",",
"string",
"$",
"password",
")",
":",
"TurboSmsSoapAdapter",
"{",
"$",
"responseParser",
"=",
"(",
"new",
"ResponseParserFactory",
"(",
")",
")",
"->",
"create",
"(",
")",
";",
"$",
... | Create the SOAP adapter for TurboSMS
@param string $login
@param string $password
@return TurboSmsSoapAdapter | [
"Create",
"the",
"SOAP",
"adapter",
"for",
"TurboSMS"
] | 999c9b0e77dcde7d79f47a9e0b84282c231c8744 | https://github.com/Sms-Gate/TurboSmsAdapter/blob/999c9b0e77dcde7d79f47a9e0b84282c231c8744/src/TurboSmsAdapterFactory.php#L36-L44 | train |
osflab/exception | PhpErrorException.php | PhpErrorException.logError | protected static function logError(self $e): void
{
if (class_exists('\Osf\Log\LogProxy')) {
$msg = get_class($e) . ' : ' . $e->getMessage();
try {
\Osf\Log\LogProxy::log($msg, $e->getLogLevel(), 'PHPERR', $e->getTraceAsString());
} catch (\Exception $ex) {
file_put_contents(sys_get_temp_dir() . '/undisplayed-sma-errors.log', date('Ymd-His-') . $ex->getMessage(), FILE_APPEND);
}
}
} | php | protected static function logError(self $e): void
{
if (class_exists('\Osf\Log\LogProxy')) {
$msg = get_class($e) . ' : ' . $e->getMessage();
try {
\Osf\Log\LogProxy::log($msg, $e->getLogLevel(), 'PHPERR', $e->getTraceAsString());
} catch (\Exception $ex) {
file_put_contents(sys_get_temp_dir() . '/undisplayed-sma-errors.log', date('Ymd-His-') . $ex->getMessage(), FILE_APPEND);
}
}
} | [
"protected",
"static",
"function",
"logError",
"(",
"self",
"$",
"e",
")",
":",
"void",
"{",
"if",
"(",
"class_exists",
"(",
"'\\Osf\\Log\\LogProxy'",
")",
")",
"{",
"$",
"msg",
"=",
"get_class",
"(",
"$",
"e",
")",
".",
"' : '",
".",
"$",
"e",
"->",... | Error -> Osf\Log\LogProxy
@param self $e
@return void | [
"Error",
"-",
">",
"Osf",
"\\",
"Log",
"\\",
"LogProxy"
] | 01fda2339cc654ec01092aff7c581032b082cf38 | https://github.com/osflab/exception/blob/01fda2339cc654ec01092aff7c581032b082cf38/PhpErrorException.php#L108-L118 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.