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
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
5,600 | znframework/package-security | CrossSiteScripting.php | CrossSiteScripting.encode | public static function encode(String $string) : String
{
$secBadChars = self::$scriptBadChars;
if( ! empty($secBadChars) )
{
foreach( $secBadChars as $badChar => $changeChar )
{
if( is_numeric($badChar) )
{
$badChar = $changeChar;
$changeChar = '';
}
$badChar = trim($badChar, '/');
$string = preg_replace('/'.$badChar.'/xi', $changeChar, $string);
}
}
return $string;
} | php | public static function encode(String $string) : String
{
$secBadChars = self::$scriptBadChars;
if( ! empty($secBadChars) )
{
foreach( $secBadChars as $badChar => $changeChar )
{
if( is_numeric($badChar) )
{
$badChar = $changeChar;
$changeChar = '';
}
$badChar = trim($badChar, '/');
$string = preg_replace('/'.$badChar.'/xi', $changeChar, $string);
}
}
return $string;
} | [
"public",
"static",
"function",
"encode",
"(",
"String",
"$",
"string",
")",
":",
"String",
"{",
"$",
"secBadChars",
"=",
"self",
"::",
"$",
"scriptBadChars",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"secBadChars",
")",
")",
"{",
"foreach",
"(",
"$",
"secBadChars",
"as",
"$",
"badChar",
"=>",
"$",
"changeChar",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"badChar",
")",
")",
"{",
"$",
"badChar",
"=",
"$",
"changeChar",
";",
"$",
"changeChar",
"=",
"''",
";",
"}",
"$",
"badChar",
"=",
"trim",
"(",
"$",
"badChar",
",",
"'/'",
")",
";",
"$",
"string",
"=",
"preg_replace",
"(",
"'/'",
".",
"$",
"badChar",
".",
"'/xi'",
",",
"$",
"changeChar",
",",
"$",
"string",
")",
";",
"}",
"}",
"return",
"$",
"string",
";",
"}"
] | Encode Cross Site Scripting
@param string $string
@return string | [
"Encode",
"Cross",
"Site",
"Scripting"
] | dfced60e243ab9f52a1b5bbdb695bfc39b26cac0 | https://github.com/znframework/package-security/blob/dfced60e243ab9f52a1b5bbdb695bfc39b26cac0/CrossSiteScripting.php#L37-L58 |
5,601 | mirko-pagliai/cakephp-tokens | src/Utility/TokenTrait.php | TokenTrait.check | public function check($token, array $options = [])
{
$conditions = compact('token');
foreach (['user_id', 'type'] as $key) {
$conditions[$key] = array_key_exists($key, $options) ? $options[$key] : null;
}
return !$this->find($conditions)->isEmpty();
} | php | public function check($token, array $options = [])
{
$conditions = compact('token');
foreach (['user_id', 'type'] as $key) {
$conditions[$key] = array_key_exists($key, $options) ? $options[$key] : null;
}
return !$this->find($conditions)->isEmpty();
} | [
"public",
"function",
"check",
"(",
"$",
"token",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"conditions",
"=",
"compact",
"(",
"'token'",
")",
";",
"foreach",
"(",
"[",
"'user_id'",
",",
"'type'",
"]",
"as",
"$",
"key",
")",
"{",
"$",
"conditions",
"[",
"$",
"key",
"]",
"=",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"options",
")",
"?",
"$",
"options",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}",
"return",
"!",
"$",
"this",
"->",
"find",
"(",
"$",
"conditions",
")",
"->",
"isEmpty",
"(",
")",
";",
"}"
] | Checks if a token exists and is active.
Valid optios values: `user_id`, `type`.
Be careful: if the token has these options, then you must set them.
In other words, blank options will be replaced with `null`.
@param string $token Token value
@param array $options Options
@return bool
@uses find() | [
"Checks",
"if",
"a",
"token",
"exists",
"and",
"is",
"active",
"."
] | 1e6e2fb4bdabc1e3801c428775813d2a2f022ae7 | https://github.com/mirko-pagliai/cakephp-tokens/blob/1e6e2fb4bdabc1e3801c428775813d2a2f022ae7/src/Utility/TokenTrait.php#L57-L66 |
5,602 | mirko-pagliai/cakephp-tokens | src/Utility/TokenTrait.php | TokenTrait.create | public function create($token, array $options = [])
{
$entity = new Token(compact('token'));
foreach (['user_id', 'type', 'extra', 'expiry'] as $key) {
if (array_key_exists($key, $options)) {
$entity->set($key, $options[$key]);
}
}
if (!$this->getTable()->save($entity)) {
$field = collection(array_keys($entity->getErrors()))->first();
$error = collection(collection(($entity->getErrors()))->first())->first();
throw new LogicException(sprintf('Error for `%s` field: %s', $field, lcfirst($error)));
}
return $entity->token;
} | php | public function create($token, array $options = [])
{
$entity = new Token(compact('token'));
foreach (['user_id', 'type', 'extra', 'expiry'] as $key) {
if (array_key_exists($key, $options)) {
$entity->set($key, $options[$key]);
}
}
if (!$this->getTable()->save($entity)) {
$field = collection(array_keys($entity->getErrors()))->first();
$error = collection(collection(($entity->getErrors()))->first())->first();
throw new LogicException(sprintf('Error for `%s` field: %s', $field, lcfirst($error)));
}
return $entity->token;
} | [
"public",
"function",
"create",
"(",
"$",
"token",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"entity",
"=",
"new",
"Token",
"(",
"compact",
"(",
"'token'",
")",
")",
";",
"foreach",
"(",
"[",
"'user_id'",
",",
"'type'",
",",
"'extra'",
",",
"'expiry'",
"]",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"options",
")",
")",
"{",
"$",
"entity",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"options",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"save",
"(",
"$",
"entity",
")",
")",
"{",
"$",
"field",
"=",
"collection",
"(",
"array_keys",
"(",
"$",
"entity",
"->",
"getErrors",
"(",
")",
")",
")",
"->",
"first",
"(",
")",
";",
"$",
"error",
"=",
"collection",
"(",
"collection",
"(",
"(",
"$",
"entity",
"->",
"getErrors",
"(",
")",
")",
")",
"->",
"first",
"(",
")",
")",
"->",
"first",
"(",
")",
";",
"throw",
"new",
"LogicException",
"(",
"sprintf",
"(",
"'Error for `%s` field: %s'",
",",
"$",
"field",
",",
"lcfirst",
"(",
"$",
"error",
")",
")",
")",
";",
"}",
"return",
"$",
"entity",
"->",
"token",
";",
"}"
] | Creates a token.
Valid optios values: `user_id`, `type`, `extra`, `expiry`.
@param string $token Token value
@param array $options Options
@return string Token value
@throws LogicException
@uses getTable() | [
"Creates",
"a",
"token",
"."
] | 1e6e2fb4bdabc1e3801c428775813d2a2f022ae7 | https://github.com/mirko-pagliai/cakephp-tokens/blob/1e6e2fb4bdabc1e3801c428775813d2a2f022ae7/src/Utility/TokenTrait.php#L78-L96 |
5,603 | mirko-pagliai/cakephp-tokens | src/Utility/TokenTrait.php | TokenTrait.delete | public function delete($token)
{
$query = $this->find(compact('token'));
return $query->count() ? $this->getTable()->delete($query->first()) : false;
} | php | public function delete($token)
{
$query = $this->find(compact('token'));
return $query->count() ? $this->getTable()->delete($query->first()) : false;
} | [
"public",
"function",
"delete",
"(",
"$",
"token",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"find",
"(",
"compact",
"(",
"'token'",
")",
")",
";",
"return",
"$",
"query",
"->",
"count",
"(",
")",
"?",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"delete",
"(",
"$",
"query",
"->",
"first",
"(",
")",
")",
":",
"false",
";",
"}"
] | Deletes a token
@param string $token Token value
@return bool
@uses find()
@uses getTable() | [
"Deletes",
"a",
"token"
] | 1e6e2fb4bdabc1e3801c428775813d2a2f022ae7 | https://github.com/mirko-pagliai/cakephp-tokens/blob/1e6e2fb4bdabc1e3801c428775813d2a2f022ae7/src/Utility/TokenTrait.php#L105-L110 |
5,604 | delboy1978uk/bone | src/Mvc/Router.php | Router.setCustomRoutesFromConfig | private function setCustomRoutesFromConfig()
{
// we be checkin' our instruction fer configgered routes
$configgeration = Registry::ahoy()->get('routes');
// stick some voodoo pins in the map
foreach ($configgeration as $route => $options) {
// add the route t' the map
$this->routes[] = new Route($route, $options);
}
} | php | private function setCustomRoutesFromConfig()
{
// we be checkin' our instruction fer configgered routes
$configgeration = Registry::ahoy()->get('routes');
// stick some voodoo pins in the map
foreach ($configgeration as $route => $options) {
// add the route t' the map
$this->routes[] = new Route($route, $options);
}
} | [
"private",
"function",
"setCustomRoutesFromConfig",
"(",
")",
"{",
"// we be checkin' our instruction fer configgered routes",
"$",
"configgeration",
"=",
"Registry",
"::",
"ahoy",
"(",
")",
"->",
"get",
"(",
"'routes'",
")",
";",
"// stick some voodoo pins in the map",
"foreach",
"(",
"$",
"configgeration",
"as",
"$",
"route",
"=>",
"$",
"options",
")",
"{",
"// add the route t' the map",
"$",
"this",
"->",
"routes",
"[",
"]",
"=",
"new",
"Route",
"(",
"$",
"route",
",",
"$",
"options",
")",
";",
"}",
"}"
] | gets custom routes from config | [
"gets",
"custom",
"routes",
"from",
"config"
] | dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268 | https://github.com/delboy1978uk/bone/blob/dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268/src/Mvc/Router.php#L128-L138 |
5,605 | delboy1978uk/bone | src/Mvc/Router.php | Router.setParams | private function setParams()
{
// be addin' the $_GET an' $_POST t' th' params!
$method = $this->request->getMethod();
$getParams = $this->request->getQueryParams();
$postParams = $this->request->getParsedBody();
if ($method == "POST" && is_array($postParams)) {
$this->params = array_merge($this->params, $postParams);
}
$this->params = array_merge($this->params, $getParams);
} | php | private function setParams()
{
// be addin' the $_GET an' $_POST t' th' params!
$method = $this->request->getMethod();
$getParams = $this->request->getQueryParams();
$postParams = $this->request->getParsedBody();
if ($method == "POST" && is_array($postParams)) {
$this->params = array_merge($this->params, $postParams);
}
$this->params = array_merge($this->params, $getParams);
} | [
"private",
"function",
"setParams",
"(",
")",
"{",
"// be addin' the $_GET an' $_POST t' th' params!",
"$",
"method",
"=",
"$",
"this",
"->",
"request",
"->",
"getMethod",
"(",
")",
";",
"$",
"getParams",
"=",
"$",
"this",
"->",
"request",
"->",
"getQueryParams",
"(",
")",
";",
"$",
"postParams",
"=",
"$",
"this",
"->",
"request",
"->",
"getParsedBody",
"(",
")",
";",
"if",
"(",
"$",
"method",
"==",
"\"POST\"",
"&&",
"is_array",
"(",
"$",
"postParams",
")",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"params",
",",
"$",
"postParams",
")",
";",
"}",
"$",
"this",
"->",
"params",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"params",
",",
"$",
"getParams",
")",
";",
"}"
] | Merges params from config | [
"Merges",
"params",
"from",
"config"
] | dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268 | https://github.com/delboy1978uk/bone/blob/dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268/src/Mvc/Router.php#L144-L154 |
5,606 | delboy1978uk/bone | src/Mvc/Router.php | Router.parseRoute | public function parseRoute()
{
// start at the home page
$this->sailHome();
// which way be we goin' ?
$path = $this->uri;
// Has th' route been set?
if ($path != '/') {
// Set the routes configgerd in th' config.php
$this->setCustomRoutesFromConfig();
// Match the feckin' route ya blubberin' seadog!
$this->matchRoute();
}
// Merge th' GET POST and config params
$this->setParams();
} | php | public function parseRoute()
{
// start at the home page
$this->sailHome();
// which way be we goin' ?
$path = $this->uri;
// Has th' route been set?
if ($path != '/') {
// Set the routes configgerd in th' config.php
$this->setCustomRoutesFromConfig();
// Match the feckin' route ya blubberin' seadog!
$this->matchRoute();
}
// Merge th' GET POST and config params
$this->setParams();
} | [
"public",
"function",
"parseRoute",
"(",
")",
"{",
"// start at the home page",
"$",
"this",
"->",
"sailHome",
"(",
")",
";",
"// which way be we goin' ?",
"$",
"path",
"=",
"$",
"this",
"->",
"uri",
";",
"// Has th' route been set?",
"if",
"(",
"$",
"path",
"!=",
"'/'",
")",
"{",
"// Set the routes configgerd in th' config.php",
"$",
"this",
"->",
"setCustomRoutesFromConfig",
"(",
")",
";",
"// Match the feckin' route ya blubberin' seadog!",
"$",
"this",
"->",
"matchRoute",
"(",
")",
";",
"}",
"// Merge th' GET POST and config params",
"$",
"this",
"->",
"setParams",
"(",
")",
";",
"}"
] | Figger out where we be goin' | [
"Figger",
"out",
"where",
"we",
"be",
"goin"
] | dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268 | https://github.com/delboy1978uk/bone/blob/dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268/src/Mvc/Router.php#L208-L227 |
5,607 | frozensheep/synthesize | src/Synthesize.php | Synthesize.setupWithArray | public function setupWithArray(Array $arrData){
foreach($arrData as $strProperty => $mixOptions){
if(!is_array($mixOptions)){
$strProperty = $mixOptions;
$mixOptions = array();
}
$strProperty = $this->_formatPropertyName($strProperty);
$this->_arrProperties[] = $strProperty;
$this->_arrOptions[$strProperty] = new SynthesizeOption($mixOptions);
$this->_arrData[$strProperty] = $this->_create($this->_arrOptions[$strProperty]);
}
} | php | public function setupWithArray(Array $arrData){
foreach($arrData as $strProperty => $mixOptions){
if(!is_array($mixOptions)){
$strProperty = $mixOptions;
$mixOptions = array();
}
$strProperty = $this->_formatPropertyName($strProperty);
$this->_arrProperties[] = $strProperty;
$this->_arrOptions[$strProperty] = new SynthesizeOption($mixOptions);
$this->_arrData[$strProperty] = $this->_create($this->_arrOptions[$strProperty]);
}
} | [
"public",
"function",
"setupWithArray",
"(",
"Array",
"$",
"arrData",
")",
"{",
"foreach",
"(",
"$",
"arrData",
"as",
"$",
"strProperty",
"=>",
"$",
"mixOptions",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"mixOptions",
")",
")",
"{",
"$",
"strProperty",
"=",
"$",
"mixOptions",
";",
"$",
"mixOptions",
"=",
"array",
"(",
")",
";",
"}",
"$",
"strProperty",
"=",
"$",
"this",
"->",
"_formatPropertyName",
"(",
"$",
"strProperty",
")",
";",
"$",
"this",
"->",
"_arrProperties",
"[",
"]",
"=",
"$",
"strProperty",
";",
"$",
"this",
"->",
"_arrOptions",
"[",
"$",
"strProperty",
"]",
"=",
"new",
"SynthesizeOption",
"(",
"$",
"mixOptions",
")",
";",
"$",
"this",
"->",
"_arrData",
"[",
"$",
"strProperty",
"]",
"=",
"$",
"this",
"->",
"_create",
"(",
"$",
"this",
"->",
"_arrOptions",
"[",
"$",
"strProperty",
"]",
")",
";",
"}",
"}"
] | Setup With Array Method
Sets up the object using an array of options.
@param array $arrData The options in array format.
@return void | [
"Setup",
"With",
"Array",
"Method"
] | 18e4ece4f02ad2fbd5510eac6342b8c2d31ccc51 | https://github.com/frozensheep/synthesize/blob/18e4ece4f02ad2fbd5510eac6342b8c2d31ccc51/src/Synthesize.php#L84-L96 |
5,608 | frozensheep/synthesize | src/Synthesize.php | Synthesize.setupWithJSON | public function setupWithJSON($strData){
if($arrData = json_decode($strData, true)){
$this->setupWithArray($arrData);
}else{
throw new InvalidJSONException($strData);
}
} | php | public function setupWithJSON($strData){
if($arrData = json_decode($strData, true)){
$this->setupWithArray($arrData);
}else{
throw new InvalidJSONException($strData);
}
} | [
"public",
"function",
"setupWithJSON",
"(",
"$",
"strData",
")",
"{",
"if",
"(",
"$",
"arrData",
"=",
"json_decode",
"(",
"$",
"strData",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"setupWithArray",
"(",
"$",
"arrData",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidJSONException",
"(",
"$",
"strData",
")",
";",
"}",
"}"
] | Setup With JSON Method
Sets up the object using a string of JSON.
@param string $strData The options in JSON.
@return void | [
"Setup",
"With",
"JSON",
"Method"
] | 18e4ece4f02ad2fbd5510eac6342b8c2d31ccc51 | https://github.com/frozensheep/synthesize/blob/18e4ece4f02ad2fbd5510eac6342b8c2d31ccc51/src/Synthesize.php#L105-L111 |
5,609 | frozensheep/synthesize | src/Synthesize.php | Synthesize.asObject | public function asObject($strProperty){
$strProperty = $this->_formatPropertyName($strProperty);
return $this->_arrData[$strProperty]->asObject();
} | php | public function asObject($strProperty){
$strProperty = $this->_formatPropertyName($strProperty);
return $this->_arrData[$strProperty]->asObject();
} | [
"public",
"function",
"asObject",
"(",
"$",
"strProperty",
")",
"{",
"$",
"strProperty",
"=",
"$",
"this",
"->",
"_formatPropertyName",
"(",
"$",
"strProperty",
")",
";",
"return",
"$",
"this",
"->",
"_arrData",
"[",
"$",
"strProperty",
"]",
"->",
"asObject",
"(",
")",
";",
"}"
] | As Object Method
Returns the full object of the property requested.
@param string $strProperty The name of the value you want to get.
@return object | [
"As",
"Object",
"Method"
] | 18e4ece4f02ad2fbd5510eac6342b8c2d31ccc51 | https://github.com/frozensheep/synthesize/blob/18e4ece4f02ad2fbd5510eac6342b8c2d31ccc51/src/Synthesize.php#L131-L134 |
5,610 | frozensheep/synthesize | src/Synthesize.php | Synthesize.setObject | public function setObject($strProperty, $mixValue){
$strProperty = $this->_formatPropertyName($strProperty);
$this->_arrData[$strProperty] = $mixValue;
} | php | public function setObject($strProperty, $mixValue){
$strProperty = $this->_formatPropertyName($strProperty);
$this->_arrData[$strProperty] = $mixValue;
} | [
"public",
"function",
"setObject",
"(",
"$",
"strProperty",
",",
"$",
"mixValue",
")",
"{",
"$",
"strProperty",
"=",
"$",
"this",
"->",
"_formatPropertyName",
"(",
"$",
"strProperty",
")",
";",
"$",
"this",
"->",
"_arrData",
"[",
"$",
"strProperty",
"]",
"=",
"$",
"mixValue",
";",
"}"
] | Set Object Method
Sets an object for the property.
@param string $strProperty The property name.
@param mixed $mixValue The value to set.
@return void | [
"Set",
"Object",
"Method"
] | 18e4ece4f02ad2fbd5510eac6342b8c2d31ccc51 | https://github.com/frozensheep/synthesize/blob/18e4ece4f02ad2fbd5510eac6342b8c2d31ccc51/src/Synthesize.php#L157-L160 |
5,611 | frozensheep/synthesize | src/Synthesize.php | Synthesize.hasProperty | public function hasProperty($strProperty){
$strProperty = $this->_formatPropertyName($strProperty);
if(in_array($strProperty, $this->_arrProperties)){
return true;
}
return false;
} | php | public function hasProperty($strProperty){
$strProperty = $this->_formatPropertyName($strProperty);
if(in_array($strProperty, $this->_arrProperties)){
return true;
}
return false;
} | [
"public",
"function",
"hasProperty",
"(",
"$",
"strProperty",
")",
"{",
"$",
"strProperty",
"=",
"$",
"this",
"->",
"_formatPropertyName",
"(",
"$",
"strProperty",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"strProperty",
",",
"$",
"this",
"->",
"_arrProperties",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Has Property Method
Checks to see if a given property is set.
@param string $strProperty The property you want to check.
@return true|false | [
"Has",
"Property",
"Method"
] | 18e4ece4f02ad2fbd5510eac6342b8c2d31ccc51 | https://github.com/frozensheep/synthesize/blob/18e4ece4f02ad2fbd5510eac6342b8c2d31ccc51/src/Synthesize.php#L181-L187 |
5,612 | Danack/HTTP | src/Room11/HTTP/HeadersSet.php | HeadersSet.getHeaders | public function getHeaders($name)
{
$ucName = strtoupper($name);
if (isset($this->ucNames[$ucName])) {
$name = $this->ucNames[$ucName];
return $this->headers[$name];
}
throw new HTTPException(
sprintf('Header field is not assigned: %s', $name)
);
} | php | public function getHeaders($name)
{
$ucName = strtoupper($name);
if (isset($this->ucNames[$ucName])) {
$name = $this->ucNames[$ucName];
return $this->headers[$name];
}
throw new HTTPException(
sprintf('Header field is not assigned: %s', $name)
);
} | [
"public",
"function",
"getHeaders",
"(",
"$",
"name",
")",
"{",
"$",
"ucName",
"=",
"strtoupper",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"ucNames",
"[",
"$",
"ucName",
"]",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"ucNames",
"[",
"$",
"ucName",
"]",
";",
"return",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
";",
"}",
"throw",
"new",
"HTTPException",
"(",
"sprintf",
"(",
"'Header field is not assigned: %s'",
",",
"$",
"name",
")",
")",
";",
"}"
] | Retrieve assigned header values for the specified field name
@param string $name
@throws \Room11\HTTP\HTTPException
@return array | [
"Retrieve",
"assigned",
"header",
"values",
"for",
"the",
"specified",
"field",
"name"
] | c4e19668b21de0c00bfaa1e0d1a18175764fd966 | https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/HeadersSet.php#L85-L97 |
5,613 | Danack/HTTP | src/Room11/HTTP/HeadersSet.php | HeadersSet.clearHeaders | public function clearHeaders($name)
{
$ucName = strtoupper($name);
if (isset($this->ucNames[$ucName])) {
$name = $this->ucNames[$ucName];
unset($this->ucNames[$ucName]);
unset($this->headers[$name]);
}
} | php | public function clearHeaders($name)
{
$ucName = strtoupper($name);
if (isset($this->ucNames[$ucName])) {
$name = $this->ucNames[$ucName];
unset($this->ucNames[$ucName]);
unset($this->headers[$name]);
}
} | [
"public",
"function",
"clearHeaders",
"(",
"$",
"name",
")",
"{",
"$",
"ucName",
"=",
"strtoupper",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"ucNames",
"[",
"$",
"ucName",
"]",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"ucNames",
"[",
"$",
"ucName",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"ucNames",
"[",
"$",
"ucName",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"headers",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}"
] | Remove all entries for a particular header name
@param $name | [
"Remove",
"all",
"entries",
"for",
"a",
"particular",
"header",
"name"
] | c4e19668b21de0c00bfaa1e0d1a18175764fd966 | https://github.com/Danack/HTTP/blob/c4e19668b21de0c00bfaa1e0d1a18175764fd966/src/Room11/HTTP/HeadersSet.php#L103-L111 |
5,614 | slickframework/mvc | src/Service/Entity/EntityUpdateService.php | EntityUpdateService.setForm | public function setForm(EntityForm $form)
{
if (!$form->isValid()) {
throw new InvalidFormDataException(
"Submitted form data is not valid."
);
}
$this->setData($form->getData());
$this->form = $form;
return $this;
} | php | public function setForm(EntityForm $form)
{
if (!$form->isValid()) {
throw new InvalidFormDataException(
"Submitted form data is not valid."
);
}
$this->setData($form->getData());
$this->form = $form;
return $this;
} | [
"public",
"function",
"setForm",
"(",
"EntityForm",
"$",
"form",
")",
"{",
"if",
"(",
"!",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidFormDataException",
"(",
"\"Submitted form data is not valid.\"",
")",
";",
"}",
"$",
"this",
"->",
"setData",
"(",
"$",
"form",
"->",
"getData",
"(",
")",
")",
";",
"$",
"this",
"->",
"form",
"=",
"$",
"form",
";",
"return",
"$",
"this",
";",
"}"
] | Set entity for
@param EntityForm $form
@return EntityUpdateService
@throws InvalidFormDataException If the provided form has invalid data | [
"Set",
"entity",
"for"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Service/Entity/EntityUpdateService.php#L102-L112 |
5,615 | vutran/wpmvc-core | src/Models/AjaxResponse.php | AjaxResponse.output | public function output()
{
header('Content-type: application/json');
$data = array(
'status' => $this->status,
'data' => $this->data
);
echo json_encode($data);
die();
} | php | public function output()
{
header('Content-type: application/json');
$data = array(
'status' => $this->status,
'data' => $this->data
);
echo json_encode($data);
die();
} | [
"public",
"function",
"output",
"(",
")",
"{",
"header",
"(",
"'Content-type: application/json'",
")",
";",
"$",
"data",
"=",
"array",
"(",
"'status'",
"=>",
"$",
"this",
"->",
"status",
",",
"'data'",
"=>",
"$",
"this",
"->",
"data",
")",
";",
"echo",
"json_encode",
"(",
"$",
"data",
")",
";",
"die",
"(",
")",
";",
"}"
] | Outputs the JSON response status and data
@access public
@return void | [
"Outputs",
"the",
"JSON",
"response",
"status",
"and",
"data"
] | 4081be36116ae8e79abfd182d783d28d0fb42219 | https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Models/AjaxResponse.php#L75-L84 |
5,616 | osflab/view | Helper/Bootstrap/Table.php | Table.getId | public function getId()
{
if (!isset($this->attributes['id'])) {
$this->buildIdAttr(Container::getRequest()->getParam(self::AI_KEY));
}
return $this->attributes['id'];
} | php | public function getId()
{
if (!isset($this->attributes['id'])) {
$this->buildIdAttr(Container::getRequest()->getParam(self::AI_KEY));
}
return $this->attributes['id'];
} | [
"public",
"function",
"getId",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"buildIdAttr",
"(",
"Container",
"::",
"getRequest",
"(",
")",
"->",
"getParam",
"(",
"self",
"::",
"AI_KEY",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"attributes",
"[",
"'id'",
"]",
";",
"}"
] | Id attribute of table element
@return string | [
"Id",
"attribute",
"of",
"table",
"element"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Table.php#L96-L102 |
5,617 | PentagonalProject/SlimService | src/Validator.php | Validator.getWebServerSoftWare | public static function getWebServerSoftWare() : string
{
static $type;
if (isset($type)) {
return $type;
}
$software = isset($_SERVER['SERVER_SOFTWARE'])
? $_SERVER['SERVER_SOFTWARE']
: null;
$type = self::SERVER_TYPE_UNKNOWN;
if (stripos($software, 'lighttpd') !== false) {
$type = self::SERVER_TYPE_LIGHTTPD;
}
if (strpos($software, 'Hiawatha') !== false) {
$type = self::SERVER_TYPE_HIAWATHA;
}
if (strpos($software, 'Apache') !== false) {
$type = self::SERVER_TYPE_APACHE;
} elseif (strpos($software, 'Litespeed') !== false) {
$type = self::SERVER_TYPE_LITESPEED;
}
if (strpos($software, 'nginx') !== false) {
$type = self::SERVER_TYPE_NGINX;
}
if ($type !== self::SERVER_TYPE_APACHE && $type !== self::SERVER_TYPE_LITESPEED
&& strpos($software, 'Microsoft-IIS') !== false
&& strpos($software, 'ExpressionDevServer') !== false
) {
$type = self::SERVER_TYPE_IIS;
if (intval(substr($software, strpos($software, 'Microsoft-IIS/')+14)) >= 7) {
$type = self::SERVER_TYPE_IIS7;
}
}
if (function_exists('apache_get_modules')) {
if (in_array('mod_security', apache_get_modules())) {
$type = self::SERVER_TYPE_APACHE;
}
if ($type == self::SERVER_TYPE_UNKNOWN && function_exists('apache_get_version')) {
$type = self::SERVER_TYPE_APACHE;
}
}
return $type;
} | php | public static function getWebServerSoftWare() : string
{
static $type;
if (isset($type)) {
return $type;
}
$software = isset($_SERVER['SERVER_SOFTWARE'])
? $_SERVER['SERVER_SOFTWARE']
: null;
$type = self::SERVER_TYPE_UNKNOWN;
if (stripos($software, 'lighttpd') !== false) {
$type = self::SERVER_TYPE_LIGHTTPD;
}
if (strpos($software, 'Hiawatha') !== false) {
$type = self::SERVER_TYPE_HIAWATHA;
}
if (strpos($software, 'Apache') !== false) {
$type = self::SERVER_TYPE_APACHE;
} elseif (strpos($software, 'Litespeed') !== false) {
$type = self::SERVER_TYPE_LITESPEED;
}
if (strpos($software, 'nginx') !== false) {
$type = self::SERVER_TYPE_NGINX;
}
if ($type !== self::SERVER_TYPE_APACHE && $type !== self::SERVER_TYPE_LITESPEED
&& strpos($software, 'Microsoft-IIS') !== false
&& strpos($software, 'ExpressionDevServer') !== false
) {
$type = self::SERVER_TYPE_IIS;
if (intval(substr($software, strpos($software, 'Microsoft-IIS/')+14)) >= 7) {
$type = self::SERVER_TYPE_IIS7;
}
}
if (function_exists('apache_get_modules')) {
if (in_array('mod_security', apache_get_modules())) {
$type = self::SERVER_TYPE_APACHE;
}
if ($type == self::SERVER_TYPE_UNKNOWN && function_exists('apache_get_version')) {
$type = self::SERVER_TYPE_APACHE;
}
}
return $type;
} | [
"public",
"static",
"function",
"getWebServerSoftWare",
"(",
")",
":",
"string",
"{",
"static",
"$",
"type",
";",
"if",
"(",
"isset",
"(",
"$",
"type",
")",
")",
"{",
"return",
"$",
"type",
";",
"}",
"$",
"software",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'SERVER_SOFTWARE'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'SERVER_SOFTWARE'",
"]",
":",
"null",
";",
"$",
"type",
"=",
"self",
"::",
"SERVER_TYPE_UNKNOWN",
";",
"if",
"(",
"stripos",
"(",
"$",
"software",
",",
"'lighttpd'",
")",
"!==",
"false",
")",
"{",
"$",
"type",
"=",
"self",
"::",
"SERVER_TYPE_LIGHTTPD",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"software",
",",
"'Hiawatha'",
")",
"!==",
"false",
")",
"{",
"$",
"type",
"=",
"self",
"::",
"SERVER_TYPE_HIAWATHA",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"software",
",",
"'Apache'",
")",
"!==",
"false",
")",
"{",
"$",
"type",
"=",
"self",
"::",
"SERVER_TYPE_APACHE",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"software",
",",
"'Litespeed'",
")",
"!==",
"false",
")",
"{",
"$",
"type",
"=",
"self",
"::",
"SERVER_TYPE_LITESPEED",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"software",
",",
"'nginx'",
")",
"!==",
"false",
")",
"{",
"$",
"type",
"=",
"self",
"::",
"SERVER_TYPE_NGINX",
";",
"}",
"if",
"(",
"$",
"type",
"!==",
"self",
"::",
"SERVER_TYPE_APACHE",
"&&",
"$",
"type",
"!==",
"self",
"::",
"SERVER_TYPE_LITESPEED",
"&&",
"strpos",
"(",
"$",
"software",
",",
"'Microsoft-IIS'",
")",
"!==",
"false",
"&&",
"strpos",
"(",
"$",
"software",
",",
"'ExpressionDevServer'",
")",
"!==",
"false",
")",
"{",
"$",
"type",
"=",
"self",
"::",
"SERVER_TYPE_IIS",
";",
"if",
"(",
"intval",
"(",
"substr",
"(",
"$",
"software",
",",
"strpos",
"(",
"$",
"software",
",",
"'Microsoft-IIS/'",
")",
"+",
"14",
")",
")",
">=",
"7",
")",
"{",
"$",
"type",
"=",
"self",
"::",
"SERVER_TYPE_IIS7",
";",
"}",
"}",
"if",
"(",
"function_exists",
"(",
"'apache_get_modules'",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"'mod_security'",
",",
"apache_get_modules",
"(",
")",
")",
")",
"{",
"$",
"type",
"=",
"self",
"::",
"SERVER_TYPE_APACHE",
";",
"}",
"if",
"(",
"$",
"type",
"==",
"self",
"::",
"SERVER_TYPE_UNKNOWN",
"&&",
"function_exists",
"(",
"'apache_get_version'",
")",
")",
"{",
"$",
"type",
"=",
"self",
"::",
"SERVER_TYPE_APACHE",
";",
"}",
"}",
"return",
"$",
"type",
";",
"}"
] | Get Web Server Type
@return string | [
"Get",
"Web",
"Server",
"Type"
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Validator.php#L54-L106 |
5,618 | PentagonalProject/SlimService | src/Validator.php | Validator.getConvertAliasLogLevel | public static function getConvertAliasLogLevel(int $code) : int
{
switch ($code) {
case Logger::ALERT:
return Logger::ALERT;
case Logger::CRITICAL:
return Logger::CRITICAL;
case E_ALL:
case Logger::DEBUG:
return Logger::DEBUG;
case E_NOTICE:
case E_USER_NOTICE:
case E_DEPRECATED:
case E_USER_DEPRECATED:
case Logger::NOTICE:
return Logger::NOTICE;
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case Logger::ERROR:
return Logger::ERROR;
case Logger::INFO:
return Logger::INFO;
case Logger::EMERGENCY:
return Logger::EMERGENCY;
case E_WARNING:
case E_USER_WARNING:
case E_COMPILE_WARNING:
case Logger::WARNING:
return Logger::WARNING;
}
return 0;
} | php | public static function getConvertAliasLogLevel(int $code) : int
{
switch ($code) {
case Logger::ALERT:
return Logger::ALERT;
case Logger::CRITICAL:
return Logger::CRITICAL;
case E_ALL:
case Logger::DEBUG:
return Logger::DEBUG;
case E_NOTICE:
case E_USER_NOTICE:
case E_DEPRECATED:
case E_USER_DEPRECATED:
case Logger::NOTICE:
return Logger::NOTICE;
case E_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case Logger::ERROR:
return Logger::ERROR;
case Logger::INFO:
return Logger::INFO;
case Logger::EMERGENCY:
return Logger::EMERGENCY;
case E_WARNING:
case E_USER_WARNING:
case E_COMPILE_WARNING:
case Logger::WARNING:
return Logger::WARNING;
}
return 0;
} | [
"public",
"static",
"function",
"getConvertAliasLogLevel",
"(",
"int",
"$",
"code",
")",
":",
"int",
"{",
"switch",
"(",
"$",
"code",
")",
"{",
"case",
"Logger",
"::",
"ALERT",
":",
"return",
"Logger",
"::",
"ALERT",
";",
"case",
"Logger",
"::",
"CRITICAL",
":",
"return",
"Logger",
"::",
"CRITICAL",
";",
"case",
"E_ALL",
":",
"case",
"Logger",
"::",
"DEBUG",
":",
"return",
"Logger",
"::",
"DEBUG",
";",
"case",
"E_NOTICE",
":",
"case",
"E_USER_NOTICE",
":",
"case",
"E_DEPRECATED",
":",
"case",
"E_USER_DEPRECATED",
":",
"case",
"Logger",
"::",
"NOTICE",
":",
"return",
"Logger",
"::",
"NOTICE",
";",
"case",
"E_ERROR",
":",
"case",
"E_CORE_ERROR",
":",
"case",
"E_COMPILE_ERROR",
":",
"case",
"Logger",
"::",
"ERROR",
":",
"return",
"Logger",
"::",
"ERROR",
";",
"case",
"Logger",
"::",
"INFO",
":",
"return",
"Logger",
"::",
"INFO",
";",
"case",
"Logger",
"::",
"EMERGENCY",
":",
"return",
"Logger",
"::",
"EMERGENCY",
";",
"case",
"E_WARNING",
":",
"case",
"E_USER_WARNING",
":",
"case",
"E_COMPILE_WARNING",
":",
"case",
"Logger",
"::",
"WARNING",
":",
"return",
"Logger",
"::",
"WARNING",
";",
"}",
"return",
"0",
";",
"}"
] | Get Alias Log Level
@param int $code
@return int if no match between code will be return int 0 | [
"Get",
"Alias",
"Log",
"Level"
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Validator.php#L245-L278 |
5,619 | PentagonalProject/SlimService | src/Validator.php | Validator.getLogStringByCode | public static function getLogStringByCode($code)
{
$code = is_numeric($code) && !is_float($code)
? abs($code)
: $code;
if (!is_int($code)) {
return null;
}
switch (self::getConvertAliasLogLevel($code)) {
case Logger::NOTICE:
return 'notice';
case Logger::ERROR:
return 'error';
case Logger::WARNING:
return 'warning';
case Logger::INFO:
return 'info';
case Logger::DEBUG:
return 'debug';
case Logger::EMERGENCY:
return 'emergency';
case Logger::CRITICAL:
return 'critical';
case Logger::ALERT:
return 'alert';
}
return null;
} | php | public static function getLogStringByCode($code)
{
$code = is_numeric($code) && !is_float($code)
? abs($code)
: $code;
if (!is_int($code)) {
return null;
}
switch (self::getConvertAliasLogLevel($code)) {
case Logger::NOTICE:
return 'notice';
case Logger::ERROR:
return 'error';
case Logger::WARNING:
return 'warning';
case Logger::INFO:
return 'info';
case Logger::DEBUG:
return 'debug';
case Logger::EMERGENCY:
return 'emergency';
case Logger::CRITICAL:
return 'critical';
case Logger::ALERT:
return 'alert';
}
return null;
} | [
"public",
"static",
"function",
"getLogStringByCode",
"(",
"$",
"code",
")",
"{",
"$",
"code",
"=",
"is_numeric",
"(",
"$",
"code",
")",
"&&",
"!",
"is_float",
"(",
"$",
"code",
")",
"?",
"abs",
"(",
"$",
"code",
")",
":",
"$",
"code",
";",
"if",
"(",
"!",
"is_int",
"(",
"$",
"code",
")",
")",
"{",
"return",
"null",
";",
"}",
"switch",
"(",
"self",
"::",
"getConvertAliasLogLevel",
"(",
"$",
"code",
")",
")",
"{",
"case",
"Logger",
"::",
"NOTICE",
":",
"return",
"'notice'",
";",
"case",
"Logger",
"::",
"ERROR",
":",
"return",
"'error'",
";",
"case",
"Logger",
"::",
"WARNING",
":",
"return",
"'warning'",
";",
"case",
"Logger",
"::",
"INFO",
":",
"return",
"'info'",
";",
"case",
"Logger",
"::",
"DEBUG",
":",
"return",
"'debug'",
";",
"case",
"Logger",
"::",
"EMERGENCY",
":",
"return",
"'emergency'",
";",
"case",
"Logger",
"::",
"CRITICAL",
":",
"return",
"'critical'",
";",
"case",
"Logger",
"::",
"ALERT",
":",
"return",
"'alert'",
";",
"}",
"return",
"null",
";",
"}"
] | Get Default Log Name By Code
@param int $code
@return string|null string as lowercase and returning null if not found | [
"Get",
"Default",
"Log",
"Name",
"By",
"Code"
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Validator.php#L286-L315 |
5,620 | PentagonalProject/SlimService | src/Validator.php | Validator.isAbsolutePath | public static function isAbsolutePath($path) : bool
{
/*
* This is definitive if true but fails if $path does not exist or contains
* a symbolic link.
*/
if (realpath($path) == $path) {
return true;
}
if (strlen($path) == 0 || $path[0] == '.') {
return false;
}
// Windows allows absolute paths like this.
if (preg_match('#^[a-zA-Z]:\\\\#', $path)) {
return true;
}
// A path starting with / or \ is absolute; anything else is relative.
return ( $path[0] == '/' || $path[0] == '\\' );
} | php | public static function isAbsolutePath($path) : bool
{
/*
* This is definitive if true but fails if $path does not exist or contains
* a symbolic link.
*/
if (realpath($path) == $path) {
return true;
}
if (strlen($path) == 0 || $path[0] == '.') {
return false;
}
// Windows allows absolute paths like this.
if (preg_match('#^[a-zA-Z]:\\\\#', $path)) {
return true;
}
// A path starting with / or \ is absolute; anything else is relative.
return ( $path[0] == '/' || $path[0] == '\\' );
} | [
"public",
"static",
"function",
"isAbsolutePath",
"(",
"$",
"path",
")",
":",
"bool",
"{",
"/*\n * This is definitive if true but fails if $path does not exist or contains\n * a symbolic link.\n */",
"if",
"(",
"realpath",
"(",
"$",
"path",
")",
"==",
"$",
"path",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"path",
")",
"==",
"0",
"||",
"$",
"path",
"[",
"0",
"]",
"==",
"'.'",
")",
"{",
"return",
"false",
";",
"}",
"// Windows allows absolute paths like this.",
"if",
"(",
"preg_match",
"(",
"'#^[a-zA-Z]:\\\\\\\\#'",
",",
"$",
"path",
")",
")",
"{",
"return",
"true",
";",
"}",
"// A path starting with / or \\ is absolute; anything else is relative.",
"return",
"(",
"$",
"path",
"[",
"0",
"]",
"==",
"'/'",
"||",
"$",
"path",
"[",
"0",
"]",
"==",
"'\\\\'",
")",
";",
"}"
] | Test if a give filesystem path is absolute.
For example, '/foo/bar', or 'c:\windows'.
@since 2.5.0
@param string $path File path.
@return bool True if path is absolute, false is not absolute. | [
"Test",
"if",
"a",
"give",
"filesystem",
"path",
"is",
"absolute",
"."
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Validator.php#L327-L348 |
5,621 | nano7/Foundation | src/Application.php | Application.registerEnv | protected function registerEnv()
{
$file_env = $this->basePath('.env');
$env = new Dotenv($this->basePath(), '.env');
if (file_exists($file_env)) {
$env->load();
}
} | php | protected function registerEnv()
{
$file_env = $this->basePath('.env');
$env = new Dotenv($this->basePath(), '.env');
if (file_exists($file_env)) {
$env->load();
}
} | [
"protected",
"function",
"registerEnv",
"(",
")",
"{",
"$",
"file_env",
"=",
"$",
"this",
"->",
"basePath",
"(",
"'.env'",
")",
";",
"$",
"env",
"=",
"new",
"Dotenv",
"(",
"$",
"this",
"->",
"basePath",
"(",
")",
",",
"'.env'",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file_env",
")",
")",
"{",
"$",
"env",
"->",
"load",
"(",
")",
";",
"}",
"}"
] | Register the env bindings into the container.
@return void | [
"Register",
"the",
"env",
"bindings",
"into",
"the",
"container",
"."
] | 8328423f81c69b8fabc04b4f6b1f3ba712695374 | https://github.com/nano7/Foundation/blob/8328423f81c69b8fabc04b4f6b1f3ba712695374/src/Application.php#L70-L78 |
5,622 | nano7/Foundation | src/Application.php | Application.register | public function register($provider)
{
// Verificar se provider já foi registrado
$keyProvider = is_string($provider) ? $provider : get_class($provider);
if (array_key_exists($keyProvider, $this->serviceProviders)) {
return $this->serviceProviders[$keyProvider];
}
// Carregar provider quando string
if (is_string($provider)) {
$provider = new $provider($this);
}
if (method_exists($provider, 'register')) {
$provider->register();
}
// Marcar como registrado
$this->serviceProviders[$keyProvider] = $provider;
// Verificar se deve
if ($this->booted) {
$this->bootProvider($provider);
}
return $provider;
} | php | public function register($provider)
{
// Verificar se provider já foi registrado
$keyProvider = is_string($provider) ? $provider : get_class($provider);
if (array_key_exists($keyProvider, $this->serviceProviders)) {
return $this->serviceProviders[$keyProvider];
}
// Carregar provider quando string
if (is_string($provider)) {
$provider = new $provider($this);
}
if (method_exists($provider, 'register')) {
$provider->register();
}
// Marcar como registrado
$this->serviceProviders[$keyProvider] = $provider;
// Verificar se deve
if ($this->booted) {
$this->bootProvider($provider);
}
return $provider;
} | [
"public",
"function",
"register",
"(",
"$",
"provider",
")",
"{",
"// Verificar se provider já foi registrado",
"$",
"keyProvider",
"=",
"is_string",
"(",
"$",
"provider",
")",
"?",
"$",
"provider",
":",
"get_class",
"(",
"$",
"provider",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keyProvider",
",",
"$",
"this",
"->",
"serviceProviders",
")",
")",
"{",
"return",
"$",
"this",
"->",
"serviceProviders",
"[",
"$",
"keyProvider",
"]",
";",
"}",
"// Carregar provider quando string",
"if",
"(",
"is_string",
"(",
"$",
"provider",
")",
")",
"{",
"$",
"provider",
"=",
"new",
"$",
"provider",
"(",
"$",
"this",
")",
";",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"provider",
",",
"'register'",
")",
")",
"{",
"$",
"provider",
"->",
"register",
"(",
")",
";",
"}",
"// Marcar como registrado",
"$",
"this",
"->",
"serviceProviders",
"[",
"$",
"keyProvider",
"]",
"=",
"$",
"provider",
";",
"// Verificar se deve",
"if",
"(",
"$",
"this",
"->",
"booted",
")",
"{",
"$",
"this",
"->",
"bootProvider",
"(",
"$",
"provider",
")",
";",
"}",
"return",
"$",
"provider",
";",
"}"
] | Register services providers.
@param $provider
@return string | [
"Register",
"services",
"providers",
"."
] | 8328423f81c69b8fabc04b4f6b1f3ba712695374 | https://github.com/nano7/Foundation/blob/8328423f81c69b8fabc04b4f6b1f3ba712695374/src/Application.php#L155-L181 |
5,623 | helionogueir/changedirective | core/cgi/Locale.class.php | Locale.set | public function set(string $locale, string $collate): bool {
$auth = false;
try {
if (!empty($locale)) {
$_locale = preg_replace("/^(\w{2})-(\w{2})$/", "$1_$2", $locale);
locale_set_default($_locale);
if (!empty($collate)) {
$_locale .= "." . strtoupper($collate);
}
setlocale(LC_ALL, $_locale);
$auth = true;
}
} catch (Exception $ex) {
$auth = false;
throw $ex;
}
return $auth;
} | php | public function set(string $locale, string $collate): bool {
$auth = false;
try {
if (!empty($locale)) {
$_locale = preg_replace("/^(\w{2})-(\w{2})$/", "$1_$2", $locale);
locale_set_default($_locale);
if (!empty($collate)) {
$_locale .= "." . strtoupper($collate);
}
setlocale(LC_ALL, $_locale);
$auth = true;
}
} catch (Exception $ex) {
$auth = false;
throw $ex;
}
return $auth;
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"locale",
",",
"string",
"$",
"collate",
")",
":",
"bool",
"{",
"$",
"auth",
"=",
"false",
";",
"try",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"locale",
")",
")",
"{",
"$",
"_locale",
"=",
"preg_replace",
"(",
"\"/^(\\w{2})-(\\w{2})$/\"",
",",
"\"$1_$2\"",
",",
"$",
"locale",
")",
";",
"locale_set_default",
"(",
"$",
"_locale",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"collate",
")",
")",
"{",
"$",
"_locale",
".=",
"\".\"",
".",
"strtoupper",
"(",
"$",
"collate",
")",
";",
"}",
"setlocale",
"(",
"LC_ALL",
",",
"$",
"_locale",
")",
";",
"$",
"auth",
"=",
"true",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"$",
"auth",
"=",
"false",
";",
"throw",
"$",
"ex",
";",
"}",
"return",
"$",
"auth",
";",
"}"
] | - Set locale and collate
@param string $locale Codename of locale (Ex: en-US)
@param string $collate Codename of collate (Ex: utf-8)
@return bool Return true case locale set, or false case fail | [
"-",
"Set",
"locale",
"and",
"collate"
] | 4c02ed10afceefc48909fdacadfe4e19cd52e88c | https://github.com/helionogueir/changedirective/blob/4c02ed10afceefc48909fdacadfe4e19cd52e88c/core/cgi/Locale.class.php#L20-L37 |
5,624 | worddrop/bookworm | src/Bookworm/Bookworm.php | Bookworm.estimate | public static function estimate($text, $units = array(' minute', ' minutes'))
{
// Count how many words are in the given text
$wordCount = self::countWords($text);
$wordSeconds = ($wordCount / self::$wordsPerMinute) * 60;
// Count how many images are in the given text
$imageCount = self::countImages($text);
$imageSeconds = $imageCount * self::$secondsPerImage;
// Count how many images are in the given text
$codeCount = self::countCode($text);
$codeSeconds = ($codeCount / self::$codewordsPerMinute) * 60;
// Calculate the amount of minutes required to read the text
$minutes = round(($wordSeconds + $imageSeconds + $codeSeconds) / 60);
// If it's smaller than one or one, we default it to one
$minutes = $minutes > 1 ? $minutes : 1;
// return only int, if $units set to false
if (is_string($units) === true) {
return $minutes.$units;
}
if (is_array($units) === true && count($units) === 2) {
$units = array_values($units);
return $minutes.($minutes === 1 ? $units[0] : $units[1]);
}
return $minutes;
} | php | public static function estimate($text, $units = array(' minute', ' minutes'))
{
// Count how many words are in the given text
$wordCount = self::countWords($text);
$wordSeconds = ($wordCount / self::$wordsPerMinute) * 60;
// Count how many images are in the given text
$imageCount = self::countImages($text);
$imageSeconds = $imageCount * self::$secondsPerImage;
// Count how many images are in the given text
$codeCount = self::countCode($text);
$codeSeconds = ($codeCount / self::$codewordsPerMinute) * 60;
// Calculate the amount of minutes required to read the text
$minutes = round(($wordSeconds + $imageSeconds + $codeSeconds) / 60);
// If it's smaller than one or one, we default it to one
$minutes = $minutes > 1 ? $minutes : 1;
// return only int, if $units set to false
if (is_string($units) === true) {
return $minutes.$units;
}
if (is_array($units) === true && count($units) === 2) {
$units = array_values($units);
return $minutes.($minutes === 1 ? $units[0] : $units[1]);
}
return $minutes;
} | [
"public",
"static",
"function",
"estimate",
"(",
"$",
"text",
",",
"$",
"units",
"=",
"array",
"(",
"' minute'",
",",
"' minutes'",
")",
")",
"{",
"// Count how many words are in the given text",
"$",
"wordCount",
"=",
"self",
"::",
"countWords",
"(",
"$",
"text",
")",
";",
"$",
"wordSeconds",
"=",
"(",
"$",
"wordCount",
"/",
"self",
"::",
"$",
"wordsPerMinute",
")",
"*",
"60",
";",
"// Count how many images are in the given text",
"$",
"imageCount",
"=",
"self",
"::",
"countImages",
"(",
"$",
"text",
")",
";",
"$",
"imageSeconds",
"=",
"$",
"imageCount",
"*",
"self",
"::",
"$",
"secondsPerImage",
";",
"// Count how many images are in the given text",
"$",
"codeCount",
"=",
"self",
"::",
"countCode",
"(",
"$",
"text",
")",
";",
"$",
"codeSeconds",
"=",
"(",
"$",
"codeCount",
"/",
"self",
"::",
"$",
"codewordsPerMinute",
")",
"*",
"60",
";",
"// Calculate the amount of minutes required to read the text",
"$",
"minutes",
"=",
"round",
"(",
"(",
"$",
"wordSeconds",
"+",
"$",
"imageSeconds",
"+",
"$",
"codeSeconds",
")",
"/",
"60",
")",
";",
"// If it's smaller than one or one, we default it to one",
"$",
"minutes",
"=",
"$",
"minutes",
">",
"1",
"?",
"$",
"minutes",
":",
"1",
";",
"// return only int, if $units set to false",
"if",
"(",
"is_string",
"(",
"$",
"units",
")",
"===",
"true",
")",
"{",
"return",
"$",
"minutes",
".",
"$",
"units",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"units",
")",
"===",
"true",
"&&",
"count",
"(",
"$",
"units",
")",
"===",
"2",
")",
"{",
"$",
"units",
"=",
"array_values",
"(",
"$",
"units",
")",
";",
"return",
"$",
"minutes",
".",
"(",
"$",
"minutes",
"===",
"1",
"?",
"$",
"units",
"[",
"0",
"]",
":",
"$",
"units",
"[",
"1",
"]",
")",
";",
"}",
"return",
"$",
"minutes",
";",
"}"
] | Estimates the time needed to read a given string.
@param string $text The text to estimate
@param string|array $units singular | singular & plural
@return string | [
"Estimates",
"the",
"time",
"needed",
"to",
"read",
"a",
"given",
"string",
"."
] | 07f1f2a3ca66b03386b53906a41eaac2c4ceb2ce | https://github.com/worddrop/bookworm/blob/07f1f2a3ca66b03386b53906a41eaac2c4ceb2ce/src/Bookworm/Bookworm.php#L52-L81 |
5,625 | worddrop/bookworm | src/Bookworm/Bookworm.php | Bookworm.countWords | private static function countWords($text)
{
// Remove markdown images from text
$words = trim(preg_replace('/!\[([^\[]+)\]\(([^\)]+)\)/i', ' ', $text));
// Remove image tags from text
$words = trim(preg_replace('/<img[^>]*>/i', ' ', $words));
// Remove picture tags from text (counted already due to mandatory img tag)
$words = trim(preg_replace('/<picture[^>]*>([\s\S]*?)<\/picture>/i', ' ', $words));
// Remove code markdown
$words = trim(preg_replace('/(?<=(?<!`))`[^`\n\r]+`(?=(?!`))|```[\w+]?[^`]*```/i', ' ', $words));
// Remove code html
$words = trim(preg_replace('/<code>([\s\S]*?)<\/code>/i', ' ', $words));
$words = strip_tags($words);
// Explode on spaces to separate words
$words = explode(' ', $words);
return count($words);
} | php | private static function countWords($text)
{
// Remove markdown images from text
$words = trim(preg_replace('/!\[([^\[]+)\]\(([^\)]+)\)/i', ' ', $text));
// Remove image tags from text
$words = trim(preg_replace('/<img[^>]*>/i', ' ', $words));
// Remove picture tags from text (counted already due to mandatory img tag)
$words = trim(preg_replace('/<picture[^>]*>([\s\S]*?)<\/picture>/i', ' ', $words));
// Remove code markdown
$words = trim(preg_replace('/(?<=(?<!`))`[^`\n\r]+`(?=(?!`))|```[\w+]?[^`]*```/i', ' ', $words));
// Remove code html
$words = trim(preg_replace('/<code>([\s\S]*?)<\/code>/i', ' ', $words));
$words = strip_tags($words);
// Explode on spaces to separate words
$words = explode(' ', $words);
return count($words);
} | [
"private",
"static",
"function",
"countWords",
"(",
"$",
"text",
")",
"{",
"// Remove markdown images from text",
"$",
"words",
"=",
"trim",
"(",
"preg_replace",
"(",
"'/!\\[([^\\[]+)\\]\\(([^\\)]+)\\)/i'",
",",
"' '",
",",
"$",
"text",
")",
")",
";",
"// Remove image tags from text",
"$",
"words",
"=",
"trim",
"(",
"preg_replace",
"(",
"'/<img[^>]*>/i'",
",",
"' '",
",",
"$",
"words",
")",
")",
";",
"// Remove picture tags from text (counted already due to mandatory img tag)",
"$",
"words",
"=",
"trim",
"(",
"preg_replace",
"(",
"'/<picture[^>]*>([\\s\\S]*?)<\\/picture>/i'",
",",
"' '",
",",
"$",
"words",
")",
")",
";",
"// Remove code markdown",
"$",
"words",
"=",
"trim",
"(",
"preg_replace",
"(",
"'/(?<=(?<!`))`[^`\\n\\r]+`(?=(?!`))|```[\\w+]?[^`]*```/i'",
",",
"' '",
",",
"$",
"words",
")",
")",
";",
"// Remove code html",
"$",
"words",
"=",
"trim",
"(",
"preg_replace",
"(",
"'/<code>([\\s\\S]*?)<\\/code>/i'",
",",
"' '",
",",
"$",
"words",
")",
")",
";",
"$",
"words",
"=",
"strip_tags",
"(",
"$",
"words",
")",
";",
"// Explode on spaces to separate words",
"$",
"words",
"=",
"explode",
"(",
"' '",
",",
"$",
"words",
")",
";",
"return",
"count",
"(",
"$",
"words",
")",
";",
"}"
] | Counts how many words are in a specific text.
@param string $text The text from which the words should be counted
@return int | [
"Counts",
"how",
"many",
"words",
"are",
"in",
"a",
"specific",
"text",
"."
] | 07f1f2a3ca66b03386b53906a41eaac2c4ceb2ce | https://github.com/worddrop/bookworm/blob/07f1f2a3ca66b03386b53906a41eaac2c4ceb2ce/src/Bookworm/Bookworm.php#L90-L107 |
5,626 | worddrop/bookworm | src/Bookworm/Bookworm.php | Bookworm.countImages | private static function countImages($text)
{
// Count markdown images from text
$markdownImages = preg_match_all('/!\[([^\[]+)\]\(([^\)]+)\)/i', $text, $matches);
// Count image tags from text
$imgTags = preg_match_all('/<img[^>]*>/i', $text, $matches);
return $markdownImages + $imgTags;
} | php | private static function countImages($text)
{
// Count markdown images from text
$markdownImages = preg_match_all('/!\[([^\[]+)\]\(([^\)]+)\)/i', $text, $matches);
// Count image tags from text
$imgTags = preg_match_all('/<img[^>]*>/i', $text, $matches);
return $markdownImages + $imgTags;
} | [
"private",
"static",
"function",
"countImages",
"(",
"$",
"text",
")",
"{",
"// Count markdown images from text",
"$",
"markdownImages",
"=",
"preg_match_all",
"(",
"'/!\\[([^\\[]+)\\]\\(([^\\)]+)\\)/i'",
",",
"$",
"text",
",",
"$",
"matches",
")",
";",
"// Count image tags from text",
"$",
"imgTags",
"=",
"preg_match_all",
"(",
"'/<img[^>]*>/i'",
",",
"$",
"text",
",",
"$",
"matches",
")",
";",
"return",
"$",
"markdownImages",
"+",
"$",
"imgTags",
";",
"}"
] | Counts how many images are in a specific text.
@param string $text The text from which the words should be counted
@return int | [
"Counts",
"how",
"many",
"images",
"are",
"in",
"a",
"specific",
"text",
"."
] | 07f1f2a3ca66b03386b53906a41eaac2c4ceb2ce | https://github.com/worddrop/bookworm/blob/07f1f2a3ca66b03386b53906a41eaac2c4ceb2ce/src/Bookworm/Bookworm.php#L116-L124 |
5,627 | worddrop/bookworm | src/Bookworm/Bookworm.php | Bookworm.countCode | private static function countCode($text)
{
// remove code attribute content, like from href="" or d=""
$text = preg_replace('/"[^"]*"/i', '', $text);
// get markdown code
$regex = '/(?<=(?<!`))`([^`\n\r]+)`(?=(?!`))|```[a-zA-Z]*([^`]*)```/i';
$markdownCount = preg_match_all($regex, $text, $markdownMatches, PREG_PATTERN_ORDER);
// Remove markdown code from text, as to not double count
$text = trim(preg_replace('/(?<=(?<!`))`[^`\n\r]+`(?=(?!`))|```[a-zA-Z]*[^`]*```/i', ' ', $text));
// get html code elements
$regex = '/<code>([\s\S]*?)<\/code>/i';
$htmlCount = preg_match_all($regex, $text, $htmlMatches, PREG_PATTERN_ORDER);
// check if any matches exist
if ($markdownCount === 0 && $htmlCount === 0) {
return 0;
}
// concat all code
$code = implode($markdownMatches[1], ' ').' '.implode($markdownMatches[2], ' ').' '.implode($htmlMatches[1], ' ');
// replace multiple spaces
$code = preg_replace(['/\s+/', '/^\s/'], [' ', ''], $code);
// return the number words in the code blocks
return count(array_filter(explode(' ', $code)));
} | php | private static function countCode($text)
{
// remove code attribute content, like from href="" or d=""
$text = preg_replace('/"[^"]*"/i', '', $text);
// get markdown code
$regex = '/(?<=(?<!`))`([^`\n\r]+)`(?=(?!`))|```[a-zA-Z]*([^`]*)```/i';
$markdownCount = preg_match_all($regex, $text, $markdownMatches, PREG_PATTERN_ORDER);
// Remove markdown code from text, as to not double count
$text = trim(preg_replace('/(?<=(?<!`))`[^`\n\r]+`(?=(?!`))|```[a-zA-Z]*[^`]*```/i', ' ', $text));
// get html code elements
$regex = '/<code>([\s\S]*?)<\/code>/i';
$htmlCount = preg_match_all($regex, $text, $htmlMatches, PREG_PATTERN_ORDER);
// check if any matches exist
if ($markdownCount === 0 && $htmlCount === 0) {
return 0;
}
// concat all code
$code = implode($markdownMatches[1], ' ').' '.implode($markdownMatches[2], ' ').' '.implode($htmlMatches[1], ' ');
// replace multiple spaces
$code = preg_replace(['/\s+/', '/^\s/'], [' ', ''], $code);
// return the number words in the code blocks
return count(array_filter(explode(' ', $code)));
} | [
"private",
"static",
"function",
"countCode",
"(",
"$",
"text",
")",
"{",
"// remove code attribute content, like from href=\"\" or d=\"\"",
"$",
"text",
"=",
"preg_replace",
"(",
"'/\"[^\"]*\"/i'",
",",
"''",
",",
"$",
"text",
")",
";",
"// get markdown code",
"$",
"regex",
"=",
"'/(?<=(?<!`))`([^`\\n\\r]+)`(?=(?!`))|```[a-zA-Z]*([^`]*)```/i'",
";",
"$",
"markdownCount",
"=",
"preg_match_all",
"(",
"$",
"regex",
",",
"$",
"text",
",",
"$",
"markdownMatches",
",",
"PREG_PATTERN_ORDER",
")",
";",
"// Remove markdown code from text, as to not double count",
"$",
"text",
"=",
"trim",
"(",
"preg_replace",
"(",
"'/(?<=(?<!`))`[^`\\n\\r]+`(?=(?!`))|```[a-zA-Z]*[^`]*```/i'",
",",
"' '",
",",
"$",
"text",
")",
")",
";",
"// get html code elements",
"$",
"regex",
"=",
"'/<code>([\\s\\S]*?)<\\/code>/i'",
";",
"$",
"htmlCount",
"=",
"preg_match_all",
"(",
"$",
"regex",
",",
"$",
"text",
",",
"$",
"htmlMatches",
",",
"PREG_PATTERN_ORDER",
")",
";",
"// check if any matches exist",
"if",
"(",
"$",
"markdownCount",
"===",
"0",
"&&",
"$",
"htmlCount",
"===",
"0",
")",
"{",
"return",
"0",
";",
"}",
"// concat all code",
"$",
"code",
"=",
"implode",
"(",
"$",
"markdownMatches",
"[",
"1",
"]",
",",
"' '",
")",
".",
"' '",
".",
"implode",
"(",
"$",
"markdownMatches",
"[",
"2",
"]",
",",
"' '",
")",
".",
"' '",
".",
"implode",
"(",
"$",
"htmlMatches",
"[",
"1",
"]",
",",
"' '",
")",
";",
"// replace multiple spaces",
"$",
"code",
"=",
"preg_replace",
"(",
"[",
"'/\\s+/'",
",",
"'/^\\s/'",
"]",
",",
"[",
"' '",
",",
"''",
"]",
",",
"$",
"code",
")",
";",
"// return the number words in the code blocks",
"return",
"count",
"(",
"array_filter",
"(",
"explode",
"(",
"' '",
",",
"$",
"code",
")",
")",
")",
";",
"}"
] | Counts how many "code words" are in a specific text.
@param string $text The text from which the words should be counted
@return int | [
"Counts",
"how",
"many",
"code",
"words",
"are",
"in",
"a",
"specific",
"text",
"."
] | 07f1f2a3ca66b03386b53906a41eaac2c4ceb2ce | https://github.com/worddrop/bookworm/blob/07f1f2a3ca66b03386b53906a41eaac2c4ceb2ce/src/Bookworm/Bookworm.php#L133-L159 |
5,628 | worddrop/bookworm | src/Bookworm/Bookworm.php | Bookworm.configure | public static function configure(array $config = [])
{
$config = array_merge(
[
'wordsPerMinute' => self::$wordsPerMinute,
'secondsPerImage' => self::$secondsPerImage,
'codewordsPerMinute' => self::$codewordsPerMinute,
],
$config
);
self::$wordsPerMinute = $config['wordsPerMinute'];
self::$secondsPerImage = $config['secondsPerImage'];
self::$codewordsPerMinute = $config['codewordsPerMinute'];
} | php | public static function configure(array $config = [])
{
$config = array_merge(
[
'wordsPerMinute' => self::$wordsPerMinute,
'secondsPerImage' => self::$secondsPerImage,
'codewordsPerMinute' => self::$codewordsPerMinute,
],
$config
);
self::$wordsPerMinute = $config['wordsPerMinute'];
self::$secondsPerImage = $config['secondsPerImage'];
self::$codewordsPerMinute = $config['codewordsPerMinute'];
} | [
"public",
"static",
"function",
"configure",
"(",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"config",
"=",
"array_merge",
"(",
"[",
"'wordsPerMinute'",
"=>",
"self",
"::",
"$",
"wordsPerMinute",
",",
"'secondsPerImage'",
"=>",
"self",
"::",
"$",
"secondsPerImage",
",",
"'codewordsPerMinute'",
"=>",
"self",
"::",
"$",
"codewordsPerMinute",
",",
"]",
",",
"$",
"config",
")",
";",
"self",
"::",
"$",
"wordsPerMinute",
"=",
"$",
"config",
"[",
"'wordsPerMinute'",
"]",
";",
"self",
"::",
"$",
"secondsPerImage",
"=",
"$",
"config",
"[",
"'secondsPerImage'",
"]",
";",
"self",
"::",
"$",
"codewordsPerMinute",
"=",
"$",
"config",
"[",
"'codewordsPerMinute'",
"]",
";",
"}"
] | Alters the configuration.
@param array $config | [
"Alters",
"the",
"configuration",
"."
] | 07f1f2a3ca66b03386b53906a41eaac2c4ceb2ce | https://github.com/worddrop/bookworm/blob/07f1f2a3ca66b03386b53906a41eaac2c4ceb2ce/src/Bookworm/Bookworm.php#L165-L178 |
5,629 | atelierspierrot/library | src/Library/Helper/Url.php | Url.parse | public static function parse($url)
{
if (!strlen($url)) {
return null;
}
$_urls = array_merge( @parse_url($url), array('params'=>array()) );
if (isset($_urls['query'])) {
parse_str($_urls['query'], $_urls['params']);
}
return $_urls;
} | php | public static function parse($url)
{
if (!strlen($url)) {
return null;
}
$_urls = array_merge( @parse_url($url), array('params'=>array()) );
if (isset($_urls['query'])) {
parse_str($_urls['query'], $_urls['params']);
}
return $_urls;
} | [
"public",
"static",
"function",
"parse",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"url",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"_urls",
"=",
"array_merge",
"(",
"@",
"parse_url",
"(",
"$",
"url",
")",
",",
"array",
"(",
"'params'",
"=>",
"array",
"(",
")",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_urls",
"[",
"'query'",
"]",
")",
")",
"{",
"parse_str",
"(",
"$",
"_urls",
"[",
"'query'",
"]",
",",
"$",
"_urls",
"[",
"'params'",
"]",
")",
";",
"}",
"return",
"$",
"_urls",
";",
"}"
] | Parse an URL and returns its composition as an array, with the URI query if so
@param string $url The URL to parse (required)
@return array An array of the URL components | [
"Parse",
"an",
"URL",
"and",
"returns",
"its",
"composition",
"as",
"an",
"array",
"with",
"the",
"URI",
"query",
"if",
"so"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Url.php#L103-L113 |
5,630 | atelierspierrot/library | src/Library/Helper/Url.php | Url.getAbsoluteUrl | public static function getAbsoluteUrl($url = null)
{
if (is_null($url)) {
return '';
}
if (self::isUrl($url)) {
return $url;
}
$url = '/'.self::resolvePath($url);
$current_url = self::getRequestUrl(true, true);
$curr = substr($current_url, 0, strrpos($current_url, '/') );
return $curr.$url;
} | php | public static function getAbsoluteUrl($url = null)
{
if (is_null($url)) {
return '';
}
if (self::isUrl($url)) {
return $url;
}
$url = '/'.self::resolvePath($url);
$current_url = self::getRequestUrl(true, true);
$curr = substr($current_url, 0, strrpos($current_url, '/') );
return $curr.$url;
} | [
"public",
"static",
"function",
"getAbsoluteUrl",
"(",
"$",
"url",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"url",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"self",
"::",
"isUrl",
"(",
"$",
"url",
")",
")",
"{",
"return",
"$",
"url",
";",
"}",
"$",
"url",
"=",
"'/'",
".",
"self",
"::",
"resolvePath",
"(",
"$",
"url",
")",
";",
"$",
"current_url",
"=",
"self",
"::",
"getRequestUrl",
"(",
"true",
",",
"true",
")",
";",
"$",
"curr",
"=",
"substr",
"(",
"$",
"current_url",
",",
"0",
",",
"strrpos",
"(",
"$",
"current_url",
",",
"'/'",
")",
")",
";",
"return",
"$",
"curr",
".",
"$",
"url",
";",
"}"
] | Returns if possible an absolute URL in the current system
@param string $url The URL to resolve
@return string The resolved URL | [
"Returns",
"if",
"possible",
"an",
"absolute",
"URL",
"in",
"the",
"current",
"system"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Url.php#L169-L181 |
5,631 | atelierspierrot/library | src/Library/Helper/Url.php | Url.url | public static function url($param = null, $value = null, $url = null)
{
if (is_null($param)) {
return '';
}
if (is_null($url) || !strlen($url)) {
$url = self::getRequestUrl();
}
if (!is_null($param)) {
if (is_array($param) && is_null($value)) {
foreach($param as $param_p=>$value_p) {
$url = self::setParameter($param_p, $value_p, $url);
}
} elseif (is_null($value)) {
$parsed_url = self::parse($url);
if (isset($parsed_url['params']) && isset($parsed_url['params'][$param])) {
return $parsed_url['params'][$param];
}
return false;
} elseif (!is_null($value)) {
$url = self::setParameter($param, $value, $url);
}
}
return self::build(self::parse($url));
} | php | public static function url($param = null, $value = null, $url = null)
{
if (is_null($param)) {
return '';
}
if (is_null($url) || !strlen($url)) {
$url = self::getRequestUrl();
}
if (!is_null($param)) {
if (is_array($param) && is_null($value)) {
foreach($param as $param_p=>$value_p) {
$url = self::setParameter($param_p, $value_p, $url);
}
} elseif (is_null($value)) {
$parsed_url = self::parse($url);
if (isset($parsed_url['params']) && isset($parsed_url['params'][$param])) {
return $parsed_url['params'][$param];
}
return false;
} elseif (!is_null($value)) {
$url = self::setParameter($param, $value, $url);
}
}
return self::build(self::parse($url));
} | [
"public",
"static",
"function",
"url",
"(",
"$",
"param",
"=",
"null",
",",
"$",
"value",
"=",
"null",
",",
"$",
"url",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"param",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"url",
")",
"||",
"!",
"strlen",
"(",
"$",
"url",
")",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"getRequestUrl",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"param",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"param",
")",
"&&",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"param",
"as",
"$",
"param_p",
"=>",
"$",
"value_p",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"setParameter",
"(",
"$",
"param_p",
",",
"$",
"value_p",
",",
"$",
"url",
")",
";",
"}",
"}",
"elseif",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"$",
"parsed_url",
"=",
"self",
"::",
"parse",
"(",
"$",
"url",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parsed_url",
"[",
"'params'",
"]",
")",
"&&",
"isset",
"(",
"$",
"parsed_url",
"[",
"'params'",
"]",
"[",
"$",
"param",
"]",
")",
")",
"{",
"return",
"$",
"parsed_url",
"[",
"'params'",
"]",
"[",
"$",
"param",
"]",
";",
"}",
"return",
"false",
";",
"}",
"elseif",
"(",
"!",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"setParameter",
"(",
"$",
"param",
",",
"$",
"value",
",",
"$",
"url",
")",
";",
"}",
"}",
"return",
"self",
"::",
"build",
"(",
"self",
"::",
"parse",
"(",
"$",
"url",
")",
")",
";",
"}"
] | Global URL builder
@param string/array/null $param A parameter to set, or an array like `param => value` to set in URL
@param string/null $value The value of the `$param` argument (if it is a string)
@param string/null $url The URL to work on (`self::getRequestUrl()` by default)
@return string The final rebuilt URL | [
"Global",
"URL",
"builder"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Url.php#L191-L217 |
5,632 | atelierspierrot/library | src/Library/Helper/Url.php | Url.getParameter | public static function getParameter($param = false, $url = false)
{
if (empty($param)) {
return null;
}
if (!$url || !strlen($url)) {
$url = self::getRequestUrl();
}
$parsed_url = self::parse($url);
$params = (isset($parsed_url['params']) && count($parsed_url['params']))
? $parsed_url['params'] : false;
if ($param && strlen($param)) {
if ($params) {
foreach($params as $p=>$v) {
if ($p==$param) return $v;
}
}
return false;
}
return $params;
} | php | public static function getParameter($param = false, $url = false)
{
if (empty($param)) {
return null;
}
if (!$url || !strlen($url)) {
$url = self::getRequestUrl();
}
$parsed_url = self::parse($url);
$params = (isset($parsed_url['params']) && count($parsed_url['params']))
? $parsed_url['params'] : false;
if ($param && strlen($param)) {
if ($params) {
foreach($params as $p=>$v) {
if ($p==$param) return $v;
}
}
return false;
}
return $params;
} | [
"public",
"static",
"function",
"getParameter",
"(",
"$",
"param",
"=",
"false",
",",
"$",
"url",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"param",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"url",
"||",
"!",
"strlen",
"(",
"$",
"url",
")",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"getRequestUrl",
"(",
")",
";",
"}",
"$",
"parsed_url",
"=",
"self",
"::",
"parse",
"(",
"$",
"url",
")",
";",
"$",
"params",
"=",
"(",
"isset",
"(",
"$",
"parsed_url",
"[",
"'params'",
"]",
")",
"&&",
"count",
"(",
"$",
"parsed_url",
"[",
"'params'",
"]",
")",
")",
"?",
"$",
"parsed_url",
"[",
"'params'",
"]",
":",
"false",
";",
"if",
"(",
"$",
"param",
"&&",
"strlen",
"(",
"$",
"param",
")",
")",
"{",
"if",
"(",
"$",
"params",
")",
"{",
"foreach",
"(",
"$",
"params",
"as",
"$",
"p",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"p",
"==",
"$",
"param",
")",
"return",
"$",
"v",
";",
"}",
"}",
"return",
"false",
";",
"}",
"return",
"$",
"params",
";",
"}"
] | Get the value of an URL parameter
@param string/bool $param A parameter to get, or `false` to get the global parameters array
@param string/null $url The URL to work on (`self::getRequestUrl()` by default)
@return string/array The parameter value or the global array of parameters | [
"Get",
"the",
"value",
"of",
"an",
"URL",
"parameter"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Url.php#L226-L248 |
5,633 | atelierspierrot/library | src/Library/Helper/Url.php | Url.setParameter | public static function setParameter($var = '', $val = false, $url = false, $rebuild = true)
{
$url_entree = $url;
if (!$url || !is_array($url)) {
$_url = $url ? $url : self::getRequestUrl();
$url = self::parse($_url);
}
$url['params'][$var] = $val;
if ($rebuild) {
return self::build($url);
}
return $url;
} | php | public static function setParameter($var = '', $val = false, $url = false, $rebuild = true)
{
$url_entree = $url;
if (!$url || !is_array($url)) {
$_url = $url ? $url : self::getRequestUrl();
$url = self::parse($_url);
}
$url['params'][$var] = $val;
if ($rebuild) {
return self::build($url);
}
return $url;
} | [
"public",
"static",
"function",
"setParameter",
"(",
"$",
"var",
"=",
"''",
",",
"$",
"val",
"=",
"false",
",",
"$",
"url",
"=",
"false",
",",
"$",
"rebuild",
"=",
"true",
")",
"{",
"$",
"url_entree",
"=",
"$",
"url",
";",
"if",
"(",
"!",
"$",
"url",
"||",
"!",
"is_array",
"(",
"$",
"url",
")",
")",
"{",
"$",
"_url",
"=",
"$",
"url",
"?",
"$",
"url",
":",
"self",
"::",
"getRequestUrl",
"(",
")",
";",
"$",
"url",
"=",
"self",
"::",
"parse",
"(",
"$",
"_url",
")",
";",
"}",
"$",
"url",
"[",
"'params'",
"]",
"[",
"$",
"var",
"]",
"=",
"$",
"val",
";",
"if",
"(",
"$",
"rebuild",
")",
"{",
"return",
"self",
"::",
"build",
"(",
"$",
"url",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] | Set the value of an URL parameter
@param string/bool $var A parameter to get, or `false` to get the global parameters array
@param string/false $val The value of the `$param` argument (if `null`, the argument is stripped)
@param string/false $url The URL to work on (`self::getRequestUrl()` by default)
@param bool $rebuild Return a rebuilt URL (`true` by dfault - if `false`, the URL components array is returned)
@return string/array The final URL | [
"Set",
"the",
"value",
"of",
"an",
"URL",
"parameter"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Url.php#L259-L271 |
5,634 | atelierspierrot/library | src/Library/Helper/Url.php | Url.build | public static function build(array $url_components = null, $not_toput = null)
{
if (!is_array($url_components)) {
return null;
}
$_ntp = $not_toput ? (is_array($not_toput) ? $not_toput : array($not_toput)) : array();
if (isset($_urls['params']))
$_urls['params'] = array_filter($_urls['params']);
$n_url =
( (isset($url_components['scheme']) && !in_array('scheme', $_ntp)) ? $url_components['scheme'].'://' : 'http://')
.( (isset($url_components['user']) && !in_array('user', $_ntp)) ? $url_components['user'] : '')
.( (isset($url_components['pass']) && !in_array('pass', $_ntp)) ? ':'.$url_components['pass'] : '')
.( ((isset($url_components['user']) && !in_array('user', $_ntp)) || (isset($url_components['pass']) && !in_array('pass', $_ntp))) ? '@' : '')
.( (isset($url_components['host']) && !in_array('host', $_ntp)) ? $url_components['host'] : '')
.( (isset($url_components['port']) && !in_array('port', $_ntp)) ? ':'.$url_components['port'] : '')
.( (isset($url_components['path']) && !in_array('path', $_ntp)) ? $url_components['path'] : '')
.( (isset($url_components['params']) && !in_array('params', $_ntp)) ? '?'.http_build_query($url_components['params']) : '')
.( (isset($url_components['hash']) && !in_array('hash', $_ntp)) ? '#'.$url_components['hash'] : '');
return trim($n_url, '?&');
} | php | public static function build(array $url_components = null, $not_toput = null)
{
if (!is_array($url_components)) {
return null;
}
$_ntp = $not_toput ? (is_array($not_toput) ? $not_toput : array($not_toput)) : array();
if (isset($_urls['params']))
$_urls['params'] = array_filter($_urls['params']);
$n_url =
( (isset($url_components['scheme']) && !in_array('scheme', $_ntp)) ? $url_components['scheme'].'://' : 'http://')
.( (isset($url_components['user']) && !in_array('user', $_ntp)) ? $url_components['user'] : '')
.( (isset($url_components['pass']) && !in_array('pass', $_ntp)) ? ':'.$url_components['pass'] : '')
.( ((isset($url_components['user']) && !in_array('user', $_ntp)) || (isset($url_components['pass']) && !in_array('pass', $_ntp))) ? '@' : '')
.( (isset($url_components['host']) && !in_array('host', $_ntp)) ? $url_components['host'] : '')
.( (isset($url_components['port']) && !in_array('port', $_ntp)) ? ':'.$url_components['port'] : '')
.( (isset($url_components['path']) && !in_array('path', $_ntp)) ? $url_components['path'] : '')
.( (isset($url_components['params']) && !in_array('params', $_ntp)) ? '?'.http_build_query($url_components['params']) : '')
.( (isset($url_components['hash']) && !in_array('hash', $_ntp)) ? '#'.$url_components['hash'] : '');
return trim($n_url, '?&');
} | [
"public",
"static",
"function",
"build",
"(",
"array",
"$",
"url_components",
"=",
"null",
",",
"$",
"not_toput",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"url_components",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"_ntp",
"=",
"$",
"not_toput",
"?",
"(",
"is_array",
"(",
"$",
"not_toput",
")",
"?",
"$",
"not_toput",
":",
"array",
"(",
"$",
"not_toput",
")",
")",
":",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_urls",
"[",
"'params'",
"]",
")",
")",
"$",
"_urls",
"[",
"'params'",
"]",
"=",
"array_filter",
"(",
"$",
"_urls",
"[",
"'params'",
"]",
")",
";",
"$",
"n_url",
"=",
"(",
"(",
"isset",
"(",
"$",
"url_components",
"[",
"'scheme'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"'scheme'",
",",
"$",
"_ntp",
")",
")",
"?",
"$",
"url_components",
"[",
"'scheme'",
"]",
".",
"'://'",
":",
"'http://'",
")",
".",
"(",
"(",
"isset",
"(",
"$",
"url_components",
"[",
"'user'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"'user'",
",",
"$",
"_ntp",
")",
")",
"?",
"$",
"url_components",
"[",
"'user'",
"]",
":",
"''",
")",
".",
"(",
"(",
"isset",
"(",
"$",
"url_components",
"[",
"'pass'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"'pass'",
",",
"$",
"_ntp",
")",
")",
"?",
"':'",
".",
"$",
"url_components",
"[",
"'pass'",
"]",
":",
"''",
")",
".",
"(",
"(",
"(",
"isset",
"(",
"$",
"url_components",
"[",
"'user'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"'user'",
",",
"$",
"_ntp",
")",
")",
"||",
"(",
"isset",
"(",
"$",
"url_components",
"[",
"'pass'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"'pass'",
",",
"$",
"_ntp",
")",
")",
")",
"?",
"'@'",
":",
"''",
")",
".",
"(",
"(",
"isset",
"(",
"$",
"url_components",
"[",
"'host'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"'host'",
",",
"$",
"_ntp",
")",
")",
"?",
"$",
"url_components",
"[",
"'host'",
"]",
":",
"''",
")",
".",
"(",
"(",
"isset",
"(",
"$",
"url_components",
"[",
"'port'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"'port'",
",",
"$",
"_ntp",
")",
")",
"?",
"':'",
".",
"$",
"url_components",
"[",
"'port'",
"]",
":",
"''",
")",
".",
"(",
"(",
"isset",
"(",
"$",
"url_components",
"[",
"'path'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"'path'",
",",
"$",
"_ntp",
")",
")",
"?",
"$",
"url_components",
"[",
"'path'",
"]",
":",
"''",
")",
".",
"(",
"(",
"isset",
"(",
"$",
"url_components",
"[",
"'params'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"'params'",
",",
"$",
"_ntp",
")",
")",
"?",
"'?'",
".",
"http_build_query",
"(",
"$",
"url_components",
"[",
"'params'",
"]",
")",
":",
"''",
")",
".",
"(",
"(",
"isset",
"(",
"$",
"url_components",
"[",
"'hash'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"'hash'",
",",
"$",
"_ntp",
")",
")",
"?",
"'#'",
".",
"$",
"url_components",
"[",
"'hash'",
"]",
":",
"''",
")",
";",
"return",
"trim",
"(",
"$",
"n_url",
",",
"'?&'",
")",
";",
"}"
] | Rebuild a full URL string from an array of elements
@param array $url_components The array of the URL components:: `scheme`, `user`,
`pass`, `host`, `port`, `path`, `params`, `hash`
@param string/array/boolean $not_toput The name of an array of elements to not include
@return string The final URL as a string | [
"Rebuild",
"a",
"full",
"URL",
"string",
"from",
"an",
"array",
"of",
"elements"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Helper/Url.php#L281-L304 |
5,635 | kengoldfarb/underscore_libs | src/_Libs/_Rand.php | _Rand._randString | public static function _randString($length, $lettersNumbersOnly = false) {
$str = '';
for ($i = 0; $i < $length; $i++) {
if ($lettersNumbersOnly) {
$str .= self::$lettersNums[self::_getRand(0, strlen(self::$lettersNums) - 1)];
} else {
$str .= self::_randCharacter();
}
}
return $str;
} | php | public static function _randString($length, $lettersNumbersOnly = false) {
$str = '';
for ($i = 0; $i < $length; $i++) {
if ($lettersNumbersOnly) {
$str .= self::$lettersNums[self::_getRand(0, strlen(self::$lettersNums) - 1)];
} else {
$str .= self::_randCharacter();
}
}
return $str;
} | [
"public",
"static",
"function",
"_randString",
"(",
"$",
"length",
",",
"$",
"lettersNumbersOnly",
"=",
"false",
")",
"{",
"$",
"str",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"lettersNumbersOnly",
")",
"{",
"$",
"str",
".=",
"self",
"::",
"$",
"lettersNums",
"[",
"self",
"::",
"_getRand",
"(",
"0",
",",
"strlen",
"(",
"self",
"::",
"$",
"lettersNums",
")",
"-",
"1",
")",
"]",
";",
"}",
"else",
"{",
"$",
"str",
".=",
"self",
"::",
"_randCharacter",
"(",
")",
";",
"}",
"}",
"return",
"$",
"str",
";",
"}"
] | Creates a random string of the specified length
@param int $length The length of the string
@param bool $lettersNumbersOnly Should only letters and numbers be used?
@return string A random string | [
"Creates",
"a",
"random",
"string",
"of",
"the",
"specified",
"length"
] | e0d584f25093b594e67b8a3068ebd41c7f6483c5 | https://github.com/kengoldfarb/underscore_libs/blob/e0d584f25093b594e67b8a3068ebd41c7f6483c5/src/_Libs/_Rand.php#L41-L51 |
5,636 | kengoldfarb/underscore_libs | src/_Libs/_Rand.php | _Rand._randCharacter | public static function _randCharacter($start = 32, $end = 126) {
$amountToAdd = $end - $start;
return chr($start + self::_getRand(0, $amountToAdd));
} | php | public static function _randCharacter($start = 32, $end = 126) {
$amountToAdd = $end - $start;
return chr($start + self::_getRand(0, $amountToAdd));
} | [
"public",
"static",
"function",
"_randCharacter",
"(",
"$",
"start",
"=",
"32",
",",
"$",
"end",
"=",
"126",
")",
"{",
"$",
"amountToAdd",
"=",
"$",
"end",
"-",
"$",
"start",
";",
"return",
"chr",
"(",
"$",
"start",
"+",
"self",
"::",
"_getRand",
"(",
"0",
",",
"$",
"amountToAdd",
")",
")",
";",
"}"
] | Returns a random character within the start and end ascii characters
See http://www.asciitable.com/
@param int $start The start ascii character number
@param int $end The end ascii character number
@return char A single character | [
"Returns",
"a",
"random",
"character",
"within",
"the",
"start",
"and",
"end",
"ascii",
"characters"
] | e0d584f25093b594e67b8a3068ebd41c7f6483c5 | https://github.com/kengoldfarb/underscore_libs/blob/e0d584f25093b594e67b8a3068ebd41c7f6483c5/src/_Libs/_Rand.php#L62-L65 |
5,637 | FiveLab/ResourceBundle | src/DependencyInjection/ResourceExtension.php | ResourceExtension.configureErrorPresentationFactory | private function configureErrorPresentationFactory(array $factoryConfig, ContainerBuilder $container): void
{
if ($this->isConfigEnabled($container, $factoryConfig['validation'])) {
$container->getDefinition('fivelab.resource.error_presentation_factory.validation_failed')
->setAbstract(false)
->replaceArgument(0, $factoryConfig['validation']['message'])
->replaceArgument(1, $factoryConfig['validation']['reason']);
}
} | php | private function configureErrorPresentationFactory(array $factoryConfig, ContainerBuilder $container): void
{
if ($this->isConfigEnabled($container, $factoryConfig['validation'])) {
$container->getDefinition('fivelab.resource.error_presentation_factory.validation_failed')
->setAbstract(false)
->replaceArgument(0, $factoryConfig['validation']['message'])
->replaceArgument(1, $factoryConfig['validation']['reason']);
}
} | [
"private",
"function",
"configureErrorPresentationFactory",
"(",
"array",
"$",
"factoryConfig",
",",
"ContainerBuilder",
"$",
"container",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"isConfigEnabled",
"(",
"$",
"container",
",",
"$",
"factoryConfig",
"[",
"'validation'",
"]",
")",
")",
"{",
"$",
"container",
"->",
"getDefinition",
"(",
"'fivelab.resource.error_presentation_factory.validation_failed'",
")",
"->",
"setAbstract",
"(",
"false",
")",
"->",
"replaceArgument",
"(",
"0",
",",
"$",
"factoryConfig",
"[",
"'validation'",
"]",
"[",
"'message'",
"]",
")",
"->",
"replaceArgument",
"(",
"1",
",",
"$",
"factoryConfig",
"[",
"'validation'",
"]",
"[",
"'reason'",
"]",
")",
";",
"}",
"}"
] | Configure error presentation factories
@param array $factoryConfig
@param ContainerBuilder $container | [
"Configure",
"error",
"presentation",
"factories"
] | 048fce7be5357dc23fef1402ef8ca213489e8154 | https://github.com/FiveLab/ResourceBundle/blob/048fce7be5357dc23fef1402ef8ca213489e8154/src/DependencyInjection/ResourceExtension.php#L59-L67 |
5,638 | FiveLab/ResourceBundle | src/DependencyInjection/ResourceExtension.php | ResourceExtension.configureExceptionListener | private function configureExceptionListener(
array $loggingConfig,
array $exceptionListenerConfig,
ContainerBuilder $container
): void {
if ($this->isConfigEnabled($container, $loggingConfig)) {
$definition = $container
->getDefinition('fivelab.resource.event_listener.exception_logging')
->replaceArgument(2, $loggingConfig['level'])
->setAbstract(false)
->addTag('monolog.logger', ['channel' => $loggingConfig['channel']]);
} else {
$definition = $container->getDefinition('fivelab.resource.event_listener.logging');
}
$container
->getDefinition('fivelab.resource.event_listener.exception')
->replaceArgument(3, $exceptionListenerConfig['debug_parameter']);
$definition->addTag('kernel.event_listener', [
'event' => KernelEvents::EXCEPTION,
'method' => 'onKernelException',
]);
} | php | private function configureExceptionListener(
array $loggingConfig,
array $exceptionListenerConfig,
ContainerBuilder $container
): void {
if ($this->isConfigEnabled($container, $loggingConfig)) {
$definition = $container
->getDefinition('fivelab.resource.event_listener.exception_logging')
->replaceArgument(2, $loggingConfig['level'])
->setAbstract(false)
->addTag('monolog.logger', ['channel' => $loggingConfig['channel']]);
} else {
$definition = $container->getDefinition('fivelab.resource.event_listener.logging');
}
$container
->getDefinition('fivelab.resource.event_listener.exception')
->replaceArgument(3, $exceptionListenerConfig['debug_parameter']);
$definition->addTag('kernel.event_listener', [
'event' => KernelEvents::EXCEPTION,
'method' => 'onKernelException',
]);
} | [
"private",
"function",
"configureExceptionListener",
"(",
"array",
"$",
"loggingConfig",
",",
"array",
"$",
"exceptionListenerConfig",
",",
"ContainerBuilder",
"$",
"container",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"isConfigEnabled",
"(",
"$",
"container",
",",
"$",
"loggingConfig",
")",
")",
"{",
"$",
"definition",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"'fivelab.resource.event_listener.exception_logging'",
")",
"->",
"replaceArgument",
"(",
"2",
",",
"$",
"loggingConfig",
"[",
"'level'",
"]",
")",
"->",
"setAbstract",
"(",
"false",
")",
"->",
"addTag",
"(",
"'monolog.logger'",
",",
"[",
"'channel'",
"=>",
"$",
"loggingConfig",
"[",
"'channel'",
"]",
"]",
")",
";",
"}",
"else",
"{",
"$",
"definition",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"'fivelab.resource.event_listener.logging'",
")",
";",
"}",
"$",
"container",
"->",
"getDefinition",
"(",
"'fivelab.resource.event_listener.exception'",
")",
"->",
"replaceArgument",
"(",
"3",
",",
"$",
"exceptionListenerConfig",
"[",
"'debug_parameter'",
"]",
")",
";",
"$",
"definition",
"->",
"addTag",
"(",
"'kernel.event_listener'",
",",
"[",
"'event'",
"=>",
"KernelEvents",
"::",
"EXCEPTION",
",",
"'method'",
"=>",
"'onKernelException'",
",",
"]",
")",
";",
"}"
] | Configure exception listener
@param array $loggingConfig
@param array $exceptionListenerConfig
@param ContainerBuilder $container | [
"Configure",
"exception",
"listener"
] | 048fce7be5357dc23fef1402ef8ca213489e8154 | https://github.com/FiveLab/ResourceBundle/blob/048fce7be5357dc23fef1402ef8ca213489e8154/src/DependencyInjection/ResourceExtension.php#L105-L128 |
5,639 | wotek/redis | src/Wtk/Redis/ClientFactory.php | ClientFactory.create | public function create($name)
{
$config = $this->getConfiguration($name);
if(null === $config) {
throw new \RuntimeException(
"Connection with name: $name not found."
);
}
return new Client($config);
} | php | public function create($name)
{
$config = $this->getConfiguration($name);
if(null === $config) {
throw new \RuntimeException(
"Connection with name: $name not found."
);
}
return new Client($config);
} | [
"public",
"function",
"create",
"(",
"$",
"name",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfiguration",
"(",
"$",
"name",
")",
";",
"if",
"(",
"null",
"===",
"$",
"config",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Connection with name: $name not found.\"",
")",
";",
"}",
"return",
"new",
"Client",
"(",
"$",
"config",
")",
";",
"}"
] | Creates new redis client
@param string $name
@throws RuntimeException
@return Predis\ClientInterface | [
"Creates",
"new",
"redis",
"client"
] | f0bfd33ab692d001263e87f3d70976321fa918e4 | https://github.com/wotek/redis/blob/f0bfd33ab692d001263e87f3d70976321fa918e4/src/Wtk/Redis/ClientFactory.php#L54-L65 |
5,640 | wotek/redis | src/Wtk/Redis/ClientFactory.php | ClientFactory.addConfiguration | public function addConfiguration($name, array $config)
{
if(array_key_exists($name, $this->configs)) {
throw new \RuntimeException(
"Connection with given name already exists!"
);
}
$this->configs[$name] = $config;
} | php | public function addConfiguration($name, array $config)
{
if(array_key_exists($name, $this->configs)) {
throw new \RuntimeException(
"Connection with given name already exists!"
);
}
$this->configs[$name] = $config;
} | [
"public",
"function",
"addConfiguration",
"(",
"$",
"name",
",",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"configs",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Connection with given name already exists!\"",
")",
";",
"}",
"$",
"this",
"->",
"configs",
"[",
"$",
"name",
"]",
"=",
"$",
"config",
";",
"}"
] | Adds connection config
@param string $name
@param array $config
@throws RuntimeException
@return void | [
"Adds",
"connection",
"config"
] | f0bfd33ab692d001263e87f3d70976321fa918e4 | https://github.com/wotek/redis/blob/f0bfd33ab692d001263e87f3d70976321fa918e4/src/Wtk/Redis/ClientFactory.php#L77-L86 |
5,641 | prooph/link-sql-connector | data/Application/DataType/SqlConnector/TableRow.php | TableRow.toNativePropertyName | public static function toNativePropertyName($property)
{
$propertyNames = array_keys(static::getPropertyPrototypes());
if (! in_array($property, $propertyNames)) {
foreach ($propertyNames as $propertyName) {
if (strtolower($propertyName) === strtolower($property)) {
return $propertyName;
}
}
}
return $property;
} | php | public static function toNativePropertyName($property)
{
$propertyNames = array_keys(static::getPropertyPrototypes());
if (! in_array($property, $propertyNames)) {
foreach ($propertyNames as $propertyName) {
if (strtolower($propertyName) === strtolower($property)) {
return $propertyName;
}
}
}
return $property;
} | [
"public",
"static",
"function",
"toNativePropertyName",
"(",
"$",
"property",
")",
"{",
"$",
"propertyNames",
"=",
"array_keys",
"(",
"static",
"::",
"getPropertyPrototypes",
"(",
")",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"property",
",",
"$",
"propertyNames",
")",
")",
"{",
"foreach",
"(",
"$",
"propertyNames",
"as",
"$",
"propertyName",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"propertyName",
")",
"===",
"strtolower",
"(",
"$",
"property",
")",
")",
"{",
"return",
"$",
"propertyName",
";",
"}",
"}",
"}",
"return",
"$",
"property",
";",
"}"
] | If column does not directly match with a property name a case insensitive compare is performed to
detect the correct property name.
Override method to implement custom property translation
@param string $property
@return string | [
"If",
"column",
"does",
"not",
"directly",
"match",
"with",
"a",
"property",
"name",
"a",
"case",
"insensitive",
"compare",
"is",
"performed",
"to",
"detect",
"the",
"correct",
"property",
"name",
"."
] | 8846d6abf18c2df809e150794f12efdfbe467933 | https://github.com/prooph/link-sql-connector/blob/8846d6abf18c2df809e150794f12efdfbe467933/data/Application/DataType/SqlConnector/TableRow.php#L92-L105 |
5,642 | Cyberrebell/DoctrineEntityReader | library/DoctrineEntityReader/EntityReader.php | EntityReader.getProperties | public static function getProperties($entityNamespace)
{
$reflectionClass = new \ReflectionClass($entityNamespace);
$reflectionProperties = $reflectionClass->getProperties();
$properties = [];
foreach ($reflectionProperties as $reflectionProperty) {
$property = self::createProperty($reflectionProperty);
if ($property) {
$properties[$property->getName()] = $property;
}
}
return $properties;
} | php | public static function getProperties($entityNamespace)
{
$reflectionClass = new \ReflectionClass($entityNamespace);
$reflectionProperties = $reflectionClass->getProperties();
$properties = [];
foreach ($reflectionProperties as $reflectionProperty) {
$property = self::createProperty($reflectionProperty);
if ($property) {
$properties[$property->getName()] = $property;
}
}
return $properties;
} | [
"public",
"static",
"function",
"getProperties",
"(",
"$",
"entityNamespace",
")",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"entityNamespace",
")",
";",
"$",
"reflectionProperties",
"=",
"$",
"reflectionClass",
"->",
"getProperties",
"(",
")",
";",
"$",
"properties",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"reflectionProperties",
"as",
"$",
"reflectionProperty",
")",
"{",
"$",
"property",
"=",
"self",
"::",
"createProperty",
"(",
"$",
"reflectionProperty",
")",
";",
"if",
"(",
"$",
"property",
")",
"{",
"$",
"properties",
"[",
"$",
"property",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"property",
";",
"}",
"}",
"return",
"$",
"properties",
";",
"}"
] | Returns Properties determined by Entity-Namespace
@param string $entityNamespace Entity-Namespace
@return array:\DoctrineEntityReader\Property | [
"Returns",
"Properties",
"determined",
"by",
"Entity",
"-",
"Namespace"
] | 7a089fe69548b534bd5c213f9edb225d729e2a0a | https://github.com/Cyberrebell/DoctrineEntityReader/blob/7a089fe69548b534bd5c213f9edb225d729e2a0a/library/DoctrineEntityReader/EntityReader.php#L20-L33 |
5,643 | Cyberrebell/DoctrineEntityReader | library/DoctrineEntityReader/EntityReader.php | EntityReader.createProperty | protected static function createProperty(\ReflectionProperty $reflectionProperty)
{
$property = new Property();
$property->setName($reflectionProperty->getName());
$annotationReader = new AnnotationReader();
$annotations = $annotationReader->getPropertyAnnotations($reflectionProperty);
foreach ($annotations as $annotation) {
$annotationClassName = get_class($annotation);
if ($annotationClassName == 'Doctrine\ORM\Mapping\Column' || $annotationClassName == 'Doctrine\ORM\Mapping\Id') {
$property->setAnnotation($annotation);
$property->setType(Property::PROPERTY_TYPE_COLUMN);
} elseif ($annotationClassName == 'Doctrine\ORM\Mapping\ManyToOne' || $annotationClassName == 'Doctrine\ORM\Mapping\OneToOne') {
$property->setAnnotation($annotation);
$property->setType(Property::PROPERTY_TYPE_REF_ONE);
$property->setTargetEntity($annotation->targetEntity);
} elseif ($annotationClassName == 'Doctrine\ORM\Mapping\ManyToMany' || $annotationClassName == 'Doctrine\ORM\Mapping\OneToMany') {
$property->setAnnotation($annotation);
$property->setType(Property::PROPERTY_TYPE_REF_MANY);
$property->setTargetEntity($annotation->targetEntity);
}
}
if ($property->getType() == -1) {
throw new \Exception(
'Entity "' . $reflectionProperty->getDeclaringClass()->getName()
. '": defining annotation is missing at property "' . $property->getName() . '"!'
);
}
return $property;
} | php | protected static function createProperty(\ReflectionProperty $reflectionProperty)
{
$property = new Property();
$property->setName($reflectionProperty->getName());
$annotationReader = new AnnotationReader();
$annotations = $annotationReader->getPropertyAnnotations($reflectionProperty);
foreach ($annotations as $annotation) {
$annotationClassName = get_class($annotation);
if ($annotationClassName == 'Doctrine\ORM\Mapping\Column' || $annotationClassName == 'Doctrine\ORM\Mapping\Id') {
$property->setAnnotation($annotation);
$property->setType(Property::PROPERTY_TYPE_COLUMN);
} elseif ($annotationClassName == 'Doctrine\ORM\Mapping\ManyToOne' || $annotationClassName == 'Doctrine\ORM\Mapping\OneToOne') {
$property->setAnnotation($annotation);
$property->setType(Property::PROPERTY_TYPE_REF_ONE);
$property->setTargetEntity($annotation->targetEntity);
} elseif ($annotationClassName == 'Doctrine\ORM\Mapping\ManyToMany' || $annotationClassName == 'Doctrine\ORM\Mapping\OneToMany') {
$property->setAnnotation($annotation);
$property->setType(Property::PROPERTY_TYPE_REF_MANY);
$property->setTargetEntity($annotation->targetEntity);
}
}
if ($property->getType() == -1) {
throw new \Exception(
'Entity "' . $reflectionProperty->getDeclaringClass()->getName()
. '": defining annotation is missing at property "' . $property->getName() . '"!'
);
}
return $property;
} | [
"protected",
"static",
"function",
"createProperty",
"(",
"\\",
"ReflectionProperty",
"$",
"reflectionProperty",
")",
"{",
"$",
"property",
"=",
"new",
"Property",
"(",
")",
";",
"$",
"property",
"->",
"setName",
"(",
"$",
"reflectionProperty",
"->",
"getName",
"(",
")",
")",
";",
"$",
"annotationReader",
"=",
"new",
"AnnotationReader",
"(",
")",
";",
"$",
"annotations",
"=",
"$",
"annotationReader",
"->",
"getPropertyAnnotations",
"(",
"$",
"reflectionProperty",
")",
";",
"foreach",
"(",
"$",
"annotations",
"as",
"$",
"annotation",
")",
"{",
"$",
"annotationClassName",
"=",
"get_class",
"(",
"$",
"annotation",
")",
";",
"if",
"(",
"$",
"annotationClassName",
"==",
"'Doctrine\\ORM\\Mapping\\Column'",
"||",
"$",
"annotationClassName",
"==",
"'Doctrine\\ORM\\Mapping\\Id'",
")",
"{",
"$",
"property",
"->",
"setAnnotation",
"(",
"$",
"annotation",
")",
";",
"$",
"property",
"->",
"setType",
"(",
"Property",
"::",
"PROPERTY_TYPE_COLUMN",
")",
";",
"}",
"elseif",
"(",
"$",
"annotationClassName",
"==",
"'Doctrine\\ORM\\Mapping\\ManyToOne'",
"||",
"$",
"annotationClassName",
"==",
"'Doctrine\\ORM\\Mapping\\OneToOne'",
")",
"{",
"$",
"property",
"->",
"setAnnotation",
"(",
"$",
"annotation",
")",
";",
"$",
"property",
"->",
"setType",
"(",
"Property",
"::",
"PROPERTY_TYPE_REF_ONE",
")",
";",
"$",
"property",
"->",
"setTargetEntity",
"(",
"$",
"annotation",
"->",
"targetEntity",
")",
";",
"}",
"elseif",
"(",
"$",
"annotationClassName",
"==",
"'Doctrine\\ORM\\Mapping\\ManyToMany'",
"||",
"$",
"annotationClassName",
"==",
"'Doctrine\\ORM\\Mapping\\OneToMany'",
")",
"{",
"$",
"property",
"->",
"setAnnotation",
"(",
"$",
"annotation",
")",
";",
"$",
"property",
"->",
"setType",
"(",
"Property",
"::",
"PROPERTY_TYPE_REF_MANY",
")",
";",
"$",
"property",
"->",
"setTargetEntity",
"(",
"$",
"annotation",
"->",
"targetEntity",
")",
";",
"}",
"}",
"if",
"(",
"$",
"property",
"->",
"getType",
"(",
")",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Entity \"'",
".",
"$",
"reflectionProperty",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getName",
"(",
")",
".",
"'\": defining annotation is missing at property \"'",
".",
"$",
"property",
"->",
"getName",
"(",
")",
".",
"'\"!'",
")",
";",
"}",
"return",
"$",
"property",
";",
"}"
] | Returns created Property-Object
gets Information from Reflection-Property which contains Doctrine-Annotations
@param \ReflectionProperty $reflectionProperty Reflection-Property of Entity
@throws \Exception
@return boolean|\DoctrineEntityReader\Property | [
"Returns",
"created",
"Property",
"-",
"Object",
"gets",
"Information",
"from",
"Reflection",
"-",
"Property",
"which",
"contains",
"Doctrine",
"-",
"Annotations"
] | 7a089fe69548b534bd5c213f9edb225d729e2a0a | https://github.com/Cyberrebell/DoctrineEntityReader/blob/7a089fe69548b534bd5c213f9edb225d729e2a0a/library/DoctrineEntityReader/EntityReader.php#L44-L75 |
5,644 | teamelf/core | src/View/AssetManager.php | AssetManager.getCssCode | public function getCssCode()
{
$html = '';
foreach ($this->css as $css) {
$html .= sprintf('<link rel="stylesheet" href="%s"/>', $css);
}
return $html;
} | php | public function getCssCode()
{
$html = '';
foreach ($this->css as $css) {
$html .= sprintf('<link rel="stylesheet" href="%s"/>', $css);
}
return $html;
} | [
"public",
"function",
"getCssCode",
"(",
")",
"{",
"$",
"html",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"css",
"as",
"$",
"css",
")",
"{",
"$",
"html",
".=",
"sprintf",
"(",
"'<link rel=\"stylesheet\" href=\"%s\"/>'",
",",
"$",
"css",
")",
";",
"}",
"return",
"$",
"html",
";",
"}"
] | get link code for all css assets
@return string | [
"get",
"link",
"code",
"for",
"all",
"css",
"assets"
] | 653fc6e27f42239c2a8998a5fea325480e9dd39e | https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/View/AssetManager.php#L103-L110 |
5,645 | teamelf/core | src/View/AssetManager.php | AssetManager.getJsCode | public function getJsCode()
{
$html = '';
foreach ($this->js as $js) {
$html .= sprintf('<script src="%s"></script>', $js);
}
foreach ($this->entry as $entry) {
$html .= sprintf('<script>System.import(\'%s\')</script>', $entry);
}
return $html;
} | php | public function getJsCode()
{
$html = '';
foreach ($this->js as $js) {
$html .= sprintf('<script src="%s"></script>', $js);
}
foreach ($this->entry as $entry) {
$html .= sprintf('<script>System.import(\'%s\')</script>', $entry);
}
return $html;
} | [
"public",
"function",
"getJsCode",
"(",
")",
"{",
"$",
"html",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"js",
"as",
"$",
"js",
")",
"{",
"$",
"html",
".=",
"sprintf",
"(",
"'<script src=\"%s\"></script>'",
",",
"$",
"js",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"entry",
"as",
"$",
"entry",
")",
"{",
"$",
"html",
".=",
"sprintf",
"(",
"'<script>System.import(\\'%s\\')</script>'",
",",
"$",
"entry",
")",
";",
"}",
"return",
"$",
"html",
";",
"}"
] | get script code for all js assets
@return string | [
"get",
"script",
"code",
"for",
"all",
"js",
"assets"
] | 653fc6e27f42239c2a8998a5fea325480e9dd39e | https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/View/AssetManager.php#L117-L127 |
5,646 | phPoirot/Http | HttpResponse.php | HttpResponse.renderStatusLine | function renderStatusLine()
{
$status = sprintf(
'HTTP/%s %d %s',
$this->getVersion(),
$this->getStatusCode(),
$this->getStatusReason()
);
return trim($status);
} | php | function renderStatusLine()
{
$status = sprintf(
'HTTP/%s %d %s',
$this->getVersion(),
$this->getStatusCode(),
$this->getStatusReason()
);
return trim($status);
} | [
"function",
"renderStatusLine",
"(",
")",
"{",
"$",
"status",
"=",
"sprintf",
"(",
"'HTTP/%s %d %s'",
",",
"$",
"this",
"->",
"getVersion",
"(",
")",
",",
"$",
"this",
"->",
"getStatusCode",
"(",
")",
",",
"$",
"this",
"->",
"getStatusReason",
"(",
")",
")",
";",
"return",
"trim",
"(",
"$",
"status",
")",
";",
"}"
] | Render the status line header
@return string | [
"Render",
"the",
"status",
"line",
"header"
] | 3230b3555abf0e74c3d593fc49c8978758969736 | https://github.com/phPoirot/Http/blob/3230b3555abf0e74c3d593fc49c8978758969736/HttpResponse.php#L31-L41 |
5,647 | phPoirot/Http | HttpResponse.php | HttpResponse.setStatusCode | function setStatusCode($status)
{
if (! is_numeric($status)
|| is_float($status)
|| $status < 100
|| $status >= 600
)
throw new \InvalidArgumentException(sprintf(
'Invalid status code "%s"; must be an integer between 100 and 599, inclusive',
(is_scalar($status) ? $status : gettype($status))
));
$this->statCode = $status;
return $this;
} | php | function setStatusCode($status)
{
if (! is_numeric($status)
|| is_float($status)
|| $status < 100
|| $status >= 600
)
throw new \InvalidArgumentException(sprintf(
'Invalid status code "%s"; must be an integer between 100 and 599, inclusive',
(is_scalar($status) ? $status : gettype($status))
));
$this->statCode = $status;
return $this;
} | [
"function",
"setStatusCode",
"(",
"$",
"status",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"status",
")",
"||",
"is_float",
"(",
"$",
"status",
")",
"||",
"$",
"status",
"<",
"100",
"||",
"$",
"status",
">=",
"600",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid status code \"%s\"; must be an integer between 100 and 599, inclusive'",
",",
"(",
"is_scalar",
"(",
"$",
"status",
")",
"?",
"$",
"status",
":",
"gettype",
"(",
"$",
"status",
")",
")",
")",
")",
";",
"$",
"this",
"->",
"statCode",
"=",
"$",
"status",
";",
"return",
"$",
"this",
";",
"}"
] | Set Response Status Code
@param int $status
@return $this | [
"Set",
"Response",
"Status",
"Code"
] | 3230b3555abf0e74c3d593fc49c8978758969736 | https://github.com/phPoirot/Http/blob/3230b3555abf0e74c3d593fc49c8978758969736/HttpResponse.php#L68-L82 |
5,648 | phPoirot/Http | HttpResponse.php | HttpResponse.getStatusReason | function getStatusReason()
{
if ($this->statReason)
return $this->statReason;
($reason = \Poirot\Http\Response\getStatReasonFromCode($this->getStatusCode()))
?: $reason = 'Unknown';
return $reason;
} | php | function getStatusReason()
{
if ($this->statReason)
return $this->statReason;
($reason = \Poirot\Http\Response\getStatReasonFromCode($this->getStatusCode()))
?: $reason = 'Unknown';
return $reason;
} | [
"function",
"getStatusReason",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"statReason",
")",
"return",
"$",
"this",
"->",
"statReason",
";",
"(",
"$",
"reason",
"=",
"\\",
"Poirot",
"\\",
"Http",
"\\",
"Response",
"\\",
"getStatReasonFromCode",
"(",
"$",
"this",
"->",
"getStatusCode",
"(",
")",
")",
")",
"?",
":",
"$",
"reason",
"=",
"'Unknown'",
";",
"return",
"$",
"reason",
";",
"}"
] | Get Status Code Reason
@return string | [
"Get",
"Status",
"Code",
"Reason"
] | 3230b3555abf0e74c3d593fc49c8978758969736 | https://github.com/phPoirot/Http/blob/3230b3555abf0e74c3d593fc49c8978758969736/HttpResponse.php#L112-L121 |
5,649 | treehouselabs/domain | src/TreeHouse/Domain/EventStream.php | EventStream.track | public function track(EventStream $stream)
{
if (!in_array($stream, $this->tracking, true)) {
$this->tracking[] = $stream;
}
} | php | public function track(EventStream $stream)
{
if (!in_array($stream, $this->tracking, true)) {
$this->tracking[] = $stream;
}
} | [
"public",
"function",
"track",
"(",
"EventStream",
"$",
"stream",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"stream",
",",
"$",
"this",
"->",
"tracking",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"tracking",
"[",
"]",
"=",
"$",
"stream",
";",
"}",
"}"
] | When tracking, appended events are also appended to the tracking streams.
@param EventStream $stream | [
"When",
"tracking",
"appended",
"events",
"are",
"also",
"appended",
"to",
"the",
"tracking",
"streams",
"."
] | e22b319307b985dcac94687b1c2b5418b41f1998 | https://github.com/treehouselabs/domain/blob/e22b319307b985dcac94687b1c2b5418b41f1998/src/TreeHouse/Domain/EventStream.php#L78-L83 |
5,650 | CentralApps/Pagination | src/CentralApps/Pagination/PdoTrait.php | PdoTrait.prepareWithPagination | public function prepareWithPagination($statement, PaginationInterface $pagination, $driver_options = [])
{
$this->pagination = $pagination;
return $this->prepare($statement, $driver_options);
} | php | public function prepareWithPagination($statement, PaginationInterface $pagination, $driver_options = [])
{
$this->pagination = $pagination;
return $this->prepare($statement, $driver_options);
} | [
"public",
"function",
"prepareWithPagination",
"(",
"$",
"statement",
",",
"PaginationInterface",
"$",
"pagination",
",",
"$",
"driver_options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"pagination",
"=",
"$",
"pagination",
";",
"return",
"$",
"this",
"->",
"prepare",
"(",
"$",
"statement",
",",
"$",
"driver_options",
")",
";",
"}"
] | Prepare a statement with pagination
@param string $statement
@param $pagination
@param array $driver_options
@return \PdoStatement | [
"Prepare",
"a",
"statement",
"with",
"pagination"
] | 5910508b64ff5c6ea290975707b525343447b3c1 | https://github.com/CentralApps/Pagination/blob/5910508b64ff5c6ea290975707b525343447b3c1/src/CentralApps/Pagination/PdoTrait.php#L15-L20 |
5,651 | CentralApps/Pagination | src/CentralApps/Pagination/PdoTrait.php | PdoTrait.convertToCountQuery | protected function convertToCountQuery($sql)
{
try {
$this->checkForMainOffsetOrLimit($sql);
} catch (\Exception $e) {
throw $e;
}
return "SELECT
COUNT(*) as pagination_count
" . $this->stripQueryToUnnestedKeyword($sql) . "
LIMIT
1";
} | php | protected function convertToCountQuery($sql)
{
try {
$this->checkForMainOffsetOrLimit($sql);
} catch (\Exception $e) {
throw $e;
}
return "SELECT
COUNT(*) as pagination_count
" . $this->stripQueryToUnnestedKeyword($sql) . "
LIMIT
1";
} | [
"protected",
"function",
"convertToCountQuery",
"(",
"$",
"sql",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"checkForMainOffsetOrLimit",
"(",
"$",
"sql",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"return",
"\"SELECT\n COUNT(*) as pagination_count\n \"",
".",
"$",
"this",
"->",
"stripQueryToUnnestedKeyword",
"(",
"$",
"sql",
")",
".",
"\"\n LIMIT\n 1\"",
";",
"}"
] | Convert the query to a single row count
@param string $sql
@param return query | [
"Convert",
"the",
"query",
"to",
"a",
"single",
"row",
"count"
] | 5910508b64ff5c6ea290975707b525343447b3c1 | https://github.com/CentralApps/Pagination/blob/5910508b64ff5c6ea290975707b525343447b3c1/src/CentralApps/Pagination/PdoTrait.php#L96-L109 |
5,652 | CentralApps/Pagination | src/CentralApps/Pagination/PdoTrait.php | PdoTrait.checkForMainOffsetOrLimit | protected function checkForMainOffsetOrLimit($sql)
{
if ("" !== $this->stripQueryToUnnestedKeyword($sql, $unnested_keyword = 'LIMIT')) {
throw new \LogicException("Query cannot contain an unnested LIMIT when trying to paginate");
}
if ("" !== $this->stripQueryToUnnestedKeyword($sql, $unnested_keyword = 'OFFSET')) {
throw new \LogicException("Query cannot contain an unnested OFFSET when trying to paginate");
}
return true;
} | php | protected function checkForMainOffsetOrLimit($sql)
{
if ("" !== $this->stripQueryToUnnestedKeyword($sql, $unnested_keyword = 'LIMIT')) {
throw new \LogicException("Query cannot contain an unnested LIMIT when trying to paginate");
}
if ("" !== $this->stripQueryToUnnestedKeyword($sql, $unnested_keyword = 'OFFSET')) {
throw new \LogicException("Query cannot contain an unnested OFFSET when trying to paginate");
}
return true;
} | [
"protected",
"function",
"checkForMainOffsetOrLimit",
"(",
"$",
"sql",
")",
"{",
"if",
"(",
"\"\"",
"!==",
"$",
"this",
"->",
"stripQueryToUnnestedKeyword",
"(",
"$",
"sql",
",",
"$",
"unnested_keyword",
"=",
"'LIMIT'",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"\"Query cannot contain an unnested LIMIT when trying to paginate\"",
")",
";",
"}",
"if",
"(",
"\"\"",
"!==",
"$",
"this",
"->",
"stripQueryToUnnestedKeyword",
"(",
"$",
"sql",
",",
"$",
"unnested_keyword",
"=",
"'OFFSET'",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"\"Query cannot contain an unnested OFFSET when trying to paginate\"",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Ensure that the query can be paginated
@param string $sql the query
@return bool
@throws \LogicException if either LIMIT or OFFSET is found | [
"Ensure",
"that",
"the",
"query",
"can",
"be",
"paginated"
] | 5910508b64ff5c6ea290975707b525343447b3c1 | https://github.com/CentralApps/Pagination/blob/5910508b64ff5c6ea290975707b525343447b3c1/src/CentralApps/Pagination/PdoTrait.php#L117-L128 |
5,653 | deasilworks/api | src/Model/ApiCollection.php | ApiCollection.offsetGet | public function offsetGet($offset)
{
return isset($this->hashedContainer[$offset]) ? $this->hashedContainer[$offset] : null;
} | php | public function offsetGet($offset)
{
return isset($this->hashedContainer[$offset]) ? $this->hashedContainer[$offset] : null;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"hashedContainer",
"[",
"$",
"offset",
"]",
")",
"?",
"$",
"this",
"->",
"hashedContainer",
"[",
"$",
"offset",
"]",
":",
"null",
";",
"}"
] | ArrayAccess Offset Get.
@param mixed $offset
@return mixed|null | [
"ArrayAccess",
"Offset",
"Get",
"."
] | f3ba8900b246e8ea1777692b16168fd7295670fc | https://github.com/deasilworks/api/blob/f3ba8900b246e8ea1777692b16168fd7295670fc/src/Model/ApiCollection.php#L139-L142 |
5,654 | deasilworks/api | src/Model/ApiCollection.php | ApiCollection.offsetSet | public function offsetSet($offset, $argModel)
{
if (is_null($offset)) {
$this->hashedContainer[$argModel->getName()] = $argModel;
$this->indexedContainer[] = $argModel;
return;
}
$this->hashedContainer[$offset] = $argModel;
$this->indexedContainer[$offset] = $argModel;
} | php | public function offsetSet($offset, $argModel)
{
if (is_null($offset)) {
$this->hashedContainer[$argModel->getName()] = $argModel;
$this->indexedContainer[] = $argModel;
return;
}
$this->hashedContainer[$offset] = $argModel;
$this->indexedContainer[$offset] = $argModel;
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"argModel",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"offset",
")",
")",
"{",
"$",
"this",
"->",
"hashedContainer",
"[",
"$",
"argModel",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"argModel",
";",
"$",
"this",
"->",
"indexedContainer",
"[",
"]",
"=",
"$",
"argModel",
";",
"return",
";",
"}",
"$",
"this",
"->",
"hashedContainer",
"[",
"$",
"offset",
"]",
"=",
"$",
"argModel",
";",
"$",
"this",
"->",
"indexedContainer",
"[",
"$",
"offset",
"]",
"=",
"$",
"argModel",
";",
"}"
] | ArrayAccess Offset Set.
@param mixed $offset
@param ParamModel $argModel | [
"ArrayAccess",
"Offset",
"Set",
"."
] | f3ba8900b246e8ea1777692b16168fd7295670fc | https://github.com/deasilworks/api/blob/f3ba8900b246e8ea1777692b16168fd7295670fc/src/Model/ApiCollection.php#L150-L161 |
5,655 | tsommie/eloquent-search | src/EloquentSearch.php | EloquentSearch.search | static public function search($keyword, $models = ['App\User'], $perPage = 15, $currentPage = null, array $options = [])
{
$query = null;
if (empty($options)) {
$options = [
'path' => Paginator::resolveCurrentPath()
];
}
foreach ($models as $model) {
if ($model === reset($models)) {
$query = self::searchModel(new $model, $keyword);
}
$query = $query->merge(self::searchModel(new $model, $keyword));
}
return new LengthAwarePaginator($query->forPage(null, $perPage), $query->count(), $perPage, $currentPage, $options);
} | php | static public function search($keyword, $models = ['App\User'], $perPage = 15, $currentPage = null, array $options = [])
{
$query = null;
if (empty($options)) {
$options = [
'path' => Paginator::resolveCurrentPath()
];
}
foreach ($models as $model) {
if ($model === reset($models)) {
$query = self::searchModel(new $model, $keyword);
}
$query = $query->merge(self::searchModel(new $model, $keyword));
}
return new LengthAwarePaginator($query->forPage(null, $perPage), $query->count(), $perPage, $currentPage, $options);
} | [
"static",
"public",
"function",
"search",
"(",
"$",
"keyword",
",",
"$",
"models",
"=",
"[",
"'App\\User'",
"]",
",",
"$",
"perPage",
"=",
"15",
",",
"$",
"currentPage",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"$",
"options",
"=",
"[",
"'path'",
"=>",
"Paginator",
"::",
"resolveCurrentPath",
"(",
")",
"]",
";",
"}",
"foreach",
"(",
"$",
"models",
"as",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"model",
"===",
"reset",
"(",
"$",
"models",
")",
")",
"{",
"$",
"query",
"=",
"self",
"::",
"searchModel",
"(",
"new",
"$",
"model",
",",
"$",
"keyword",
")",
";",
"}",
"$",
"query",
"=",
"$",
"query",
"->",
"merge",
"(",
"self",
"::",
"searchModel",
"(",
"new",
"$",
"model",
",",
"$",
"keyword",
")",
")",
";",
"}",
"return",
"new",
"LengthAwarePaginator",
"(",
"$",
"query",
"->",
"forPage",
"(",
"null",
",",
"$",
"perPage",
")",
",",
"$",
"query",
"->",
"count",
"(",
")",
",",
"$",
"perPage",
",",
"$",
"currentPage",
",",
"$",
"options",
")",
";",
"}"
] | Search for keyword in the given models.
@param string $keyword
@param array $models
@param int $perPage
@param int|null $currentPage
@param array $options (path, query, fragment, pageName)
@return \Illuminate\Pagination\Paginator | [
"Search",
"for",
"keyword",
"in",
"the",
"given",
"models",
"."
] | 91d4e859227f04dfc324c2c89cc0a31f08bbfd74 | https://github.com/tsommie/eloquent-search/blob/91d4e859227f04dfc324c2c89cc0a31f08bbfd74/src/EloquentSearch.php#L27-L49 |
5,656 | gismo-framework/ExpressionLanguage | Parser.php | Parser.parse | public function parse(TokenStream $stream, $names = array())
{
$this->stream = $stream;
$this->names = $names;
$node = $this->parseExpression();
if (!$stream->isEOF()) {
throw new SyntaxError(sprintf('Unexpected token "%s" of value "%s"', $stream->current->type, $stream->current->value), $stream->current->cursor);
}
return $node;
} | php | public function parse(TokenStream $stream, $names = array())
{
$this->stream = $stream;
$this->names = $names;
$node = $this->parseExpression();
if (!$stream->isEOF()) {
throw new SyntaxError(sprintf('Unexpected token "%s" of value "%s"', $stream->current->type, $stream->current->value), $stream->current->cursor);
}
return $node;
} | [
"public",
"function",
"parse",
"(",
"TokenStream",
"$",
"stream",
",",
"$",
"names",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"stream",
"=",
"$",
"stream",
";",
"$",
"this",
"->",
"names",
"=",
"$",
"names",
";",
"$",
"node",
"=",
"$",
"this",
"->",
"parseExpression",
"(",
")",
";",
"if",
"(",
"!",
"$",
"stream",
"->",
"isEOF",
"(",
")",
")",
"{",
"throw",
"new",
"SyntaxError",
"(",
"sprintf",
"(",
"'Unexpected token \"%s\" of value \"%s\"'",
",",
"$",
"stream",
"->",
"current",
"->",
"type",
",",
"$",
"stream",
"->",
"current",
"->",
"value",
")",
",",
"$",
"stream",
"->",
"current",
"->",
"cursor",
")",
";",
"}",
"return",
"$",
"node",
";",
"}"
] | Converts a token stream to a node tree.
The valid names is an array where the values
are the names that the user can use in an expression.
If the variable name in the compiled PHP code must be
different, define it as the key.
For instance, ['this' => 'container'] means that the
variable 'container' can be used in the expression
but the compiled code will use 'this'.
@param TokenStream $stream A token stream instance
@param array $names An array of valid names
@return Node\Node A node tree
@throws SyntaxError | [
"Converts",
"a",
"token",
"stream",
"to",
"a",
"node",
"tree",
"."
] | ceb176416dc3669aa269e8f93b7232a94c221167 | https://github.com/gismo-framework/ExpressionLanguage/blob/ceb176416dc3669aa269e8f93b7232a94c221167/Parser.php#L95-L106 |
5,657 | scottrobertson/pushover | src/Scottymeuk/Pushover/Client.php | Client.pushMultiple | public function pushMultiple(array $users)
{
$failed = array();
foreach ($users as $user) {
$push = $this->push($user);
if (! $push) {
$failed[] = $user;
}
}
return !count($failed);
} | php | public function pushMultiple(array $users)
{
$failed = array();
foreach ($users as $user) {
$push = $this->push($user);
if (! $push) {
$failed[] = $user;
}
}
return !count($failed);
} | [
"public",
"function",
"pushMultiple",
"(",
"array",
"$",
"users",
")",
"{",
"$",
"failed",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"users",
"as",
"$",
"user",
")",
"{",
"$",
"push",
"=",
"$",
"this",
"->",
"push",
"(",
"$",
"user",
")",
";",
"if",
"(",
"!",
"$",
"push",
")",
"{",
"$",
"failed",
"[",
"]",
"=",
"$",
"user",
";",
"}",
"}",
"return",
"!",
"count",
"(",
"$",
"failed",
")",
";",
"}"
] | Push to multiple users
@param Array $users Array of users
@return bool Did any of them fail? | [
"Push",
"to",
"multiple",
"users"
] | 6aa799ad94dd24eafa997db7a4c2de28b43d4fcb | https://github.com/scottrobertson/pushover/blob/6aa799ad94dd24eafa997db7a4c2de28b43d4fcb/src/Scottymeuk/Pushover/Client.php#L101-L112 |
5,658 | scottrobertson/pushover | src/Scottymeuk/Pushover/Client.php | Client.push | public function push($user)
{
if (! isset($this->data['message'])) {
throw new Exception('You must supply a message');
}
// Fields to send
$data = array_merge(
$this->data,
array(
'user' => $user,
)
);
// Send data to API
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->api_url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
return isset($result['status']) && (int) $result['status'] === 1;
} | php | public function push($user)
{
if (! isset($this->data['message'])) {
throw new Exception('You must supply a message');
}
// Fields to send
$data = array_merge(
$this->data,
array(
'user' => $user,
)
);
// Send data to API
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->api_url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($curl), true);
curl_close($curl);
return isset($result['status']) && (int) $result['status'] === 1;
} | [
"public",
"function",
"push",
"(",
"$",
"user",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'message'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'You must supply a message'",
")",
";",
"}",
"// Fields to send",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"data",
",",
"array",
"(",
"'user'",
"=>",
"$",
"user",
",",
")",
")",
";",
"// Send data to API",
"$",
"curl",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_URL",
",",
"$",
"this",
"->",
"api_url",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_POST",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"data",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"$",
"result",
"=",
"json_decode",
"(",
"curl_exec",
"(",
"$",
"curl",
")",
",",
"true",
")",
";",
"curl_close",
"(",
"$",
"curl",
")",
";",
"return",
"isset",
"(",
"$",
"result",
"[",
"'status'",
"]",
")",
"&&",
"(",
"int",
")",
"$",
"result",
"[",
"'status'",
"]",
"===",
"1",
";",
"}"
] | Push a notification to a specific user
@param string $user The user token
@return bool Did the notification send or not? | [
"Push",
"a",
"notification",
"to",
"a",
"specific",
"user"
] | 6aa799ad94dd24eafa997db7a4c2de28b43d4fcb | https://github.com/scottrobertson/pushover/blob/6aa799ad94dd24eafa997db7a4c2de28b43d4fcb/src/Scottymeuk/Pushover/Client.php#L120-L144 |
5,659 | chigix/chiji-frontend | src/Project/Project.php | Project.getMatchRoad | public function getMatchRoad(File $file) {
foreach ($this->roadMap as $road) {
/* @var $road SourceRoad */
if ($road->resourceCheck($file)) {
return $road;
}
}
return NULL;
} | php | public function getMatchRoad(File $file) {
foreach ($this->roadMap as $road) {
/* @var $road SourceRoad */
if ($road->resourceCheck($file)) {
return $road;
}
}
return NULL;
} | [
"public",
"function",
"getMatchRoad",
"(",
"File",
"$",
"file",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"roadMap",
"as",
"$",
"road",
")",
"{",
"/* @var $road SourceRoad */",
"if",
"(",
"$",
"road",
"->",
"resourceCheck",
"(",
"$",
"file",
")",
")",
"{",
"return",
"$",
"road",
";",
"}",
"}",
"return",
"NULL",
";",
"}"
] | Returns the first match road for the target resource file
with auto registration for the matched resource file.
@param File $file
@return SourceRoad|null | [
"Returns",
"the",
"first",
"match",
"road",
"for",
"the",
"target",
"resource",
"file",
"with",
"auto",
"registration",
"for",
"the",
"matched",
"resource",
"file",
"."
] | 5407f98c21ee99f8bbef43c97a231c0f81ed3e74 | https://github.com/chigix/chiji-frontend/blob/5407f98c21ee99f8bbef43c97a231c0f81ed3e74/src/Project/Project.php#L141-L149 |
5,660 | chigix/chiji-frontend | src/Project/Project.php | Project.getSourceDirs | public function getSourceDirs() {
$dirs = array();
foreach ($this->roadMap as $road) {
/* @var $road SourceRoad */
array_push($dirs, $road->getSourceDir());
}
return $dirs;
} | php | public function getSourceDirs() {
$dirs = array();
foreach ($this->roadMap as $road) {
/* @var $road SourceRoad */
array_push($dirs, $road->getSourceDir());
}
return $dirs;
} | [
"public",
"function",
"getSourceDirs",
"(",
")",
"{",
"$",
"dirs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"roadMap",
"as",
"$",
"road",
")",
"{",
"/* @var $road SourceRoad */",
"array_push",
"(",
"$",
"dirs",
",",
"$",
"road",
"->",
"getSourceDir",
"(",
")",
")",
";",
"}",
"return",
"$",
"dirs",
";",
"}"
] | Returns all the source directory objects from roadmap.
@return array<File> | [
"Returns",
"all",
"the",
"source",
"directory",
"objects",
"from",
"roadmap",
"."
] | 5407f98c21ee99f8bbef43c97a231c0f81ed3e74 | https://github.com/chigix/chiji-frontend/blob/5407f98c21ee99f8bbef43c97a231c0f81ed3e74/src/Project/Project.php#L155-L162 |
5,661 | chigix/chiji-frontend | src/Project/Project.php | Project.getReleaseDirs | public function getReleaseDirs() {
$dirs = array();
foreach ($this->roadMap as $road) {
/* @var $road SourceRoad */
$release_dir = $road->getReleaseDir();
if (empty($release_dir)) {
continue;
}
if (!$release_dir->exists()) {
if (!$release_dir->mkdirs()) {
continue;
}
}
array_push($dirs, $release_dir);
}
return $dirs;
} | php | public function getReleaseDirs() {
$dirs = array();
foreach ($this->roadMap as $road) {
/* @var $road SourceRoad */
$release_dir = $road->getReleaseDir();
if (empty($release_dir)) {
continue;
}
if (!$release_dir->exists()) {
if (!$release_dir->mkdirs()) {
continue;
}
}
array_push($dirs, $release_dir);
}
return $dirs;
} | [
"public",
"function",
"getReleaseDirs",
"(",
")",
"{",
"$",
"dirs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"roadMap",
"as",
"$",
"road",
")",
"{",
"/* @var $road SourceRoad */",
"$",
"release_dir",
"=",
"$",
"road",
"->",
"getReleaseDir",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"release_dir",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"release_dir",
"->",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"release_dir",
"->",
"mkdirs",
"(",
")",
")",
"{",
"continue",
";",
"}",
"}",
"array_push",
"(",
"$",
"dirs",
",",
"$",
"release_dir",
")",
";",
"}",
"return",
"$",
"dirs",
";",
"}"
] | Returns all the release directory objects from roadmap.
@return array<File> | [
"Returns",
"all",
"the",
"release",
"directory",
"objects",
"from",
"roadmap",
"."
] | 5407f98c21ee99f8bbef43c97a231c0f81ed3e74 | https://github.com/chigix/chiji-frontend/blob/5407f98c21ee99f8bbef43c97a231c0f81ed3e74/src/Project/Project.php#L168-L184 |
5,662 | chigix/chiji-frontend | src/Project/Project.php | Project.getAllMembers | public function getAllMembers() {
$this->roadMap;
$this->resources;
$result = array();
foreach ($this->roadMap as $road) {
/* @var $road SourceRoad */
$result[$road->getMemberId()] = $road;
}
foreach ($this->resources as $resource) {
/* @var $resource AbstractResourceFile */
$result[$resource->getMemberId()] = $resource;
}
return $result;
} | php | public function getAllMembers() {
$this->roadMap;
$this->resources;
$result = array();
foreach ($this->roadMap as $road) {
/* @var $road SourceRoad */
$result[$road->getMemberId()] = $road;
}
foreach ($this->resources as $resource) {
/* @var $resource AbstractResourceFile */
$result[$resource->getMemberId()] = $resource;
}
return $result;
} | [
"public",
"function",
"getAllMembers",
"(",
")",
"{",
"$",
"this",
"->",
"roadMap",
";",
"$",
"this",
"->",
"resources",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"roadMap",
"as",
"$",
"road",
")",
"{",
"/* @var $road SourceRoad */",
"$",
"result",
"[",
"$",
"road",
"->",
"getMemberId",
"(",
")",
"]",
"=",
"$",
"road",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"resources",
"as",
"$",
"resource",
")",
"{",
"/* @var $resource AbstractResourceFile */",
"$",
"result",
"[",
"$",
"resource",
"->",
"getMemberId",
"(",
")",
"]",
"=",
"$",
"resource",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get all the Member Elements such as SourceRoad, annotation and resources.
@return {memberId:MemberIdentifier} | [
"Get",
"all",
"the",
"Member",
"Elements",
"such",
"as",
"SourceRoad",
"annotation",
"and",
"resources",
"."
] | 5407f98c21ee99f8bbef43c97a231c0f81ed3e74 | https://github.com/chigix/chiji-frontend/blob/5407f98c21ee99f8bbef43c97a231c0f81ed3e74/src/Project/Project.php#L191-L204 |
5,663 | chigix/chiji-frontend | src/Project/Project.php | Project.registerResource | public function registerResource(AbstractResourceFile $resource) {
if (!isset($this->resources[md5($resource->getRealPath())])) {
$this->resources[md5($resource->getRealPath())] = $resource;
}
} | php | public function registerResource(AbstractResourceFile $resource) {
if (!isset($this->resources[md5($resource->getRealPath())])) {
$this->resources[md5($resource->getRealPath())] = $resource;
}
} | [
"public",
"function",
"registerResource",
"(",
"AbstractResourceFile",
"$",
"resource",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"resources",
"[",
"md5",
"(",
"$",
"resource",
"->",
"getRealPath",
"(",
")",
")",
"]",
")",
")",
"{",
"$",
"this",
"->",
"resources",
"[",
"md5",
"(",
"$",
"resource",
"->",
"getRealPath",
"(",
")",
")",
"]",
"=",
"$",
"resource",
";",
"}",
"}"
] | Register a resource to this project.
@param AbstractResourceFile $resource | [
"Register",
"a",
"resource",
"to",
"this",
"project",
"."
] | 5407f98c21ee99f8bbef43c97a231c0f81ed3e74 | https://github.com/chigix/chiji-frontend/blob/5407f98c21ee99f8bbef43c97a231c0f81ed3e74/src/Project/Project.php#L211-L215 |
5,664 | chigix/chiji-frontend | src/Project/Project.php | Project.getResourceByFile | public function getResourceByFile(File $file) {
if (isset($this->resources[md5($file->getAbsolutePath())])) {
return $this->resources[md5($file->getAbsolutePath())];
} else {
return null;
}
} | php | public function getResourceByFile(File $file) {
if (isset($this->resources[md5($file->getAbsolutePath())])) {
return $this->resources[md5($file->getAbsolutePath())];
} else {
return null;
}
} | [
"public",
"function",
"getResourceByFile",
"(",
"File",
"$",
"file",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"resources",
"[",
"md5",
"(",
"$",
"file",
"->",
"getAbsolutePath",
"(",
")",
")",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"resources",
"[",
"md5",
"(",
"$",
"file",
"->",
"getAbsolutePath",
"(",
")",
")",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Get the target resource via the given file object or return null
if not registered.
@param File $file
@return AbstractResourceFile The corresponding resource object. | [
"Get",
"the",
"target",
"resource",
"via",
"the",
"given",
"file",
"object",
"or",
"return",
"null",
"if",
"not",
"registered",
"."
] | 5407f98c21ee99f8bbef43c97a231c0f81ed3e74 | https://github.com/chigix/chiji-frontend/blob/5407f98c21ee99f8bbef43c97a231c0f81ed3e74/src/Project/Project.php#L224-L230 |
5,665 | rozaverta/cmf | core/View/View.php | View.getOn | public function getOn( string $name, $default = "" )
{
$event = new RenderGetOnEvent( $name, $this->getPath($name, $default) );
EventManager::dispatch($event);
return $event->getParam("value");
} | php | public function getOn( string $name, $default = "" )
{
$event = new RenderGetOnEvent( $name, $this->getPath($name, $default) );
EventManager::dispatch($event);
return $event->getParam("value");
} | [
"public",
"function",
"getOn",
"(",
"string",
"$",
"name",
",",
"$",
"default",
"=",
"\"\"",
")",
"{",
"$",
"event",
"=",
"new",
"RenderGetOnEvent",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"getPath",
"(",
"$",
"name",
",",
"$",
"default",
")",
")",
";",
"EventManager",
"::",
"dispatch",
"(",
"$",
"event",
")",
";",
"return",
"$",
"event",
"->",
"getParam",
"(",
"\"value\"",
")",
";",
"}"
] | Use RenderGetOnEvent event before return item value
@example <?= $view->getOn("content") ?>
@example <?= $view->getOn("page_title") ?>
@param string $name name or path
@param string $default default result value
@return mixed | [
"Use",
"RenderGetOnEvent",
"event",
"before",
"return",
"item",
"value"
] | 95ed38362e397d1c700ee255f7200234ef98d356 | https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/View/View.php#L417-L422 |
5,666 | rozaverta/cmf | core/View/View.php | View.fillChoice | public function fillChoice( array $keys, $default = "" )
{
foreach( $keys as $key )
{
if( $this->isFill($key) )
{
return $this->items[$key];
}
}
return $default;
} | php | public function fillChoice( array $keys, $default = "" )
{
foreach( $keys as $key )
{
if( $this->isFill($key) )
{
return $this->items[$key];
}
}
return $default;
} | [
"public",
"function",
"fillChoice",
"(",
"array",
"$",
"keys",
",",
"$",
"default",
"=",
"\"\"",
")",
"{",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isFill",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"return",
"$",
"default",
";",
"}"
] | Get an item from the collection by keys if value not empty.
@param array $keys
@param mixed $default default value
@return mixed | [
"Get",
"an",
"item",
"from",
"the",
"collection",
"by",
"keys",
"if",
"value",
"not",
"empty",
"."
] | 95ed38362e397d1c700ee255f7200234ef98d356 | https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/View/View.php#L431-L442 |
5,667 | e-commerce-passaro/produto | src/Produto/Produto.php | Produto.toArray | public function toArray()
{
return array(
'id' => $this->getId(),
'titulo' => $this->getTitulo(),
'imagem' => $this->getImagem(),
'descricao' => $this->getDescricao(),
'preco' => $this->getPreco()
);
} | php | public function toArray()
{
return array(
'id' => $this->getId(),
'titulo' => $this->getTitulo(),
'imagem' => $this->getImagem(),
'descricao' => $this->getDescricao(),
'preco' => $this->getPreco()
);
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"'titulo'",
"=>",
"$",
"this",
"->",
"getTitulo",
"(",
")",
",",
"'imagem'",
"=>",
"$",
"this",
"->",
"getImagem",
"(",
")",
",",
"'descricao'",
"=>",
"$",
"this",
"->",
"getDescricao",
"(",
")",
",",
"'preco'",
"=>",
"$",
"this",
"->",
"getPreco",
"(",
")",
")",
";",
"}"
] | Obtem a estrutura da entity Produto em formato array
@return array | [
"Obtem",
"a",
"estrutura",
"da",
"entity",
"Produto",
"em",
"formato",
"array"
] | 31cb790173485c37db8de9a2cc5cfaeb827250aa | https://github.com/e-commerce-passaro/produto/blob/31cb790173485c37db8de9a2cc5cfaeb827250aa/src/Produto/Produto.php#L116-L125 |
5,668 | wb-crowdfusion/wb-lib | classes/controllers/WbneighborWebController.php | WbneighborWebController.getNeighbor | private function getNeighbor(Date $slugDate, $direction = 'next')
{
if (strcasecmp($direction, 'next') == 0) {
$activeDate = 'ActiveDate.after';
$orderBy = 'ActiveDate ASC';
$slugDate = $slugDate->modify('+1 minute');
} else {
$activeDate = 'ActiveDate.before';
$orderBy = 'ActiveDate DESC';
$slugDate = $slugDate->modify('-1 minute');
}
$nq = new NodeQuery();
$this->passthruTemplateVariable($nq, 'Elements.in');
$this->passthruTemplateVariable($nq, 'OutTags.exist');
$this->passthruTemplateVariable($nq, 'Meta.select');
$this->passthruTemplateVariable($nq, 'OutTags.select');
$this->passthruTemplateVariable($nq, 'InTags.select');
$this->setMetaWhereParams($nq);
$nq->setParameter($activeDate, $slugDate);
$nq->setParameter('Status.isActive', true);
$nq->setLimit(1);
$nq->isRetrieveTotalRecords(false);
$nq->setOrderBy($orderBy);
return $this->RegulatedNodeService->findAll($nq)->getResults();
} | php | private function getNeighbor(Date $slugDate, $direction = 'next')
{
if (strcasecmp($direction, 'next') == 0) {
$activeDate = 'ActiveDate.after';
$orderBy = 'ActiveDate ASC';
$slugDate = $slugDate->modify('+1 minute');
} else {
$activeDate = 'ActiveDate.before';
$orderBy = 'ActiveDate DESC';
$slugDate = $slugDate->modify('-1 minute');
}
$nq = new NodeQuery();
$this->passthruTemplateVariable($nq, 'Elements.in');
$this->passthruTemplateVariable($nq, 'OutTags.exist');
$this->passthruTemplateVariable($nq, 'Meta.select');
$this->passthruTemplateVariable($nq, 'OutTags.select');
$this->passthruTemplateVariable($nq, 'InTags.select');
$this->setMetaWhereParams($nq);
$nq->setParameter($activeDate, $slugDate);
$nq->setParameter('Status.isActive', true);
$nq->setLimit(1);
$nq->isRetrieveTotalRecords(false);
$nq->setOrderBy($orderBy);
return $this->RegulatedNodeService->findAll($nq)->getResults();
} | [
"private",
"function",
"getNeighbor",
"(",
"Date",
"$",
"slugDate",
",",
"$",
"direction",
"=",
"'next'",
")",
"{",
"if",
"(",
"strcasecmp",
"(",
"$",
"direction",
",",
"'next'",
")",
"==",
"0",
")",
"{",
"$",
"activeDate",
"=",
"'ActiveDate.after'",
";",
"$",
"orderBy",
"=",
"'ActiveDate ASC'",
";",
"$",
"slugDate",
"=",
"$",
"slugDate",
"->",
"modify",
"(",
"'+1 minute'",
")",
";",
"}",
"else",
"{",
"$",
"activeDate",
"=",
"'ActiveDate.before'",
";",
"$",
"orderBy",
"=",
"'ActiveDate DESC'",
";",
"$",
"slugDate",
"=",
"$",
"slugDate",
"->",
"modify",
"(",
"'-1 minute'",
")",
";",
"}",
"$",
"nq",
"=",
"new",
"NodeQuery",
"(",
")",
";",
"$",
"this",
"->",
"passthruTemplateVariable",
"(",
"$",
"nq",
",",
"'Elements.in'",
")",
";",
"$",
"this",
"->",
"passthruTemplateVariable",
"(",
"$",
"nq",
",",
"'OutTags.exist'",
")",
";",
"$",
"this",
"->",
"passthruTemplateVariable",
"(",
"$",
"nq",
",",
"'Meta.select'",
")",
";",
"$",
"this",
"->",
"passthruTemplateVariable",
"(",
"$",
"nq",
",",
"'OutTags.select'",
")",
";",
"$",
"this",
"->",
"passthruTemplateVariable",
"(",
"$",
"nq",
",",
"'InTags.select'",
")",
";",
"$",
"this",
"->",
"setMetaWhereParams",
"(",
"$",
"nq",
")",
";",
"$",
"nq",
"->",
"setParameter",
"(",
"$",
"activeDate",
",",
"$",
"slugDate",
")",
";",
"$",
"nq",
"->",
"setParameter",
"(",
"'Status.isActive'",
",",
"true",
")",
";",
"$",
"nq",
"->",
"setLimit",
"(",
"1",
")",
";",
"$",
"nq",
"->",
"isRetrieveTotalRecords",
"(",
"false",
")",
";",
"$",
"nq",
"->",
"setOrderBy",
"(",
"$",
"orderBy",
")",
";",
"return",
"$",
"this",
"->",
"RegulatedNodeService",
"->",
"findAll",
"(",
"$",
"nq",
")",
"->",
"getResults",
"(",
")",
";",
"}"
] | gets a single neighboring item
@param Date $slugDate
@param string $direction
@return mixed | [
"gets",
"a",
"single",
"neighboring",
"item"
] | 972b0f1d4aa2fa538ee6c6b436ac84849a579326 | https://github.com/wb-crowdfusion/wb-lib/blob/972b0f1d4aa2fa538ee6c6b436ac84849a579326/classes/controllers/WbneighborWebController.php#L58-L84 |
5,669 | amenophis/Prince | Generator/Generator.php | Generator.executeCommand | protected function executeCommand($command)
{
$process = new Process($command);
$process->run();
return array(
$process->getExitCode(),
$process->getOutput(),
$process->getErrorOutput(),
);
} | php | protected function executeCommand($command)
{
$process = new Process($command);
$process->run();
return array(
$process->getExitCode(),
$process->getOutput(),
$process->getErrorOutput(),
);
} | [
"protected",
"function",
"executeCommand",
"(",
"$",
"command",
")",
"{",
"$",
"process",
"=",
"new",
"Process",
"(",
"$",
"command",
")",
";",
"$",
"process",
"->",
"run",
"(",
")",
";",
"return",
"array",
"(",
"$",
"process",
"->",
"getExitCode",
"(",
")",
",",
"$",
"process",
"->",
"getOutput",
"(",
")",
",",
"$",
"process",
"->",
"getErrorOutput",
"(",
")",
",",
")",
";",
"}"
] | Executes the given command via shell and returns the complete output as
a string
@param string $command
@return array(status, stdout, stderr) | [
"Executes",
"the",
"given",
"command",
"via",
"shell",
"and",
"returns",
"the",
"complete",
"output",
"as",
"a",
"string"
] | b5411d5bb458ddae6e98560a30a34f4022f7c096 | https://github.com/amenophis/Prince/blob/b5411d5bb458ddae6e98560a30a34f4022f7c096/Generator/Generator.php#L173-L184 |
5,670 | financialmedia/keystone-client | src/FM/Keystone/Client/Factory.php | Factory.onRequestError | public function onRequestError(Event $event)
{
// if token validity expired, re-request with a new token.
if (in_array($event['response']->getStatusCode(), array(401, 403))) {
/** @var \Guzzle\Http\Message\Request $request */
$request = $event['request'];
// if this is the token-url, stop now because we won't be able to fetch a token
if ($request->getUrl() === $request->getClient()->getTokenUrl()) {
return;
}
// see if we have retries left
if ($request->hasHeader('X-Auth-Retries')) {
$headerValues = $request->getHeader('X-Auth-Retries')->toArray();
$retriesValue = array_shift($headerValues);
}
$retries = $request->hasHeader('X-Auth-Retries') ? $retriesValue : 1;
if ($retries < 1) {
if ($this->logger) {
$this->logger->addError('Keystone request failed, no more retries left');
}
return;
}
if ($this->logger) {
$this->logger->addDebug('Token expired, fetching a new one');
}
// set new token in client
$client = $request->getClient();
$this->resetToken($client);
// clone request and update token header
$newRequest = clone $request;
$newRequest->setHeader('X-Auth-Token', $client->getToken()->getId());
$newRequest->setHeader('X-Auth-Retries', --$retries);
$newResponse = $newRequest->send();
// Set the response object of the request without firing more events
$event['response'] = $newResponse;
// Stop other events from firing when you override 401 responses
$event->stopPropagation();
}
} | php | public function onRequestError(Event $event)
{
// if token validity expired, re-request with a new token.
if (in_array($event['response']->getStatusCode(), array(401, 403))) {
/** @var \Guzzle\Http\Message\Request $request */
$request = $event['request'];
// if this is the token-url, stop now because we won't be able to fetch a token
if ($request->getUrl() === $request->getClient()->getTokenUrl()) {
return;
}
// see if we have retries left
if ($request->hasHeader('X-Auth-Retries')) {
$headerValues = $request->getHeader('X-Auth-Retries')->toArray();
$retriesValue = array_shift($headerValues);
}
$retries = $request->hasHeader('X-Auth-Retries') ? $retriesValue : 1;
if ($retries < 1) {
if ($this->logger) {
$this->logger->addError('Keystone request failed, no more retries left');
}
return;
}
if ($this->logger) {
$this->logger->addDebug('Token expired, fetching a new one');
}
// set new token in client
$client = $request->getClient();
$this->resetToken($client);
// clone request and update token header
$newRequest = clone $request;
$newRequest->setHeader('X-Auth-Token', $client->getToken()->getId());
$newRequest->setHeader('X-Auth-Retries', --$retries);
$newResponse = $newRequest->send();
// Set the response object of the request without firing more events
$event['response'] = $newResponse;
// Stop other events from firing when you override 401 responses
$event->stopPropagation();
}
} | [
"public",
"function",
"onRequestError",
"(",
"Event",
"$",
"event",
")",
"{",
"// if token validity expired, re-request with a new token.",
"if",
"(",
"in_array",
"(",
"$",
"event",
"[",
"'response'",
"]",
"->",
"getStatusCode",
"(",
")",
",",
"array",
"(",
"401",
",",
"403",
")",
")",
")",
"{",
"/** @var \\Guzzle\\Http\\Message\\Request $request */",
"$",
"request",
"=",
"$",
"event",
"[",
"'request'",
"]",
";",
"// if this is the token-url, stop now because we won't be able to fetch a token",
"if",
"(",
"$",
"request",
"->",
"getUrl",
"(",
")",
"===",
"$",
"request",
"->",
"getClient",
"(",
")",
"->",
"getTokenUrl",
"(",
")",
")",
"{",
"return",
";",
"}",
"// see if we have retries left",
"if",
"(",
"$",
"request",
"->",
"hasHeader",
"(",
"'X-Auth-Retries'",
")",
")",
"{",
"$",
"headerValues",
"=",
"$",
"request",
"->",
"getHeader",
"(",
"'X-Auth-Retries'",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"retriesValue",
"=",
"array_shift",
"(",
"$",
"headerValues",
")",
";",
"}",
"$",
"retries",
"=",
"$",
"request",
"->",
"hasHeader",
"(",
"'X-Auth-Retries'",
")",
"?",
"$",
"retriesValue",
":",
"1",
";",
"if",
"(",
"$",
"retries",
"<",
"1",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"addError",
"(",
"'Keystone request failed, no more retries left'",
")",
";",
"}",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"addDebug",
"(",
"'Token expired, fetching a new one'",
")",
";",
"}",
"// set new token in client",
"$",
"client",
"=",
"$",
"request",
"->",
"getClient",
"(",
")",
";",
"$",
"this",
"->",
"resetToken",
"(",
"$",
"client",
")",
";",
"// clone request and update token header",
"$",
"newRequest",
"=",
"clone",
"$",
"request",
";",
"$",
"newRequest",
"->",
"setHeader",
"(",
"'X-Auth-Token'",
",",
"$",
"client",
"->",
"getToken",
"(",
")",
"->",
"getId",
"(",
")",
")",
";",
"$",
"newRequest",
"->",
"setHeader",
"(",
"'X-Auth-Retries'",
",",
"--",
"$",
"retries",
")",
";",
"$",
"newResponse",
"=",
"$",
"newRequest",
"->",
"send",
"(",
")",
";",
"// Set the response object of the request without firing more events",
"$",
"event",
"[",
"'response'",
"]",
"=",
"$",
"newResponse",
";",
"// Stop other events from firing when you override 401 responses",
"$",
"event",
"->",
"stopPropagation",
"(",
")",
";",
"}",
"}"
] | Listener for request errors. Handles requests with expired
authentication, by reauthenticating and sending the request again. | [
"Listener",
"for",
"request",
"errors",
".",
"Handles",
"requests",
"with",
"expired",
"authentication",
"by",
"reauthenticating",
"and",
"sending",
"the",
"request",
"again",
"."
] | ca9d4f112f1dbbf312b2c4705753dc8d0a023569 | https://github.com/financialmedia/keystone-client/blob/ca9d4f112f1dbbf312b2c4705753dc8d0a023569/src/FM/Keystone/Client/Factory.php#L88-L135 |
5,671 | AlexHowansky/ork-base | src/String/Template.php | Template.apply | public function apply(array $params)
{
$tags = [];
foreach ($params as $key => $value) {
$tags['/{' . $key . '}/'] = $value;
}
return preg_replace(array_keys($tags), array_values($tags), $this->getConfig('template'));
} | php | public function apply(array $params)
{
$tags = [];
foreach ($params as $key => $value) {
$tags['/{' . $key . '}/'] = $value;
}
return preg_replace(array_keys($tags), array_values($tags), $this->getConfig('template'));
} | [
"public",
"function",
"apply",
"(",
"array",
"$",
"params",
")",
"{",
"$",
"tags",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"tags",
"[",
"'/{'",
".",
"$",
"key",
".",
"'}/'",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"preg_replace",
"(",
"array_keys",
"(",
"$",
"tags",
")",
",",
"array_values",
"(",
"$",
"tags",
")",
",",
"$",
"this",
"->",
"getConfig",
"(",
"'template'",
")",
")",
";",
"}"
] | Apply a data set to the template.
@param array $params The data set.
@return string The filled-out template. | [
"Apply",
"a",
"data",
"set",
"to",
"the",
"template",
"."
] | 5f4ab14e63bbc8b17898639fd1fff86ee6659bb0 | https://github.com/AlexHowansky/ork-base/blob/5f4ab14e63bbc8b17898639fd1fff86ee6659bb0/src/String/Template.php#L50-L57 |
5,672 | MINISTRYGmbH/morrow-core | src/Session.php | Session.get | public function get($identifier = null, $fallback = null) {
return $this->arrayGet(self::$_data, '_session_class._standard.' . $this->section . ($identifier !== null ? '.' . $identifier : ''), $fallback);
} | php | public function get($identifier = null, $fallback = null) {
return $this->arrayGet(self::$_data, '_session_class._standard.' . $this->section . ($identifier !== null ? '.' . $identifier : ''), $fallback);
} | [
"public",
"function",
"get",
"(",
"$",
"identifier",
"=",
"null",
",",
"$",
"fallback",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"arrayGet",
"(",
"self",
"::",
"$",
"_data",
",",
"'_session_class._standard.'",
".",
"$",
"this",
"->",
"section",
".",
"(",
"$",
"identifier",
"!==",
"null",
"?",
"'.'",
".",
"$",
"identifier",
":",
"''",
")",
",",
"$",
"fallback",
")",
";",
"}"
] | Retrieves session data saved with a given identifier.
@param string $identifier The identifier you have used on setting the data.
@param mixed $fallback The return value if the identifier was not found.
@return mixed The requested data. | [
"Retrieves",
"session",
"data",
"saved",
"with",
"a",
"given",
"identifier",
"."
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Session.php#L172-L174 |
5,673 | MINISTRYGmbH/morrow-core | src/Session.php | Session.set | public function set($identifier, $value) {
$this->arraySet(self::$_data, '_session_class._standard.' . $this->section . '.' . $identifier, $value);
} | php | public function set($identifier, $value) {
$this->arraySet(self::$_data, '_session_class._standard.' . $this->section . '.' . $identifier, $value);
} | [
"public",
"function",
"set",
"(",
"$",
"identifier",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"arraySet",
"(",
"self",
"::",
"$",
"_data",
",",
"'_session_class._standard.'",
".",
"$",
"this",
"->",
"section",
".",
"'.'",
".",
"$",
"identifier",
",",
"$",
"value",
")",
";",
"}"
] | Sets session data with a given identifier.
@param string $identifier The identifier you want to store the data with.
@param string $value The data you want to store.
@return null | [
"Sets",
"session",
"data",
"with",
"a",
"given",
"identifier",
"."
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Session.php#L183-L185 |
5,674 | MINISTRYGmbH/morrow-core | src/Session.php | Session.getFlash | public function getFlash($identifier = null, $fallback = null) {
$value = $this->arrayGet(self::$_data, '_session_class._flash.' . $this->section . ($identifier !== null ? '.' . $identifier : ''), $fallback);
if ($value !== null) {
$this->arrayDelete(self::$_data, '_session_class._flash.' . $this->section . ($identifier !== null ? '.' . $identifier : ''));
}
return $value;
} | php | public function getFlash($identifier = null, $fallback = null) {
$value = $this->arrayGet(self::$_data, '_session_class._flash.' . $this->section . ($identifier !== null ? '.' . $identifier : ''), $fallback);
if ($value !== null) {
$this->arrayDelete(self::$_data, '_session_class._flash.' . $this->section . ($identifier !== null ? '.' . $identifier : ''));
}
return $value;
} | [
"public",
"function",
"getFlash",
"(",
"$",
"identifier",
"=",
"null",
",",
"$",
"fallback",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"arrayGet",
"(",
"self",
"::",
"$",
"_data",
",",
"'_session_class._flash.'",
".",
"$",
"this",
"->",
"section",
".",
"(",
"$",
"identifier",
"!==",
"null",
"?",
"'.'",
".",
"$",
"identifier",
":",
"''",
")",
",",
"$",
"fallback",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"arrayDelete",
"(",
"self",
"::",
"$",
"_data",
",",
"'_session_class._flash.'",
".",
"$",
"this",
"->",
"section",
".",
"(",
"$",
"identifier",
"!==",
"null",
"?",
"'.'",
".",
"$",
"identifier",
":",
"''",
")",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Retrieves session data saved with a given identifier and removes the data from the session.
@param string $identifier The identifier you have used on setting the data.
@param mixed $fallback The return value if the identifier was not found.
@return mixed The requested data. | [
"Retrieves",
"session",
"data",
"saved",
"with",
"a",
"given",
"identifier",
"and",
"removes",
"the",
"data",
"from",
"the",
"session",
"."
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Session.php#L194-L200 |
5,675 | MINISTRYGmbH/morrow-core | src/Session.php | Session.delete | public function delete($identifier = null) {
if ($this->get($identifier) === null) return;
$this->arrayDelete(self::$_data, '_session_class._standard.' . $this->section . ($identifier !== null ? '.' . $identifier : ''));
} | php | public function delete($identifier = null) {
if ($this->get($identifier) === null) return;
$this->arrayDelete(self::$_data, '_session_class._standard.' . $this->section . ($identifier !== null ? '.' . $identifier : ''));
} | [
"public",
"function",
"delete",
"(",
"$",
"identifier",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"$",
"identifier",
")",
"===",
"null",
")",
"return",
";",
"$",
"this",
"->",
"arrayDelete",
"(",
"self",
"::",
"$",
"_data",
",",
"'_session_class._standard.'",
".",
"$",
"this",
"->",
"section",
".",
"(",
"$",
"identifier",
"!==",
"null",
"?",
"'.'",
".",
"$",
"identifier",
":",
"''",
")",
")",
";",
"}"
] | Deletes session data.
@param string $identifier The identifier you want to delete.
@return null | [
"Deletes",
"session",
"data",
"."
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Session.php#L219-L222 |
5,676 | MINISTRYGmbH/morrow-core | src/Session.php | Session.sessionhandler_gc | public function sessionhandler_gc($maxlifetime) {
$files = scandir($this->save_path);
foreach ($files as $file) {
if ($file{0} === '.') continue;
if (filemtime($this->save_path . $file) < time() - $maxlifetime) {
unlink($this->save_path . $file);
}
}
return true;
} | php | public function sessionhandler_gc($maxlifetime) {
$files = scandir($this->save_path);
foreach ($files as $file) {
if ($file{0} === '.') continue;
if (filemtime($this->save_path . $file) < time() - $maxlifetime) {
unlink($this->save_path . $file);
}
}
return true;
} | [
"public",
"function",
"sessionhandler_gc",
"(",
"$",
"maxlifetime",
")",
"{",
"$",
"files",
"=",
"scandir",
"(",
"$",
"this",
"->",
"save_path",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"{",
"0",
"}",
"===",
"'.'",
")",
"continue",
";",
"if",
"(",
"filemtime",
"(",
"$",
"this",
"->",
"save_path",
".",
"$",
"file",
")",
"<",
"time",
"(",
")",
"-",
"$",
"maxlifetime",
")",
"{",
"unlink",
"(",
"$",
"this",
"->",
"save_path",
".",
"$",
"file",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Cleanup old sessions.
@param string $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed.
@return boolean The return value (usually `true` on success, `false` on failure). Note this value is returned internally to PHP for processing.
@hidden | [
"Cleanup",
"old",
"sessions",
"."
] | bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e | https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Session.php#L299-L309 |
5,677 | PaymentSuite/PaymillBundle | Twig/PaymillExtension.php | PaymillExtension.renderPaymentView | public function renderPaymentView($viewTemplate = null)
{
$formType = $this->formFactory->create('paymill_view');
$this->environment->display($viewTemplate ?: $this->viewTemplate, array(
'paymill_form' => $formType->createView(),
));
} | php | public function renderPaymentView($viewTemplate = null)
{
$formType = $this->formFactory->create('paymill_view');
$this->environment->display($viewTemplate ?: $this->viewTemplate, array(
'paymill_form' => $formType->createView(),
));
} | [
"public",
"function",
"renderPaymentView",
"(",
"$",
"viewTemplate",
"=",
"null",
")",
"{",
"$",
"formType",
"=",
"$",
"this",
"->",
"formFactory",
"->",
"create",
"(",
"'paymill_view'",
")",
";",
"$",
"this",
"->",
"environment",
"->",
"display",
"(",
"$",
"viewTemplate",
"?",
":",
"$",
"this",
"->",
"viewTemplate",
",",
"array",
"(",
"'paymill_form'",
"=>",
"$",
"formType",
"->",
"createView",
"(",
")",
",",
")",
")",
";",
"}"
] | Render paymill form view
@param string $viewTemplate An optional template to render.
@return void | [
"Render",
"paymill",
"form",
"view"
] | 78aa85daaab8cf08e4971b10d86abd429ac7f6cd | https://github.com/PaymentSuite/PaymillBundle/blob/78aa85daaab8cf08e4971b10d86abd429ac7f6cd/Twig/PaymillExtension.php#L128-L135 |
5,678 | PaymentSuite/PaymillBundle | Twig/PaymillExtension.php | PaymillExtension.renderPaymentScripts | public function renderPaymentScripts()
{
$this->environment->display($this->scriptsTemplate, array(
'public_key' => $this->publicKey,
'currency' => $this->paymentBridgeInterface->getCurrency(),
));
} | php | public function renderPaymentScripts()
{
$this->environment->display($this->scriptsTemplate, array(
'public_key' => $this->publicKey,
'currency' => $this->paymentBridgeInterface->getCurrency(),
));
} | [
"public",
"function",
"renderPaymentScripts",
"(",
")",
"{",
"$",
"this",
"->",
"environment",
"->",
"display",
"(",
"$",
"this",
"->",
"scriptsTemplate",
",",
"array",
"(",
"'public_key'",
"=>",
"$",
"this",
"->",
"publicKey",
",",
"'currency'",
"=>",
"$",
"this",
"->",
"paymentBridgeInterface",
"->",
"getCurrency",
"(",
")",
",",
")",
")",
";",
"}"
] | Render paymill scripts view
@return void | [
"Render",
"paymill",
"scripts",
"view"
] | 78aa85daaab8cf08e4971b10d86abd429ac7f6cd | https://github.com/PaymentSuite/PaymillBundle/blob/78aa85daaab8cf08e4971b10d86abd429ac7f6cd/Twig/PaymillExtension.php#L142-L148 |
5,679 | massimo-filippi/slack-module | src/Model/AttachmentActionConfirm.php | AttachmentActionConfirm.toArray | public function toArray()
{
$data = [
'text' => $this->getText(),
];
if($this->getTitle()) $data['title'] = $this->getTitle();
if($this->getTitle()) $data['ok_text'] = $this->getOkText();
if($this->getTitle()) $data['dismiss_text'] = $this->getDismissText();
return $data;
} | php | public function toArray()
{
$data = [
'text' => $this->getText(),
];
if($this->getTitle()) $data['title'] = $this->getTitle();
if($this->getTitle()) $data['ok_text'] = $this->getOkText();
if($this->getTitle()) $data['dismiss_text'] = $this->getDismissText();
return $data;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"'text'",
"=>",
"$",
"this",
"->",
"getText",
"(",
")",
",",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"getTitle",
"(",
")",
")",
"$",
"data",
"[",
"'title'",
"]",
"=",
"$",
"this",
"->",
"getTitle",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getTitle",
"(",
")",
")",
"$",
"data",
"[",
"'ok_text'",
"]",
"=",
"$",
"this",
"->",
"getOkText",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getTitle",
"(",
")",
")",
"$",
"data",
"[",
"'dismiss_text'",
"]",
"=",
"$",
"this",
"->",
"getDismissText",
"(",
")",
";",
"return",
"$",
"data",
";",
"}"
] | Get the array representation of this confirm
@return array | [
"Get",
"the",
"array",
"representation",
"of",
"this",
"confirm"
] | 76bf7e3adbb690c9b591170651730cc5f12d8800 | https://github.com/massimo-filippi/slack-module/blob/76bf7e3adbb690c9b591170651730cc5f12d8800/src/Model/AttachmentActionConfirm.php#L123-L134 |
5,680 | webriq/core | module/User/src/Grid/User/View/Helper/UserLocale.php | UserLocale.getLocale | public function getLocale()
{
$auth = $this->getView()
->authentication();
if ( $auth->hasIdentity() )
{
$locale = $auth->getIdentity()->locale;
}
else
{
$locale = Locale::getDefault();
}
return $locale;
} | php | public function getLocale()
{
$auth = $this->getView()
->authentication();
if ( $auth->hasIdentity() )
{
$locale = $auth->getIdentity()->locale;
}
else
{
$locale = Locale::getDefault();
}
return $locale;
} | [
"public",
"function",
"getLocale",
"(",
")",
"{",
"$",
"auth",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"authentication",
"(",
")",
";",
"if",
"(",
"$",
"auth",
"->",
"hasIdentity",
"(",
")",
")",
"{",
"$",
"locale",
"=",
"$",
"auth",
"->",
"getIdentity",
"(",
")",
"->",
"locale",
";",
"}",
"else",
"{",
"$",
"locale",
"=",
"Locale",
"::",
"getDefault",
"(",
")",
";",
"}",
"return",
"$",
"locale",
";",
"}"
] | Get user-locale
@return string | [
"Get",
"user",
"-",
"locale"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/User/src/Grid/User/View/Helper/UserLocale.php#L21-L36 |
5,681 | sagebind/libnntp | src/Article.php | Article.parse | public static function parse(string $data): self
{
$separator = strpos($data, "\r\n\r\n");
if ($separator === false) {
throw new FormatException('Invalid article format');
}
$headers = HeaderBag::parse(substr($data, 0, $separator + 2));
$body = substr($data, $separator + 4);
return new self($body, $headers);
} | php | public static function parse(string $data): self
{
$separator = strpos($data, "\r\n\r\n");
if ($separator === false) {
throw new FormatException('Invalid article format');
}
$headers = HeaderBag::parse(substr($data, 0, $separator + 2));
$body = substr($data, $separator + 4);
return new self($body, $headers);
} | [
"public",
"static",
"function",
"parse",
"(",
"string",
"$",
"data",
")",
":",
"self",
"{",
"$",
"separator",
"=",
"strpos",
"(",
"$",
"data",
",",
"\"\\r\\n\\r\\n\"",
")",
";",
"if",
"(",
"$",
"separator",
"===",
"false",
")",
"{",
"throw",
"new",
"FormatException",
"(",
"'Invalid article format'",
")",
";",
"}",
"$",
"headers",
"=",
"HeaderBag",
"::",
"parse",
"(",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"$",
"separator",
"+",
"2",
")",
")",
";",
"$",
"body",
"=",
"substr",
"(",
"$",
"data",
",",
"$",
"separator",
"+",
"4",
")",
";",
"return",
"new",
"self",
"(",
"$",
"body",
",",
"$",
"headers",
")",
";",
"}"
] | Parses an article from a string. | [
"Parses",
"an",
"article",
"from",
"a",
"string",
"."
] | 4bb81847ec08df89bb77377e5da0b017613a0447 | https://github.com/sagebind/libnntp/blob/4bb81847ec08df89bb77377e5da0b017613a0447/src/Article.php#L15-L27 |
5,682 | sheychen290/colis | src/Headers.php | Headers.format | public static function format(string $value)
{
$value = explode(',', $value);
if (!is_array($value)) {
$value = [$value];
}
return $value;
} | php | public static function format(string $value)
{
$value = explode(',', $value);
if (!is_array($value)) {
$value = [$value];
}
return $value;
} | [
"public",
"static",
"function",
"format",
"(",
"string",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"explode",
"(",
"','",
",",
"$",
"value",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"[",
"$",
"value",
"]",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Convert header string value to array | [
"Convert",
"header",
"string",
"value",
"to",
"array"
] | b0552ece885d6b258e73ddbccf0b52c5c28e6054 | https://github.com/sheychen290/colis/blob/b0552ece885d6b258e73ddbccf0b52c5c28e6054/src/Headers.php#L10-L17 |
5,683 | aurorahttp/http-handler | src/Bundle/ListBundle.php | ListBundle.handle | public function handle($request, HandlerInterface $next)
{
if ($this->isEmpty()) {
return $request;
}
if ($this->shadow == false) {
$bundle = clone $this;
$bundle->store->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_DELETE);
$this->shadow = true;
return $next->handle($request, $bundle);
}
$handler = $this->frontPop();
return $handler->handle($request, $this);
} | php | public function handle($request, HandlerInterface $next)
{
if ($this->isEmpty()) {
return $request;
}
if ($this->shadow == false) {
$bundle = clone $this;
$bundle->store->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_DELETE);
$this->shadow = true;
return $next->handle($request, $bundle);
}
$handler = $this->frontPop();
return $handler->handle($request, $this);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"HandlerInterface",
"$",
"next",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"$",
"request",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"shadow",
"==",
"false",
")",
"{",
"$",
"bundle",
"=",
"clone",
"$",
"this",
";",
"$",
"bundle",
"->",
"store",
"->",
"setIteratorMode",
"(",
"SplDoublyLinkedList",
"::",
"IT_MODE_FIFO",
"|",
"SplDoublyLinkedList",
"::",
"IT_MODE_DELETE",
")",
";",
"$",
"this",
"->",
"shadow",
"=",
"true",
";",
"return",
"$",
"next",
"->",
"handle",
"(",
"$",
"request",
",",
"$",
"bundle",
")",
";",
"}",
"$",
"handler",
"=",
"$",
"this",
"->",
"frontPop",
"(",
")",
";",
"return",
"$",
"handler",
"->",
"handle",
"(",
"$",
"request",
",",
"$",
"this",
")",
";",
"}"
] | Process a request using all stored handlers.
@param mixed $request
@param HandlerInterface $next
@return mixed | [
"Process",
"a",
"request",
"using",
"all",
"stored",
"handlers",
"."
] | 2dc12a964b15b497f5a81b2b2ab389fe95bcd460 | https://github.com/aurorahttp/http-handler/blob/2dc12a964b15b497f5a81b2b2ab389fe95bcd460/src/Bundle/ListBundle.php#L33-L48 |
5,684 | aurorahttp/http-handler | src/Bundle/ListBundle.php | ListBundle.reverse | public function reverse()
{
$length = count($this->store);
for ($i = 0; $i < $length; ++$i) {
$this->store->unshift($this->store->pop());
}
} | php | public function reverse()
{
$length = count($this->store);
for ($i = 0; $i < $length; ++$i) {
$this->store->unshift($this->store->pop());
}
} | [
"public",
"function",
"reverse",
"(",
")",
"{",
"$",
"length",
"=",
"count",
"(",
"$",
"this",
"->",
"store",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"++",
"$",
"i",
")",
"{",
"$",
"this",
"->",
"store",
"->",
"unshift",
"(",
"$",
"this",
"->",
"store",
"->",
"pop",
"(",
")",
")",
";",
"}",
"}"
] | Reverse handlers. | [
"Reverse",
"handlers",
"."
] | 2dc12a964b15b497f5a81b2b2ab389fe95bcd460 | https://github.com/aurorahttp/http-handler/blob/2dc12a964b15b497f5a81b2b2ab389fe95bcd460/src/Bundle/ListBundle.php#L128-L134 |
5,685 | axypro/env | helpers/Normalizer.php | Normalizer.normalize | public static function normalize(Config $config)
{
self::normalizeFunctions($config);
self::normalizeTime($config);
self::normalizeArrays($config);
self::normalizeStreams($config);
} | php | public static function normalize(Config $config)
{
self::normalizeFunctions($config);
self::normalizeTime($config);
self::normalizeArrays($config);
self::normalizeStreams($config);
} | [
"public",
"static",
"function",
"normalize",
"(",
"Config",
"$",
"config",
")",
"{",
"self",
"::",
"normalizeFunctions",
"(",
"$",
"config",
")",
";",
"self",
"::",
"normalizeTime",
"(",
"$",
"config",
")",
";",
"self",
"::",
"normalizeArrays",
"(",
"$",
"config",
")",
";",
"self",
"::",
"normalizeStreams",
"(",
"$",
"config",
")",
";",
"}"
] | Normalizes a config
@param \axy\env\Config $config
@throws \axy\errors\InvalidConfig | [
"Normalizes",
"a",
"config"
] | 0cc3539682d6f021ac6645ff8dfa0a6829c33616 | https://github.com/axypro/env/blob/0cc3539682d6f021ac6645ff8dfa0a6829c33616/helpers/Normalizer.php#L26-L32 |
5,686 | Kagency/http-replay | src/Kagency/HttpReplay/Reader/MitmDump.php | MitmDump.readInteractions | public function readInteractions($file)
{
return array_map(
function (array $interaction) {
return new Interaction(
$this->messageHandler->convertFromRequest(
new SimplifiedRequest(
$interaction['request']['method'],
$interaction['request']['path'],
$this->mapHeaders($interaction['request']['headers']),
$interaction['request']['content']
)
),
$this->messageHandler->convertFromResponse(
new SimplifiedResponse(
$interaction['request']['path'],
$interaction['response']['code'],
$this->mapHeaders($interaction['response']['headers']),
$interaction['response']['content']
)
)
);
},
$this->decoder->decode(file_get_contents($file))
);
} | php | public function readInteractions($file)
{
return array_map(
function (array $interaction) {
return new Interaction(
$this->messageHandler->convertFromRequest(
new SimplifiedRequest(
$interaction['request']['method'],
$interaction['request']['path'],
$this->mapHeaders($interaction['request']['headers']),
$interaction['request']['content']
)
),
$this->messageHandler->convertFromResponse(
new SimplifiedResponse(
$interaction['request']['path'],
$interaction['response']['code'],
$this->mapHeaders($interaction['response']['headers']),
$interaction['response']['content']
)
)
);
},
$this->decoder->decode(file_get_contents($file))
);
} | [
"public",
"function",
"readInteractions",
"(",
"$",
"file",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"array",
"$",
"interaction",
")",
"{",
"return",
"new",
"Interaction",
"(",
"$",
"this",
"->",
"messageHandler",
"->",
"convertFromRequest",
"(",
"new",
"SimplifiedRequest",
"(",
"$",
"interaction",
"[",
"'request'",
"]",
"[",
"'method'",
"]",
",",
"$",
"interaction",
"[",
"'request'",
"]",
"[",
"'path'",
"]",
",",
"$",
"this",
"->",
"mapHeaders",
"(",
"$",
"interaction",
"[",
"'request'",
"]",
"[",
"'headers'",
"]",
")",
",",
"$",
"interaction",
"[",
"'request'",
"]",
"[",
"'content'",
"]",
")",
")",
",",
"$",
"this",
"->",
"messageHandler",
"->",
"convertFromResponse",
"(",
"new",
"SimplifiedResponse",
"(",
"$",
"interaction",
"[",
"'request'",
"]",
"[",
"'path'",
"]",
",",
"$",
"interaction",
"[",
"'response'",
"]",
"[",
"'code'",
"]",
",",
"$",
"this",
"->",
"mapHeaders",
"(",
"$",
"interaction",
"[",
"'response'",
"]",
"[",
"'headers'",
"]",
")",
",",
"$",
"interaction",
"[",
"'response'",
"]",
"[",
"'content'",
"]",
")",
")",
")",
";",
"}",
",",
"$",
"this",
"->",
"decoder",
"->",
"decode",
"(",
"file_get_contents",
"(",
"$",
"file",
")",
")",
")",
";",
"}"
] | Read interactions l
@param string $file
@return Interaction[] | [
"Read",
"interactions",
"l"
] | 333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5 | https://github.com/Kagency/http-replay/blob/333bcc553f0e79fc1e21f645f6eda7cc65e4f1e5/src/Kagency/HttpReplay/Reader/MitmDump.php#L48-L73 |
5,687 | monolyth-php/formulaic | src/Post.php | Post.setValue | private function setValue($item) : void
{
if (is_string($item)) {
return;
}
$element = $item->getElement();
$name = $element->name();
if ($element instanceof File) {
if (array_key_exists($name, $_FILES)) {
$element->setValue($_FILES[$name]);
$element->valueSuppliedByUser(true);
}
} elseif (array_key_exists($name, $_POST)) {
if ($element instanceof Radio) {
if ($_POST[$name] == $element->getValue()
|| (is_array($_POST[$name])
&& in_array($element->getValue(), $_POST[$name])
)
) {
$element->check();
} else {
$element->check(false);
}
} else {
$element->setValue($_POST[$name]);
}
$element->valueSuppliedByUser(true);
} elseif ($element instanceof Radio) {
$element->check(false);
}
} | php | private function setValue($item) : void
{
if (is_string($item)) {
return;
}
$element = $item->getElement();
$name = $element->name();
if ($element instanceof File) {
if (array_key_exists($name, $_FILES)) {
$element->setValue($_FILES[$name]);
$element->valueSuppliedByUser(true);
}
} elseif (array_key_exists($name, $_POST)) {
if ($element instanceof Radio) {
if ($_POST[$name] == $element->getValue()
|| (is_array($_POST[$name])
&& in_array($element->getValue(), $_POST[$name])
)
) {
$element->check();
} else {
$element->check(false);
}
} else {
$element->setValue($_POST[$name]);
}
$element->valueSuppliedByUser(true);
} elseif ($element instanceof Radio) {
$element->check(false);
}
} | [
"private",
"function",
"setValue",
"(",
"$",
"item",
")",
":",
"void",
"{",
"if",
"(",
"is_string",
"(",
"$",
"item",
")",
")",
"{",
"return",
";",
"}",
"$",
"element",
"=",
"$",
"item",
"->",
"getElement",
"(",
")",
";",
"$",
"name",
"=",
"$",
"element",
"->",
"name",
"(",
")",
";",
"if",
"(",
"$",
"element",
"instanceof",
"File",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"_FILES",
")",
")",
"{",
"$",
"element",
"->",
"setValue",
"(",
"$",
"_FILES",
"[",
"$",
"name",
"]",
")",
";",
"$",
"element",
"->",
"valueSuppliedByUser",
"(",
"true",
")",
";",
"}",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"_POST",
")",
")",
"{",
"if",
"(",
"$",
"element",
"instanceof",
"Radio",
")",
"{",
"if",
"(",
"$",
"_POST",
"[",
"$",
"name",
"]",
"==",
"$",
"element",
"->",
"getValue",
"(",
")",
"||",
"(",
"is_array",
"(",
"$",
"_POST",
"[",
"$",
"name",
"]",
")",
"&&",
"in_array",
"(",
"$",
"element",
"->",
"getValue",
"(",
")",
",",
"$",
"_POST",
"[",
"$",
"name",
"]",
")",
")",
")",
"{",
"$",
"element",
"->",
"check",
"(",
")",
";",
"}",
"else",
"{",
"$",
"element",
"->",
"check",
"(",
"false",
")",
";",
"}",
"}",
"else",
"{",
"$",
"element",
"->",
"setValue",
"(",
"$",
"_POST",
"[",
"$",
"name",
"]",
")",
";",
"}",
"$",
"element",
"->",
"valueSuppliedByUser",
"(",
"true",
")",
";",
"}",
"elseif",
"(",
"$",
"element",
"instanceof",
"Radio",
")",
"{",
"$",
"element",
"->",
"check",
"(",
"false",
")",
";",
"}",
"}"
] | Internal helper method to set the value of whatever we are dealing with.
@param mixed $item
@return void | [
"Internal",
"helper",
"method",
"to",
"set",
"the",
"value",
"of",
"whatever",
"we",
"are",
"dealing",
"with",
"."
] | 4bf7853a0c29cc17957f1b26c79f633867742c14 | https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Post.php#L58-L88 |
5,688 | franckysolo/octopush-sdk | src/Octopush/Curl.php | Curl.setOptions | public function setOptions($url, $query, $port)
{
curl_setopt_array($this->handle, [
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_PORT => $port,
CURLOPT_POSTFIELDS => $query,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_FRESH_CONNECT => true
]);
} | php | public function setOptions($url, $query, $port)
{
curl_setopt_array($this->handle, [
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_PORT => $port,
CURLOPT_POSTFIELDS => $query,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_FRESH_CONNECT => true
]);
} | [
"public",
"function",
"setOptions",
"(",
"$",
"url",
",",
"$",
"query",
",",
"$",
"port",
")",
"{",
"curl_setopt_array",
"(",
"$",
"this",
"->",
"handle",
",",
"[",
"CURLOPT_URL",
"=>",
"$",
"url",
",",
"CURLOPT_POST",
"=>",
"true",
",",
"CURLOPT_PORT",
"=>",
"$",
"port",
",",
"CURLOPT_POSTFIELDS",
"=>",
"$",
"query",
",",
"CURLOPT_RETURNTRANSFER",
"=>",
"true",
",",
"CURLOPT_SSL_VERIFYPEER",
"=>",
"false",
",",
"CURLOPT_FRESH_CONNECT",
"=>",
"true",
"]",
")",
";",
"}"
] | Sets the Curl options
@param string $url The request url
@param string $query The query string builded
@param int $port The port must be 80 or 443
@return void | [
"Sets",
"the",
"Curl",
"options"
] | 3797e53d51474a64b65fbf437e5dd46e288f2ef8 | https://github.com/franckysolo/octopush-sdk/blob/3797e53d51474a64b65fbf437e5dd46e288f2ef8/src/Octopush/Curl.php#L104-L115 |
5,689 | ekyna/UserBundle | Menu/MenuBuilder.php | MenuBuilder.addAccountEntry | public function addAccountEntry($name, array $options)
{
$this->accountEntries[$name] = $this->optionResolver->resolve($options);
} | php | public function addAccountEntry($name, array $options)
{
$this->accountEntries[$name] = $this->optionResolver->resolve($options);
} | [
"public",
"function",
"addAccountEntry",
"(",
"$",
"name",
",",
"array",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"accountEntries",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"optionResolver",
"->",
"resolve",
"(",
"$",
"options",
")",
";",
"}"
] | Adds the entry to he account menu.
@param string $name
@param array $options | [
"Adds",
"the",
"entry",
"to",
"he",
"account",
"menu",
"."
] | e38d56aee978148a312a923b9e70bdaad1a381bf | https://github.com/ekyna/UserBundle/blob/e38d56aee978148a312a923b9e70bdaad1a381bf/Menu/MenuBuilder.php#L101-L104 |
5,690 | ekyna/UserBundle | Menu/MenuBuilder.php | MenuBuilder.createAccountMenu | public function createAccountMenu()
{
$menu = $this->factory->createItem('root');
uasort($this->accountEntries, function($a, $b) {
if ($a['position'] == $b['position']) {
return 0;
}
return $a['position'] < $b['position'] ? -1 : 1;
});
foreach($this->accountEntries as $name => $options) {
$menu->addChild($name, $options);
}
return $menu;
} | php | public function createAccountMenu()
{
$menu = $this->factory->createItem('root');
uasort($this->accountEntries, function($a, $b) {
if ($a['position'] == $b['position']) {
return 0;
}
return $a['position'] < $b['position'] ? -1 : 1;
});
foreach($this->accountEntries as $name => $options) {
$menu->addChild($name, $options);
}
return $menu;
} | [
"public",
"function",
"createAccountMenu",
"(",
")",
"{",
"$",
"menu",
"=",
"$",
"this",
"->",
"factory",
"->",
"createItem",
"(",
"'root'",
")",
";",
"uasort",
"(",
"$",
"this",
"->",
"accountEntries",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"$",
"a",
"[",
"'position'",
"]",
"==",
"$",
"b",
"[",
"'position'",
"]",
")",
"{",
"return",
"0",
";",
"}",
"return",
"$",
"a",
"[",
"'position'",
"]",
"<",
"$",
"b",
"[",
"'position'",
"]",
"?",
"-",
"1",
":",
"1",
";",
"}",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"accountEntries",
"as",
"$",
"name",
"=>",
"$",
"options",
")",
"{",
"$",
"menu",
"->",
"addChild",
"(",
"$",
"name",
",",
"$",
"options",
")",
";",
"}",
"return",
"$",
"menu",
";",
"}"
] | Creates the account menu.
@return \Knp\Menu\ItemInterface | [
"Creates",
"the",
"account",
"menu",
"."
] | e38d56aee978148a312a923b9e70bdaad1a381bf | https://github.com/ekyna/UserBundle/blob/e38d56aee978148a312a923b9e70bdaad1a381bf/Menu/MenuBuilder.php#L111-L127 |
5,691 | ekyna/UserBundle | Menu/MenuBuilder.php | MenuBuilder.createUserMenu | public function createUserMenu()
{
$menu = $this->factory->createItem('root');
if ($this->accountEnabled) {
if (null !== $token = $this->tokenStorage->getToken()) {
if ($this->authorization->isGranted('IS_AUTHENTICATED_FULLY') || $this->authorization->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
/** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
$user = $token->getUser();
$item = $menu->addChild($user->getEmail(), ['uri' => '#']);
$item->addChild('ekyna_user.account.menu.my_profile', ['route' => 'fos_user_profile_show']);
if ($this->authorization->isGranted('ROLE_ADMIN')) {
$item->addChild('ekyna_user.account.menu.backend', ['route' => 'ekyna_admin']);
}
$item->addChild('ekyna_user.account.menu.logout', ['route' => 'fos_user_security_logout']);
return $menu;
}
}
$menu->addChild('ekyna_user.account.menu.login', ['route' => 'fos_user_security_login']);
}
return $menu;
} | php | public function createUserMenu()
{
$menu = $this->factory->createItem('root');
if ($this->accountEnabled) {
if (null !== $token = $this->tokenStorage->getToken()) {
if ($this->authorization->isGranted('IS_AUTHENTICATED_FULLY') || $this->authorization->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
/** @var \Ekyna\Bundle\UserBundle\Model\UserInterface $user */
$user = $token->getUser();
$item = $menu->addChild($user->getEmail(), ['uri' => '#']);
$item->addChild('ekyna_user.account.menu.my_profile', ['route' => 'fos_user_profile_show']);
if ($this->authorization->isGranted('ROLE_ADMIN')) {
$item->addChild('ekyna_user.account.menu.backend', ['route' => 'ekyna_admin']);
}
$item->addChild('ekyna_user.account.menu.logout', ['route' => 'fos_user_security_logout']);
return $menu;
}
}
$menu->addChild('ekyna_user.account.menu.login', ['route' => 'fos_user_security_login']);
}
return $menu;
} | [
"public",
"function",
"createUserMenu",
"(",
")",
"{",
"$",
"menu",
"=",
"$",
"this",
"->",
"factory",
"->",
"createItem",
"(",
"'root'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"accountEnabled",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"token",
"=",
"$",
"this",
"->",
"tokenStorage",
"->",
"getToken",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"authorization",
"->",
"isGranted",
"(",
"'IS_AUTHENTICATED_FULLY'",
")",
"||",
"$",
"this",
"->",
"authorization",
"->",
"isGranted",
"(",
"'IS_AUTHENTICATED_REMEMBERED'",
")",
")",
"{",
"/** @var \\Ekyna\\Bundle\\UserBundle\\Model\\UserInterface $user */",
"$",
"user",
"=",
"$",
"token",
"->",
"getUser",
"(",
")",
";",
"$",
"item",
"=",
"$",
"menu",
"->",
"addChild",
"(",
"$",
"user",
"->",
"getEmail",
"(",
")",
",",
"[",
"'uri'",
"=>",
"'#'",
"]",
")",
";",
"$",
"item",
"->",
"addChild",
"(",
"'ekyna_user.account.menu.my_profile'",
",",
"[",
"'route'",
"=>",
"'fos_user_profile_show'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"authorization",
"->",
"isGranted",
"(",
"'ROLE_ADMIN'",
")",
")",
"{",
"$",
"item",
"->",
"addChild",
"(",
"'ekyna_user.account.menu.backend'",
",",
"[",
"'route'",
"=>",
"'ekyna_admin'",
"]",
")",
";",
"}",
"$",
"item",
"->",
"addChild",
"(",
"'ekyna_user.account.menu.logout'",
",",
"[",
"'route'",
"=>",
"'fos_user_security_logout'",
"]",
")",
";",
"return",
"$",
"menu",
";",
"}",
"}",
"$",
"menu",
"->",
"addChild",
"(",
"'ekyna_user.account.menu.login'",
",",
"[",
"'route'",
"=>",
"'fos_user_security_login'",
"]",
")",
";",
"}",
"return",
"$",
"menu",
";",
"}"
] | Creates the user menu.
@return \Knp\Menu\ItemInterface | [
"Creates",
"the",
"user",
"menu",
"."
] | e38d56aee978148a312a923b9e70bdaad1a381bf | https://github.com/ekyna/UserBundle/blob/e38d56aee978148a312a923b9e70bdaad1a381bf/Menu/MenuBuilder.php#L134-L156 |
5,692 | PushmanPHP/pushman_php_library | src/Pushman.php | Pushman.initializeConfig | private function initializeConfig()
{
if (empty($this->config['url'])) {
$this->config['url'] = static::$url;
}
$this->config['url'] = rtrim($this->config['url'], '/');
if (filter_var($this->config['url'], FILTER_VALIDATE_URL) === false) {
throw new InvalidConfigException('You must provide a valid URL in the config.');
}
} | php | private function initializeConfig()
{
if (empty($this->config['url'])) {
$this->config['url'] = static::$url;
}
$this->config['url'] = rtrim($this->config['url'], '/');
if (filter_var($this->config['url'], FILTER_VALIDATE_URL) === false) {
throw new InvalidConfigException('You must provide a valid URL in the config.');
}
} | [
"private",
"function",
"initializeConfig",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'url'",
"]",
"=",
"static",
"::",
"$",
"url",
";",
"}",
"$",
"this",
"->",
"config",
"[",
"'url'",
"]",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"config",
"[",
"'url'",
"]",
",",
"'/'",
")",
";",
"if",
"(",
"filter_var",
"(",
"$",
"this",
"->",
"config",
"[",
"'url'",
"]",
",",
"FILTER_VALIDATE_URL",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"'You must provide a valid URL in the config.'",
")",
";",
"}",
"}"
] | Setup the config if one hasn't been provided.
@throws \Pushman\PHPLib\Exceptions\InvalidConfigException | [
"Setup",
"the",
"config",
"if",
"one",
"hasn",
"t",
"been",
"provided",
"."
] | 27eea27e7042a65bd1eef0955a9d8537f737701f | https://github.com/PushmanPHP/pushman_php_library/blob/27eea27e7042a65bd1eef0955a9d8537f737701f/src/Pushman.php#L87-L98 |
5,693 | PushmanPHP/pushman_php_library | src/Pushman.php | Pushman.push | public function push($event, $channel = 'public', array $payload = [])
{
$payload = $this->preparePayload($payload);
$this->validateEvent($event);
$channels = $this->validateChannel($channel);
$url = $this->getURL();
$headers = [
'body' => [
'private' => $this->privateKey,
'channels' => $channels,
'event' => $event,
'payload' => $payload
]
];
$response = $this->processRequest($url, $headers);
return $response;
} | php | public function push($event, $channel = 'public', array $payload = [])
{
$payload = $this->preparePayload($payload);
$this->validateEvent($event);
$channels = $this->validateChannel($channel);
$url = $this->getURL();
$headers = [
'body' => [
'private' => $this->privateKey,
'channels' => $channels,
'event' => $event,
'payload' => $payload
]
];
$response = $this->processRequest($url, $headers);
return $response;
} | [
"public",
"function",
"push",
"(",
"$",
"event",
",",
"$",
"channel",
"=",
"'public'",
",",
"array",
"$",
"payload",
"=",
"[",
"]",
")",
"{",
"$",
"payload",
"=",
"$",
"this",
"->",
"preparePayload",
"(",
"$",
"payload",
")",
";",
"$",
"this",
"->",
"validateEvent",
"(",
"$",
"event",
")",
";",
"$",
"channels",
"=",
"$",
"this",
"->",
"validateChannel",
"(",
"$",
"channel",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getURL",
"(",
")",
";",
"$",
"headers",
"=",
"[",
"'body'",
"=>",
"[",
"'private'",
"=>",
"$",
"this",
"->",
"privateKey",
",",
"'channels'",
"=>",
"$",
"channels",
",",
"'event'",
"=>",
"$",
"event",
",",
"'payload'",
"=>",
"$",
"payload",
"]",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"processRequest",
"(",
"$",
"url",
",",
"$",
"headers",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Push an event to Pushman, the most used command.
@param $event
@param string $channel
@param array $payload
@return string
@throws \Pushman\PHPLib\Exceptions\InvalidChannelException
@throws \Pushman\PHPLib\Exceptions\InvalidEventException | [
"Push",
"an",
"event",
"to",
"Pushman",
"the",
"most",
"used",
"command",
"."
] | 27eea27e7042a65bd1eef0955a9d8537f737701f | https://github.com/PushmanPHP/pushman_php_library/blob/27eea27e7042a65bd1eef0955a9d8537f737701f/src/Pushman.php#L120-L140 |
5,694 | PushmanPHP/pushman_php_library | src/Pushman.php | Pushman.validateChannel | private function validateChannel($channels = [], $returnAsArray = true)
{
if ($returnAsArray) {
if (is_string($channels)) {
$channels = [$channels];
}
if (empty($channels)) {
return ['public'];
}
foreach ($channels as $channel) {
if (strpos($channel, ' ') !== false) {
throw new InvalidChannelException('No spaces are allowed in channel names.');
}
}
return json_encode($channels);
} else {
if (empty($channels)) {
return 'public';
}
if (strpos($channels, ' ') !== false) {
throw new InvalidChannelException('No spaces are allowed in channel names.');
}
return $channels;
}
} | php | private function validateChannel($channels = [], $returnAsArray = true)
{
if ($returnAsArray) {
if (is_string($channels)) {
$channels = [$channels];
}
if (empty($channels)) {
return ['public'];
}
foreach ($channels as $channel) {
if (strpos($channel, ' ') !== false) {
throw new InvalidChannelException('No spaces are allowed in channel names.');
}
}
return json_encode($channels);
} else {
if (empty($channels)) {
return 'public';
}
if (strpos($channels, ' ') !== false) {
throw new InvalidChannelException('No spaces are allowed in channel names.');
}
return $channels;
}
} | [
"private",
"function",
"validateChannel",
"(",
"$",
"channels",
"=",
"[",
"]",
",",
"$",
"returnAsArray",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"returnAsArray",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"channels",
")",
")",
"{",
"$",
"channels",
"=",
"[",
"$",
"channels",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"channels",
")",
")",
"{",
"return",
"[",
"'public'",
"]",
";",
"}",
"foreach",
"(",
"$",
"channels",
"as",
"$",
"channel",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"channel",
",",
"' '",
")",
"!==",
"false",
")",
"{",
"throw",
"new",
"InvalidChannelException",
"(",
"'No spaces are allowed in channel names.'",
")",
";",
"}",
"}",
"return",
"json_encode",
"(",
"$",
"channels",
")",
";",
"}",
"else",
"{",
"if",
"(",
"empty",
"(",
"$",
"channels",
")",
")",
"{",
"return",
"'public'",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"channels",
",",
"' '",
")",
"!==",
"false",
")",
"{",
"throw",
"new",
"InvalidChannelException",
"(",
"'No spaces are allowed in channel names.'",
")",
";",
"}",
"return",
"$",
"channels",
";",
"}",
"}"
] | Validate a channel or set of channels, return JSON if appropriate.
@param array $channels
@param bool $returnAsArray
@return array|string
@throws \Pushman\PHPLib\Exceptions\InvalidChannelException | [
"Validate",
"a",
"channel",
"or",
"set",
"of",
"channels",
"return",
"JSON",
"if",
"appropriate",
"."
] | 27eea27e7042a65bd1eef0955a9d8537f737701f | https://github.com/PushmanPHP/pushman_php_library/blob/27eea27e7042a65bd1eef0955a9d8537f737701f/src/Pushman.php#L180-L206 |
5,695 | PushmanPHP/pushman_php_library | src/Pushman.php | Pushman.getURL | private function getURL($endpoint = null)
{
if (is_null($endpoint)) {
$endpoint = $this->getEndpoint();
} else {
$endpoint = '/api/' . $endpoint;
}
return $this->config['url'] . $endpoint;
} | php | private function getURL($endpoint = null)
{
if (is_null($endpoint)) {
$endpoint = $this->getEndpoint();
} else {
$endpoint = '/api/' . $endpoint;
}
return $this->config['url'] . $endpoint;
} | [
"private",
"function",
"getURL",
"(",
"$",
"endpoint",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"endpoint",
")",
")",
"{",
"$",
"endpoint",
"=",
"$",
"this",
"->",
"getEndpoint",
"(",
")",
";",
"}",
"else",
"{",
"$",
"endpoint",
"=",
"'/api/'",
".",
"$",
"endpoint",
";",
"}",
"return",
"$",
"this",
"->",
"config",
"[",
"'url'",
"]",
".",
"$",
"endpoint",
";",
"}"
] | Get the URL of our Pushman instance.
Defaults to the live site Push command.
@param null $endpoint
@return string | [
"Get",
"the",
"URL",
"of",
"our",
"Pushman",
"instance",
".",
"Defaults",
"to",
"the",
"live",
"site",
"Push",
"command",
"."
] | 27eea27e7042a65bd1eef0955a9d8537f737701f | https://github.com/PushmanPHP/pushman_php_library/blob/27eea27e7042a65bd1eef0955a9d8537f737701f/src/Pushman.php#L215-L224 |
5,696 | PushmanPHP/pushman_php_library | src/Pushman.php | Pushman.processRequest | private function processRequest($url, $headers, $method = 'post')
{
if (array_key_exists('body', $headers)) {
$headers['body'] = json_encode($headers['body']);
}
if ($method == 'post') {
$response = $this->guzzle->request('POST', $url, $headers);
} elseif ($method == 'delete') {
$response = $this->guzzle->request('DELETE', $url, $headers);
} else {
$params = $this->processGetParams($headers);
$response = $this->guzzle->request('GET', $url . $params);
}
$response = $this->processResponse($response);
return $response;
} | php | private function processRequest($url, $headers, $method = 'post')
{
if (array_key_exists('body', $headers)) {
$headers['body'] = json_encode($headers['body']);
}
if ($method == 'post') {
$response = $this->guzzle->request('POST', $url, $headers);
} elseif ($method == 'delete') {
$response = $this->guzzle->request('DELETE', $url, $headers);
} else {
$params = $this->processGetParams($headers);
$response = $this->guzzle->request('GET', $url . $params);
}
$response = $this->processResponse($response);
return $response;
} | [
"private",
"function",
"processRequest",
"(",
"$",
"url",
",",
"$",
"headers",
",",
"$",
"method",
"=",
"'post'",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'body'",
",",
"$",
"headers",
")",
")",
"{",
"$",
"headers",
"[",
"'body'",
"]",
"=",
"json_encode",
"(",
"$",
"headers",
"[",
"'body'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"method",
"==",
"'post'",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"guzzle",
"->",
"request",
"(",
"'POST'",
",",
"$",
"url",
",",
"$",
"headers",
")",
";",
"}",
"elseif",
"(",
"$",
"method",
"==",
"'delete'",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"guzzle",
"->",
"request",
"(",
"'DELETE'",
",",
"$",
"url",
",",
"$",
"headers",
")",
";",
"}",
"else",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"processGetParams",
"(",
"$",
"headers",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"guzzle",
"->",
"request",
"(",
"'GET'",
",",
"$",
"url",
".",
"$",
"params",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"response",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Process a request and return the handled response.
@param string $url
@param array $headers
@param string $method
@return string | [
"Process",
"a",
"request",
"and",
"return",
"the",
"handled",
"response",
"."
] | 27eea27e7042a65bd1eef0955a9d8537f737701f | https://github.com/PushmanPHP/pushman_php_library/blob/27eea27e7042a65bd1eef0955a9d8537f737701f/src/Pushman.php#L244-L261 |
5,697 | PushmanPHP/pushman_php_library | src/Pushman.php | Pushman.processGetParams | private function processGetParams($headers)
{
$paramStrings = [];
foreach ($headers['body'] as $key => $value) {
$paramStrings[] = $key . "=" . $value;
}
$paramString = "?";
$paramString .= implode("&", $paramStrings);
return $paramString;
} | php | private function processGetParams($headers)
{
$paramStrings = [];
foreach ($headers['body'] as $key => $value) {
$paramStrings[] = $key . "=" . $value;
}
$paramString = "?";
$paramString .= implode("&", $paramStrings);
return $paramString;
} | [
"private",
"function",
"processGetParams",
"(",
"$",
"headers",
")",
"{",
"$",
"paramStrings",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"headers",
"[",
"'body'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"paramStrings",
"[",
"]",
"=",
"$",
"key",
".",
"\"=\"",
".",
"$",
"value",
";",
"}",
"$",
"paramString",
"=",
"\"?\"",
";",
"$",
"paramString",
".=",
"implode",
"(",
"\"&\"",
",",
"$",
"paramStrings",
")",
";",
"return",
"$",
"paramString",
";",
"}"
] | If we are doing a GET request, turn it into URL params.
@param $headers
@return string | [
"If",
"we",
"are",
"doing",
"a",
"GET",
"request",
"turn",
"it",
"into",
"URL",
"params",
"."
] | 27eea27e7042a65bd1eef0955a9d8537f737701f | https://github.com/PushmanPHP/pushman_php_library/blob/27eea27e7042a65bd1eef0955a9d8537f737701f/src/Pushman.php#L269-L279 |
5,698 | PushmanPHP/pushman_php_library | src/Pushman.php | Pushman.processResponse | private function processResponse(Response $response)
{
$response = $response->getBody()->getContents();
$response = json_decode($response, true);
return $response;
} | php | private function processResponse(Response $response)
{
$response = $response->getBody()->getContents();
$response = json_decode($response, true);
return $response;
} | [
"private",
"function",
"processResponse",
"(",
"Response",
"$",
"response",
")",
"{",
"$",
"response",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"$",
"response",
"=",
"json_decode",
"(",
"$",
"response",
",",
"true",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Process a repsonse, get the JSON and output the decoded values.
@param Response $response
@return Response|mixed|string | [
"Process",
"a",
"repsonse",
"get",
"the",
"JSON",
"and",
"output",
"the",
"decoded",
"values",
"."
] | 27eea27e7042a65bd1eef0955a9d8537f737701f | https://github.com/PushmanPHP/pushman_php_library/blob/27eea27e7042a65bd1eef0955a9d8537f737701f/src/Pushman.php#L287-L293 |
5,699 | PushmanPHP/pushman_php_library | src/Pushman.php | Pushman.channel | public function channel($channel)
{
$channel = $this->validateChannel($channel, false);
$url = $this->getURL('channel');
$headers = [
'body' => [
'private' => $this->privateKey,
'channel' => $channel
]
];
$response = $this->processRequest($url, $headers, 'get');
return $response;
} | php | public function channel($channel)
{
$channel = $this->validateChannel($channel, false);
$url = $this->getURL('channel');
$headers = [
'body' => [
'private' => $this->privateKey,
'channel' => $channel
]
];
$response = $this->processRequest($url, $headers, 'get');
return $response;
} | [
"public",
"function",
"channel",
"(",
"$",
"channel",
")",
"{",
"$",
"channel",
"=",
"$",
"this",
"->",
"validateChannel",
"(",
"$",
"channel",
",",
"false",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getURL",
"(",
"'channel'",
")",
";",
"$",
"headers",
"=",
"[",
"'body'",
"=>",
"[",
"'private'",
"=>",
"$",
"this",
"->",
"privateKey",
",",
"'channel'",
"=>",
"$",
"channel",
"]",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"processRequest",
"(",
"$",
"url",
",",
"$",
"headers",
",",
"'get'",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Get information on a single channel.
@param $channel
@return string
@throws \Pushman\PHPLib\Exceptions\InvalidChannelException | [
"Get",
"information",
"on",
"a",
"single",
"channel",
"."
] | 27eea27e7042a65bd1eef0955a9d8537f737701f | https://github.com/PushmanPHP/pushman_php_library/blob/27eea27e7042a65bd1eef0955a9d8537f737701f/src/Pushman.php#L315-L331 |
Subsets and Splits