id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
236,400 | 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 |
236,401 | 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 |
236,402 | 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 |
236,403 | 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 |
236,404 | 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 |
236,405 | 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 |
236,406 | 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 |
236,407 | 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 |
236,408 | 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 |
236,409 | 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 |
236,410 | 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 |
236,411 | 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 |
236,412 | 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 |
236,413 | 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 |
236,414 | 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 |
236,415 | 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 |
236,416 | 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 |
236,417 | 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 |
236,418 | 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 |
236,419 | 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 |
236,420 | 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 |
236,421 | 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 |
236,422 | 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 |
236,423 | 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 |
236,424 | 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 |
236,425 | 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 |
236,426 | 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 |
236,427 | 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 |
236,428 | 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 |
236,429 | 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 |
236,430 | 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 |
236,431 | 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 |
236,432 | 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 |
236,433 | 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 |
236,434 | 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 |
236,435 | 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 |
236,436 | 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 |
236,437 | 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 |
236,438 | 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 |
236,439 | 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 |
236,440 | 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 |
236,441 | 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 |
236,442 | 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 |
236,443 | 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 |
236,444 | 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 |
236,445 | 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 |
236,446 | 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 |
236,447 | 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 |
236,448 | 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 |
236,449 | 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 |
236,450 | 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 |
236,451 | 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 |
236,452 | 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 |
236,453 | 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 |
236,454 | 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 |
236,455 | 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 |
236,456 | 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 |
236,457 | 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 |
236,458 | 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 |
236,459 | 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 |
236,460 | 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 |
236,461 | 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 |
236,462 | 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 |
236,463 | 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 |
236,464 | 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 |
236,465 | 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 |
236,466 | 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 |
236,467 | 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 |
236,468 | 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 |
236,469 | 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 |
236,470 | 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 |
236,471 | 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 |
236,472 | 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 |
236,473 | 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 |
236,474 | 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 |
236,475 | 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 |
236,476 | 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 |
236,477 | 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 |
236,478 | 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 |
236,479 | 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 |
236,480 | 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 |
236,481 | 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 |
236,482 | 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 |
236,483 | 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 |
236,484 | 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 |
236,485 | osflab/exception | PhpErrorException.php | PhpErrorException.triggerApplication | protected static function triggerApplication(self $e): void
{
if (class_exists('\Osf\Application\OsfApplication')) {
if (\Osf\Application\OsfApplication::isDevelopment()) {
\Osf\Exception\Error::displayException($e);
} else {
if (\Osf\Application\OsfApplication::isStaging()) {
$err = sprintf(__("%s. Details in log file."), $e->getMessage());
echo \Osf\Container\OsfContainer::getViewHelper()->alert(__("Error detected"), $err)->statusWarning();
}
}
}
} | php | protected static function triggerApplication(self $e): void
{
if (class_exists('\Osf\Application\OsfApplication')) {
if (\Osf\Application\OsfApplication::isDevelopment()) {
\Osf\Exception\Error::displayException($e);
} else {
if (\Osf\Application\OsfApplication::isStaging()) {
$err = sprintf(__("%s. Details in log file."), $e->getMessage());
echo \Osf\Container\OsfContainer::getViewHelper()->alert(__("Error detected"), $err)->statusWarning();
}
}
}
} | [
"protected",
"static",
"function",
"triggerApplication",
"(",
"self",
"$",
"e",
")",
":",
"void",
"{",
"if",
"(",
"class_exists",
"(",
"'\\Osf\\Application\\OsfApplication'",
")",
")",
"{",
"if",
"(",
"\\",
"Osf",
"\\",
"Application",
"\\",
"OsfApplication",
"... | Transmit error to the application context
@param self $e
@return void | [
"Transmit",
"error",
"to",
"the",
"application",
"context"
] | 01fda2339cc654ec01092aff7c581032b082cf38 | https://github.com/osflab/exception/blob/01fda2339cc654ec01092aff7c581032b082cf38/PhpErrorException.php#L125-L137 |
236,486 | gearphp/loop | Manager/WhileManager.php | WhileManager.addTick | public function addTick(TickInterface $tick)
{
$tick->setManager($this);
$this->ticks[$tick->getName()] = [
'tick' => $tick,
'time' => 0,
];
return $this;
} | php | public function addTick(TickInterface $tick)
{
$tick->setManager($this);
$this->ticks[$tick->getName()] = [
'tick' => $tick,
'time' => 0,
];
return $this;
} | [
"public",
"function",
"addTick",
"(",
"TickInterface",
"$",
"tick",
")",
"{",
"$",
"tick",
"->",
"setManager",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"ticks",
"[",
"$",
"tick",
"->",
"getName",
"(",
")",
"]",
"=",
"[",
"'tick'",
"=>",
"$",
... | Add tick to loop.
@param TickInterface $tick
@return $this | [
"Add",
"tick",
"to",
"loop",
"."
] | 53032b3e9f789b729744922c75e09b2a33845f90 | https://github.com/gearphp/loop/blob/53032b3e9f789b729744922c75e09b2a33845f90/Manager/WhileManager.php#L68-L77 |
236,487 | gearphp/loop | Manager/WhileManager.php | WhileManager.removeTick | public function removeTick($name)
{
if (isset($this->ticks[$name])) {
$this->ticks[$name]->setManager(null);
unset($this->ticks[$name]);
}
} | php | public function removeTick($name)
{
if (isset($this->ticks[$name])) {
$this->ticks[$name]->setManager(null);
unset($this->ticks[$name]);
}
} | [
"public",
"function",
"removeTick",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"ticks",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"ticks",
"[",
"$",
"name",
"]",
"->",
"setManager",
"(",
"null",
")",
... | Remove tick by name from loop.
@param string $name
@return void | [
"Remove",
"tick",
"by",
"name",
"from",
"loop",
"."
] | 53032b3e9f789b729744922c75e09b2a33845f90 | https://github.com/gearphp/loop/blob/53032b3e9f789b729744922c75e09b2a33845f90/Manager/WhileManager.php#L85-L91 |
236,488 | gearphp/loop | Manager/WhileManager.php | WhileManager.start | public function start()
{
if ($this->isStart) {
return;
}
$this->startAt = time();
$this->stopAt = null;
$this->isStart = true;
if (extension_loaded('xdebug')) {
xdebug_disable();
}
foreach ($this->onStart as $callable) {
call_user_func_array($callable, []);
}
while ($this->isStart) {
$this->tick();
}
$this->stopAt = time();
foreach ($this->onStop as $callable) {
call_user_func_array($callable, []);
}
if (extension_loaded('xdebug')) {
xdebug_enable();
}
} | php | public function start()
{
if ($this->isStart) {
return;
}
$this->startAt = time();
$this->stopAt = null;
$this->isStart = true;
if (extension_loaded('xdebug')) {
xdebug_disable();
}
foreach ($this->onStart as $callable) {
call_user_func_array($callable, []);
}
while ($this->isStart) {
$this->tick();
}
$this->stopAt = time();
foreach ($this->onStop as $callable) {
call_user_func_array($callable, []);
}
if (extension_loaded('xdebug')) {
xdebug_enable();
}
} | [
"public",
"function",
"start",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isStart",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"startAt",
"=",
"time",
"(",
")",
";",
"$",
"this",
"->",
"stopAt",
"=",
"null",
";",
"$",
"this",
"->",
"is... | Start loop.
@return void | [
"Start",
"loop",
"."
] | 53032b3e9f789b729744922c75e09b2a33845f90 | https://github.com/gearphp/loop/blob/53032b3e9f789b729744922c75e09b2a33845f90/Manager/WhileManager.php#L98-L129 |
236,489 | gearphp/loop | Manager/WhileManager.php | WhileManager.tick | protected function tick()
{
$time = microtime(true);
foreach ($this->ticks as $name => $value) {
/* @var TickInterface $tick */
$tick = $value['tick'];
$interval = $tick->getInterval() >= $this->interval ? $tick->getInterval() : $this->interval;
$diff = ($time - $value['time']) * 1000;
if ($diff >= $interval) {
try {
$tick->tick();
} catch (\Exception $e) {
$this->catchTickException($tick, $e);
}
$this->ticks[$name]['time'] = $time;
}
}
usleep($this->interval * 1e3);
} | php | protected function tick()
{
$time = microtime(true);
foreach ($this->ticks as $name => $value) {
/* @var TickInterface $tick */
$tick = $value['tick'];
$interval = $tick->getInterval() >= $this->interval ? $tick->getInterval() : $this->interval;
$diff = ($time - $value['time']) * 1000;
if ($diff >= $interval) {
try {
$tick->tick();
} catch (\Exception $e) {
$this->catchTickException($tick, $e);
}
$this->ticks[$name]['time'] = $time;
}
}
usleep($this->interval * 1e3);
} | [
"protected",
"function",
"tick",
"(",
")",
"{",
"$",
"time",
"=",
"microtime",
"(",
"true",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"ticks",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"/* @var TickInterface $tick */",
"$",
"tick",
"=",
"$",
... | Loop tick. | [
"Loop",
"tick",
"."
] | 53032b3e9f789b729744922c75e09b2a33845f90 | https://github.com/gearphp/loop/blob/53032b3e9f789b729744922c75e09b2a33845f90/Manager/WhileManager.php#L134-L158 |
236,490 | zugoripls/laravel-framework | src/Illuminate/Auth/Passwords/PasswordBroker.php | PasswordBroker.emailResetLink | public function emailResetLink(CanResetPasswordContract $user, $token, Closure $callback = null)
{
// We will use the reminder view that was given to the broker to display the
// password reminder e-mail. We'll pass a "token" variable into the views
// so that it may be displayed for an user to click for password reset.
$view = $this->emailView;
return $this->mailer->send($view, compact('token', 'user'), function($m) use ($user, $token, $callback)
{
$m->to($user->getEmailForPasswordReset());
if ( ! is_null($callback))
{
call_user_func($callback, $m, $user, $token);
}
});
} | php | public function emailResetLink(CanResetPasswordContract $user, $token, Closure $callback = null)
{
// We will use the reminder view that was given to the broker to display the
// password reminder e-mail. We'll pass a "token" variable into the views
// so that it may be displayed for an user to click for password reset.
$view = $this->emailView;
return $this->mailer->send($view, compact('token', 'user'), function($m) use ($user, $token, $callback)
{
$m->to($user->getEmailForPasswordReset());
if ( ! is_null($callback))
{
call_user_func($callback, $m, $user, $token);
}
});
} | [
"public",
"function",
"emailResetLink",
"(",
"CanResetPasswordContract",
"$",
"user",
",",
"$",
"token",
",",
"Closure",
"$",
"callback",
"=",
"null",
")",
"{",
"// We will use the reminder view that was given to the broker to display the",
"// password reminder e-mail. We'll p... | Send the password reset link via e-mail.
@param \Illuminate\Contracts\Auth\CanResetPassword $user
@param string $token
@param \Closure|null $callback
@return int | [
"Send",
"the",
"password",
"reset",
"link",
"via",
"e",
"-",
"mail",
"."
] | 90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655 | https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Auth/Passwords/PasswordBroker.php#L104-L120 |
236,491 | open-orchestra/open-orchestra-elastica-admin-bundle | ElasticaAdmin/SchemaInitializer/Strategies/ContentTypeSchemaInitializer.php | ContentTypeSchemaInitializer.initialize | public function initialize()
{
$contentTypes = $this->contentTypeRepository->findAllNotDeletedInLastVersion();
foreach ($contentTypes as $contentType) {
$this->schemaGenerator->createMapping($contentType);
}
} | php | public function initialize()
{
$contentTypes = $this->contentTypeRepository->findAllNotDeletedInLastVersion();
foreach ($contentTypes as $contentType) {
$this->schemaGenerator->createMapping($contentType);
}
} | [
"public",
"function",
"initialize",
"(",
")",
"{",
"$",
"contentTypes",
"=",
"$",
"this",
"->",
"contentTypeRepository",
"->",
"findAllNotDeletedInLastVersion",
"(",
")",
";",
"foreach",
"(",
"$",
"contentTypes",
"as",
"$",
"contentType",
")",
"{",
"$",
"this"... | Initialize content type schema | [
"Initialize",
"content",
"type",
"schema"
] | 6d14beec9d78410e62549d6645d213548e4001a3 | https://github.com/open-orchestra/open-orchestra-elastica-admin-bundle/blob/6d14beec9d78410e62549d6645d213548e4001a3/ElasticaAdmin/SchemaInitializer/Strategies/ContentTypeSchemaInitializer.php#L30-L37 |
236,492 | xqddd/Presentable | src/PresentableTrait.php | PresentableTrait.toOutput | public function toOutput($structure, $assoc = true)
{
switch ($structure) {
case 'string':
$output = $this->toString();
break;
case 'array':
default:
$output = $this->toArray($assoc);
break;
}
return $output;
} | php | public function toOutput($structure, $assoc = true)
{
switch ($structure) {
case 'string':
$output = $this->toString();
break;
case 'array':
default:
$output = $this->toArray($assoc);
break;
}
return $output;
} | [
"public",
"function",
"toOutput",
"(",
"$",
"structure",
",",
"$",
"assoc",
"=",
"true",
")",
"{",
"switch",
"(",
"$",
"structure",
")",
"{",
"case",
"'string'",
":",
"$",
"output",
"=",
"$",
"this",
"->",
"toString",
"(",
")",
";",
"break",
";",
"... | Get the public representation of the object
@param string $structure
@param bool $assoc
@return array|string | [
"Get",
"the",
"public",
"representation",
"of",
"the",
"object"
] | 995e55d2aa81467382272eddbf5df6a589439d7b | https://github.com/xqddd/Presentable/blob/995e55d2aa81467382272eddbf5df6a589439d7b/src/PresentableTrait.php#L35-L47 |
236,493 | xqddd/Presentable | src/PresentableTrait.php | PresentableTrait.toJson | public function toJson($options = 0, $structure, $assoc = true)
{
return json_encode(
$this->toOutput($structure, $assoc),
$options
);
} | php | public function toJson($options = 0, $structure, $assoc = true)
{
return json_encode(
$this->toOutput($structure, $assoc),
$options
);
} | [
"public",
"function",
"toJson",
"(",
"$",
"options",
"=",
"0",
",",
"$",
"structure",
",",
"$",
"assoc",
"=",
"true",
")",
"{",
"return",
"json_encode",
"(",
"$",
"this",
"->",
"toOutput",
"(",
"$",
"structure",
",",
"$",
"assoc",
")",
",",
"$",
"o... | Get the JSON representation of the object
@param int $options
@param string $structure
@param bool $assoc
@return string | [
"Get",
"the",
"JSON",
"representation",
"of",
"the",
"object"
] | 995e55d2aa81467382272eddbf5df6a589439d7b | https://github.com/xqddd/Presentable/blob/995e55d2aa81467382272eddbf5df6a589439d7b/src/PresentableTrait.php#L57-L63 |
236,494 | emhar/SearchDoctrineBundle | Query/QueryFactory.php | QueryFactory.doLoad | protected function doLoad($itemMetaData)
{
$query = $this->newQueryInstance($itemMetaData);
$databaseMapping = $this->ormDriver->loadDatabaseMapping($itemMetaData);
$query->mapDatabase($databaseMapping, $itemMetaData->getItemClass(), $itemMetaData->getHitPositions());
return $query;
} | php | protected function doLoad($itemMetaData)
{
$query = $this->newQueryInstance($itemMetaData);
$databaseMapping = $this->ormDriver->loadDatabaseMapping($itemMetaData);
$query->mapDatabase($databaseMapping, $itemMetaData->getItemClass(), $itemMetaData->getHitPositions());
return $query;
} | [
"protected",
"function",
"doLoad",
"(",
"$",
"itemMetaData",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"newQueryInstance",
"(",
"$",
"itemMetaData",
")",
";",
"$",
"databaseMapping",
"=",
"$",
"this",
"->",
"ormDriver",
"->",
"loadDatabaseMapping",
"("... | Loads Query for itemMetaData
@param ItemMetaData $itemMetaData | [
"Loads",
"Query",
"for",
"itemMetaData"
] | 0844cda4a6972dd71c04c0b38dba1ebf9b15c238 | https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Query/QueryFactory.php#L73-L79 |
236,495 | sebardo/core | CoreBundle/Service/Mailer.php | Mailer.sendSubscribeToNewsletterMessage | public function sendSubscribeToNewsletterMessage(Actor $user)
{
$templateName = 'CoreBundle:Email:subscription.email.html.twig';
$context = array(
'user' => $user
);
$this->sendMessage(
$templateName,
$context,
$this->twigGlobal->getParameter('admin_email'),
$user->getEmail()
);
} | php | public function sendSubscribeToNewsletterMessage(Actor $user)
{
$templateName = 'CoreBundle:Email:subscription.email.html.twig';
$context = array(
'user' => $user
);
$this->sendMessage(
$templateName,
$context,
$this->twigGlobal->getParameter('admin_email'),
$user->getEmail()
);
} | [
"public",
"function",
"sendSubscribeToNewsletterMessage",
"(",
"Actor",
"$",
"user",
")",
"{",
"$",
"templateName",
"=",
"'CoreBundle:Email:subscription.email.html.twig'",
";",
"$",
"context",
"=",
"array",
"(",
"'user'",
"=>",
"$",
"user",
")",
";",
"$",
"this",
... | Send an email to a user to confirm the subscription
@param UserInterface $user
@return void | [
"Send",
"an",
"email",
"to",
"a",
"user",
"to",
"confirm",
"the",
"subscription"
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Service/Mailer.php#L150-L164 |
236,496 | sebardo/core | CoreBundle/Service/Mailer.php | Mailer.sendContactMessage | public function sendContactMessage(array $params)
{
$templateName = 'CoreBundle:Email:base.email.html.twig';
$context = array(
'params' => $params
);
$this->sendMessage(
$templateName,
$context,
$this->twigGlobal->getParameter('admin_email'),
$params['email']
);
$this->sendMessage(
$templateName,
$context,
$params['email'],
$this->twigGlobal->getParameter('admin_email')
);
} | php | public function sendContactMessage(array $params)
{
$templateName = 'CoreBundle:Email:base.email.html.twig';
$context = array(
'params' => $params
);
$this->sendMessage(
$templateName,
$context,
$this->twigGlobal->getParameter('admin_email'),
$params['email']
);
$this->sendMessage(
$templateName,
$context,
$params['email'],
$this->twigGlobal->getParameter('admin_email')
);
} | [
"public",
"function",
"sendContactMessage",
"(",
"array",
"$",
"params",
")",
"{",
"$",
"templateName",
"=",
"'CoreBundle:Email:base.email.html.twig'",
";",
"$",
"context",
"=",
"array",
"(",
"'params'",
"=>",
"$",
"params",
")",
";",
"$",
"this",
"->",
"sendM... | Send an email to a user and admin
@param array $params (name, email, message)
@return void | [
"Send",
"an",
"email",
"to",
"a",
"user",
"and",
"admin"
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Service/Mailer.php#L242-L264 |
236,497 | sebardo/core | CoreBundle/Service/Mailer.php | Mailer.sendNotificationEmail | public function sendNotificationEmail($mail, $from=null)
{
$templateName = 'CoreBundle:Email:notification.email.html.twig';
$context = array(
'mail' => $mail
);
if(is_null($from)){
$this->sendMessage(
$templateName,
$context,
$mail->getSender(),
$mail->getRecipient(),
$mail->getAttachment()
);
}else{
$this->sendMessage(
$templateName,
$context,
$from,
$mail->getRecipient(),
$mail->getAttachment()
);
}
} | php | public function sendNotificationEmail($mail, $from=null)
{
$templateName = 'CoreBundle:Email:notification.email.html.twig';
$context = array(
'mail' => $mail
);
if(is_null($from)){
$this->sendMessage(
$templateName,
$context,
$mail->getSender(),
$mail->getRecipient(),
$mail->getAttachment()
);
}else{
$this->sendMessage(
$templateName,
$context,
$from,
$mail->getRecipient(),
$mail->getAttachment()
);
}
} | [
"public",
"function",
"sendNotificationEmail",
"(",
"$",
"mail",
",",
"$",
"from",
"=",
"null",
")",
"{",
"$",
"templateName",
"=",
"'CoreBundle:Email:notification.email.html.twig'",
";",
"$",
"context",
"=",
"array",
"(",
"'mail'",
"=>",
"$",
"mail",
")",
";"... | Send an email from notification
@param MailLog $mail
@return void | [
"Send",
"an",
"email",
"from",
"notification"
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Service/Mailer.php#L273-L299 |
236,498 | sebardo/core | CoreBundle/Service/Mailer.php | Mailer.sendAdvertPurchaseConfirmationMessage | public function sendAdvertPurchaseConfirmationMessage(Invoice $invoice, $amount)
{
//send email to optic to confirm plan purchase
//check empty bank number account
$templateName = 'PaymentBundle:Email:advert.confirmation.html.twig';
$advert = $invoice->getTransaction()->getItems()->first()->getAdvert();
if($invoice->getTransaction()->getActor() instanceof Actor){
$user = $invoice->getTransaction()->getActor();
}elseif($invoice->getTransaction()->getOptic() instanceof Optic){
$user = $invoice->getTransaction()->getOptic();
}
$toEmail = $user->getEmail();
$token = null;
$context = array(
'order_number' => $invoice->getTransaction()->getTransactionKey(),
'advert' => $advert,
'user' => $user,
'token' => $token
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
} | php | public function sendAdvertPurchaseConfirmationMessage(Invoice $invoice, $amount)
{
//send email to optic to confirm plan purchase
//check empty bank number account
$templateName = 'PaymentBundle:Email:advert.confirmation.html.twig';
$advert = $invoice->getTransaction()->getItems()->first()->getAdvert();
if($invoice->getTransaction()->getActor() instanceof Actor){
$user = $invoice->getTransaction()->getActor();
}elseif($invoice->getTransaction()->getOptic() instanceof Optic){
$user = $invoice->getTransaction()->getOptic();
}
$toEmail = $user->getEmail();
$token = null;
$context = array(
'order_number' => $invoice->getTransaction()->getTransactionKey(),
'advert' => $advert,
'user' => $user,
'token' => $token
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
} | [
"public",
"function",
"sendAdvertPurchaseConfirmationMessage",
"(",
"Invoice",
"$",
"invoice",
",",
"$",
"amount",
")",
"{",
"//send email to optic to confirm plan purchase",
"//check empty bank number account",
"$",
"templateName",
"=",
"'PaymentBundle:Email:advert.confirmation.ht... | Send plan purchase confirmation
@param Invoice $invoice
@param float $amount | [
"Send",
"plan",
"purchase",
"confirmation"
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Service/Mailer.php#L400-L425 |
236,499 | sebardo/core | CoreBundle/Service/Mailer.php | Mailer.sendPurchaseConfirmationMessage | public function sendPurchaseConfirmationMessage(Invoice $invoice, $amount)
{
$templateName = 'PaymentBundle:Email:sale.confirmation.html.twig';
$toEmail = $invoice->getTransaction()->getActor()->getEmail();
$orderUrl = $this->router->generate('payment_checkout_showinvoice', array('number' => $invoice->getInvoiceNumber()), UrlGeneratorInterface::ABSOLUTE_URL);
$context = array(
'order_number' => $invoice->getTransaction()->getTransactionKey(),
'amount' => $amount,
'payment_type' => $invoice->getTransaction()->getPaymentMethod()->getName(),
'order_url' => $orderUrl,
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
//send email to optic to confirm purchase
//check empty bank number account
$templateName = 'PaymentBundle:Email:sale.confirmation.actor.html.twig';
$productItems = $invoice->getTransaction()->getItems();
$actor = $productItems->first()->getProduct()->getActor();
if($actor instanceof Actor) {
$toEmail = $actor->getEmail();
$token = null;
if($actor->getBankAccountNumber() == ''){
$token = sha1(uniqid());
$date = new \DateTime();
$actor->setBankAccountToken($token);
$actor->setBankAccountTime($date->getTimestamp());
$this->manager->persist($actor);
$this->manager->flush();
}
$context = array(
'order_number' => $invoice->getTransaction()->getTransactionKey(),
'products' => $productItems,
'token' => $token,
'actor' => $actor
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
}
} | php | public function sendPurchaseConfirmationMessage(Invoice $invoice, $amount)
{
$templateName = 'PaymentBundle:Email:sale.confirmation.html.twig';
$toEmail = $invoice->getTransaction()->getActor()->getEmail();
$orderUrl = $this->router->generate('payment_checkout_showinvoice', array('number' => $invoice->getInvoiceNumber()), UrlGeneratorInterface::ABSOLUTE_URL);
$context = array(
'order_number' => $invoice->getTransaction()->getTransactionKey(),
'amount' => $amount,
'payment_type' => $invoice->getTransaction()->getPaymentMethod()->getName(),
'order_url' => $orderUrl,
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
//send email to optic to confirm purchase
//check empty bank number account
$templateName = 'PaymentBundle:Email:sale.confirmation.actor.html.twig';
$productItems = $invoice->getTransaction()->getItems();
$actor = $productItems->first()->getProduct()->getActor();
if($actor instanceof Actor) {
$toEmail = $actor->getEmail();
$token = null;
if($actor->getBankAccountNumber() == ''){
$token = sha1(uniqid());
$date = new \DateTime();
$actor->setBankAccountToken($token);
$actor->setBankAccountTime($date->getTimestamp());
$this->manager->persist($actor);
$this->manager->flush();
}
$context = array(
'order_number' => $invoice->getTransaction()->getTransactionKey(),
'products' => $productItems,
'token' => $token,
'actor' => $actor
);
$this->sendMessage($templateName, $context, $this->twigGlobal->getParameter('admin_email') , $toEmail);
}
} | [
"public",
"function",
"sendPurchaseConfirmationMessage",
"(",
"Invoice",
"$",
"invoice",
",",
"$",
"amount",
")",
"{",
"$",
"templateName",
"=",
"'PaymentBundle:Email:sale.confirmation.html.twig'",
";",
"$",
"toEmail",
"=",
"$",
"invoice",
"->",
"getTransaction",
"(",... | Send invest confirmation
@param Invoice $invoice
@param float $amount | [
"Send",
"invest",
"confirmation"
] | d063334639dd717406c97ea4da9f4b260d0af4f4 | https://github.com/sebardo/core/blob/d063334639dd717406c97ea4da9f4b260d0af4f4/CoreBundle/Service/Mailer.php#L462-L505 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.