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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
25,000
|
pryley/castor-framework
|
src/Services/Validator.php
|
Validator.validateAccepted
|
protected function validateAccepted( $value )
{
$acceptable = ['yes', 'on', '1', 1, true, 'true'];
return $this->validateRequired( $value ) && in_array( $value, $acceptable, true );
}
|
php
|
protected function validateAccepted( $value )
{
$acceptable = ['yes', 'on', '1', 1, true, 'true'];
return $this->validateRequired( $value ) && in_array( $value, $acceptable, true );
}
|
[
"protected",
"function",
"validateAccepted",
"(",
"$",
"value",
")",
"{",
"$",
"acceptable",
"=",
"[",
"'yes'",
",",
"'on'",
",",
"'1'",
",",
"1",
",",
"true",
",",
"'true'",
"]",
";",
"return",
"$",
"this",
"->",
"validateRequired",
"(",
"$",
"value",
")",
"&&",
"in_array",
"(",
"$",
"value",
",",
"$",
"acceptable",
",",
"true",
")",
";",
"}"
] |
Validate that an attribute was "accepted".
This validation rule implies the attribute is "required".
@param mixed $value
@return bool
|
[
"Validate",
"that",
"an",
"attribute",
"was",
"accepted",
"."
] |
cbc137d02625cd05f4cc96414d6f70e451cb821f
|
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Services/Validator.php#L446-L451
|
25,001
|
pryley/castor-framework
|
src/Services/Validator.php
|
Validator.validateMin
|
protected function validateMin( $value, $attribute, array $parameters )
{
$this->requireParameterCount( 1, $parameters, 'min' );
return $this->getSize( $attribute, $value ) >= $parameters[0];
}
|
php
|
protected function validateMin( $value, $attribute, array $parameters )
{
$this->requireParameterCount( 1, $parameters, 'min' );
return $this->getSize( $attribute, $value ) >= $parameters[0];
}
|
[
"protected",
"function",
"validateMin",
"(",
"$",
"value",
",",
"$",
"attribute",
",",
"array",
"$",
"parameters",
")",
"{",
"$",
"this",
"->",
"requireParameterCount",
"(",
"1",
",",
"$",
"parameters",
",",
"'min'",
")",
";",
"return",
"$",
"this",
"->",
"getSize",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
">=",
"$",
"parameters",
"[",
"0",
"]",
";",
"}"
] |
Validate the size of an attribute is greater than a minimum value.
@param mixed $value
@param string $attribute
@return bool
|
[
"Validate",
"the",
"size",
"of",
"an",
"attribute",
"is",
"greater",
"than",
"a",
"minimum",
"value",
"."
] |
cbc137d02625cd05f4cc96414d6f70e451cb821f
|
https://github.com/pryley/castor-framework/blob/cbc137d02625cd05f4cc96414d6f70e451cb821f/src/Services/Validator.php#L531-L536
|
25,002
|
native5/native5-sdk-client-php
|
src/Native5/UI/ScriptPathResolver.php
|
ScriptPathResolver.resolve
|
public static function resolve($name)
{
$logger = $GLOBALS['logger'];
$app = $GLOBALS['app'];
$staticPath = 'public';
if ($app->getConfiguration()->isLocal()) {
$staticPath = 'views';
}
$session = $app->getSessionManager()->getActiveSession();
$category = $session->getAttribute('category');
$basePath = '/'.$staticPath.'/resources/'.$category;
$commonPath = '/'.$staticPath.'/resources/common';
$searchFolder = '.';
$isUrl = false;
if(preg_match('/.*\.js$/', $name)) {
$searchFolder = 'scripts';
} else if(preg_match('/.*\.css$/', $name)) {
$searchFolder = 'styles';
} else if(preg_match('/.*\.(?:jpg|jpeg|gif|png)$/', $name)) {
$searchFolder = 'images';
} else {
$isUrl = true;
$name = DIRECTORY_SEPARATOR.$app->getConfiguration()->getApplicationContext().DIRECTORY_SEPARATOR.$name;
}
if ($isUrl) {
return $name;
}
if (file_exists(getcwd().$basePath.'/'.$searchFolder.'/'.$name)) {
return '/'.$app->getConfiguration()->getApplicationContext().$basePath.'/'.$searchFolder.'/'.$name;
} else if (file_exists(getcwd().$commonPath.'/'.$searchFolder.'/'.$name)) {
return '/'.$app->getConfiguration()->getApplicationContext().$commonPath.'/'.$searchFolder.'/'.$name;
}
return $name;
}
|
php
|
public static function resolve($name)
{
$logger = $GLOBALS['logger'];
$app = $GLOBALS['app'];
$staticPath = 'public';
if ($app->getConfiguration()->isLocal()) {
$staticPath = 'views';
}
$session = $app->getSessionManager()->getActiveSession();
$category = $session->getAttribute('category');
$basePath = '/'.$staticPath.'/resources/'.$category;
$commonPath = '/'.$staticPath.'/resources/common';
$searchFolder = '.';
$isUrl = false;
if(preg_match('/.*\.js$/', $name)) {
$searchFolder = 'scripts';
} else if(preg_match('/.*\.css$/', $name)) {
$searchFolder = 'styles';
} else if(preg_match('/.*\.(?:jpg|jpeg|gif|png)$/', $name)) {
$searchFolder = 'images';
} else {
$isUrl = true;
$name = DIRECTORY_SEPARATOR.$app->getConfiguration()->getApplicationContext().DIRECTORY_SEPARATOR.$name;
}
if ($isUrl) {
return $name;
}
if (file_exists(getcwd().$basePath.'/'.$searchFolder.'/'.$name)) {
return '/'.$app->getConfiguration()->getApplicationContext().$basePath.'/'.$searchFolder.'/'.$name;
} else if (file_exists(getcwd().$commonPath.'/'.$searchFolder.'/'.$name)) {
return '/'.$app->getConfiguration()->getApplicationContext().$commonPath.'/'.$searchFolder.'/'.$name;
}
return $name;
}
|
[
"public",
"static",
"function",
"resolve",
"(",
"$",
"name",
")",
"{",
"$",
"logger",
"=",
"$",
"GLOBALS",
"[",
"'logger'",
"]",
";",
"$",
"app",
"=",
"$",
"GLOBALS",
"[",
"'app'",
"]",
";",
"$",
"staticPath",
"=",
"'public'",
";",
"if",
"(",
"$",
"app",
"->",
"getConfiguration",
"(",
")",
"->",
"isLocal",
"(",
")",
")",
"{",
"$",
"staticPath",
"=",
"'views'",
";",
"}",
"$",
"session",
"=",
"$",
"app",
"->",
"getSessionManager",
"(",
")",
"->",
"getActiveSession",
"(",
")",
";",
"$",
"category",
"=",
"$",
"session",
"->",
"getAttribute",
"(",
"'category'",
")",
";",
"$",
"basePath",
"=",
"'/'",
".",
"$",
"staticPath",
".",
"'/resources/'",
".",
"$",
"category",
";",
"$",
"commonPath",
"=",
"'/'",
".",
"$",
"staticPath",
".",
"'/resources/common'",
";",
"$",
"searchFolder",
"=",
"'.'",
";",
"$",
"isUrl",
"=",
"false",
";",
"if",
"(",
"preg_match",
"(",
"'/.*\\.js$/'",
",",
"$",
"name",
")",
")",
"{",
"$",
"searchFolder",
"=",
"'scripts'",
";",
"}",
"else",
"if",
"(",
"preg_match",
"(",
"'/.*\\.css$/'",
",",
"$",
"name",
")",
")",
"{",
"$",
"searchFolder",
"=",
"'styles'",
";",
"}",
"else",
"if",
"(",
"preg_match",
"(",
"'/.*\\.(?:jpg|jpeg|gif|png)$/'",
",",
"$",
"name",
")",
")",
"{",
"$",
"searchFolder",
"=",
"'images'",
";",
"}",
"else",
"{",
"$",
"isUrl",
"=",
"true",
";",
"$",
"name",
"=",
"DIRECTORY_SEPARATOR",
".",
"$",
"app",
"->",
"getConfiguration",
"(",
")",
"->",
"getApplicationContext",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"name",
";",
"}",
"if",
"(",
"$",
"isUrl",
")",
"{",
"return",
"$",
"name",
";",
"}",
"if",
"(",
"file_exists",
"(",
"getcwd",
"(",
")",
".",
"$",
"basePath",
".",
"'/'",
".",
"$",
"searchFolder",
".",
"'/'",
".",
"$",
"name",
")",
")",
"{",
"return",
"'/'",
".",
"$",
"app",
"->",
"getConfiguration",
"(",
")",
"->",
"getApplicationContext",
"(",
")",
".",
"$",
"basePath",
".",
"'/'",
".",
"$",
"searchFolder",
".",
"'/'",
".",
"$",
"name",
";",
"}",
"else",
"if",
"(",
"file_exists",
"(",
"getcwd",
"(",
")",
".",
"$",
"commonPath",
".",
"'/'",
".",
"$",
"searchFolder",
".",
"'/'",
".",
"$",
"name",
")",
")",
"{",
"return",
"'/'",
".",
"$",
"app",
"->",
"getConfiguration",
"(",
")",
"->",
"getApplicationContext",
"(",
")",
".",
"$",
"commonPath",
".",
"'/'",
".",
"$",
"searchFolder",
".",
"'/'",
".",
"$",
"name",
";",
"}",
"return",
"$",
"name",
";",
"}"
] |
Resolve Script Path based on name.
@param mixed $name Name of the script to resolve.
@access public
@return void
|
[
"Resolve",
"Script",
"Path",
"based",
"on",
"name",
"."
] |
e1f598cf27654d81bb5facace1990b737242a2f9
|
https://github.com/native5/native5-sdk-client-php/blob/e1f598cf27654d81bb5facace1990b737242a2f9/src/Native5/UI/ScriptPathResolver.php#L55-L95
|
25,003
|
jonesiscoding/device
|
src/DetectDefaults.php
|
DetectDefaults.getDefaults
|
public function getDefaults()
{
return array(
'android' => false,
'browser' => self::BROWSER,
'cookies' => ( count( $_COOKIE ) > 0 ) ? true : false,
'height' => self::HEIGHT,
'hidpi' => ( array_key_exists( 'HTTP_DPR', $_SERVER ) ) ? $_SERVER[ 'HTTP_DPR' ] > 1 : false,
'ios' => false,
'low_speed' => false, // deprecated
'low_battery' => false, // deprecated
'metered' => $this->getMeteredDefault(),
'touch' => self::TOUCH,
'user-agent' => $this->getUserAgentDefault(),
'viewport' => $this->getViewportDefault(),
'width' => self::WIDTH
);
}
|
php
|
public function getDefaults()
{
return array(
'android' => false,
'browser' => self::BROWSER,
'cookies' => ( count( $_COOKIE ) > 0 ) ? true : false,
'height' => self::HEIGHT,
'hidpi' => ( array_key_exists( 'HTTP_DPR', $_SERVER ) ) ? $_SERVER[ 'HTTP_DPR' ] > 1 : false,
'ios' => false,
'low_speed' => false, // deprecated
'low_battery' => false, // deprecated
'metered' => $this->getMeteredDefault(),
'touch' => self::TOUCH,
'user-agent' => $this->getUserAgentDefault(),
'viewport' => $this->getViewportDefault(),
'width' => self::WIDTH
);
}
|
[
"public",
"function",
"getDefaults",
"(",
")",
"{",
"return",
"array",
"(",
"'android'",
"=>",
"false",
",",
"'browser'",
"=>",
"self",
"::",
"BROWSER",
",",
"'cookies'",
"=>",
"(",
"count",
"(",
"$",
"_COOKIE",
")",
">",
"0",
")",
"?",
"true",
":",
"false",
",",
"'height'",
"=>",
"self",
"::",
"HEIGHT",
",",
"'hidpi'",
"=>",
"(",
"array_key_exists",
"(",
"'HTTP_DPR'",
",",
"$",
"_SERVER",
")",
")",
"?",
"$",
"_SERVER",
"[",
"'HTTP_DPR'",
"]",
">",
"1",
":",
"false",
",",
"'ios'",
"=>",
"false",
",",
"'low_speed'",
"=>",
"false",
",",
"// deprecated",
"'low_battery'",
"=>",
"false",
",",
"// deprecated",
"'metered'",
"=>",
"$",
"this",
"->",
"getMeteredDefault",
"(",
")",
",",
"'touch'",
"=>",
"self",
"::",
"TOUCH",
",",
"'user-agent'",
"=>",
"$",
"this",
"->",
"getUserAgentDefault",
"(",
")",
",",
"'viewport'",
"=>",
"$",
"this",
"->",
"getViewportDefault",
"(",
")",
",",
"'width'",
"=>",
"self",
"::",
"WIDTH",
")",
";",
"}"
] |
These defaults come from an number of places, including client hints. The only values based on a UA string are
the Android & iOS values.
References:
* https://developers.google.com/web/updates/2015/09/automating-resource-selection-with-client-hints
* http://httpwg.org/http-extensions/client-hints.html
* https://developers.google.com/web/updates/2016/02/save-data
@return array
|
[
"These",
"defaults",
"come",
"from",
"an",
"number",
"of",
"places",
"including",
"client",
"hints",
".",
"The",
"only",
"values",
"based",
"on",
"a",
"UA",
"string",
"are",
"the",
"Android",
"&",
"iOS",
"values",
"."
] |
d3c66f934bcaa8e5e0424cf684c995b1c80cee29
|
https://github.com/jonesiscoding/device/blob/d3c66f934bcaa8e5e0424cf684c995b1c80cee29/src/DetectDefaults.php#L59-L76
|
25,004
|
jonesiscoding/device
|
src/DetectDefaults.php
|
DetectDefaults.getMeteredDefault
|
private function getMeteredDefault()
{
foreach( self::METERED_HEADERS as $header )
{
if( array_key_exists( $header, $_SERVER ) )
{
return true;
}
}
return false;
}
|
php
|
private function getMeteredDefault()
{
foreach( self::METERED_HEADERS as $header )
{
if( array_key_exists( $header, $_SERVER ) )
{
return true;
}
}
return false;
}
|
[
"private",
"function",
"getMeteredDefault",
"(",
")",
"{",
"foreach",
"(",
"self",
"::",
"METERED_HEADERS",
"as",
"$",
"header",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"header",
",",
"$",
"_SERVER",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Uses potential mobile headers & Google's new 'save-data' header to determine if we have a metered connection.
* Reference for 'save-data': https://developers.google.com/web/updates/2016/02/save-data
@return bool
|
[
"Uses",
"potential",
"mobile",
"headers",
"&",
"Google",
"s",
"new",
"save",
"-",
"data",
"header",
"to",
"determine",
"if",
"we",
"have",
"a",
"metered",
"connection",
"."
] |
d3c66f934bcaa8e5e0424cf684c995b1c80cee29
|
https://github.com/jonesiscoding/device/blob/d3c66f934bcaa8e5e0424cf684c995b1c80cee29/src/DetectDefaults.php#L85-L96
|
25,005
|
PenoaksDev/Milky-Framework
|
src/Milky/Account/Permissions/PermissionManager.php
|
PermissionManager.policy
|
public function policy( Policy $policy )
{
$this->loadedPolicies[] = $policy;
// Caches the policy nodes as a nestable tree
foreach ( $policy->getNodes() as $namespace => $callable )
$this->getPermission( $namespace )->addPolicyMethod( $callable );
}
|
php
|
public function policy( Policy $policy )
{
$this->loadedPolicies[] = $policy;
// Caches the policy nodes as a nestable tree
foreach ( $policy->getNodes() as $namespace => $callable )
$this->getPermission( $namespace )->addPolicyMethod( $callable );
}
|
[
"public",
"function",
"policy",
"(",
"Policy",
"$",
"policy",
")",
"{",
"$",
"this",
"->",
"loadedPolicies",
"[",
"]",
"=",
"$",
"policy",
";",
"// Caches the policy nodes as a nestable tree",
"foreach",
"(",
"$",
"policy",
"->",
"getNodes",
"(",
")",
"as",
"$",
"namespace",
"=>",
"$",
"callable",
")",
"$",
"this",
"->",
"getPermission",
"(",
"$",
"namespace",
")",
"->",
"addPolicyMethod",
"(",
"$",
"callable",
")",
";",
"}"
] |
Adds a new policy checker.
Policies are checked for permissions before they are checked by the general permission backend
@param Policy $policy
|
[
"Adds",
"a",
"new",
"policy",
"checker",
"."
] |
8afd7156610a70371aa5b1df50b8a212bf7b142c
|
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Permissions/PermissionManager.php#L78-L85
|
25,006
|
PenoaksDev/Milky-Framework
|
src/Milky/Account/Permissions/PermissionManager.php
|
PermissionManager.checkRaw
|
protected function checkRaw( $namespace, PermissibleEntity $entity = null )
{
if ( $namespace == null || strlen( $namespace ) == 0 || $namespace == "everybody" || $namespace == "-1" )
$namespace = Permission::EVERYBODY;
if ( $namespace == "op" || $namespace == "0" )
$namespace = Permission::OP;
if ( $namespace == "admin" )
$namespace = Permission::ADMIN;
if ( $namespace == "banned" )
$namespace = Permission::BANNED;
if ( $namespace == "whitelisted" )
$namespace = Permission::WHITELISTED;
$namespace = static::getAlias( $namespace );
if ( !preg_match( "/[a-z0-9_.]*/", $namespace ) )
throw new PermissionException( "The permission namespace [$namespace] can only contain the characters 'a-z0-9_.'." );
$permission_defaults = PermissionDefaults::find( $namespace );
if ( $entity === null )
{
if ( !Acct::check() )
{
$result = $this->checkWalker( $namespace, [] );
if ( $result == PermissionValues::UNSET )
$result = $permission_defaults->value_default;
return $result;
}
$entity = Acct::acct();
}
$group_state = PermissionValues::UNSET;
/*
* Check group permissible state
*/
foreach ( $entity->groups() as $group )
{
$group_state = $this->checkRaw( $namespace, $group );
if ( $group_state == PermissionValues::ALWAYS || $group_state == PermissionValues::NEVER )
break;
}
/*
* Check user permissible state
*/
$user_state = $this->checkWalker( $namespace, $entity->permissions() );
if ( $group_state == PermissionValues::ALWAYS || $group_state == PermissionValues::NEVER )
{
if ( $user_state == PermissionValues::ALWAYS )
return true;
else if ( $user_state == PermissionValues::NEVER )
return false;
else
return $group_state;
}
else if ( $group_state == PermissionValues::UNSET && $user_state == PermissionValues::UNSET )
return $permission_defaults->value_default;
else if ( $user_state == PermissionValues::UNSET )
return $group_state;
else // if ( $group_state == PermissionValues::UNSET )
return $user_state;
}
|
php
|
protected function checkRaw( $namespace, PermissibleEntity $entity = null )
{
if ( $namespace == null || strlen( $namespace ) == 0 || $namespace == "everybody" || $namespace == "-1" )
$namespace = Permission::EVERYBODY;
if ( $namespace == "op" || $namespace == "0" )
$namespace = Permission::OP;
if ( $namespace == "admin" )
$namespace = Permission::ADMIN;
if ( $namespace == "banned" )
$namespace = Permission::BANNED;
if ( $namespace == "whitelisted" )
$namespace = Permission::WHITELISTED;
$namespace = static::getAlias( $namespace );
if ( !preg_match( "/[a-z0-9_.]*/", $namespace ) )
throw new PermissionException( "The permission namespace [$namespace] can only contain the characters 'a-z0-9_.'." );
$permission_defaults = PermissionDefaults::find( $namespace );
if ( $entity === null )
{
if ( !Acct::check() )
{
$result = $this->checkWalker( $namespace, [] );
if ( $result == PermissionValues::UNSET )
$result = $permission_defaults->value_default;
return $result;
}
$entity = Acct::acct();
}
$group_state = PermissionValues::UNSET;
/*
* Check group permissible state
*/
foreach ( $entity->groups() as $group )
{
$group_state = $this->checkRaw( $namespace, $group );
if ( $group_state == PermissionValues::ALWAYS || $group_state == PermissionValues::NEVER )
break;
}
/*
* Check user permissible state
*/
$user_state = $this->checkWalker( $namespace, $entity->permissions() );
if ( $group_state == PermissionValues::ALWAYS || $group_state == PermissionValues::NEVER )
{
if ( $user_state == PermissionValues::ALWAYS )
return true;
else if ( $user_state == PermissionValues::NEVER )
return false;
else
return $group_state;
}
else if ( $group_state == PermissionValues::UNSET && $user_state == PermissionValues::UNSET )
return $permission_defaults->value_default;
else if ( $user_state == PermissionValues::UNSET )
return $group_state;
else // if ( $group_state == PermissionValues::UNSET )
return $user_state;
}
|
[
"protected",
"function",
"checkRaw",
"(",
"$",
"namespace",
",",
"PermissibleEntity",
"$",
"entity",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"namespace",
"==",
"null",
"||",
"strlen",
"(",
"$",
"namespace",
")",
"==",
"0",
"||",
"$",
"namespace",
"==",
"\"everybody\"",
"||",
"$",
"namespace",
"==",
"\"-1\"",
")",
"$",
"namespace",
"=",
"Permission",
"::",
"EVERYBODY",
";",
"if",
"(",
"$",
"namespace",
"==",
"\"op\"",
"||",
"$",
"namespace",
"==",
"\"0\"",
")",
"$",
"namespace",
"=",
"Permission",
"::",
"OP",
";",
"if",
"(",
"$",
"namespace",
"==",
"\"admin\"",
")",
"$",
"namespace",
"=",
"Permission",
"::",
"ADMIN",
";",
"if",
"(",
"$",
"namespace",
"==",
"\"banned\"",
")",
"$",
"namespace",
"=",
"Permission",
"::",
"BANNED",
";",
"if",
"(",
"$",
"namespace",
"==",
"\"whitelisted\"",
")",
"$",
"namespace",
"=",
"Permission",
"::",
"WHITELISTED",
";",
"$",
"namespace",
"=",
"static",
"::",
"getAlias",
"(",
"$",
"namespace",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"\"/[a-z0-9_.]*/\"",
",",
"$",
"namespace",
")",
")",
"throw",
"new",
"PermissionException",
"(",
"\"The permission namespace [$namespace] can only contain the characters 'a-z0-9_.'.\"",
")",
";",
"$",
"permission_defaults",
"=",
"PermissionDefaults",
"::",
"find",
"(",
"$",
"namespace",
")",
";",
"if",
"(",
"$",
"entity",
"===",
"null",
")",
"{",
"if",
"(",
"!",
"Acct",
"::",
"check",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"checkWalker",
"(",
"$",
"namespace",
",",
"[",
"]",
")",
";",
"if",
"(",
"$",
"result",
"==",
"PermissionValues",
"::",
"UNSET",
")",
"$",
"result",
"=",
"$",
"permission_defaults",
"->",
"value_default",
";",
"return",
"$",
"result",
";",
"}",
"$",
"entity",
"=",
"Acct",
"::",
"acct",
"(",
")",
";",
"}",
"$",
"group_state",
"=",
"PermissionValues",
"::",
"UNSET",
";",
"/*\n\t\t * Check group permissible state\n\t\t */",
"foreach",
"(",
"$",
"entity",
"->",
"groups",
"(",
")",
"as",
"$",
"group",
")",
"{",
"$",
"group_state",
"=",
"$",
"this",
"->",
"checkRaw",
"(",
"$",
"namespace",
",",
"$",
"group",
")",
";",
"if",
"(",
"$",
"group_state",
"==",
"PermissionValues",
"::",
"ALWAYS",
"||",
"$",
"group_state",
"==",
"PermissionValues",
"::",
"NEVER",
")",
"break",
";",
"}",
"/*\n\t\t * Check user permissible state\n\t\t */",
"$",
"user_state",
"=",
"$",
"this",
"->",
"checkWalker",
"(",
"$",
"namespace",
",",
"$",
"entity",
"->",
"permissions",
"(",
")",
")",
";",
"if",
"(",
"$",
"group_state",
"==",
"PermissionValues",
"::",
"ALWAYS",
"||",
"$",
"group_state",
"==",
"PermissionValues",
"::",
"NEVER",
")",
"{",
"if",
"(",
"$",
"user_state",
"==",
"PermissionValues",
"::",
"ALWAYS",
")",
"return",
"true",
";",
"else",
"if",
"(",
"$",
"user_state",
"==",
"PermissionValues",
"::",
"NEVER",
")",
"return",
"false",
";",
"else",
"return",
"$",
"group_state",
";",
"}",
"else",
"if",
"(",
"$",
"group_state",
"==",
"PermissionValues",
"::",
"UNSET",
"&&",
"$",
"user_state",
"==",
"PermissionValues",
"::",
"UNSET",
")",
"return",
"$",
"permission_defaults",
"->",
"value_default",
";",
"else",
"if",
"(",
"$",
"user_state",
"==",
"PermissionValues",
"::",
"UNSET",
")",
"return",
"$",
"group_state",
";",
"else",
"// if ( $group_state == PermissionValues::UNSET )",
"return",
"$",
"user_state",
";",
"}"
] |
Checks a raw singular namespace and returns the unhindered result
@param $namespace
@param PermissibleEntity|null $entity
@return string
|
[
"Checks",
"a",
"raw",
"singular",
"namespace",
"and",
"returns",
"the",
"unhindered",
"result"
] |
8afd7156610a70371aa5b1df50b8a212bf7b142c
|
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Permissions/PermissionManager.php#L178-L243
|
25,007
|
PenoaksDev/Milky-Framework
|
src/Milky/Account/Permissions/PermissionManager.php
|
PermissionManager.check
|
public function check( $namespaces, PermissibleModel $model = null, PermissibleEntity $entity = null )
{
// Allows for static calling
$instance = $this ?: self::i();
if ( !is_array( $namespaces ) )
$namespaces = [$namespaces];
foreach ( $namespaces as &$ns )
{
if ( !is_string( $ns ) )
throw new PermissionException( "The permission namespace must be a string." );
$ns = static::getAlias( $ns );
if ( !preg_match( "/[a-z0-9_.]*/", $ns ) )
throw new PermissionException( "The permission namespace [$ns] can only contain the characters 'a-z0-9_.'." );
}
if ( $model != null )
{
if ( $model instanceof PermissibleModel )
{
$namespaces_new = $namespaces;
foreach ( $model->getIdentifiers() as $key => $id )
$namespaces_new = str_replace( "{" . $key . "}", $id, $namespaces_new );
// Removes untouched values. Seems like a good idea, except in the cast that the user wishes to check a generic permission node.
// $namespaces_new = array_diff( $namespaces_new, array_intersect( $namespaces_new, $namespaces ) );
// Log::debug( "Amending namespaces [" . str_replace( "\n", "", var_export( $namespaces, true ) ) . "] with model [" . get_class( $model ) . "] resulting in [" . str_replace( "\n", "", var_export( $namespaces_new, true ) ) . "]" );
return $instance->check( $namespaces_new, null, $entity );
}
else
throw new PermissionException( "The 'model' must implement PermissibleModel." );
}
$current_state = PermissionValues::UNSET;
array_walk( $namespaces, function ( $ns ) use ( &$instance, &$entity, &$current_state )
{
$current_state = $instance->checkRaw( $ns, $entity );
Log::debug( "Checking permission [" . $ns . "] on entity [" . ( $entity ? get_class( $entity ) : "null" ) . "] with result [" . $current_state . "]" );
if ( $current_state == PermissionValues::ALWAYS )
return true;
if ( $current_state == PermissionValues::NEVER )
return false;
if ( $current_state == PermissionValues::UNSET || !PermissionValues::valid( $current_state ) )
throw new PermissionException( "Permission Exception!" );
} );
return $current_state == PermissionValues::YES;
}
|
php
|
public function check( $namespaces, PermissibleModel $model = null, PermissibleEntity $entity = null )
{
// Allows for static calling
$instance = $this ?: self::i();
if ( !is_array( $namespaces ) )
$namespaces = [$namespaces];
foreach ( $namespaces as &$ns )
{
if ( !is_string( $ns ) )
throw new PermissionException( "The permission namespace must be a string." );
$ns = static::getAlias( $ns );
if ( !preg_match( "/[a-z0-9_.]*/", $ns ) )
throw new PermissionException( "The permission namespace [$ns] can only contain the characters 'a-z0-9_.'." );
}
if ( $model != null )
{
if ( $model instanceof PermissibleModel )
{
$namespaces_new = $namespaces;
foreach ( $model->getIdentifiers() as $key => $id )
$namespaces_new = str_replace( "{" . $key . "}", $id, $namespaces_new );
// Removes untouched values. Seems like a good idea, except in the cast that the user wishes to check a generic permission node.
// $namespaces_new = array_diff( $namespaces_new, array_intersect( $namespaces_new, $namespaces ) );
// Log::debug( "Amending namespaces [" . str_replace( "\n", "", var_export( $namespaces, true ) ) . "] with model [" . get_class( $model ) . "] resulting in [" . str_replace( "\n", "", var_export( $namespaces_new, true ) ) . "]" );
return $instance->check( $namespaces_new, null, $entity );
}
else
throw new PermissionException( "The 'model' must implement PermissibleModel." );
}
$current_state = PermissionValues::UNSET;
array_walk( $namespaces, function ( $ns ) use ( &$instance, &$entity, &$current_state )
{
$current_state = $instance->checkRaw( $ns, $entity );
Log::debug( "Checking permission [" . $ns . "] on entity [" . ( $entity ? get_class( $entity ) : "null" ) . "] with result [" . $current_state . "]" );
if ( $current_state == PermissionValues::ALWAYS )
return true;
if ( $current_state == PermissionValues::NEVER )
return false;
if ( $current_state == PermissionValues::UNSET || !PermissionValues::valid( $current_state ) )
throw new PermissionException( "Permission Exception!" );
} );
return $current_state == PermissionValues::YES;
}
|
[
"public",
"function",
"check",
"(",
"$",
"namespaces",
",",
"PermissibleModel",
"$",
"model",
"=",
"null",
",",
"PermissibleEntity",
"$",
"entity",
"=",
"null",
")",
"{",
"// Allows for static calling",
"$",
"instance",
"=",
"$",
"this",
"?",
":",
"self",
"::",
"i",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"namespaces",
")",
")",
"$",
"namespaces",
"=",
"[",
"$",
"namespaces",
"]",
";",
"foreach",
"(",
"$",
"namespaces",
"as",
"&",
"$",
"ns",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"ns",
")",
")",
"throw",
"new",
"PermissionException",
"(",
"\"The permission namespace must be a string.\"",
")",
";",
"$",
"ns",
"=",
"static",
"::",
"getAlias",
"(",
"$",
"ns",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"\"/[a-z0-9_.]*/\"",
",",
"$",
"ns",
")",
")",
"throw",
"new",
"PermissionException",
"(",
"\"The permission namespace [$ns] can only contain the characters 'a-z0-9_.'.\"",
")",
";",
"}",
"if",
"(",
"$",
"model",
"!=",
"null",
")",
"{",
"if",
"(",
"$",
"model",
"instanceof",
"PermissibleModel",
")",
"{",
"$",
"namespaces_new",
"=",
"$",
"namespaces",
";",
"foreach",
"(",
"$",
"model",
"->",
"getIdentifiers",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"id",
")",
"$",
"namespaces_new",
"=",
"str_replace",
"(",
"\"{\"",
".",
"$",
"key",
".",
"\"}\"",
",",
"$",
"id",
",",
"$",
"namespaces_new",
")",
";",
"// Removes untouched values. Seems like a good idea, except in the cast that the user wishes to check a generic permission node.",
"// $namespaces_new = array_diff( $namespaces_new, array_intersect( $namespaces_new, $namespaces ) );",
"// Log::debug( \"Amending namespaces [\" . str_replace( \"\\n\", \"\", var_export( $namespaces, true ) ) . \"] with model [\" . get_class( $model ) . \"] resulting in [\" . str_replace( \"\\n\", \"\", var_export( $namespaces_new, true ) ) . \"]\" );",
"return",
"$",
"instance",
"->",
"check",
"(",
"$",
"namespaces_new",
",",
"null",
",",
"$",
"entity",
")",
";",
"}",
"else",
"throw",
"new",
"PermissionException",
"(",
"\"The 'model' must implement PermissibleModel.\"",
")",
";",
"}",
"$",
"current_state",
"=",
"PermissionValues",
"::",
"UNSET",
";",
"array_walk",
"(",
"$",
"namespaces",
",",
"function",
"(",
"$",
"ns",
")",
"use",
"(",
"&",
"$",
"instance",
",",
"&",
"$",
"entity",
",",
"&",
"$",
"current_state",
")",
"{",
"$",
"current_state",
"=",
"$",
"instance",
"->",
"checkRaw",
"(",
"$",
"ns",
",",
"$",
"entity",
")",
";",
"Log",
"::",
"debug",
"(",
"\"Checking permission [\"",
".",
"$",
"ns",
".",
"\"] on entity [\"",
".",
"(",
"$",
"entity",
"?",
"get_class",
"(",
"$",
"entity",
")",
":",
"\"null\"",
")",
".",
"\"] with result [\"",
".",
"$",
"current_state",
".",
"\"]\"",
")",
";",
"if",
"(",
"$",
"current_state",
"==",
"PermissionValues",
"::",
"ALWAYS",
")",
"return",
"true",
";",
"if",
"(",
"$",
"current_state",
"==",
"PermissionValues",
"::",
"NEVER",
")",
"return",
"false",
";",
"if",
"(",
"$",
"current_state",
"==",
"PermissionValues",
"::",
"UNSET",
"||",
"!",
"PermissionValues",
"::",
"valid",
"(",
"$",
"current_state",
")",
")",
"throw",
"new",
"PermissionException",
"(",
"\"Permission Exception!\"",
")",
";",
"}",
")",
";",
"return",
"$",
"current_state",
"==",
"PermissionValues",
"::",
"YES",
";",
"}"
] |
Checks a permission for assignment and policy checks
@param string|array $namespace
@param PermissibleEntity|null $entity
@return bool
|
[
"Checks",
"a",
"permission",
"for",
"assignment",
"and",
"policy",
"checks"
] |
8afd7156610a70371aa5b1df50b8a212bf7b142c
|
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Permissions/PermissionManager.php#L253-L308
|
25,008
|
danielgp/common-lib
|
source/DomCssAndJavascriptByDanielGPwithCDN.php
|
DomCssAndJavascriptByDanielGPwithCDN.setCssFileCDN
|
protected function setCssFileCDN($cssFileName)
{
$patternFound = null;
if (strpos(pathinfo($cssFileName)['basename'], 'font-awesome-') !== false) {
$patternFound = $this->setCssFileCDNforFontAwesome($cssFileName);
}
if (is_null($patternFound)) {
$patternFound = [false, $this->sanitizeString($cssFileName)];
}
return $patternFound;
}
|
php
|
protected function setCssFileCDN($cssFileName)
{
$patternFound = null;
if (strpos(pathinfo($cssFileName)['basename'], 'font-awesome-') !== false) {
$patternFound = $this->setCssFileCDNforFontAwesome($cssFileName);
}
if (is_null($patternFound)) {
$patternFound = [false, $this->sanitizeString($cssFileName)];
}
return $patternFound;
}
|
[
"protected",
"function",
"setCssFileCDN",
"(",
"$",
"cssFileName",
")",
"{",
"$",
"patternFound",
"=",
"null",
";",
"if",
"(",
"strpos",
"(",
"pathinfo",
"(",
"$",
"cssFileName",
")",
"[",
"'basename'",
"]",
",",
"'font-awesome-'",
")",
"!==",
"false",
")",
"{",
"$",
"patternFound",
"=",
"$",
"this",
"->",
"setCssFileCDNforFontAwesome",
"(",
"$",
"cssFileName",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"patternFound",
")",
")",
"{",
"$",
"patternFound",
"=",
"[",
"false",
",",
"$",
"this",
"->",
"sanitizeString",
"(",
"$",
"cssFileName",
")",
"]",
";",
"}",
"return",
"$",
"patternFound",
";",
"}"
] |
Manages all known CSS that can be handled through CDNs
@param string $cssFileName
@return array|string
|
[
"Manages",
"all",
"known",
"CSS",
"that",
"can",
"be",
"handled",
"through",
"CDNs"
] |
627b99b4408414c7cd21a6c8016f6468dc9216b2
|
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/DomCssAndJavascriptByDanielGPwithCDN.php#L78-L88
|
25,009
|
danielgp/common-lib
|
source/DomCssAndJavascriptByDanielGPwithCDN.php
|
DomCssAndJavascriptByDanielGPwithCDN.setJavascriptFileCDNforHighChartsMain
|
private function setJavascriptFileCDNforHighChartsMain($jsFileName, $libName)
{
$jsFN = $this->sanitizeString($jsFileName);
$jsVersionlessFN = str_replace([$libName . '-', '.js'], '', pathinfo($jsFileName)['basename'])
. ($libName === 'exporting' ? '/modules' : '');
if (strpos($jsFileName, $libName) !== false) {
return [
true,
$this->sCloundFlareUrl . 'highcharts/' . $jsVersionlessFN . '/' . $libName . '.js',
'<script>!window.Highcharts && document.write(\'<script src="' . $jsFN . '">\x3C/script>\')</script>',
];
}
return null;
}
|
php
|
private function setJavascriptFileCDNforHighChartsMain($jsFileName, $libName)
{
$jsFN = $this->sanitizeString($jsFileName);
$jsVersionlessFN = str_replace([$libName . '-', '.js'], '', pathinfo($jsFileName)['basename'])
. ($libName === 'exporting' ? '/modules' : '');
if (strpos($jsFileName, $libName) !== false) {
return [
true,
$this->sCloundFlareUrl . 'highcharts/' . $jsVersionlessFN . '/' . $libName . '.js',
'<script>!window.Highcharts && document.write(\'<script src="' . $jsFN . '">\x3C/script>\')</script>',
];
}
return null;
}
|
[
"private",
"function",
"setJavascriptFileCDNforHighChartsMain",
"(",
"$",
"jsFileName",
",",
"$",
"libName",
")",
"{",
"$",
"jsFN",
"=",
"$",
"this",
"->",
"sanitizeString",
"(",
"$",
"jsFileName",
")",
";",
"$",
"jsVersionlessFN",
"=",
"str_replace",
"(",
"[",
"$",
"libName",
".",
"'-'",
",",
"'.js'",
"]",
",",
"''",
",",
"pathinfo",
"(",
"$",
"jsFileName",
")",
"[",
"'basename'",
"]",
")",
".",
"(",
"$",
"libName",
"===",
"'exporting'",
"?",
"'/modules'",
":",
"''",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"jsFileName",
",",
"$",
"libName",
")",
"!==",
"false",
")",
"{",
"return",
"[",
"true",
",",
"$",
"this",
"->",
"sCloundFlareUrl",
".",
"'highcharts/'",
".",
"$",
"jsVersionlessFN",
".",
"'/'",
".",
"$",
"libName",
".",
"'.js'",
",",
"'<script>!window.Highcharts && document.write(\\'<script src=\"'",
".",
"$",
"jsFN",
".",
"'\">\\x3C/script>\\')</script>'",
",",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns an array with CDN call of a known Javascript library
and fall-back line that points to local cache of it
specific for HighCharts
@param string $jsFileName
@param string $libName
@return array
|
[
"Returns",
"an",
"array",
"with",
"CDN",
"call",
"of",
"a",
"known",
"Javascript",
"library",
"and",
"fall",
"-",
"back",
"line",
"that",
"points",
"to",
"local",
"cache",
"of",
"it",
"specific",
"for",
"HighCharts"
] |
627b99b4408414c7cd21a6c8016f6468dc9216b2
|
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/DomCssAndJavascriptByDanielGPwithCDN.php#L178-L191
|
25,010
|
danielgp/common-lib
|
source/DomCssAndJavascriptByDanielGPwithCDN.php
|
DomCssAndJavascriptByDanielGPwithCDN.setJavascriptFileCDNjQuery
|
private function setJavascriptFileCDNjQuery($jsFileName)
{
$jQueryPosition = strpos($jsFileName, 'jquery-');
$jQueryMajorVersion = substr($jsFileName, 7, 1);
if (($jQueryPosition !== false) && is_numeric($jQueryMajorVersion) && (substr($jsFileName, -7) == '.min.js')) {
return [
true,
$this->sCloundFlareUrl . 'jquery/' . $this->getCmpltVers($jsFileName, 'jquery-') . '/jquery.min.js',
'<script>window.jQuery || document.write(\'<script src="' . $this->sanitizeString($jsFileName)
. '">\x3C/script>\')</script>',
];
}
return null;
}
|
php
|
private function setJavascriptFileCDNjQuery($jsFileName)
{
$jQueryPosition = strpos($jsFileName, 'jquery-');
$jQueryMajorVersion = substr($jsFileName, 7, 1);
if (($jQueryPosition !== false) && is_numeric($jQueryMajorVersion) && (substr($jsFileName, -7) == '.min.js')) {
return [
true,
$this->sCloundFlareUrl . 'jquery/' . $this->getCmpltVers($jsFileName, 'jquery-') . '/jquery.min.js',
'<script>window.jQuery || document.write(\'<script src="' . $this->sanitizeString($jsFileName)
. '">\x3C/script>\')</script>',
];
}
return null;
}
|
[
"private",
"function",
"setJavascriptFileCDNjQuery",
"(",
"$",
"jsFileName",
")",
"{",
"$",
"jQueryPosition",
"=",
"strpos",
"(",
"$",
"jsFileName",
",",
"'jquery-'",
")",
";",
"$",
"jQueryMajorVersion",
"=",
"substr",
"(",
"$",
"jsFileName",
",",
"7",
",",
"1",
")",
";",
"if",
"(",
"(",
"$",
"jQueryPosition",
"!==",
"false",
")",
"&&",
"is_numeric",
"(",
"$",
"jQueryMajorVersion",
")",
"&&",
"(",
"substr",
"(",
"$",
"jsFileName",
",",
"-",
"7",
")",
"==",
"'.min.js'",
")",
")",
"{",
"return",
"[",
"true",
",",
"$",
"this",
"->",
"sCloundFlareUrl",
".",
"'jquery/'",
".",
"$",
"this",
"->",
"getCmpltVers",
"(",
"$",
"jsFileName",
",",
"'jquery-'",
")",
".",
"'/jquery.min.js'",
",",
"'<script>window.jQuery || document.write(\\'<script src=\"'",
".",
"$",
"this",
"->",
"sanitizeString",
"(",
"$",
"jsFileName",
")",
".",
"'\">\\x3C/script>\\')</script>'",
",",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns an array with CDN call of a known Javascript library
and fall-back line that points to local cache of it
specific for jQuery
@param string $jsFileName
@return array
|
[
"Returns",
"an",
"array",
"with",
"CDN",
"call",
"of",
"a",
"known",
"Javascript",
"library",
"and",
"fall",
"-",
"back",
"line",
"that",
"points",
"to",
"local",
"cache",
"of",
"it",
"specific",
"for",
"jQuery"
] |
627b99b4408414c7cd21a6c8016f6468dc9216b2
|
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/DomCssAndJavascriptByDanielGPwithCDN.php#L201-L214
|
25,011
|
danielgp/common-lib
|
source/DomCssAndJavascriptByDanielGPwithCDN.php
|
DomCssAndJavascriptByDanielGPwithCDN.setJavascriptFileCDNjQueryLibs
|
private function setJavascriptFileCDNjQueryLibs($jsFileName)
{
$sFN = $this->sanitizeString($jsFileName);
$eArray = $this->knownCloudFlareJavascript($sFN);
if (!is_null($eArray['version'])) {
return [
true,
$this->sCloundFlareUrl . $eArray['version'] . $eArray['justFile'],
'<script>' . $eArray['eVerify'] . ' || document.write(\'<script src="' . $sFN
. '">\x3C/script>\')</script>',
];
}
return null;
}
|
php
|
private function setJavascriptFileCDNjQueryLibs($jsFileName)
{
$sFN = $this->sanitizeString($jsFileName);
$eArray = $this->knownCloudFlareJavascript($sFN);
if (!is_null($eArray['version'])) {
return [
true,
$this->sCloundFlareUrl . $eArray['version'] . $eArray['justFile'],
'<script>' . $eArray['eVerify'] . ' || document.write(\'<script src="' . $sFN
. '">\x3C/script>\')</script>',
];
}
return null;
}
|
[
"private",
"function",
"setJavascriptFileCDNjQueryLibs",
"(",
"$",
"jsFileName",
")",
"{",
"$",
"sFN",
"=",
"$",
"this",
"->",
"sanitizeString",
"(",
"$",
"jsFileName",
")",
";",
"$",
"eArray",
"=",
"$",
"this",
"->",
"knownCloudFlareJavascript",
"(",
"$",
"sFN",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"eArray",
"[",
"'version'",
"]",
")",
")",
"{",
"return",
"[",
"true",
",",
"$",
"this",
"->",
"sCloundFlareUrl",
".",
"$",
"eArray",
"[",
"'version'",
"]",
".",
"$",
"eArray",
"[",
"'justFile'",
"]",
",",
"'<script>'",
".",
"$",
"eArray",
"[",
"'eVerify'",
"]",
".",
"' || document.write(\\'<script src=\"'",
".",
"$",
"sFN",
".",
"'\">\\x3C/script>\\')</script>'",
",",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns an array with CDN call of a known Javascript library
and fall-back line that points to local cache of it
specific for jQuery Libraries
@param string $jsFileName
@return array
|
[
"Returns",
"an",
"array",
"with",
"CDN",
"call",
"of",
"a",
"known",
"Javascript",
"library",
"and",
"fall",
"-",
"back",
"line",
"that",
"points",
"to",
"local",
"cache",
"of",
"it",
"specific",
"for",
"jQuery",
"Libraries"
] |
627b99b4408414c7cd21a6c8016f6468dc9216b2
|
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/DomCssAndJavascriptByDanielGPwithCDN.php#L224-L237
|
25,012
|
SysControllers/Admin
|
src/app/Http/Controllers/Admin/UsersController.php
|
UsersController.profileData
|
public function profileData()
{
$user = Auth::user();
$profile = UserProfile::whereUserId($user->id)->first();
$data = Input::all();
$rules = [
'nombre' => 'required',
'apellidos' => 'required'
];
$validator = Validator::make($data, $rules);
if($validator->passes())
{
$profile->fill($data);
$profile->save();
//REDIRECCIONAR A PAGINA PARA VER DATOS
return redirect()->route('admin.user.profile');
}
else
{
return Redirect::back()->withInput()->withErrors($validator->messages());
}
}
|
php
|
public function profileData()
{
$user = Auth::user();
$profile = UserProfile::whereUserId($user->id)->first();
$data = Input::all();
$rules = [
'nombre' => 'required',
'apellidos' => 'required'
];
$validator = Validator::make($data, $rules);
if($validator->passes())
{
$profile->fill($data);
$profile->save();
//REDIRECCIONAR A PAGINA PARA VER DATOS
return redirect()->route('admin.user.profile');
}
else
{
return Redirect::back()->withInput()->withErrors($validator->messages());
}
}
|
[
"public",
"function",
"profileData",
"(",
")",
"{",
"$",
"user",
"=",
"Auth",
"::",
"user",
"(",
")",
";",
"$",
"profile",
"=",
"UserProfile",
"::",
"whereUserId",
"(",
"$",
"user",
"->",
"id",
")",
"->",
"first",
"(",
")",
";",
"$",
"data",
"=",
"Input",
"::",
"all",
"(",
")",
";",
"$",
"rules",
"=",
"[",
"'nombre'",
"=>",
"'required'",
",",
"'apellidos'",
"=>",
"'required'",
"]",
";",
"$",
"validator",
"=",
"Validator",
"::",
"make",
"(",
"$",
"data",
",",
"$",
"rules",
")",
";",
"if",
"(",
"$",
"validator",
"->",
"passes",
"(",
")",
")",
"{",
"$",
"profile",
"->",
"fill",
"(",
"$",
"data",
")",
";",
"$",
"profile",
"->",
"save",
"(",
")",
";",
"//REDIRECCIONAR A PAGINA PARA VER DATOS",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'admin.user.profile'",
")",
";",
"}",
"else",
"{",
"return",
"Redirect",
"::",
"back",
"(",
")",
"->",
"withInput",
"(",
")",
"->",
"withErrors",
"(",
"$",
"validator",
"->",
"messages",
"(",
")",
")",
";",
"}",
"}"
] |
Funcion para cambiar datos de Perfil de usuario logeado
|
[
"Funcion",
"para",
"cambiar",
"datos",
"de",
"Perfil",
"de",
"usuario",
"logeado"
] |
8f1df46aca422b87f2f522fbba610dcfa0c5f7f3
|
https://github.com/SysControllers/Admin/blob/8f1df46aca422b87f2f522fbba610dcfa0c5f7f3/src/app/Http/Controllers/Admin/UsersController.php#L197-L224
|
25,013
|
koolkode/lexer
|
src/AbstractTokenSequence.php
|
AbstractTokenSequence.contains
|
public function contains($type)
{
foreach($this->tokens as $token)
{
if($token->is($type))
{
return true;
}
}
return false;
}
|
php
|
public function contains($type)
{
foreach($this->tokens as $token)
{
if($token->is($type))
{
return true;
}
}
return false;
}
|
[
"public",
"function",
"contains",
"(",
"$",
"type",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"tokens",
"as",
"$",
"token",
")",
"{",
"if",
"(",
"$",
"token",
"->",
"is",
"(",
"$",
"type",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if the sequence contains at least one token of the given type.
@param integer $type
@return boolean
|
[
"Check",
"if",
"the",
"sequence",
"contains",
"at",
"least",
"one",
"token",
"of",
"the",
"given",
"type",
"."
] |
1f33fb4e95bf3b6b21c63187e503bbe612a1646c
|
https://github.com/koolkode/lexer/blob/1f33fb4e95bf3b6b21c63187e503bbe612a1646c/src/AbstractTokenSequence.php#L42-L53
|
25,014
|
koolkode/lexer
|
src/AbstractTokenSequence.php
|
AbstractTokenSequence.containsOneOf
|
public function containsOneOf(array $types)
{
foreach($this->tokens as $token)
{
if($token->isOneOf($types))
{
return true;
}
}
return false;
}
|
php
|
public function containsOneOf(array $types)
{
foreach($this->tokens as $token)
{
if($token->isOneOf($types))
{
return true;
}
}
return false;
}
|
[
"public",
"function",
"containsOneOf",
"(",
"array",
"$",
"types",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"tokens",
"as",
"$",
"token",
")",
"{",
"if",
"(",
"$",
"token",
"->",
"isOneOf",
"(",
"$",
"types",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if the sequence contains at least one token of any of the given token types.
@param array<integer> $types
@return boolean
|
[
"Check",
"if",
"the",
"sequence",
"contains",
"at",
"least",
"one",
"token",
"of",
"any",
"of",
"the",
"given",
"token",
"types",
"."
] |
1f33fb4e95bf3b6b21c63187e503bbe612a1646c
|
https://github.com/koolkode/lexer/blob/1f33fb4e95bf3b6b21c63187e503bbe612a1646c/src/AbstractTokenSequence.php#L61-L72
|
25,015
|
koolkode/lexer
|
src/AbstractTokenSequence.php
|
AbstractTokenSequence.endsWith
|
public function endsWith($type)
{
if(empty($this->tokens))
{
return false;
}
return $this->tokens[count($this->tokens) - 1]->is($type);
}
|
php
|
public function endsWith($type)
{
if(empty($this->tokens))
{
return false;
}
return $this->tokens[count($this->tokens) - 1]->is($type);
}
|
[
"public",
"function",
"endsWith",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"tokens",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"tokens",
"[",
"count",
"(",
"$",
"this",
"->",
"tokens",
")",
"-",
"1",
"]",
"->",
"is",
"(",
"$",
"type",
")",
";",
"}"
] |
Check if the sequence ends with a token of the given token type.
@param integer $type
@return boolean
|
[
"Check",
"if",
"the",
"sequence",
"ends",
"with",
"a",
"token",
"of",
"the",
"given",
"token",
"type",
"."
] |
1f33fb4e95bf3b6b21c63187e503bbe612a1646c
|
https://github.com/koolkode/lexer/blob/1f33fb4e95bf3b6b21c63187e503bbe612a1646c/src/AbstractTokenSequence.php#L80-L88
|
25,016
|
koolkode/http
|
src/HttpResponse.php
|
HttpResponse.setStatus
|
public function setStatus($status)
{
$status = (int)$status;
if($status < 100)
{
throw new \InvalidArgumentException(sprintf('Invalid HTTP status code: %u', $status));
}
if($status >= 600)
{
throw new \InvalidArgumentException(sprintf('Invalid HTTP status code: %u', $status));
}
$this->status = $status;
return $this;
}
|
php
|
public function setStatus($status)
{
$status = (int)$status;
if($status < 100)
{
throw new \InvalidArgumentException(sprintf('Invalid HTTP status code: %u', $status));
}
if($status >= 600)
{
throw new \InvalidArgumentException(sprintf('Invalid HTTP status code: %u', $status));
}
$this->status = $status;
return $this;
}
|
[
"public",
"function",
"setStatus",
"(",
"$",
"status",
")",
"{",
"$",
"status",
"=",
"(",
"int",
")",
"$",
"status",
";",
"if",
"(",
"$",
"status",
"<",
"100",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid HTTP status code: %u'",
",",
"$",
"status",
")",
")",
";",
"}",
"if",
"(",
"$",
"status",
">=",
"600",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid HTTP status code: %u'",
",",
"$",
"status",
")",
")",
";",
"}",
"$",
"this",
"->",
"status",
"=",
"$",
"status",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the HTTP status of this response.
@param integer $status
@return HttpResponse
@throws \InvalidArgumentException
|
[
"Set",
"the",
"HTTP",
"status",
"of",
"this",
"response",
"."
] |
3c1626d409d5ce5d71d26f0e8f31ae3683a2a966
|
https://github.com/koolkode/http/blob/3c1626d409d5ce5d71d26f0e8f31ae3683a2a966/src/HttpResponse.php#L82-L99
|
25,017
|
koolkode/http
|
src/HttpResponse.php
|
HttpResponse.removeCookie
|
public function removeCookie($name)
{
$cookie = new SetCookieHeader($name, '');
$cookie->setExpires(1337);
$this->addHeader($cookie);
return $this;
}
|
php
|
public function removeCookie($name)
{
$cookie = new SetCookieHeader($name, '');
$cookie->setExpires(1337);
$this->addHeader($cookie);
return $this;
}
|
[
"public",
"function",
"removeCookie",
"(",
"$",
"name",
")",
"{",
"$",
"cookie",
"=",
"new",
"SetCookieHeader",
"(",
"$",
"name",
",",
"''",
")",
";",
"$",
"cookie",
"->",
"setExpires",
"(",
"1337",
")",
";",
"$",
"this",
"->",
"addHeader",
"(",
"$",
"cookie",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Remove a cookie by eliminating a Set-Cookie header for this cookie replacing it with a
header that will cause the client to remove the cookie.
@param string $name Name of the cookie to be removed.
@return HttpResponse
|
[
"Remove",
"a",
"cookie",
"by",
"eliminating",
"a",
"Set",
"-",
"Cookie",
"header",
"for",
"this",
"cookie",
"replacing",
"it",
"with",
"a",
"header",
"that",
"will",
"cause",
"the",
"client",
"to",
"remove",
"the",
"cookie",
"."
] |
3c1626d409d5ce5d71d26f0e8f31ae3683a2a966
|
https://github.com/koolkode/http/blob/3c1626d409d5ce5d71d26f0e8f31ae3683a2a966/src/HttpResponse.php#L194-L202
|
25,018
|
shrink0r/monatic
|
src/Attempt.php
|
Attempt.get
|
public function get(callable $codeBlock = null)
{
if (!$this->result) {
$this->result = $this->run(new Success);
}
if ($this->result instanceof Success) {
return is_callable($codeBlock) ? $codeBlock($this->result) : $this->result;
}
return $this->result;
}
|
php
|
public function get(callable $codeBlock = null)
{
if (!$this->result) {
$this->result = $this->run(new Success);
}
if ($this->result instanceof Success) {
return is_callable($codeBlock) ? $codeBlock($this->result) : $this->result;
}
return $this->result;
}
|
[
"public",
"function",
"get",
"(",
"callable",
"$",
"codeBlock",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"result",
")",
"{",
"$",
"this",
"->",
"result",
"=",
"$",
"this",
"->",
"run",
"(",
"new",
"Success",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"result",
"instanceof",
"Success",
")",
"{",
"return",
"is_callable",
"(",
"$",
"codeBlock",
")",
"?",
"$",
"codeBlock",
"(",
"$",
"this",
"->",
"result",
")",
":",
"$",
"this",
"->",
"result",
";",
"}",
"return",
"$",
"this",
"->",
"result",
";",
"}"
] |
Returns the result of the code-block execution attempt.
@param callable $codeBlock Is never executed for this type.
@return null
|
[
"Returns",
"the",
"result",
"of",
"the",
"code",
"-",
"block",
"execution",
"attempt",
"."
] |
f39b8b2ef68a397d31d844341487412b335fd107
|
https://github.com/shrink0r/monatic/blob/f39b8b2ef68a397d31d844341487412b335fd107/src/Attempt.php#L38-L49
|
25,019
|
shrink0r/monatic
|
src/Attempt.php
|
Attempt.bind
|
public function bind(callable $codeBlock)
{
return static::unit(function ($result) use ($codeBlock) {
$result = $this->run($result);
if ($result instanceof Success) {
return $codeBlock($result);
} else {
return $result;
}
});
}
|
php
|
public function bind(callable $codeBlock)
{
return static::unit(function ($result) use ($codeBlock) {
$result = $this->run($result);
if ($result instanceof Success) {
return $codeBlock($result);
} else {
return $result;
}
});
}
|
[
"public",
"function",
"bind",
"(",
"callable",
"$",
"codeBlock",
")",
"{",
"return",
"static",
"::",
"unit",
"(",
"function",
"(",
"$",
"result",
")",
"use",
"(",
"$",
"codeBlock",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"run",
"(",
"$",
"result",
")",
";",
"if",
"(",
"$",
"result",
"instanceof",
"Success",
")",
"{",
"return",
"$",
"codeBlock",
"(",
"$",
"result",
")",
";",
"}",
"else",
"{",
"return",
"$",
"result",
";",
"}",
"}",
")",
";",
"}"
] |
Returns a new Attempt monad that is bound to the given code-block.
@param callable $codeBlock
@return Attempt
|
[
"Returns",
"a",
"new",
"Attempt",
"monad",
"that",
"is",
"bound",
"to",
"the",
"given",
"code",
"-",
"block",
"."
] |
f39b8b2ef68a397d31d844341487412b335fd107
|
https://github.com/shrink0r/monatic/blob/f39b8b2ef68a397d31d844341487412b335fd107/src/Attempt.php#L58-L68
|
25,020
|
shrink0r/monatic
|
src/Attempt.php
|
Attempt.run
|
protected function run(MonadInterface $prevResult, callable $next = null)
{
try {
$result = call_user_func($this->codeBlock, $prevResult);
return ($result instanceof MonadInterface) ? $result : Success::unit($result);
} catch (Exception $error) {
return Error::unit($error);
}
}
|
php
|
protected function run(MonadInterface $prevResult, callable $next = null)
{
try {
$result = call_user_func($this->codeBlock, $prevResult);
return ($result instanceof MonadInterface) ? $result : Success::unit($result);
} catch (Exception $error) {
return Error::unit($error);
}
}
|
[
"protected",
"function",
"run",
"(",
"MonadInterface",
"$",
"prevResult",
",",
"callable",
"$",
"next",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"codeBlock",
",",
"$",
"prevResult",
")",
";",
"return",
"(",
"$",
"result",
"instanceof",
"MonadInterface",
")",
"?",
"$",
"result",
":",
"Success",
"::",
"unit",
"(",
"$",
"result",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"error",
")",
"{",
"return",
"Error",
"::",
"unit",
"(",
"$",
"error",
")",
";",
"}",
"}"
] |
Runs the monad's code-block.
@param MonadInterface $prevResult
@param callable $next
@return MonadInterface Either Success or Error in case an exception occured.
|
[
"Runs",
"the",
"monad",
"s",
"code",
"-",
"block",
"."
] |
f39b8b2ef68a397d31d844341487412b335fd107
|
https://github.com/shrink0r/monatic/blob/f39b8b2ef68a397d31d844341487412b335fd107/src/Attempt.php#L89-L97
|
25,021
|
ciims/ciims-modules-install
|
models/UserForm.php
|
UserForm.validateForm
|
public function validateForm()
{
// Validates the model
if ($this->validate())
{
// Getters and setters don't work in CFormModel? So set them manually
$this->encryptionKey = $this->getEncryptionKey();
$this->encryptedPassword = $this->getEncryptedPassword();
return true;
}
return false;
}
|
php
|
public function validateForm()
{
// Validates the model
if ($this->validate())
{
// Getters and setters don't work in CFormModel? So set them manually
$this->encryptionKey = $this->getEncryptionKey();
$this->encryptedPassword = $this->getEncryptedPassword();
return true;
}
return false;
}
|
[
"public",
"function",
"validateForm",
"(",
")",
"{",
"// Validates the model",
"if",
"(",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"// Getters and setters don't work in CFormModel? So set them manually",
"$",
"this",
"->",
"encryptionKey",
"=",
"$",
"this",
"->",
"getEncryptionKey",
"(",
")",
";",
"$",
"this",
"->",
"encryptedPassword",
"=",
"$",
"this",
"->",
"getEncryptedPassword",
"(",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Validates the model, and provides the encrypted data stream for hashing
@return bool If the model validated or not
|
[
"Validates",
"the",
"model",
"and",
"provides",
"the",
"encrypted",
"data",
"stream",
"for",
"hashing"
] |
54d6a93e5c42c2d98e19de38a90e27f77358e88b
|
https://github.com/ciims/ciims-modules-install/blob/54d6a93e5c42c2d98e19de38a90e27f77358e88b/models/UserForm.php#L90-L102
|
25,022
|
ciims/ciims-modules-install
|
models/UserForm.php
|
UserForm.save
|
public function save()
{
if (!$this->validateForm())
return false;
try
{
// Store some data in session temporarily
Yii::app()->session['encryptionKey'] = $this->encryptionKey;
Yii::app()->session['siteName'] = $this->siteName;
Yii::app()->session['primaryEmail'] = $this->email;
// Try to save the record into the database
$connection = new CDbConnection(Yii::app()->session['dsn']['dsn'], Yii::app()->session['dsn']['username'], Yii::app()->session['dsn']['password']);
$connection->setActive(true);
$connection->createCommand('INSERT INTO users (id, email, password, username, user_role, status, created, updated) VALUES (1, :email, :password, :username, 9, 1, UNIX_TIMESTAMP(),UNIX_TIMESTAMP())')
->bindParam(':email', $this->email)
->bindParam(':password', $this->encryptedPassword)
->bindParam(':username', $this->username)
->execute();
return true;
}
catch (CDbException $e)
{
$this->addError('password', Yii::t('Install.main','There was an error saving your details to the database.'));
return false;
}
return false;
}
|
php
|
public function save()
{
if (!$this->validateForm())
return false;
try
{
// Store some data in session temporarily
Yii::app()->session['encryptionKey'] = $this->encryptionKey;
Yii::app()->session['siteName'] = $this->siteName;
Yii::app()->session['primaryEmail'] = $this->email;
// Try to save the record into the database
$connection = new CDbConnection(Yii::app()->session['dsn']['dsn'], Yii::app()->session['dsn']['username'], Yii::app()->session['dsn']['password']);
$connection->setActive(true);
$connection->createCommand('INSERT INTO users (id, email, password, username, user_role, status, created, updated) VALUES (1, :email, :password, :username, 9, 1, UNIX_TIMESTAMP(),UNIX_TIMESTAMP())')
->bindParam(':email', $this->email)
->bindParam(':password', $this->encryptedPassword)
->bindParam(':username', $this->username)
->execute();
return true;
}
catch (CDbException $e)
{
$this->addError('password', Yii::t('Install.main','There was an error saving your details to the database.'));
return false;
}
return false;
}
|
[
"public",
"function",
"save",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateForm",
"(",
")",
")",
"return",
"false",
";",
"try",
"{",
"// Store some data in session temporarily",
"Yii",
"::",
"app",
"(",
")",
"->",
"session",
"[",
"'encryptionKey'",
"]",
"=",
"$",
"this",
"->",
"encryptionKey",
";",
"Yii",
"::",
"app",
"(",
")",
"->",
"session",
"[",
"'siteName'",
"]",
"=",
"$",
"this",
"->",
"siteName",
";",
"Yii",
"::",
"app",
"(",
")",
"->",
"session",
"[",
"'primaryEmail'",
"]",
"=",
"$",
"this",
"->",
"email",
";",
"// Try to save the record into the database",
"$",
"connection",
"=",
"new",
"CDbConnection",
"(",
"Yii",
"::",
"app",
"(",
")",
"->",
"session",
"[",
"'dsn'",
"]",
"[",
"'dsn'",
"]",
",",
"Yii",
"::",
"app",
"(",
")",
"->",
"session",
"[",
"'dsn'",
"]",
"[",
"'username'",
"]",
",",
"Yii",
"::",
"app",
"(",
")",
"->",
"session",
"[",
"'dsn'",
"]",
"[",
"'password'",
"]",
")",
";",
"$",
"connection",
"->",
"setActive",
"(",
"true",
")",
";",
"$",
"connection",
"->",
"createCommand",
"(",
"'INSERT INTO users (id, email, password, username, user_role, status, created, updated) VALUES (1, :email, :password, :username, 9, 1, UNIX_TIMESTAMP(),UNIX_TIMESTAMP())'",
")",
"->",
"bindParam",
"(",
"':email'",
",",
"$",
"this",
"->",
"email",
")",
"->",
"bindParam",
"(",
"':password'",
",",
"$",
"this",
"->",
"encryptedPassword",
")",
"->",
"bindParam",
"(",
"':username'",
",",
"$",
"this",
"->",
"username",
")",
"->",
"execute",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"CDbException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"'password'",
",",
"Yii",
"::",
"t",
"(",
"'Install.main'",
",",
"'There was an error saving your details to the database.'",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"false",
";",
"}"
] |
This method will save the admin user into the database,
|
[
"This",
"method",
"will",
"save",
"the",
"admin",
"user",
"into",
"the",
"database"
] |
54d6a93e5c42c2d98e19de38a90e27f77358e88b
|
https://github.com/ciims/ciims-modules-install/blob/54d6a93e5c42c2d98e19de38a90e27f77358e88b/models/UserForm.php#L107-L136
|
25,023
|
ciims/ciims-modules-install
|
models/UserForm.php
|
UserForm.checkConfigDir
|
public function checkConfigDir()
{
if (is_writable(dirname(__FILE__) . '/../../../config'))
return true;
$this->addError('isConfigDirWritable', Yii::t('Install.main','Configuration directory is not writable. This must be corrected before your settings can be applied.'));
return false;
}
|
php
|
public function checkConfigDir()
{
if (is_writable(dirname(__FILE__) . '/../../../config'))
return true;
$this->addError('isConfigDirWritable', Yii::t('Install.main','Configuration directory is not writable. This must be corrected before your settings can be applied.'));
return false;
}
|
[
"public",
"function",
"checkConfigDir",
"(",
")",
"{",
"if",
"(",
"is_writable",
"(",
"dirname",
"(",
"__FILE__",
")",
".",
"'/../../../config'",
")",
")",
"return",
"true",
";",
"$",
"this",
"->",
"addError",
"(",
"'isConfigDirWritable'",
",",
"Yii",
"::",
"t",
"(",
"'Install.main'",
",",
"'Configuration directory is not writable. This must be corrected before your settings can be applied.'",
")",
")",
";",
"return",
"false",
";",
"}"
] |
Validator for checkConfigDir
|
[
"Validator",
"for",
"checkConfigDir"
] |
54d6a93e5c42c2d98e19de38a90e27f77358e88b
|
https://github.com/ciims/ciims-modules-install/blob/54d6a93e5c42c2d98e19de38a90e27f77358e88b/models/UserForm.php#L141-L148
|
25,024
|
frodosghost/AtomLoggerBundle
|
Connection/Request.php
|
Request.formatData
|
public function formatData()
{
$this->formatter->addData($this->data);
try {
$formatted = $this->formatter->format();
} catch (DataException $e) {
throw new FormattingException('The provided data has been incorrectly formatted.');
}
return $formatted;
}
|
php
|
public function formatData()
{
$this->formatter->addData($this->data);
try {
$formatted = $this->formatter->format();
} catch (DataException $e) {
throw new FormattingException('The provided data has been incorrectly formatted.');
}
return $formatted;
}
|
[
"public",
"function",
"formatData",
"(",
")",
"{",
"$",
"this",
"->",
"formatter",
"->",
"addData",
"(",
"$",
"this",
"->",
"data",
")",
";",
"try",
"{",
"$",
"formatted",
"=",
"$",
"this",
"->",
"formatter",
"->",
"format",
"(",
")",
";",
"}",
"catch",
"(",
"DataException",
"$",
"e",
")",
"{",
"throw",
"new",
"FormattingException",
"(",
"'The provided data has been incorrectly formatted.'",
")",
";",
"}",
"return",
"$",
"formatted",
";",
"}"
] |
Calls the Formatter with the data passed into the Request
@return string
|
[
"Calls",
"the",
"Formatter",
"with",
"the",
"data",
"passed",
"into",
"the",
"Request"
] |
c48823e4b3772e498b366867f27e6581f613f733
|
https://github.com/frodosghost/AtomLoggerBundle/blob/c48823e4b3772e498b366867f27e6581f613f733/Connection/Request.php#L57-L68
|
25,025
|
freialib/fenrir.system
|
src/Web.php
|
Web.send
|
function send($contents, $status = 200, array $headers = null) {
$this->http_response_code($status);
if ($headers !== null) {
foreach ($headers as $header) {
$this->header($header[0], $header[1], $header[2]);
}
}
if ( ! empty($contents)) {
echo $contents;
}
}
|
php
|
function send($contents, $status = 200, array $headers = null) {
$this->http_response_code($status);
if ($headers !== null) {
foreach ($headers as $header) {
$this->header($header[0], $header[1], $header[2]);
}
}
if ( ! empty($contents)) {
echo $contents;
}
}
|
[
"function",
"send",
"(",
"$",
"contents",
",",
"$",
"status",
"=",
"200",
",",
"array",
"$",
"headers",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"http_response_code",
"(",
"$",
"status",
")",
";",
"if",
"(",
"$",
"headers",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
")",
"{",
"$",
"this",
"->",
"header",
"(",
"$",
"header",
"[",
"0",
"]",
",",
"$",
"header",
"[",
"1",
"]",
",",
"$",
"header",
"[",
"2",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"contents",
")",
")",
"{",
"echo",
"$",
"contents",
";",
"}",
"}"
] |
Sent content to the client.
|
[
"Sent",
"content",
"to",
"the",
"client",
"."
] |
388d360dbc3bc6dcf85b09bb06e08a2dce8f3ec8
|
https://github.com/freialib/fenrir.system/blob/388d360dbc3bc6dcf85b09bb06e08a2dce8f3ec8/src/Web.php#L86-L99
|
25,026
|
frodosghost/AtomLoggerBundle
|
Controller/Controller.php
|
Controller.createNotFoundException
|
public function createNotFoundException($message = 'Not Found', \Exception $previous = null)
{
if ($this->has('atom.404.logger')) {
$log = $this->get('atom.404.logger');
$log->addRecord(400, $message, array('request' => $this->getRequest()->getUri()));
}
return new NotFoundHttpException($message, $previous);
}
|
php
|
public function createNotFoundException($message = 'Not Found', \Exception $previous = null)
{
if ($this->has('atom.404.logger')) {
$log = $this->get('atom.404.logger');
$log->addRecord(400, $message, array('request' => $this->getRequest()->getUri()));
}
return new NotFoundHttpException($message, $previous);
}
|
[
"public",
"function",
"createNotFoundException",
"(",
"$",
"message",
"=",
"'Not Found'",
",",
"\\",
"Exception",
"$",
"previous",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"'atom.404.logger'",
")",
")",
"{",
"$",
"log",
"=",
"$",
"this",
"->",
"get",
"(",
"'atom.404.logger'",
")",
";",
"$",
"log",
"->",
"addRecord",
"(",
"400",
",",
"$",
"message",
",",
"array",
"(",
"'request'",
"=>",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getUri",
"(",
")",
")",
")",
";",
"}",
"return",
"new",
"NotFoundHttpException",
"(",
"$",
"message",
",",
"$",
"previous",
")",
";",
"}"
] |
Sends 404 to Page AtomLogger
@param string $message Error Message to be logged
@param \Exception $previous Previous message made prior to 404
@return NotFoundHttpException
|
[
"Sends",
"404",
"to",
"Page",
"AtomLogger"
] |
c48823e4b3772e498b366867f27e6581f613f733
|
https://github.com/frodosghost/AtomLoggerBundle/blob/c48823e4b3772e498b366867f27e6581f613f733/Controller/Controller.php#L26-L34
|
25,027
|
nicodevs/laito
|
src/Laito/Controller.php
|
Controller.index
|
public function index($params = [])
{
// Set the filters
$params = (!empty($params))? $params : $this->app->request->input();
// Get records
$this->model->params = $params;
$result = $this->model->search($params)->get();
// Get pagination and number of records
$pagination = array_merge(
['records' => $this->model->search($params)->count()],
$this->model->pagination()
);
// Return results
return [
'success' => true,
'paging' => $pagination,
'data' => $result
];
}
|
php
|
public function index($params = [])
{
// Set the filters
$params = (!empty($params))? $params : $this->app->request->input();
// Get records
$this->model->params = $params;
$result = $this->model->search($params)->get();
// Get pagination and number of records
$pagination = array_merge(
['records' => $this->model->search($params)->count()],
$this->model->pagination()
);
// Return results
return [
'success' => true,
'paging' => $pagination,
'data' => $result
];
}
|
[
"public",
"function",
"index",
"(",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"// Set the filters",
"$",
"params",
"=",
"(",
"!",
"empty",
"(",
"$",
"params",
")",
")",
"?",
"$",
"params",
":",
"$",
"this",
"->",
"app",
"->",
"request",
"->",
"input",
"(",
")",
";",
"// Get records",
"$",
"this",
"->",
"model",
"->",
"params",
"=",
"$",
"params",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"model",
"->",
"search",
"(",
"$",
"params",
")",
"->",
"get",
"(",
")",
";",
"// Get pagination and number of records",
"$",
"pagination",
"=",
"array_merge",
"(",
"[",
"'records'",
"=>",
"$",
"this",
"->",
"model",
"->",
"search",
"(",
"$",
"params",
")",
"->",
"count",
"(",
")",
"]",
",",
"$",
"this",
"->",
"model",
"->",
"pagination",
"(",
")",
")",
";",
"// Return results",
"return",
"[",
"'success'",
"=>",
"true",
",",
"'paging'",
"=>",
"$",
"pagination",
",",
"'data'",
"=>",
"$",
"result",
"]",
";",
"}"
] |
Display a listing of the resource
@param array $params Listing parameters
@return array Response
|
[
"Display",
"a",
"listing",
"of",
"the",
"resource"
] |
d2d28abfcbf981c4decfec28ce94f8849600e9fe
|
https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Controller.php#L49-L70
|
25,028
|
nicodevs/laito
|
src/Laito/Controller.php
|
Controller.show
|
public function show($id = null)
{
// Check the ID
if (!isset($id)) {
throw new \InvalidArgumentException('Undefined ID', 400);
}
// Get record
$item = $this->model->find($id);
// Abort if the record is not found
if (!$item) {
throw new \Exception('Element not found', 404);
}
// Return response
return [
'success' => true,
'data' => $item
];
}
|
php
|
public function show($id = null)
{
// Check the ID
if (!isset($id)) {
throw new \InvalidArgumentException('Undefined ID', 400);
}
// Get record
$item = $this->model->find($id);
// Abort if the record is not found
if (!$item) {
throw new \Exception('Element not found', 404);
}
// Return response
return [
'success' => true,
'data' => $item
];
}
|
[
"public",
"function",
"show",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"// Check the ID",
"if",
"(",
"!",
"isset",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Undefined ID'",
",",
"400",
")",
";",
"}",
"// Get record",
"$",
"item",
"=",
"$",
"this",
"->",
"model",
"->",
"find",
"(",
"$",
"id",
")",
";",
"// Abort if the record is not found",
"if",
"(",
"!",
"$",
"item",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Element not found'",
",",
"404",
")",
";",
"}",
"// Return response",
"return",
"[",
"'success'",
"=>",
"true",
",",
"'data'",
"=>",
"$",
"item",
"]",
";",
"}"
] |
Display the specified resource
@param array $id Resource ID
@return array Response
|
[
"Display",
"the",
"specified",
"resource"
] |
d2d28abfcbf981c4decfec28ce94f8849600e9fe
|
https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Controller.php#L78-L98
|
25,029
|
nicodevs/laito
|
src/Laito/Controller.php
|
Controller.store
|
public function store($attributes = [])
{
// Set the attributes
$attributes = (!empty($attributes))? $attributes : $this->app->request->input();
// Create the record
$result = $this->model->create($attributes);
// Return results
return [
'success' => true,
'id' => $result['id'],
'data' => $result
];
}
|
php
|
public function store($attributes = [])
{
// Set the attributes
$attributes = (!empty($attributes))? $attributes : $this->app->request->input();
// Create the record
$result = $this->model->create($attributes);
// Return results
return [
'success' => true,
'id' => $result['id'],
'data' => $result
];
}
|
[
"public",
"function",
"store",
"(",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"// Set the attributes",
"$",
"attributes",
"=",
"(",
"!",
"empty",
"(",
"$",
"attributes",
")",
")",
"?",
"$",
"attributes",
":",
"$",
"this",
"->",
"app",
"->",
"request",
"->",
"input",
"(",
")",
";",
"// Create the record",
"$",
"result",
"=",
"$",
"this",
"->",
"model",
"->",
"create",
"(",
"$",
"attributes",
")",
";",
"// Return results",
"return",
"[",
"'success'",
"=>",
"true",
",",
"'id'",
"=>",
"$",
"result",
"[",
"'id'",
"]",
",",
"'data'",
"=>",
"$",
"result",
"]",
";",
"}"
] |
Stores a newly created resource in storage
@param array $params Resource attributes
@return array Response
|
[
"Stores",
"a",
"newly",
"created",
"resource",
"in",
"storage"
] |
d2d28abfcbf981c4decfec28ce94f8849600e9fe
|
https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Controller.php#L106-L120
|
25,030
|
nicodevs/laito
|
src/Laito/Controller.php
|
Controller.update
|
public function update($id = null, $attributes = [])
{
// Check the ID
if (!isset($id)) {
throw new \InvalidArgumentException('Undefined ID', 400);
}
// Set the attributes
$attributes = (!empty($attributes))? $attributes : $this->app->request->input();
// Update the record
$result = $this->model->update($id, $attributes);
// Return results
return [
'success' => true,
'id' => $id,
'data' => $result
];
}
|
php
|
public function update($id = null, $attributes = [])
{
// Check the ID
if (!isset($id)) {
throw new \InvalidArgumentException('Undefined ID', 400);
}
// Set the attributes
$attributes = (!empty($attributes))? $attributes : $this->app->request->input();
// Update the record
$result = $this->model->update($id, $attributes);
// Return results
return [
'success' => true,
'id' => $id,
'data' => $result
];
}
|
[
"public",
"function",
"update",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"// Check the ID",
"if",
"(",
"!",
"isset",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Undefined ID'",
",",
"400",
")",
";",
"}",
"// Set the attributes",
"$",
"attributes",
"=",
"(",
"!",
"empty",
"(",
"$",
"attributes",
")",
")",
"?",
"$",
"attributes",
":",
"$",
"this",
"->",
"app",
"->",
"request",
"->",
"input",
"(",
")",
";",
"// Update the record",
"$",
"result",
"=",
"$",
"this",
"->",
"model",
"->",
"update",
"(",
"$",
"id",
",",
"$",
"attributes",
")",
";",
"// Return results",
"return",
"[",
"'success'",
"=>",
"true",
",",
"'id'",
"=>",
"$",
"id",
",",
"'data'",
"=>",
"$",
"result",
"]",
";",
"}"
] |
Update the specified resource in storage
@param array $id Resource ID
@return array Response
|
[
"Update",
"the",
"specified",
"resource",
"in",
"storage"
] |
d2d28abfcbf981c4decfec28ce94f8849600e9fe
|
https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Controller.php#L128-L147
|
25,031
|
nicodevs/laito
|
src/Laito/Controller.php
|
Controller.destroy
|
public function destroy($id = null)
{
// Check the ID
if (!isset($id)) {
throw new \InvalidArgumentException('Undefined ID', 400);
}
// Delete the record
$result = $this->model->destroy($id);
// Return results
return [
'success' => true,
'id' => $result
];
}
|
php
|
public function destroy($id = null)
{
// Check the ID
if (!isset($id)) {
throw new \InvalidArgumentException('Undefined ID', 400);
}
// Delete the record
$result = $this->model->destroy($id);
// Return results
return [
'success' => true,
'id' => $result
];
}
|
[
"public",
"function",
"destroy",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"// Check the ID",
"if",
"(",
"!",
"isset",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Undefined ID'",
",",
"400",
")",
";",
"}",
"// Delete the record",
"$",
"result",
"=",
"$",
"this",
"->",
"model",
"->",
"destroy",
"(",
"$",
"id",
")",
";",
"// Return results",
"return",
"[",
"'success'",
"=>",
"true",
",",
"'id'",
"=>",
"$",
"result",
"]",
";",
"}"
] |
Remove the specified resource from storage
@param array $id Resource ID
@return array Response
|
[
"Remove",
"the",
"specified",
"resource",
"from",
"storage"
] |
d2d28abfcbf981c4decfec28ce94f8849600e9fe
|
https://github.com/nicodevs/laito/blob/d2d28abfcbf981c4decfec28ce94f8849600e9fe/src/Laito/Controller.php#L155-L170
|
25,032
|
Linkvalue-Interne/MobileNotifBundle
|
DependencyInjection/Configuration.php
|
Configuration.addApnsClientsNode
|
private function addApnsClientsNode()
{
$builder = new TreeBuilder();
$node = $builder->root('apns');
$node
->useAttributeAsKey('name')
->prototype('array')
->children()
->arrayNode('services')
->addDefaultsIfNotSet()
->children()
->scalarNode('logger')->defaultValue('logger')->end()
->scalarNode('profiler')->defaultValue('link_value_mobile_notif.profiler.client_profiler')->end()
->end()
->end()
->arrayNode('params')
->children()
->scalarNode('endpoint')->cannotBeEmpty()->defaultValue('tls://gateway.sandbox.push.apple.com:2195')->end()
->scalarNode('ssl_pem_path')->cannotBeEmpty()->isRequired()->end()
->scalarNode('ssl_passphrase')->cannotBeEmpty()->end()
->end()
->end()
->end()
->end()
;
return $node;
}
|
php
|
private function addApnsClientsNode()
{
$builder = new TreeBuilder();
$node = $builder->root('apns');
$node
->useAttributeAsKey('name')
->prototype('array')
->children()
->arrayNode('services')
->addDefaultsIfNotSet()
->children()
->scalarNode('logger')->defaultValue('logger')->end()
->scalarNode('profiler')->defaultValue('link_value_mobile_notif.profiler.client_profiler')->end()
->end()
->end()
->arrayNode('params')
->children()
->scalarNode('endpoint')->cannotBeEmpty()->defaultValue('tls://gateway.sandbox.push.apple.com:2195')->end()
->scalarNode('ssl_pem_path')->cannotBeEmpty()->isRequired()->end()
->scalarNode('ssl_passphrase')->cannotBeEmpty()->end()
->end()
->end()
->end()
->end()
;
return $node;
}
|
[
"private",
"function",
"addApnsClientsNode",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"node",
"=",
"$",
"builder",
"->",
"root",
"(",
"'apns'",
")",
";",
"$",
"node",
"->",
"useAttributeAsKey",
"(",
"'name'",
")",
"->",
"prototype",
"(",
"'array'",
")",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'services'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'logger'",
")",
"->",
"defaultValue",
"(",
"'logger'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'profiler'",
")",
"->",
"defaultValue",
"(",
"'link_value_mobile_notif.profiler.client_profiler'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'params'",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'endpoint'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'tls://gateway.sandbox.push.apple.com:2195'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'ssl_pem_path'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"isRequired",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'ssl_passphrase'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"node",
";",
"}"
] |
Add APNS clients node.
@return \Symfony\Component\Config\Definition\Builder\NodeDefinition
|
[
"Add",
"APNS",
"clients",
"node",
"."
] |
8124f4132c581516be9928ece81ae2cf9f59763d
|
https://github.com/Linkvalue-Interne/MobileNotifBundle/blob/8124f4132c581516be9928ece81ae2cf9f59763d/DependencyInjection/Configuration.php#L41-L69
|
25,033
|
kkthek/diqa-util
|
maintenance/runStatistics.php
|
RunStatistics.getStatisticSites
|
private function getStatisticSites() {
$result = [ ];
$StatistikQuery = new \SMWPrintRequest ( \SMWPrintRequest::PRINT_PROP, "StatistikQuery",
\SMWPropertyValue::makeUserProperty ( 'StatistikQuery' ) );
$StatistikTemplate = new \SMWPrintRequest ( \SMWPrintRequest::PRINT_PROP, "StatistikTemplate",
\SMWPropertyValue::makeUserProperty ( 'StatistikTemplate' ) );
$pages = QueryUtils::executeBasicQuery ( '[[Category:Statistik]]', [$StatistikQuery, $StatistikTemplate ], [] );
while ( $res = $pages->getNext () ) {
$pageID = $res [0]->getNextText ( SMW_OUTPUT_WIKI );
$StatistikQuery = $res [1]->getNextText ( SMW_OUTPUT_WIKI );
$StatistikTemplate = $res [2]->getNextText ( SMW_OUTPUT_WIKI );
$mwTitle = \Title::newFromText ( $pageID );
$result [] = [ 'title' => $mwTitle,
'statistikQuery' => urldecode($StatistikQuery),
'statistikTemplate' => urldecode($StatistikTemplate)
];
}
return $result;
}
|
php
|
private function getStatisticSites() {
$result = [ ];
$StatistikQuery = new \SMWPrintRequest ( \SMWPrintRequest::PRINT_PROP, "StatistikQuery",
\SMWPropertyValue::makeUserProperty ( 'StatistikQuery' ) );
$StatistikTemplate = new \SMWPrintRequest ( \SMWPrintRequest::PRINT_PROP, "StatistikTemplate",
\SMWPropertyValue::makeUserProperty ( 'StatistikTemplate' ) );
$pages = QueryUtils::executeBasicQuery ( '[[Category:Statistik]]', [$StatistikQuery, $StatistikTemplate ], [] );
while ( $res = $pages->getNext () ) {
$pageID = $res [0]->getNextText ( SMW_OUTPUT_WIKI );
$StatistikQuery = $res [1]->getNextText ( SMW_OUTPUT_WIKI );
$StatistikTemplate = $res [2]->getNextText ( SMW_OUTPUT_WIKI );
$mwTitle = \Title::newFromText ( $pageID );
$result [] = [ 'title' => $mwTitle,
'statistikQuery' => urldecode($StatistikQuery),
'statistikTemplate' => urldecode($StatistikTemplate)
];
}
return $result;
}
|
[
"private",
"function",
"getStatisticSites",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"StatistikQuery",
"=",
"new",
"\\",
"SMWPrintRequest",
"(",
"\\",
"SMWPrintRequest",
"::",
"PRINT_PROP",
",",
"\"StatistikQuery\"",
",",
"\\",
"SMWPropertyValue",
"::",
"makeUserProperty",
"(",
"'StatistikQuery'",
")",
")",
";",
"$",
"StatistikTemplate",
"=",
"new",
"\\",
"SMWPrintRequest",
"(",
"\\",
"SMWPrintRequest",
"::",
"PRINT_PROP",
",",
"\"StatistikTemplate\"",
",",
"\\",
"SMWPropertyValue",
"::",
"makeUserProperty",
"(",
"'StatistikTemplate'",
")",
")",
";",
"$",
"pages",
"=",
"QueryUtils",
"::",
"executeBasicQuery",
"(",
"'[[Category:Statistik]]'",
",",
"[",
"$",
"StatistikQuery",
",",
"$",
"StatistikTemplate",
"]",
",",
"[",
"]",
")",
";",
"while",
"(",
"$",
"res",
"=",
"$",
"pages",
"->",
"getNext",
"(",
")",
")",
"{",
"$",
"pageID",
"=",
"$",
"res",
"[",
"0",
"]",
"->",
"getNextText",
"(",
"SMW_OUTPUT_WIKI",
")",
";",
"$",
"StatistikQuery",
"=",
"$",
"res",
"[",
"1",
"]",
"->",
"getNextText",
"(",
"SMW_OUTPUT_WIKI",
")",
";",
"$",
"StatistikTemplate",
"=",
"$",
"res",
"[",
"2",
"]",
"->",
"getNextText",
"(",
"SMW_OUTPUT_WIKI",
")",
";",
"$",
"mwTitle",
"=",
"\\",
"Title",
"::",
"newFromText",
"(",
"$",
"pageID",
")",
";",
"$",
"result",
"[",
"]",
"=",
"[",
"'title'",
"=>",
"$",
"mwTitle",
",",
"'statistikQuery'",
"=>",
"urldecode",
"(",
"$",
"StatistikQuery",
")",
",",
"'statistikTemplate'",
"=>",
"urldecode",
"(",
"$",
"StatistikTemplate",
")",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns array of statistic site with StatistikQuery, StatistikTemplate annotations
@return array of [ title, statistikQuery, statistikTemplate ]
|
[
"Returns",
"array",
"of",
"statistic",
"site",
"with",
"StatistikQuery",
"StatistikTemplate",
"annotations"
] |
df35d16403b5dbf0f7570daded6cfa26814ae7e0
|
https://github.com/kkthek/diqa-util/blob/df35d16403b5dbf0f7570daded6cfa26814ae7e0/maintenance/runStatistics.php#L49-L71
|
25,034
|
Stinger-Soft/MediaParsingBundle
|
Parser/ParserCompilerPass.php
|
ParserCompilerPass.process
|
public function process(ContainerBuilder $container){
if (!$container->hasDefinition(ParserChainInterface::SERVICE_ID)) {
return;
}
$definition = $container->getDefinition(ParserChainInterface::SERVICE_ID);
$taggedServices = $container->findTaggedServiceIds(MediaParserInterface::SERVICE_TAG);
foreach ($taggedServices as $id => $tagAttributes) {
foreach ($tagAttributes as $attributes) {
$definition->addMethodCall(
'addParser',
array(new Reference($id))
);
}
}
}
|
php
|
public function process(ContainerBuilder $container){
if (!$container->hasDefinition(ParserChainInterface::SERVICE_ID)) {
return;
}
$definition = $container->getDefinition(ParserChainInterface::SERVICE_ID);
$taggedServices = $container->findTaggedServiceIds(MediaParserInterface::SERVICE_TAG);
foreach ($taggedServices as $id => $tagAttributes) {
foreach ($tagAttributes as $attributes) {
$definition->addMethodCall(
'addParser',
array(new Reference($id))
);
}
}
}
|
[
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"$",
"container",
"->",
"hasDefinition",
"(",
"ParserChainInterface",
"::",
"SERVICE_ID",
")",
")",
"{",
"return",
";",
"}",
"$",
"definition",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"ParserChainInterface",
"::",
"SERVICE_ID",
")",
";",
"$",
"taggedServices",
"=",
"$",
"container",
"->",
"findTaggedServiceIds",
"(",
"MediaParserInterface",
"::",
"SERVICE_TAG",
")",
";",
"foreach",
"(",
"$",
"taggedServices",
"as",
"$",
"id",
"=>",
"$",
"tagAttributes",
")",
"{",
"foreach",
"(",
"$",
"tagAttributes",
"as",
"$",
"attributes",
")",
"{",
"$",
"definition",
"->",
"addMethodCall",
"(",
"'addParser'",
",",
"array",
"(",
"new",
"Reference",
"(",
"$",
"id",
")",
")",
")",
";",
"}",
"}",
"}"
] |
Searches for all Audio Parsers that are tagged as 'stinger_soft.audioparser' inside all services.yml files
@see Symfony\Component\DependencyInjection\Compiler.CompilerPassInterface::process()
|
[
"Searches",
"for",
"all",
"Audio",
"Parsers",
"that",
"are",
"tagged",
"as",
"stinger_soft",
".",
"audioparser",
"inside",
"all",
"services",
".",
"yml",
"files"
] |
6f68ddf75c1c4ef4da912643710abc824fd8d3e2
|
https://github.com/Stinger-Soft/MediaParsingBundle/blob/6f68ddf75c1c4ef4da912643710abc824fd8d3e2/Parser/ParserCompilerPass.php#L24-L41
|
25,035
|
sndsgd/http
|
src/http/request/Host.php
|
Host.getDnsName
|
public function getDnsName(): string
{
$host = $this->environment["HTTP_HOST"] ?? "";
$port = strpos($host, ":");
if ($port !== false) {
return substr($host, 0, $port);
}
return $host;
}
|
php
|
public function getDnsName(): string
{
$host = $this->environment["HTTP_HOST"] ?? "";
$port = strpos($host, ":");
if ($port !== false) {
return substr($host, 0, $port);
}
return $host;
}
|
[
"public",
"function",
"getDnsName",
"(",
")",
":",
"string",
"{",
"$",
"host",
"=",
"$",
"this",
"->",
"environment",
"[",
"\"HTTP_HOST\"",
"]",
"??",
"\"\"",
";",
"$",
"port",
"=",
"strpos",
"(",
"$",
"host",
",",
"\":\"",
")",
";",
"if",
"(",
"$",
"port",
"!==",
"false",
")",
"{",
"return",
"substr",
"(",
"$",
"host",
",",
"0",
",",
"$",
"port",
")",
";",
"}",
"return",
"$",
"host",
";",
"}"
] |
Retrieve the name of the request host
@return string
|
[
"Retrieve",
"the",
"name",
"of",
"the",
"request",
"host"
] |
e7f82010a66c6d3241a24ea82baf4593130c723b
|
https://github.com/sndsgd/http/blob/e7f82010a66c6d3241a24ea82baf4593130c723b/src/http/request/Host.php#L45-L53
|
25,036
|
gplcart/cli
|
controllers/commands/Role.php
|
Role.cmdPermAddRole
|
public function cmdPermAddRole()
{
list($role_id, $existing, $submitted) = $this->getPermissionsRole();
$data = array('permissions' => array_unique(array_merge($existing, $submitted)));
$this->setSubmitted(null, $data);
$this->setSubmitted('update', $role_id);
$this->validateComponent('user_role');
$this->updateRole($role_id);
$this->output();
}
|
php
|
public function cmdPermAddRole()
{
list($role_id, $existing, $submitted) = $this->getPermissionsRole();
$data = array('permissions' => array_unique(array_merge($existing, $submitted)));
$this->setSubmitted(null, $data);
$this->setSubmitted('update', $role_id);
$this->validateComponent('user_role');
$this->updateRole($role_id);
$this->output();
}
|
[
"public",
"function",
"cmdPermAddRole",
"(",
")",
"{",
"list",
"(",
"$",
"role_id",
",",
"$",
"existing",
",",
"$",
"submitted",
")",
"=",
"$",
"this",
"->",
"getPermissionsRole",
"(",
")",
";",
"$",
"data",
"=",
"array",
"(",
"'permissions'",
"=>",
"array_unique",
"(",
"array_merge",
"(",
"$",
"existing",
",",
"$",
"submitted",
")",
")",
")",
";",
"$",
"this",
"->",
"setSubmitted",
"(",
"null",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"setSubmitted",
"(",
"'update'",
",",
"$",
"role_id",
")",
";",
"$",
"this",
"->",
"validateComponent",
"(",
"'user_role'",
")",
";",
"$",
"this",
"->",
"updateRole",
"(",
"$",
"role_id",
")",
";",
"$",
"this",
"->",
"output",
"(",
")",
";",
"}"
] |
Callback for "role-perm-add" command
|
[
"Callback",
"for",
"role",
"-",
"perm",
"-",
"add",
"command"
] |
e57dba53e291a225b4bff0c0d9b23d685dd1c125
|
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Role.php#L40-L53
|
25,037
|
gplcart/cli
|
controllers/commands/Role.php
|
Role.cmdPermDeleteRole
|
public function cmdPermDeleteRole()
{
list($role_id, $existing, $submitted) = $this->getPermissionsRole();
$data = array(
'permissions' => array_unique(array_diff($existing, $submitted))
);
$this->setSubmitted(null, $data);
$this->setSubmitted('update', $role_id);
$this->validateComponent('user_role');
$this->updateRole($role_id);
$this->output();
}
|
php
|
public function cmdPermDeleteRole()
{
list($role_id, $existing, $submitted) = $this->getPermissionsRole();
$data = array(
'permissions' => array_unique(array_diff($existing, $submitted))
);
$this->setSubmitted(null, $data);
$this->setSubmitted('update', $role_id);
$this->validateComponent('user_role');
$this->updateRole($role_id);
$this->output();
}
|
[
"public",
"function",
"cmdPermDeleteRole",
"(",
")",
"{",
"list",
"(",
"$",
"role_id",
",",
"$",
"existing",
",",
"$",
"submitted",
")",
"=",
"$",
"this",
"->",
"getPermissionsRole",
"(",
")",
";",
"$",
"data",
"=",
"array",
"(",
"'permissions'",
"=>",
"array_unique",
"(",
"array_diff",
"(",
"$",
"existing",
",",
"$",
"submitted",
")",
")",
")",
";",
"$",
"this",
"->",
"setSubmitted",
"(",
"null",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"setSubmitted",
"(",
"'update'",
",",
"$",
"role_id",
")",
";",
"$",
"this",
"->",
"validateComponent",
"(",
"'user_role'",
")",
";",
"$",
"this",
"->",
"updateRole",
"(",
"$",
"role_id",
")",
";",
"$",
"this",
"->",
"output",
"(",
")",
";",
"}"
] |
Callback for "role-perm-delete" command
|
[
"Callback",
"for",
"role",
"-",
"perm",
"-",
"delete",
"command"
] |
e57dba53e291a225b4bff0c0d9b23d685dd1c125
|
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Role.php#L58-L73
|
25,038
|
gplcart/cli
|
controllers/commands/Role.php
|
Role.cmdGetRole
|
public function cmdGetRole()
{
$result = $this->getListRole();
$this->outputFormat($result);
$this->outputFormatTableRole($result);
$this->output();
}
|
php
|
public function cmdGetRole()
{
$result = $this->getListRole();
$this->outputFormat($result);
$this->outputFormatTableRole($result);
$this->output();
}
|
[
"public",
"function",
"cmdGetRole",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getListRole",
"(",
")",
";",
"$",
"this",
"->",
"outputFormat",
"(",
"$",
"result",
")",
";",
"$",
"this",
"->",
"outputFormatTableRole",
"(",
"$",
"result",
")",
";",
"$",
"this",
"->",
"output",
"(",
")",
";",
"}"
] |
Callback for "role-get" command
|
[
"Callback",
"for",
"role",
"-",
"get",
"command"
] |
e57dba53e291a225b4bff0c0d9b23d685dd1c125
|
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Role.php#L78-L84
|
25,039
|
gplcart/cli
|
controllers/commands/Role.php
|
Role.cmdDeleteRole
|
public function cmdDeleteRole()
{
$id = $this->getParam(0);
$all = $this->getParam('all');
if (!isset($id) && empty($all)) {
$this->errorAndExit($this->text('Invalid command'));
}
$result = false;
if (isset($id)) {
if (empty($id) || !is_numeric($id)) {
$this->errorAndExit($this->text('Invalid argument'));
}
$result = $this->role->delete($id);
} else if ($all) {
$deleted = $count = 0;
foreach ($this->role->getList() as $item) {
$count++;
$deleted += (int) $this->role->delete($item['role_id']);
}
$result = $count && $count == $deleted;
}
if (empty($result)) {
$this->errorAndExit($this->text('Unexpected result'));
}
$this->output();
}
|
php
|
public function cmdDeleteRole()
{
$id = $this->getParam(0);
$all = $this->getParam('all');
if (!isset($id) && empty($all)) {
$this->errorAndExit($this->text('Invalid command'));
}
$result = false;
if (isset($id)) {
if (empty($id) || !is_numeric($id)) {
$this->errorAndExit($this->text('Invalid argument'));
}
$result = $this->role->delete($id);
} else if ($all) {
$deleted = $count = 0;
foreach ($this->role->getList() as $item) {
$count++;
$deleted += (int) $this->role->delete($item['role_id']);
}
$result = $count && $count == $deleted;
}
if (empty($result)) {
$this->errorAndExit($this->text('Unexpected result'));
}
$this->output();
}
|
[
"public",
"function",
"cmdDeleteRole",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getParam",
"(",
"0",
")",
";",
"$",
"all",
"=",
"$",
"this",
"->",
"getParam",
"(",
"'all'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"id",
")",
"&&",
"empty",
"(",
"$",
"all",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid command'",
")",
")",
";",
"}",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"id",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
"||",
"!",
"is_numeric",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid argument'",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"role",
"->",
"delete",
"(",
"$",
"id",
")",
";",
"}",
"else",
"if",
"(",
"$",
"all",
")",
"{",
"$",
"deleted",
"=",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"role",
"->",
"getList",
"(",
")",
"as",
"$",
"item",
")",
"{",
"$",
"count",
"++",
";",
"$",
"deleted",
"+=",
"(",
"int",
")",
"$",
"this",
"->",
"role",
"->",
"delete",
"(",
"$",
"item",
"[",
"'role_id'",
"]",
")",
";",
"}",
"$",
"result",
"=",
"$",
"count",
"&&",
"$",
"count",
"==",
"$",
"deleted",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Unexpected result'",
")",
")",
";",
"}",
"$",
"this",
"->",
"output",
"(",
")",
";",
"}"
] |
Callback for "role-delete" command
|
[
"Callback",
"for",
"role",
"-",
"delete",
"command"
] |
e57dba53e291a225b4bff0c0d9b23d685dd1c125
|
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Role.php#L89-L124
|
25,040
|
gplcart/cli
|
controllers/commands/Role.php
|
Role.cmdUpdateRole
|
public function cmdUpdateRole()
{
$params = $this->getParam();
if (empty($params[0]) || count($params) < 2) {
$this->errorAndExit($this->text('Invalid command'));
}
if (!is_numeric($params[0])) {
$this->errorAndExit($this->text('Invalid argument'));
}
$this->setSubmitted(null, $params);
$this->setSubmittedList('permissions');
$this->setSubmitted('update', $params[0]);
$this->validateComponent('user_role');
$this->updateRole($params[0]);
$this->output();
}
|
php
|
public function cmdUpdateRole()
{
$params = $this->getParam();
if (empty($params[0]) || count($params) < 2) {
$this->errorAndExit($this->text('Invalid command'));
}
if (!is_numeric($params[0])) {
$this->errorAndExit($this->text('Invalid argument'));
}
$this->setSubmitted(null, $params);
$this->setSubmittedList('permissions');
$this->setSubmitted('update', $params[0]);
$this->validateComponent('user_role');
$this->updateRole($params[0]);
$this->output();
}
|
[
"public",
"function",
"cmdUpdateRole",
"(",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getParam",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"params",
"[",
"0",
"]",
")",
"||",
"count",
"(",
"$",
"params",
")",
"<",
"2",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid command'",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"params",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid argument'",
")",
")",
";",
"}",
"$",
"this",
"->",
"setSubmitted",
"(",
"null",
",",
"$",
"params",
")",
";",
"$",
"this",
"->",
"setSubmittedList",
"(",
"'permissions'",
")",
";",
"$",
"this",
"->",
"setSubmitted",
"(",
"'update'",
",",
"$",
"params",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"validateComponent",
"(",
"'user_role'",
")",
";",
"$",
"this",
"->",
"updateRole",
"(",
"$",
"params",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"output",
"(",
")",
";",
"}"
] |
Callback for "role-update" command
|
[
"Callback",
"for",
"role",
"-",
"update",
"command"
] |
e57dba53e291a225b4bff0c0d9b23d685dd1c125
|
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Role.php#L143-L163
|
25,041
|
gplcart/cli
|
controllers/commands/Role.php
|
Role.submitAddRole
|
protected function submitAddRole()
{
$this->setSubmitted(null, $this->getParam());
$this->setSubmittedList('permissions');
$this->validateComponent('user_role');
$this->addRole();
}
|
php
|
protected function submitAddRole()
{
$this->setSubmitted(null, $this->getParam());
$this->setSubmittedList('permissions');
$this->validateComponent('user_role');
$this->addRole();
}
|
[
"protected",
"function",
"submitAddRole",
"(",
")",
"{",
"$",
"this",
"->",
"setSubmitted",
"(",
"null",
",",
"$",
"this",
"->",
"getParam",
"(",
")",
")",
";",
"$",
"this",
"->",
"setSubmittedList",
"(",
"'permissions'",
")",
";",
"$",
"this",
"->",
"validateComponent",
"(",
"'user_role'",
")",
";",
"$",
"this",
"->",
"addRole",
"(",
")",
";",
"}"
] |
Add a new user role at once
|
[
"Add",
"a",
"new",
"user",
"role",
"at",
"once"
] |
e57dba53e291a225b4bff0c0d9b23d685dd1c125
|
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Role.php#L261-L267
|
25,042
|
gplcart/cli
|
controllers/commands/Role.php
|
Role.addRole
|
protected function addRole()
{
if (!$this->isError()) {
$id = $this->role->add($this->getSubmitted());
if (empty($id)) {
$this->errorAndExit($this->text('Unexpected result'));
}
$this->line($id);
}
}
|
php
|
protected function addRole()
{
if (!$this->isError()) {
$id = $this->role->add($this->getSubmitted());
if (empty($id)) {
$this->errorAndExit($this->text('Unexpected result'));
}
$this->line($id);
}
}
|
[
"protected",
"function",
"addRole",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isError",
"(",
")",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"role",
"->",
"add",
"(",
"$",
"this",
"->",
"getSubmitted",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Unexpected result'",
")",
")",
";",
"}",
"$",
"this",
"->",
"line",
"(",
"$",
"id",
")",
";",
"}",
"}"
] |
Add a new user role
|
[
"Add",
"a",
"new",
"user",
"role"
] |
e57dba53e291a225b4bff0c0d9b23d685dd1c125
|
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Role.php#L272-L281
|
25,043
|
gplcart/cli
|
controllers/commands/Role.php
|
Role.wizardAddRole
|
protected function wizardAddRole()
{
$this->validatePrompt('name', $this->text('Name'), 'user_role');
$this->validatePromptList('permissions', $this->text('Permissions'), 'user_role');
$this->validatePrompt('redirect', $this->text('Redirect'), 'user_role', '');
$this->validatePrompt('status', $this->text('Status'), 'user_role', 0);
$this->setSubmittedList('permissions');
$this->validateComponent('user_role');
$this->addRole();
}
|
php
|
protected function wizardAddRole()
{
$this->validatePrompt('name', $this->text('Name'), 'user_role');
$this->validatePromptList('permissions', $this->text('Permissions'), 'user_role');
$this->validatePrompt('redirect', $this->text('Redirect'), 'user_role', '');
$this->validatePrompt('status', $this->text('Status'), 'user_role', 0);
$this->setSubmittedList('permissions');
$this->validateComponent('user_role');
$this->addRole();
}
|
[
"protected",
"function",
"wizardAddRole",
"(",
")",
"{",
"$",
"this",
"->",
"validatePrompt",
"(",
"'name'",
",",
"$",
"this",
"->",
"text",
"(",
"'Name'",
")",
",",
"'user_role'",
")",
";",
"$",
"this",
"->",
"validatePromptList",
"(",
"'permissions'",
",",
"$",
"this",
"->",
"text",
"(",
"'Permissions'",
")",
",",
"'user_role'",
")",
";",
"$",
"this",
"->",
"validatePrompt",
"(",
"'redirect'",
",",
"$",
"this",
"->",
"text",
"(",
"'Redirect'",
")",
",",
"'user_role'",
",",
"''",
")",
";",
"$",
"this",
"->",
"validatePrompt",
"(",
"'status'",
",",
"$",
"this",
"->",
"text",
"(",
"'Status'",
")",
",",
"'user_role'",
",",
"0",
")",
";",
"$",
"this",
"->",
"setSubmittedList",
"(",
"'permissions'",
")",
";",
"$",
"this",
"->",
"validateComponent",
"(",
"'user_role'",
")",
";",
"$",
"this",
"->",
"addRole",
"(",
")",
";",
"}"
] |
Add a new user role step by step
|
[
"Add",
"a",
"new",
"user",
"role",
"step",
"by",
"step"
] |
e57dba53e291a225b4bff0c0d9b23d685dd1c125
|
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Role.php#L286-L296
|
25,044
|
mdzzohrabi/Azera-Queryable
|
Queryable.php
|
Queryable.All
|
public function All( $Func )
{
$result = true;
$Func = new Expression( $Func );
foreach ( $this->repository as $item )
$result &= $Func->execute( $item );
return (boolean)$result;
}
|
php
|
public function All( $Func )
{
$result = true;
$Func = new Expression( $Func );
foreach ( $this->repository as $item )
$result &= $Func->execute( $item );
return (boolean)$result;
}
|
[
"public",
"function",
"All",
"(",
"$",
"Func",
")",
"{",
"$",
"result",
"=",
"true",
";",
"$",
"Func",
"=",
"new",
"Expression",
"(",
"$",
"Func",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"repository",
"as",
"$",
"item",
")",
"$",
"result",
"&=",
"$",
"Func",
"->",
"execute",
"(",
"$",
"item",
")",
";",
"return",
"(",
"boolean",
")",
"$",
"result",
";",
"}"
] |
Retreive all items with or without condition
@param string|Closure $Func
@return bool
|
[
"Retreive",
"all",
"items",
"with",
"or",
"without",
"condition"
] |
6b85f335d33f8326c259e623b0c410396789f70b
|
https://github.com/mdzzohrabi/Azera-Queryable/blob/6b85f335d33f8326c259e623b0c410396789f70b/Queryable.php#L72-L84
|
25,045
|
mdzzohrabi/Azera-Queryable
|
Queryable.php
|
Queryable.Where
|
public function Where( $Func )
{
if ( $Func != null ){
$repo = array();
$Func = new Expression( $Func );
foreach ( $this->repository as $item )
if ( $Func->execute( $item ) )
$repo[] = $item;
} else {
$repo = $this->repository;
}
return $this->getClone()->setRepository( $repo );
}
|
php
|
public function Where( $Func )
{
if ( $Func != null ){
$repo = array();
$Func = new Expression( $Func );
foreach ( $this->repository as $item )
if ( $Func->execute( $item ) )
$repo[] = $item;
} else {
$repo = $this->repository;
}
return $this->getClone()->setRepository( $repo );
}
|
[
"public",
"function",
"Where",
"(",
"$",
"Func",
")",
"{",
"if",
"(",
"$",
"Func",
"!=",
"null",
")",
"{",
"$",
"repo",
"=",
"array",
"(",
")",
";",
"$",
"Func",
"=",
"new",
"Expression",
"(",
"$",
"Func",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"repository",
"as",
"$",
"item",
")",
"if",
"(",
"$",
"Func",
"->",
"execute",
"(",
"$",
"item",
")",
")",
"$",
"repo",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"else",
"{",
"$",
"repo",
"=",
"$",
"this",
"->",
"repository",
";",
"}",
"return",
"$",
"this",
"->",
"getClone",
"(",
")",
"->",
"setRepository",
"(",
"$",
"repo",
")",
";",
"}"
] |
Filters a sequence of values based on a predicate.
@param string|Closure $Func
@return Queryable
|
[
"Filters",
"a",
"sequence",
"of",
"values",
"based",
"on",
"a",
"predicate",
"."
] |
6b85f335d33f8326c259e623b0c410396789f70b
|
https://github.com/mdzzohrabi/Azera-Queryable/blob/6b85f335d33f8326c259e623b0c410396789f70b/Queryable.php#L92-L113
|
25,046
|
mdzzohrabi/Azera-Queryable
|
Queryable.php
|
Queryable.Any
|
public function Any( $Func )
{
$result = false;
$Func = new Expression( $Func );
foreach ( $this->repository as $item ) $result |= $Func->execute( $item );
return (boolean)$result;
}
|
php
|
public function Any( $Func )
{
$result = false;
$Func = new Expression( $Func );
foreach ( $this->repository as $item ) $result |= $Func->execute( $item );
return (boolean)$result;
}
|
[
"public",
"function",
"Any",
"(",
"$",
"Func",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"Func",
"=",
"new",
"Expression",
"(",
"$",
"Func",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"repository",
"as",
"$",
"item",
")",
"$",
"result",
"|=",
"$",
"Func",
"->",
"execute",
"(",
"$",
"item",
")",
";",
"return",
"(",
"boolean",
")",
"$",
"result",
";",
"}"
] |
Determines whether a sequence contains any elements.
@param string|Closure $Func
@return bool
|
[
"Determines",
"whether",
"a",
"sequence",
"contains",
"any",
"elements",
"."
] |
6b85f335d33f8326c259e623b0c410396789f70b
|
https://github.com/mdzzohrabi/Azera-Queryable/blob/6b85f335d33f8326c259e623b0c410396789f70b/Queryable.php#L121-L132
|
25,047
|
mdzzohrabi/Azera-Queryable
|
Queryable.php
|
Queryable.Count
|
public function Count( $Func = null )
{
return $Func ? $this->Where( $Func )->Count() : count( $this->repository );
}
|
php
|
public function Count( $Func = null )
{
return $Func ? $this->Where( $Func )->Count() : count( $this->repository );
}
|
[
"public",
"function",
"Count",
"(",
"$",
"Func",
"=",
"null",
")",
"{",
"return",
"$",
"Func",
"?",
"$",
"this",
"->",
"Where",
"(",
"$",
"Func",
")",
"->",
"Count",
"(",
")",
":",
"count",
"(",
"$",
"this",
"->",
"repository",
")",
";",
"}"
] |
Count repository with or without condition
@param string|Closure $Func
@return int
|
[
"Count",
"repository",
"with",
"or",
"without",
"condition"
] |
6b85f335d33f8326c259e623b0c410396789f70b
|
https://github.com/mdzzohrabi/Azera-Queryable/blob/6b85f335d33f8326c259e623b0c410396789f70b/Queryable.php#L140-L145
|
25,048
|
mdzzohrabi/Azera-Queryable
|
Queryable.php
|
Queryable.Average
|
public function Average( $Func = null )
{
$items = $this->Select( $Func );
$count = $items->Count();
$sum = 0;
foreach ( $items as $item ) $sum += $item;
return $sum / $count;
}
|
php
|
public function Average( $Func = null )
{
$items = $this->Select( $Func );
$count = $items->Count();
$sum = 0;
foreach ( $items as $item ) $sum += $item;
return $sum / $count;
}
|
[
"public",
"function",
"Average",
"(",
"$",
"Func",
"=",
"null",
")",
"{",
"$",
"items",
"=",
"$",
"this",
"->",
"Select",
"(",
"$",
"Func",
")",
";",
"$",
"count",
"=",
"$",
"items",
"->",
"Count",
"(",
")",
";",
"$",
"sum",
"=",
"0",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"$",
"sum",
"+=",
"$",
"item",
";",
"return",
"$",
"sum",
"/",
"$",
"count",
";",
"}"
] |
Get Average of sequence
@param string|Closure $Func
@return double
|
[
"Get",
"Average",
"of",
"sequence"
] |
6b85f335d33f8326c259e623b0c410396789f70b
|
https://github.com/mdzzohrabi/Azera-Queryable/blob/6b85f335d33f8326c259e623b0c410396789f70b/Queryable.php#L153-L166
|
25,049
|
mdzzohrabi/Azera-Queryable
|
Queryable.php
|
Queryable.Sum
|
public function Sum( $Func = null )
{
$items = $this->Select( $Func );
$sum = 0;
foreach ( $items as $item ) $sum += $item;
return $sum;
}
|
php
|
public function Sum( $Func = null )
{
$items = $this->Select( $Func );
$sum = 0;
foreach ( $items as $item ) $sum += $item;
return $sum;
}
|
[
"public",
"function",
"Sum",
"(",
"$",
"Func",
"=",
"null",
")",
"{",
"$",
"items",
"=",
"$",
"this",
"->",
"Select",
"(",
"$",
"Func",
")",
";",
"$",
"sum",
"=",
"0",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"$",
"sum",
"+=",
"$",
"item",
";",
"return",
"$",
"sum",
";",
"}"
] |
Get sum of sequence
@param string|Closure $Func
@return double
|
[
"Get",
"sum",
"of",
"sequence"
] |
6b85f335d33f8326c259e623b0c410396789f70b
|
https://github.com/mdzzohrabi/Azera-Queryable/blob/6b85f335d33f8326c259e623b0c410396789f70b/Queryable.php#L174-L182
|
25,050
|
mdzzohrabi/Azera-Queryable
|
Queryable.php
|
Queryable.Concat
|
public function Concat( $source )
{
$source = is_array($source) ? $source : ( $source instanceof Queryable ? $source->toList() : iterator_to_array($source) );
return $this
->getClone()
->setRepository( array_merge( $this->repository , $source ) );
}
|
php
|
public function Concat( $source )
{
$source = is_array($source) ? $source : ( $source instanceof Queryable ? $source->toList() : iterator_to_array($source) );
return $this
->getClone()
->setRepository( array_merge( $this->repository , $source ) );
}
|
[
"public",
"function",
"Concat",
"(",
"$",
"source",
")",
"{",
"$",
"source",
"=",
"is_array",
"(",
"$",
"source",
")",
"?",
"$",
"source",
":",
"(",
"$",
"source",
"instanceof",
"Queryable",
"?",
"$",
"source",
"->",
"toList",
"(",
")",
":",
"iterator_to_array",
"(",
"$",
"source",
")",
")",
";",
"return",
"$",
"this",
"->",
"getClone",
"(",
")",
"->",
"setRepository",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"repository",
",",
"$",
"source",
")",
")",
";",
"}"
] |
Concatenates two sequences.
@param array|Queryable|Traversable $source
@return Queryable
|
[
"Concatenates",
"two",
"sequences",
"."
] |
6b85f335d33f8326c259e623b0c410396789f70b
|
https://github.com/mdzzohrabi/Azera-Queryable/blob/6b85f335d33f8326c259e623b0c410396789f70b/Queryable.php#L201-L210
|
25,051
|
mdzzohrabi/Azera-Queryable
|
Queryable.php
|
Queryable.Except
|
public function Except( $items )
{
return $this
->getClone()
->setRepository( array_diff( $this->repository , $items instanceof Queryable ? $items->toArray() : $items ) );
}
|
php
|
public function Except( $items )
{
return $this
->getClone()
->setRepository( array_diff( $this->repository , $items instanceof Queryable ? $items->toArray() : $items ) );
}
|
[
"public",
"function",
"Except",
"(",
"$",
"items",
")",
"{",
"return",
"$",
"this",
"->",
"getClone",
"(",
")",
"->",
"setRepository",
"(",
"array_diff",
"(",
"$",
"this",
"->",
"repository",
",",
"$",
"items",
"instanceof",
"Queryable",
"?",
"$",
"items",
"->",
"toArray",
"(",
")",
":",
"$",
"items",
")",
")",
";",
"}"
] |
Produces the set difference of two sequences by using the default equality comparer to compare values.
@param array|Queryable $items Items
@return Queryable
|
[
"Produces",
"the",
"set",
"difference",
"of",
"two",
"sequences",
"by",
"using",
"the",
"default",
"equality",
"comparer",
"to",
"compare",
"values",
"."
] |
6b85f335d33f8326c259e623b0c410396789f70b
|
https://github.com/mdzzohrabi/Azera-Queryable/blob/6b85f335d33f8326c259e623b0c410396789f70b/Queryable.php#L232-L239
|
25,052
|
mdzzohrabi/Azera-Queryable
|
Queryable.php
|
Queryable.First
|
public function First( $Func = null , $default = null )
{
$bag = $Func ? $this->Select($Func) : $this->repository;
return current($bag) ?: $default;
}
|
php
|
public function First( $Func = null , $default = null )
{
$bag = $Func ? $this->Select($Func) : $this->repository;
return current($bag) ?: $default;
}
|
[
"public",
"function",
"First",
"(",
"$",
"Func",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"bag",
"=",
"$",
"Func",
"?",
"$",
"this",
"->",
"Select",
"(",
"$",
"Func",
")",
":",
"$",
"this",
"->",
"repository",
";",
"return",
"current",
"(",
"$",
"bag",
")",
"?",
":",
"$",
"default",
";",
"}"
] |
Get first element of sequence with or without condition
@param string|Closure $Func Condition
@param null $default
@return mixed
@internal param mixed $defaul Default
|
[
"Get",
"first",
"element",
"of",
"sequence",
"with",
"or",
"without",
"condition"
] |
6b85f335d33f8326c259e623b0c410396789f70b
|
https://github.com/mdzzohrabi/Azera-Queryable/blob/6b85f335d33f8326c259e623b0c410396789f70b/Queryable.php#L249-L253
|
25,053
|
mdzzohrabi/Azera-Queryable
|
Queryable.php
|
Queryable.SelectKeyValue
|
public function SelectKeyValue( $Key , $Value ) {
$Key = new Expression( $Key );
$Value = new Expression( $Value );
$items = array();
foreach ( $this->repository as $item ) {
$_k = $Key->execute( $item );
$_v = $Value->execute( $item );
$items[$_k] = $_v;
}
return new Queryable( $items );
}
|
php
|
public function SelectKeyValue( $Key , $Value ) {
$Key = new Expression( $Key );
$Value = new Expression( $Value );
$items = array();
foreach ( $this->repository as $item ) {
$_k = $Key->execute( $item );
$_v = $Value->execute( $item );
$items[$_k] = $_v;
}
return new Queryable( $items );
}
|
[
"public",
"function",
"SelectKeyValue",
"(",
"$",
"Key",
",",
"$",
"Value",
")",
"{",
"$",
"Key",
"=",
"new",
"Expression",
"(",
"$",
"Key",
")",
";",
"$",
"Value",
"=",
"new",
"Expression",
"(",
"$",
"Value",
")",
";",
"$",
"items",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"repository",
"as",
"$",
"item",
")",
"{",
"$",
"_k",
"=",
"$",
"Key",
"->",
"execute",
"(",
"$",
"item",
")",
";",
"$",
"_v",
"=",
"$",
"Value",
"->",
"execute",
"(",
"$",
"item",
")",
";",
"$",
"items",
"[",
"$",
"_k",
"]",
"=",
"$",
"_v",
";",
"}",
"return",
"new",
"Queryable",
"(",
"$",
"items",
")",
";",
"}"
] |
Select key value
@param Closure $Key
@param Closure $Value
@return Queryable
|
[
"Select",
"key",
"value"
] |
6b85f335d33f8326c259e623b0c410396789f70b
|
https://github.com/mdzzohrabi/Azera-Queryable/blob/6b85f335d33f8326c259e623b0c410396789f70b/Queryable.php#L328-L343
|
25,054
|
mdzzohrabi/Azera-Queryable
|
Queryable.php
|
Queryable.Intersect
|
public function Intersect( $items )
{
return $this
->getClone()
->setRepository( array_intersect( $this->repository , $items instanceof Queryable ? $items->toArray() : $items ) );
}
|
php
|
public function Intersect( $items )
{
return $this
->getClone()
->setRepository( array_intersect( $this->repository , $items instanceof Queryable ? $items->toArray() : $items ) );
}
|
[
"public",
"function",
"Intersect",
"(",
"$",
"items",
")",
"{",
"return",
"$",
"this",
"->",
"getClone",
"(",
")",
"->",
"setRepository",
"(",
"array_intersect",
"(",
"$",
"this",
"->",
"repository",
",",
"$",
"items",
"instanceof",
"Queryable",
"?",
"$",
"items",
"->",
"toArray",
"(",
")",
":",
"$",
"items",
")",
")",
";",
"}"
] |
Get Intersect of two sequence
@param array|Queryable $items
@return Queryable
|
[
"Get",
"Intersect",
"of",
"two",
"sequence"
] |
6b85f335d33f8326c259e623b0c410396789f70b
|
https://github.com/mdzzohrabi/Azera-Queryable/blob/6b85f335d33f8326c259e623b0c410396789f70b/Queryable.php#L367-L374
|
25,055
|
mdzzohrabi/Azera-Queryable
|
Queryable.php
|
Queryable.Cast
|
public function Cast( $type )
{
$obj = $this->getClone();
foreach ($obj->repository as &$value) {
settype($value, $type);
}
return $obj;
}
|
php
|
public function Cast( $type )
{
$obj = $this->getClone();
foreach ($obj->repository as &$value) {
settype($value, $type);
}
return $obj;
}
|
[
"public",
"function",
"Cast",
"(",
"$",
"type",
")",
"{",
"$",
"obj",
"=",
"$",
"this",
"->",
"getClone",
"(",
")",
";",
"foreach",
"(",
"$",
"obj",
"->",
"repository",
"as",
"&",
"$",
"value",
")",
"{",
"settype",
"(",
"$",
"value",
",",
"$",
"type",
")",
";",
"}",
"return",
"$",
"obj",
";",
"}"
] |
Casts the elements to the specified type.
@param string $type Type
@return Queryable
|
[
"Casts",
"the",
"elements",
"to",
"the",
"specified",
"type",
"."
] |
6b85f335d33f8326c259e623b0c410396789f70b
|
https://github.com/mdzzohrabi/Azera-Queryable/blob/6b85f335d33f8326c259e623b0c410396789f70b/Queryable.php#L382-L393
|
25,056
|
mdzzohrabi/Azera-Queryable
|
Queryable.php
|
Queryable.Sort
|
public function Sort( $Func = null )
{
$sorted = $this->repository;
$Func = new Expression( $Func );
usort( $sorted , [ $Func , 'execute' ] );
return $this
->getClone()
->setRepository( $sorted );
}
|
php
|
public function Sort( $Func = null )
{
$sorted = $this->repository;
$Func = new Expression( $Func );
usort( $sorted , [ $Func , 'execute' ] );
return $this
->getClone()
->setRepository( $sorted );
}
|
[
"public",
"function",
"Sort",
"(",
"$",
"Func",
"=",
"null",
")",
"{",
"$",
"sorted",
"=",
"$",
"this",
"->",
"repository",
";",
"$",
"Func",
"=",
"new",
"Expression",
"(",
"$",
"Func",
")",
";",
"usort",
"(",
"$",
"sorted",
",",
"[",
"$",
"Func",
",",
"'execute'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"getClone",
"(",
")",
"->",
"setRepository",
"(",
"$",
"sorted",
")",
";",
"}"
] |
Sort sequence by given comparator
@param Expression $Func Comparator
@return Queryable
|
[
"Sort",
"sequence",
"by",
"given",
"comparator"
] |
6b85f335d33f8326c259e623b0c410396789f70b
|
https://github.com/mdzzohrabi/Azera-Queryable/blob/6b85f335d33f8326c259e623b0c410396789f70b/Queryable.php#L553-L564
|
25,057
|
vpg/titon.utility
|
src/Titon/Utility/Str.php
|
Str.compare
|
public static function compare($string, $value, $length = 0) {
$string = (string) $string;
$value = (string) $value;
if ($length > 0) {
return strncasecmp($string, $value, $length);
}
return strcasecmp($string, $value);
}
|
php
|
public static function compare($string, $value, $length = 0) {
$string = (string) $string;
$value = (string) $value;
if ($length > 0) {
return strncasecmp($string, $value, $length);
}
return strcasecmp($string, $value);
}
|
[
"public",
"static",
"function",
"compare",
"(",
"$",
"string",
",",
"$",
"value",
",",
"$",
"length",
"=",
"0",
")",
"{",
"$",
"string",
"=",
"(",
"string",
")",
"$",
"string",
";",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"if",
"(",
"$",
"length",
">",
"0",
")",
"{",
"return",
"strncasecmp",
"(",
"$",
"string",
",",
"$",
"value",
",",
"$",
"length",
")",
";",
"}",
"return",
"strcasecmp",
"(",
"$",
"string",
",",
"$",
"value",
")",
";",
"}"
] |
Compares to strings alphabetically. Returns 0 if they are equal, negative if passed value is greater, or positive if current value is greater.
@param string $string
@param string $value
@param int $length
@return int
|
[
"Compares",
"to",
"strings",
"alphabetically",
".",
"Returns",
"0",
"if",
"they",
"are",
"equal",
"negative",
"if",
"passed",
"value",
"is",
"greater",
"or",
"positive",
"if",
"current",
"value",
"is",
"greater",
"."
] |
8a77eb9e7b8baacf41cc25487289779d8319cd3a
|
https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Str.php#L49-L58
|
25,058
|
vpg/titon.utility
|
src/Titon/Utility/Str.php
|
Str.contains
|
public static function contains($string, $needle, $strict = true, $offset = 0) {
return (static::indexOf($string, $needle, $strict, $offset) !== false);
}
|
php
|
public static function contains($string, $needle, $strict = true, $offset = 0) {
return (static::indexOf($string, $needle, $strict, $offset) !== false);
}
|
[
"public",
"static",
"function",
"contains",
"(",
"$",
"string",
",",
"$",
"needle",
",",
"$",
"strict",
"=",
"true",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"return",
"(",
"static",
"::",
"indexOf",
"(",
"$",
"string",
",",
"$",
"needle",
",",
"$",
"strict",
",",
"$",
"offset",
")",
"!==",
"false",
")",
";",
"}"
] |
Check to see if a string exists within this string.
@param string $string
@param string $needle
@param bool $strict
@param int $offset
@return bool
|
[
"Check",
"to",
"see",
"if",
"a",
"string",
"exists",
"within",
"this",
"string",
"."
] |
8a77eb9e7b8baacf41cc25487289779d8319cd3a
|
https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Str.php#L69-L71
|
25,059
|
vpg/titon.utility
|
src/Titon/Utility/Str.php
|
Str.endsWith
|
public static function endsWith($string, $needle, $strict = true) {
$end = static::extract($string, -mb_strlen($needle));
if ($strict) {
return ($end === $needle);
}
return (mb_strtolower($end) === mb_strtolower($needle));
}
|
php
|
public static function endsWith($string, $needle, $strict = true) {
$end = static::extract($string, -mb_strlen($needle));
if ($strict) {
return ($end === $needle);
}
return (mb_strtolower($end) === mb_strtolower($needle));
}
|
[
"public",
"static",
"function",
"endsWith",
"(",
"$",
"string",
",",
"$",
"needle",
",",
"$",
"strict",
"=",
"true",
")",
"{",
"$",
"end",
"=",
"static",
"::",
"extract",
"(",
"$",
"string",
",",
"-",
"mb_strlen",
"(",
"$",
"needle",
")",
")",
";",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"(",
"$",
"end",
"===",
"$",
"needle",
")",
";",
"}",
"return",
"(",
"mb_strtolower",
"(",
"$",
"end",
")",
"===",
"mb_strtolower",
"(",
"$",
"needle",
")",
")",
";",
"}"
] |
Checks to see if the string ends with a specific value.
@param string $string
@param string $needle
@param bool $strict
@return bool
|
[
"Checks",
"to",
"see",
"if",
"the",
"string",
"ends",
"with",
"a",
"specific",
"value",
"."
] |
8a77eb9e7b8baacf41cc25487289779d8319cd3a
|
https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Str.php#L81-L89
|
25,060
|
vpg/titon.utility
|
src/Titon/Utility/Str.php
|
Str.extract
|
public static function extract($string, $offset, $length = null) {
if ($length) {
return mb_substr($string, $offset, $length);
}
return mb_substr($string, $offset);
}
|
php
|
public static function extract($string, $offset, $length = null) {
if ($length) {
return mb_substr($string, $offset, $length);
}
return mb_substr($string, $offset);
}
|
[
"public",
"static",
"function",
"extract",
"(",
"$",
"string",
",",
"$",
"offset",
",",
"$",
"length",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"length",
")",
"{",
"return",
"mb_substr",
"(",
"$",
"string",
",",
"$",
"offset",
",",
"$",
"length",
")",
";",
"}",
"return",
"mb_substr",
"(",
"$",
"string",
",",
"$",
"offset",
")",
";",
"}"
] |
Extracts a portion of a string.
@param string $string
@param int $offset
@param int $length
@return string
|
[
"Extracts",
"a",
"portion",
"of",
"a",
"string",
"."
] |
8a77eb9e7b8baacf41cc25487289779d8319cd3a
|
https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Str.php#L99-L105
|
25,061
|
vpg/titon.utility
|
src/Titon/Utility/Str.php
|
Str.indexOf
|
public static function indexOf($string, $needle, $strict = true, $offset = 0) {
if ($strict) {
return mb_strpos($string, $needle, $offset);
}
return mb_stripos($string, $needle, $offset);
}
|
php
|
public static function indexOf($string, $needle, $strict = true, $offset = 0) {
if ($strict) {
return mb_strpos($string, $needle, $offset);
}
return mb_stripos($string, $needle, $offset);
}
|
[
"public",
"static",
"function",
"indexOf",
"(",
"$",
"string",
",",
"$",
"needle",
",",
"$",
"strict",
"=",
"true",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"mb_strpos",
"(",
"$",
"string",
",",
"$",
"needle",
",",
"$",
"offset",
")",
";",
"}",
"return",
"mb_stripos",
"(",
"$",
"string",
",",
"$",
"needle",
",",
"$",
"offset",
")",
";",
"}"
] |
Grab the index of the first matched character.
@param string $string
@param string $needle
@param bool $strict
@param int $offset
@return int
|
[
"Grab",
"the",
"index",
"of",
"the",
"first",
"matched",
"character",
"."
] |
8a77eb9e7b8baacf41cc25487289779d8319cd3a
|
https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Str.php#L135-L141
|
25,062
|
vpg/titon.utility
|
src/Titon/Utility/Str.php
|
Str.insert
|
public static function insert($string, array $data, array $options = array()) {
$options = $options + array(
'before' => '{',
'after' => '}',
'escape' => true
);
foreach ($data as $key => $value) {
$string = str_replace($options['before'] . $key . $options['after'], $value, $string);
}
if ($options['escape']) {
$string = Sanitize::escape($string);
}
return $string;
}
|
php
|
public static function insert($string, array $data, array $options = array()) {
$options = $options + array(
'before' => '{',
'after' => '}',
'escape' => true
);
foreach ($data as $key => $value) {
$string = str_replace($options['before'] . $key . $options['after'], $value, $string);
}
if ($options['escape']) {
$string = Sanitize::escape($string);
}
return $string;
}
|
[
"public",
"static",
"function",
"insert",
"(",
"$",
"string",
",",
"array",
"$",
"data",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"$",
"options",
"+",
"array",
"(",
"'before'",
"=>",
"'{'",
",",
"'after'",
"=>",
"'}'",
",",
"'escape'",
"=>",
"true",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"$",
"options",
"[",
"'before'",
"]",
".",
"$",
"key",
".",
"$",
"options",
"[",
"'after'",
"]",
",",
"$",
"value",
",",
"$",
"string",
")",
";",
"}",
"if",
"(",
"$",
"options",
"[",
"'escape'",
"]",
")",
"{",
"$",
"string",
"=",
"Sanitize",
"::",
"escape",
"(",
"$",
"string",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
] |
Insert values into a string defined by an array of key tokens.
@uses Titon\Utility\Sanitize
@param string $string
@param array $data
@param array $options {
@type string $before Opening variable delimiter
@type string $after Closing variable delimiter
@type bool $escape Escape the string
}
@return string
|
[
"Insert",
"values",
"into",
"a",
"string",
"defined",
"by",
"an",
"array",
"of",
"key",
"tokens",
"."
] |
8a77eb9e7b8baacf41cc25487289779d8319cd3a
|
https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Str.php#L157-L173
|
25,063
|
vpg/titon.utility
|
src/Titon/Utility/Str.php
|
Str.lastIndexOf
|
public static function lastIndexOf($string, $needle, $strict = true, $offset = 0) {
if ($strict) {
return mb_strrpos($string, $needle, $offset);
}
return mb_strripos($string, $needle, $offset);
}
|
php
|
public static function lastIndexOf($string, $needle, $strict = true, $offset = 0) {
if ($strict) {
return mb_strrpos($string, $needle, $offset);
}
return mb_strripos($string, $needle, $offset);
}
|
[
"public",
"static",
"function",
"lastIndexOf",
"(",
"$",
"string",
",",
"$",
"needle",
",",
"$",
"strict",
"=",
"true",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"mb_strrpos",
"(",
"$",
"string",
",",
"$",
"needle",
",",
"$",
"offset",
")",
";",
"}",
"return",
"mb_strripos",
"(",
"$",
"string",
",",
"$",
"needle",
",",
"$",
"offset",
")",
";",
"}"
] |
Grab the index of the last matched character.
@param string $string
@param string $needle
@param bool $strict
@param int $offset
@return int
|
[
"Grab",
"the",
"index",
"of",
"the",
"last",
"matched",
"character",
"."
] |
8a77eb9e7b8baacf41cc25487289779d8319cd3a
|
https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Str.php#L184-L190
|
25,064
|
vpg/titon.utility
|
src/Titon/Utility/Str.php
|
Str.listing
|
public static function listing($items, $glue = ' & ', $sep = ', ') {
if (is_array($items)) {
$lastItem = array_pop($items);
if (count($items) === 0) {
return $lastItem;
}
$items = implode($sep, $items);
$items = $items . $glue . $lastItem;
}
return $items;
}
|
php
|
public static function listing($items, $glue = ' & ', $sep = ', ') {
if (is_array($items)) {
$lastItem = array_pop($items);
if (count($items) === 0) {
return $lastItem;
}
$items = implode($sep, $items);
$items = $items . $glue . $lastItem;
}
return $items;
}
|
[
"public",
"static",
"function",
"listing",
"(",
"$",
"items",
",",
"$",
"glue",
"=",
"' & '",
",",
"$",
"sep",
"=",
"', '",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"items",
")",
")",
"{",
"$",
"lastItem",
"=",
"array_pop",
"(",
"$",
"items",
")",
";",
"if",
"(",
"count",
"(",
"$",
"items",
")",
"===",
"0",
")",
"{",
"return",
"$",
"lastItem",
";",
"}",
"$",
"items",
"=",
"implode",
"(",
"$",
"sep",
",",
"$",
"items",
")",
";",
"$",
"items",
"=",
"$",
"items",
".",
"$",
"glue",
".",
"$",
"lastItem",
";",
"}",
"return",
"$",
"items",
";",
"}"
] |
Creates a comma separated list with the last item having an ampersand prefixing it.
@param array $items
@param string $glue
@param string $sep
@return string
|
[
"Creates",
"a",
"comma",
"separated",
"list",
"with",
"the",
"last",
"item",
"having",
"an",
"ampersand",
"prefixing",
"it",
"."
] |
8a77eb9e7b8baacf41cc25487289779d8319cd3a
|
https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Str.php#L200-L213
|
25,065
|
vpg/titon.utility
|
src/Titon/Utility/Str.php
|
Str.shorten
|
public static function shorten($string, $limit = 25, $glue = ' … ') {
if (mb_strlen($string) > $limit) {
$width = round($limit / 2);
// prefix
$pre = mb_substr($string, 0, $width);
if (mb_substr($pre, -1) !== ' ' && ($i = static::lastIndexOf($pre, ' '))) {
$pre = mb_substr($pre, 0, $i);
}
// suffix
$suf = mb_substr($string, -$width);
if (mb_substr($suf, 0, 1) !== ' ' && ($i = static::indexOf($suf, ' '))) {
$suf = mb_substr($suf, $i);
}
return trim($pre) . $glue . trim($suf);
}
return $string;
}
|
php
|
public static function shorten($string, $limit = 25, $glue = ' … ') {
if (mb_strlen($string) > $limit) {
$width = round($limit / 2);
// prefix
$pre = mb_substr($string, 0, $width);
if (mb_substr($pre, -1) !== ' ' && ($i = static::lastIndexOf($pre, ' '))) {
$pre = mb_substr($pre, 0, $i);
}
// suffix
$suf = mb_substr($string, -$width);
if (mb_substr($suf, 0, 1) !== ' ' && ($i = static::indexOf($suf, ' '))) {
$suf = mb_substr($suf, $i);
}
return trim($pre) . $glue . trim($suf);
}
return $string;
}
|
[
"public",
"static",
"function",
"shorten",
"(",
"$",
"string",
",",
"$",
"limit",
"=",
"25",
",",
"$",
"glue",
"=",
"' … '",
")",
"{",
"if",
"(",
"mb_strlen",
"(",
"$",
"string",
")",
">",
"$",
"limit",
")",
"{",
"$",
"width",
"=",
"round",
"(",
"$",
"limit",
"/",
"2",
")",
";",
"// prefix",
"$",
"pre",
"=",
"mb_substr",
"(",
"$",
"string",
",",
"0",
",",
"$",
"width",
")",
";",
"if",
"(",
"mb_substr",
"(",
"$",
"pre",
",",
"-",
"1",
")",
"!==",
"' '",
"&&",
"(",
"$",
"i",
"=",
"static",
"::",
"lastIndexOf",
"(",
"$",
"pre",
",",
"' '",
")",
")",
")",
"{",
"$",
"pre",
"=",
"mb_substr",
"(",
"$",
"pre",
",",
"0",
",",
"$",
"i",
")",
";",
"}",
"// suffix",
"$",
"suf",
"=",
"mb_substr",
"(",
"$",
"string",
",",
"-",
"$",
"width",
")",
";",
"if",
"(",
"mb_substr",
"(",
"$",
"suf",
",",
"0",
",",
"1",
")",
"!==",
"' '",
"&&",
"(",
"$",
"i",
"=",
"static",
"::",
"indexOf",
"(",
"$",
"suf",
",",
"' '",
")",
")",
")",
"{",
"$",
"suf",
"=",
"mb_substr",
"(",
"$",
"suf",
",",
"$",
"i",
")",
";",
"}",
"return",
"trim",
"(",
"$",
"pre",
")",
".",
"$",
"glue",
".",
"trim",
"(",
"$",
"suf",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
] |
If a string is too long, shorten it in the middle while also respecting whitespace and preserving words.
@param string $string
@param int $limit
@param string $glue
@return string
|
[
"If",
"a",
"string",
"is",
"too",
"long",
"shorten",
"it",
"in",
"the",
"middle",
"while",
"also",
"respecting",
"whitespace",
"and",
"preserving",
"words",
"."
] |
8a77eb9e7b8baacf41cc25487289779d8319cd3a
|
https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Str.php#L223-L245
|
25,066
|
vpg/titon.utility
|
src/Titon/Utility/Str.php
|
Str.startsWith
|
public static function startsWith($string, $needle, $strict = true) {
$start = static::extract($string, 0, mb_strlen($needle));
if ($strict) {
return ($start === $needle);
}
return (mb_strtolower($start) === mb_strtolower($needle));
}
|
php
|
public static function startsWith($string, $needle, $strict = true) {
$start = static::extract($string, 0, mb_strlen($needle));
if ($strict) {
return ($start === $needle);
}
return (mb_strtolower($start) === mb_strtolower($needle));
}
|
[
"public",
"static",
"function",
"startsWith",
"(",
"$",
"string",
",",
"$",
"needle",
",",
"$",
"strict",
"=",
"true",
")",
"{",
"$",
"start",
"=",
"static",
"::",
"extract",
"(",
"$",
"string",
",",
"0",
",",
"mb_strlen",
"(",
"$",
"needle",
")",
")",
";",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"(",
"$",
"start",
"===",
"$",
"needle",
")",
";",
"}",
"return",
"(",
"mb_strtolower",
"(",
"$",
"start",
")",
"===",
"mb_strtolower",
"(",
"$",
"needle",
")",
")",
";",
"}"
] |
Checks to see if the string starts with a specific value.
@param string $string
@param string $needle
@param bool $strict
@return bool
|
[
"Checks",
"to",
"see",
"if",
"the",
"string",
"starts",
"with",
"a",
"specific",
"value",
"."
] |
8a77eb9e7b8baacf41cc25487289779d8319cd3a
|
https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Str.php#L255-L263
|
25,067
|
agentmedia/phine-core
|
src/Core/Logic/Module/BackendForm.php
|
BackendForm.AddRichTextField
|
protected function AddRichTextField($name, $value = '')
{
$renderer = new CKEditorRenderer(PathUtil::BackendRTEPath(), PathUtil::BackendRTEUrl(),
PathUtil::UploadPath(), PathUtil::UploadUrl(), self::Guard());
$field = new Custom($renderer);
$field->SetName($name);
$field->SetValue($value);
$this->AddField($field);
return $field;
}
|
php
|
protected function AddRichTextField($name, $value = '')
{
$renderer = new CKEditorRenderer(PathUtil::BackendRTEPath(), PathUtil::BackendRTEUrl(),
PathUtil::UploadPath(), PathUtil::UploadUrl(), self::Guard());
$field = new Custom($renderer);
$field->SetName($name);
$field->SetValue($value);
$this->AddField($field);
return $field;
}
|
[
"protected",
"function",
"AddRichTextField",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"''",
")",
"{",
"$",
"renderer",
"=",
"new",
"CKEditorRenderer",
"(",
"PathUtil",
"::",
"BackendRTEPath",
"(",
")",
",",
"PathUtil",
"::",
"BackendRTEUrl",
"(",
")",
",",
"PathUtil",
"::",
"UploadPath",
"(",
")",
",",
"PathUtil",
"::",
"UploadUrl",
"(",
")",
",",
"self",
"::",
"Guard",
"(",
")",
")",
";",
"$",
"field",
"=",
"new",
"Custom",
"(",
"$",
"renderer",
")",
";",
"$",
"field",
"->",
"SetName",
"(",
"$",
"name",
")",
";",
"$",
"field",
"->",
"SetValue",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"AddField",
"(",
"$",
"field",
")",
";",
"return",
"$",
"field",
";",
"}"
] |
Adds a field with the default rich text editor
@param string $name The field name
@param string $value The field value
@return Custom Returns the custom field containing the RT Editor
|
[
"Adds",
"a",
"field",
"with",
"the",
"default",
"rich",
"text",
"editor"
] |
38c1be8d03ebffae950d00a96da3c612aff67832
|
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Module/BackendForm.php#L16-L25
|
25,068
|
freialib/hlin.archetype
|
src/Trait/Context.php
|
ContextTrait.addpath
|
function addpath($name, $fspath, $overwrite = false) {
if ( ! $overwrite && isset($this->registeredpaths[$name])) {
throw new Panic("A path is already registered for $name.");
}
else { // path is not registered yet or overwrite == true
$this->registeredpaths[$name] = $fspath;
}
}
|
php
|
function addpath($name, $fspath, $overwrite = false) {
if ( ! $overwrite && isset($this->registeredpaths[$name])) {
throw new Panic("A path is already registered for $name.");
}
else { // path is not registered yet or overwrite == true
$this->registeredpaths[$name] = $fspath;
}
}
|
[
"function",
"addpath",
"(",
"$",
"name",
",",
"$",
"fspath",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"overwrite",
"&&",
"isset",
"(",
"$",
"this",
"->",
"registeredpaths",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"Panic",
"(",
"\"A path is already registered for $name.\"",
")",
";",
"}",
"else",
"{",
"// path is not registered yet or overwrite == true",
"$",
"this",
"->",
"registeredpaths",
"[",
"$",
"name",
"]",
"=",
"$",
"fspath",
";",
"}",
"}"
] |
Registers a path under a specified name.
If the path is already registered the method will Panic unless the 3rd
parameter is passed.
|
[
"Registers",
"a",
"path",
"under",
"a",
"specified",
"name",
"."
] |
d8750a9bf4b7efb8063899969e3f39c1915c423a
|
https://github.com/freialib/hlin.archetype/blob/d8750a9bf4b7efb8063899969e3f39c1915c423a/src/Trait/Context.php#L96-L103
|
25,069
|
freialib/hlin.archetype
|
src/Trait/Context.php
|
ContextTrait.path
|
function path($name, $null_on_failure = false) {
if ( ! isset($this->registeredpaths[$name])) {
if ($null_on_failure) {
return null;
}
else { // panic
throw new Panic("There is no path registered for $name.");
}
}
else { //
return $this->registeredpaths[$name];
}
}
|
php
|
function path($name, $null_on_failure = false) {
if ( ! isset($this->registeredpaths[$name])) {
if ($null_on_failure) {
return null;
}
else { // panic
throw new Panic("There is no path registered for $name.");
}
}
else { //
return $this->registeredpaths[$name];
}
}
|
[
"function",
"path",
"(",
"$",
"name",
",",
"$",
"null_on_failure",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"registeredpaths",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"$",
"null_on_failure",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"// panic",
"throw",
"new",
"Panic",
"(",
"\"There is no path registered for $name.\"",
")",
";",
"}",
"}",
"else",
"{",
"//",
"return",
"$",
"this",
"->",
"registeredpaths",
"[",
"$",
"name",
"]",
";",
"}",
"}"
] |
Retrieves the specified path. If the path is not registered the method
will Panic, unless the second parameter is set, in which case it will
just return null.
@return string|null
|
[
"Retrieves",
"the",
"specified",
"path",
".",
"If",
"the",
"path",
"is",
"not",
"registered",
"the",
"method",
"will",
"Panic",
"unless",
"the",
"second",
"parameter",
"is",
"set",
"in",
"which",
"case",
"it",
"will",
"just",
"return",
"null",
"."
] |
d8750a9bf4b7efb8063899969e3f39c1915c423a
|
https://github.com/freialib/hlin.archetype/blob/d8750a9bf4b7efb8063899969e3f39c1915c423a/src/Trait/Context.php#L112-L124
|
25,070
|
TiMESPLiNTER/tsfw-db
|
lib/timesplinter/tsfw/db/DB.php
|
DB.addListener
|
public function addListener(DBListener $listener, $name = null)
{
if($name !== null)
$this->listeners->offsetSet($name, $listener);
else
$this->listeners->append($listener);
}
|
php
|
public function addListener(DBListener $listener, $name = null)
{
if($name !== null)
$this->listeners->offsetSet($name, $listener);
else
$this->listeners->append($listener);
}
|
[
"public",
"function",
"addListener",
"(",
"DBListener",
"$",
"listener",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"!==",
"null",
")",
"$",
"this",
"->",
"listeners",
"->",
"offsetSet",
"(",
"$",
"name",
",",
"$",
"listener",
")",
";",
"else",
"$",
"this",
"->",
"listeners",
"->",
"append",
"(",
"$",
"listener",
")",
";",
"}"
] |
Adds a DBListener to listen on some events of the DB class
@param DBListener $listener The listener object to register
@param string $name The name of the listener [optional]
|
[
"Adds",
"a",
"DBListener",
"to",
"listen",
"on",
"some",
"events",
"of",
"the",
"DB",
"class"
] |
d897d3d3a3d761a0f4fc9aa20426429d0aad1d92
|
https://github.com/TiMESPLiNTER/tsfw-db/blob/d897d3d3a3d761a0f4fc9aa20426429d0aad1d92/lib/timesplinter/tsfw/db/DB.php#L142-L148
|
25,071
|
TiMESPLiNTER/tsfw-db
|
lib/timesplinter/tsfw/db/DB.php
|
DB.triggerListeners
|
protected function triggerListeners($method, array $params = array())
{
if($this->muteListeners === true)
return;
// Mute all the listeners cause we don't want listeners called in listeners
// If we do so: unmute the listeners in the listener method itself
$this->muteListeners = true;
foreach($this->listeners as $l) {
/** @var DBListener $l */
call_user_func_array(array($l, $method), $params);
}
// Unmute listeners cause from now on we're not in a listener method anymore
$this->muteListeners = false;
}
|
php
|
protected function triggerListeners($method, array $params = array())
{
if($this->muteListeners === true)
return;
// Mute all the listeners cause we don't want listeners called in listeners
// If we do so: unmute the listeners in the listener method itself
$this->muteListeners = true;
foreach($this->listeners as $l) {
/** @var DBListener $l */
call_user_func_array(array($l, $method), $params);
}
// Unmute listeners cause from now on we're not in a listener method anymore
$this->muteListeners = false;
}
|
[
"protected",
"function",
"triggerListeners",
"(",
"$",
"method",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"muteListeners",
"===",
"true",
")",
"return",
";",
"// Mute all the listeners cause we don't want listeners called in listeners",
"// If we do so: unmute the listeners in the listener method itself",
"$",
"this",
"->",
"muteListeners",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"listeners",
"as",
"$",
"l",
")",
"{",
"/** @var DBListener $l */",
"call_user_func_array",
"(",
"array",
"(",
"$",
"l",
",",
"$",
"method",
")",
",",
"$",
"params",
")",
";",
"}",
"// Unmute listeners cause from now on we're not in a listener method anymore",
"$",
"this",
"->",
"muteListeners",
"=",
"false",
";",
"}"
] |
Triggers a call of a specific method from all registered listener classes if the listeners are not set to mute
@param string $method The listener method that should be called
@param array $params The parameters for the listener method
|
[
"Triggers",
"a",
"call",
"of",
"a",
"specific",
"method",
"from",
"all",
"registered",
"listener",
"classes",
"if",
"the",
"listeners",
"are",
"not",
"set",
"to",
"mute"
] |
d897d3d3a3d761a0f4fc9aa20426429d0aad1d92
|
https://github.com/TiMESPLiNTER/tsfw-db/blob/d897d3d3a3d761a0f4fc9aa20426429d0aad1d92/lib/timesplinter/tsfw/db/DB.php#L208-L224
|
25,072
|
linpax/microphp-framework
|
src/queue/drivers/RabbitMQ.php
|
RabbitMQ.read
|
public function read($chat, $route, $nameReader = 'random')
{
$queue = new \AMQPQueue($this->channel);
$queue->setName($nameReader);
/** @noinspection PhpUndefinedMethodInspection */
$queue->declare();
$queue->bind($chat, $route);
$envelop = $queue->get();
if ($envelop) {
$queue->ack($envelop->getDeliveryTag());
return $envelop;
}
return false;
}
|
php
|
public function read($chat, $route, $nameReader = 'random')
{
$queue = new \AMQPQueue($this->channel);
$queue->setName($nameReader);
/** @noinspection PhpUndefinedMethodInspection */
$queue->declare();
$queue->bind($chat, $route);
$envelop = $queue->get();
if ($envelop) {
$queue->ack($envelop->getDeliveryTag());
return $envelop;
}
return false;
}
|
[
"public",
"function",
"read",
"(",
"$",
"chat",
",",
"$",
"route",
",",
"$",
"nameReader",
"=",
"'random'",
")",
"{",
"$",
"queue",
"=",
"new",
"\\",
"AMQPQueue",
"(",
"$",
"this",
"->",
"channel",
")",
";",
"$",
"queue",
"->",
"setName",
"(",
"$",
"nameReader",
")",
";",
"/** @noinspection PhpUndefinedMethodInspection */",
"$",
"queue",
"->",
"declare",
"(",
")",
";",
"$",
"queue",
"->",
"bind",
"(",
"$",
"chat",
",",
"$",
"route",
")",
";",
"$",
"envelop",
"=",
"$",
"queue",
"->",
"get",
"(",
")",
";",
"if",
"(",
"$",
"envelop",
")",
"{",
"$",
"queue",
"->",
"ack",
"(",
"$",
"envelop",
"->",
"getDeliveryTag",
"(",
")",
")",
";",
"return",
"$",
"envelop",
";",
"}",
"return",
"false",
";",
"}"
] |
Read current message
@access public
@param string $chat name chat room
@param string $route name route
@param string $nameReader name queue
@return \AMQPEnvelope|bool
@throws \AMQPConnectionException
@throws \AMQPChannelException
@throws \AMQPQueueException
|
[
"Read",
"current",
"message"
] |
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
|
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/queue/drivers/RabbitMQ.php#L90-L106
|
25,073
|
linpax/microphp-framework
|
src/queue/drivers/RabbitMQ.php
|
RabbitMQ.readAll
|
public function readAll($chat, $route, $nameReader)
{
$queue = new \AMQPQueue($this->channel);
$queue->setName($nameReader);
/** @noinspection PhpUndefinedMethodInspection */
$queue->declare();
$queue->bind($chat, $route);
$result = [];
while ($envelop = $queue->get()) {
$queue->ack($envelop->getDeliveryTag());
$result[] = $envelop;
}
return $result;
}
|
php
|
public function readAll($chat, $route, $nameReader)
{
$queue = new \AMQPQueue($this->channel);
$queue->setName($nameReader);
/** @noinspection PhpUndefinedMethodInspection */
$queue->declare();
$queue->bind($chat, $route);
$result = [];
while ($envelop = $queue->get()) {
$queue->ack($envelop->getDeliveryTag());
$result[] = $envelop;
}
return $result;
}
|
[
"public",
"function",
"readAll",
"(",
"$",
"chat",
",",
"$",
"route",
",",
"$",
"nameReader",
")",
"{",
"$",
"queue",
"=",
"new",
"\\",
"AMQPQueue",
"(",
"$",
"this",
"->",
"channel",
")",
";",
"$",
"queue",
"->",
"setName",
"(",
"$",
"nameReader",
")",
";",
"/** @noinspection PhpUndefinedMethodInspection */",
"$",
"queue",
"->",
"declare",
"(",
")",
";",
"$",
"queue",
"->",
"bind",
"(",
"$",
"chat",
",",
"$",
"route",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"while",
"(",
"$",
"envelop",
"=",
"$",
"queue",
"->",
"get",
"(",
")",
")",
"{",
"$",
"queue",
"->",
"ack",
"(",
"$",
"envelop",
"->",
"getDeliveryTag",
"(",
")",
")",
";",
"$",
"result",
"[",
"]",
"=",
"$",
"envelop",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Read all messages
@access public
@param string $chat name chat room
@param string $route name route
@param string $nameReader name queue
@return array
@throws \AMQPConnectionException
@throws \AMQPQueueException
@throws \AMQPChannelException
|
[
"Read",
"all",
"messages"
] |
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
|
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/queue/drivers/RabbitMQ.php#L122-L137
|
25,074
|
shgysk8zer0/core_api
|
traits/image.php
|
Image.resizeImage
|
final public function resizeImage($width = null, $height = null)
{
if (is_int($width) and is_int($height)) {
$new_image = imagecreatetruecolor($width, $height);
imagecopyresampled(
$new_image,
$this->_image_handle,
0,
0,
0,
0,
$width,
$height,
$this->imageWidth(),
$this->imageHeight()
);
if (is_resource($new_image)) {
$this->_image_handle = $new_image;
}
}
return $this;
}
|
php
|
final public function resizeImage($width = null, $height = null)
{
if (is_int($width) and is_int($height)) {
$new_image = imagecreatetruecolor($width, $height);
imagecopyresampled(
$new_image,
$this->_image_handle,
0,
0,
0,
0,
$width,
$height,
$this->imageWidth(),
$this->imageHeight()
);
if (is_resource($new_image)) {
$this->_image_handle = $new_image;
}
}
return $this;
}
|
[
"final",
"public",
"function",
"resizeImage",
"(",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"width",
")",
"and",
"is_int",
"(",
"$",
"height",
")",
")",
"{",
"$",
"new_image",
"=",
"imagecreatetruecolor",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"imagecopyresampled",
"(",
"$",
"new_image",
",",
"$",
"this",
"->",
"_image_handle",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"this",
"->",
"imageWidth",
"(",
")",
",",
"$",
"this",
"->",
"imageHeight",
"(",
")",
")",
";",
"if",
"(",
"is_resource",
"(",
"$",
"new_image",
")",
")",
"{",
"$",
"this",
"->",
"_image_handle",
"=",
"$",
"new_image",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Resize an image to an exact width and height
@param int $width Width in pixels
@param int $height Height in pixels
@return self With $this->_image_handle as resized image
|
[
"Resize",
"an",
"image",
"to",
"an",
"exact",
"width",
"and",
"height"
] |
9e9b8baf761af874b95256ad2462e55fbb2b2e58
|
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/image.php#L172-L193
|
25,075
|
shgysk8zer0/core_api
|
traits/image.php
|
Image.rotateImage
|
final public function rotateImage(
$angle = 0,
array $bgd_color = array(0, 0, 0, 127),
$ignore_transparent = false
)
{
$this->_image_handle = imagerotate(
$this->_image_handle,
$angle,
$this->_createImageColorAlpha($bgd_color),
$ignore_transparent ? 1 : 0
);
}
|
php
|
final public function rotateImage(
$angle = 0,
array $bgd_color = array(0, 0, 0, 127),
$ignore_transparent = false
)
{
$this->_image_handle = imagerotate(
$this->_image_handle,
$angle,
$this->_createImageColorAlpha($bgd_color),
$ignore_transparent ? 1 : 0
);
}
|
[
"final",
"public",
"function",
"rotateImage",
"(",
"$",
"angle",
"=",
"0",
",",
"array",
"$",
"bgd_color",
"=",
"array",
"(",
"0",
",",
"0",
",",
"0",
",",
"127",
")",
",",
"$",
"ignore_transparent",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"_image_handle",
"=",
"imagerotate",
"(",
"$",
"this",
"->",
"_image_handle",
",",
"$",
"angle",
",",
"$",
"this",
"->",
"_createImageColorAlpha",
"(",
"$",
"bgd_color",
")",
",",
"$",
"ignore_transparent",
"?",
"1",
":",
"0",
")",
";",
"}"
] |
Rotate an image with a given angle
@param int $angle Rotation angle, in degrees.
@param array $bgd_color RGBA array for background color
@param bool $ignore_transparent Ignore transparent colors?
|
[
"Rotate",
"an",
"image",
"with",
"a",
"given",
"angle"
] |
9e9b8baf761af874b95256ad2462e55fbb2b2e58
|
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/image.php#L221-L233
|
25,076
|
shgysk8zer0/core_api
|
traits/image.php
|
Image._createImageColorAlpha
|
final protected function _createImageColorAlpha(array $rgba = array())
{
$keys = array('r', 'g', 'b', 'a');
$rgba = array_filter($rgba, 'is_int');
$rgba = array_map('abs', $rgba);
$rgba = array_pad($rgba, count($keys), 0);
$rgba = array_slice($rgba, 0, count($keys));
$rgba = array_combine($keys, $rgba);
extract($rgba);
return imagecolorallocatealpha(
$this->_image_handle,
min($r, 255),
min($g, 255),
min($b, 255),
min($a, 127)
);
}
|
php
|
final protected function _createImageColorAlpha(array $rgba = array())
{
$keys = array('r', 'g', 'b', 'a');
$rgba = array_filter($rgba, 'is_int');
$rgba = array_map('abs', $rgba);
$rgba = array_pad($rgba, count($keys), 0);
$rgba = array_slice($rgba, 0, count($keys));
$rgba = array_combine($keys, $rgba);
extract($rgba);
return imagecolorallocatealpha(
$this->_image_handle,
min($r, 255),
min($g, 255),
min($b, 255),
min($a, 127)
);
}
|
[
"final",
"protected",
"function",
"_createImageColorAlpha",
"(",
"array",
"$",
"rgba",
"=",
"array",
"(",
")",
")",
"{",
"$",
"keys",
"=",
"array",
"(",
"'r'",
",",
"'g'",
",",
"'b'",
",",
"'a'",
")",
";",
"$",
"rgba",
"=",
"array_filter",
"(",
"$",
"rgba",
",",
"'is_int'",
")",
";",
"$",
"rgba",
"=",
"array_map",
"(",
"'abs'",
",",
"$",
"rgba",
")",
";",
"$",
"rgba",
"=",
"array_pad",
"(",
"$",
"rgba",
",",
"count",
"(",
"$",
"keys",
")",
",",
"0",
")",
";",
"$",
"rgba",
"=",
"array_slice",
"(",
"$",
"rgba",
",",
"0",
",",
"count",
"(",
"$",
"keys",
")",
")",
";",
"$",
"rgba",
"=",
"array_combine",
"(",
"$",
"keys",
",",
"$",
"rgba",
")",
";",
"extract",
"(",
"$",
"rgba",
")",
";",
"return",
"imagecolorallocatealpha",
"(",
"$",
"this",
"->",
"_image_handle",
",",
"min",
"(",
"$",
"r",
",",
"255",
")",
",",
"min",
"(",
"$",
"g",
",",
"255",
")",
",",
"min",
"(",
"$",
"b",
",",
"255",
")",
",",
"min",
"(",
"$",
"a",
",",
"127",
")",
")",
";",
"}"
] |
Allocate a color for an image
@param array $rgba RGBA array for color
@return int A color identifier or FALSE if the allocation failed.
@see https://php.net/manual/en/function.imagecolorallocatealpha.php
|
[
"Allocate",
"a",
"color",
"for",
"an",
"image"
] |
9e9b8baf761af874b95256ad2462e55fbb2b2e58
|
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/image.php#L242-L260
|
25,077
|
shgysk8zer0/core_api
|
traits/image.php
|
Image.imagePNG
|
final public function imagePNG($filename = null, $quality = -1, $filters = PNG_NO_FILTER)
{
return imagepng($this->_image_handle, $filename, $quality, $filters);
}
|
php
|
final public function imagePNG($filename = null, $quality = -1, $filters = PNG_NO_FILTER)
{
return imagepng($this->_image_handle, $filename, $quality, $filters);
}
|
[
"final",
"public",
"function",
"imagePNG",
"(",
"$",
"filename",
"=",
"null",
",",
"$",
"quality",
"=",
"-",
"1",
",",
"$",
"filters",
"=",
"PNG_NO_FILTER",
")",
"{",
"return",
"imagepng",
"(",
"$",
"this",
"->",
"_image_handle",
",",
"$",
"filename",
",",
"$",
"quality",
",",
"$",
"filters",
")",
";",
"}"
] |
Output a PNG image to either the browser or a file
@param string $filename The path to save the file to. null outputs directly
@param int $quality Compression level: from 0 (no compression) to 9.
@param int $filters Any combination of the PNG_FILTER_XXX constants.
@return bool True on success, false on failure
|
[
"Output",
"a",
"PNG",
"image",
"to",
"either",
"the",
"browser",
"or",
"a",
"file"
] |
9e9b8baf761af874b95256ad2462e55fbb2b2e58
|
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/image.php#L295-L298
|
25,078
|
shgysk8zer0/core_api
|
traits/image.php
|
Image.saveImage
|
final public function saveImage($filename)
{
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if (! is_string($extension)) {
$extension = image_type_to_extension($this->_image_type);
$filename .= ".{$extension}";
}
switch(strtolower($extension))
{
case 'jpeg':
case 'jpg':
return $this->imageJPEG($filename);
break;
case 'png':
return $this->imagePNG($filename);
break;
case 'gif':
return $this->imageGIF($filename);
default:
trigger_error('Invalid extension or not an image', E_USER_WARNING);
return false;
}
}
|
php
|
final public function saveImage($filename)
{
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if (! is_string($extension)) {
$extension = image_type_to_extension($this->_image_type);
$filename .= ".{$extension}";
}
switch(strtolower($extension))
{
case 'jpeg':
case 'jpg':
return $this->imageJPEG($filename);
break;
case 'png':
return $this->imagePNG($filename);
break;
case 'gif':
return $this->imageGIF($filename);
default:
trigger_error('Invalid extension or not an image', E_USER_WARNING);
return false;
}
}
|
[
"final",
"public",
"function",
"saveImage",
"(",
"$",
"filename",
")",
"{",
"$",
"extension",
"=",
"pathinfo",
"(",
"$",
"filename",
",",
"PATHINFO_EXTENSION",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"extension",
")",
")",
"{",
"$",
"extension",
"=",
"image_type_to_extension",
"(",
"$",
"this",
"->",
"_image_type",
")",
";",
"$",
"filename",
".=",
"\".{$extension}\"",
";",
"}",
"switch",
"(",
"strtolower",
"(",
"$",
"extension",
")",
")",
"{",
"case",
"'jpeg'",
":",
"case",
"'jpg'",
":",
"return",
"$",
"this",
"->",
"imageJPEG",
"(",
"$",
"filename",
")",
";",
"break",
";",
"case",
"'png'",
":",
"return",
"$",
"this",
"->",
"imagePNG",
"(",
"$",
"filename",
")",
";",
"break",
";",
"case",
"'gif'",
":",
"return",
"$",
"this",
"->",
"imageGIF",
"(",
"$",
"filename",
")",
";",
"default",
":",
"trigger_error",
"(",
"'Invalid extension or not an image'",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Generic save funciton, which converts image according to extension
@param string $filename Path and extension to save to
@return bool Success or failure of save
|
[
"Generic",
"save",
"funciton",
"which",
"converts",
"image",
"according",
"to",
"extension"
] |
9e9b8baf761af874b95256ad2462e55fbb2b2e58
|
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/image.php#L306-L333
|
25,079
|
shgysk8zer0/core_api
|
traits/image.php
|
Image.imageAsDOMElement
|
final public function imageAsDOMElement($as = null)
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$image = $dom->appendChild($dom->createElement('img'));
$image->setAttribute('height', $this->imageHeight());
$image->setAttribute('width', $this->imageWidth());
$image->setAttribute('alt', $this->alt_text);
$image->setAttribute('src', $this->dataURI($as));
return $image;
}
|
php
|
final public function imageAsDOMElement($as = null)
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$image = $dom->appendChild($dom->createElement('img'));
$image->setAttribute('height', $this->imageHeight());
$image->setAttribute('width', $this->imageWidth());
$image->setAttribute('alt', $this->alt_text);
$image->setAttribute('src', $this->dataURI($as));
return $image;
}
|
[
"final",
"public",
"function",
"imageAsDOMElement",
"(",
"$",
"as",
"=",
"null",
")",
"{",
"$",
"dom",
"=",
"new",
"\\",
"DOMDocument",
"(",
"'1.0'",
",",
"'UTF-8'",
")",
";",
"$",
"image",
"=",
"$",
"dom",
"->",
"appendChild",
"(",
"$",
"dom",
"->",
"createElement",
"(",
"'img'",
")",
")",
";",
"$",
"image",
"->",
"setAttribute",
"(",
"'height'",
",",
"$",
"this",
"->",
"imageHeight",
"(",
")",
")",
";",
"$",
"image",
"->",
"setAttribute",
"(",
"'width'",
",",
"$",
"this",
"->",
"imageWidth",
"(",
")",
")",
";",
"$",
"image",
"->",
"setAttribute",
"(",
"'alt'",
",",
"$",
"this",
"->",
"alt_text",
")",
";",
"$",
"image",
"->",
"setAttribute",
"(",
"'src'",
",",
"$",
"this",
"->",
"dataURI",
"(",
"$",
"as",
")",
")",
";",
"return",
"$",
"image",
";",
"}"
] |
Create a DOMElement containing attributes of the image
@param void
@return DOMElement
@uses DOMDocument
|
[
"Create",
"a",
"DOMElement",
"containing",
"attributes",
"of",
"the",
"image"
] |
9e9b8baf761af874b95256ad2462e55fbb2b2e58
|
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/image.php#L342-L351
|
25,080
|
shgysk8zer0/core_api
|
traits/image.php
|
Image.imageAsString
|
final public function imageAsString($as = null)
{
$image = $this->imageAsDOMElement($as);
return $image->ownerDocument->saveHTML($image);
}
|
php
|
final public function imageAsString($as = null)
{
$image = $this->imageAsDOMElement($as);
return $image->ownerDocument->saveHTML($image);
}
|
[
"final",
"public",
"function",
"imageAsString",
"(",
"$",
"as",
"=",
"null",
")",
"{",
"$",
"image",
"=",
"$",
"this",
"->",
"imageAsDOMElement",
"(",
"$",
"as",
")",
";",
"return",
"$",
"image",
"->",
"ownerDocument",
"->",
"saveHTML",
"(",
"$",
"image",
")",
";",
"}"
] |
Uses imageAsDOMElement and returns it as an HTML string
@param void
@return string HTML <img> element
|
[
"Uses",
"imageAsDOMElement",
"and",
"returns",
"it",
"as",
"an",
"HTML",
"string"
] |
9e9b8baf761af874b95256ad2462e55fbb2b2e58
|
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/image.php#L359-L363
|
25,081
|
shgysk8zer0/core_api
|
traits/image.php
|
Image.dataURI
|
final public function dataURI($as = null)
{
$mime = is_int($as) ? image_type_to_mime_type($as) : $this->_image_mime;
return 'data:' . $mime . ';base64,' . base64_encode($this->imageAsBinary($as));
}
|
php
|
final public function dataURI($as = null)
{
$mime = is_int($as) ? image_type_to_mime_type($as) : $this->_image_mime;
return 'data:' . $mime . ';base64,' . base64_encode($this->imageAsBinary($as));
}
|
[
"final",
"public",
"function",
"dataURI",
"(",
"$",
"as",
"=",
"null",
")",
"{",
"$",
"mime",
"=",
"is_int",
"(",
"$",
"as",
")",
"?",
"image_type_to_mime_type",
"(",
"$",
"as",
")",
":",
"$",
"this",
"->",
"_image_mime",
";",
"return",
"'data:'",
".",
"$",
"mime",
".",
"';base64,'",
".",
"base64_encode",
"(",
"$",
"this",
"->",
"imageAsBinary",
"(",
"$",
"as",
")",
")",
";",
"}"
] |
Converts image to a base64 encoded string
@param void
@return string "data:image/*;base64,..."
|
[
"Converts",
"image",
"to",
"a",
"base64",
"encoded",
"string"
] |
9e9b8baf761af874b95256ad2462e55fbb2b2e58
|
https://github.com/shgysk8zer0/core_api/blob/9e9b8baf761af874b95256ad2462e55fbb2b2e58/traits/image.php#L371-L375
|
25,082
|
ammarfaizi2/icetea-framework
|
src/System/Crayner/Database/DB.php
|
DB.makeStatement
|
protected static function makeStatement($statement)
{
$self = self::getInstance();
$optionWhere = (!empty($self->optionWhere)) ? " WHERE ". substr(implode("", $self->optionWhere), 4) : null;
$optionJoin = implode("", $self->optionJoin);
$optionOrder = $self->optionOrder;
$optionLimit = $self->optionLimit;
return $statement.$optionJoin.$optionWhere.$optionOrder.$optionLimit;
}
|
php
|
protected static function makeStatement($statement)
{
$self = self::getInstance();
$optionWhere = (!empty($self->optionWhere)) ? " WHERE ". substr(implode("", $self->optionWhere), 4) : null;
$optionJoin = implode("", $self->optionJoin);
$optionOrder = $self->optionOrder;
$optionLimit = $self->optionLimit;
return $statement.$optionJoin.$optionWhere.$optionOrder.$optionLimit;
}
|
[
"protected",
"static",
"function",
"makeStatement",
"(",
"$",
"statement",
")",
"{",
"$",
"self",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"$",
"optionWhere",
"=",
"(",
"!",
"empty",
"(",
"$",
"self",
"->",
"optionWhere",
")",
")",
"?",
"\" WHERE \"",
".",
"substr",
"(",
"implode",
"(",
"\"\"",
",",
"$",
"self",
"->",
"optionWhere",
")",
",",
"4",
")",
":",
"null",
";",
"$",
"optionJoin",
"=",
"implode",
"(",
"\"\"",
",",
"$",
"self",
"->",
"optionJoin",
")",
";",
"$",
"optionOrder",
"=",
"$",
"self",
"->",
"optionOrder",
";",
"$",
"optionLimit",
"=",
"$",
"self",
"->",
"optionLimit",
";",
"return",
"$",
"statement",
".",
"$",
"optionJoin",
".",
"$",
"optionWhere",
".",
"$",
"optionOrder",
".",
"$",
"optionLimit",
";",
"}"
] |
Make Query Statement
@param string $statement
@return string
|
[
"Make",
"Query",
"Statement"
] |
dedd832846c3e69b429b18b8612fae50881af180
|
https://github.com/ammarfaizi2/icetea-framework/blob/dedd832846c3e69b429b18b8612fae50881af180/src/System/Crayner/Database/DB.php#L125-L135
|
25,083
|
ammarfaizi2/icetea-framework
|
src/System/Crayner/Database/DB.php
|
DB.makeMultipleInsert
|
protected static function makeMultipleInsert($table, $data)
{
$insert_values = array();
foreach ($data as $d) {
$insert_values = array_merge($insert_values, array_values($d));
$count = count($d);
$array = array_fill(0, $count, '?');
$placeholder[] = '('.implode(',', $array).')';
}
$column = implode(',', array_keys($data[0]));
$values = implode(',', $placeholder);
$query = "INSERT INTO {$table} ({$column}) VALUES {$values}";
return [$query, $insert_values];
}
|
php
|
protected static function makeMultipleInsert($table, $data)
{
$insert_values = array();
foreach ($data as $d) {
$insert_values = array_merge($insert_values, array_values($d));
$count = count($d);
$array = array_fill(0, $count, '?');
$placeholder[] = '('.implode(',', $array).')';
}
$column = implode(',', array_keys($data[0]));
$values = implode(',', $placeholder);
$query = "INSERT INTO {$table} ({$column}) VALUES {$values}";
return [$query, $insert_values];
}
|
[
"protected",
"static",
"function",
"makeMultipleInsert",
"(",
"$",
"table",
",",
"$",
"data",
")",
"{",
"$",
"insert_values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"d",
")",
"{",
"$",
"insert_values",
"=",
"array_merge",
"(",
"$",
"insert_values",
",",
"array_values",
"(",
"$",
"d",
")",
")",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"d",
")",
";",
"$",
"array",
"=",
"array_fill",
"(",
"0",
",",
"$",
"count",
",",
"'?'",
")",
";",
"$",
"placeholder",
"[",
"]",
"=",
"'('",
".",
"implode",
"(",
"','",
",",
"$",
"array",
")",
".",
"')'",
";",
"}",
"$",
"column",
"=",
"implode",
"(",
"','",
",",
"array_keys",
"(",
"$",
"data",
"[",
"0",
"]",
")",
")",
";",
"$",
"values",
"=",
"implode",
"(",
"','",
",",
"$",
"placeholder",
")",
";",
"$",
"query",
"=",
"\"INSERT INTO {$table} ({$column}) VALUES {$values}\"",
";",
"return",
"[",
"$",
"query",
",",
"$",
"insert_values",
"]",
";",
"}"
] |
Make Multiple Insert Parameter
@param string $table
@param array $data
@return array
|
[
"Make",
"Multiple",
"Insert",
"Parameter"
] |
dedd832846c3e69b429b18b8612fae50881af180
|
https://github.com/ammarfaizi2/icetea-framework/blob/dedd832846c3e69b429b18b8612fae50881af180/src/System/Crayner/Database/DB.php#L159-L178
|
25,084
|
ammarfaizi2/icetea-framework
|
src/System/Crayner/Database/DB.php
|
DB.makeUpdateParameter
|
protected static function makeUpdateParameter($data)
{
foreach ($data as $field => $value) {
$newData[] = "{$field}=:{$field}";
}
$newData = implode(",", $newData); // override new data
return $newData;
}
|
php
|
protected static function makeUpdateParameter($data)
{
foreach ($data as $field => $value) {
$newData[] = "{$field}=:{$field}";
}
$newData = implode(",", $newData); // override new data
return $newData;
}
|
[
"protected",
"static",
"function",
"makeUpdateParameter",
"(",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"newData",
"[",
"]",
"=",
"\"{$field}=:{$field}\"",
";",
"}",
"$",
"newData",
"=",
"implode",
"(",
"\",\"",
",",
"$",
"newData",
")",
";",
"// override new data",
"return",
"$",
"newData",
";",
"}"
] |
Make Update Parameter
@param array $data
@return array
|
[
"Make",
"Update",
"Parameter"
] |
dedd832846c3e69b429b18b8612fae50881af180
|
https://github.com/ammarfaizi2/icetea-framework/blob/dedd832846c3e69b429b18b8612fae50881af180/src/System/Crayner/Database/DB.php#L186-L195
|
25,085
|
ammarfaizi2/icetea-framework
|
src/System/Crayner/Database/DB.php
|
DB.makeSelect
|
protected static function makeSelect()
{
$self = self::getInstance();
$select = (!empty($self->optionSelect)) ? $self->optionSelect : "*";
return "SELECT {$select} FROM {$self->table_name} ";
}
|
php
|
protected static function makeSelect()
{
$self = self::getInstance();
$select = (!empty($self->optionSelect)) ? $self->optionSelect : "*";
return "SELECT {$select} FROM {$self->table_name} ";
}
|
[
"protected",
"static",
"function",
"makeSelect",
"(",
")",
"{",
"$",
"self",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"$",
"select",
"=",
"(",
"!",
"empty",
"(",
"$",
"self",
"->",
"optionSelect",
")",
")",
"?",
"$",
"self",
"->",
"optionSelect",
":",
"\"*\"",
";",
"return",
"\"SELECT {$select} FROM {$self->table_name} \"",
";",
"}"
] |
Make Select Query
@return string
|
[
"Make",
"Select",
"Query"
] |
dedd832846c3e69b429b18b8612fae50881af180
|
https://github.com/ammarfaizi2/icetea-framework/blob/dedd832846c3e69b429b18b8612fae50881af180/src/System/Crayner/Database/DB.php#L202-L208
|
25,086
|
ammarfaizi2/icetea-framework
|
src/System/Crayner/Database/DB.php
|
DB.makeEmpty
|
protected static function makeEmpty()
{
$self = self::getInstance();
$self->optionWhere = [];
$self->optionWhereData = [];
$self->optionJoin = [];
$self->optionLimit = null;
$self->optionSelect = null;
$self->table_name = null;
return $self;
}
|
php
|
protected static function makeEmpty()
{
$self = self::getInstance();
$self->optionWhere = [];
$self->optionWhereData = [];
$self->optionJoin = [];
$self->optionLimit = null;
$self->optionSelect = null;
$self->table_name = null;
return $self;
}
|
[
"protected",
"static",
"function",
"makeEmpty",
"(",
")",
"{",
"$",
"self",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"$",
"self",
"->",
"optionWhere",
"=",
"[",
"]",
";",
"$",
"self",
"->",
"optionWhereData",
"=",
"[",
"]",
";",
"$",
"self",
"->",
"optionJoin",
"=",
"[",
"]",
";",
"$",
"self",
"->",
"optionLimit",
"=",
"null",
";",
"$",
"self",
"->",
"optionSelect",
"=",
"null",
";",
"$",
"self",
"->",
"table_name",
"=",
"null",
";",
"return",
"$",
"self",
";",
"}"
] |
Empty All Option
@return Instance
|
[
"Empty",
"All",
"Option"
] |
dedd832846c3e69b429b18b8612fae50881af180
|
https://github.com/ammarfaizi2/icetea-framework/blob/dedd832846c3e69b429b18b8612fae50881af180/src/System/Crayner/Database/DB.php#L215-L227
|
25,087
|
ammarfaizi2/icetea-framework
|
src/System/Crayner/Database/DB.php
|
DB.makeArrayOfWhere
|
protected function makeArrayOfWhere($array, $type)
{
$self = self::getInstance();
if (array_key_exists(0, $array)) :
foreach ($array as $a):
$make = [
'parameter' => str_replace(".", "_", $a[0]),
'column' => $a[0],
'operator' => $a[1],
'value' => (isset($a[2])) ? $a[2] : null,
];
$where = $self->makeWhere(
$make['parameter'], $make['column'], $make['operator'], $make['value']
);
$whereData = $self->makeOptionWhere(
$make['parameter'], $make['column'], $make['operator'], $make['value']
);
array_push($self->optionWhere, $type.$where);
$self->optionWhereData = array_merge(
$self->optionWhereData, [":where_{$make['parameter']}" => $whereData]
);
endforeach; else:
foreach ($array as $a => $v):
$param = str_replace(".", "_", $a);
$where = $self->makeWhere($param, $a, '=', $v);
$whereData = $self->makeOptionWhere($param, $a, '=', $v);
array_push($self->optionWhere, $type.$where);
$self->optionWhereData = array_merge($self->optionWhereData, [":where_{$param}" => $whereData]);
endforeach;
endif;
return $self;
}
|
php
|
protected function makeArrayOfWhere($array, $type)
{
$self = self::getInstance();
if (array_key_exists(0, $array)) :
foreach ($array as $a):
$make = [
'parameter' => str_replace(".", "_", $a[0]),
'column' => $a[0],
'operator' => $a[1],
'value' => (isset($a[2])) ? $a[2] : null,
];
$where = $self->makeWhere(
$make['parameter'], $make['column'], $make['operator'], $make['value']
);
$whereData = $self->makeOptionWhere(
$make['parameter'], $make['column'], $make['operator'], $make['value']
);
array_push($self->optionWhere, $type.$where);
$self->optionWhereData = array_merge(
$self->optionWhereData, [":where_{$make['parameter']}" => $whereData]
);
endforeach; else:
foreach ($array as $a => $v):
$param = str_replace(".", "_", $a);
$where = $self->makeWhere($param, $a, '=', $v);
$whereData = $self->makeOptionWhere($param, $a, '=', $v);
array_push($self->optionWhere, $type.$where);
$self->optionWhereData = array_merge($self->optionWhereData, [":where_{$param}" => $whereData]);
endforeach;
endif;
return $self;
}
|
[
"protected",
"function",
"makeArrayOfWhere",
"(",
"$",
"array",
",",
"$",
"type",
")",
"{",
"$",
"self",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"0",
",",
"$",
"array",
")",
")",
":",
"foreach",
"(",
"$",
"array",
"as",
"$",
"a",
")",
":",
"$",
"make",
"=",
"[",
"'parameter'",
"=>",
"str_replace",
"(",
"\".\"",
",",
"\"_\"",
",",
"$",
"a",
"[",
"0",
"]",
")",
",",
"'column'",
"=>",
"$",
"a",
"[",
"0",
"]",
",",
"'operator'",
"=>",
"$",
"a",
"[",
"1",
"]",
",",
"'value'",
"=>",
"(",
"isset",
"(",
"$",
"a",
"[",
"2",
"]",
")",
")",
"?",
"$",
"a",
"[",
"2",
"]",
":",
"null",
",",
"]",
";",
"$",
"where",
"=",
"$",
"self",
"->",
"makeWhere",
"(",
"$",
"make",
"[",
"'parameter'",
"]",
",",
"$",
"make",
"[",
"'column'",
"]",
",",
"$",
"make",
"[",
"'operator'",
"]",
",",
"$",
"make",
"[",
"'value'",
"]",
")",
";",
"$",
"whereData",
"=",
"$",
"self",
"->",
"makeOptionWhere",
"(",
"$",
"make",
"[",
"'parameter'",
"]",
",",
"$",
"make",
"[",
"'column'",
"]",
",",
"$",
"make",
"[",
"'operator'",
"]",
",",
"$",
"make",
"[",
"'value'",
"]",
")",
";",
"array_push",
"(",
"$",
"self",
"->",
"optionWhere",
",",
"$",
"type",
".",
"$",
"where",
")",
";",
"$",
"self",
"->",
"optionWhereData",
"=",
"array_merge",
"(",
"$",
"self",
"->",
"optionWhereData",
",",
"[",
"\":where_{$make['parameter']}\"",
"=>",
"$",
"whereData",
"]",
")",
";",
"endforeach",
";",
"else",
":",
"foreach",
"(",
"$",
"array",
"as",
"$",
"a",
"=>",
"$",
"v",
")",
":",
"$",
"param",
"=",
"str_replace",
"(",
"\".\"",
",",
"\"_\"",
",",
"$",
"a",
")",
";",
"$",
"where",
"=",
"$",
"self",
"->",
"makeWhere",
"(",
"$",
"param",
",",
"$",
"a",
",",
"'='",
",",
"$",
"v",
")",
";",
"$",
"whereData",
"=",
"$",
"self",
"->",
"makeOptionWhere",
"(",
"$",
"param",
",",
"$",
"a",
",",
"'='",
",",
"$",
"v",
")",
";",
"array_push",
"(",
"$",
"self",
"->",
"optionWhere",
",",
"$",
"type",
".",
"$",
"where",
")",
";",
"$",
"self",
"->",
"optionWhereData",
"=",
"array_merge",
"(",
"$",
"self",
"->",
"optionWhereData",
",",
"[",
"\":where_{$param}\"",
"=>",
"$",
"whereData",
"]",
")",
";",
"endforeach",
";",
"endif",
";",
"return",
"$",
"self",
";",
"}"
] |
Make Where Array
@param array $array
@param string $type
@return Instance
|
[
"Make",
"Where",
"Array"
] |
dedd832846c3e69b429b18b8612fae50881af180
|
https://github.com/ammarfaizi2/icetea-framework/blob/dedd832846c3e69b429b18b8612fae50881af180/src/System/Crayner/Database/DB.php#L264-L306
|
25,088
|
ammarfaizi2/icetea-framework
|
src/System/Crayner/Database/DB.php
|
DB.makeStringOfWhere
|
protected function makeStringOfWhere($column, $operator = null, $value = null, $type)
{
$self = self::getInstance();
$param = str_replace(".", "_", $column); // remove table seperator for parameter
$where = $self->makeWhere($param, $column, $operator, $value);
$whereData = $self->makeOptionWhere($param, $column, $operator, $value);
array_push($self->optionWhere, $type.$where);
$self->optionWhereData = array_merge($self->optionWhereData, [":where_{$param}" => $whereData]);
return $self;
}
|
php
|
protected function makeStringOfWhere($column, $operator = null, $value = null, $type)
{
$self = self::getInstance();
$param = str_replace(".", "_", $column); // remove table seperator for parameter
$where = $self->makeWhere($param, $column, $operator, $value);
$whereData = $self->makeOptionWhere($param, $column, $operator, $value);
array_push($self->optionWhere, $type.$where);
$self->optionWhereData = array_merge($self->optionWhereData, [":where_{$param}" => $whereData]);
return $self;
}
|
[
"protected",
"function",
"makeStringOfWhere",
"(",
"$",
"column",
",",
"$",
"operator",
"=",
"null",
",",
"$",
"value",
"=",
"null",
",",
"$",
"type",
")",
"{",
"$",
"self",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"$",
"param",
"=",
"str_replace",
"(",
"\".\"",
",",
"\"_\"",
",",
"$",
"column",
")",
";",
"// remove table seperator for parameter",
"$",
"where",
"=",
"$",
"self",
"->",
"makeWhere",
"(",
"$",
"param",
",",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
")",
";",
"$",
"whereData",
"=",
"$",
"self",
"->",
"makeOptionWhere",
"(",
"$",
"param",
",",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
")",
";",
"array_push",
"(",
"$",
"self",
"->",
"optionWhere",
",",
"$",
"type",
".",
"$",
"where",
")",
";",
"$",
"self",
"->",
"optionWhereData",
"=",
"array_merge",
"(",
"$",
"self",
"->",
"optionWhereData",
",",
"[",
"\":where_{$param}\"",
"=>",
"$",
"whereData",
"]",
")",
";",
"return",
"$",
"self",
";",
"}"
] |
Make String Where
@return Instance
|
[
"Make",
"String",
"Where"
] |
dedd832846c3e69b429b18b8612fae50881af180
|
https://github.com/ammarfaizi2/icetea-framework/blob/dedd832846c3e69b429b18b8612fae50881af180/src/System/Crayner/Database/DB.php#L313-L325
|
25,089
|
ammarfaizi2/icetea-framework
|
src/System/Crayner/Database/DB.php
|
DB.insert
|
public static function insert($data)
{
$self = self::getInstance();
$table = $self->table_name;
if (isset($data[0])) {
$make = $self->makeMultipleInsert($table, $data);
$statement = $make[0];
$value = $make[1];
} else {
$newData = $self->makeInsertParameter($data);
$column = implode(",", array_keys($data));
$paramValue = implode(",", array_keys($newData));
$statement = "INSERT INTO {$table} ({$column}) VALUES({$paramValue});";
$value = $newData;
}
$execute = $self->exec($statement, $value);
return $execute;
}
|
php
|
public static function insert($data)
{
$self = self::getInstance();
$table = $self->table_name;
if (isset($data[0])) {
$make = $self->makeMultipleInsert($table, $data);
$statement = $make[0];
$value = $make[1];
} else {
$newData = $self->makeInsertParameter($data);
$column = implode(",", array_keys($data));
$paramValue = implode(",", array_keys($newData));
$statement = "INSERT INTO {$table} ({$column}) VALUES({$paramValue});";
$value = $newData;
}
$execute = $self->exec($statement, $value);
return $execute;
}
|
[
"public",
"static",
"function",
"insert",
"(",
"$",
"data",
")",
"{",
"$",
"self",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"$",
"table",
"=",
"$",
"self",
"->",
"table_name",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"0",
"]",
")",
")",
"{",
"$",
"make",
"=",
"$",
"self",
"->",
"makeMultipleInsert",
"(",
"$",
"table",
",",
"$",
"data",
")",
";",
"$",
"statement",
"=",
"$",
"make",
"[",
"0",
"]",
";",
"$",
"value",
"=",
"$",
"make",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"newData",
"=",
"$",
"self",
"->",
"makeInsertParameter",
"(",
"$",
"data",
")",
";",
"$",
"column",
"=",
"implode",
"(",
"\",\"",
",",
"array_keys",
"(",
"$",
"data",
")",
")",
";",
"$",
"paramValue",
"=",
"implode",
"(",
"\",\"",
",",
"array_keys",
"(",
"$",
"newData",
")",
")",
";",
"$",
"statement",
"=",
"\"INSERT INTO {$table} ({$column}) VALUES({$paramValue});\"",
";",
"$",
"value",
"=",
"$",
"newData",
";",
"}",
"$",
"execute",
"=",
"$",
"self",
"->",
"exec",
"(",
"$",
"statement",
",",
"$",
"value",
")",
";",
"return",
"$",
"execute",
";",
"}"
] |
Insert & Multiple Insert
@param array $data
@return boolean
|
[
"Insert",
"&",
"Multiple",
"Insert"
] |
dedd832846c3e69b429b18b8612fae50881af180
|
https://github.com/ammarfaizi2/icetea-framework/blob/dedd832846c3e69b429b18b8612fae50881af180/src/System/Crayner/Database/DB.php#L389-L409
|
25,090
|
ammarfaizi2/icetea-framework
|
src/System/Crayner/Database/DB.php
|
DB.increment
|
public function increment($column, $value = null, $where = [], $operator = "+")
{
return self::getInstance()->makeIncreDecrement($column, $value, $where, $operator);
}
|
php
|
public function increment($column, $value = null, $where = [], $operator = "+")
{
return self::getInstance()->makeIncreDecrement($column, $value, $where, $operator);
}
|
[
"public",
"function",
"increment",
"(",
"$",
"column",
",",
"$",
"value",
"=",
"null",
",",
"$",
"where",
"=",
"[",
"]",
",",
"$",
"operator",
"=",
"\"+\"",
")",
"{",
"return",
"self",
"::",
"getInstance",
"(",
")",
"->",
"makeIncreDecrement",
"(",
"$",
"column",
",",
"$",
"value",
",",
"$",
"where",
",",
"$",
"operator",
")",
";",
"}"
] |
Increment & Decrement
@param string $column
@param string/integer $value
@param array $where
@param string $operator
@return Instance
|
[
"Increment",
"&",
"Decrement"
] |
dedd832846c3e69b429b18b8612fae50881af180
|
https://github.com/ammarfaizi2/icetea-framework/blob/dedd832846c3e69b429b18b8612fae50881af180/src/System/Crayner/Database/DB.php#L516-L519
|
25,091
|
ammarfaizi2/icetea-framework
|
src/System/Crayner/Database/DB.php
|
DB.get
|
public static function get()
{
$self = self::getInstance();
$statement = $self->makeSelect();
$execute = $self->exec($statement, []);
return $execute->fetchAll(\PDO::FETCH_CLASS);
}
|
php
|
public static function get()
{
$self = self::getInstance();
$statement = $self->makeSelect();
$execute = $self->exec($statement, []);
return $execute->fetchAll(\PDO::FETCH_CLASS);
}
|
[
"public",
"static",
"function",
"get",
"(",
")",
"{",
"$",
"self",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"$",
"statement",
"=",
"$",
"self",
"->",
"makeSelect",
"(",
")",
";",
"$",
"execute",
"=",
"$",
"self",
"->",
"exec",
"(",
"$",
"statement",
",",
"[",
"]",
")",
";",
"return",
"$",
"execute",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_CLASS",
")",
";",
"}"
] |
Get All Record
@return Array
|
[
"Get",
"All",
"Record"
] |
dedd832846c3e69b429b18b8612fae50881af180
|
https://github.com/ammarfaizi2/icetea-framework/blob/dedd832846c3e69b429b18b8612fae50881af180/src/System/Crayner/Database/DB.php#L584-L592
|
25,092
|
ammarfaizi2/icetea-framework
|
src/System/Crayner/Database/DB.php
|
DB.first
|
public static function first()
{
$self = self::getInstance();
$statement = $self->makeSelect();
$execute = $self->exec($statement, []);
return $execute->fetchObject();
}
|
php
|
public static function first()
{
$self = self::getInstance();
$statement = $self->makeSelect();
$execute = $self->exec($statement, []);
return $execute->fetchObject();
}
|
[
"public",
"static",
"function",
"first",
"(",
")",
"{",
"$",
"self",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"$",
"statement",
"=",
"$",
"self",
"->",
"makeSelect",
"(",
")",
";",
"$",
"execute",
"=",
"$",
"self",
"->",
"exec",
"(",
"$",
"statement",
",",
"[",
"]",
")",
";",
"return",
"$",
"execute",
"->",
"fetchObject",
"(",
")",
";",
"}"
] |
Get First Record
@return Array
|
[
"Get",
"First",
"Record"
] |
dedd832846c3e69b429b18b8612fae50881af180
|
https://github.com/ammarfaizi2/icetea-framework/blob/dedd832846c3e69b429b18b8612fae50881af180/src/System/Crayner/Database/DB.php#L607-L615
|
25,093
|
mossphp/moss-storage
|
Moss/Storage/Query/Relation/OneRelation.php
|
OneRelation.write
|
public function write(&$result)
{
$entity = $this->accessor->getPropertyValue($result, $this->definition->container());
if (empty($entity)) {
$conditions = [];
foreach ($this->definition->keys() as $local => $foreign) {
$conditions[$foreign][] = $this->accessor->getPropertyValue($result, $local);
}
$this->cleanup($this->definition->entity(), [], $conditions);
return $result;
}
$this->assertInstance($entity);
foreach ($this->definition->keys() as $local => $foreign) {
$this->accessor->setPropertyValue($entity, $foreign, $this->accessor->getPropertyValue($result, $local));
}
$this->storage->write($entity, $this->definition->entity())->execute();
$this->accessor->setPropertyValue($result, $this->definition->container(), $entity);
return $result;
}
|
php
|
public function write(&$result)
{
$entity = $this->accessor->getPropertyValue($result, $this->definition->container());
if (empty($entity)) {
$conditions = [];
foreach ($this->definition->keys() as $local => $foreign) {
$conditions[$foreign][] = $this->accessor->getPropertyValue($result, $local);
}
$this->cleanup($this->definition->entity(), [], $conditions);
return $result;
}
$this->assertInstance($entity);
foreach ($this->definition->keys() as $local => $foreign) {
$this->accessor->setPropertyValue($entity, $foreign, $this->accessor->getPropertyValue($result, $local));
}
$this->storage->write($entity, $this->definition->entity())->execute();
$this->accessor->setPropertyValue($result, $this->definition->container(), $entity);
return $result;
}
|
[
"public",
"function",
"write",
"(",
"&",
"$",
"result",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"accessor",
"->",
"getPropertyValue",
"(",
"$",
"result",
",",
"$",
"this",
"->",
"definition",
"->",
"container",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"entity",
")",
")",
"{",
"$",
"conditions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"definition",
"->",
"keys",
"(",
")",
"as",
"$",
"local",
"=>",
"$",
"foreign",
")",
"{",
"$",
"conditions",
"[",
"$",
"foreign",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"accessor",
"->",
"getPropertyValue",
"(",
"$",
"result",
",",
"$",
"local",
")",
";",
"}",
"$",
"this",
"->",
"cleanup",
"(",
"$",
"this",
"->",
"definition",
"->",
"entity",
"(",
")",
",",
"[",
"]",
",",
"$",
"conditions",
")",
";",
"return",
"$",
"result",
";",
"}",
"$",
"this",
"->",
"assertInstance",
"(",
"$",
"entity",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"definition",
"->",
"keys",
"(",
")",
"as",
"$",
"local",
"=>",
"$",
"foreign",
")",
"{",
"$",
"this",
"->",
"accessor",
"->",
"setPropertyValue",
"(",
"$",
"entity",
",",
"$",
"foreign",
",",
"$",
"this",
"->",
"accessor",
"->",
"getPropertyValue",
"(",
"$",
"result",
",",
"$",
"local",
")",
")",
";",
"}",
"$",
"this",
"->",
"storage",
"->",
"write",
"(",
"$",
"entity",
",",
"$",
"this",
"->",
"definition",
"->",
"entity",
"(",
")",
")",
"->",
"execute",
"(",
")",
";",
"$",
"this",
"->",
"accessor",
"->",
"setPropertyValue",
"(",
"$",
"result",
",",
"$",
"this",
"->",
"definition",
"->",
"container",
"(",
")",
",",
"$",
"entity",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Executes write fro one-to-one relation
@param array|\ArrayAccess $result
@return array|\ArrayAccess
@throws RelationException
|
[
"Executes",
"write",
"fro",
"one",
"-",
"to",
"-",
"one",
"relation"
] |
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
|
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/Relation/OneRelation.php#L68-L91
|
25,094
|
fuelphp-storage/session
|
src/Driver/Cookie.php
|
Cookie.encrypt
|
protected function encrypt($string)
{
// only if we want the cookie to be encrypted
if ($this->config['cookie']['encrypt_cookie'])
{
// we require the mcrypt PECL extension for this
if ( ! function_exists('mcrypt_encrypt'))
{
throw new \BadMethodCallException('The Session Cookie driver requires the PHP mcrypt extension to be installed.');
}
// create the encyption key
$key = hash('SHA256', $this->config['cookie']['crypt_key'], true);
// create the IV
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
if (strlen($iv_base64 = rtrim(base64_encode($iv), '=')) != 22)
{
// invalid IV
return false;
}
// construct the encrypted payload
$string = $iv_base64.base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $string.md5($string), MCRYPT_MODE_CBC, $iv));
}
return $string;
}
|
php
|
protected function encrypt($string)
{
// only if we want the cookie to be encrypted
if ($this->config['cookie']['encrypt_cookie'])
{
// we require the mcrypt PECL extension for this
if ( ! function_exists('mcrypt_encrypt'))
{
throw new \BadMethodCallException('The Session Cookie driver requires the PHP mcrypt extension to be installed.');
}
// create the encyption key
$key = hash('SHA256', $this->config['cookie']['crypt_key'], true);
// create the IV
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
if (strlen($iv_base64 = rtrim(base64_encode($iv), '=')) != 22)
{
// invalid IV
return false;
}
// construct the encrypted payload
$string = $iv_base64.base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $string.md5($string), MCRYPT_MODE_CBC, $iv));
}
return $string;
}
|
[
"protected",
"function",
"encrypt",
"(",
"$",
"string",
")",
"{",
"// only if we want the cookie to be encrypted",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'cookie'",
"]",
"[",
"'encrypt_cookie'",
"]",
")",
"{",
"// we require the mcrypt PECL extension for this",
"if",
"(",
"!",
"function_exists",
"(",
"'mcrypt_encrypt'",
")",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"'The Session Cookie driver requires the PHP mcrypt extension to be installed.'",
")",
";",
"}",
"// create the encyption key",
"$",
"key",
"=",
"hash",
"(",
"'SHA256'",
",",
"$",
"this",
"->",
"config",
"[",
"'cookie'",
"]",
"[",
"'crypt_key'",
"]",
",",
"true",
")",
";",
"// create the IV",
"$",
"iv",
"=",
"mcrypt_create_iv",
"(",
"mcrypt_get_iv_size",
"(",
"MCRYPT_RIJNDAEL_128",
",",
"MCRYPT_MODE_CBC",
")",
",",
"MCRYPT_RAND",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"iv_base64",
"=",
"rtrim",
"(",
"base64_encode",
"(",
"$",
"iv",
")",
",",
"'='",
")",
")",
"!=",
"22",
")",
"{",
"// invalid IV",
"return",
"false",
";",
"}",
"// construct the encrypted payload",
"$",
"string",
"=",
"$",
"iv_base64",
".",
"base64_encode",
"(",
"mcrypt_encrypt",
"(",
"MCRYPT_RIJNDAEL_128",
",",
"$",
"key",
",",
"$",
"string",
".",
"md5",
"(",
"$",
"string",
")",
",",
"MCRYPT_MODE_CBC",
",",
"$",
"iv",
")",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
] |
Encrypts a string using the crypt_key configured in the config
@param string $string
@return string
@throws \BadMethodCallException if the required mcrypt extension is not installed
|
[
"Encrypts",
"a",
"string",
"using",
"the",
"crypt_key",
"configured",
"in",
"the",
"config"
] |
948fd2b45286e65e7fababf65de89ca6aaca3c4a
|
https://github.com/fuelphp-storage/session/blob/948fd2b45286e65e7fababf65de89ca6aaca3c4a/src/Driver/Cookie.php#L199-L226
|
25,095
|
fuelphp-storage/session
|
src/Driver/Cookie.php
|
Cookie.decrypt
|
protected function decrypt($string)
{
// only if we want the cookie to be encrypted
if ($this->config['cookie']['encrypt_cookie'])
{
// we require the mcrypt PECL extension for this
if ( ! function_exists('mcrypt_decrypt'))
{
throw new \BadMethodCallException('The Session Cookie driver requires the PHP mcrypt extension to be installed.');
}
// create the encyption key
$key = hash('SHA256', $this->config['cookie']['crypt_key'], true);
// key the IV from the payload
$iv = base64_decode(substr($string, 0, 22) . '==');
$string = substr($string, 22);
// decrypt the payload
$string = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($string), MCRYPT_MODE_CBC, $iv), "\0\4");
// split the hash from the payload
$hash = substr($string, -32);
$string = substr($string, 0, -32);
// double-check it wasn't tampered with
if (md5($string) != $hash)
{
return false;
}
}
return $string;
}
|
php
|
protected function decrypt($string)
{
// only if we want the cookie to be encrypted
if ($this->config['cookie']['encrypt_cookie'])
{
// we require the mcrypt PECL extension for this
if ( ! function_exists('mcrypt_decrypt'))
{
throw new \BadMethodCallException('The Session Cookie driver requires the PHP mcrypt extension to be installed.');
}
// create the encyption key
$key = hash('SHA256', $this->config['cookie']['crypt_key'], true);
// key the IV from the payload
$iv = base64_decode(substr($string, 0, 22) . '==');
$string = substr($string, 22);
// decrypt the payload
$string = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($string), MCRYPT_MODE_CBC, $iv), "\0\4");
// split the hash from the payload
$hash = substr($string, -32);
$string = substr($string, 0, -32);
// double-check it wasn't tampered with
if (md5($string) != $hash)
{
return false;
}
}
return $string;
}
|
[
"protected",
"function",
"decrypt",
"(",
"$",
"string",
")",
"{",
"// only if we want the cookie to be encrypted",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'cookie'",
"]",
"[",
"'encrypt_cookie'",
"]",
")",
"{",
"// we require the mcrypt PECL extension for this",
"if",
"(",
"!",
"function_exists",
"(",
"'mcrypt_decrypt'",
")",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"'The Session Cookie driver requires the PHP mcrypt extension to be installed.'",
")",
";",
"}",
"// create the encyption key",
"$",
"key",
"=",
"hash",
"(",
"'SHA256'",
",",
"$",
"this",
"->",
"config",
"[",
"'cookie'",
"]",
"[",
"'crypt_key'",
"]",
",",
"true",
")",
";",
"// key the IV from the payload",
"$",
"iv",
"=",
"base64_decode",
"(",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"22",
")",
".",
"'=='",
")",
";",
"$",
"string",
"=",
"substr",
"(",
"$",
"string",
",",
"22",
")",
";",
"// decrypt the payload",
"$",
"string",
"=",
"rtrim",
"(",
"mcrypt_decrypt",
"(",
"MCRYPT_RIJNDAEL_128",
",",
"$",
"key",
",",
"base64_decode",
"(",
"$",
"string",
")",
",",
"MCRYPT_MODE_CBC",
",",
"$",
"iv",
")",
",",
"\"\\0\\4\"",
")",
";",
"// split the hash from the payload",
"$",
"hash",
"=",
"substr",
"(",
"$",
"string",
",",
"-",
"32",
")",
";",
"$",
"string",
"=",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"-",
"32",
")",
";",
"// double-check it wasn't tampered with",
"if",
"(",
"md5",
"(",
"$",
"string",
")",
"!=",
"$",
"hash",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"$",
"string",
";",
"}"
] |
Decrypts a string using the crypt_key configured in the config
@param string $string
@return string
@throws \BadMethodCallException if the required mcrypt extension is not installed
|
[
"Decrypts",
"a",
"string",
"using",
"the",
"crypt_key",
"configured",
"in",
"the",
"config"
] |
948fd2b45286e65e7fababf65de89ca6aaca3c4a
|
https://github.com/fuelphp-storage/session/blob/948fd2b45286e65e7fababf65de89ca6aaca3c4a/src/Driver/Cookie.php#L237-L270
|
25,096
|
joegreen88/zf1-component-validate
|
src/Zend/Validate/Db/Abstract.php
|
Zend_Validate_Db_Abstract.getAdapter
|
public function getAdapter()
{
/**
* Check for an adapter being defined. if not, fetch the default adapter.
*/
if ($this->_adapter === null) {
$this->_adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
if (null === $this->_adapter) {
throw new Zend_Validate_Exception('No database adapter present');
}
}
return $this->_adapter;
}
|
php
|
public function getAdapter()
{
/**
* Check for an adapter being defined. if not, fetch the default adapter.
*/
if ($this->_adapter === null) {
$this->_adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
if (null === $this->_adapter) {
throw new Zend_Validate_Exception('No database adapter present');
}
}
return $this->_adapter;
}
|
[
"public",
"function",
"getAdapter",
"(",
")",
"{",
"/**\n * Check for an adapter being defined. if not, fetch the default adapter.\n */",
"if",
"(",
"$",
"this",
"->",
"_adapter",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_adapter",
"=",
"Zend_Db_Table_Abstract",
"::",
"getDefaultAdapter",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"_adapter",
")",
"{",
"throw",
"new",
"Zend_Validate_Exception",
"(",
"'No database adapter present'",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_adapter",
";",
"}"
] |
Returns the set adapter
@return Zend_Db_Adapter
|
[
"Returns",
"the",
"set",
"adapter"
] |
88d9ea016f73d48ff0ba7d06ecbbf28951fd279e
|
https://github.com/joegreen88/zf1-component-validate/blob/88d9ea016f73d48ff0ba7d06ecbbf28951fd279e/src/Zend/Validate/Db/Abstract.php#L156-L169
|
25,097
|
bytic/http
|
src/Request/RequestAwareTrait.php
|
RequestAwareTrait.getRequest
|
public function getRequest($autoInit = false)
{
$this->setAutoInitRequest($autoInit);
if ($this->request == null && $this->isAutoInitRequest()) {
$this->initRequest();
}
return $this->request;
}
|
php
|
public function getRequest($autoInit = false)
{
$this->setAutoInitRequest($autoInit);
if ($this->request == null && $this->isAutoInitRequest()) {
$this->initRequest();
}
return $this->request;
}
|
[
"public",
"function",
"getRequest",
"(",
"$",
"autoInit",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"setAutoInitRequest",
"(",
"$",
"autoInit",
")",
";",
"if",
"(",
"$",
"this",
"->",
"request",
"==",
"null",
"&&",
"$",
"this",
"->",
"isAutoInitRequest",
"(",
")",
")",
"{",
"$",
"this",
"->",
"initRequest",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"request",
";",
"}"
] |
Get the Request.
@param bool $autoInit
@return Request
|
[
"Get",
"the",
"Request",
"."
] |
0d22507a8bcf05575d3d1d6c6a87c2026778c47c
|
https://github.com/bytic/http/blob/0d22507a8bcf05575d3d1d6c6a87c2026778c47c/src/Request/RequestAwareTrait.php#L30-L38
|
25,098
|
bkstg/schedule-bundle
|
EventSubscriber/UserMenuSubscriber.php
|
UserMenuSubscriber.addScheduleMenuItem
|
public function addScheduleMenuItem(UserMenuCollectionEvent $event): void
{
// Get the menu from the event.
$menu = $event->getMenu();
// Create a separator first.
$separator = $this->factory->createItem('schedule_separator', [
'extras' => [
'separator' => true,
'translation_domain' => false,
],
]);
$menu->addChild($separator);
// Add link to user's calendar.
$schedule = $this->factory->createItem('menu_item.my_schedule', [
'route' => 'bkstg_calendar_personal',
'extras' => [
'icon' => 'calendar',
'translation_domain' => BkstgScheduleBundle::TRANSLATION_DOMAIN,
],
]);
$menu->addChild($schedule);
}
|
php
|
public function addScheduleMenuItem(UserMenuCollectionEvent $event): void
{
// Get the menu from the event.
$menu = $event->getMenu();
// Create a separator first.
$separator = $this->factory->createItem('schedule_separator', [
'extras' => [
'separator' => true,
'translation_domain' => false,
],
]);
$menu->addChild($separator);
// Add link to user's calendar.
$schedule = $this->factory->createItem('menu_item.my_schedule', [
'route' => 'bkstg_calendar_personal',
'extras' => [
'icon' => 'calendar',
'translation_domain' => BkstgScheduleBundle::TRANSLATION_DOMAIN,
],
]);
$menu->addChild($schedule);
}
|
[
"public",
"function",
"addScheduleMenuItem",
"(",
"UserMenuCollectionEvent",
"$",
"event",
")",
":",
"void",
"{",
"// Get the menu from the event.",
"$",
"menu",
"=",
"$",
"event",
"->",
"getMenu",
"(",
")",
";",
"// Create a separator first.",
"$",
"separator",
"=",
"$",
"this",
"->",
"factory",
"->",
"createItem",
"(",
"'schedule_separator'",
",",
"[",
"'extras'",
"=>",
"[",
"'separator'",
"=>",
"true",
",",
"'translation_domain'",
"=>",
"false",
",",
"]",
",",
"]",
")",
";",
"$",
"menu",
"->",
"addChild",
"(",
"$",
"separator",
")",
";",
"// Add link to user's calendar.",
"$",
"schedule",
"=",
"$",
"this",
"->",
"factory",
"->",
"createItem",
"(",
"'menu_item.my_schedule'",
",",
"[",
"'route'",
"=>",
"'bkstg_calendar_personal'",
",",
"'extras'",
"=>",
"[",
"'icon'",
"=>",
"'calendar'",
",",
"'translation_domain'",
"=>",
"BkstgScheduleBundle",
"::",
"TRANSLATION_DOMAIN",
",",
"]",
",",
"]",
")",
";",
"$",
"menu",
"->",
"addChild",
"(",
"$",
"schedule",
")",
";",
"}"
] |
Add the schedule items to the user menu.
@param UserMenuCollectionEvent $event The menu collection event.
@return void
|
[
"Add",
"the",
"schedule",
"items",
"to",
"the",
"user",
"menu",
"."
] |
e64ac897aa7b28bc48319470d65de13cd4788afe
|
https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/EventSubscriber/UserMenuSubscriber.php#L67-L90
|
25,099
|
bkstg/schedule-bundle
|
EventSubscriber/UserMenuSubscriber.php
|
UserMenuSubscriber.addInvitationsMenuItem
|
public function addInvitationsMenuItem(UserMenuCollectionEvent $event): void
{
// Get the menu from the event.
$menu = $event->getMenu();
// Lookup and count pending invitations.
$repo = $this->em->getRepository(Invitation::class);
$user = $this->token_storage->getToken()->getUser();
$invitations = $repo->findPendingInvitations($user);
// Create the pending invitations menu link.
$invitations = $this->factory->createItem('menu_item.pending_invitations', [
'route' => 'bkstg_invitation_index',
'extras' => [
'badge_count' => count($invitations),
'translation_domain' => BkstgScheduleBundle::TRANSLATION_DOMAIN,
],
]);
$menu->addChild($invitations);
}
|
php
|
public function addInvitationsMenuItem(UserMenuCollectionEvent $event): void
{
// Get the menu from the event.
$menu = $event->getMenu();
// Lookup and count pending invitations.
$repo = $this->em->getRepository(Invitation::class);
$user = $this->token_storage->getToken()->getUser();
$invitations = $repo->findPendingInvitations($user);
// Create the pending invitations menu link.
$invitations = $this->factory->createItem('menu_item.pending_invitations', [
'route' => 'bkstg_invitation_index',
'extras' => [
'badge_count' => count($invitations),
'translation_domain' => BkstgScheduleBundle::TRANSLATION_DOMAIN,
],
]);
$menu->addChild($invitations);
}
|
[
"public",
"function",
"addInvitationsMenuItem",
"(",
"UserMenuCollectionEvent",
"$",
"event",
")",
":",
"void",
"{",
"// Get the menu from the event.",
"$",
"menu",
"=",
"$",
"event",
"->",
"getMenu",
"(",
")",
";",
"// Lookup and count pending invitations.",
"$",
"repo",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"Invitation",
"::",
"class",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"token_storage",
"->",
"getToken",
"(",
")",
"->",
"getUser",
"(",
")",
";",
"$",
"invitations",
"=",
"$",
"repo",
"->",
"findPendingInvitations",
"(",
"$",
"user",
")",
";",
"// Create the pending invitations menu link.",
"$",
"invitations",
"=",
"$",
"this",
"->",
"factory",
"->",
"createItem",
"(",
"'menu_item.pending_invitations'",
",",
"[",
"'route'",
"=>",
"'bkstg_invitation_index'",
",",
"'extras'",
"=>",
"[",
"'badge_count'",
"=>",
"count",
"(",
"$",
"invitations",
")",
",",
"'translation_domain'",
"=>",
"BkstgScheduleBundle",
"::",
"TRANSLATION_DOMAIN",
",",
"]",
",",
"]",
")",
";",
"$",
"menu",
"->",
"addChild",
"(",
"$",
"invitations",
")",
";",
"}"
] |
Add invitations menu item.
@param UserMenuCollectionEvent $event The menu collection event.
@return void
|
[
"Add",
"invitations",
"menu",
"item",
"."
] |
e64ac897aa7b28bc48319470d65de13cd4788afe
|
https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/EventSubscriber/UserMenuSubscriber.php#L99-L118
|
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.