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
|
---|---|---|---|---|---|---|---|---|---|---|---|
3,800 |
n0m4dz/laracasa
|
Zend/Gdata/MediaMimeStream.php
|
Zend_Gdata_MediaMimeStream.read
|
public function read($bytesRequested)
{
if($this->_currentPart >= count($this->_parts)) {
return FALSE;
}
$activePart = $this->_parts[$this->_currentPart];
$buffer = $activePart->read($bytesRequested);
while(strlen($buffer) < $bytesRequested) {
$this->_currentPart += 1;
$nextBuffer = $this->read($bytesRequested - strlen($buffer));
if($nextBuffer === FALSE) {
break;
}
$buffer .= $nextBuffer;
}
return $buffer;
}
|
php
|
public function read($bytesRequested)
{
if($this->_currentPart >= count($this->_parts)) {
return FALSE;
}
$activePart = $this->_parts[$this->_currentPart];
$buffer = $activePart->read($bytesRequested);
while(strlen($buffer) < $bytesRequested) {
$this->_currentPart += 1;
$nextBuffer = $this->read($bytesRequested - strlen($buffer));
if($nextBuffer === FALSE) {
break;
}
$buffer .= $nextBuffer;
}
return $buffer;
}
|
[
"public",
"function",
"read",
"(",
"$",
"bytesRequested",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_currentPart",
">=",
"count",
"(",
"$",
"this",
"->",
"_parts",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"activePart",
"=",
"$",
"this",
"->",
"_parts",
"[",
"$",
"this",
"->",
"_currentPart",
"]",
";",
"$",
"buffer",
"=",
"$",
"activePart",
"->",
"read",
"(",
"$",
"bytesRequested",
")",
";",
"while",
"(",
"strlen",
"(",
"$",
"buffer",
")",
"<",
"$",
"bytesRequested",
")",
"{",
"$",
"this",
"->",
"_currentPart",
"+=",
"1",
";",
"$",
"nextBuffer",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"bytesRequested",
"-",
"strlen",
"(",
"$",
"buffer",
")",
")",
";",
"if",
"(",
"$",
"nextBuffer",
"===",
"FALSE",
")",
"{",
"break",
";",
"}",
"$",
"buffer",
".=",
"$",
"nextBuffer",
";",
"}",
"return",
"$",
"buffer",
";",
"}"
] |
Read a specific chunk of the the MIME multipart message.
@param integer $bufferSize The size of the chunk that is to be read,
must be lower than MAX_BUFFER_SIZE.
@return string A corresponding piece of the message. This could be
binary or regular text.
|
[
"Read",
"a",
"specific",
"chunk",
"of",
"the",
"the",
"MIME",
"multipart",
"message",
"."
] |
6141f0c16c7d4453275e3b74be5041f336085c91
|
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/MediaMimeStream.php#L136-L155
|
3,801 |
mszewcz/php-json-schema-validator
|
src/Validators/MiscValidators/PropertyNamesValidator.php
|
PropertyNamesValidator.validate
|
public function validate($subject): bool
{
$propertyNames = \array_keys($subject);
foreach ($propertyNames as $propertyName) {
$nodeValidator = new NodeValidator($this->schema['propertyNames'], $this->rootSchema);
if (!$nodeValidator->validate($propertyName)) {
return false;
}
}
return true;
}
|
php
|
public function validate($subject): bool
{
$propertyNames = \array_keys($subject);
foreach ($propertyNames as $propertyName) {
$nodeValidator = new NodeValidator($this->schema['propertyNames'], $this->rootSchema);
if (!$nodeValidator->validate($propertyName)) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"validate",
"(",
"$",
"subject",
")",
":",
"bool",
"{",
"$",
"propertyNames",
"=",
"\\",
"array_keys",
"(",
"$",
"subject",
")",
";",
"foreach",
"(",
"$",
"propertyNames",
"as",
"$",
"propertyName",
")",
"{",
"$",
"nodeValidator",
"=",
"new",
"NodeValidator",
"(",
"$",
"this",
"->",
"schema",
"[",
"'propertyNames'",
"]",
",",
"$",
"this",
"->",
"rootSchema",
")",
";",
"if",
"(",
"!",
"$",
"nodeValidator",
"->",
"validate",
"(",
"$",
"propertyName",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Validates subject against propertyNames
@param $subject
@return bool
|
[
"Validates",
"subject",
"against",
"propertyNames"
] |
f7768bfe07ce6508bb1ff36163560a5e5791de7d
|
https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/MiscValidators/PropertyNamesValidator.php#L48-L58
|
3,802 |
experus/commands
|
src/Dispatcher.php
|
Dispatcher.execute
|
public function execute($command)
{
$commandClass = get_class($command);
$mappings = $this->getMappings();
$this->checkIfCommandExistsInMappings($commandClass, $mappings);
$handlerClass = array_get($mappings, $commandClass);
try {
return $this->getContainer()->make($handlerClass)->handle($command);
} catch (ReflectionException $e) {
throw new CommandNotInstantiableException($handlerClass . ' is not instantiable.');
}
}
|
php
|
public function execute($command)
{
$commandClass = get_class($command);
$mappings = $this->getMappings();
$this->checkIfCommandExistsInMappings($commandClass, $mappings);
$handlerClass = array_get($mappings, $commandClass);
try {
return $this->getContainer()->make($handlerClass)->handle($command);
} catch (ReflectionException $e) {
throw new CommandNotInstantiableException($handlerClass . ' is not instantiable.');
}
}
|
[
"public",
"function",
"execute",
"(",
"$",
"command",
")",
"{",
"$",
"commandClass",
"=",
"get_class",
"(",
"$",
"command",
")",
";",
"$",
"mappings",
"=",
"$",
"this",
"->",
"getMappings",
"(",
")",
";",
"$",
"this",
"->",
"checkIfCommandExistsInMappings",
"(",
"$",
"commandClass",
",",
"$",
"mappings",
")",
";",
"$",
"handlerClass",
"=",
"array_get",
"(",
"$",
"mappings",
",",
"$",
"commandClass",
")",
";",
"try",
"{",
"return",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"make",
"(",
"$",
"handlerClass",
")",
"->",
"handle",
"(",
"$",
"command",
")",
";",
"}",
"catch",
"(",
"ReflectionException",
"$",
"e",
")",
"{",
"throw",
"new",
"CommandNotInstantiableException",
"(",
"$",
"handlerClass",
".",
"' is not instantiable.'",
")",
";",
"}",
"}"
] |
Dispatch a command on the dispatcher.
@param mixed $command The command to dispatch.
@return mixed The result that is returned by the command his handler.
@throws CommandNotInstantiableException Thrown when the dispatcher failed to instantiate the command handler.
@throws CommandNotFoundException When the command could not be found in the mappings.
@throws Exception Any function that the handler throws.
|
[
"Dispatch",
"a",
"command",
"on",
"the",
"dispatcher",
"."
] |
efe3d643147dd1542c243b4099d483cd744cc44b
|
https://github.com/experus/commands/blob/efe3d643147dd1542c243b4099d483cd744cc44b/src/Dispatcher.php#L83-L97
|
3,803 |
kambo-1st/KamboRouter
|
src/Route/Collection.php
|
Collection.get
|
public function get(string $route, $handler) : Route
{
return $this->createRoute(Method::GET, $route, $handler);
}
|
php
|
public function get(string $route, $handler) : Route
{
return $this->createRoute(Method::GET, $route, $handler);
}
|
[
"public",
"function",
"get",
"(",
"string",
"$",
"route",
",",
"$",
"handler",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"createRoute",
"(",
"Method",
"::",
"GET",
",",
"$",
"route",
",",
"$",
"handler",
")",
";",
"}"
] |
Add route matched with GET method.
Shortcut for createRoute function with preset GET method.
@param mixed $route route definition
@param mixed $handler handler which will be executed if the url match
the route
@return \Kambo\Router\Route\Route Created route
|
[
"Add",
"route",
"matched",
"with",
"GET",
"method",
".",
"Shortcut",
"for",
"createRoute",
"function",
"with",
"preset",
"GET",
"method",
"."
] |
32ad63ab1c5483714868d5acbbc67beb2f0b1cda
|
https://github.com/kambo-1st/KamboRouter/blob/32ad63ab1c5483714868d5acbbc67beb2f0b1cda/src/Route/Collection.php#L71-L74
|
3,804 |
kambo-1st/KamboRouter
|
src/Route/Collection.php
|
Collection.post
|
public function post(string $route, $handler) : Route
{
return $this->createRoute(Method::POST, $route, $handler);
}
|
php
|
public function post(string $route, $handler) : Route
{
return $this->createRoute(Method::POST, $route, $handler);
}
|
[
"public",
"function",
"post",
"(",
"string",
"$",
"route",
",",
"$",
"handler",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"createRoute",
"(",
"Method",
"::",
"POST",
",",
"$",
"route",
",",
"$",
"handler",
")",
";",
"}"
] |
Add route matched with POST method.
Shortcut for createRoute function with preset POST method.
@param mixed $route route definition
@param mixed $handler handler which will be executed if the url match
the route
@return \Kambo\Router\Route\Route Created route
|
[
"Add",
"route",
"matched",
"with",
"POST",
"method",
".",
"Shortcut",
"for",
"createRoute",
"function",
"with",
"preset",
"POST",
"method",
"."
] |
32ad63ab1c5483714868d5acbbc67beb2f0b1cda
|
https://github.com/kambo-1st/KamboRouter/blob/32ad63ab1c5483714868d5acbbc67beb2f0b1cda/src/Route/Collection.php#L86-L89
|
3,805 |
kambo-1st/KamboRouter
|
src/Route/Collection.php
|
Collection.delete
|
public function delete(string $route, $handler) : Route
{
return $this->createRoute(Method::DELETE, $route, $handler);
}
|
php
|
public function delete(string $route, $handler) : Route
{
return $this->createRoute(Method::DELETE, $route, $handler);
}
|
[
"public",
"function",
"delete",
"(",
"string",
"$",
"route",
",",
"$",
"handler",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"createRoute",
"(",
"Method",
"::",
"DELETE",
",",
"$",
"route",
",",
"$",
"handler",
")",
";",
"}"
] |
Add route matched with DELETE method.
Shortcut for createRoute function with preset DELETE method.
@param mixed $route route definition
@param mixed $handler handler which will be executed if the url match
the route
@return \Kambo\Router\Route\Route Created route
|
[
"Add",
"route",
"matched",
"with",
"DELETE",
"method",
".",
"Shortcut",
"for",
"createRoute",
"function",
"with",
"preset",
"DELETE",
"method",
"."
] |
32ad63ab1c5483714868d5acbbc67beb2f0b1cda
|
https://github.com/kambo-1st/KamboRouter/blob/32ad63ab1c5483714868d5acbbc67beb2f0b1cda/src/Route/Collection.php#L101-L104
|
3,806 |
kambo-1st/KamboRouter
|
src/Route/Collection.php
|
Collection.put
|
public function put(string $route, $handler) : Route
{
return $this->createRoute(Method::PUT, $route, $handler);
}
|
php
|
public function put(string $route, $handler) : Route
{
return $this->createRoute(Method::PUT, $route, $handler);
}
|
[
"public",
"function",
"put",
"(",
"string",
"$",
"route",
",",
"$",
"handler",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"createRoute",
"(",
"Method",
"::",
"PUT",
",",
"$",
"route",
",",
"$",
"handler",
")",
";",
"}"
] |
Add route matched with PUT method.
Shortcut for createRoute function with preset PUT method.
@param mixed $route route definition
@param mixed $handler handler which will be executed if the url match
the route
@return \Kambo\Router\Route\Route Created route
|
[
"Add",
"route",
"matched",
"with",
"PUT",
"method",
".",
"Shortcut",
"for",
"createRoute",
"function",
"with",
"preset",
"PUT",
"method",
"."
] |
32ad63ab1c5483714868d5acbbc67beb2f0b1cda
|
https://github.com/kambo-1st/KamboRouter/blob/32ad63ab1c5483714868d5acbbc67beb2f0b1cda/src/Route/Collection.php#L116-L119
|
3,807 |
kambo-1st/KamboRouter
|
src/Route/Collection.php
|
Collection.any
|
public function any(string $route, $handler) : Route
{
return $this->createRoute(Method::ANY, $route, $handler);
}
|
php
|
public function any(string $route, $handler) : Route
{
return $this->createRoute(Method::ANY, $route, $handler);
}
|
[
"public",
"function",
"any",
"(",
"string",
"$",
"route",
",",
"$",
"handler",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"createRoute",
"(",
"Method",
"::",
"ANY",
",",
"$",
"route",
",",
"$",
"handler",
")",
";",
"}"
] |
Add route which will be matched to any method.
Shortcut for createRoute function with preset ANY method.
@param mixed $route route definition
@param mixed $handler handler which will be executed if the url match
the route
@return \Kambo\Router\Route\Route Created route
|
[
"Add",
"route",
"which",
"will",
"be",
"matched",
"to",
"any",
"method",
".",
"Shortcut",
"for",
"createRoute",
"function",
"with",
"preset",
"ANY",
"method",
"."
] |
32ad63ab1c5483714868d5acbbc67beb2f0b1cda
|
https://github.com/kambo-1st/KamboRouter/blob/32ad63ab1c5483714868d5acbbc67beb2f0b1cda/src/Route/Collection.php#L131-L134
|
3,808 |
oss2/doctrine2
|
src/Oss2/Doctrine2/WithPreferences.php
|
WithPreferences.loadPreference
|
public function loadPreference( $name, $index = null, $includeExpired = false )
{
foreach( $this->getPreferences() as $pref )
{
if( ( $pref->getName() == $name ) && ( $pref->getIx() === $index ) )
{
if( $includeExpired || !$pref->getExpiresAt() || ( $pref->getExpiresAt() > new \DateTime() ) )
return $pref;
return false;
}
}
return false;
}
|
php
|
public function loadPreference( $name, $index = null, $includeExpired = false )
{
foreach( $this->getPreferences() as $pref )
{
if( ( $pref->getName() == $name ) && ( $pref->getIx() === $index ) )
{
if( $includeExpired || !$pref->getExpiresAt() || ( $pref->getExpiresAt() > new \DateTime() ) )
return $pref;
return false;
}
}
return false;
}
|
[
"public",
"function",
"loadPreference",
"(",
"$",
"name",
",",
"$",
"index",
"=",
"null",
",",
"$",
"includeExpired",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getPreferences",
"(",
")",
"as",
"$",
"pref",
")",
"{",
"if",
"(",
"(",
"$",
"pref",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"&&",
"(",
"$",
"pref",
"->",
"getIx",
"(",
")",
"===",
"$",
"index",
")",
")",
"{",
"if",
"(",
"$",
"includeExpired",
"||",
"!",
"$",
"pref",
"->",
"getExpiresAt",
"(",
")",
"||",
"(",
"$",
"pref",
"->",
"getExpiresAt",
"(",
")",
">",
"new",
"\\",
"DateTime",
"(",
")",
")",
")",
"return",
"$",
"pref",
";",
"return",
"false",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Return the entity object of the named preference
@param string $name The named attribute / preference to check for
@param int $index default null If an indexed preference, get a specific index
@param boolean $includeExpired default false If true, include preferences even if they have expired.
@return WithPreference If the named preference is not defined, returns FALSE; otherwise it returns the Doctrine_Record
|
[
"Return",
"the",
"entity",
"object",
"of",
"the",
"named",
"preference"
] |
76d42678b28d0d4fe25f09271b76262280de3d97
|
https://github.com/oss2/doctrine2/blob/76d42678b28d0d4fe25f09271b76262280de3d97/src/Oss2/Doctrine2/WithPreferences.php#L89-L103
|
3,809 |
oss2/doctrine2
|
src/Oss2/Doctrine2/WithPreferences.php
|
WithPreferences.hasPreference
|
public function hasPreference( $name, $index = null, $includeExpired = false )
{
return $this->getPreference( $name, $index, $includeExpired );
}
|
php
|
public function hasPreference( $name, $index = null, $includeExpired = false )
{
return $this->getPreference( $name, $index, $includeExpired );
}
|
[
"public",
"function",
"hasPreference",
"(",
"$",
"name",
",",
"$",
"index",
"=",
"null",
",",
"$",
"includeExpired",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getPreference",
"(",
"$",
"name",
",",
"$",
"index",
",",
"$",
"includeExpired",
")",
";",
"}"
] |
Does the named preference exist or not?
WARNING: Evaluate the return of this function using !== or === as a preference such as '0'
will evaluate as false otherwise.
@param string $name The named attribute / preference to check for
@param int $index default null If an indexed preference, get a specific index
@param boolean $includeExpired default false If true, include preferences even if they have expired.
@return boolean|string If the named preference is not defined or has expired, returns FALSE; otherwise it returns the preference
@see getPreference()
|
[
"Does",
"the",
"named",
"preference",
"exist",
"or",
"not?"
] |
76d42678b28d0d4fe25f09271b76262280de3d97
|
https://github.com/oss2/doctrine2/blob/76d42678b28d0d4fe25f09271b76262280de3d97/src/Oss2/Doctrine2/WithPreferences.php#L118-L121
|
3,810 |
oss2/doctrine2
|
src/Oss2/Doctrine2/WithPreferences.php
|
WithPreferences.getPreference
|
public function getPreference( $name, $index = null, $includeExpired = false )
{
$pref = $this->loadPreference( $name, $index, $includeExpired );
if( !$pref )
return false;
return $pref->getValue();
}
|
php
|
public function getPreference( $name, $index = null, $includeExpired = false )
{
$pref = $this->loadPreference( $name, $index, $includeExpired );
if( !$pref )
return false;
return $pref->getValue();
}
|
[
"public",
"function",
"getPreference",
"(",
"$",
"name",
",",
"$",
"index",
"=",
"null",
",",
"$",
"includeExpired",
"=",
"false",
")",
"{",
"$",
"pref",
"=",
"$",
"this",
"->",
"loadPreference",
"(",
"$",
"name",
",",
"$",
"index",
",",
"$",
"includeExpired",
")",
";",
"if",
"(",
"!",
"$",
"pref",
")",
"return",
"false",
";",
"return",
"$",
"pref",
"->",
"getValue",
"(",
")",
";",
"}"
] |
Get the named preference's VALUE
WARNING: Evaluate the return of this function using !== or === as a preference such as '0'
will evaluate as false otherwise.
@param string $name The named attribute / preference to check for
@param int $index default null If an indexed preference, get a specific index
@param boolean $includeExpired default false If true, include preferences even if they have expired.
@return boolean|string If the named preference is not defined or has expired, returns FALSE; otherwise it returns the preference
@see loadPreference()
|
[
"Get",
"the",
"named",
"preference",
"s",
"VALUE"
] |
76d42678b28d0d4fe25f09271b76262280de3d97
|
https://github.com/oss2/doctrine2/blob/76d42678b28d0d4fe25f09271b76262280de3d97/src/Oss2/Doctrine2/WithPreferences.php#L136-L144
|
3,811 |
oss2/doctrine2
|
src/Oss2/Doctrine2/WithPreferences.php
|
WithPreferences.setPreference
|
public function setPreference( $name, $value, $expires = null, $index = null )
{
$pref = $this->loadPreference( $name, $index );
if( is_int( $expires ) )
$expires = new \DateTime( date( 'Y-m-d H:i:s', $expires ) );
elseif( is_string( $expires ) )
$expires = new \DateTime( $expires );
if( $pref )
{
$pref->setValue( $value );
$pref->setExpiresAt( $expires );
$pref->setIx( $index );
return $this;
}
$pref = $this->_createPreferenceEntity( $this );
$pref->setName( $name );
$pref->setValue( $value );
$pref->setCreatedAt( new \DateTime() );
$pref->setExpiresAt( $expires );
$pref->setIx( $index );
\D2EM::persist( $pref );
return $this;
}
|
php
|
public function setPreference( $name, $value, $expires = null, $index = null )
{
$pref = $this->loadPreference( $name, $index );
if( is_int( $expires ) )
$expires = new \DateTime( date( 'Y-m-d H:i:s', $expires ) );
elseif( is_string( $expires ) )
$expires = new \DateTime( $expires );
if( $pref )
{
$pref->setValue( $value );
$pref->setExpiresAt( $expires );
$pref->setIx( $index );
return $this;
}
$pref = $this->_createPreferenceEntity( $this );
$pref->setName( $name );
$pref->setValue( $value );
$pref->setCreatedAt( new \DateTime() );
$pref->setExpiresAt( $expires );
$pref->setIx( $index );
\D2EM::persist( $pref );
return $this;
}
|
[
"public",
"function",
"setPreference",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"expires",
"=",
"null",
",",
"$",
"index",
"=",
"null",
")",
"{",
"$",
"pref",
"=",
"$",
"this",
"->",
"loadPreference",
"(",
"$",
"name",
",",
"$",
"index",
")",
";",
"if",
"(",
"is_int",
"(",
"$",
"expires",
")",
")",
"$",
"expires",
"=",
"new",
"\\",
"DateTime",
"(",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"$",
"expires",
")",
")",
";",
"elseif",
"(",
"is_string",
"(",
"$",
"expires",
")",
")",
"$",
"expires",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"expires",
")",
";",
"if",
"(",
"$",
"pref",
")",
"{",
"$",
"pref",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"$",
"pref",
"->",
"setExpiresAt",
"(",
"$",
"expires",
")",
";",
"$",
"pref",
"->",
"setIx",
"(",
"$",
"index",
")",
";",
"return",
"$",
"this",
";",
"}",
"$",
"pref",
"=",
"$",
"this",
"->",
"_createPreferenceEntity",
"(",
"$",
"this",
")",
";",
"$",
"pref",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"$",
"pref",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"$",
"pref",
"->",
"setCreatedAt",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
";",
"$",
"pref",
"->",
"setExpiresAt",
"(",
"$",
"expires",
")",
";",
"$",
"pref",
"->",
"setIx",
"(",
"$",
"index",
")",
";",
"\\",
"D2EM",
"::",
"persist",
"(",
"$",
"pref",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set or update a preference
@param string $name The preference name
@param string $value The value to assign to the preference
@param int|string|object $expires default null The expiry as a UNIX timestamp, \DateTime string or \DateTime object. null means never.
@param int $index default null If an indexed preference, set a specific index number.
@return \Oss2\Doctrine2\WithPreferences An instance of this object for fluid interfaces.
|
[
"Set",
"or",
"update",
"a",
"preference"
] |
76d42678b28d0d4fe25f09271b76262280de3d97
|
https://github.com/oss2/doctrine2/blob/76d42678b28d0d4fe25f09271b76262280de3d97/src/Oss2/Doctrine2/WithPreferences.php#L156-L184
|
3,812 |
oss2/doctrine2
|
src/Oss2/Doctrine2/WithPreferences.php
|
WithPreferences.addIndexedPreference
|
public function addIndexedPreference( $name, $value, $expires = null, $max = 0 )
{
// what's the current highest index and how many is there?
$highest = -1;
$count = 0;
foreach( $this->getPreferences() as $pref )
{
if( $pref->getName() == $name )
{
$count++;
if( $pref->getIx() > $highest )
$highest = $pref->getIx();
}
}
if( $max && ( $count >= $max ) )
throw new IndexLimitException( 'Requested maximum number of indexed preferences reached' );
if( is_array( $value ) )
{
foreach( $value as $v )
$this->setPreference( $name, $value, $expires, ++$highest );
}
else
{
$this->setPreference( $name, $value, $expires, ++$highest );
}
return $this;
}
|
php
|
public function addIndexedPreference( $name, $value, $expires = null, $max = 0 )
{
// what's the current highest index and how many is there?
$highest = -1;
$count = 0;
foreach( $this->getPreferences() as $pref )
{
if( $pref->getName() == $name )
{
$count++;
if( $pref->getIx() > $highest )
$highest = $pref->getIx();
}
}
if( $max && ( $count >= $max ) )
throw new IndexLimitException( 'Requested maximum number of indexed preferences reached' );
if( is_array( $value ) )
{
foreach( $value as $v )
$this->setPreference( $name, $value, $expires, ++$highest );
}
else
{
$this->setPreference( $name, $value, $expires, ++$highest );
}
return $this;
}
|
[
"public",
"function",
"addIndexedPreference",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"expires",
"=",
"null",
",",
"$",
"max",
"=",
"0",
")",
"{",
"// what's the current highest index and how many is there?",
"$",
"highest",
"=",
"-",
"1",
";",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPreferences",
"(",
")",
"as",
"$",
"pref",
")",
"{",
"if",
"(",
"$",
"pref",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"{",
"$",
"count",
"++",
";",
"if",
"(",
"$",
"pref",
"->",
"getIx",
"(",
")",
">",
"$",
"highest",
")",
"$",
"highest",
"=",
"$",
"pref",
"->",
"getIx",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"max",
"&&",
"(",
"$",
"count",
">=",
"$",
"max",
")",
")",
"throw",
"new",
"IndexLimitException",
"(",
"'Requested maximum number of indexed preferences reached'",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"v",
")",
"$",
"this",
"->",
"setPreference",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"expires",
",",
"++",
"$",
"highest",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setPreference",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"expires",
",",
"++",
"$",
"highest",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add an indexed preference
Let's say we need to add a list of email addresses as a preference where the following is
the list:
$emails = [ '[email protected]', '[email protected]', '[email protected]' ];
then we could add these as an indexed preference as follows for a given User $u:
$u->addPreference( 'mailing_list.goalies.email', $emails );
which would result in database entries as follows:
attribute index op value
------------------------------------------------------
| mailing_list.goalies.email | 0 | = | [email protected] |
| mailing_list.goalies.email | 1 | = | [email protected] |
| mailing_list.goalies.email | 2 | = | [email protected] |
------------------------------------------------------
we could then add a fourth address as follows:
$u->addPreference( 'mailing_list.goalies.email', '[email protected]' );
which would result in database entries as follows:
attribute index op value
------------------------------------------------------
| mailing_list.goalies.email | 0 | = | [email protected] |
| mailing_list.goalies.email | 1 | = | [email protected] |
| mailing_list.goalies.email | 2 | = | [email protected] |
| mailing_list.goalies.email | 3 | = | [email protected] |
------------------------------------------------------
===== BEGIN NOT IMPLEMENTED =====
If out list was to be of names and emails, then we could create an array as follows:
$emails = [
[ 'name' => 'John Smith', 'email' => '[email protected]' ],
[ 'name' => 'David Blue', 'email' => '[email protected]' ]
];
then we could add these as an indexed preference as follows for a given User $u:
$u->addPreference( 'mailing_list.goalies', $emails );
which would result in database entries as follows:
attribute index op value
--------------------------------------------------------
| mailing_list.goalies!email | 0 | = | [email protected] |
| mailing_list.goalies!name | 0 | = | John Smith |
| mailing_list.goalies!email | 1 | = | [email protected] |
| mailing_list.goalies!name | 1 | = | David Blue |
--------------------------------------------------------
We can further be specific on operator for each one as follows:
$emails = [
[ 'name' => [ value = 'John Smith', expires = '123456789' ] ]
];
Note that in the above form, value is required but if expires is not set, it will be taken from the function parameters.
===== END NOT IMPLEMENTED =====
@param string $name The preference name
@param string $value The value to assign to the preference
@param int $expires default null The expiry as a UNIX timestamp. null which means never.
@param int $max The maximum index allowed. Defaults to 0 meaning no limit.
@return \Oss2\Doctrine2\WithPreferences An instance of this object for fluid interfaces.
@throws \Oss2\Doctrine2\WithPreferences\IndexLimitException If $max is set and limit exceeded
|
[
"Add",
"an",
"indexed",
"preference"
] |
76d42678b28d0d4fe25f09271b76262280de3d97
|
https://github.com/oss2/doctrine2/blob/76d42678b28d0d4fe25f09271b76262280de3d97/src/Oss2/Doctrine2/WithPreferences.php#L264-L295
|
3,813 |
oss2/doctrine2
|
src/Oss2/Doctrine2/WithPreferences.php
|
WithPreferences.cleanExpiredPreferences
|
public function cleanExpiredPreferences( $asOf = null, $name = null )
{
$count = 0;
if( $asOf === null )
$asOf = new \DateTime();
elseif( is_int( $asOf ) )
$asOf = new \DateTime( date( 'Y-m-d H:i:s', $asOf ) );
elseif( is_string( $asOf ) )
$asOf = new \DateTime( $asOf );
foreach( $this->getPreferences() as $pref )
{
if( $name && ( $pref->getName() != $name ) )
continue;
if( $pref->getExpiresAt() && ( $pref->getExpiresAt() < $asOf ) )
{
$count++;
$this->getPreferences()->removeElement( $pref );
\D2EM::remove( $pref );
}
}
return $count;
}
|
php
|
public function cleanExpiredPreferences( $asOf = null, $name = null )
{
$count = 0;
if( $asOf === null )
$asOf = new \DateTime();
elseif( is_int( $asOf ) )
$asOf = new \DateTime( date( 'Y-m-d H:i:s', $asOf ) );
elseif( is_string( $asOf ) )
$asOf = new \DateTime( $asOf );
foreach( $this->getPreferences() as $pref )
{
if( $name && ( $pref->getName() != $name ) )
continue;
if( $pref->getExpiresAt() && ( $pref->getExpiresAt() < $asOf ) )
{
$count++;
$this->getPreferences()->removeElement( $pref );
\D2EM::remove( $pref );
}
}
return $count;
}
|
[
"public",
"function",
"cleanExpiredPreferences",
"(",
"$",
"asOf",
"=",
"null",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"count",
"=",
"0",
";",
"if",
"(",
"$",
"asOf",
"===",
"null",
")",
"$",
"asOf",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"elseif",
"(",
"is_int",
"(",
"$",
"asOf",
")",
")",
"$",
"asOf",
"=",
"new",
"\\",
"DateTime",
"(",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"$",
"asOf",
")",
")",
";",
"elseif",
"(",
"is_string",
"(",
"$",
"asOf",
")",
")",
"$",
"asOf",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"asOf",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPreferences",
"(",
")",
"as",
"$",
"pref",
")",
"{",
"if",
"(",
"$",
"name",
"&&",
"(",
"$",
"pref",
"->",
"getName",
"(",
")",
"!=",
"$",
"name",
")",
")",
"continue",
";",
"if",
"(",
"$",
"pref",
"->",
"getExpiresAt",
"(",
")",
"&&",
"(",
"$",
"pref",
"->",
"getExpiresAt",
"(",
")",
"<",
"$",
"asOf",
")",
")",
"{",
"$",
"count",
"++",
";",
"$",
"this",
"->",
"getPreferences",
"(",
")",
"->",
"removeElement",
"(",
"$",
"pref",
")",
";",
"\\",
"D2EM",
"::",
"remove",
"(",
"$",
"pref",
")",
";",
"}",
"}",
"return",
"$",
"count",
";",
"}"
] |
Clean expired preferences
Cleans preferences with an expiry date less than $asOf but not set to null (never expires).
WARNING: You need to EntityManager::flush() if the return > 0!
@param int|object|string $asOf default null A \DateTime object or date(time) string or Unix timestamp for the expriy, null means now
@param string $name default null Limit it to the specified attributes, null means all attributes
@return int The number of preferences deleted
|
[
"Clean",
"expired",
"preferences"
] |
76d42678b28d0d4fe25f09271b76262280de3d97
|
https://github.com/oss2/doctrine2/blob/76d42678b28d0d4fe25f09271b76262280de3d97/src/Oss2/Doctrine2/WithPreferences.php#L309-L334
|
3,814 |
oss2/doctrine2
|
src/Oss2/Doctrine2/WithPreferences.php
|
WithPreferences.deletePreference
|
public function deletePreference( $name, $index = null )
{
$count = 0;
foreach( $this->getPreferences() as $pref )
{
if( ( $pref->getName() == $name ) && ( ( $index === null ) || ( $pref->getIx() == $index ) ) )
{
$count++;
$this->getPreferences()->removeElement( $pref );
\D2EM::remove( $pref );
}
}
return $count;
}
|
php
|
public function deletePreference( $name, $index = null )
{
$count = 0;
foreach( $this->getPreferences() as $pref )
{
if( ( $pref->getName() == $name ) && ( ( $index === null ) || ( $pref->getIx() == $index ) ) )
{
$count++;
$this->getPreferences()->removeElement( $pref );
\D2EM::remove( $pref );
}
}
return $count;
}
|
[
"public",
"function",
"deletePreference",
"(",
"$",
"name",
",",
"$",
"index",
"=",
"null",
")",
"{",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPreferences",
"(",
")",
"as",
"$",
"pref",
")",
"{",
"if",
"(",
"(",
"$",
"pref",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"&&",
"(",
"(",
"$",
"index",
"===",
"null",
")",
"||",
"(",
"$",
"pref",
"->",
"getIx",
"(",
")",
"==",
"$",
"index",
")",
")",
")",
"{",
"$",
"count",
"++",
";",
"$",
"this",
"->",
"getPreferences",
"(",
")",
"->",
"removeElement",
"(",
"$",
"pref",
")",
";",
"\\",
"D2EM",
"::",
"remove",
"(",
"$",
"pref",
")",
";",
"}",
"}",
"return",
"$",
"count",
";",
"}"
] |
Delete the named preference
WARNING: You need to EntityManager::flush() if the return > 0!
@param string $name The named attribute / preference to check for
@param int $index default null If an indexed preference then delete a specific index, if null then delete all
@return int The number of preferences deleted
|
[
"Delete",
"the",
"named",
"preference"
] |
76d42678b28d0d4fe25f09271b76262280de3d97
|
https://github.com/oss2/doctrine2/blob/76d42678b28d0d4fe25f09271b76262280de3d97/src/Oss2/Doctrine2/WithPreferences.php#L346-L361
|
3,815 |
oss2/doctrine2
|
src/Oss2/Doctrine2/WithPreferences.php
|
WithPreferences.expungePreferences
|
public function expungePreferences()
{
return \D2EM::createQuery( 'delete \\Entities\\' . $this->_getPreferenceClassName() . ' up where up.' . $this->_getShortClassname() . ' = ?1' )
->setParameter( 1, $this )
->execute();
}
|
php
|
public function expungePreferences()
{
return \D2EM::createQuery( 'delete \\Entities\\' . $this->_getPreferenceClassName() . ' up where up.' . $this->_getShortClassname() . ' = ?1' )
->setParameter( 1, $this )
->execute();
}
|
[
"public",
"function",
"expungePreferences",
"(",
")",
"{",
"return",
"\\",
"D2EM",
"::",
"createQuery",
"(",
"'delete \\\\Entities\\\\'",
".",
"$",
"this",
"->",
"_getPreferenceClassName",
"(",
")",
".",
"' up where up.'",
".",
"$",
"this",
"->",
"_getShortClassname",
"(",
")",
".",
"' = ?1'",
")",
"->",
"setParameter",
"(",
"1",
",",
"$",
"this",
")",
"->",
"execute",
"(",
")",
";",
"}"
] |
Deletes all preferences.
@param void
@return int The number of preferences deleted
|
[
"Deletes",
"all",
"preferences",
"."
] |
76d42678b28d0d4fe25f09271b76262280de3d97
|
https://github.com/oss2/doctrine2/blob/76d42678b28d0d4fe25f09271b76262280de3d97/src/Oss2/Doctrine2/WithPreferences.php#L370-L375
|
3,816 |
oss2/doctrine2
|
src/Oss2/Doctrine2/WithPreferences.php
|
WithPreferences.getIndexedPreference
|
public function getIndexedPreference( $name, $withIndex = false, $ignoreExpired = true )
{
$values = [];
foreach( $this->getPreferences() as $pref )
{
if( $pref->getName() == $name )
{
if( $ignoreExpired && $pref->getExpiresAt() && ( $pref->getExpiresAt() < new \DateTime() ) )
continue;
if( $withIndex )
$values[ $pref->getIx() ] = [ 'index' => $pref->getIx(), 'value' => $pref->getValue() ];
else
$values[ $pref->getIx() ] = $pref->getValue();
}
}
ksort( $values, SORT_NUMERIC );
return $values;
}
|
php
|
public function getIndexedPreference( $name, $withIndex = false, $ignoreExpired = true )
{
$values = [];
foreach( $this->getPreferences() as $pref )
{
if( $pref->getName() == $name )
{
if( $ignoreExpired && $pref->getExpiresAt() && ( $pref->getExpiresAt() < new \DateTime() ) )
continue;
if( $withIndex )
$values[ $pref->getIx() ] = [ 'index' => $pref->getIx(), 'value' => $pref->getValue() ];
else
$values[ $pref->getIx() ] = $pref->getValue();
}
}
ksort( $values, SORT_NUMERIC );
return $values;
}
|
[
"public",
"function",
"getIndexedPreference",
"(",
"$",
"name",
",",
"$",
"withIndex",
"=",
"false",
",",
"$",
"ignoreExpired",
"=",
"true",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPreferences",
"(",
")",
"as",
"$",
"pref",
")",
"{",
"if",
"(",
"$",
"pref",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"ignoreExpired",
"&&",
"$",
"pref",
"->",
"getExpiresAt",
"(",
")",
"&&",
"(",
"$",
"pref",
"->",
"getExpiresAt",
"(",
")",
"<",
"new",
"\\",
"DateTime",
"(",
")",
")",
")",
"continue",
";",
"if",
"(",
"$",
"withIndex",
")",
"$",
"values",
"[",
"$",
"pref",
"->",
"getIx",
"(",
")",
"]",
"=",
"[",
"'index'",
"=>",
"$",
"pref",
"->",
"getIx",
"(",
")",
",",
"'value'",
"=>",
"$",
"pref",
"->",
"getValue",
"(",
")",
"]",
";",
"else",
"$",
"values",
"[",
"$",
"pref",
"->",
"getIx",
"(",
")",
"]",
"=",
"$",
"pref",
"->",
"getValue",
"(",
")",
";",
"}",
"}",
"ksort",
"(",
"$",
"values",
",",
"SORT_NUMERIC",
")",
";",
"return",
"$",
"values",
";",
"}"
] |
Get indexed preferences as an array
The standard response is an array of scalar values such as:
[ 'a', 'b', 'c' ];
If $withIndex is set to true, then it will be an array of associated arrays with the
index included:
[
[ 'p_index' => '0', 'p_value' => 'a' ],
[ 'p_index' => '1', 'p_value' => 'b' ],
[ 'p_index' => '2', 'p_value' => 'c' ]
);
@param string $name The attribute to load
@param boolean $withIndex default false Include index values.
@param boolean $ignoreExpired If set to false, include expired preferences
@return array an empty array if no such preference(s) exist
|
[
"Get",
"indexed",
"preferences",
"as",
"an",
"array"
] |
76d42678b28d0d4fe25f09271b76262280de3d97
|
https://github.com/oss2/doctrine2/blob/76d42678b28d0d4fe25f09271b76262280de3d97/src/Oss2/Doctrine2/WithPreferences.php#L399-L420
|
3,817 |
oss2/doctrine2
|
src/Oss2/Doctrine2/WithPreferences.php
|
WithPreferences.getAssocPreference
|
public function getAssocPreference( $name, $index = null, $ignoreExpired = true )
{
$values = [];
foreach( $this->getPreferences() as $pref )
{
if( strpos( $pref->getName(), $name ) === 0 )
{
if( ( $index === null ) || ( $pref->getIx() == $index ) )
{
if( !$ignoreExpired && $pref->getExpiresAt() && ( $pref->getExpiresAt() < new \DateTime() ) )
continue;
if( strpos( $pref->getName(), '.' ) !== false )
$key = substr( $pref->getName(), strlen( $name ) + 1 );
if( $key )
{
$key = $pref->getIx() . '.' . $key;
$values = $this->_processKey( $values, $key, $pref->getValue() );
}
else
{
$values[ $pref->getIx() ] = $pref->getValue();
}
}
}
}
if( $values === [] )
return false;
return $values;
}
|
php
|
public function getAssocPreference( $name, $index = null, $ignoreExpired = true )
{
$values = [];
foreach( $this->getPreferences() as $pref )
{
if( strpos( $pref->getName(), $name ) === 0 )
{
if( ( $index === null ) || ( $pref->getIx() == $index ) )
{
if( !$ignoreExpired && $pref->getExpiresAt() && ( $pref->getExpiresAt() < new \DateTime() ) )
continue;
if( strpos( $pref->getName(), '.' ) !== false )
$key = substr( $pref->getName(), strlen( $name ) + 1 );
if( $key )
{
$key = $pref->getIx() . '.' . $key;
$values = $this->_processKey( $values, $key, $pref->getValue() );
}
else
{
$values[ $pref->getIx() ] = $pref->getValue();
}
}
}
}
if( $values === [] )
return false;
return $values;
}
|
[
"public",
"function",
"getAssocPreference",
"(",
"$",
"name",
",",
"$",
"index",
"=",
"null",
",",
"$",
"ignoreExpired",
"=",
"true",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPreferences",
"(",
")",
"as",
"$",
"pref",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"pref",
"->",
"getName",
"(",
")",
",",
"$",
"name",
")",
"===",
"0",
")",
"{",
"if",
"(",
"(",
"$",
"index",
"===",
"null",
")",
"||",
"(",
"$",
"pref",
"->",
"getIx",
"(",
")",
"==",
"$",
"index",
")",
")",
"{",
"if",
"(",
"!",
"$",
"ignoreExpired",
"&&",
"$",
"pref",
"->",
"getExpiresAt",
"(",
")",
"&&",
"(",
"$",
"pref",
"->",
"getExpiresAt",
"(",
")",
"<",
"new",
"\\",
"DateTime",
"(",
")",
")",
")",
"continue",
";",
"if",
"(",
"strpos",
"(",
"$",
"pref",
"->",
"getName",
"(",
")",
",",
"'.'",
")",
"!==",
"false",
")",
"$",
"key",
"=",
"substr",
"(",
"$",
"pref",
"->",
"getName",
"(",
")",
",",
"strlen",
"(",
"$",
"name",
")",
"+",
"1",
")",
";",
"if",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"pref",
"->",
"getIx",
"(",
")",
".",
"'.'",
".",
"$",
"key",
";",
"$",
"values",
"=",
"$",
"this",
"->",
"_processKey",
"(",
"$",
"values",
",",
"$",
"key",
",",
"$",
"pref",
"->",
"getValue",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"values",
"[",
"$",
"pref",
"->",
"getIx",
"(",
")",
"]",
"=",
"$",
"pref",
"->",
"getValue",
"(",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"$",
"values",
"===",
"[",
"]",
")",
"return",
"false",
";",
"return",
"$",
"values",
";",
"}"
] |
Get associative preferences as an array.
For example, if we have preferences:
attribute email.address idx=0 value=1email
attribute email.confirmed idx=0 value=false
attribute email.tokens.0 idx=0 value=fwfddwde
attribute email.tokens.1 idx=0 value=fwewec4r
attribute email.address idx=1 value=2email
attribute email.confirmed idx=1 value=true
and if we search by `$name = 'email'` we will get:
[
0 => [
'address' => '1email',
'confirmed' => false,
'tokens' => [
0 => 'fwfddwde',
1 => 'fwewec4r'
]
],
1 => [
'address' => '2email',
'confirmed' => true
]
]
@param string $name The attribute to load
@param int $index default null If an indexed preference, get a specific index, null means all indexes alowed
@param boolean $ignoreExpired default true If set to false, then includes expired preferences
@return boolean|array False if no such preference(s) exist, otherwise an array.
|
[
"Get",
"associative",
"preferences",
"as",
"an",
"array",
"."
] |
76d42678b28d0d4fe25f09271b76262280de3d97
|
https://github.com/oss2/doctrine2/blob/76d42678b28d0d4fe25f09271b76262280de3d97/src/Oss2/Doctrine2/WithPreferences.php#L459-L492
|
3,818 |
gourmet/common
|
Model/Datasource/ArraySource.php
|
ArraySource.name
|
public function name($data) {
if (is_object($data) && isset($data->type)) {
return $data->value;
}
if ($data === '*') {
return '*';
}
if (is_array($data)) {
foreach ($data as $i => $dataItem) {
$data[$i] = $this->name($dataItem);
}
return $data;
}
return (string)$data;
}
|
php
|
public function name($data) {
if (is_object($data) && isset($data->type)) {
return $data->value;
}
if ($data === '*') {
return '*';
}
if (is_array($data)) {
foreach ($data as $i => $dataItem) {
$data[$i] = $this->name($dataItem);
}
return $data;
}
return (string)$data;
}
|
[
"public",
"function",
"name",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
"&&",
"isset",
"(",
"$",
"data",
"->",
"type",
")",
")",
"{",
"return",
"$",
"data",
"->",
"value",
";",
"}",
"if",
"(",
"$",
"data",
"===",
"'*'",
")",
"{",
"return",
"'*'",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"i",
"=>",
"$",
"dataItem",
")",
"{",
"$",
"data",
"[",
"$",
"i",
"]",
"=",
"$",
"this",
"->",
"name",
"(",
"$",
"dataItem",
")",
";",
"}",
"return",
"$",
"data",
";",
"}",
"return",
"(",
"string",
")",
"$",
"data",
";",
"}"
] |
Imitation of DboSource method.
@param mixed $data Either a string with a column to quote. An array of columns
to quote.
@return string SQL field
|
[
"Imitation",
"of",
"DboSource",
"method",
"."
] |
53ad4e919c51606dc81f2c716267d01ee768ade5
|
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Model/Datasource/ArraySource.php#L74-L88
|
3,819 |
gourmet/common
|
Model/Datasource/ArraySource.php
|
ArraySource.getLog
|
public function getLog($sorted = false, $clear = true) {
if ($sorted) {
$log = sortByKey($this->_requestsLog, 'took', 'desc', SORT_NUMERIC);
} else {
$log = $this->_requestsLog;
}
if ($clear) {
$this->_requestsLog = array();
}
return array('log' => $log, 'count' => count($log), 'time' => array_sum(Hash::extract($log, '{n}.took')));
}
|
php
|
public function getLog($sorted = false, $clear = true) {
if ($sorted) {
$log = sortByKey($this->_requestsLog, 'took', 'desc', SORT_NUMERIC);
} else {
$log = $this->_requestsLog;
}
if ($clear) {
$this->_requestsLog = array();
}
return array('log' => $log, 'count' => count($log), 'time' => array_sum(Hash::extract($log, '{n}.took')));
}
|
[
"public",
"function",
"getLog",
"(",
"$",
"sorted",
"=",
"false",
",",
"$",
"clear",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"sorted",
")",
"{",
"$",
"log",
"=",
"sortByKey",
"(",
"$",
"this",
"->",
"_requestsLog",
",",
"'took'",
",",
"'desc'",
",",
"SORT_NUMERIC",
")",
";",
"}",
"else",
"{",
"$",
"log",
"=",
"$",
"this",
"->",
"_requestsLog",
";",
"}",
"if",
"(",
"$",
"clear",
")",
"{",
"$",
"this",
"->",
"_requestsLog",
"=",
"array",
"(",
")",
";",
"}",
"return",
"array",
"(",
"'log'",
"=>",
"$",
"log",
",",
"'count'",
"=>",
"count",
"(",
"$",
"log",
")",
",",
"'time'",
"=>",
"array_sum",
"(",
"Hash",
"::",
"extract",
"(",
"$",
"log",
",",
"'{n}.took'",
")",
")",
")",
";",
"}"
] |
Get the query log as an array.
@param boolean $sorted Get the queries sorted by time taken, defaults to false.
@param boolean $clear Clear after return logs
@return array Array of queries run as an array
|
[
"Get",
"the",
"query",
"log",
"as",
"an",
"array",
"."
] |
53ad4e919c51606dc81f2c716267d01ee768ade5
|
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Model/Datasource/ArraySource.php#L444-L454
|
3,820 |
gourmet/common
|
Model/Datasource/ArraySource.php
|
ArraySource._registerLog
|
protected function _registerLog(Model $model, &$queryData, $took, $numRows) {
if (!Configure::read()) {
return;
}
$this->_requestsLog[] = array(
'query' => $this->_pseudoSelect($model, $queryData),
'error' => '',
'affected' => 0,
'numRows' => $numRows,
'took' => round($took, 3)
);
}
|
php
|
protected function _registerLog(Model $model, &$queryData, $took, $numRows) {
if (!Configure::read()) {
return;
}
$this->_requestsLog[] = array(
'query' => $this->_pseudoSelect($model, $queryData),
'error' => '',
'affected' => 0,
'numRows' => $numRows,
'took' => round($took, 3)
);
}
|
[
"protected",
"function",
"_registerLog",
"(",
"Model",
"$",
"model",
",",
"&",
"$",
"queryData",
",",
"$",
"took",
",",
"$",
"numRows",
")",
"{",
"if",
"(",
"!",
"Configure",
"::",
"read",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"_requestsLog",
"[",
"]",
"=",
"array",
"(",
"'query'",
"=>",
"$",
"this",
"->",
"_pseudoSelect",
"(",
"$",
"model",
",",
"$",
"queryData",
")",
",",
"'error'",
"=>",
"''",
",",
"'affected'",
"=>",
"0",
",",
"'numRows'",
"=>",
"$",
"numRows",
",",
"'took'",
"=>",
"round",
"(",
"$",
"took",
",",
"3",
")",
")",
";",
"}"
] |
Generate a log registry
@param object $model
@param array $queryData
@param float $took
@param integer $numRows
@return void
|
[
"Generate",
"a",
"log",
"registry"
] |
53ad4e919c51606dc81f2c716267d01ee768ade5
|
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Model/Datasource/ArraySource.php#L465-L476
|
3,821 |
gourmet/common
|
Model/Datasource/ArraySource.php
|
ArraySource._pseudoSelect
|
protected function _pseudoSelect(Model $model, &$queryData) {
$out = '(symbolic) SELECT ';
if (empty($queryData['fields'])) {
$out .= '*';
} elseif ($queryData['fields']) {
$out .= 'COUNT(*)';
} else {
$out .= implode(', ', $queryData['fields']);
}
$out .= ' FROM ' . $model->alias;
if (!empty($queryData['conditions'])) {
$out .= ' WHERE';
foreach ($queryData['conditions'] as $id => $condition) {
if (empty($condition)) {
continue;
}
if (is_array($condition)) {
$condition = '(' . implode(', ', $condition) . ')';
if (strpos($id, ' ') === false) {
$id .= ' IN';
}
}
if (is_string($id)) {
if (strpos($id, ' ') !== false) {
$condition = $id . ' ' . $condition;
} else {
$condition = $id . ' = ' . $condition;
}
}
if (preg_match('/^(\w+\.)?\w+ /', $condition, $matches)) {
if (!empty($matches[1]) && substr($matches[1], 0, -1) !== $model->alias) {
continue;
}
}
$out .= ' (' . $condition . ') &&';
}
$out = substr($out, 0, -3);
}
if (!empty($queryData['order'][0])) {
$out .= ' ORDER BY ' . implode(', ', $queryData['order']);
}
if (!empty($queryData['limit'])) {
$out .= ' LIMIT ' . (($queryData['page'] - 1) * $queryData['limit']) . ', ' . $queryData['limit'];
}
return $out;
}
|
php
|
protected function _pseudoSelect(Model $model, &$queryData) {
$out = '(symbolic) SELECT ';
if (empty($queryData['fields'])) {
$out .= '*';
} elseif ($queryData['fields']) {
$out .= 'COUNT(*)';
} else {
$out .= implode(', ', $queryData['fields']);
}
$out .= ' FROM ' . $model->alias;
if (!empty($queryData['conditions'])) {
$out .= ' WHERE';
foreach ($queryData['conditions'] as $id => $condition) {
if (empty($condition)) {
continue;
}
if (is_array($condition)) {
$condition = '(' . implode(', ', $condition) . ')';
if (strpos($id, ' ') === false) {
$id .= ' IN';
}
}
if (is_string($id)) {
if (strpos($id, ' ') !== false) {
$condition = $id . ' ' . $condition;
} else {
$condition = $id . ' = ' . $condition;
}
}
if (preg_match('/^(\w+\.)?\w+ /', $condition, $matches)) {
if (!empty($matches[1]) && substr($matches[1], 0, -1) !== $model->alias) {
continue;
}
}
$out .= ' (' . $condition . ') &&';
}
$out = substr($out, 0, -3);
}
if (!empty($queryData['order'][0])) {
$out .= ' ORDER BY ' . implode(', ', $queryData['order']);
}
if (!empty($queryData['limit'])) {
$out .= ' LIMIT ' . (($queryData['page'] - 1) * $queryData['limit']) . ', ' . $queryData['limit'];
}
return $out;
}
|
[
"protected",
"function",
"_pseudoSelect",
"(",
"Model",
"$",
"model",
",",
"&",
"$",
"queryData",
")",
"{",
"$",
"out",
"=",
"'(symbolic) SELECT '",
";",
"if",
"(",
"empty",
"(",
"$",
"queryData",
"[",
"'fields'",
"]",
")",
")",
"{",
"$",
"out",
".=",
"'*'",
";",
"}",
"elseif",
"(",
"$",
"queryData",
"[",
"'fields'",
"]",
")",
"{",
"$",
"out",
".=",
"'COUNT(*)'",
";",
"}",
"else",
"{",
"$",
"out",
".=",
"implode",
"(",
"', '",
",",
"$",
"queryData",
"[",
"'fields'",
"]",
")",
";",
"}",
"$",
"out",
".=",
"' FROM '",
".",
"$",
"model",
"->",
"alias",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"queryData",
"[",
"'conditions'",
"]",
")",
")",
"{",
"$",
"out",
".=",
"' WHERE'",
";",
"foreach",
"(",
"$",
"queryData",
"[",
"'conditions'",
"]",
"as",
"$",
"id",
"=>",
"$",
"condition",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"condition",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"condition",
")",
")",
"{",
"$",
"condition",
"=",
"'('",
".",
"implode",
"(",
"', '",
",",
"$",
"condition",
")",
".",
"')'",
";",
"if",
"(",
"strpos",
"(",
"$",
"id",
",",
"' '",
")",
"===",
"false",
")",
"{",
"$",
"id",
".=",
"' IN'",
";",
"}",
"}",
"if",
"(",
"is_string",
"(",
"$",
"id",
")",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"id",
",",
"' '",
")",
"!==",
"false",
")",
"{",
"$",
"condition",
"=",
"$",
"id",
".",
"' '",
".",
"$",
"condition",
";",
"}",
"else",
"{",
"$",
"condition",
"=",
"$",
"id",
".",
"' = '",
".",
"$",
"condition",
";",
"}",
"}",
"if",
"(",
"preg_match",
"(",
"'/^(\\w+\\.)?\\w+ /'",
",",
"$",
"condition",
",",
"$",
"matches",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
"&&",
"substr",
"(",
"$",
"matches",
"[",
"1",
"]",
",",
"0",
",",
"-",
"1",
")",
"!==",
"$",
"model",
"->",
"alias",
")",
"{",
"continue",
";",
"}",
"}",
"$",
"out",
".=",
"' ('",
".",
"$",
"condition",
".",
"') &&'",
";",
"}",
"$",
"out",
"=",
"substr",
"(",
"$",
"out",
",",
"0",
",",
"-",
"3",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"queryData",
"[",
"'order'",
"]",
"[",
"0",
"]",
")",
")",
"{",
"$",
"out",
".=",
"' ORDER BY '",
".",
"implode",
"(",
"', '",
",",
"$",
"queryData",
"[",
"'order'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"queryData",
"[",
"'limit'",
"]",
")",
")",
"{",
"$",
"out",
".=",
"' LIMIT '",
".",
"(",
"(",
"$",
"queryData",
"[",
"'page'",
"]",
"-",
"1",
")",
"*",
"$",
"queryData",
"[",
"'limit'",
"]",
")",
".",
"', '",
".",
"$",
"queryData",
"[",
"'limit'",
"]",
";",
"}",
"return",
"$",
"out",
";",
"}"
] |
Generate a pseudo select to log
@param object $model Model
@param array $queryData Query data sended by find
@return string Pseudo query
|
[
"Generate",
"a",
"pseudo",
"select",
"to",
"log"
] |
53ad4e919c51606dc81f2c716267d01ee768ade5
|
https://github.com/gourmet/common/blob/53ad4e919c51606dc81f2c716267d01ee768ade5/Model/Datasource/ArraySource.php#L485-L530
|
3,822 |
kevindierkx/elicit
|
src/ConnectionFactory.php
|
ConnectionFactory.addConnection
|
public function addConnection(array $config, $name = 'default')
{
$this->connectionResolver->addConnection(
$this->make($config),
$name
);
return $this;
}
|
php
|
public function addConnection(array $config, $name = 'default')
{
$this->connectionResolver->addConnection(
$this->make($config),
$name
);
return $this;
}
|
[
"public",
"function",
"addConnection",
"(",
"array",
"$",
"config",
",",
"$",
"name",
"=",
"'default'",
")",
"{",
"$",
"this",
"->",
"connectionResolver",
"->",
"addConnection",
"(",
"$",
"this",
"->",
"make",
"(",
"$",
"config",
")",
",",
"$",
"name",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Register a connection.
@param array $config
@param string $name
@return self
|
[
"Register",
"a",
"connection",
"."
] |
c277942f5f5f63b175bc37e9d392faa946888f65
|
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/ConnectionFactory.php#L42-L50
|
3,823 |
kevindierkx/elicit
|
src/ConnectionFactory.php
|
ConnectionFactory.createSingleConnection
|
protected function createSingleConnection(array $config)
{
$connector = $this->createConnector($config)->connect($config);
return $this->createConnection($connector, $config);
}
|
php
|
protected function createSingleConnection(array $config)
{
$connector = $this->createConnector($config)->connect($config);
return $this->createConnection($connector, $config);
}
|
[
"protected",
"function",
"createSingleConnection",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"connector",
"=",
"$",
"this",
"->",
"createConnector",
"(",
"$",
"config",
")",
"->",
"connect",
"(",
"$",
"config",
")",
";",
"return",
"$",
"this",
"->",
"createConnection",
"(",
"$",
"connector",
",",
"$",
"config",
")",
";",
"}"
] |
Create a single API connection instance.
@param array $config
@return ConnectionInterface
|
[
"Create",
"a",
"single",
"API",
"connection",
"instance",
"."
] |
c277942f5f5f63b175bc37e9d392faa946888f65
|
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/ConnectionFactory.php#L80-L85
|
3,824 |
rezzza/jobflow
|
src/Rezzza/Jobflow/Scheduler/Jobflow.php
|
Jobflow.handle
|
public function handle($msg)
{
if (!$msg instanceof JobMessage) {
if ($this->logger) {
$this->logger->info('No more message');
}
return false;
}
return $this->handleMsg($msg);
}
|
php
|
public function handle($msg)
{
if (!$msg instanceof JobMessage) {
if ($this->logger) {
$this->logger->info('No more message');
}
return false;
}
return $this->handleMsg($msg);
}
|
[
"public",
"function",
"handle",
"(",
"$",
"msg",
")",
"{",
"if",
"(",
"!",
"$",
"msg",
"instanceof",
"JobMessage",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"'No more message'",
")",
";",
"}",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"handleMsg",
"(",
"$",
"msg",
")",
";",
"}"
] |
Handle msg after its execution. If we need to create a new msg to continue execution or stop here
|
[
"Handle",
"msg",
"after",
"its",
"execution",
".",
"If",
"we",
"need",
"to",
"create",
"a",
"new",
"msg",
"to",
"continue",
"execution",
"or",
"stop",
"here"
] |
80ded8ac6ed6a2f4500b8f86e2958701ec84fd65
|
https://github.com/rezzza/jobflow/blob/80ded8ac6ed6a2f4500b8f86e2958701ec84fd65/src/Rezzza/Jobflow/Scheduler/Jobflow.php#L101-L112
|
3,825 |
gossi/trixionary
|
src/domain/base/ReferenceDomainTrait.php
|
ReferenceDomainTrait.addSkills
|
public function addSkills($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Reference not found.']);
}
// pass add to internal logic
try {
$this->doAddSkills($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(ReferenceEvent::PRE_SKILLS_ADD, $model, $data);
$this->dispatch(ReferenceEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(ReferenceEvent::POST_SKILLS_ADD, $model, $data);
$this->dispatch(ReferenceEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
}
|
php
|
public function addSkills($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Reference not found.']);
}
// pass add to internal logic
try {
$this->doAddSkills($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(ReferenceEvent::PRE_SKILLS_ADD, $model, $data);
$this->dispatch(ReferenceEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(ReferenceEvent::POST_SKILLS_ADD, $model, $data);
$this->dispatch(ReferenceEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
}
|
[
"public",
"function",
"addSkills",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"// find",
"$",
"model",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"return",
"new",
"NotFound",
"(",
"[",
"'message'",
"=>",
"'Reference not found.'",
"]",
")",
";",
"}",
"// pass add to internal logic",
"try",
"{",
"$",
"this",
"->",
"doAddSkills",
"(",
"$",
"model",
",",
"$",
"data",
")",
";",
"}",
"catch",
"(",
"ErrorsException",
"$",
"e",
")",
"{",
"return",
"new",
"NotValid",
"(",
"[",
"'errors'",
"=>",
"$",
"e",
"->",
"getErrors",
"(",
")",
"]",
")",
";",
"}",
"// save and dispatch events",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"PRE_SKILLS_ADD",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"PRE_SAVE",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"$",
"rows",
"=",
"$",
"model",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"POST_SKILLS_ADD",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"POST_SAVE",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"rows",
">",
"0",
")",
"{",
"return",
"Updated",
"(",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}",
"return",
"NotUpdated",
"(",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}"
] |
Adds Skills to Reference
@param mixed $id
@param mixed $data
@return PayloadInterface
|
[
"Adds",
"Skills",
"to",
"Reference"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/ReferenceDomainTrait.php#L41-L68
|
3,826 |
gossi/trixionary
|
src/domain/base/ReferenceDomainTrait.php
|
ReferenceDomainTrait.addVideos
|
public function addVideos($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Reference not found.']);
}
// pass add to internal logic
try {
$this->doAddVideos($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(ReferenceEvent::PRE_VIDEOS_ADD, $model, $data);
$this->dispatch(ReferenceEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(ReferenceEvent::POST_VIDEOS_ADD, $model, $data);
$this->dispatch(ReferenceEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
}
|
php
|
public function addVideos($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Reference not found.']);
}
// pass add to internal logic
try {
$this->doAddVideos($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(ReferenceEvent::PRE_VIDEOS_ADD, $model, $data);
$this->dispatch(ReferenceEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(ReferenceEvent::POST_VIDEOS_ADD, $model, $data);
$this->dispatch(ReferenceEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
}
|
[
"public",
"function",
"addVideos",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"// find",
"$",
"model",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"return",
"new",
"NotFound",
"(",
"[",
"'message'",
"=>",
"'Reference not found.'",
"]",
")",
";",
"}",
"// pass add to internal logic",
"try",
"{",
"$",
"this",
"->",
"doAddVideos",
"(",
"$",
"model",
",",
"$",
"data",
")",
";",
"}",
"catch",
"(",
"ErrorsException",
"$",
"e",
")",
"{",
"return",
"new",
"NotValid",
"(",
"[",
"'errors'",
"=>",
"$",
"e",
"->",
"getErrors",
"(",
")",
"]",
")",
";",
"}",
"// save and dispatch events",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"PRE_VIDEOS_ADD",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"PRE_SAVE",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"$",
"rows",
"=",
"$",
"model",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"POST_VIDEOS_ADD",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"POST_SAVE",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"rows",
">",
"0",
")",
"{",
"return",
"Updated",
"(",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}",
"return",
"NotUpdated",
"(",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}"
] |
Adds Videos to Reference
@param mixed $id
@param mixed $data
@return PayloadInterface
|
[
"Adds",
"Videos",
"to",
"Reference"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/ReferenceDomainTrait.php#L77-L104
|
3,827 |
gossi/trixionary
|
src/domain/base/ReferenceDomainTrait.php
|
ReferenceDomainTrait.updateSkills
|
public function updateSkills($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Reference not found.']);
}
// pass update to internal logic
try {
$this->doUpdateSkills($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(ReferenceEvent::PRE_SKILLS_UPDATE, $model, $data);
$this->dispatch(ReferenceEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(ReferenceEvent::POST_SKILLS_UPDATE, $model, $data);
$this->dispatch(ReferenceEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
}
|
php
|
public function updateSkills($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Reference not found.']);
}
// pass update to internal logic
try {
$this->doUpdateSkills($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(ReferenceEvent::PRE_SKILLS_UPDATE, $model, $data);
$this->dispatch(ReferenceEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(ReferenceEvent::POST_SKILLS_UPDATE, $model, $data);
$this->dispatch(ReferenceEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
}
|
[
"public",
"function",
"updateSkills",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"// find",
"$",
"model",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"return",
"new",
"NotFound",
"(",
"[",
"'message'",
"=>",
"'Reference not found.'",
"]",
")",
";",
"}",
"// pass update to internal logic",
"try",
"{",
"$",
"this",
"->",
"doUpdateSkills",
"(",
"$",
"model",
",",
"$",
"data",
")",
";",
"}",
"catch",
"(",
"ErrorsException",
"$",
"e",
")",
"{",
"return",
"new",
"NotValid",
"(",
"[",
"'errors'",
"=>",
"$",
"e",
"->",
"getErrors",
"(",
")",
"]",
")",
";",
"}",
"// save and dispatch events",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"PRE_SKILLS_UPDATE",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"PRE_SAVE",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"$",
"rows",
"=",
"$",
"model",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"POST_SKILLS_UPDATE",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"POST_SAVE",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"rows",
">",
"0",
")",
"{",
"return",
"Updated",
"(",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}",
"return",
"NotUpdated",
"(",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}"
] |
Updates Skills on Reference
@param mixed $id
@param mixed $data
@return PayloadInterface
|
[
"Updates",
"Skills",
"on",
"Reference"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/ReferenceDomainTrait.php#L345-L372
|
3,828 |
gossi/trixionary
|
src/domain/base/ReferenceDomainTrait.php
|
ReferenceDomainTrait.updateVideos
|
public function updateVideos($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Reference not found.']);
}
// pass update to internal logic
try {
$this->doUpdateVideos($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(ReferenceEvent::PRE_VIDEOS_UPDATE, $model, $data);
$this->dispatch(ReferenceEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(ReferenceEvent::POST_VIDEOS_UPDATE, $model, $data);
$this->dispatch(ReferenceEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
}
|
php
|
public function updateVideos($id, $data) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Reference not found.']);
}
// pass update to internal logic
try {
$this->doUpdateVideos($model, $data);
} catch (ErrorsException $e) {
return new NotValid(['errors' => $e->getErrors()]);
}
// save and dispatch events
$this->dispatch(ReferenceEvent::PRE_VIDEOS_UPDATE, $model, $data);
$this->dispatch(ReferenceEvent::PRE_SAVE, $model, $data);
$rows = $model->save();
$this->dispatch(ReferenceEvent::POST_VIDEOS_UPDATE, $model, $data);
$this->dispatch(ReferenceEvent::POST_SAVE, $model, $data);
if ($rows > 0) {
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
}
|
[
"public",
"function",
"updateVideos",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"// find",
"$",
"model",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"return",
"new",
"NotFound",
"(",
"[",
"'message'",
"=>",
"'Reference not found.'",
"]",
")",
";",
"}",
"// pass update to internal logic",
"try",
"{",
"$",
"this",
"->",
"doUpdateVideos",
"(",
"$",
"model",
",",
"$",
"data",
")",
";",
"}",
"catch",
"(",
"ErrorsException",
"$",
"e",
")",
"{",
"return",
"new",
"NotValid",
"(",
"[",
"'errors'",
"=>",
"$",
"e",
"->",
"getErrors",
"(",
")",
"]",
")",
";",
"}",
"// save and dispatch events",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"PRE_VIDEOS_UPDATE",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"PRE_SAVE",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"$",
"rows",
"=",
"$",
"model",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"POST_VIDEOS_UPDATE",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"ReferenceEvent",
"::",
"POST_SAVE",
",",
"$",
"model",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"rows",
">",
"0",
")",
"{",
"return",
"Updated",
"(",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}",
"return",
"NotUpdated",
"(",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}"
] |
Updates Videos on Reference
@param mixed $id
@param mixed $data
@return PayloadInterface
|
[
"Updates",
"Videos",
"on",
"Reference"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/ReferenceDomainTrait.php#L381-L408
|
3,829 |
gossi/trixionary
|
src/domain/base/ReferenceDomainTrait.php
|
ReferenceDomainTrait.doAddVideos
|
protected function doAddVideos(Reference $model, $data) {
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Video';
} else {
$related = VideoQuery::create()->findOneById($entry['id']);
$model->addVideo($related);
}
}
if (count($errors) > 0) {
return new ErrorsException($errors);
}
}
|
php
|
protected function doAddVideos(Reference $model, $data) {
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Video';
} else {
$related = VideoQuery::create()->findOneById($entry['id']);
$model->addVideo($related);
}
}
if (count($errors) > 0) {
return new ErrorsException($errors);
}
}
|
[
"protected",
"function",
"doAddVideos",
"(",
"Reference",
"$",
"model",
",",
"$",
"data",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"entry",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"'Missing id for Video'",
";",
"}",
"else",
"{",
"$",
"related",
"=",
"VideoQuery",
"::",
"create",
"(",
")",
"->",
"findOneById",
"(",
"$",
"entry",
"[",
"'id'",
"]",
")",
";",
"$",
"model",
"->",
"addVideo",
"(",
"$",
"related",
")",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"errors",
")",
">",
"0",
")",
"{",
"return",
"new",
"ErrorsException",
"(",
"$",
"errors",
")",
";",
"}",
"}"
] |
Interal mechanism to add Videos to Reference
@param Reference $model
@param mixed $data
|
[
"Interal",
"mechanism",
"to",
"add",
"Videos",
"to",
"Reference"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/ReferenceDomainTrait.php#L510-L524
|
3,830 |
gossi/trixionary
|
src/domain/base/ReferenceDomainTrait.php
|
ReferenceDomainTrait.doUpdateSkills
|
protected function doUpdateSkills(Reference $model, $data) {
// remove all relationships before
SkillReferenceQuery::create()->filterByReference($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(Reference $model, $data) {
// remove all relationships before
SkillReferenceQuery::create()->filterByReference($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",
"(",
"Reference",
"$",
"model",
",",
"$",
"data",
")",
"{",
"// remove all relationships before",
"SkillReferenceQuery",
"::",
"create",
"(",
")",
"->",
"filterByReference",
"(",
"$",
"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",
")",
";",
"}",
"}"
] |
Internal update mechanism of Skills on Reference
@param Reference $model
@param mixed $data
|
[
"Internal",
"update",
"mechanism",
"of",
"Skills",
"on",
"Reference"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/ReferenceDomainTrait.php#L576-L594
|
3,831 |
gossi/trixionary
|
src/domain/base/ReferenceDomainTrait.php
|
ReferenceDomainTrait.doUpdateVideos
|
protected function doUpdateVideos(Reference $model, $data) {
// remove all relationships before
VideoQuery::create()->filterByReference($model)->delete();
// add them
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Video';
} else {
$related = VideoQuery::create()->findOneById($entry['id']);
$model->addVideo($related);
}
}
if (count($errors) > 0) {
throw new ErrorsException($errors);
}
}
|
php
|
protected function doUpdateVideos(Reference $model, $data) {
// remove all relationships before
VideoQuery::create()->filterByReference($model)->delete();
// add them
$errors = [];
foreach ($data as $entry) {
if (!isset($entry['id'])) {
$errors[] = 'Missing id for Video';
} else {
$related = VideoQuery::create()->findOneById($entry['id']);
$model->addVideo($related);
}
}
if (count($errors) > 0) {
throw new ErrorsException($errors);
}
}
|
[
"protected",
"function",
"doUpdateVideos",
"(",
"Reference",
"$",
"model",
",",
"$",
"data",
")",
"{",
"// remove all relationships before",
"VideoQuery",
"::",
"create",
"(",
")",
"->",
"filterByReference",
"(",
"$",
"model",
")",
"->",
"delete",
"(",
")",
";",
"// add them",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"entry",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"'Missing id for Video'",
";",
"}",
"else",
"{",
"$",
"related",
"=",
"VideoQuery",
"::",
"create",
"(",
")",
"->",
"findOneById",
"(",
"$",
"entry",
"[",
"'id'",
"]",
")",
";",
"$",
"model",
"->",
"addVideo",
"(",
"$",
"related",
")",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"errors",
")",
">",
"0",
")",
"{",
"throw",
"new",
"ErrorsException",
"(",
"$",
"errors",
")",
";",
"}",
"}"
] |
Internal update mechanism of Videos on Reference
@param Reference $model
@param mixed $data
|
[
"Internal",
"update",
"mechanism",
"of",
"Videos",
"on",
"Reference"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/ReferenceDomainTrait.php#L602-L620
|
3,832 |
gliverphp/helpers
|
src/Session/Session.php
|
Session.get
|
public static function get($key)
{
//check if this key exists
$exists = (isset($_SESSION[$key])) ? true : false;
//return check status if false
if ( ! $exists) return $exists;
//return the session data if found
else return $_SESSION[$key];
}
|
php
|
public static function get($key)
{
//check if this key exists
$exists = (isset($_SESSION[$key])) ? true : false;
//return check status if false
if ( ! $exists) return $exists;
//return the session data if found
else return $_SESSION[$key];
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"//check if this key exists ",
"$",
"exists",
"=",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"key",
"]",
")",
")",
"?",
"true",
":",
"false",
";",
"//return check status if false",
"if",
"(",
"!",
"$",
"exists",
")",
"return",
"$",
"exists",
";",
"//return the session data if found",
"else",
"return",
"$",
"_SESSION",
"[",
"$",
"key",
"]",
";",
"}"
] |
This method returns a session data by key
@param string $key The key with which to search session data
@return mixed The value stored in session
|
[
"This",
"method",
"returns",
"a",
"session",
"data",
"by",
"key"
] |
c5204df8169fad55f5b273422e45f56164373ab8
|
https://github.com/gliverphp/helpers/blob/c5204df8169fad55f5b273422e45f56164373ab8/src/Session/Session.php#L66-L77
|
3,833 |
orkestra/orkestra-transactor
|
lib/Orkestra/Transactor/Entity/AbstractAccount.php
|
AbstractAccount.setAccountNumber
|
public function setAccountNumber($accountNumber)
{
$this->accountNumber = (string) $accountNumber;
$this->lastFour = substr((string) $accountNumber,-4);
}
|
php
|
public function setAccountNumber($accountNumber)
{
$this->accountNumber = (string) $accountNumber;
$this->lastFour = substr((string) $accountNumber,-4);
}
|
[
"public",
"function",
"setAccountNumber",
"(",
"$",
"accountNumber",
")",
"{",
"$",
"this",
"->",
"accountNumber",
"=",
"(",
"string",
")",
"$",
"accountNumber",
";",
"$",
"this",
"->",
"lastFour",
"=",
"substr",
"(",
"(",
"string",
")",
"$",
"accountNumber",
",",
"-",
"4",
")",
";",
"}"
] |
Set Account Number
@param string $accountNumber
|
[
"Set",
"Account",
"Number"
] |
0edaeb756f22c2d25d6fa2da4793df9b343f8811
|
https://github.com/orkestra/orkestra-transactor/blob/0edaeb756f22c2d25d6fa2da4793df9b343f8811/lib/Orkestra/Transactor/Entity/AbstractAccount.php#L179-L183
|
3,834 |
jfortunato/fortune
|
src/Routing/SlimRouteGenerator.php
|
SlimRouteGenerator.generateGetAll
|
protected function generateGetAll(ResourceConfiguration $config)
{
$that = $this;
$this->slim->get($this->baseRoute($config), function () use ($that) {
$that->executeRoute('index', func_get_args());
});
}
|
php
|
protected function generateGetAll(ResourceConfiguration $config)
{
$that = $this;
$this->slim->get($this->baseRoute($config), function () use ($that) {
$that->executeRoute('index', func_get_args());
});
}
|
[
"protected",
"function",
"generateGetAll",
"(",
"ResourceConfiguration",
"$",
"config",
")",
"{",
"$",
"that",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"slim",
"->",
"get",
"(",
"$",
"this",
"->",
"baseRoute",
"(",
"$",
"config",
")",
",",
"function",
"(",
")",
"use",
"(",
"$",
"that",
")",
"{",
"$",
"that",
"->",
"executeRoute",
"(",
"'index'",
",",
"func_get_args",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] |
Generates the index route.
@param ResourceConfiguration $config
@return void
|
[
"Generates",
"the",
"index",
"route",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Routing/SlimRouteGenerator.php#L67-L74
|
3,835 |
jfortunato/fortune
|
src/Routing/SlimRouteGenerator.php
|
SlimRouteGenerator.generateGetSingle
|
protected function generateGetSingle(ResourceConfiguration $config)
{
$that = $this;
$this->slim->get("{$this->baseRoute($config)}/:id", function () use ($that) {
$that->executeRoute('show', func_get_args());
});
}
|
php
|
protected function generateGetSingle(ResourceConfiguration $config)
{
$that = $this;
$this->slim->get("{$this->baseRoute($config)}/:id", function () use ($that) {
$that->executeRoute('show', func_get_args());
});
}
|
[
"protected",
"function",
"generateGetSingle",
"(",
"ResourceConfiguration",
"$",
"config",
")",
"{",
"$",
"that",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"slim",
"->",
"get",
"(",
"\"{$this->baseRoute($config)}/:id\"",
",",
"function",
"(",
")",
"use",
"(",
"$",
"that",
")",
"{",
"$",
"that",
"->",
"executeRoute",
"(",
"'show'",
",",
"func_get_args",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] |
Generates the show route.
@param ResourceConfiguration $config
@return void
|
[
"Generates",
"the",
"show",
"route",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Routing/SlimRouteGenerator.php#L82-L89
|
3,836 |
jfortunato/fortune
|
src/Routing/SlimRouteGenerator.php
|
SlimRouteGenerator.generatePost
|
protected function generatePost(ResourceConfiguration $config)
{
$that = $this;
$this->slim->post($this->baseRoute($config), function () use ($that) {
$that->executeRoute('create', func_get_args());
});
}
|
php
|
protected function generatePost(ResourceConfiguration $config)
{
$that = $this;
$this->slim->post($this->baseRoute($config), function () use ($that) {
$that->executeRoute('create', func_get_args());
});
}
|
[
"protected",
"function",
"generatePost",
"(",
"ResourceConfiguration",
"$",
"config",
")",
"{",
"$",
"that",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"slim",
"->",
"post",
"(",
"$",
"this",
"->",
"baseRoute",
"(",
"$",
"config",
")",
",",
"function",
"(",
")",
"use",
"(",
"$",
"that",
")",
"{",
"$",
"that",
"->",
"executeRoute",
"(",
"'create'",
",",
"func_get_args",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] |
Generates the create route.
@param ResourceConfiguration $config
@return void
|
[
"Generates",
"the",
"create",
"route",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Routing/SlimRouteGenerator.php#L97-L104
|
3,837 |
jfortunato/fortune
|
src/Routing/SlimRouteGenerator.php
|
SlimRouteGenerator.generatePut
|
protected function generatePut(ResourceConfiguration $config)
{
$that = $this;
$this->slim->put("{$this->baseRoute($config)}/:id", function () use ($that) {
$that->executeRoute('update', func_get_args());
});
}
|
php
|
protected function generatePut(ResourceConfiguration $config)
{
$that = $this;
$this->slim->put("{$this->baseRoute($config)}/:id", function () use ($that) {
$that->executeRoute('update', func_get_args());
});
}
|
[
"protected",
"function",
"generatePut",
"(",
"ResourceConfiguration",
"$",
"config",
")",
"{",
"$",
"that",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"slim",
"->",
"put",
"(",
"\"{$this->baseRoute($config)}/:id\"",
",",
"function",
"(",
")",
"use",
"(",
"$",
"that",
")",
"{",
"$",
"that",
"->",
"executeRoute",
"(",
"'update'",
",",
"func_get_args",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] |
Generates the update route.
@param ResourceConfiguration $config
@return void
|
[
"Generates",
"the",
"update",
"route",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Routing/SlimRouteGenerator.php#L112-L119
|
3,838 |
jfortunato/fortune
|
src/Routing/SlimRouteGenerator.php
|
SlimRouteGenerator.generateDelete
|
protected function generateDelete(ResourceConfiguration $config)
{
$that = $this;
$this->slim->delete("{$this->baseRoute($config)}/:id", function () use ($that) {
$that->executeRoute('delete', func_get_args());
});
}
|
php
|
protected function generateDelete(ResourceConfiguration $config)
{
$that = $this;
$this->slim->delete("{$this->baseRoute($config)}/:id", function () use ($that) {
$that->executeRoute('delete', func_get_args());
});
}
|
[
"protected",
"function",
"generateDelete",
"(",
"ResourceConfiguration",
"$",
"config",
")",
"{",
"$",
"that",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"slim",
"->",
"delete",
"(",
"\"{$this->baseRoute($config)}/:id\"",
",",
"function",
"(",
")",
"use",
"(",
"$",
"that",
")",
"{",
"$",
"that",
"->",
"executeRoute",
"(",
"'delete'",
",",
"func_get_args",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] |
Generates the delete route.
@param ResourceConfiguration $config
@return void
|
[
"Generates",
"the",
"delete",
"route",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Routing/SlimRouteGenerator.php#L127-L134
|
3,839 |
jfortunato/fortune
|
src/Routing/SlimRouteGenerator.php
|
SlimRouteGenerator.parentRoutesFor
|
protected function parentRoutesFor(ResourceConfiguration $config)
{
if ($config->getParent()) {
$parentConfig = $this->configuration->resourceConfigurationFor($config->getParent());
return $this->parentRoutesFor($parentConfig) . "/{$config->getParent()}/:{$config->getParent()}_id";
}
}
|
php
|
protected function parentRoutesFor(ResourceConfiguration $config)
{
if ($config->getParent()) {
$parentConfig = $this->configuration->resourceConfigurationFor($config->getParent());
return $this->parentRoutesFor($parentConfig) . "/{$config->getParent()}/:{$config->getParent()}_id";
}
}
|
[
"protected",
"function",
"parentRoutesFor",
"(",
"ResourceConfiguration",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"config",
"->",
"getParent",
"(",
")",
")",
"{",
"$",
"parentConfig",
"=",
"$",
"this",
"->",
"configuration",
"->",
"resourceConfigurationFor",
"(",
"$",
"config",
"->",
"getParent",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"parentRoutesFor",
"(",
"$",
"parentConfig",
")",
".",
"\"/{$config->getParent()}/:{$config->getParent()}_id\"",
";",
"}",
"}"
] |
Gets the parents routes for a given child resource.
@param ResourceConfiguration $config
@return string
|
[
"Gets",
"the",
"parents",
"routes",
"for",
"a",
"given",
"child",
"resource",
"."
] |
3bbf66a85304070562e54a66c99145f58f32877e
|
https://github.com/jfortunato/fortune/blob/3bbf66a85304070562e54a66c99145f58f32877e/src/Routing/SlimRouteGenerator.php#L155-L162
|
3,840 |
pdenis/SnideTravinizerBundle
|
Manager/RepoManager.php
|
RepoManager.findAll
|
public function findAll()
{
$repos = array();
foreach ($this->repository->findAll() as $repo) {
$this->loadPackagistInfos($repo);
$repos[] = $repo;
}
return $repos;
}
|
php
|
public function findAll()
{
$repos = array();
foreach ($this->repository->findAll() as $repo) {
$this->loadPackagistInfos($repo);
$repos[] = $repo;
}
return $repos;
}
|
[
"public",
"function",
"findAll",
"(",
")",
"{",
"$",
"repos",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"repository",
"->",
"findAll",
"(",
")",
"as",
"$",
"repo",
")",
"{",
"$",
"this",
"->",
"loadPackagistInfos",
"(",
"$",
"repo",
")",
";",
"$",
"repos",
"[",
"]",
"=",
"$",
"repo",
";",
"}",
"return",
"$",
"repos",
";",
"}"
] |
Find all repos
@return array
|
[
"Find",
"all",
"repos"
] |
53a6fd647280d81a496018d379e4b5c446f81729
|
https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Manager/RepoManager.php#L139-L148
|
3,841 |
pdenis/SnideTravinizerBundle
|
Manager/RepoManager.php
|
RepoManager.loadExtraInfos
|
public function loadExtraInfos(Repo $repo)
{
try {
$this->scrutinizerLoader->load($repo);
$this->travisLoader->load($repo);
$this->versionEyeLoader->load($repo);
} catch (\Exception $e) {
print_r($e->getMessage());
// We do not want to throw exception here!
// Travis or Scrutinizer may not be configured
}
}
|
php
|
public function loadExtraInfos(Repo $repo)
{
try {
$this->scrutinizerLoader->load($repo);
$this->travisLoader->load($repo);
$this->versionEyeLoader->load($repo);
} catch (\Exception $e) {
print_r($e->getMessage());
// We do not want to throw exception here!
// Travis or Scrutinizer may not be configured
}
}
|
[
"public",
"function",
"loadExtraInfos",
"(",
"Repo",
"$",
"repo",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"scrutinizerLoader",
"->",
"load",
"(",
"$",
"repo",
")",
";",
"$",
"this",
"->",
"travisLoader",
"->",
"load",
"(",
"$",
"repo",
")",
";",
"$",
"this",
"->",
"versionEyeLoader",
"->",
"load",
"(",
"$",
"repo",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"print_r",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"// We do not want to throw exception here!",
"// Travis or Scrutinizer may not be configured",
"}",
"}"
] |
Load infos from travis & scrutinizer
@param Repo $repo
|
[
"Load",
"infos",
"from",
"travis",
"&",
"scrutinizer"
] |
53a6fd647280d81a496018d379e4b5c446f81729
|
https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Manager/RepoManager.php#L155-L167
|
3,842 |
pdenis/SnideTravinizerBundle
|
Manager/RepoManager.php
|
RepoManager.loadPackagistInfos
|
public function loadPackagistInfos(Repo $repo)
{
try {
$this->composerReader->load($repo->getSlug());
// Load package name
if ($this->composerReader->has('name')) {
$repo->setPackagistSlug($this->composerReader->get('name'));
}
// Load authors
if ($this->composerReader->has('authors')) {
$repo->setAuthors($this->composerReader->get('authors'));
}
// Load dependencies
if ($this->composerReader->has('require')) {
$repo->setDependencies($this->composerReader->get('require'));
}
} catch (\Exception $e) {
// We do not want to throw exception here!
}
}
|
php
|
public function loadPackagistInfos(Repo $repo)
{
try {
$this->composerReader->load($repo->getSlug());
// Load package name
if ($this->composerReader->has('name')) {
$repo->setPackagistSlug($this->composerReader->get('name'));
}
// Load authors
if ($this->composerReader->has('authors')) {
$repo->setAuthors($this->composerReader->get('authors'));
}
// Load dependencies
if ($this->composerReader->has('require')) {
$repo->setDependencies($this->composerReader->get('require'));
}
} catch (\Exception $e) {
// We do not want to throw exception here!
}
}
|
[
"public",
"function",
"loadPackagistInfos",
"(",
"Repo",
"$",
"repo",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"composerReader",
"->",
"load",
"(",
"$",
"repo",
"->",
"getSlug",
"(",
")",
")",
";",
"// Load package name",
"if",
"(",
"$",
"this",
"->",
"composerReader",
"->",
"has",
"(",
"'name'",
")",
")",
"{",
"$",
"repo",
"->",
"setPackagistSlug",
"(",
"$",
"this",
"->",
"composerReader",
"->",
"get",
"(",
"'name'",
")",
")",
";",
"}",
"// Load authors",
"if",
"(",
"$",
"this",
"->",
"composerReader",
"->",
"has",
"(",
"'authors'",
")",
")",
"{",
"$",
"repo",
"->",
"setAuthors",
"(",
"$",
"this",
"->",
"composerReader",
"->",
"get",
"(",
"'authors'",
")",
")",
";",
"}",
"// Load dependencies",
"if",
"(",
"$",
"this",
"->",
"composerReader",
"->",
"has",
"(",
"'require'",
")",
")",
"{",
"$",
"repo",
"->",
"setDependencies",
"(",
"$",
"this",
"->",
"composerReader",
"->",
"get",
"(",
"'require'",
")",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// We do not want to throw exception here!",
"}",
"}"
] |
Load packagist infos by reading composer json file
@param Repo $repo
|
[
"Load",
"packagist",
"infos",
"by",
"reading",
"composer",
"json",
"file"
] |
53a6fd647280d81a496018d379e4b5c446f81729
|
https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Manager/RepoManager.php#L174-L196
|
3,843 |
pdenis/SnideTravinizerBundle
|
Manager/RepoManager.php
|
RepoManager.loadRepo
|
protected function loadRepo(Repo $repo = null)
{
if (null == $repo) {
return null;
}
$this->loadExtraInfos($repo);
$this->loadPackagistInfos($repo);
return $repo;
}
|
php
|
protected function loadRepo(Repo $repo = null)
{
if (null == $repo) {
return null;
}
$this->loadExtraInfos($repo);
$this->loadPackagistInfos($repo);
return $repo;
}
|
[
"protected",
"function",
"loadRepo",
"(",
"Repo",
"$",
"repo",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"repo",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"loadExtraInfos",
"(",
"$",
"repo",
")",
";",
"$",
"this",
"->",
"loadPackagistInfos",
"(",
"$",
"repo",
")",
";",
"return",
"$",
"repo",
";",
"}"
] |
Load repo infos
@param Repo $repo
@return Repo
|
[
"Load",
"repo",
"infos"
] |
53a6fd647280d81a496018d379e4b5c446f81729
|
https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Manager/RepoManager.php#L236-L245
|
3,844 |
pdenis/SnideTravinizerBundle
|
Manager/RepoManager.php
|
RepoManager.isExists
|
public function isExists(Repo $repo)
{
$anotherRepo = $this->findBySlug($repo->getSlug());
return ($anotherRepo != null && $repo->getId() != $anotherRepo->getId());
}
|
php
|
public function isExists(Repo $repo)
{
$anotherRepo = $this->findBySlug($repo->getSlug());
return ($anotherRepo != null && $repo->getId() != $anotherRepo->getId());
}
|
[
"public",
"function",
"isExists",
"(",
"Repo",
"$",
"repo",
")",
"{",
"$",
"anotherRepo",
"=",
"$",
"this",
"->",
"findBySlug",
"(",
"$",
"repo",
"->",
"getSlug",
"(",
")",
")",
";",
"return",
"(",
"$",
"anotherRepo",
"!=",
"null",
"&&",
"$",
"repo",
"->",
"getId",
"(",
")",
"!=",
"$",
"anotherRepo",
"->",
"getId",
"(",
")",
")",
";",
"}"
] |
Checks if slug exist
@param Repo $repo
@return boolean
|
[
"Checks",
"if",
"slug",
"exist"
] |
53a6fd647280d81a496018d379e4b5c446f81729
|
https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Manager/RepoManager.php#L253-L258
|
3,845 |
phramz/staticfiles
|
src/Util/UrlUtil.php
|
UrlUtil.isPossiblePathTraversalAttack
|
public static function isPossiblePathTraversalAttack($path)
{
$virtualBase = '/' . md5(microtime(true) . '/' . mt_rand());
$virtualPath = $virtualBase . '/' . ltrim($path, '/');
return !FileUtil::isBasePath($virtualPath, $virtualBase);
}
|
php
|
public static function isPossiblePathTraversalAttack($path)
{
$virtualBase = '/' . md5(microtime(true) . '/' . mt_rand());
$virtualPath = $virtualBase . '/' . ltrim($path, '/');
return !FileUtil::isBasePath($virtualPath, $virtualBase);
}
|
[
"public",
"static",
"function",
"isPossiblePathTraversalAttack",
"(",
"$",
"path",
")",
"{",
"$",
"virtualBase",
"=",
"'/'",
".",
"md5",
"(",
"microtime",
"(",
"true",
")",
".",
"'/'",
".",
"mt_rand",
"(",
")",
")",
";",
"$",
"virtualPath",
"=",
"$",
"virtualBase",
".",
"'/'",
".",
"ltrim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"return",
"!",
"FileUtil",
"::",
"isBasePath",
"(",
"$",
"virtualPath",
",",
"$",
"virtualBase",
")",
";",
"}"
] |
Returns true if the given path will leave the root directory
@param $path
@return bool
|
[
"Returns",
"true",
"if",
"the",
"given",
"path",
"will",
"leave",
"the",
"root",
"directory"
] |
e636d75f5ae5d2a8a0f625f488199276d34af345
|
https://github.com/phramz/staticfiles/blob/e636d75f5ae5d2a8a0f625f488199276d34af345/src/Util/UrlUtil.php#L33-L39
|
3,846 |
programster/package-google-charts
|
Axis.php
|
Axis.setTitlePosition
|
public function setTitlePosition($position)
{
$allowedValues = array("in", "out", "none");
if (!in_array($position, $allowedValues))
{
throw new \Exception("Invalid position: " . $position);
}
$this->m_options['titlePosition'] = $position;
}
|
php
|
public function setTitlePosition($position)
{
$allowedValues = array("in", "out", "none");
if (!in_array($position, $allowedValues))
{
throw new \Exception("Invalid position: " . $position);
}
$this->m_options['titlePosition'] = $position;
}
|
[
"public",
"function",
"setTitlePosition",
"(",
"$",
"position",
")",
"{",
"$",
"allowedValues",
"=",
"array",
"(",
"\"in\"",
",",
"\"out\"",
",",
"\"none\"",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"position",
",",
"$",
"allowedValues",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Invalid position: \"",
".",
"$",
"position",
")",
";",
"}",
"$",
"this",
"->",
"m_options",
"[",
"'titlePosition'",
"]",
"=",
"$",
"position",
";",
"}"
] |
Set the position of the title.
@param type $position - one of "in", "out" or "none.
@throws \Exception
|
[
"Set",
"the",
"position",
"of",
"the",
"title",
"."
] |
9459d5ce2a6b50c73d8f18ec657d4208e8cbb529
|
https://github.com/programster/package-google-charts/blob/9459d5ce2a6b50c73d8f18ec657d4208e8cbb529/Axis.php#L23-L33
|
3,847 |
flowcode/enlace
|
src/flowcode/enlace/view/JsonView.php
|
JsonView.toArray
|
private function toArray($obj) {
$arr = array();
if (is_array($obj)) {
foreach ($obj as $value) {
$arr[] = $this->toArray($value);
}
} else if (is_object($obj)) {
$arObj = (array) $obj;
foreach ($arObj as $key => $value) {
$attribute = str_replace(get_class($obj), "", $key);
if (is_object($value) || is_array($value)) {
$value = $this->toArray($value);
} else {
$arr[$attribute] = $this->utf8_encode_all($value);
}
}
} else {
$arr = $this->utf8_encode_all($obj);
}
return $arr;
}
|
php
|
private function toArray($obj) {
$arr = array();
if (is_array($obj)) {
foreach ($obj as $value) {
$arr[] = $this->toArray($value);
}
} else if (is_object($obj)) {
$arObj = (array) $obj;
foreach ($arObj as $key => $value) {
$attribute = str_replace(get_class($obj), "", $key);
if (is_object($value) || is_array($value)) {
$value = $this->toArray($value);
} else {
$arr[$attribute] = $this->utf8_encode_all($value);
}
}
} else {
$arr = $this->utf8_encode_all($obj);
}
return $arr;
}
|
[
"private",
"function",
"toArray",
"(",
"$",
"obj",
")",
"{",
"$",
"arr",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"obj",
")",
")",
"{",
"foreach",
"(",
"$",
"obj",
"as",
"$",
"value",
")",
"{",
"$",
"arr",
"[",
"]",
"=",
"$",
"this",
"->",
"toArray",
"(",
"$",
"value",
")",
";",
"}",
"}",
"else",
"if",
"(",
"is_object",
"(",
"$",
"obj",
")",
")",
"{",
"$",
"arObj",
"=",
"(",
"array",
")",
"$",
"obj",
";",
"foreach",
"(",
"$",
"arObj",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"attribute",
"=",
"str_replace",
"(",
"get_class",
"(",
"$",
"obj",
")",
",",
"\"\"",
",",
"$",
"key",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"||",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"toArray",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"arr",
"[",
"$",
"attribute",
"]",
"=",
"$",
"this",
"->",
"utf8_encode_all",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"arr",
"=",
"$",
"this",
"->",
"utf8_encode_all",
"(",
"$",
"obj",
")",
";",
"}",
"return",
"$",
"arr",
";",
"}"
] |
Convierte un objeto a notacion json.
@param type $obj
@return type
|
[
"Convierte",
"un",
"objeto",
"a",
"notacion",
"json",
"."
] |
2dacd15cd3cf32171a19695c331487e1620eacb8
|
https://github.com/flowcode/enlace/blob/2dacd15cd3cf32171a19695c331487e1620eacb8/src/flowcode/enlace/view/JsonView.php#L38-L59
|
3,848 |
antaresproject/tester
|
src/Processor/CollectiveProcessor.php
|
CollectiveProcessor.index
|
public function index(ViewListener $listener)
{
$form = $this->presenter->form();
return $listener->show(compact('form'));
}
|
php
|
public function index(ViewListener $listener)
{
$form = $this->presenter->form();
return $listener->show(compact('form'));
}
|
[
"public",
"function",
"index",
"(",
"ViewListener",
"$",
"listener",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"presenter",
"->",
"form",
"(",
")",
";",
"return",
"$",
"listener",
"->",
"show",
"(",
"compact",
"(",
"'form'",
")",
")",
";",
"}"
] |
shows module tester default index action
@return Antares\Tester\Contracts\TesterView
|
[
"shows",
"module",
"tester",
"default",
"index",
"action"
] |
23e9b4dd7880475769486a8c8f979ab6530c99df
|
https://github.com/antaresproject/tester/blob/23e9b4dd7880475769486a8c8f979ab6530c99df/src/Processor/CollectiveProcessor.php#L50-L54
|
3,849 |
antaresproject/tester
|
src/Processor/CollectiveProcessor.php
|
CollectiveProcessor.prepare
|
public function prepare(array $data = null)
{
$response = [];
$code = 200;
try {
if (!isset($data['module']) or empty($data['module'])) {
throw new Exception\InvalidArgumentException(
'Unable to start tests. No module has been selected.');
}
$selected = array_keys($data['module']);
$tests = app('antares.memory')->make('tests')->all();
$active = app('antares.memory')->get("extensions.active");
foreach ($tests as $name => $test) {
if (in_array($test['id'], $selected)) {
$fullName = isset($active[$test['component']]) ? $active[$test['component']]['full_name'] : 'Foundation';
$response[] = [
'cid' => $test['id'],
'message' => "Currently testing {$name} in {$fullName}."
];
}
}
} catch (\Exception $ex) {
Log::warning($ex);
$code = 400;
$response[] = [
'error' => $ex->getMessage()
];
}
return Response::json($response, $code);
}
|
php
|
public function prepare(array $data = null)
{
$response = [];
$code = 200;
try {
if (!isset($data['module']) or empty($data['module'])) {
throw new Exception\InvalidArgumentException(
'Unable to start tests. No module has been selected.');
}
$selected = array_keys($data['module']);
$tests = app('antares.memory')->make('tests')->all();
$active = app('antares.memory')->get("extensions.active");
foreach ($tests as $name => $test) {
if (in_array($test['id'], $selected)) {
$fullName = isset($active[$test['component']]) ? $active[$test['component']]['full_name'] : 'Foundation';
$response[] = [
'cid' => $test['id'],
'message' => "Currently testing {$name} in {$fullName}."
];
}
}
} catch (\Exception $ex) {
Log::warning($ex);
$code = 400;
$response[] = [
'error' => $ex->getMessage()
];
}
return Response::json($response, $code);
}
|
[
"public",
"function",
"prepare",
"(",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"response",
"=",
"[",
"]",
";",
"$",
"code",
"=",
"200",
";",
"try",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'module'",
"]",
")",
"or",
"empty",
"(",
"$",
"data",
"[",
"'module'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'Unable to start tests. No module has been selected.'",
")",
";",
"}",
"$",
"selected",
"=",
"array_keys",
"(",
"$",
"data",
"[",
"'module'",
"]",
")",
";",
"$",
"tests",
"=",
"app",
"(",
"'antares.memory'",
")",
"->",
"make",
"(",
"'tests'",
")",
"->",
"all",
"(",
")",
";",
"$",
"active",
"=",
"app",
"(",
"'antares.memory'",
")",
"->",
"get",
"(",
"\"extensions.active\"",
")",
";",
"foreach",
"(",
"$",
"tests",
"as",
"$",
"name",
"=>",
"$",
"test",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"test",
"[",
"'id'",
"]",
",",
"$",
"selected",
")",
")",
"{",
"$",
"fullName",
"=",
"isset",
"(",
"$",
"active",
"[",
"$",
"test",
"[",
"'component'",
"]",
"]",
")",
"?",
"$",
"active",
"[",
"$",
"test",
"[",
"'component'",
"]",
"]",
"[",
"'full_name'",
"]",
":",
"'Foundation'",
";",
"$",
"response",
"[",
"]",
"=",
"[",
"'cid'",
"=>",
"$",
"test",
"[",
"'id'",
"]",
",",
"'message'",
"=>",
"\"Currently testing {$name} in {$fullName}.\"",
"]",
";",
"}",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"Log",
"::",
"warning",
"(",
"$",
"ex",
")",
";",
"$",
"code",
"=",
"400",
";",
"$",
"response",
"[",
"]",
"=",
"[",
"'error'",
"=>",
"$",
"ex",
"->",
"getMessage",
"(",
")",
"]",
";",
"}",
"return",
"Response",
"::",
"json",
"(",
"$",
"response",
",",
"$",
"code",
")",
";",
"}"
] |
build sepcification data before real test
@param array $data
|
[
"build",
"sepcification",
"data",
"before",
"real",
"test"
] |
23e9b4dd7880475769486a8c8f979ab6530c99df
|
https://github.com/antaresproject/tester/blob/23e9b4dd7880475769486a8c8f979ab6530c99df/src/Processor/CollectiveProcessor.php#L61-L94
|
3,850 |
antaresproject/tester
|
src/Processor/CollectiveProcessor.php
|
CollectiveProcessor.run
|
public function run(ProcessListener $listener, array $data)
{
try {
if (empty($data)) {
throw new Exception\InvalidArgumentException('Invalid method arguments.');
}
$validator = null;
$values = null;
if (isset($data['cid'])) {
$model = MemoryTests::findOrNew($data['cid']);
$params = unserialize($model->value);
$validator = new $params['validator'];
$values = !empty($params['controls']) ? $params['controls'] : array_get($params, 'data');
}
if (isset($data['validator'])) {
$validator = new $data['validator'];
$values = $data;
}
$response = $validator($values)->getResponse();
$return = view('antares/tester::admin.partials._messages')->with(['response' => $response]);
} catch (\Exception $e) {
Log::emergency($e);
$return = view('antares/tester::admin.partials._error')->with(['message' => $e->getMessage(), 'code' => $e->getCode()]);
}
return $listener->render($return);
}
|
php
|
public function run(ProcessListener $listener, array $data)
{
try {
if (empty($data)) {
throw new Exception\InvalidArgumentException('Invalid method arguments.');
}
$validator = null;
$values = null;
if (isset($data['cid'])) {
$model = MemoryTests::findOrNew($data['cid']);
$params = unserialize($model->value);
$validator = new $params['validator'];
$values = !empty($params['controls']) ? $params['controls'] : array_get($params, 'data');
}
if (isset($data['validator'])) {
$validator = new $data['validator'];
$values = $data;
}
$response = $validator($values)->getResponse();
$return = view('antares/tester::admin.partials._messages')->with(['response' => $response]);
} catch (\Exception $e) {
Log::emergency($e);
$return = view('antares/tester::admin.partials._error')->with(['message' => $e->getMessage(), 'code' => $e->getCode()]);
}
return $listener->render($return);
}
|
[
"public",
"function",
"run",
"(",
"ProcessListener",
"$",
"listener",
",",
"array",
"$",
"data",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'Invalid method arguments.'",
")",
";",
"}",
"$",
"validator",
"=",
"null",
";",
"$",
"values",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'cid'",
"]",
")",
")",
"{",
"$",
"model",
"=",
"MemoryTests",
"::",
"findOrNew",
"(",
"$",
"data",
"[",
"'cid'",
"]",
")",
";",
"$",
"params",
"=",
"unserialize",
"(",
"$",
"model",
"->",
"value",
")",
";",
"$",
"validator",
"=",
"new",
"$",
"params",
"[",
"'validator'",
"]",
";",
"$",
"values",
"=",
"!",
"empty",
"(",
"$",
"params",
"[",
"'controls'",
"]",
")",
"?",
"$",
"params",
"[",
"'controls'",
"]",
":",
"array_get",
"(",
"$",
"params",
",",
"'data'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'validator'",
"]",
")",
")",
"{",
"$",
"validator",
"=",
"new",
"$",
"data",
"[",
"'validator'",
"]",
";",
"$",
"values",
"=",
"$",
"data",
";",
"}",
"$",
"response",
"=",
"$",
"validator",
"(",
"$",
"values",
")",
"->",
"getResponse",
"(",
")",
";",
"$",
"return",
"=",
"view",
"(",
"'antares/tester::admin.partials._messages'",
")",
"->",
"with",
"(",
"[",
"'response'",
"=>",
"$",
"response",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"e",
")",
";",
"$",
"return",
"=",
"view",
"(",
"'antares/tester::admin.partials._error'",
")",
"->",
"with",
"(",
"[",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"'code'",
"=>",
"$",
"e",
"->",
"getCode",
"(",
")",
"]",
")",
";",
"}",
"return",
"$",
"listener",
"->",
"render",
"(",
"$",
"return",
")",
";",
"}"
] |
run validation of partial module configuration
@param array $data
@return Illuminate\Support\Facades\Response
|
[
"run",
"validation",
"of",
"partial",
"module",
"configuration"
] |
23e9b4dd7880475769486a8c8f979ab6530c99df
|
https://github.com/antaresproject/tester/blob/23e9b4dd7880475769486a8c8f979ab6530c99df/src/Processor/CollectiveProcessor.php#L102-L128
|
3,851 |
picoss/cvss
|
lib/Cvss/Cvss3.php
|
Cvss3.setVector
|
public function setVector($vector)
{
if (empty($vector)) {
throw new \InvalidArgumentException(sprintf('Cvss vector "%s" is not valid.', $vector));
}
if (!preg_match('/^' . self::$vectorHead . '.*/mi', $vector)) {
throw new \InvalidArgumentException((sprintf('Cvss vector "%s" is not valid. Must start with "%s"', $vector, self::$vectorHead)));
}
$this->vectorInputs = self::parseVector($vector);
$resolver = $this->getInputLevelConfiguration();
$this->vectorLevels = $resolver->resolve($this->vectorInputs);
$this->calculate();
}
|
php
|
public function setVector($vector)
{
if (empty($vector)) {
throw new \InvalidArgumentException(sprintf('Cvss vector "%s" is not valid.', $vector));
}
if (!preg_match('/^' . self::$vectorHead . '.*/mi', $vector)) {
throw new \InvalidArgumentException((sprintf('Cvss vector "%s" is not valid. Must start with "%s"', $vector, self::$vectorHead)));
}
$this->vectorInputs = self::parseVector($vector);
$resolver = $this->getInputLevelConfiguration();
$this->vectorLevels = $resolver->resolve($this->vectorInputs);
$this->calculate();
}
|
[
"public",
"function",
"setVector",
"(",
"$",
"vector",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"vector",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Cvss vector \"%s\" is not valid.'",
",",
"$",
"vector",
")",
")",
";",
"}",
"if",
"(",
"!",
"preg_match",
"(",
"'/^'",
".",
"self",
"::",
"$",
"vectorHead",
".",
"'.*/mi'",
",",
"$",
"vector",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"(",
"sprintf",
"(",
"'Cvss vector \"%s\" is not valid. Must start with \"%s\"'",
",",
"$",
"vector",
",",
"self",
"::",
"$",
"vectorHead",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"vectorInputs",
"=",
"self",
"::",
"parseVector",
"(",
"$",
"vector",
")",
";",
"$",
"resolver",
"=",
"$",
"this",
"->",
"getInputLevelConfiguration",
"(",
")",
";",
"$",
"this",
"->",
"vectorLevels",
"=",
"$",
"resolver",
"->",
"resolve",
"(",
"$",
"this",
"->",
"vectorInputs",
")",
";",
"$",
"this",
"->",
"calculate",
"(",
")",
";",
"}"
] |
Parse CVSS vector
@param string $vector
@throws \InvalidArgumentException
|
[
"Parse",
"CVSS",
"vector"
] |
e7506eb034e9ba10fa289717a23731e4e0978a68
|
https://github.com/picoss/cvss/blob/e7506eb034e9ba10fa289717a23731e4e0978a68/lib/Cvss/Cvss3.php#L264-L280
|
3,852 |
picoss/cvss
|
lib/Cvss/Cvss3.php
|
Cvss3.getSeverity
|
protected function getSeverity($score)
{
foreach ($this->severityRatingScale as $level => $options) {
if ($score >= $options['min_range'] && $score <= $options['max_range']) {
return $level;
}
}
return null;
}
|
php
|
protected function getSeverity($score)
{
foreach ($this->severityRatingScale as $level => $options) {
if ($score >= $options['min_range'] && $score <= $options['max_range']) {
return $level;
}
}
return null;
}
|
[
"protected",
"function",
"getSeverity",
"(",
"$",
"score",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"severityRatingScale",
"as",
"$",
"level",
"=>",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"score",
">=",
"$",
"options",
"[",
"'min_range'",
"]",
"&&",
"$",
"score",
"<=",
"$",
"options",
"[",
"'max_range'",
"]",
")",
"{",
"return",
"$",
"level",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get severity for the given score
@param float $score
@return int|null|string
|
[
"Get",
"severity",
"for",
"the",
"given",
"score"
] |
e7506eb034e9ba10fa289717a23731e4e0978a68
|
https://github.com/picoss/cvss/blob/e7506eb034e9ba10fa289717a23731e4e0978a68/lib/Cvss/Cvss3.php#L379-L387
|
3,853 |
picoss/cvss
|
lib/Cvss/Cvss3.php
|
Cvss3.getOverallScore
|
public function getOverallScore()
{
if ($this->environmentalScore != $this->baseScore) {
return $this->environmentalScore;
}
elseif ($this->temporalScore != $this->baseScore) {
return $this->temporalScore;
}
else {
return $this->baseScore;
}
}
|
php
|
public function getOverallScore()
{
if ($this->environmentalScore != $this->baseScore) {
return $this->environmentalScore;
}
elseif ($this->temporalScore != $this->baseScore) {
return $this->temporalScore;
}
else {
return $this->baseScore;
}
}
|
[
"public",
"function",
"getOverallScore",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"environmentalScore",
"!=",
"$",
"this",
"->",
"baseScore",
")",
"{",
"return",
"$",
"this",
"->",
"environmentalScore",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"temporalScore",
"!=",
"$",
"this",
"->",
"baseScore",
")",
"{",
"return",
"$",
"this",
"->",
"temporalScore",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"baseScore",
";",
"}",
"}"
] |
Get overall score
@return float
|
[
"Get",
"overall",
"score"
] |
e7506eb034e9ba10fa289717a23731e4e0978a68
|
https://github.com/picoss/cvss/blob/e7506eb034e9ba10fa289717a23731e4e0978a68/lib/Cvss/Cvss3.php#L394-L405
|
3,854 |
picoss/cvss
|
lib/Cvss/Cvss3.php
|
Cvss3.getVector
|
public function getVector($omitUndefined = true)
{
$metrics = [];
foreach ($this->vectorInputs as $name => $value) {
if ($value != 'X' || !$omitUndefined) {
$metrics[$name] = $value;
}
}
return self::buildVector($metrics);
}
|
php
|
public function getVector($omitUndefined = true)
{
$metrics = [];
foreach ($this->vectorInputs as $name => $value) {
if ($value != 'X' || !$omitUndefined) {
$metrics[$name] = $value;
}
}
return self::buildVector($metrics);
}
|
[
"public",
"function",
"getVector",
"(",
"$",
"omitUndefined",
"=",
"true",
")",
"{",
"$",
"metrics",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"vectorInputs",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"!=",
"'X'",
"||",
"!",
"$",
"omitUndefined",
")",
"{",
"$",
"metrics",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"self",
"::",
"buildVector",
"(",
"$",
"metrics",
")",
";",
"}"
] |
Get full vector
@param bool $omitUndefined Do not include metrics that are not defined (ex:MPR:X)
@return string
|
[
"Get",
"full",
"vector"
] |
e7506eb034e9ba10fa289717a23731e4e0978a68
|
https://github.com/picoss/cvss/blob/e7506eb034e9ba10fa289717a23731e4e0978a68/lib/Cvss/Cvss3.php#L434-L444
|
3,855 |
picoss/cvss
|
lib/Cvss/Cvss3.php
|
Cvss3.buildVector
|
static function buildVector($inputs)
{
$inputs = array_merge(array('CVSS' => self::VERSION), $inputs);
return implode(self::$metricSeparator, array_map(function ($k, $v) {
return sprintf('%1$s%3$s%2$s', strtoupper($k), strtoupper($v), self::$valueSeparator);
}, array_keys($inputs), $inputs));
}
|
php
|
static function buildVector($inputs)
{
$inputs = array_merge(array('CVSS' => self::VERSION), $inputs);
return implode(self::$metricSeparator, array_map(function ($k, $v) {
return sprintf('%1$s%3$s%2$s', strtoupper($k), strtoupper($v), self::$valueSeparator);
}, array_keys($inputs), $inputs));
}
|
[
"static",
"function",
"buildVector",
"(",
"$",
"inputs",
")",
"{",
"$",
"inputs",
"=",
"array_merge",
"(",
"array",
"(",
"'CVSS'",
"=>",
"self",
"::",
"VERSION",
")",
",",
"$",
"inputs",
")",
";",
"return",
"implode",
"(",
"self",
"::",
"$",
"metricSeparator",
",",
"array_map",
"(",
"function",
"(",
"$",
"k",
",",
"$",
"v",
")",
"{",
"return",
"sprintf",
"(",
"'%1$s%3$s%2$s'",
",",
"strtoupper",
"(",
"$",
"k",
")",
",",
"strtoupper",
"(",
"$",
"v",
")",
",",
"self",
"::",
"$",
"valueSeparator",
")",
";",
"}",
",",
"array_keys",
"(",
"$",
"inputs",
")",
",",
"$",
"inputs",
")",
")",
";",
"}"
] |
Build CVSS vector for the given inputs
@param array $inputs
@return string
|
[
"Build",
"CVSS",
"vector",
"for",
"the",
"given",
"inputs"
] |
e7506eb034e9ba10fa289717a23731e4e0978a68
|
https://github.com/picoss/cvss/blob/e7506eb034e9ba10fa289717a23731e4e0978a68/lib/Cvss/Cvss3.php#L453-L459
|
3,856 |
cmdweb/owl
|
Owl/Owl.php
|
Owl.Insert
|
function Insert($model){
$this->OpenTransaction();
$data = clone $model;
$table = $this->getTableName($data);
//verifico se é um objeto
if (is_object($data))
ModelState::ModelTreatment($data);
$data = (array)$data;
// Ordena
ksort($data);
// Campos e valores
$camposNomes = implode('`, `', array_keys($data));
$camposValores = ':' . implode(', :', array_keys($data));
// Prepara a Query
$sth = $this->prepare("INSERT INTO $table (`$camposNomes`) VALUES ($camposValores)");
// Define os dados
foreach ($data as $key => $value) {
// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR
$tipo = (is_int($value)) ? \PDO::PARAM_INT : \PDO::PARAM_STR;
// Define o dado
$sth->bindValue(":$key", $value, $tipo);
}
// Executa
try {
$sth->execute();
}catch (\Exception $e){
echo $e->getMessage();
}
$primaryKey = ModelState::GetPrimary($model);
if(!empty($primaryKey))
$model->$primaryKey = $this->lastInsertId();
return $this->lastInsertId();
}
|
php
|
function Insert($model){
$this->OpenTransaction();
$data = clone $model;
$table = $this->getTableName($data);
//verifico se é um objeto
if (is_object($data))
ModelState::ModelTreatment($data);
$data = (array)$data;
// Ordena
ksort($data);
// Campos e valores
$camposNomes = implode('`, `', array_keys($data));
$camposValores = ':' . implode(', :', array_keys($data));
// Prepara a Query
$sth = $this->prepare("INSERT INTO $table (`$camposNomes`) VALUES ($camposValores)");
// Define os dados
foreach ($data as $key => $value) {
// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR
$tipo = (is_int($value)) ? \PDO::PARAM_INT : \PDO::PARAM_STR;
// Define o dado
$sth->bindValue(":$key", $value, $tipo);
}
// Executa
try {
$sth->execute();
}catch (\Exception $e){
echo $e->getMessage();
}
$primaryKey = ModelState::GetPrimary($model);
if(!empty($primaryKey))
$model->$primaryKey = $this->lastInsertId();
return $this->lastInsertId();
}
|
[
"function",
"Insert",
"(",
"$",
"model",
")",
"{",
"$",
"this",
"->",
"OpenTransaction",
"(",
")",
";",
"$",
"data",
"=",
"clone",
"$",
"model",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"getTableName",
"(",
"$",
"data",
")",
";",
"//verifico se é um objeto",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"ModelState",
"::",
"ModelTreatment",
"(",
"$",
"data",
")",
";",
"$",
"data",
"=",
"(",
"array",
")",
"$",
"data",
";",
"// Ordena",
"ksort",
"(",
"$",
"data",
")",
";",
"// Campos e valores",
"$",
"camposNomes",
"=",
"implode",
"(",
"'`, `'",
",",
"array_keys",
"(",
"$",
"data",
")",
")",
";",
"$",
"camposValores",
"=",
"':'",
".",
"implode",
"(",
"', :'",
",",
"array_keys",
"(",
"$",
"data",
")",
")",
";",
"// Prepara a Query",
"$",
"sth",
"=",
"$",
"this",
"->",
"prepare",
"(",
"\"INSERT INTO $table (`$camposNomes`) VALUES ($camposValores)\"",
")",
";",
"// Define os dados",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR",
"$",
"tipo",
"=",
"(",
"is_int",
"(",
"$",
"value",
")",
")",
"?",
"\\",
"PDO",
"::",
"PARAM_INT",
":",
"\\",
"PDO",
"::",
"PARAM_STR",
";",
"// Define o dado",
"$",
"sth",
"->",
"bindValue",
"(",
"\":$key\"",
",",
"$",
"value",
",",
"$",
"tipo",
")",
";",
"}",
"// Executa",
"try",
"{",
"$",
"sth",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"echo",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"$",
"primaryKey",
"=",
"ModelState",
"::",
"GetPrimary",
"(",
"$",
"model",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"primaryKey",
")",
")",
"$",
"model",
"->",
"$",
"primaryKey",
"=",
"$",
"this",
"->",
"lastInsertId",
"(",
")",
";",
"return",
"$",
"this",
"->",
"lastInsertId",
"(",
")",
";",
"}"
] |
Insere dados no banco atraves de uma model mapeada
@param $model
@return string
|
[
"Insere",
"dados",
"no",
"banco",
"atraves",
"de",
"uma",
"model",
"mapeada"
] |
9ad920e5d76df51508fe3b0a2375c6657bb6eda5
|
https://github.com/cmdweb/owl/blob/9ad920e5d76df51508fe3b0a2375c6657bb6eda5/Owl/Owl.php#L64-L110
|
3,857 |
cmdweb/owl
|
Owl/Owl.php
|
Owl.Update
|
public function Update($model, array $campos = null)
{
$this->OpenTransaction();
$data = clone $model;
if (is_object($data))
ModelState::ModelTreatment($data);
$primaryKey = ModelState::GetPrimary($model);
if($primaryKey == null)
throw new OwlException("Classe nao contem PK");
$table = $this->getTableName($data);
$data = (array)$data;
$novosDados = NULL;
if($campos == null)
$campos = array_keys($data);
foreach ($campos as $key) {
$novosDados .= "`$key`=:$key,";
}
$novosDados = rtrim($novosDados, ',');
// Prepara a Query
$sth = $this->prepare("UPDATE $table SET $novosDados WHERE $primaryKey = '".$model->$primaryKey."'");
// Define os dados
foreach ($campos as $key) {
// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR
$tipo = (is_int($model->$key)) ? \PDO::PARAM_INT : \PDO::PARAM_STR;
// Define o dado
$sth->bindValue(":$key",$model->$key, $tipo);
}
try {
$sth->execute();
$model = $this->GetById($table,$model->$primaryKey);
}catch (\Exception $e){
echo $e->getMessage();
}
}
|
php
|
public function Update($model, array $campos = null)
{
$this->OpenTransaction();
$data = clone $model;
if (is_object($data))
ModelState::ModelTreatment($data);
$primaryKey = ModelState::GetPrimary($model);
if($primaryKey == null)
throw new OwlException("Classe nao contem PK");
$table = $this->getTableName($data);
$data = (array)$data;
$novosDados = NULL;
if($campos == null)
$campos = array_keys($data);
foreach ($campos as $key) {
$novosDados .= "`$key`=:$key,";
}
$novosDados = rtrim($novosDados, ',');
// Prepara a Query
$sth = $this->prepare("UPDATE $table SET $novosDados WHERE $primaryKey = '".$model->$primaryKey."'");
// Define os dados
foreach ($campos as $key) {
// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR
$tipo = (is_int($model->$key)) ? \PDO::PARAM_INT : \PDO::PARAM_STR;
// Define o dado
$sth->bindValue(":$key",$model->$key, $tipo);
}
try {
$sth->execute();
$model = $this->GetById($table,$model->$primaryKey);
}catch (\Exception $e){
echo $e->getMessage();
}
}
|
[
"public",
"function",
"Update",
"(",
"$",
"model",
",",
"array",
"$",
"campos",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"OpenTransaction",
"(",
")",
";",
"$",
"data",
"=",
"clone",
"$",
"model",
";",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"ModelState",
"::",
"ModelTreatment",
"(",
"$",
"data",
")",
";",
"$",
"primaryKey",
"=",
"ModelState",
"::",
"GetPrimary",
"(",
"$",
"model",
")",
";",
"if",
"(",
"$",
"primaryKey",
"==",
"null",
")",
"throw",
"new",
"OwlException",
"(",
"\"Classe nao contem PK\"",
")",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"getTableName",
"(",
"$",
"data",
")",
";",
"$",
"data",
"=",
"(",
"array",
")",
"$",
"data",
";",
"$",
"novosDados",
"=",
"NULL",
";",
"if",
"(",
"$",
"campos",
"==",
"null",
")",
"$",
"campos",
"=",
"array_keys",
"(",
"$",
"data",
")",
";",
"foreach",
"(",
"$",
"campos",
"as",
"$",
"key",
")",
"{",
"$",
"novosDados",
".=",
"\"`$key`=:$key,\"",
";",
"}",
"$",
"novosDados",
"=",
"rtrim",
"(",
"$",
"novosDados",
",",
"','",
")",
";",
"// Prepara a Query",
"$",
"sth",
"=",
"$",
"this",
"->",
"prepare",
"(",
"\"UPDATE $table SET $novosDados WHERE $primaryKey = '\"",
".",
"$",
"model",
"->",
"$",
"primaryKey",
".",
"\"'\"",
")",
";",
"// Define os dados",
"foreach",
"(",
"$",
"campos",
"as",
"$",
"key",
")",
"{",
"// Se o tipo do dado for inteiro, usa PDO::PARAM_INT, caso contr�rio, PDO::PARAM_STR",
"$",
"tipo",
"=",
"(",
"is_int",
"(",
"$",
"model",
"->",
"$",
"key",
")",
")",
"?",
"\\",
"PDO",
"::",
"PARAM_INT",
":",
"\\",
"PDO",
"::",
"PARAM_STR",
";",
"// Define o dado",
"$",
"sth",
"->",
"bindValue",
"(",
"\":$key\"",
",",
"$",
"model",
"->",
"$",
"key",
",",
"$",
"tipo",
")",
";",
"}",
"try",
"{",
"$",
"sth",
"->",
"execute",
"(",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"GetById",
"(",
"$",
"table",
",",
"$",
"model",
"->",
"$",
"primaryKey",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"echo",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"}"
] |
Atualiza os dados no banco atraves de uma model mapeada
@param $model Objeto que contem os dados
@param $campos Seleciona os campos que quer atulizar passando por array, caso seja nulo serão atualizados todos os campos
|
[
"Atualiza",
"os",
"dados",
"no",
"banco",
"atraves",
"de",
"uma",
"model",
"mapeada"
] |
9ad920e5d76df51508fe3b0a2375c6657bb6eda5
|
https://github.com/cmdweb/owl/blob/9ad920e5d76df51508fe3b0a2375c6657bb6eda5/Owl/Owl.php#L117-L163
|
3,858 |
ionutmilica/ionix-framework
|
src/Types/String.php
|
String.substr
|
public function substr($start, $length = null)
{
$str = mb_substr($this->value, $start, $length);
return static::make($str);
}
|
php
|
public function substr($start, $length = null)
{
$str = mb_substr($this->value, $start, $length);
return static::make($str);
}
|
[
"public",
"function",
"substr",
"(",
"$",
"start",
",",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"str",
"=",
"mb_substr",
"(",
"$",
"this",
"->",
"value",
",",
"$",
"start",
",",
"$",
"length",
")",
";",
"return",
"static",
"::",
"make",
"(",
"$",
"str",
")",
";",
"}"
] |
Get substring from the current string
@param int $start
@param null $length
@return \Ionix\Types\String
|
[
"Get",
"substring",
"from",
"the",
"current",
"string"
] |
a0363667ff677f1772bdd9ac9530a9f4710f9321
|
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Types/String.php#L22-L27
|
3,859 |
sedp-mis/base-repository
|
src/Validation.php
|
Validation.validate
|
public function validate($operation, $model)
{
$model = is_array($model) ? $model : $model->getAttributes();
$rules = $this->model->rules($operation == 'update' ? array_keys($model) : null, $operation);
$rules = $this->interpolateValidationRules($rules, $model);
$validator = Validator::make($model, $rules);
$messages = [];
if ($validator->fails()) {
$messages = $validator->messages()->all();
}
// Perform other validations
foreach ($this->validations as $validationMethod) {
if ($message = $this->{$validationMethod}($model)) {
$messages[] = $message;
}
}
if (count($messages)) {
throw App::make('sedp-mis.base-repository.validationException', $messages);
}
}
|
php
|
public function validate($operation, $model)
{
$model = is_array($model) ? $model : $model->getAttributes();
$rules = $this->model->rules($operation == 'update' ? array_keys($model) : null, $operation);
$rules = $this->interpolateValidationRules($rules, $model);
$validator = Validator::make($model, $rules);
$messages = [];
if ($validator->fails()) {
$messages = $validator->messages()->all();
}
// Perform other validations
foreach ($this->validations as $validationMethod) {
if ($message = $this->{$validationMethod}($model)) {
$messages[] = $message;
}
}
if (count($messages)) {
throw App::make('sedp-mis.base-repository.validationException', $messages);
}
}
|
[
"public",
"function",
"validate",
"(",
"$",
"operation",
",",
"$",
"model",
")",
"{",
"$",
"model",
"=",
"is_array",
"(",
"$",
"model",
")",
"?",
"$",
"model",
":",
"$",
"model",
"->",
"getAttributes",
"(",
")",
";",
"$",
"rules",
"=",
"$",
"this",
"->",
"model",
"->",
"rules",
"(",
"$",
"operation",
"==",
"'update'",
"?",
"array_keys",
"(",
"$",
"model",
")",
":",
"null",
",",
"$",
"operation",
")",
";",
"$",
"rules",
"=",
"$",
"this",
"->",
"interpolateValidationRules",
"(",
"$",
"rules",
",",
"$",
"model",
")",
";",
"$",
"validator",
"=",
"Validator",
"::",
"make",
"(",
"$",
"model",
",",
"$",
"rules",
")",
";",
"$",
"messages",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"validator",
"->",
"fails",
"(",
")",
")",
"{",
"$",
"messages",
"=",
"$",
"validator",
"->",
"messages",
"(",
")",
"->",
"all",
"(",
")",
";",
"}",
"// Perform other validations",
"foreach",
"(",
"$",
"this",
"->",
"validations",
"as",
"$",
"validationMethod",
")",
"{",
"if",
"(",
"$",
"message",
"=",
"$",
"this",
"->",
"{",
"$",
"validationMethod",
"}",
"(",
"$",
"model",
")",
")",
"{",
"$",
"messages",
"[",
"]",
"=",
"$",
"message",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"messages",
")",
")",
"{",
"throw",
"App",
"::",
"make",
"(",
"'sedp-mis.base-repository.validationException'",
",",
"$",
"messages",
")",
";",
"}",
"}"
] |
Validate model attributes before saving.
Throw an exception when validation fails.
@param string $operation
@param array|\Illuminate\Database\Eloquent\Model $model
@throws \Exception
@return void
|
[
"Validate",
"model",
"attributes",
"before",
"saving",
".",
"Throw",
"an",
"exception",
"when",
"validation",
"fails",
"."
] |
a55ac631bad78c6318f7efaa6a82dc1fbc3cc444
|
https://github.com/sedp-mis/base-repository/blob/a55ac631bad78c6318f7efaa6a82dc1fbc3cc444/src/Validation.php#L43-L69
|
3,860 |
sedp-mis/base-repository
|
src/Validation.php
|
Validation.interpolateValidationRules
|
protected function interpolateValidationRules($rules, $model)
{
foreach ($rules as &$rule) {
$attrs = last(chars_within($rule, ['{', '}']));
foreach ($attrs as $attr) {
$rule = str_replace(
'{'.$attr.'}',
// Useful for unique validation rule, which lets you check unique with exceptId parameter and
// other column keys combination. Example:
// 'name' => 'unique:parishes,name,{id},id,parish_category_id,{parish_category_id}'
is_null($model[$attr]) && $attr == $this->model->getKeyName() ? 'NULL' : $model[$attr],
$rule
);
}
}
return $rules;
}
|
php
|
protected function interpolateValidationRules($rules, $model)
{
foreach ($rules as &$rule) {
$attrs = last(chars_within($rule, ['{', '}']));
foreach ($attrs as $attr) {
$rule = str_replace(
'{'.$attr.'}',
// Useful for unique validation rule, which lets you check unique with exceptId parameter and
// other column keys combination. Example:
// 'name' => 'unique:parishes,name,{id},id,parish_category_id,{parish_category_id}'
is_null($model[$attr]) && $attr == $this->model->getKeyName() ? 'NULL' : $model[$attr],
$rule
);
}
}
return $rules;
}
|
[
"protected",
"function",
"interpolateValidationRules",
"(",
"$",
"rules",
",",
"$",
"model",
")",
"{",
"foreach",
"(",
"$",
"rules",
"as",
"&",
"$",
"rule",
")",
"{",
"$",
"attrs",
"=",
"last",
"(",
"chars_within",
"(",
"$",
"rule",
",",
"[",
"'{'",
",",
"'}'",
"]",
")",
")",
";",
"foreach",
"(",
"$",
"attrs",
"as",
"$",
"attr",
")",
"{",
"$",
"rule",
"=",
"str_replace",
"(",
"'{'",
".",
"$",
"attr",
".",
"'}'",
",",
"// Useful for unique validation rule, which lets you check unique with exceptId parameter and",
"// other column keys combination. Example:",
"// 'name' => 'unique:parishes,name,{id},id,parish_category_id,{parish_category_id}'",
"is_null",
"(",
"$",
"model",
"[",
"$",
"attr",
"]",
")",
"&&",
"$",
"attr",
"==",
"$",
"this",
"->",
"model",
"->",
"getKeyName",
"(",
")",
"?",
"'NULL'",
":",
"$",
"model",
"[",
"$",
"attr",
"]",
",",
"$",
"rule",
")",
";",
"}",
"}",
"return",
"$",
"rules",
";",
"}"
] |
Interpolate model attribute values on validation rules.
@param array $rules
@param array $model
@return array
|
[
"Interpolate",
"model",
"attribute",
"values",
"on",
"validation",
"rules",
"."
] |
a55ac631bad78c6318f7efaa6a82dc1fbc3cc444
|
https://github.com/sedp-mis/base-repository/blob/a55ac631bad78c6318f7efaa6a82dc1fbc3cc444/src/Validation.php#L78-L96
|
3,861 |
harvestcloud/CoreBundle
|
Entity/Location.php
|
Location.getAddress
|
public function getAddress($include_country = false)
{
$string = '';
if ($v = $this->getAddressLine1()) $string .= $v.', ';
if ($v = $this->getAddressLine2()) $string .= $v.', ';
if ($v = $this->getAddressLine3()) $string .= $v.', ';
$string .= $this->getCityStateZip();
if ($include_country) $string .= $this->getCountryCode();
return $string;
}
|
php
|
public function getAddress($include_country = false)
{
$string = '';
if ($v = $this->getAddressLine1()) $string .= $v.', ';
if ($v = $this->getAddressLine2()) $string .= $v.', ';
if ($v = $this->getAddressLine3()) $string .= $v.', ';
$string .= $this->getCityStateZip();
if ($include_country) $string .= $this->getCountryCode();
return $string;
}
|
[
"public",
"function",
"getAddress",
"(",
"$",
"include_country",
"=",
"false",
")",
"{",
"$",
"string",
"=",
"''",
";",
"if",
"(",
"$",
"v",
"=",
"$",
"this",
"->",
"getAddressLine1",
"(",
")",
")",
"$",
"string",
".=",
"$",
"v",
".",
"', '",
";",
"if",
"(",
"$",
"v",
"=",
"$",
"this",
"->",
"getAddressLine2",
"(",
")",
")",
"$",
"string",
".=",
"$",
"v",
".",
"', '",
";",
"if",
"(",
"$",
"v",
"=",
"$",
"this",
"->",
"getAddressLine3",
"(",
")",
")",
"$",
"string",
".=",
"$",
"v",
".",
"', '",
";",
"$",
"string",
".=",
"$",
"this",
"->",
"getCityStateZip",
"(",
")",
";",
"if",
"(",
"$",
"include_country",
")",
"$",
"string",
".=",
"$",
"this",
"->",
"getCountryCode",
"(",
")",
";",
"return",
"$",
"string",
";",
"}"
] |
Get address string
@author Tom Haskins-Vaughan <[email protected]>
@since 2012-04-25
@param bool $include_country
@return string
|
[
"Get",
"address",
"string"
] |
f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc
|
https://github.com/harvestcloud/CoreBundle/blob/f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc/Entity/Location.php#L524-L535
|
3,862 |
ionutmilica/ionix-framework
|
src/Foundation/ClassLoader.php
|
ClassLoader.load
|
public function load($class)
{
if ($class[0] == '\\') $class = substr($class, 1);
$class = str_replace(array('\\', '_'), DIRECTORY_SEPARATOR, $class).'.php';
foreach ($this->directories as $directory)
{
if (file_exists($path = $directory.DIRECTORY_SEPARATOR.$class))
{
require_once $path;
return true;
}
}
return false;
}
|
php
|
public function load($class)
{
if ($class[0] == '\\') $class = substr($class, 1);
$class = str_replace(array('\\', '_'), DIRECTORY_SEPARATOR, $class).'.php';
foreach ($this->directories as $directory)
{
if (file_exists($path = $directory.DIRECTORY_SEPARATOR.$class))
{
require_once $path;
return true;
}
}
return false;
}
|
[
"public",
"function",
"load",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
"[",
"0",
"]",
"==",
"'\\\\'",
")",
"$",
"class",
"=",
"substr",
"(",
"$",
"class",
",",
"1",
")",
";",
"$",
"class",
"=",
"str_replace",
"(",
"array",
"(",
"'\\\\'",
",",
"'_'",
")",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"class",
")",
".",
"'.php'",
";",
"foreach",
"(",
"$",
"this",
"->",
"directories",
"as",
"$",
"directory",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"path",
"=",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"class",
")",
")",
"{",
"require_once",
"$",
"path",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Search and load a specific class. Used for auto-loader.
@param $class
@return bool
|
[
"Search",
"and",
"load",
"a",
"specific",
"class",
".",
"Used",
"for",
"auto",
"-",
"loader",
"."
] |
a0363667ff677f1772bdd9ac9530a9f4710f9321
|
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Foundation/ClassLoader.php#L27-L41
|
3,863 |
slayerfat/VzlaPhoneParser
|
src/PhoneParser.php
|
PhoneParser.execute
|
private function execute($regex, $data)
{
$matches = [];
preg_match($regex, (string)$data, $matches);
return $matches;
}
|
php
|
private function execute($regex, $data)
{
$matches = [];
preg_match($regex, (string)$data, $matches);
return $matches;
}
|
[
"private",
"function",
"execute",
"(",
"$",
"regex",
",",
"$",
"data",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"preg_match",
"(",
"$",
"regex",
",",
"(",
"string",
")",
"$",
"data",
",",
"$",
"matches",
")",
";",
"return",
"$",
"matches",
";",
"}"
] |
Ejecuta la comprobacion por medio de regex
y devuelve lo se pudo capturar.
@param string $regex el regex a ejecutar
@param string $data el texto al que se hara la comprobacion.
@return string[]
|
[
"Ejecuta",
"la",
"comprobacion",
"por",
"medio",
"de",
"regex",
"y",
"devuelve",
"lo",
"se",
"pudo",
"capturar",
"."
] |
d06d06496bbc99e4795a71eced0eda2b326044c7
|
https://github.com/slayerfat/VzlaPhoneParser/blob/d06d06496bbc99e4795a71eced0eda2b326044c7/src/PhoneParser.php#L63-L70
|
3,864 |
faustbrian/binary
|
src/Buffer/Writer/Concerns/UnsignedInteger.php
|
UnsignedInteger.writeUInt8
|
public function writeUInt8(int $value): self
{
$this->bytes .= Writer::bit8($value);
return $this;
}
|
php
|
public function writeUInt8(int $value): self
{
$this->bytes .= Writer::bit8($value);
return $this;
}
|
[
"public",
"function",
"writeUInt8",
"(",
"int",
"$",
"value",
")",
":",
"self",
"{",
"$",
"this",
"->",
"bytes",
".=",
"Writer",
"::",
"bit8",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Write an unsigned 8 bit integer.
@param int $value
@return \BrianFaust\Binary\Buffer\Writer\Buffer
|
[
"Write",
"an",
"unsigned",
"8",
"bit",
"integer",
"."
] |
7d845497460c2dabf7e369ec8e55baf989ef74cb
|
https://github.com/faustbrian/binary/blob/7d845497460c2dabf7e369ec8e55baf989ef74cb/src/Buffer/Writer/Concerns/UnsignedInteger.php#L27-L32
|
3,865 |
faustbrian/binary
|
src/Buffer/Writer/Concerns/UnsignedInteger.php
|
UnsignedInteger.writeUInt16
|
public function writeUInt16(int $value): self
{
$this->bytes .= Writer::bit16($value);
return $this;
}
|
php
|
public function writeUInt16(int $value): self
{
$this->bytes .= Writer::bit16($value);
return $this;
}
|
[
"public",
"function",
"writeUInt16",
"(",
"int",
"$",
"value",
")",
":",
"self",
"{",
"$",
"this",
"->",
"bytes",
".=",
"Writer",
"::",
"bit16",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Write an unsigned 16 bit integer.
@param int $value
@return \BrianFaust\Binary\Buffer\Writer\Buffer
|
[
"Write",
"an",
"unsigned",
"16",
"bit",
"integer",
"."
] |
7d845497460c2dabf7e369ec8e55baf989ef74cb
|
https://github.com/faustbrian/binary/blob/7d845497460c2dabf7e369ec8e55baf989ef74cb/src/Buffer/Writer/Concerns/UnsignedInteger.php#L41-L46
|
3,866 |
faustbrian/binary
|
src/Buffer/Writer/Concerns/UnsignedInteger.php
|
UnsignedInteger.writeUInt32
|
public function writeUInt32(int $value): self
{
$this->bytes .= Writer::bit32($value);
return $this;
}
|
php
|
public function writeUInt32(int $value): self
{
$this->bytes .= Writer::bit32($value);
return $this;
}
|
[
"public",
"function",
"writeUInt32",
"(",
"int",
"$",
"value",
")",
":",
"self",
"{",
"$",
"this",
"->",
"bytes",
".=",
"Writer",
"::",
"bit32",
"(",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Write an unsigned 32 bit integer.
@param int $value
@return \BrianFaust\Binary\Buffer\Writer\Buffer
|
[
"Write",
"an",
"unsigned",
"32",
"bit",
"integer",
"."
] |
7d845497460c2dabf7e369ec8e55baf989ef74cb
|
https://github.com/faustbrian/binary/blob/7d845497460c2dabf7e369ec8e55baf989ef74cb/src/Buffer/Writer/Concerns/UnsignedInteger.php#L55-L60
|
3,867 |
ytubes/videos
|
controllers/RecentController.php
|
RecentController.actionIndex
|
public function actionIndex($page = 1)
{
$this->trigger(self::EVENT_BEFORE_RECENT_SHOW);
$data['page'] = (int) $page;
$data['route'] = '/' . $this->getRoute();
$finder = new VideoFinder();
$data['videos'] = $finder->getNewVideos($page);
$data['total_items'] = $finder->totalCount();
$pagination = new Pagination([
'totalCount' => $data['total_items'],
'defaultPageSize' => Module::getInstance()->settings->get('items_per_page', 20),
'pageSize' => Module::getInstance()->settings->get('items_per_page', 20),
'route' => $data['route'],
'forcePageParam' => false,
]);
$settings = Yii::$app->settings->getAll();
$settings['videos'] = Module::getInstance()->settings->getAll();
$this->trigger(self::EVENT_AFTER_RECENT_SHOW);
return $this->render('recent', [
'data' => $data,
'settings' => $settings,
'pagination' => $pagination,
]);
}
|
php
|
public function actionIndex($page = 1)
{
$this->trigger(self::EVENT_BEFORE_RECENT_SHOW);
$data['page'] = (int) $page;
$data['route'] = '/' . $this->getRoute();
$finder = new VideoFinder();
$data['videos'] = $finder->getNewVideos($page);
$data['total_items'] = $finder->totalCount();
$pagination = new Pagination([
'totalCount' => $data['total_items'],
'defaultPageSize' => Module::getInstance()->settings->get('items_per_page', 20),
'pageSize' => Module::getInstance()->settings->get('items_per_page', 20),
'route' => $data['route'],
'forcePageParam' => false,
]);
$settings = Yii::$app->settings->getAll();
$settings['videos'] = Module::getInstance()->settings->getAll();
$this->trigger(self::EVENT_AFTER_RECENT_SHOW);
return $this->render('recent', [
'data' => $data,
'settings' => $settings,
'pagination' => $pagination,
]);
}
|
[
"public",
"function",
"actionIndex",
"(",
"$",
"page",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_BEFORE_RECENT_SHOW",
")",
";",
"$",
"data",
"[",
"'page'",
"]",
"=",
"(",
"int",
")",
"$",
"page",
";",
"$",
"data",
"[",
"'route'",
"]",
"=",
"'/'",
".",
"$",
"this",
"->",
"getRoute",
"(",
")",
";",
"$",
"finder",
"=",
"new",
"VideoFinder",
"(",
")",
";",
"$",
"data",
"[",
"'videos'",
"]",
"=",
"$",
"finder",
"->",
"getNewVideos",
"(",
"$",
"page",
")",
";",
"$",
"data",
"[",
"'total_items'",
"]",
"=",
"$",
"finder",
"->",
"totalCount",
"(",
")",
";",
"$",
"pagination",
"=",
"new",
"Pagination",
"(",
"[",
"'totalCount'",
"=>",
"$",
"data",
"[",
"'total_items'",
"]",
",",
"'defaultPageSize'",
"=>",
"Module",
"::",
"getInstance",
"(",
")",
"->",
"settings",
"->",
"get",
"(",
"'items_per_page'",
",",
"20",
")",
",",
"'pageSize'",
"=>",
"Module",
"::",
"getInstance",
"(",
")",
"->",
"settings",
"->",
"get",
"(",
"'items_per_page'",
",",
"20",
")",
",",
"'route'",
"=>",
"$",
"data",
"[",
"'route'",
"]",
",",
"'forcePageParam'",
"=>",
"false",
",",
"]",
")",
";",
"$",
"settings",
"=",
"Yii",
"::",
"$",
"app",
"->",
"settings",
"->",
"getAll",
"(",
")",
";",
"$",
"settings",
"[",
"'videos'",
"]",
"=",
"Module",
"::",
"getInstance",
"(",
")",
"->",
"settings",
"->",
"getAll",
"(",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_AFTER_RECENT_SHOW",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'recent'",
",",
"[",
"'data'",
"=>",
"$",
"data",
",",
"'settings'",
"=>",
"$",
"settings",
",",
"'pagination'",
"=>",
"$",
"pagination",
",",
"]",
")",
";",
"}"
] |
Lists all Videos models.
@return mixed
|
[
"Lists",
"all",
"Videos",
"models",
"."
] |
a35ecb1f8e38381063fbd757683a13df3a8cbc48
|
https://github.com/ytubes/videos/blob/a35ecb1f8e38381063fbd757683a13df3a8cbc48/controllers/RecentController.php#L49-L78
|
3,868 |
olajoscs/QueryBuilder
|
src/Common/Connection.php
|
Connection.bindParameters
|
protected function bindParameters(\PDOStatement $statement, array $parameters, $prefix = '')
{
foreach ($parameters as $key => $value) {
// In case of multiple rows are given for insert statement
if (is_array($value)) {
$statement = $this->bindParameters($statement, $value, $prefix . $key);
} else {
switch (true) {
case is_int($value):
$type = \PDO::PARAM_INT;
break;
case is_bool($value):
$type = \PDO::PARAM_BOOL;
break;
case $value === null:
$type = \PDO::PARAM_NULL;
break;
case $value instanceof \DateTimeInterface:
$type = \PDO::PARAM_STR;
$value = $value->format('Y-m-d H:i:s.u');
break;
default:
$type = \PDO::PARAM_STR;
}
$statement->bindValue($prefix . $key, $value, $type);
}
}
return $statement;
}
|
php
|
protected function bindParameters(\PDOStatement $statement, array $parameters, $prefix = '')
{
foreach ($parameters as $key => $value) {
// In case of multiple rows are given for insert statement
if (is_array($value)) {
$statement = $this->bindParameters($statement, $value, $prefix . $key);
} else {
switch (true) {
case is_int($value):
$type = \PDO::PARAM_INT;
break;
case is_bool($value):
$type = \PDO::PARAM_BOOL;
break;
case $value === null:
$type = \PDO::PARAM_NULL;
break;
case $value instanceof \DateTimeInterface:
$type = \PDO::PARAM_STR;
$value = $value->format('Y-m-d H:i:s.u');
break;
default:
$type = \PDO::PARAM_STR;
}
$statement->bindValue($prefix . $key, $value, $type);
}
}
return $statement;
}
|
[
"protected",
"function",
"bindParameters",
"(",
"\\",
"PDOStatement",
"$",
"statement",
",",
"array",
"$",
"parameters",
",",
"$",
"prefix",
"=",
"''",
")",
"{",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// In case of multiple rows are given for insert statement",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"bindParameters",
"(",
"$",
"statement",
",",
"$",
"value",
",",
"$",
"prefix",
".",
"$",
"key",
")",
";",
"}",
"else",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"is_int",
"(",
"$",
"value",
")",
":",
"$",
"type",
"=",
"\\",
"PDO",
"::",
"PARAM_INT",
";",
"break",
";",
"case",
"is_bool",
"(",
"$",
"value",
")",
":",
"$",
"type",
"=",
"\\",
"PDO",
"::",
"PARAM_BOOL",
";",
"break",
";",
"case",
"$",
"value",
"===",
"null",
":",
"$",
"type",
"=",
"\\",
"PDO",
"::",
"PARAM_NULL",
";",
"break",
";",
"case",
"$",
"value",
"instanceof",
"\\",
"DateTimeInterface",
":",
"$",
"type",
"=",
"\\",
"PDO",
"::",
"PARAM_STR",
";",
"$",
"value",
"=",
"$",
"value",
"->",
"format",
"(",
"'Y-m-d H:i:s.u'",
")",
";",
"break",
";",
"default",
":",
"$",
"type",
"=",
"\\",
"PDO",
"::",
"PARAM_STR",
";",
"}",
"$",
"statement",
"->",
"bindValue",
"(",
"$",
"prefix",
".",
"$",
"key",
",",
"$",
"value",
",",
"$",
"type",
")",
";",
"}",
"}",
"return",
"$",
"statement",
";",
"}"
] |
Bind the parameters to the statement
@param \PDOStatement $statement
@param array $parameters
@param string $prefix
@return \PDOStatement
|
[
"Bind",
"the",
"parameters",
"to",
"the",
"statement"
] |
5e1568ced2c2c7f0294cf32f30a290db1e642035
|
https://github.com/olajoscs/QueryBuilder/blob/5e1568ced2c2c7f0294cf32f30a290db1e642035/src/Common/Connection.php#L256-L286
|
3,869 |
olajoscs/QueryBuilder
|
src/Common/Connection.php
|
Connection.readOne
|
protected function readOne($query, $parameters)
{
$statement = $this->execute($query, $parameters);
$rowCount = $statement->rowCount();
if ($rowCount > 1) {
throw new MultipleRowFoundException('Multiple row found for query: ' . $query);
}
if ($rowCount === 0) {
throw new RowNotFoundException('Row not found for query: ' . $query);
}
return $statement;
}
|
php
|
protected function readOne($query, $parameters)
{
$statement = $this->execute($query, $parameters);
$rowCount = $statement->rowCount();
if ($rowCount > 1) {
throw new MultipleRowFoundException('Multiple row found for query: ' . $query);
}
if ($rowCount === 0) {
throw new RowNotFoundException('Row not found for query: ' . $query);
}
return $statement;
}
|
[
"protected",
"function",
"readOne",
"(",
"$",
"query",
",",
"$",
"parameters",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"execute",
"(",
"$",
"query",
",",
"$",
"parameters",
")",
";",
"$",
"rowCount",
"=",
"$",
"statement",
"->",
"rowCount",
"(",
")",
";",
"if",
"(",
"$",
"rowCount",
">",
"1",
")",
"{",
"throw",
"new",
"MultipleRowFoundException",
"(",
"'Multiple row found for query: '",
".",
"$",
"query",
")",
";",
"}",
"if",
"(",
"$",
"rowCount",
"===",
"0",
")",
"{",
"throw",
"new",
"RowNotFoundException",
"(",
"'Row not found for query: '",
".",
"$",
"query",
")",
";",
"}",
"return",
"$",
"statement",
";",
"}"
] |
Return the statement checked that the result contains only 1 row
@param string $query
@param array $parameters
@return \PDOStatement
@throws MultipleRowFoundException
@throws RowNotFoundException
|
[
"Return",
"the",
"statement",
"checked",
"that",
"the",
"result",
"contains",
"only",
"1",
"row"
] |
5e1568ced2c2c7f0294cf32f30a290db1e642035
|
https://github.com/olajoscs/QueryBuilder/blob/5e1568ced2c2c7f0294cf32f30a290db1e642035/src/Common/Connection.php#L299-L313
|
3,870 |
olajoscs/QueryBuilder
|
src/Common/Connection.php
|
Connection.processWithKey
|
private function processWithKey(array $rows, $keyField)
{
if (empty($rows)) {
return [];
}
$first = reset($rows);
if (!isset($first->$keyField)) {
throw new FieldNotFoundException($keyField . ' field not found in result of the query');
}
$result = [];
foreach ($rows as $row) {
$result[$row->$keyField] = $row;
}
return $result;
}
|
php
|
private function processWithKey(array $rows, $keyField)
{
if (empty($rows)) {
return [];
}
$first = reset($rows);
if (!isset($first->$keyField)) {
throw new FieldNotFoundException($keyField . ' field not found in result of the query');
}
$result = [];
foreach ($rows as $row) {
$result[$row->$keyField] = $row;
}
return $result;
}
|
[
"private",
"function",
"processWithKey",
"(",
"array",
"$",
"rows",
",",
"$",
"keyField",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"rows",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"first",
"=",
"reset",
"(",
"$",
"rows",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"first",
"->",
"$",
"keyField",
")",
")",
"{",
"throw",
"new",
"FieldNotFoundException",
"(",
"$",
"keyField",
".",
"' field not found in result of the query'",
")",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"$",
"result",
"[",
"$",
"row",
"->",
"$",
"keyField",
"]",
"=",
"$",
"row",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Process the queried rows into an array which has the keyField keys
@param array $rows
@param string $keyField
@return array
@throws FieldNotFoundException
|
[
"Process",
"the",
"queried",
"rows",
"into",
"an",
"array",
"which",
"has",
"the",
"keyField",
"keys"
] |
5e1568ced2c2c7f0294cf32f30a290db1e642035
|
https://github.com/olajoscs/QueryBuilder/blob/5e1568ced2c2c7f0294cf32f30a290db1e642035/src/Common/Connection.php#L325-L343
|
3,871 |
drmvc/helpers
|
src/Helpers/Clean.php
|
Clean.run
|
public static function run($value, string $type = null)
{
switch ($type) {
case 'int':
$regexp = self::compileRegexp(self::INT);
break;
case 'float':
$regexp = self::compileRegexp(self::FLOAT);
break;
case 'text':
$value = self::fixQuotes($value);
$regexp = self::compileRegexp(self::CHARS_RUS . self::CHARS_ENG);
break;
default:
$value = self::fixQuotes($value);
$regexp = self::compileRegexp(
self::CHARS_RUS . self::CHARS_ENG . self::FLOAT .
'—~`@%[]/:<>;?&()_!$^-+=' . self::SUPER
);
break;
}
return preg_replace($regexp, '', $value);
}
|
php
|
public static function run($value, string $type = null)
{
switch ($type) {
case 'int':
$regexp = self::compileRegexp(self::INT);
break;
case 'float':
$regexp = self::compileRegexp(self::FLOAT);
break;
case 'text':
$value = self::fixQuotes($value);
$regexp = self::compileRegexp(self::CHARS_RUS . self::CHARS_ENG);
break;
default:
$value = self::fixQuotes($value);
$regexp = self::compileRegexp(
self::CHARS_RUS . self::CHARS_ENG . self::FLOAT .
'—~`@%[]/:<>;?&()_!$^-+=' . self::SUPER
);
break;
}
return preg_replace($regexp, '', $value);
}
|
[
"public",
"static",
"function",
"run",
"(",
"$",
"value",
",",
"string",
"$",
"type",
"=",
"null",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'int'",
":",
"$",
"regexp",
"=",
"self",
"::",
"compileRegexp",
"(",
"self",
"::",
"INT",
")",
";",
"break",
";",
"case",
"'float'",
":",
"$",
"regexp",
"=",
"self",
"::",
"compileRegexp",
"(",
"self",
"::",
"FLOAT",
")",
";",
"break",
";",
"case",
"'text'",
":",
"$",
"value",
"=",
"self",
"::",
"fixQuotes",
"(",
"$",
"value",
")",
";",
"$",
"regexp",
"=",
"self",
"::",
"compileRegexp",
"(",
"self",
"::",
"CHARS_RUS",
".",
"self",
"::",
"CHARS_ENG",
")",
";",
"break",
";",
"default",
":",
"$",
"value",
"=",
"self",
"::",
"fixQuotes",
"(",
"$",
"value",
")",
";",
"$",
"regexp",
"=",
"self",
"::",
"compileRegexp",
"(",
"self",
"::",
"CHARS_RUS",
".",
"self",
"::",
"CHARS_ENG",
".",
"self",
"::",
"FLOAT",
".",
"'—~`@%[]/:<>;?&()_!$^-+=' .",
"s",
"lf::",
"SU",
"PER",
")",
";",
"break",
";",
"}",
"return",
"preg_replace",
"(",
"$",
"regexp",
",",
"''",
",",
"$",
"value",
")",
";",
"}"
] |
Cleanup the value
@param string|int|null $value
@param string $type
@return mixed
|
[
"Cleanup",
"the",
"value"
] |
1a9a3f8d4c655b48ddbd61a81eb15688ad207d7b
|
https://github.com/drmvc/helpers/blob/1a9a3f8d4c655b48ddbd61a81eb15688ad207d7b/src/Helpers/Clean.php#L46-L69
|
3,872 |
matteosister/PygmentsElephantBundle
|
PygmentsElephant/PygmentizeBinary.php
|
PygmentizeBinary.execute
|
public function execute(Pygmentize $pygmentize, array $options)
{
$cmd = sprintf('-f %s -l %s -O encoding=%s %s %s',
$pygmentize->getFormat(),
$pygmentize->getLexer(),
mb_detect_encoding(file_get_contents($pygmentize->getSubject())),
$this->generateOptions($options),
$pygmentize->getSubject()
);
return $this->executeCommand($cmd);
}
|
php
|
public function execute(Pygmentize $pygmentize, array $options)
{
$cmd = sprintf('-f %s -l %s -O encoding=%s %s %s',
$pygmentize->getFormat(),
$pygmentize->getLexer(),
mb_detect_encoding(file_get_contents($pygmentize->getSubject())),
$this->generateOptions($options),
$pygmentize->getSubject()
);
return $this->executeCommand($cmd);
}
|
[
"public",
"function",
"execute",
"(",
"Pygmentize",
"$",
"pygmentize",
",",
"array",
"$",
"options",
")",
"{",
"$",
"cmd",
"=",
"sprintf",
"(",
"'-f %s -l %s -O encoding=%s %s %s'",
",",
"$",
"pygmentize",
"->",
"getFormat",
"(",
")",
",",
"$",
"pygmentize",
"->",
"getLexer",
"(",
")",
",",
"mb_detect_encoding",
"(",
"file_get_contents",
"(",
"$",
"pygmentize",
"->",
"getSubject",
"(",
")",
")",
")",
",",
"$",
"this",
"->",
"generateOptions",
"(",
"$",
"options",
")",
",",
"$",
"pygmentize",
"->",
"getSubject",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"executeCommand",
"(",
"$",
"cmd",
")",
";",
"}"
] |
execute a call to pygmentize binary
@param Pygmentize $pygmentize
@param array $options
@return string
|
[
"execute",
"a",
"call",
"to",
"pygmentize",
"binary"
] |
647cc00272126314f6d083d8b2350a9d6280bade
|
https://github.com/matteosister/PygmentsElephantBundle/blob/647cc00272126314f6d083d8b2350a9d6280bade/PygmentsElephant/PygmentizeBinary.php#L72-L83
|
3,873 |
matteosister/PygmentsElephantBundle
|
PygmentsElephant/PygmentizeBinary.php
|
PygmentizeBinary.executeCommand
|
public function executeCommand($command)
{
$cmd = sprintf('%s %s', $this->binaryPath, $command);
$p = new Process($cmd);
$p->run();
if ($p->isSuccessful()) {
return $p->getOutput();
} else {
throw new \RuntimeException(sprintf('pygmentize failed with the error: %s', $p->getErrorOutput()));
}
}
|
php
|
public function executeCommand($command)
{
$cmd = sprintf('%s %s', $this->binaryPath, $command);
$p = new Process($cmd);
$p->run();
if ($p->isSuccessful()) {
return $p->getOutput();
} else {
throw new \RuntimeException(sprintf('pygmentize failed with the error: %s', $p->getErrorOutput()));
}
}
|
[
"public",
"function",
"executeCommand",
"(",
"$",
"command",
")",
"{",
"$",
"cmd",
"=",
"sprintf",
"(",
"'%s %s'",
",",
"$",
"this",
"->",
"binaryPath",
",",
"$",
"command",
")",
";",
"$",
"p",
"=",
"new",
"Process",
"(",
"$",
"cmd",
")",
";",
"$",
"p",
"->",
"run",
"(",
")",
";",
"if",
"(",
"$",
"p",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"return",
"$",
"p",
"->",
"getOutput",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'pygmentize failed with the error: %s'",
",",
"$",
"p",
"->",
"getErrorOutput",
"(",
")",
")",
")",
";",
"}",
"}"
] |
executes a command
@param string $command command
@return string
@throws \RuntimeException
|
[
"executes",
"a",
"command"
] |
647cc00272126314f6d083d8b2350a9d6280bade
|
https://github.com/matteosister/PygmentsElephantBundle/blob/647cc00272126314f6d083d8b2350a9d6280bade/PygmentsElephant/PygmentizeBinary.php#L106-L116
|
3,874 |
matteosister/PygmentsElephantBundle
|
PygmentsElephant/PygmentizeBinary.php
|
PygmentizeBinary.guessLexer
|
public function guessLexer($filename)
{
$cmd = sprintf('%s -N %s', $this->binaryPath, $filename);
$p = new Process($cmd);
$p->run();
$output = trim($p->getOutput());
if ('text' === $output) {
$output = $this->guessFromExtension($filename);
}
if ('text' === $output) {
$output = $this->guessFromContent($filename);
}
return $output;
}
|
php
|
public function guessLexer($filename)
{
$cmd = sprintf('%s -N %s', $this->binaryPath, $filename);
$p = new Process($cmd);
$p->run();
$output = trim($p->getOutput());
if ('text' === $output) {
$output = $this->guessFromExtension($filename);
}
if ('text' === $output) {
$output = $this->guessFromContent($filename);
}
return $output;
}
|
[
"public",
"function",
"guessLexer",
"(",
"$",
"filename",
")",
"{",
"$",
"cmd",
"=",
"sprintf",
"(",
"'%s -N %s'",
",",
"$",
"this",
"->",
"binaryPath",
",",
"$",
"filename",
")",
";",
"$",
"p",
"=",
"new",
"Process",
"(",
"$",
"cmd",
")",
";",
"$",
"p",
"->",
"run",
"(",
")",
";",
"$",
"output",
"=",
"trim",
"(",
"$",
"p",
"->",
"getOutput",
"(",
")",
")",
";",
"if",
"(",
"'text'",
"===",
"$",
"output",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"guessFromExtension",
"(",
"$",
"filename",
")",
";",
"}",
"if",
"(",
"'text'",
"===",
"$",
"output",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"guessFromContent",
"(",
"$",
"filename",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
guess the lexer from the filename
@param string $filename file name
@return string
|
[
"guess",
"the",
"lexer",
"from",
"the",
"filename"
] |
647cc00272126314f6d083d8b2350a9d6280bade
|
https://github.com/matteosister/PygmentsElephantBundle/blob/647cc00272126314f6d083d8b2350a9d6280bade/PygmentsElephant/PygmentizeBinary.php#L125-L139
|
3,875 |
matteosister/PygmentsElephantBundle
|
PygmentsElephant/PygmentizeBinary.php
|
PygmentizeBinary.guessFromContent
|
private function guessFromContent($filename)
{
$output = 'text';
if (!is_file($filename)) {
return $output;
}
if ($fileContents = file_get_contents($filename)) {
if (1 === preg_match('/<?xml.*?>/', $fileContents)) {
$output = 'xml';
}
}
return $output;
}
|
php
|
private function guessFromContent($filename)
{
$output = 'text';
if (!is_file($filename)) {
return $output;
}
if ($fileContents = file_get_contents($filename)) {
if (1 === preg_match('/<?xml.*?>/', $fileContents)) {
$output = 'xml';
}
}
return $output;
}
|
[
"private",
"function",
"guessFromContent",
"(",
"$",
"filename",
")",
"{",
"$",
"output",
"=",
"'text'",
";",
"if",
"(",
"!",
"is_file",
"(",
"$",
"filename",
")",
")",
"{",
"return",
"$",
"output",
";",
"}",
"if",
"(",
"$",
"fileContents",
"=",
"file_get_contents",
"(",
"$",
"filename",
")",
")",
"{",
"if",
"(",
"1",
"===",
"preg_match",
"(",
"'/<?xml.*?>/'",
",",
"$",
"fileContents",
")",
")",
"{",
"$",
"output",
"=",
"'xml'",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] |
try to guess lexer from the file content, by searching some text
@param string $filename file name
@return string
|
[
"try",
"to",
"guess",
"lexer",
"from",
"the",
"file",
"content",
"by",
"searching",
"some",
"text"
] |
647cc00272126314f6d083d8b2350a9d6280bade
|
https://github.com/matteosister/PygmentsElephantBundle/blob/647cc00272126314f6d083d8b2350a9d6280bade/PygmentsElephant/PygmentizeBinary.php#L170-L183
|
3,876 |
grape-fluid/link-collector
|
src/LinkCollector.php
|
LinkCollector.generateCollections
|
public function generateCollections()
{
$collections = $this->collections;
$this->collections = [];
foreach ($collections as $category => $detail)
{
foreach ($detail['class'] as $class) {
if (!in_array(ILinkCollection::class, class_implements($class))) {
throw new \LogicException("Collection must implement 'Grapesc\GrapeFluid\LinkCollector\ILinkCollection' interface");
}
if (!isset($detail['name'])) {
$detail['name'] = $category;
}
$detail['icon'] = isset($detail['icon']) ? $detail['icon'] : "";
/** @var ILinkCollection $collection */
$collection = new $class;
$this->container->callInjects($collection);
$this->addCollection($category, $detail['name'], $detail['icon'], $collection->getLinks());
}
}
}
|
php
|
public function generateCollections()
{
$collections = $this->collections;
$this->collections = [];
foreach ($collections as $category => $detail)
{
foreach ($detail['class'] as $class) {
if (!in_array(ILinkCollection::class, class_implements($class))) {
throw new \LogicException("Collection must implement 'Grapesc\GrapeFluid\LinkCollector\ILinkCollection' interface");
}
if (!isset($detail['name'])) {
$detail['name'] = $category;
}
$detail['icon'] = isset($detail['icon']) ? $detail['icon'] : "";
/** @var ILinkCollection $collection */
$collection = new $class;
$this->container->callInjects($collection);
$this->addCollection($category, $detail['name'], $detail['icon'], $collection->getLinks());
}
}
}
|
[
"public",
"function",
"generateCollections",
"(",
")",
"{",
"$",
"collections",
"=",
"$",
"this",
"->",
"collections",
";",
"$",
"this",
"->",
"collections",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"collections",
"as",
"$",
"category",
"=>",
"$",
"detail",
")",
"{",
"foreach",
"(",
"$",
"detail",
"[",
"'class'",
"]",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"ILinkCollection",
"::",
"class",
",",
"class_implements",
"(",
"$",
"class",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"\"Collection must implement 'Grapesc\\GrapeFluid\\LinkCollector\\ILinkCollection' interface\"",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"detail",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"detail",
"[",
"'name'",
"]",
"=",
"$",
"category",
";",
"}",
"$",
"detail",
"[",
"'icon'",
"]",
"=",
"isset",
"(",
"$",
"detail",
"[",
"'icon'",
"]",
")",
"?",
"$",
"detail",
"[",
"'icon'",
"]",
":",
"\"\"",
";",
"/** @var ILinkCollection $collection */",
"$",
"collection",
"=",
"new",
"$",
"class",
";",
"$",
"this",
"->",
"container",
"->",
"callInjects",
"(",
"$",
"collection",
")",
";",
"$",
"this",
"->",
"addCollection",
"(",
"$",
"category",
",",
"$",
"detail",
"[",
"'name'",
"]",
",",
"$",
"detail",
"[",
"'icon'",
"]",
",",
"$",
"collection",
"->",
"getLinks",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Vygeneruje seznam kolekci dle vsech nakonfigurovanich Collection
Collection musi implementovat \Grapesc\GrapeFluid\LinkCollector\ILinkCollection
|
[
"Vygeneruje",
"seznam",
"kolekci",
"dle",
"vsech",
"nakonfigurovanich",
"Collection",
"Collection",
"musi",
"implementovat",
"\\",
"Grapesc",
"\\",
"GrapeFluid",
"\\",
"LinkCollector",
"\\",
"ILinkCollection"
] |
20992a021ae68198962793c42bc1bb6bbc0d3e66
|
https://github.com/grape-fluid/link-collector/blob/20992a021ae68198962793c42bc1bb6bbc0d3e66/src/LinkCollector.php#L38-L60
|
3,877 |
MINISTRYGmbH/morrow-core
|
src/Core/Frontcontroller.php
|
Frontcontroller.exceptionHandler
|
public function exceptionHandler($exception) {
try {
// load errorhandler
$debug = Factory::load('Debug');
$debug->errorhandler($exception);
} catch (\Exception $e) {
echo "<pre>$exception</pre>\n\n";
// useful if the \Exception handler itself contains errors
echo "<pre>The Debug class threw an exception:\n$e</pre>";
}
}
|
php
|
public function exceptionHandler($exception) {
try {
// load errorhandler
$debug = Factory::load('Debug');
$debug->errorhandler($exception);
} catch (\Exception $e) {
echo "<pre>$exception</pre>\n\n";
// useful if the \Exception handler itself contains errors
echo "<pre>The Debug class threw an exception:\n$e</pre>";
}
}
|
[
"public",
"function",
"exceptionHandler",
"(",
"$",
"exception",
")",
"{",
"try",
"{",
"// load errorhandler",
"$",
"debug",
"=",
"Factory",
"::",
"load",
"(",
"'Debug'",
")",
";",
"$",
"debug",
"->",
"errorhandler",
"(",
"$",
"exception",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"echo",
"\"<pre>$exception</pre>\\n\\n\"",
";",
"// useful if the \\Exception handler itself contains errors",
"echo",
"\"<pre>The Debug class threw an exception:\\n$e</pre>\"",
";",
"}",
"}"
] |
Will be set by the Constructor as global exception handler.
@param object $exception The thrown exception.
@return null
|
[
"Will",
"be",
"set",
"by",
"the",
"Constructor",
"as",
"global",
"exception",
"handler",
"."
] |
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
|
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Core/Frontcontroller.php#L72-L83
|
3,878 |
felixarntz/contracts
|
src/EnumTrait.php
|
EnumTrait.getConstList
|
public static function getConstList() : array
{
if (static::$constList === null) {
$reflection = new ReflectionClass(get_called_class());
static::$constList = array_values($reflection->getConstants());
}
return static::$constList;
}
|
php
|
public static function getConstList() : array
{
if (static::$constList === null) {
$reflection = new ReflectionClass(get_called_class());
static::$constList = array_values($reflection->getConstants());
}
return static::$constList;
}
|
[
"public",
"static",
"function",
"getConstList",
"(",
")",
":",
"array",
"{",
"if",
"(",
"static",
"::",
"$",
"constList",
"===",
"null",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"get_called_class",
"(",
")",
")",
";",
"static",
"::",
"$",
"constList",
"=",
"array_values",
"(",
"$",
"reflection",
"->",
"getConstants",
"(",
")",
")",
";",
"}",
"return",
"static",
"::",
"$",
"constList",
";",
"}"
] |
Gets all possible values as an array.
@since 1.0.0
@return array List of constants.
|
[
"Gets",
"all",
"possible",
"values",
"as",
"an",
"array",
"."
] |
4fa2272f7b3f29f3a8928a1c2bb085b787df7a4c
|
https://github.com/felixarntz/contracts/blob/4fa2272f7b3f29f3a8928a1c2bb085b787df7a4c/src/EnumTrait.php#L37-L45
|
3,879 |
easy-system/es-http
|
src/Factory/UriSchemeFactory.php
|
UriSchemeFactory.setForcedScheme
|
public static function setForcedScheme($scheme = null)
{
if (! is_string($scheme) && ! is_null($scheme)) {
throw new InvalidArgumentException(sprintf(
'Invalid scheme provided; must be an string or a null, "%s" received.',
is_object($scheme) ? get_class($scheme) : gettype($scheme)
));
}
static::$forcedScheme = $scheme;
}
|
php
|
public static function setForcedScheme($scheme = null)
{
if (! is_string($scheme) && ! is_null($scheme)) {
throw new InvalidArgumentException(sprintf(
'Invalid scheme provided; must be an string or a null, "%s" received.',
is_object($scheme) ? get_class($scheme) : gettype($scheme)
));
}
static::$forcedScheme = $scheme;
}
|
[
"public",
"static",
"function",
"setForcedScheme",
"(",
"$",
"scheme",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"scheme",
")",
"&&",
"!",
"is_null",
"(",
"$",
"scheme",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid scheme provided; must be an string or a null, \"%s\" received.'",
",",
"is_object",
"(",
"$",
"scheme",
")",
"?",
"get_class",
"(",
"$",
"scheme",
")",
":",
"gettype",
"(",
"$",
"scheme",
")",
")",
")",
";",
"}",
"static",
"::",
"$",
"forcedScheme",
"=",
"$",
"scheme",
";",
"}"
] |
Sets the Uri scheme for forced usage.
@param null|string $scheme Optional; null by default removes a forced
scheme. The Uri scheme
@throws \InvalidArgumentException If the received scheme is not a string
or not a null
|
[
"Sets",
"the",
"Uri",
"scheme",
"for",
"forced",
"usage",
"."
] |
dd5852e94901e147a7546a8715133408ece767a1
|
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Factory/UriSchemeFactory.php#L35-L44
|
3,880 |
easy-system/es-http
|
src/Factory/UriSchemeFactory.php
|
UriSchemeFactory.retrieve
|
public static function retrieve(array $server = null)
{
if (empty($server)) {
$server = $_SERVER;
}
$scheme = 'http';
if (isset($server['HTTPS']) && 'off' != $server['HTTPS']) {
$scheme = 'https';
}
return $scheme;
}
|
php
|
public static function retrieve(array $server = null)
{
if (empty($server)) {
$server = $_SERVER;
}
$scheme = 'http';
if (isset($server['HTTPS']) && 'off' != $server['HTTPS']) {
$scheme = 'https';
}
return $scheme;
}
|
[
"public",
"static",
"function",
"retrieve",
"(",
"array",
"$",
"server",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"server",
")",
")",
"{",
"$",
"server",
"=",
"$",
"_SERVER",
";",
"}",
"$",
"scheme",
"=",
"'http'",
";",
"if",
"(",
"isset",
"(",
"$",
"server",
"[",
"'HTTPS'",
"]",
")",
"&&",
"'off'",
"!=",
"$",
"server",
"[",
"'HTTPS'",
"]",
")",
"{",
"$",
"scheme",
"=",
"'https'",
";",
"}",
"return",
"$",
"scheme",
";",
"}"
] |
Retrieves the Uri scheme using incoming data, ignores a forced scheme.
If unable to retrieve the scheme, returns 'http'.
@param array $server Optional; null by default or empty array means
global $_SERVER. The source data
@return string Returns the Uri scheme if any, 'http' otherwise
|
[
"Retrieves",
"the",
"Uri",
"scheme",
"using",
"incoming",
"data",
"ignores",
"a",
"forced",
"scheme",
".",
"If",
"unable",
"to",
"retrieve",
"the",
"scheme",
"returns",
"http",
"."
] |
dd5852e94901e147a7546a8715133408ece767a1
|
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Factory/UriSchemeFactory.php#L82-L95
|
3,881 |
zepi/turbo-base
|
Zepi/Web/AccessControl/src/EventHandler/Activation.php
|
Activation.execute
|
public function execute(Framework $framework, WebRequest $request, Response $response)
{
$title = $this->translate('Activate account', '\\Zepi\\Web\\AccessControl');
// Prepare the page
$this->setTitle($title);
// Get the cluster
$uuid = $request->getRouteParam('uuid');
$activationToken = $request->getRouteParam('token');
// Activate the user
$result = array('result' => false, 'message' => $this->translate('Wrong request parameters.', '\\Zepi\\Web\\AccessControl'));
if ($uuid != false && $activationToken != false) {
$result = $this->activateUser($uuid, $activationToken);
}
// Display the result
$response->setOutput($this->render('\\Zepi\\Web\\AccessControl\\Templates\\Activation', array(
'result' => $result
)));
}
|
php
|
public function execute(Framework $framework, WebRequest $request, Response $response)
{
$title = $this->translate('Activate account', '\\Zepi\\Web\\AccessControl');
// Prepare the page
$this->setTitle($title);
// Get the cluster
$uuid = $request->getRouteParam('uuid');
$activationToken = $request->getRouteParam('token');
// Activate the user
$result = array('result' => false, 'message' => $this->translate('Wrong request parameters.', '\\Zepi\\Web\\AccessControl'));
if ($uuid != false && $activationToken != false) {
$result = $this->activateUser($uuid, $activationToken);
}
// Display the result
$response->setOutput($this->render('\\Zepi\\Web\\AccessControl\\Templates\\Activation', array(
'result' => $result
)));
}
|
[
"public",
"function",
"execute",
"(",
"Framework",
"$",
"framework",
",",
"WebRequest",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"title",
"=",
"$",
"this",
"->",
"translate",
"(",
"'Activate account'",
",",
"'\\\\Zepi\\\\Web\\\\AccessControl'",
")",
";",
"// Prepare the page",
"$",
"this",
"->",
"setTitle",
"(",
"$",
"title",
")",
";",
"// Get the cluster",
"$",
"uuid",
"=",
"$",
"request",
"->",
"getRouteParam",
"(",
"'uuid'",
")",
";",
"$",
"activationToken",
"=",
"$",
"request",
"->",
"getRouteParam",
"(",
"'token'",
")",
";",
"// Activate the user",
"$",
"result",
"=",
"array",
"(",
"'result'",
"=>",
"false",
",",
"'message'",
"=>",
"$",
"this",
"->",
"translate",
"(",
"'Wrong request parameters.'",
",",
"'\\\\Zepi\\\\Web\\\\AccessControl'",
")",
")",
";",
"if",
"(",
"$",
"uuid",
"!=",
"false",
"&&",
"$",
"activationToken",
"!=",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"activateUser",
"(",
"$",
"uuid",
",",
"$",
"activationToken",
")",
";",
"}",
"// Display the result",
"$",
"response",
"->",
"setOutput",
"(",
"$",
"this",
"->",
"render",
"(",
"'\\\\Zepi\\\\Web\\\\AccessControl\\\\Templates\\\\Activation'",
",",
"array",
"(",
"'result'",
"=>",
"$",
"result",
")",
")",
")",
";",
"}"
] |
Deletes a cluster in the database
@access public
@param \Zepi\Turbo\Framework $framework
@param \Zepi\Turbo\Request\WebRequest $request
@param \Zepi\Turbo\Response\Response $response
|
[
"Deletes",
"a",
"cluster",
"in",
"the",
"database"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/EventHandler/Activation.php#L65-L86
|
3,882 |
zepi/turbo-base
|
Zepi/Web/AccessControl/src/EventHandler/Activation.php
|
Activation.activateUser
|
protected function activateUser($uuid, $activationToken)
{
// Check the uuid
if (!$this->userManager->hasUserForUuid($uuid)) {
return array('result' => false, 'message' => $this->translate('Account with the given UUID does not exist.', '\\Zepi\\Web\\AccessControl'));
}
// Compare the activation token
$user = $this->userManager->getUserForUuid($uuid);
if ($user->getMetaData('activationToken') !== $activationToken) {
return array('result' => false, 'message' => $this->translate('The given activation token is not valid.', '\\Zepi\\Web\\AccessControl'));
}
// Remove the disabled access level
$this->accessControlManager->revokePermission($uuid, get_class($user), '\\Global\\Disabled');
$this->accessControlManager->grantPermission($uuid, get_class($user), '\\Global\\Active', 'Activation');
return array('result' => true, 'message' => $this->translate('Your account was activated successfully.', '\\Zepi\\Web\\AccessControl'));
}
|
php
|
protected function activateUser($uuid, $activationToken)
{
// Check the uuid
if (!$this->userManager->hasUserForUuid($uuid)) {
return array('result' => false, 'message' => $this->translate('Account with the given UUID does not exist.', '\\Zepi\\Web\\AccessControl'));
}
// Compare the activation token
$user = $this->userManager->getUserForUuid($uuid);
if ($user->getMetaData('activationToken') !== $activationToken) {
return array('result' => false, 'message' => $this->translate('The given activation token is not valid.', '\\Zepi\\Web\\AccessControl'));
}
// Remove the disabled access level
$this->accessControlManager->revokePermission($uuid, get_class($user), '\\Global\\Disabled');
$this->accessControlManager->grantPermission($uuid, get_class($user), '\\Global\\Active', 'Activation');
return array('result' => true, 'message' => $this->translate('Your account was activated successfully.', '\\Zepi\\Web\\AccessControl'));
}
|
[
"protected",
"function",
"activateUser",
"(",
"$",
"uuid",
",",
"$",
"activationToken",
")",
"{",
"// Check the uuid",
"if",
"(",
"!",
"$",
"this",
"->",
"userManager",
"->",
"hasUserForUuid",
"(",
"$",
"uuid",
")",
")",
"{",
"return",
"array",
"(",
"'result'",
"=>",
"false",
",",
"'message'",
"=>",
"$",
"this",
"->",
"translate",
"(",
"'Account with the given UUID does not exist.'",
",",
"'\\\\Zepi\\\\Web\\\\AccessControl'",
")",
")",
";",
"}",
"// Compare the activation token",
"$",
"user",
"=",
"$",
"this",
"->",
"userManager",
"->",
"getUserForUuid",
"(",
"$",
"uuid",
")",
";",
"if",
"(",
"$",
"user",
"->",
"getMetaData",
"(",
"'activationToken'",
")",
"!==",
"$",
"activationToken",
")",
"{",
"return",
"array",
"(",
"'result'",
"=>",
"false",
",",
"'message'",
"=>",
"$",
"this",
"->",
"translate",
"(",
"'The given activation token is not valid.'",
",",
"'\\\\Zepi\\\\Web\\\\AccessControl'",
")",
")",
";",
"}",
"// Remove the disabled access level",
"$",
"this",
"->",
"accessControlManager",
"->",
"revokePermission",
"(",
"$",
"uuid",
",",
"get_class",
"(",
"$",
"user",
")",
",",
"'\\\\Global\\\\Disabled'",
")",
";",
"$",
"this",
"->",
"accessControlManager",
"->",
"grantPermission",
"(",
"$",
"uuid",
",",
"get_class",
"(",
"$",
"user",
")",
",",
"'\\\\Global\\\\Active'",
",",
"'Activation'",
")",
";",
"return",
"array",
"(",
"'result'",
"=>",
"true",
",",
"'message'",
"=>",
"$",
"this",
"->",
"translate",
"(",
"'Your account was activated successfully.'",
",",
"'\\\\Zepi\\\\Web\\\\AccessControl'",
")",
")",
";",
"}"
] |
Activates the user or returns an error message
@access protected
@param string $uuid
@param string $activationToken
@return array
|
[
"Activates",
"the",
"user",
"or",
"returns",
"an",
"error",
"message"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/EventHandler/Activation.php#L96-L114
|
3,883 |
saxulum/saxulum-doctrine-orm-commands
|
src/Command/Proxy/DoctrineCommandHelper.php
|
DoctrineCommandHelper.setApplicationConnection
|
public static function setApplicationConnection(Application $application = null, $connName)
{
if (is_null($application)) {
throw new \InvalidArgumentException('Application instance needed!');
}
$helperSet = $application->getHelperSet();
/** @var ManagerRegistry $doctrine */
$doctrine = $helperSet->get('doctrine');
/** @var Connection $connection */
$connection = $doctrine->getConnection($connName);
$helperSet->set(new ConnectionHelper($connection), 'db');
}
|
php
|
public static function setApplicationConnection(Application $application = null, $connName)
{
if (is_null($application)) {
throw new \InvalidArgumentException('Application instance needed!');
}
$helperSet = $application->getHelperSet();
/** @var ManagerRegistry $doctrine */
$doctrine = $helperSet->get('doctrine');
/** @var Connection $connection */
$connection = $doctrine->getConnection($connName);
$helperSet->set(new ConnectionHelper($connection), 'db');
}
|
[
"public",
"static",
"function",
"setApplicationConnection",
"(",
"Application",
"$",
"application",
"=",
"null",
",",
"$",
"connName",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"application",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Application instance needed!'",
")",
";",
"}",
"$",
"helperSet",
"=",
"$",
"application",
"->",
"getHelperSet",
"(",
")",
";",
"/** @var ManagerRegistry $doctrine */",
"$",
"doctrine",
"=",
"$",
"helperSet",
"->",
"get",
"(",
"'doctrine'",
")",
";",
"/** @var Connection $connection */",
"$",
"connection",
"=",
"$",
"doctrine",
"->",
"getConnection",
"(",
"$",
"connName",
")",
";",
"$",
"helperSet",
"->",
"set",
"(",
"new",
"ConnectionHelper",
"(",
"$",
"connection",
")",
",",
"'db'",
")",
";",
"}"
] |
Convenience method to push the helper sets of a given connection into the application.
@param Application $application
@param string $connName
@throws \InvalidArgumentException
|
[
"Convenience",
"method",
"to",
"push",
"the",
"helper",
"sets",
"of",
"a",
"given",
"connection",
"into",
"the",
"application",
"."
] |
d1b70e19504a464cb1a0b46a671bbd11d02aca94
|
https://github.com/saxulum/saxulum-doctrine-orm-commands/blob/d1b70e19504a464cb1a0b46a671bbd11d02aca94/src/Command/Proxy/DoctrineCommandHelper.php#L62-L77
|
3,884 |
subugoe/typo3-pazpar2
|
Classes/Domain/Model/QueryServiceProxy.php
|
QueryServiceProxy.fetchURL
|
protected function fetchURL($URL)
{
$cookieHeader = [];
if ($this->cookie) {
$cookieHeader[] = 'Cookie: ' . $this->cookie . ';';
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $URL);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $cookieHeader);
$body = null;
$result = curl_exec($curl);
if ($result) {
$parts = explode("\r\n\r\n", $result, 2);
$headers = explode("\r\n", $parts[0]);
if (!$this->cookie) {
$setCookieString = 'Set-Cookie: ';
foreach ($headers as $header) {
if (strpos($header, $setCookieString) === 0) {
$cookieString = substr($header, strlen($setCookieString));
$cookieStringParts = explode(';', $cookieString);
$this->cookie = $cookieStringParts[0];
break;
}
}
}
$body = $parts[1];
}
return $body;
}
|
php
|
protected function fetchURL($URL)
{
$cookieHeader = [];
if ($this->cookie) {
$cookieHeader[] = 'Cookie: ' . $this->cookie . ';';
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $URL);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $cookieHeader);
$body = null;
$result = curl_exec($curl);
if ($result) {
$parts = explode("\r\n\r\n", $result, 2);
$headers = explode("\r\n", $parts[0]);
if (!$this->cookie) {
$setCookieString = 'Set-Cookie: ';
foreach ($headers as $header) {
if (strpos($header, $setCookieString) === 0) {
$cookieString = substr($header, strlen($setCookieString));
$cookieStringParts = explode(';', $cookieString);
$this->cookie = $cookieStringParts[0];
break;
}
}
}
$body = $parts[1];
}
return $body;
}
|
[
"protected",
"function",
"fetchURL",
"(",
"$",
"URL",
")",
"{",
"$",
"cookieHeader",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"cookie",
")",
"{",
"$",
"cookieHeader",
"[",
"]",
"=",
"'Cookie: '",
".",
"$",
"this",
"->",
"cookie",
".",
"';'",
";",
"}",
"$",
"curl",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_URL",
",",
"$",
"URL",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_HEADER",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_RETURNTRANSFER",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"cookieHeader",
")",
";",
"$",
"body",
"=",
"null",
";",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"curl",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"\"\\r\\n\\r\\n\"",
",",
"$",
"result",
",",
"2",
")",
";",
"$",
"headers",
"=",
"explode",
"(",
"\"\\r\\n\"",
",",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"cookie",
")",
"{",
"$",
"setCookieString",
"=",
"'Set-Cookie: '",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"header",
",",
"$",
"setCookieString",
")",
"===",
"0",
")",
"{",
"$",
"cookieString",
"=",
"substr",
"(",
"$",
"header",
",",
"strlen",
"(",
"$",
"setCookieString",
")",
")",
";",
"$",
"cookieStringParts",
"=",
"explode",
"(",
"';'",
",",
"$",
"cookieString",
")",
";",
"$",
"this",
"->",
"cookie",
"=",
"$",
"cookieStringParts",
"[",
"0",
"]",
";",
"break",
";",
"}",
"}",
"}",
"$",
"body",
"=",
"$",
"parts",
"[",
"1",
"]",
";",
"}",
"return",
"$",
"body",
";",
"}"
] |
Returns the content loaded from the given URL.
Uses curl to fetch the cookie from the response and insert it into
requests, if available.
@param string $URL to fetch
@return string
|
[
"Returns",
"the",
"content",
"loaded",
"from",
"the",
"given",
"URL",
".",
"Uses",
"curl",
"to",
"fetch",
"the",
"cookie",
"from",
"the",
"response",
"and",
"insert",
"it",
"into",
"requests",
"if",
"available",
"."
] |
3da8c483e24228d92dbb9fff034f0ff50ac937ef
|
https://github.com/subugoe/typo3-pazpar2/blob/3da8c483e24228d92dbb9fff034f0ff50ac937ef/Classes/Domain/Model/QueryServiceProxy.php#L90-L124
|
3,885 |
webforge-labs/webforge-common
|
lib/Webforge/Common/System/Util.php
|
Util.escapeShellArg
|
public static function escapeShellArg($arg, $escapeFor = NULL) {
$escaped = \Symfony\Component\Process\ProcessUtils::escapeArgument($arg);
return Preg::replace($escaped, '~(?<!\\\\)\\\\"$~', '\\\\\\"');
}
|
php
|
public static function escapeShellArg($arg, $escapeFor = NULL) {
$escaped = \Symfony\Component\Process\ProcessUtils::escapeArgument($arg);
return Preg::replace($escaped, '~(?<!\\\\)\\\\"$~', '\\\\\\"');
}
|
[
"public",
"static",
"function",
"escapeShellArg",
"(",
"$",
"arg",
",",
"$",
"escapeFor",
"=",
"NULL",
")",
"{",
"$",
"escaped",
"=",
"\\",
"Symfony",
"\\",
"Component",
"\\",
"Process",
"\\",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"$",
"arg",
")",
";",
"return",
"Preg",
"::",
"replace",
"(",
"$",
"escaped",
",",
"'~(?<!\\\\\\\\)\\\\\\\\\"$~'",
",",
"'\\\\\\\\\\\\\"'",
")",
";",
"}"
] |
This escapes shell arguments on windows correctly
@return string
|
[
"This",
"escapes",
"shell",
"arguments",
"on",
"windows",
"correctly"
] |
e07619d769e445469ab880325e68ad6d9fde8ca2
|
https://github.com/webforge-labs/webforge-common/blob/e07619d769e445469ab880325e68ad6d9fde8ca2/lib/Webforge/Common/System/Util.php#L35-L39
|
3,886 |
indigophp-archive/codeception-fuel-module
|
fuel/fuel/core/classes/controller.php
|
Controller.after
|
public function after($response)
{
// Make sure the $response is a Response object
if ( ! $response instanceof Response)
{
$response = \Response::forge($response, $this->response_status);
}
return $response;
}
|
php
|
public function after($response)
{
// Make sure the $response is a Response object
if ( ! $response instanceof Response)
{
$response = \Response::forge($response, $this->response_status);
}
return $response;
}
|
[
"public",
"function",
"after",
"(",
"$",
"response",
")",
"{",
"// Make sure the $response is a Response object",
"if",
"(",
"!",
"$",
"response",
"instanceof",
"Response",
")",
"{",
"$",
"response",
"=",
"\\",
"Response",
"::",
"forge",
"(",
"$",
"response",
",",
"$",
"this",
"->",
"response_status",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
This method gets called after the action is called
|
[
"This",
"method",
"gets",
"called",
"after",
"the",
"action",
"is",
"called"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/controller.php#L46-L55
|
3,887 |
nonetallt/jinitialize-core
|
src/Installer.php
|
Installer.askYesNo
|
public function askYesNo(string $prompt)
{
$prompt .= ' (y/n): ';
$result = null;
$result = $this->askUntillValid($prompt, function($answer) {
/* Lowercase user prompt */
$answer = strtolower($answer);
/* Correrct answer is y or n */
return $answer === 'y' || $answer === 'n';
});
return $result === 'y';
}
|
php
|
public function askYesNo(string $prompt)
{
$prompt .= ' (y/n): ';
$result = null;
$result = $this->askUntillValid($prompt, function($answer) {
/* Lowercase user prompt */
$answer = strtolower($answer);
/* Correrct answer is y or n */
return $answer === 'y' || $answer === 'n';
});
return $result === 'y';
}
|
[
"public",
"function",
"askYesNo",
"(",
"string",
"$",
"prompt",
")",
"{",
"$",
"prompt",
".=",
"' (y/n): '",
";",
"$",
"result",
"=",
"null",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"askUntillValid",
"(",
"$",
"prompt",
",",
"function",
"(",
"$",
"answer",
")",
"{",
"/* Lowercase user prompt */",
"$",
"answer",
"=",
"strtolower",
"(",
"$",
"answer",
")",
";",
"/* Correrct answer is y or n */",
"return",
"$",
"answer",
"===",
"'y'",
"||",
"$",
"answer",
"===",
"'n'",
";",
"}",
")",
";",
"return",
"$",
"result",
"===",
"'y'",
";",
"}"
] |
Prompt user to supply either a yes or no answer
@param string $prompt the prompt message
@return bool user answer, y = true : n = false
|
[
"Prompt",
"user",
"to",
"supply",
"either",
"a",
"yes",
"or",
"no",
"answer"
] |
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
|
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/Installer.php#L69-L83
|
3,888 |
nonetallt/jinitialize-core
|
src/Installer.php
|
Installer.askUntillValid
|
public function askUntillValid(string $prompt, callable $validationCallback)
{
$result = null;
while($validationCallback($result) !== true) {
$result = $this->readLine("$prompt");
}
return $result;
}
|
php
|
public function askUntillValid(string $prompt, callable $validationCallback)
{
$result = null;
while($validationCallback($result) !== true) {
$result = $this->readLine("$prompt");
}
return $result;
}
|
[
"public",
"function",
"askUntillValid",
"(",
"string",
"$",
"prompt",
",",
"callable",
"$",
"validationCallback",
")",
"{",
"$",
"result",
"=",
"null",
";",
"while",
"(",
"$",
"validationCallback",
"(",
"$",
"result",
")",
"!==",
"true",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"readLine",
"(",
"\"$prompt\"",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Prompt user for input untill the given input returns true from the
validation callback function.
@param string $prompt the prompt message
@param callable $validationCallback
@return $result user input that passed validation
|
[
"Prompt",
"user",
"for",
"input",
"untill",
"the",
"given",
"input",
"returns",
"true",
"from",
"the",
"validation",
"callback",
"function",
"."
] |
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
|
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/Installer.php#L94-L102
|
3,889 |
nonetallt/jinitialize-core
|
src/Installer.php
|
Installer.readline
|
private function readline(string $prompt)
{
if (PHP_OS == 'WINNT') {
echo $prompt;
$line = stream_get_line(STDIN, 1024, PHP_EOL);
} else {
$line = readline($prompt);
}
return $line;
}
|
php
|
private function readline(string $prompt)
{
if (PHP_OS == 'WINNT') {
echo $prompt;
$line = stream_get_line(STDIN, 1024, PHP_EOL);
} else {
$line = readline($prompt);
}
return $line;
}
|
[
"private",
"function",
"readline",
"(",
"string",
"$",
"prompt",
")",
"{",
"if",
"(",
"PHP_OS",
"==",
"'WINNT'",
")",
"{",
"echo",
"$",
"prompt",
";",
"$",
"line",
"=",
"stream_get_line",
"(",
"STDIN",
",",
"1024",
",",
"PHP_EOL",
")",
";",
"}",
"else",
"{",
"$",
"line",
"=",
"readline",
"(",
"$",
"prompt",
")",
";",
"}",
"return",
"$",
"line",
";",
"}"
] |
Get user input from commandline
|
[
"Get",
"user",
"input",
"from",
"commandline"
] |
284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f
|
https://github.com/nonetallt/jinitialize-core/blob/284fbd72b7c1d6f5f8f265dfe2589c0d99b6a88f/src/Installer.php#L107-L117
|
3,890 |
canis-io/yii2-canis-lib
|
lib/base/Module.php
|
Module.getSystemId
|
public function getSystemId()
{
if (!is_null($this->_systemId)) {
return $this->_systemId;
}
preg_match('/' . ucfirst($this->moduleType) . '([A-Za-z]+)\\\Module/', get_class($this), $matches);
if (!isset($matches[1])) {
throw new Exception(get_class($this) . " is not set up correctly!");
}
return $this->_systemId = $matches[1];
}
|
php
|
public function getSystemId()
{
if (!is_null($this->_systemId)) {
return $this->_systemId;
}
preg_match('/' . ucfirst($this->moduleType) . '([A-Za-z]+)\\\Module/', get_class($this), $matches);
if (!isset($matches[1])) {
throw new Exception(get_class($this) . " is not set up correctly!");
}
return $this->_systemId = $matches[1];
}
|
[
"public",
"function",
"getSystemId",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"_systemId",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_systemId",
";",
"}",
"preg_match",
"(",
"'/'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"moduleType",
")",
".",
"'([A-Za-z]+)\\\\\\Module/'",
",",
"get_class",
"(",
"$",
"this",
")",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"get_class",
"(",
"$",
"this",
")",
".",
"\" is not set up correctly!\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_systemId",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"}"
] |
Get system.
@throws Exception [[@doctodo exception_description:Exception]]
@return unknown
|
[
"Get",
"system",
"."
] |
97d533521f65b084dc805c5f312c364b469142d2
|
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/base/Module.php#L92-L103
|
3,891 |
nfilin/libs
|
src/Nfilin/Libs/InputData.php
|
InputData.mergeWith
|
function mergeWith($data = [])
{
if (is_array($data) || is_object($data))
foreach ($data as $key => $value) {
$this->__data->{$key} = $value;
}
return $this;
}
|
php
|
function mergeWith($data = [])
{
if (is_array($data) || is_object($data))
foreach ($data as $key => $value) {
$this->__data->{$key} = $value;
}
return $this;
}
|
[
"function",
"mergeWith",
"(",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
"||",
"is_object",
"(",
"$",
"data",
")",
")",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"__data",
"->",
"{",
"$",
"key",
"}",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds data to storage
@param array|object|null $data
@return $this
|
[
"Adds",
"data",
"to",
"storage"
] |
091440e53847d24eb42823ba5b91fef9a620ed8b
|
https://github.com/nfilin/libs/blob/091440e53847d24eb42823ba5b91fef9a620ed8b/src/Nfilin/Libs/InputData.php#L81-L88
|
3,892 |
nfilin/libs
|
src/Nfilin/Libs/InputData.php
|
InputData.parseRule
|
static protected function parseRule($rule)
{
switch (gettype($rule)) {
case 'string':
$type = $rule;
$target = null;
$types = [];
break;
case 'array':
$type = isset($rule['type']) ? $rule['type'] : [];
$target = isset($rule['target']) ? $rule['target'] : [];
$types = isset($rule['types']) ? $rule['types'] : [];
break;
case 'object':
$type = isset($rule->type) ? $rule->type : null;
$target = isset($rule->target) ? $rule->target : null;
$types = isset($rule->types) ? $rule->types : [];
break;
default:
$type = null;
$target = null;
$types = [];
}
return compact('type', 'target', 'types');
}
|
php
|
static protected function parseRule($rule)
{
switch (gettype($rule)) {
case 'string':
$type = $rule;
$target = null;
$types = [];
break;
case 'array':
$type = isset($rule['type']) ? $rule['type'] : [];
$target = isset($rule['target']) ? $rule['target'] : [];
$types = isset($rule['types']) ? $rule['types'] : [];
break;
case 'object':
$type = isset($rule->type) ? $rule->type : null;
$target = isset($rule->target) ? $rule->target : null;
$types = isset($rule->types) ? $rule->types : [];
break;
default:
$type = null;
$target = null;
$types = [];
}
return compact('type', 'target', 'types');
}
|
[
"static",
"protected",
"function",
"parseRule",
"(",
"$",
"rule",
")",
"{",
"switch",
"(",
"gettype",
"(",
"$",
"rule",
")",
")",
"{",
"case",
"'string'",
":",
"$",
"type",
"=",
"$",
"rule",
";",
"$",
"target",
"=",
"null",
";",
"$",
"types",
"=",
"[",
"]",
";",
"break",
";",
"case",
"'array'",
":",
"$",
"type",
"=",
"isset",
"(",
"$",
"rule",
"[",
"'type'",
"]",
")",
"?",
"$",
"rule",
"[",
"'type'",
"]",
":",
"[",
"]",
";",
"$",
"target",
"=",
"isset",
"(",
"$",
"rule",
"[",
"'target'",
"]",
")",
"?",
"$",
"rule",
"[",
"'target'",
"]",
":",
"[",
"]",
";",
"$",
"types",
"=",
"isset",
"(",
"$",
"rule",
"[",
"'types'",
"]",
")",
"?",
"$",
"rule",
"[",
"'types'",
"]",
":",
"[",
"]",
";",
"break",
";",
"case",
"'object'",
":",
"$",
"type",
"=",
"isset",
"(",
"$",
"rule",
"->",
"type",
")",
"?",
"$",
"rule",
"->",
"type",
":",
"null",
";",
"$",
"target",
"=",
"isset",
"(",
"$",
"rule",
"->",
"target",
")",
"?",
"$",
"rule",
"->",
"target",
":",
"null",
";",
"$",
"types",
"=",
"isset",
"(",
"$",
"rule",
"->",
"types",
")",
"?",
"$",
"rule",
"->",
"types",
":",
"[",
"]",
";",
"break",
";",
"default",
":",
"$",
"type",
"=",
"null",
";",
"$",
"target",
"=",
"null",
";",
"$",
"types",
"=",
"[",
"]",
";",
"}",
"return",
"compact",
"(",
"'type'",
",",
"'target'",
",",
"'types'",
")",
";",
"}"
] |
Standartise `type`,`target` and `types`
@param array|object|string $rule
@return array
|
[
"Standartise",
"type",
"target",
"and",
"types"
] |
091440e53847d24eb42823ba5b91fef9a620ed8b
|
https://github.com/nfilin/libs/blob/091440e53847d24eb42823ba5b91fef9a620ed8b/src/Nfilin/Libs/InputData.php#L95-L119
|
3,893 |
nfilin/libs
|
src/Nfilin/Libs/InputData.php
|
InputData.parseType
|
protected function parseType(array $input)
{
/** @var string $type */
/** @var string[] $types */
extract($input);
switch ($type) {
case 'array':
if (!is_array($this->{$key}))
return false;
break;
case 'int':
case 'integer':
if (!is_int($this->{$key}))
return false;
break;
case 'or':
$valid = false;
foreach ($types as $_type) {
if (gettype($this->{$key}) == $_type) {
$valid = true;
break;
}
}
if (!$valid) return false;
break;
default:
//throw new Exception('Incorrect rule');
return null;
}
return true;
}
|
php
|
protected function parseType(array $input)
{
/** @var string $type */
/** @var string[] $types */
extract($input);
switch ($type) {
case 'array':
if (!is_array($this->{$key}))
return false;
break;
case 'int':
case 'integer':
if (!is_int($this->{$key}))
return false;
break;
case 'or':
$valid = false;
foreach ($types as $_type) {
if (gettype($this->{$key}) == $_type) {
$valid = true;
break;
}
}
if (!$valid) return false;
break;
default:
//throw new Exception('Incorrect rule');
return null;
}
return true;
}
|
[
"protected",
"function",
"parseType",
"(",
"array",
"$",
"input",
")",
"{",
"/** @var string $type */",
"/** @var string[] $types */",
"extract",
"(",
"$",
"input",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'array'",
":",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
")",
")",
"return",
"false",
";",
"break",
";",
"case",
"'int'",
":",
"case",
"'integer'",
":",
"if",
"(",
"!",
"is_int",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
")",
")",
"return",
"false",
";",
"break",
";",
"case",
"'or'",
":",
"$",
"valid",
"=",
"false",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"_type",
")",
"{",
"if",
"(",
"gettype",
"(",
"$",
"this",
"->",
"{",
"$",
"key",
"}",
")",
"==",
"$",
"_type",
")",
"{",
"$",
"valid",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"valid",
")",
"return",
"false",
";",
"break",
";",
"default",
":",
"//throw new Exception('Incorrect rule');",
"return",
"null",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks if field match type
@param array $input Array with result of [[parseRule()]]
@return boolean|null
|
[
"Checks",
"if",
"field",
"match",
"type"
] |
091440e53847d24eb42823ba5b91fef9a620ed8b
|
https://github.com/nfilin/libs/blob/091440e53847d24eb42823ba5b91fef9a620ed8b/src/Nfilin/Libs/InputData.php#L126-L156
|
3,894 |
asbsoft/yii2-common_2_170212
|
helpers/ConfigsBuilder.php
|
ConfigsBuilder.cacheAllConfigsFile
|
public static function cacheAllConfigsFile($application = null)
{
if (empty($application)) {
$application = Yii::$app;
}
$appKey = UniApplication::appKey($application);
$cacheKey = static::$confFileCacheKey . '/' . $appKey;
if ($application->cache instanceof Cache && !empty(static::$_configFiles)) {
$application->cache->set($cacheKey, static::$_configFiles, static::$defaultCacheDuration);
}
}
|
php
|
public static function cacheAllConfigsFile($application = null)
{
if (empty($application)) {
$application = Yii::$app;
}
$appKey = UniApplication::appKey($application);
$cacheKey = static::$confFileCacheKey . '/' . $appKey;
if ($application->cache instanceof Cache && !empty(static::$_configFiles)) {
$application->cache->set($cacheKey, static::$_configFiles, static::$defaultCacheDuration);
}
}
|
[
"public",
"static",
"function",
"cacheAllConfigsFile",
"(",
"$",
"application",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"application",
")",
")",
"{",
"$",
"application",
"=",
"Yii",
"::",
"$",
"app",
";",
"}",
"$",
"appKey",
"=",
"UniApplication",
"::",
"appKey",
"(",
"$",
"application",
")",
";",
"$",
"cacheKey",
"=",
"static",
"::",
"$",
"confFileCacheKey",
".",
"'/'",
".",
"$",
"appKey",
";",
"if",
"(",
"$",
"application",
"->",
"cache",
"instanceof",
"Cache",
"&&",
"!",
"empty",
"(",
"static",
"::",
"$",
"_configFiles",
")",
")",
"{",
"$",
"application",
"->",
"cache",
"->",
"set",
"(",
"$",
"cacheKey",
",",
"static",
"::",
"$",
"_configFiles",
",",
"static",
"::",
"$",
"defaultCacheDuration",
")",
";",
"}",
"}"
] |
Save all configs together in cache
|
[
"Save",
"all",
"configs",
"together",
"in",
"cache"
] |
6c58012ff89225d7d4e42b200cf39e009e9d9dac
|
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/helpers/ConfigsBuilder.php#L44-L55
|
3,895 |
antaresproject/tester
|
src/Adapter/ResponseAdapter.php
|
ResponseAdapter.addError
|
protected function addError($message, $code = null)
{
$this->adapter->add($message, $code, 'error');
return $this;
}
|
php
|
protected function addError($message, $code = null)
{
$this->adapter->add($message, $code, 'error');
return $this;
}
|
[
"protected",
"function",
"addError",
"(",
"$",
"message",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"adapter",
"->",
"add",
"(",
"$",
"message",
",",
"$",
"code",
",",
"'error'",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
add error into container
@param String $message
@param numeric $code
@return \Antares\Tester\Factory\ResponseFactory
|
[
"add",
"error",
"into",
"container"
] |
23e9b4dd7880475769486a8c8f979ab6530c99df
|
https://github.com/antaresproject/tester/blob/23e9b4dd7880475769486a8c8f979ab6530c99df/src/Adapter/ResponseAdapter.php#L51-L55
|
3,896 |
antaresproject/tester
|
src/Adapter/ResponseAdapter.php
|
ResponseAdapter.addWarning
|
protected function addWarning($message, $code = null)
{
$this->adapter->add($message, $code, 'success');
return $this;
}
|
php
|
protected function addWarning($message, $code = null)
{
$this->adapter->add($message, $code, 'success');
return $this;
}
|
[
"protected",
"function",
"addWarning",
"(",
"$",
"message",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"adapter",
"->",
"add",
"(",
"$",
"message",
",",
"$",
"code",
",",
"'success'",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
add warning into container
@param String $message
@param numeric $code
@return \Antares\Tester\Factory\ResponseFactory
|
[
"add",
"warning",
"into",
"container"
] |
23e9b4dd7880475769486a8c8f979ab6530c99df
|
https://github.com/antaresproject/tester/blob/23e9b4dd7880475769486a8c8f979ab6530c99df/src/Adapter/ResponseAdapter.php#L64-L68
|
3,897 |
antaresproject/tester
|
src/Adapter/ResponseAdapter.php
|
ResponseAdapter.addInfo
|
protected function addInfo($message, $code = null)
{
$this->adapter->add($message, $code, 'info');
return $this;
}
|
php
|
protected function addInfo($message, $code = null)
{
$this->adapter->add($message, $code, 'info');
return $this;
}
|
[
"protected",
"function",
"addInfo",
"(",
"$",
"message",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"adapter",
"->",
"add",
"(",
"$",
"message",
",",
"$",
"code",
",",
"'info'",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
add info into container
@param String $message
@param numeric $code
@return \Antares\Tester\Factory\ResponseFactory
|
[
"add",
"info",
"into",
"container"
] |
23e9b4dd7880475769486a8c8f979ab6530c99df
|
https://github.com/antaresproject/tester/blob/23e9b4dd7880475769486a8c8f979ab6530c99df/src/Adapter/ResponseAdapter.php#L77-L81
|
3,898 |
antaresproject/tester
|
src/Adapter/ResponseAdapter.php
|
ResponseAdapter.addSuccess
|
protected function addSuccess($message, $code = null)
{
$this->adapter->add($message, $code, 'success');
return $this;
}
|
php
|
protected function addSuccess($message, $code = null)
{
$this->adapter->add($message, $code, 'success');
return $this;
}
|
[
"protected",
"function",
"addSuccess",
"(",
"$",
"message",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"adapter",
"->",
"add",
"(",
"$",
"message",
",",
"$",
"code",
",",
"'success'",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
add success into container
@param String $message
@param numeric $code
@return \Antares\Tester\Factory\ResponseFactory
|
[
"add",
"success",
"into",
"container"
] |
23e9b4dd7880475769486a8c8f979ab6530c99df
|
https://github.com/antaresproject/tester/blob/23e9b4dd7880475769486a8c8f979ab6530c99df/src/Adapter/ResponseAdapter.php#L90-L94
|
3,899 |
consolle/framework
|
src/Command/Command.php
|
Command.getDaemonOptions
|
protected function getDaemonOptions()
{
return [
['daemon', null, InputOption::VALUE_NONE, 'Run the command in daemon mode'],
['sleep', null, InputOption::VALUE_OPTIONAL, 'Number of seconds to sleep when no job is available', 3],
['memory', null, InputOption::VALUE_OPTIONAL, 'The memory limit in megabytes', 128],
];
}
|
php
|
protected function getDaemonOptions()
{
return [
['daemon', null, InputOption::VALUE_NONE, 'Run the command in daemon mode'],
['sleep', null, InputOption::VALUE_OPTIONAL, 'Number of seconds to sleep when no job is available', 3],
['memory', null, InputOption::VALUE_OPTIONAL, 'The memory limit in megabytes', 128],
];
}
|
[
"protected",
"function",
"getDaemonOptions",
"(",
")",
"{",
"return",
"[",
"[",
"'daemon'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_NONE",
",",
"'Run the command in daemon mode'",
"]",
",",
"[",
"'sleep'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_OPTIONAL",
",",
"'Number of seconds to sleep when no job is available'",
",",
"3",
"]",
",",
"[",
"'memory'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_OPTIONAL",
",",
"'The memory limit in megabytes'",
",",
"128",
"]",
",",
"]",
";",
"}"
] |
Get the console daemon options.
@return array
|
[
"Get",
"the",
"console",
"daemon",
"options",
"."
] |
2799921d6983f31e775099eac116c337bbe29c74
|
https://github.com/consolle/framework/blob/2799921d6983f31e775099eac116c337bbe29c74/src/Command/Command.php#L396-L403
|
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.