id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
14,000 | PandaPlatform/framework | src/Panda/Localization/Processors/AbstractProcessor.php | AbstractProcessor.get | public function get($key, $locale, $package = 'default', $default = null)
{
// Check key
if (empty($key)) {
return $default;
}
// Normalize group and load translations
$package = ($package ?: 'default');
try {
$this->loadTranslations($locale, $package);
// Return translation
$array = (static::$translations[$locale] ?: []);
$value = ArrayHelper::get($array, $key, $default, true);
} catch (Exception $ex) {
$value = $default;
}
return $value;
} | php | public function get($key, $locale, $package = 'default', $default = null)
{
// Check key
if (empty($key)) {
return $default;
}
// Normalize group and load translations
$package = ($package ?: 'default');
try {
$this->loadTranslations($locale, $package);
// Return translation
$array = (static::$translations[$locale] ?: []);
$value = ArrayHelper::get($array, $key, $default, true);
} catch (Exception $ex) {
$value = $default;
}
return $value;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"locale",
",",
"$",
"package",
"=",
"'default'",
",",
"$",
"default",
"=",
"null",
")",
"{",
"// Check key",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"// Normalize group and load translations",
"$",
"package",
"=",
"(",
"$",
"package",
"?",
":",
"'default'",
")",
";",
"try",
"{",
"$",
"this",
"->",
"loadTranslations",
"(",
"$",
"locale",
",",
"$",
"package",
")",
";",
"// Return translation",
"$",
"array",
"=",
"(",
"static",
"::",
"$",
"translations",
"[",
"$",
"locale",
"]",
"?",
":",
"[",
"]",
")",
";",
"$",
"value",
"=",
"ArrayHelper",
"::",
"get",
"(",
"$",
"array",
",",
"$",
"key",
",",
"$",
"default",
",",
"true",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"$",
"value",
"=",
"$",
"default",
";",
"}",
"return",
"$",
"value",
";",
"}"
]
| Get a translation value.
If the default value is null and no translation is found, it throws Exception.
@param string $key
@param string $locale
@param string $package
@param mixed $default
@return mixed | [
"Get",
"a",
"translation",
"value",
".",
"If",
"the",
"default",
"value",
"is",
"null",
"and",
"no",
"translation",
"is",
"found",
"it",
"throws",
"Exception",
"."
]
| a78cf051b379896b5a4d5df620988e37a0e632f5 | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Localization/Processors/AbstractProcessor.php#L82-L104 |
14,001 | astronati/php-fantasy-football-quotations-parser | src/Map/Row/Normalizer/Field/RowFieldNormalizerFactory.php | RowFieldNormalizerFactory.create | public static function create($field): RowFieldNormalizerInterface
{
switch ($field) {
case Quotation::ACTIVE:
return new ActiveNormalizer();
case Quotation::ASSISTS_MAGIC_POINTS:
return new AssistsMagicPointsNormalizer();
case Quotation::ASSISTS:
return new AssistsNormalizer();
case Quotation::AUTO_GOALS_MAGIC_POINTS:
return new AutoGoalsMagicPointsNormalizer();
case Quotation::AUTO_GOALS:
return new AutoGoalsNormalizer();
case Quotation::CODE:
return new CodeNormalizer();
case Quotation::GOALS_MAGIC_POINTS:
return new GoalsMagicPointsNormalizer();
case Quotation::GOALS:
return new GoalsNormalizer();
case Quotation::MAGIC_POINTS:
return new MagicPointsNormalizer();
case Quotation::ORIGINAL_MAGIC_POINTS:
return new OriginalMagicPointsNormalizer();
case Quotation::PENALTIES_MAGIC_POINTS:
return new PenaltiesMagicPointsNormalizer();
case Quotation::PENALTIES:
return new PenaltiesNormalizer();
case Quotation::PLAYER:
return new PlayerNormalizer();
case Quotation::QUOTATION:
return new QuotationNormalizer();
case Quotation::RED_CARDS_MAGIC_POINTS:
return new RedCardsMagicPointsNormalizer();
case Quotation::RED_CARDS:
return new RedCardsNormalizer();
case Quotation::ROLE:
return new RoleNormalizer();
case Quotation::SECONDARY_ROLE:
return new SecondaryRoleNormalizer();
case Quotation::TEAM:
return new TeamNormalizer();
case Quotation::VOTE:
return new VoteNormalizer();
case Quotation::YELLOW_CARDS_MAGIC_POINTS:
return new YellowCardsMagicPointsNormalizer();
case Quotation::YELLOW_CARDS:
return new YellowCardsNormalizer();
default:
throw new NotFoundFieldException('Field not found: ' . $field);
}
} | php | public static function create($field): RowFieldNormalizerInterface
{
switch ($field) {
case Quotation::ACTIVE:
return new ActiveNormalizer();
case Quotation::ASSISTS_MAGIC_POINTS:
return new AssistsMagicPointsNormalizer();
case Quotation::ASSISTS:
return new AssistsNormalizer();
case Quotation::AUTO_GOALS_MAGIC_POINTS:
return new AutoGoalsMagicPointsNormalizer();
case Quotation::AUTO_GOALS:
return new AutoGoalsNormalizer();
case Quotation::CODE:
return new CodeNormalizer();
case Quotation::GOALS_MAGIC_POINTS:
return new GoalsMagicPointsNormalizer();
case Quotation::GOALS:
return new GoalsNormalizer();
case Quotation::MAGIC_POINTS:
return new MagicPointsNormalizer();
case Quotation::ORIGINAL_MAGIC_POINTS:
return new OriginalMagicPointsNormalizer();
case Quotation::PENALTIES_MAGIC_POINTS:
return new PenaltiesMagicPointsNormalizer();
case Quotation::PENALTIES:
return new PenaltiesNormalizer();
case Quotation::PLAYER:
return new PlayerNormalizer();
case Quotation::QUOTATION:
return new QuotationNormalizer();
case Quotation::RED_CARDS_MAGIC_POINTS:
return new RedCardsMagicPointsNormalizer();
case Quotation::RED_CARDS:
return new RedCardsNormalizer();
case Quotation::ROLE:
return new RoleNormalizer();
case Quotation::SECONDARY_ROLE:
return new SecondaryRoleNormalizer();
case Quotation::TEAM:
return new TeamNormalizer();
case Quotation::VOTE:
return new VoteNormalizer();
case Quotation::YELLOW_CARDS_MAGIC_POINTS:
return new YellowCardsMagicPointsNormalizer();
case Quotation::YELLOW_CARDS:
return new YellowCardsNormalizer();
default:
throw new NotFoundFieldException('Field not found: ' . $field);
}
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"field",
")",
":",
"RowFieldNormalizerInterface",
"{",
"switch",
"(",
"$",
"field",
")",
"{",
"case",
"Quotation",
"::",
"ACTIVE",
":",
"return",
"new",
"ActiveNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"ASSISTS_MAGIC_POINTS",
":",
"return",
"new",
"AssistsMagicPointsNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"ASSISTS",
":",
"return",
"new",
"AssistsNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"AUTO_GOALS_MAGIC_POINTS",
":",
"return",
"new",
"AutoGoalsMagicPointsNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"AUTO_GOALS",
":",
"return",
"new",
"AutoGoalsNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"CODE",
":",
"return",
"new",
"CodeNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"GOALS_MAGIC_POINTS",
":",
"return",
"new",
"GoalsMagicPointsNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"GOALS",
":",
"return",
"new",
"GoalsNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"MAGIC_POINTS",
":",
"return",
"new",
"MagicPointsNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"ORIGINAL_MAGIC_POINTS",
":",
"return",
"new",
"OriginalMagicPointsNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"PENALTIES_MAGIC_POINTS",
":",
"return",
"new",
"PenaltiesMagicPointsNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"PENALTIES",
":",
"return",
"new",
"PenaltiesNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"PLAYER",
":",
"return",
"new",
"PlayerNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"QUOTATION",
":",
"return",
"new",
"QuotationNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"RED_CARDS_MAGIC_POINTS",
":",
"return",
"new",
"RedCardsMagicPointsNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"RED_CARDS",
":",
"return",
"new",
"RedCardsNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"ROLE",
":",
"return",
"new",
"RoleNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"SECONDARY_ROLE",
":",
"return",
"new",
"SecondaryRoleNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"TEAM",
":",
"return",
"new",
"TeamNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"VOTE",
":",
"return",
"new",
"VoteNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"YELLOW_CARDS_MAGIC_POINTS",
":",
"return",
"new",
"YellowCardsMagicPointsNormalizer",
"(",
")",
";",
"case",
"Quotation",
"::",
"YELLOW_CARDS",
":",
"return",
"new",
"YellowCardsNormalizer",
"(",
")",
";",
"default",
":",
"throw",
"new",
"NotFoundFieldException",
"(",
"'Field not found: '",
".",
"$",
"field",
")",
";",
"}",
"}"
]
| Returns an implementation of RowFieldNormalizerInterface
@param string $field
@return RowFieldNormalizerInterface
@throws NotFoundFieldException | [
"Returns",
"an",
"implementation",
"of",
"RowFieldNormalizerInterface"
]
| 1214f313c325ac7e9fc4d5218b85b3d7234f7bf3 | https://github.com/astronati/php-fantasy-football-quotations-parser/blob/1214f313c325ac7e9fc4d5218b85b3d7234f7bf3/src/Map/Row/Normalizer/Field/RowFieldNormalizerFactory.php#L41-L91 |
14,002 | serverdensity/sd-php-wrapper | lib/serverdensity/Api/Metrics.php | Metrics.available | public function available($id, $start, $end){
$param = array(
'start' => date("Y-m-d\TH:i:s\Z", $start),
'end' => date("Y-m-d\TH:i:s\Z", $end)
);
return $this->get('metrics/definitions/'.urlencode($id), $param);
} | php | public function available($id, $start, $end){
$param = array(
'start' => date("Y-m-d\TH:i:s\Z", $start),
'end' => date("Y-m-d\TH:i:s\Z", $end)
);
return $this->get('metrics/definitions/'.urlencode($id), $param);
} | [
"public",
"function",
"available",
"(",
"$",
"id",
",",
"$",
"start",
",",
"$",
"end",
")",
"{",
"$",
"param",
"=",
"array",
"(",
"'start'",
"=>",
"date",
"(",
"\"Y-m-d\\TH:i:s\\Z\"",
",",
"$",
"start",
")",
",",
"'end'",
"=>",
"date",
"(",
"\"Y-m-d\\TH:i:s\\Z\"",
",",
"$",
"end",
")",
")",
";",
"return",
"$",
"this",
"->",
"get",
"(",
"'metrics/definitions/'",
".",
"urlencode",
"(",
"$",
"id",
")",
",",
"$",
"param",
")",
";",
"}"
]
| Get available metrics
@link https://developer.serverdensity.com/docs/available-metrics
@param string $id the subjectID to get available metrics
@param timestamp $start the start of the period.
@param timestamp $end the end of the period
@return an array that is all available metrics. | [
"Get",
"available",
"metrics"
]
| 9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e | https://github.com/serverdensity/sd-php-wrapper/blob/9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e/lib/serverdensity/Api/Metrics.php#L17-L24 |
14,003 | serverdensity/sd-php-wrapper | lib/serverdensity/Api/Metrics.php | Metrics.metrics | public function metrics($id, $filter, $start, $end){
$param = array(
'start' => date("Y-m-d\TH:i:s\Z", $start),
'end' => date("Y-m-d\TH:i:s\Z", $end),
'filter' => $filter
);
$param = $this->makeJsonReady($param);
return $this->get('metrics/graphs/'.urlencode($id), $param);
} | php | public function metrics($id, $filter, $start, $end){
$param = array(
'start' => date("Y-m-d\TH:i:s\Z", $start),
'end' => date("Y-m-d\TH:i:s\Z", $end),
'filter' => $filter
);
$param = $this->makeJsonReady($param);
return $this->get('metrics/graphs/'.urlencode($id), $param);
} | [
"public",
"function",
"metrics",
"(",
"$",
"id",
",",
"$",
"filter",
",",
"$",
"start",
",",
"$",
"end",
")",
"{",
"$",
"param",
"=",
"array",
"(",
"'start'",
"=>",
"date",
"(",
"\"Y-m-d\\TH:i:s\\Z\"",
",",
"$",
"start",
")",
",",
"'end'",
"=>",
"date",
"(",
"\"Y-m-d\\TH:i:s\\Z\"",
",",
"$",
"end",
")",
",",
"'filter'",
"=>",
"$",
"filter",
")",
";",
"$",
"param",
"=",
"$",
"this",
"->",
"makeJsonReady",
"(",
"$",
"param",
")",
";",
"return",
"$",
"this",
"->",
"get",
"(",
"'metrics/graphs/'",
".",
"urlencode",
"(",
"$",
"id",
")",
",",
"$",
"param",
")",
";",
"}"
]
| Get actual metrics
@link https://developer.serverdensity.com/docs/get-metrics
@param string $id the subjectID to get available metrics
@param array $filter an array of what you want to filter
@param timestamp $start the start of the period.
@param timestamp $end the end of the period
@return an array that is all available metrics. | [
"Get",
"actual",
"metrics"
]
| 9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e | https://github.com/serverdensity/sd-php-wrapper/blob/9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e/lib/serverdensity/Api/Metrics.php#L36-L46 |
14,004 | serverdensity/sd-php-wrapper | lib/serverdensity/Api/Metrics.php | Metrics.dynamicMetrics | public function dynamicMetrics($filter, $start, $end, $inventoryFilter=Null){
$urlencoded = '';
$query = array();
if (isset($inventoryFilter)){
$query['inventoryFilter'] = $inventoryFilter;
}
if (!empty($query)){
$urlencoded = '?' . http_build_query($query);
}
$param = array(
'start' => date("Y-m-d\TH:i:s\Z", $start),
'end' => date("Y-m-d\TH:i:s\Z", $end),
'filter' => $filter
);
$param = $this->makeJsonReady($param);
return $this->get('metrics/dynamicgraphs/' . $urlencoded, $param);
} | php | public function dynamicMetrics($filter, $start, $end, $inventoryFilter=Null){
$urlencoded = '';
$query = array();
if (isset($inventoryFilter)){
$query['inventoryFilter'] = $inventoryFilter;
}
if (!empty($query)){
$urlencoded = '?' . http_build_query($query);
}
$param = array(
'start' => date("Y-m-d\TH:i:s\Z", $start),
'end' => date("Y-m-d\TH:i:s\Z", $end),
'filter' => $filter
);
$param = $this->makeJsonReady($param);
return $this->get('metrics/dynamicgraphs/' . $urlencoded, $param);
} | [
"public",
"function",
"dynamicMetrics",
"(",
"$",
"filter",
",",
"$",
"start",
",",
"$",
"end",
",",
"$",
"inventoryFilter",
"=",
"Null",
")",
"{",
"$",
"urlencoded",
"=",
"''",
";",
"$",
"query",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"inventoryFilter",
")",
")",
"{",
"$",
"query",
"[",
"'inventoryFilter'",
"]",
"=",
"$",
"inventoryFilter",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"query",
")",
")",
"{",
"$",
"urlencoded",
"=",
"'?'",
".",
"http_build_query",
"(",
"$",
"query",
")",
";",
"}",
"$",
"param",
"=",
"array",
"(",
"'start'",
"=>",
"date",
"(",
"\"Y-m-d\\TH:i:s\\Z\"",
",",
"$",
"start",
")",
",",
"'end'",
"=>",
"date",
"(",
"\"Y-m-d\\TH:i:s\\Z\"",
",",
"$",
"end",
")",
",",
"'filter'",
"=>",
"$",
"filter",
")",
";",
"$",
"param",
"=",
"$",
"this",
"->",
"makeJsonReady",
"(",
"$",
"param",
")",
";",
"return",
"$",
"this",
"->",
"get",
"(",
"'metrics/dynamicgraphs/'",
".",
"$",
"urlencoded",
",",
"$",
"param",
")",
";",
"}"
]
| Get dynamic metrics
@link https://developer.serverdensity.com/docs/dynamic-metrics
@param array $filter an array of what you want to filter
@param timestamp $start the start of the period.
@param timestamp $end the end of the period
@param string $inventoryFilter the filter to use to find inventory
@param array $ids an array of ids that you want to filter for.
@param array $names an array of names that you would like to filter for.
@return an array that is all available metrics. | [
"Get",
"dynamic",
"metrics"
]
| 9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e | https://github.com/serverdensity/sd-php-wrapper/blob/9c742a9ee61e32a9bc4ed17b5fe0eca1f4c3015e/lib/serverdensity/Api/Metrics.php#L59-L78 |
14,005 | Im0rtality/Underscore | src/Underscore.php | Underscore.executePayload | protected function executePayload($payload, $args)
{
array_unshift($args, $this->wrapped);
if ($payload instanceof Mutator) {
/** @var $payload callable */
$this->wrapped = call_user_func_array($payload, $args);
return $this;
} else {
return call_user_func_array($payload, $args);
}
} | php | protected function executePayload($payload, $args)
{
array_unshift($args, $this->wrapped);
if ($payload instanceof Mutator) {
/** @var $payload callable */
$this->wrapped = call_user_func_array($payload, $args);
return $this;
} else {
return call_user_func_array($payload, $args);
}
} | [
"protected",
"function",
"executePayload",
"(",
"$",
"payload",
",",
"$",
"args",
")",
"{",
"array_unshift",
"(",
"$",
"args",
",",
"$",
"this",
"->",
"wrapped",
")",
";",
"if",
"(",
"$",
"payload",
"instanceof",
"Mutator",
")",
"{",
"/** @var $payload callable */",
"$",
"this",
"->",
"wrapped",
"=",
"call_user_func_array",
"(",
"$",
"payload",
",",
"$",
"args",
")",
";",
"return",
"$",
"this",
";",
"}",
"else",
"{",
"return",
"call_user_func_array",
"(",
"$",
"payload",
",",
"$",
"args",
")",
";",
"}",
"}"
]
| Payload is either Mutator or Accessor. Both are supposed to be callable.
@param callable $payload
@param array $args
@return $this|mixed | [
"Payload",
"is",
"either",
"Mutator",
"or",
"Accessor",
".",
"Both",
"are",
"supposed",
"to",
"be",
"callable",
"."
]
| 2deb95cfd340761d00ecd0f033e67ce600f2b535 | https://github.com/Im0rtality/Underscore/blob/2deb95cfd340761d00ecd0f033e67ce600f2b535/src/Underscore.php#L145-L157 |
14,006 | TFHInc/ci-realredis | src/Traits/SupportRedis.php | SupportRedis.getElseSet | public function getElseSet(string $key, int $ttl, callable $callable)
{
if ($this->exists($key)) {
return $this->get($key);
}
try {
$callable_data = call_user_func($callable);
} catch( Exception $e ) {
// throw exception
}
$this->set($key, $callable_data);
$this->expireAt($key, time() + $ttl);
return $this->get($key);
} | php | public function getElseSet(string $key, int $ttl, callable $callable)
{
if ($this->exists($key)) {
return $this->get($key);
}
try {
$callable_data = call_user_func($callable);
} catch( Exception $e ) {
// throw exception
}
$this->set($key, $callable_data);
$this->expireAt($key, time() + $ttl);
return $this->get($key);
} | [
"public",
"function",
"getElseSet",
"(",
"string",
"$",
"key",
",",
"int",
"$",
"ttl",
",",
"callable",
"$",
"callable",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"}",
"try",
"{",
"$",
"callable_data",
"=",
"call_user_func",
"(",
"$",
"callable",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"// throw exception",
"}",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"callable_data",
")",
";",
"$",
"this",
"->",
"expireAt",
"(",
"$",
"key",
",",
"time",
"(",
")",
"+",
"$",
"ttl",
")",
";",
"return",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"}"
]
| Get the cache key. If it does not exist, execute the callable and set the cache key.
@param string $key
@param int $ttl
@param callable $callable
@return mixed | [
"Get",
"the",
"cache",
"key",
".",
"If",
"it",
"does",
"not",
"exist",
"execute",
"the",
"callable",
"and",
"set",
"the",
"cache",
"key",
"."
]
| 23b11fb65445a0e3704084788677fe229cf255e6 | https://github.com/TFHInc/ci-realredis/blob/23b11fb65445a0e3704084788677fe229cf255e6/src/Traits/SupportRedis.php#L22-L38 |
14,007 | ipunkt/social-auth | src/Ipunkt/SocialAuth/Repositories/EloquentUserRepository.php | EloquentUserRepository.findByAuth | public function findByAuth($provider, $identifier) {
$user = null;
$login = $this->repository->findByAuth($provider, $identifier);
if($login !== null)
$user = $login->getUser();
return $user;
} | php | public function findByAuth($provider, $identifier) {
$user = null;
$login = $this->repository->findByAuth($provider, $identifier);
if($login !== null)
$user = $login->getUser();
return $user;
} | [
"public",
"function",
"findByAuth",
"(",
"$",
"provider",
",",
"$",
"identifier",
")",
"{",
"$",
"user",
"=",
"null",
";",
"$",
"login",
"=",
"$",
"this",
"->",
"repository",
"->",
"findByAuth",
"(",
"$",
"provider",
",",
"$",
"identifier",
")",
";",
"if",
"(",
"$",
"login",
"!==",
"null",
")",
"$",
"user",
"=",
"$",
"login",
"->",
"getUser",
"(",
")",
";",
"return",
"$",
"user",
";",
"}"
]
| Attempt to find a UserInterface by given login credentials
returns the UserInterface or null on error
@param array $credentials
@return null|User | [
"Attempt",
"to",
"find",
"a",
"UserInterface",
"by",
"given",
"login",
"credentials",
"returns",
"the",
"UserInterface",
"or",
"null",
"on",
"error"
]
| 28723a8e449612789a2cd7d21137996c48b62229 | https://github.com/ipunkt/social-auth/blob/28723a8e449612789a2cd7d21137996c48b62229/src/Ipunkt/SocialAuth/Repositories/EloquentUserRepository.php#L54-L63 |
14,008 | wpup/digster | src/class-digster.php | Digster.instance | public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self;
self::$instance->boot();
self::$instance->setup_actions();
}
return self::$instance;
} | php | public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self;
self::$instance->boot();
self::$instance->setup_actions();
}
return self::$instance;
} | [
"public",
"static",
"function",
"instance",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instance",
")",
")",
"{",
"self",
"::",
"$",
"instance",
"=",
"new",
"self",
";",
"self",
"::",
"$",
"instance",
"->",
"boot",
"(",
")",
";",
"self",
"::",
"$",
"instance",
"->",
"setup_actions",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instance",
";",
"}"
]
| Get Plugin boilerplate loader instance.
@return object | [
"Get",
"Plugin",
"boilerplate",
"loader",
"instance",
"."
]
| 9ef9626ce82673af698bc0976d6c38a532e4a6d9 | https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/class-digster.php#L28-L36 |
14,009 | wpup/digster | src/class-digster.php | Digster.config | public static function config( $key, $value = null ) {
return self::factory()->engine()->config( $key, $value );
} | php | public static function config( $key, $value = null ) {
return self::factory()->engine()->config( $key, $value );
} | [
"public",
"static",
"function",
"config",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"return",
"self",
"::",
"factory",
"(",
")",
"->",
"engine",
"(",
")",
"->",
"config",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
]
| Get or set configuration value.
@param array|string $key
@param mixed $value
@return mixed | [
"Get",
"or",
"set",
"configuration",
"value",
"."
]
| 9ef9626ce82673af698bc0976d6c38a532e4a6d9 | https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/class-digster.php#L65-L67 |
14,010 | wpup/digster | src/class-digster.php | Digster.load_extensions | public function load_extensions() {
$extensions = [
new \Frozzare\Digster\Extensions\Filter_Extensions(),
new \Frozzare\Digster\Extensions\Function_Extensions(),
new \Frozzare\Digster\Extensions\Global_Extensions(),
new \Frozzare\Digster\Extensions\I18n_Extensions()
];
/**
* Modify extensions or add custom.
*
* @param array $extensions
*/
$extensions = apply_filters( 'digster/extensions', $extensions );
// Register extensions with engine.
$this->factory->engine()->register_extensions( $extensions );
} | php | public function load_extensions() {
$extensions = [
new \Frozzare\Digster\Extensions\Filter_Extensions(),
new \Frozzare\Digster\Extensions\Function_Extensions(),
new \Frozzare\Digster\Extensions\Global_Extensions(),
new \Frozzare\Digster\Extensions\I18n_Extensions()
];
/**
* Modify extensions or add custom.
*
* @param array $extensions
*/
$extensions = apply_filters( 'digster/extensions', $extensions );
// Register extensions with engine.
$this->factory->engine()->register_extensions( $extensions );
} | [
"public",
"function",
"load_extensions",
"(",
")",
"{",
"$",
"extensions",
"=",
"[",
"new",
"\\",
"Frozzare",
"\\",
"Digster",
"\\",
"Extensions",
"\\",
"Filter_Extensions",
"(",
")",
",",
"new",
"\\",
"Frozzare",
"\\",
"Digster",
"\\",
"Extensions",
"\\",
"Function_Extensions",
"(",
")",
",",
"new",
"\\",
"Frozzare",
"\\",
"Digster",
"\\",
"Extensions",
"\\",
"Global_Extensions",
"(",
")",
",",
"new",
"\\",
"Frozzare",
"\\",
"Digster",
"\\",
"Extensions",
"\\",
"I18n_Extensions",
"(",
")",
"]",
";",
"/**\n\t\t * Modify extensions or add custom.\n\t\t *\n\t\t * @param array $extensions\n\t\t */",
"$",
"extensions",
"=",
"apply_filters",
"(",
"'digster/extensions'",
",",
"$",
"extensions",
")",
";",
"// Register extensions with engine.",
"$",
"this",
"->",
"factory",
"->",
"engine",
"(",
")",
"->",
"register_extensions",
"(",
"$",
"extensions",
")",
";",
"}"
]
| Load Digster extensions. | [
"Load",
"Digster",
"extensions",
"."
]
| 9ef9626ce82673af698bc0976d6c38a532e4a6d9 | https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/class-digster.php#L93-L110 |
14,011 | wpup/digster | src/class-digster.php | Digster.view | public static function view( $view = null, array $data = [] ) {
if ( func_num_args() === 0 ) {
return self::factory();
}
return self::factory()->make( $view, $data );
} | php | public static function view( $view = null, array $data = [] ) {
if ( func_num_args() === 0 ) {
return self::factory();
}
return self::factory()->make( $view, $data );
} | [
"public",
"static",
"function",
"view",
"(",
"$",
"view",
"=",
"null",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"===",
"0",
")",
"{",
"return",
"self",
"::",
"factory",
"(",
")",
";",
"}",
"return",
"self",
"::",
"factory",
"(",
")",
"->",
"make",
"(",
"$",
"view",
",",
"$",
"data",
")",
";",
"}"
]
| Get the view class.
@param string $view
@param array $data
@return string | [
"Get",
"the",
"view",
"class",
"."
]
| 9ef9626ce82673af698bc0976d6c38a532e4a6d9 | https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/class-digster.php#L158-L164 |
14,012 | euro-ix/ixf-client-php | lib/IXF/ApiResource.php | ApiResource.resolveClass | public static function resolveClass( $resource, $id = null )
{
$class = 'IXF\\' . $resource;
if( class_exists($class) )
return new $class( $id );
return new IXF\ApiResource( $id );
} | php | public static function resolveClass( $resource, $id = null )
{
$class = 'IXF\\' . $resource;
if( class_exists($class) )
return new $class( $id );
return new IXF\ApiResource( $id );
} | [
"public",
"static",
"function",
"resolveClass",
"(",
"$",
"resource",
",",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"class",
"=",
"'IXF\\\\'",
".",
"$",
"resource",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
")",
"return",
"new",
"$",
"class",
"(",
"$",
"id",
")",
";",
"return",
"new",
"IXF",
"\\",
"ApiResource",
"(",
"$",
"id",
")",
";",
"}"
]
| If a class exists for the given resource return an instance
of it, else return an instance of the generic ApiResouce class.
@param string $resource The resource - e.g. ''IXP''
@param int $id ID of the object - use for initialisation
@return ApiResouce Or the more specific child class | [
"If",
"a",
"class",
"exists",
"for",
"the",
"given",
"resource",
"return",
"an",
"instance",
"of",
"it",
"else",
"return",
"an",
"instance",
"of",
"the",
"generic",
"ApiResouce",
"class",
"."
]
| dd39f5c17dc2d3795fcacf5d06793ca28886f3c1 | https://github.com/euro-ix/ixf-client-php/blob/dd39f5c17dc2d3795fcacf5d06793ca28886f3c1/lib/IXF/ApiResource.php#L15-L22 |
14,013 | euro-ix/ixf-client-php | lib/IXF/ApiResource.php | ApiResource.retrieve | public static function retrieve( $resource, $id )
{
$instance = self::resolveClass( $resource, $id );
$instance->refresh( $resource );
return $instance;
} | php | public static function retrieve( $resource, $id )
{
$instance = self::resolveClass( $resource, $id );
$instance->refresh( $resource );
return $instance;
} | [
"public",
"static",
"function",
"retrieve",
"(",
"$",
"resource",
",",
"$",
"id",
")",
"{",
"$",
"instance",
"=",
"self",
"::",
"resolveClass",
"(",
"$",
"resource",
",",
"$",
"id",
")",
";",
"$",
"instance",
"->",
"refresh",
"(",
"$",
"resource",
")",
";",
"return",
"$",
"instance",
";",
"}"
]
| Retrieve an object by ID
@param string $resource The resource - e.g. ''IXP''
@param int $id ID of the object
@return ApiResouce
@throws Error\NotFound If the requested object does not exist | [
"Retrieve",
"an",
"object",
"by",
"ID"
]
| dd39f5c17dc2d3795fcacf5d06793ca28886f3c1 | https://github.com/euro-ix/ixf-client-php/blob/dd39f5c17dc2d3795fcacf5d06793ca28886f3c1/lib/IXF/ApiResource.php#L48-L53 |
14,014 | euro-ix/ixf-client-php | lib/IXF/ApiResource.php | ApiResource.refresh | public function refresh( $resource )
{
$url = $url = '/' . $resource . '/' . $this->id;
$requestor = new ApiRequestor();
$response = $requestor->request(
'get',
$url,
$this->_retrieveOptions
);
$this->refreshFrom($response[0]);
return $this;
} | php | public function refresh( $resource )
{
$url = $url = '/' . $resource . '/' . $this->id;
$requestor = new ApiRequestor();
$response = $requestor->request(
'get',
$url,
$this->_retrieveOptions
);
$this->refreshFrom($response[0]);
return $this;
} | [
"public",
"function",
"refresh",
"(",
"$",
"resource",
")",
"{",
"$",
"url",
"=",
"$",
"url",
"=",
"'/'",
".",
"$",
"resource",
".",
"'/'",
".",
"$",
"this",
"->",
"id",
";",
"$",
"requestor",
"=",
"new",
"ApiRequestor",
"(",
")",
";",
"$",
"response",
"=",
"$",
"requestor",
"->",
"request",
"(",
"'get'",
",",
"$",
"url",
",",
"$",
"this",
"->",
"_retrieveOptions",
")",
";",
"$",
"this",
"->",
"refreshFrom",
"(",
"$",
"response",
"[",
"0",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Refresh the current object from the API service
@param string $resource The resource - e.g. ''IXP''
@return ApiResource The refreshed resource.
@throws Error An appropriate error object | [
"Refresh",
"the",
"current",
"object",
"from",
"the",
"API",
"service"
]
| dd39f5c17dc2d3795fcacf5d06793ca28886f3c1 | https://github.com/euro-ix/ixf-client-php/blob/dd39f5c17dc2d3795fcacf5d06793ca28886f3c1/lib/IXF/ApiResource.php#L63-L76 |
14,015 | euro-ix/ixf-client-php | lib/IXF/ApiResource.php | ApiResource.all | public static function all( $resource, $params=null )
{
self::_validateCall('all', $params);
$requestor = new ApiRequestor();
$url = '/' . $resource;
$response = $requestor->request('get', $url, $params);
return Util::convertToIxfObject($response);
} | php | public static function all( $resource, $params=null )
{
self::_validateCall('all', $params);
$requestor = new ApiRequestor();
$url = '/' . $resource;
$response = $requestor->request('get', $url, $params);
return Util::convertToIxfObject($response);
} | [
"public",
"static",
"function",
"all",
"(",
"$",
"resource",
",",
"$",
"params",
"=",
"null",
")",
"{",
"self",
"::",
"_validateCall",
"(",
"'all'",
",",
"$",
"params",
")",
";",
"$",
"requestor",
"=",
"new",
"ApiRequestor",
"(",
")",
";",
"$",
"url",
"=",
"'/'",
".",
"$",
"resource",
";",
"$",
"response",
"=",
"$",
"requestor",
"->",
"request",
"(",
"'get'",
",",
"$",
"url",
",",
"$",
"params",
")",
";",
"return",
"Util",
"::",
"convertToIxfObject",
"(",
"$",
"response",
")",
";",
"}"
]
| Get all objects of a given resource
Allowed params:
* ''limit'' => integer, limit the number of objects
* ''skip'' => integer, skip the first n objects
@param string $resource The resource - e.g. ''IXP''
@param array|null $params
@return ApiResource[] An array of resource objects.
@throws Error An appropriate error object | [
"Get",
"all",
"objects",
"of",
"a",
"given",
"resource"
]
| dd39f5c17dc2d3795fcacf5d06793ca28886f3c1 | https://github.com/euro-ix/ixf-client-php/blob/dd39f5c17dc2d3795fcacf5d06793ca28886f3c1/lib/IXF/ApiResource.php#L91-L98 |
14,016 | euro-ix/ixf-client-php | lib/IXF/ApiResource.php | ApiResource.save | public function save()
{
$requestor = new ApiRequestor();
$params = $this->serializeParameters();
self::_validateCall( 'save', $params );
unset( $params['id'] );
if( count( $params ) > 0 )
{
$url = '/' . $this->getType() . '/' . $this->id;
return $requestor->request('put', $url, $params);
}
return true;
} | php | public function save()
{
$requestor = new ApiRequestor();
$params = $this->serializeParameters();
self::_validateCall( 'save', $params );
unset( $params['id'] );
if( count( $params ) > 0 )
{
$url = '/' . $this->getType() . '/' . $this->id;
return $requestor->request('put', $url, $params);
}
return true;
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"requestor",
"=",
"new",
"ApiRequestor",
"(",
")",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"serializeParameters",
"(",
")",
";",
"self",
"::",
"_validateCall",
"(",
"'save'",
",",
"$",
"params",
")",
";",
"unset",
"(",
"$",
"params",
"[",
"'id'",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"params",
")",
">",
"0",
")",
"{",
"$",
"url",
"=",
"'/'",
".",
"$",
"this",
"->",
"getType",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"id",
";",
"return",
"$",
"requestor",
"->",
"request",
"(",
"'put'",
",",
"$",
"url",
",",
"$",
"params",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| Save an object
@return bool True when successful
@throws Error An appropriate error object | [
"Save",
"an",
"object"
]
| dd39f5c17dc2d3795fcacf5d06793ca28886f3c1 | https://github.com/euro-ix/ixf-client-php/blob/dd39f5c17dc2d3795fcacf5d06793ca28886f3c1/lib/IXF/ApiResource.php#L125-L139 |
14,017 | crysalead/net | src/Mime/Address.php | Address.toString | public function toString()
{
$email = '<' . Mime::encodeEmail($this->email()) . '>';
$name = $this->name();
return $name ? Mime::encodeValue($name) . ' ' . $email : $email;
} | php | public function toString()
{
$email = '<' . Mime::encodeEmail($this->email()) . '>';
$name = $this->name();
return $name ? Mime::encodeValue($name) . ' ' . $email : $email;
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"email",
"=",
"'<'",
".",
"Mime",
"::",
"encodeEmail",
"(",
"$",
"this",
"->",
"email",
"(",
")",
")",
".",
"'>'",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"name",
"(",
")",
";",
"return",
"$",
"name",
"?",
"Mime",
"::",
"encodeValue",
"(",
"$",
"name",
")",
".",
"' '",
".",
"$",
"email",
":",
"$",
"email",
";",
"}"
]
| Return the encoded representation of the address
@return string | [
"Return",
"the",
"encoded",
"representation",
"of",
"the",
"address"
]
| 4d75abead39e954529b56cbffa3841a9cd3044bb | https://github.com/crysalead/net/blob/4d75abead39e954529b56cbffa3841a9cd3044bb/src/Mime/Address.php#L89-L94 |
14,018 | activecollab/bootstrap | src/ResultEncoder/ResultEncoder.php | ResultEncoder.encodeCollection | private function encodeCollection(CollectionInterface $action_result, ResponseInterface $response)
{
$response = $response->write(json_encode($action_result))->withStatus(200);
if ($action_result->canBeEtagged()) {
if ($action_result->getApplicationIdentifier() != $this->app_identifier) {
$action_result->setApplicationIdentifier($this->app_identifier); // Sign collection etag with app identifier
}
$response = $this->cache_provider->withEtag($response, $action_result->getEtag($this->user_identifier));
$response = $this->cache_provider->withExpires($response, '+90 days');
}
if ($action_result->getCurrentPage() && $action_result->getItemsPerPage()) {
$response = $response->withHeader('X-PaginationCurrentPage', $action_result->getCurrentPage())
->withHeader('X-PaginationItemsPerPage', $action_result->getItemsPerPage())
->withHeader('X-PaginationTotalItems', $action_result->count());
} else {
$response = $response->withHeader('X-PaginationCurrentPage', 0)
->withHeader('X-PaginationItemsPerPage', 0)
->withHeader('X-PaginationTotalItems', $action_result->count());
}
return $response;
} | php | private function encodeCollection(CollectionInterface $action_result, ResponseInterface $response)
{
$response = $response->write(json_encode($action_result))->withStatus(200);
if ($action_result->canBeEtagged()) {
if ($action_result->getApplicationIdentifier() != $this->app_identifier) {
$action_result->setApplicationIdentifier($this->app_identifier); // Sign collection etag with app identifier
}
$response = $this->cache_provider->withEtag($response, $action_result->getEtag($this->user_identifier));
$response = $this->cache_provider->withExpires($response, '+90 days');
}
if ($action_result->getCurrentPage() && $action_result->getItemsPerPage()) {
$response = $response->withHeader('X-PaginationCurrentPage', $action_result->getCurrentPage())
->withHeader('X-PaginationItemsPerPage', $action_result->getItemsPerPage())
->withHeader('X-PaginationTotalItems', $action_result->count());
} else {
$response = $response->withHeader('X-PaginationCurrentPage', 0)
->withHeader('X-PaginationItemsPerPage', 0)
->withHeader('X-PaginationTotalItems', $action_result->count());
}
return $response;
} | [
"private",
"function",
"encodeCollection",
"(",
"CollectionInterface",
"$",
"action_result",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"response",
"=",
"$",
"response",
"->",
"write",
"(",
"json_encode",
"(",
"$",
"action_result",
")",
")",
"->",
"withStatus",
"(",
"200",
")",
";",
"if",
"(",
"$",
"action_result",
"->",
"canBeEtagged",
"(",
")",
")",
"{",
"if",
"(",
"$",
"action_result",
"->",
"getApplicationIdentifier",
"(",
")",
"!=",
"$",
"this",
"->",
"app_identifier",
")",
"{",
"$",
"action_result",
"->",
"setApplicationIdentifier",
"(",
"$",
"this",
"->",
"app_identifier",
")",
";",
"// Sign collection etag with app identifier",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"cache_provider",
"->",
"withEtag",
"(",
"$",
"response",
",",
"$",
"action_result",
"->",
"getEtag",
"(",
"$",
"this",
"->",
"user_identifier",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"cache_provider",
"->",
"withExpires",
"(",
"$",
"response",
",",
"'+90 days'",
")",
";",
"}",
"if",
"(",
"$",
"action_result",
"->",
"getCurrentPage",
"(",
")",
"&&",
"$",
"action_result",
"->",
"getItemsPerPage",
"(",
")",
")",
"{",
"$",
"response",
"=",
"$",
"response",
"->",
"withHeader",
"(",
"'X-PaginationCurrentPage'",
",",
"$",
"action_result",
"->",
"getCurrentPage",
"(",
")",
")",
"->",
"withHeader",
"(",
"'X-PaginationItemsPerPage'",
",",
"$",
"action_result",
"->",
"getItemsPerPage",
"(",
")",
")",
"->",
"withHeader",
"(",
"'X-PaginationTotalItems'",
",",
"$",
"action_result",
"->",
"count",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"response",
"=",
"$",
"response",
"->",
"withHeader",
"(",
"'X-PaginationCurrentPage'",
",",
"0",
")",
"->",
"withHeader",
"(",
"'X-PaginationItemsPerPage'",
",",
"0",
")",
"->",
"withHeader",
"(",
"'X-PaginationTotalItems'",
",",
"$",
"action_result",
"->",
"count",
"(",
")",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
]
| Encode DataObject collection.
@param CollectionInterface $action_result
@param ResponseInterface $response
@return ResponseInterface | [
"Encode",
"DataObject",
"collection",
"."
]
| 92eea19b2b2b329035f20e855a78f36e74084ccf | https://github.com/activecollab/bootstrap/blob/92eea19b2b2b329035f20e855a78f36e74084ccf/src/ResultEncoder/ResultEncoder.php#L101-L125 |
14,019 | activecollab/bootstrap | src/ResultEncoder/ResultEncoder.php | ResultEncoder.encodeSingle | private function encodeSingle(ObjectInterface $action_result, ResponseInterface $response)
{
$result = ['single' => $action_result];
foreach ($action_result->jsonSerializeDetails() as $k => $v) {
if ($k == 'single') {
throw new LogicException("JSON serialize details can't overwrite 'single' property");
} else {
$result[$k] = $v;
}
}
$response = $response->write(json_encode($result))->withStatus(200);
if ($action_result instanceof EtagInterface) {
$response = $response->withHeader('Etag', $action_result->getEtag($this->user_identifier));
}
return $response;
} | php | private function encodeSingle(ObjectInterface $action_result, ResponseInterface $response)
{
$result = ['single' => $action_result];
foreach ($action_result->jsonSerializeDetails() as $k => $v) {
if ($k == 'single') {
throw new LogicException("JSON serialize details can't overwrite 'single' property");
} else {
$result[$k] = $v;
}
}
$response = $response->write(json_encode($result))->withStatus(200);
if ($action_result instanceof EtagInterface) {
$response = $response->withHeader('Etag', $action_result->getEtag($this->user_identifier));
}
return $response;
} | [
"private",
"function",
"encodeSingle",
"(",
"ObjectInterface",
"$",
"action_result",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"result",
"=",
"[",
"'single'",
"=>",
"$",
"action_result",
"]",
";",
"foreach",
"(",
"$",
"action_result",
"->",
"jsonSerializeDetails",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"k",
"==",
"'single'",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"\"JSON serialize details can't overwrite 'single' property\"",
")",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"$",
"response",
"=",
"$",
"response",
"->",
"write",
"(",
"json_encode",
"(",
"$",
"result",
")",
")",
"->",
"withStatus",
"(",
"200",
")",
";",
"if",
"(",
"$",
"action_result",
"instanceof",
"EtagInterface",
")",
"{",
"$",
"response",
"=",
"$",
"response",
"->",
"withHeader",
"(",
"'Etag'",
",",
"$",
"action_result",
"->",
"getEtag",
"(",
"$",
"this",
"->",
"user_identifier",
")",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
]
| Encode individual DataObject object.
@param ObjectInterface $action_result
@param ResponseInterface $response
@return ResponseInterface | [
"Encode",
"individual",
"DataObject",
"object",
"."
]
| 92eea19b2b2b329035f20e855a78f36e74084ccf | https://github.com/activecollab/bootstrap/blob/92eea19b2b2b329035f20e855a78f36e74084ccf/src/ResultEncoder/ResultEncoder.php#L134-L153 |
14,020 | activecollab/bootstrap | src/ResultEncoder/ResultEncoder.php | ResultEncoder.encodeJsonSerializable | protected function encodeJsonSerializable(JsonSerializable $action_result, ResponseInterface $response, $status = 200)
{
return $response->write(json_encode($action_result))->withStatus($status);
} | php | protected function encodeJsonSerializable(JsonSerializable $action_result, ResponseInterface $response, $status = 200)
{
return $response->write(json_encode($action_result))->withStatus($status);
} | [
"protected",
"function",
"encodeJsonSerializable",
"(",
"JsonSerializable",
"$",
"action_result",
",",
"ResponseInterface",
"$",
"response",
",",
"$",
"status",
"=",
"200",
")",
"{",
"return",
"$",
"response",
"->",
"write",
"(",
"json_encode",
"(",
"$",
"action_result",
")",
")",
"->",
"withStatus",
"(",
"$",
"status",
")",
";",
"}"
]
| Encode JsonSerializable instance response, with status 200.
@param JsonSerializable $action_result
@param ResponseInterface $response
@param int $status
@return ResponseInterface | [
"Encode",
"JsonSerializable",
"instance",
"response",
"with",
"status",
"200",
"."
]
| 92eea19b2b2b329035f20e855a78f36e74084ccf | https://github.com/activecollab/bootstrap/blob/92eea19b2b2b329035f20e855a78f36e74084ccf/src/ResultEncoder/ResultEncoder.php#L163-L166 |
14,021 | activecollab/bootstrap | src/ResultEncoder/ResultEncoder.php | ResultEncoder.encodeUserSessionResponse | private function encodeUserSessionResponse(UserSessionResponseInterface $action_result, ServerRequestInterface $request, ResponseInterface $response)
{
if ($action_result->getAuthenticatedWith() instanceof SessionInterface) {
$response = $this->getCookiesProvider()->set($request, $response, $this->getUserSessionIdCookieName(), $action_result->getAuthenticatedWith()->getSessionId(), [
'ttl' => 1209600,
'http_only' => true,
])[1];
}
return $this->encodeArray($action_result->toArray(), $response);
} | php | private function encodeUserSessionResponse(UserSessionResponseInterface $action_result, ServerRequestInterface $request, ResponseInterface $response)
{
if ($action_result->getAuthenticatedWith() instanceof SessionInterface) {
$response = $this->getCookiesProvider()->set($request, $response, $this->getUserSessionIdCookieName(), $action_result->getAuthenticatedWith()->getSessionId(), [
'ttl' => 1209600,
'http_only' => true,
])[1];
}
return $this->encodeArray($action_result->toArray(), $response);
} | [
"private",
"function",
"encodeUserSessionResponse",
"(",
"UserSessionResponseInterface",
"$",
"action_result",
",",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"action_result",
"->",
"getAuthenticatedWith",
"(",
")",
"instanceof",
"SessionInterface",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getCookiesProvider",
"(",
")",
"->",
"set",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"this",
"->",
"getUserSessionIdCookieName",
"(",
")",
",",
"$",
"action_result",
"->",
"getAuthenticatedWith",
"(",
")",
"->",
"getSessionId",
"(",
")",
",",
"[",
"'ttl'",
"=>",
"1209600",
",",
"'http_only'",
"=>",
"true",
",",
"]",
")",
"[",
"1",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"encodeArray",
"(",
"$",
"action_result",
"->",
"toArray",
"(",
")",
",",
"$",
"response",
")",
";",
"}"
]
| Encode user session action results and return properly populated response.
@param UserSessionResponseInterface $action_result
@param ServerRequestInterface $request
@param ResponseInterface $response
@return ResponseInterface | [
"Encode",
"user",
"session",
"action",
"results",
"and",
"return",
"properly",
"populated",
"response",
"."
]
| 92eea19b2b2b329035f20e855a78f36e74084ccf | https://github.com/activecollab/bootstrap/blob/92eea19b2b2b329035f20e855a78f36e74084ccf/src/ResultEncoder/ResultEncoder.php#L176-L186 |
14,022 | activecollab/bootstrap | src/ResultEncoder/ResultEncoder.php | ResultEncoder.encodeUserSessionTerminatedResponse | private function encodeUserSessionTerminatedResponse(UserSessionTerminateResponseInterface $action_result, ServerRequestInterface $request, ResponseInterface $response)
{
$response = $this->getCookiesProvider()->remove($request, $response, $this->getUserSessionIdCookieName())[1];
return $this->encodeArray($action_result->toArray(), $response);
} | php | private function encodeUserSessionTerminatedResponse(UserSessionTerminateResponseInterface $action_result, ServerRequestInterface $request, ResponseInterface $response)
{
$response = $this->getCookiesProvider()->remove($request, $response, $this->getUserSessionIdCookieName())[1];
return $this->encodeArray($action_result->toArray(), $response);
} | [
"private",
"function",
"encodeUserSessionTerminatedResponse",
"(",
"UserSessionTerminateResponseInterface",
"$",
"action_result",
",",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getCookiesProvider",
"(",
")",
"->",
"remove",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"this",
"->",
"getUserSessionIdCookieName",
"(",
")",
")",
"[",
"1",
"]",
";",
"return",
"$",
"this",
"->",
"encodeArray",
"(",
"$",
"action_result",
"->",
"toArray",
"(",
")",
",",
"$",
"response",
")",
";",
"}"
]
| Encode user session terminated action results and return properly populated response.
@param UserSessionTerminateResponseInterface $action_result
@param ServerRequestInterface $request
@param ResponseInterface $response
@return ResponseInterface | [
"Encode",
"user",
"session",
"terminated",
"action",
"results",
"and",
"return",
"properly",
"populated",
"response",
"."
]
| 92eea19b2b2b329035f20e855a78f36e74084ccf | https://github.com/activecollab/bootstrap/blob/92eea19b2b2b329035f20e855a78f36e74084ccf/src/ResultEncoder/ResultEncoder.php#L196-L201 |
14,023 | sifophp/sifo-common-instance | controllers/scripts/loadAvgAutoswitch.php | ScriptsLoadAvgAutoswitchController._getFileContent | private function _getFileContent()
{
if ( !isset( $this->_index_file_content ) )
{
if ( !( $this->_index_file_content = file_get_contents( $this->_root_page_path ) ) )
{
trigger_error( "Root file not found. Please, validate the path.", E_USER_ERROR );
}
}
return $this->_index_file_content;
} | php | private function _getFileContent()
{
if ( !isset( $this->_index_file_content ) )
{
if ( !( $this->_index_file_content = file_get_contents( $this->_root_page_path ) ) )
{
trigger_error( "Root file not found. Please, validate the path.", E_USER_ERROR );
}
}
return $this->_index_file_content;
} | [
"private",
"function",
"_getFileContent",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_index_file_content",
")",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"_index_file_content",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"_root_page_path",
")",
")",
")",
"{",
"trigger_error",
"(",
"\"Root file not found. Please, validate the path.\"",
",",
"E_USER_ERROR",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_index_file_content",
";",
"}"
]
| Return the platform index file content.
@return boolean | [
"Return",
"the",
"platform",
"index",
"file",
"content",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/controllers/scripts/loadAvgAutoswitch.php#L43-L54 |
14,024 | sifophp/sifo-common-instance | controllers/scripts/loadAvgAutoswitch.php | ScriptsLoadAvgAutoswitchController._enablePage | private function _enablePage()
{
if ( $this->test )
{
return true;
}
$enabled_source = $this->_getEnablingCode(). $this->_getFileContent();
return file_put_contents( $this->_root_page_path, $enabled_source );
} | php | private function _enablePage()
{
if ( $this->test )
{
return true;
}
$enabled_source = $this->_getEnablingCode(). $this->_getFileContent();
return file_put_contents( $this->_root_page_path, $enabled_source );
} | [
"private",
"function",
"_enablePage",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"test",
")",
"{",
"return",
"true",
";",
"}",
"$",
"enabled_source",
"=",
"$",
"this",
"->",
"_getEnablingCode",
"(",
")",
".",
"$",
"this",
"->",
"_getFileContent",
"(",
")",
";",
"return",
"file_put_contents",
"(",
"$",
"this",
"->",
"_root_page_path",
",",
"$",
"enabled_source",
")",
";",
"}"
]
| Enable the replacement page.
@return boolean False when error. | [
"Enable",
"the",
"replacement",
"page",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/controllers/scripts/loadAvgAutoswitch.php#L100-L109 |
14,025 | sifophp/sifo-common-instance | controllers/scripts/loadAvgAutoswitch.php | ScriptsLoadAvgAutoswitchController._disablePage | private function _disablePage()
{
if ( $this->test )
{
return true;
}
$disabled_source = str_replace( $this->_getEnablingCode(), '', $this->_getFileContent() );
return file_put_contents( $this->_root_page_path, $disabled_source );;
} | php | private function _disablePage()
{
if ( $this->test )
{
return true;
}
$disabled_source = str_replace( $this->_getEnablingCode(), '', $this->_getFileContent() );
return file_put_contents( $this->_root_page_path, $disabled_source );;
} | [
"private",
"function",
"_disablePage",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"test",
")",
"{",
"return",
"true",
";",
"}",
"$",
"disabled_source",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"_getEnablingCode",
"(",
")",
",",
"''",
",",
"$",
"this",
"->",
"_getFileContent",
"(",
")",
")",
";",
"return",
"file_put_contents",
"(",
"$",
"this",
"->",
"_root_page_path",
",",
"$",
"disabled_source",
")",
";",
";",
"}"
]
| Disable the replacement page. Normal page is enabled.
@return boolean False when error. | [
"Disable",
"the",
"replacement",
"page",
".",
"Normal",
"page",
"is",
"enabled",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/controllers/scripts/loadAvgAutoswitch.php#L117-L127 |
14,026 | FWidm/dwd-hourly-crawler | src/fwidm/dwdHourlyCrawler/DWDLib.php | DWDLib.getAllStations | public function getAllStations(DWDHourlyParameters $hourlyParameters,bool $active=false){
$services = $this->createServices($hourlyParameters);
$crawler = new DWDHourlyCrawler($services);
return $crawler->getAllStations($active);
} | php | public function getAllStations(DWDHourlyParameters $hourlyParameters,bool $active=false){
$services = $this->createServices($hourlyParameters);
$crawler = new DWDHourlyCrawler($services);
return $crawler->getAllStations($active);
} | [
"public",
"function",
"getAllStations",
"(",
"DWDHourlyParameters",
"$",
"hourlyParameters",
",",
"bool",
"$",
"active",
"=",
"false",
")",
"{",
"$",
"services",
"=",
"$",
"this",
"->",
"createServices",
"(",
"$",
"hourlyParameters",
")",
";",
"$",
"crawler",
"=",
"new",
"DWDHourlyCrawler",
"(",
"$",
"services",
")",
";",
"return",
"$",
"crawler",
"->",
"getAllStations",
"(",
"$",
"active",
")",
";",
"}"
]
| Retrieve all stations for the parameters
@param DWDHourlyParameters $hourlyParameters
@param bool $active get active stations
@return array | [
"Retrieve",
"all",
"stations",
"for",
"the",
"parameters"
]
| 36dec7d84a85af599e9d4fb6a3bcc302378ce4a8 | https://github.com/FWidm/dwd-hourly-crawler/blob/36dec7d84a85af599e9d4fb6a3bcc302378ce4a8/src/fwidm/dwdHourlyCrawler/DWDLib.php#L43-L47 |
14,027 | FWidm/dwd-hourly-crawler | src/fwidm/dwdHourlyCrawler/DWDLib.php | DWDLib.createServices | private function createServices(DWDHourlyParameters $variables): array
{
$conf = DWDConfiguration::getHourlyConfiguration()->parameters;
$controllers = array();
if (!empty($variables->getVariables())) {
foreach ($variables->getVariables() as $var) {
switch ($var) {
case $conf->pressure->name:
$controllers[$conf->pressure->name] = new HourlyPressureService('pressure');
break;
case $conf->airTemperature->name:
$controllers[$conf->airTemperature->name] = new HourlyAirTemperatureService('airTemperature');
break;
case $conf->cloudiness->name:
$controllers[$conf->cloudiness->name] = new HourlyCloudinessService('cloudiness');
break;
case $conf->precipitation->name:
$controllers[$conf->precipitation->name] = new HourlyPrecipitationService('precipitation');
break;
case $conf->soilTemperature->name:
$controllers[$conf->soilTemperature->name] = new HourlySoilTempService('soilTemperature');
break;
case $conf->solar->name:
$controllers[$conf->solar->name] = new HourlySolarService('solar');
break;
case $conf->sun->name:
$controllers[$conf->sun->name] = new HourlySunService('sun');
break;
case $conf->wind->name:
$controllers[$conf->wind->name] = new HourlyWindService('wind');
break;
default:
print('Unknown variable: var=' . $var . '<br>');
}
}
}
return $controllers;
} | php | private function createServices(DWDHourlyParameters $variables): array
{
$conf = DWDConfiguration::getHourlyConfiguration()->parameters;
$controllers = array();
if (!empty($variables->getVariables())) {
foreach ($variables->getVariables() as $var) {
switch ($var) {
case $conf->pressure->name:
$controllers[$conf->pressure->name] = new HourlyPressureService('pressure');
break;
case $conf->airTemperature->name:
$controllers[$conf->airTemperature->name] = new HourlyAirTemperatureService('airTemperature');
break;
case $conf->cloudiness->name:
$controllers[$conf->cloudiness->name] = new HourlyCloudinessService('cloudiness');
break;
case $conf->precipitation->name:
$controllers[$conf->precipitation->name] = new HourlyPrecipitationService('precipitation');
break;
case $conf->soilTemperature->name:
$controllers[$conf->soilTemperature->name] = new HourlySoilTempService('soilTemperature');
break;
case $conf->solar->name:
$controllers[$conf->solar->name] = new HourlySolarService('solar');
break;
case $conf->sun->name:
$controllers[$conf->sun->name] = new HourlySunService('sun');
break;
case $conf->wind->name:
$controllers[$conf->wind->name] = new HourlyWindService('wind');
break;
default:
print('Unknown variable: var=' . $var . '<br>');
}
}
}
return $controllers;
} | [
"private",
"function",
"createServices",
"(",
"DWDHourlyParameters",
"$",
"variables",
")",
":",
"array",
"{",
"$",
"conf",
"=",
"DWDConfiguration",
"::",
"getHourlyConfiguration",
"(",
")",
"->",
"parameters",
";",
"$",
"controllers",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"variables",
"->",
"getVariables",
"(",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"variables",
"->",
"getVariables",
"(",
")",
"as",
"$",
"var",
")",
"{",
"switch",
"(",
"$",
"var",
")",
"{",
"case",
"$",
"conf",
"->",
"pressure",
"->",
"name",
":",
"$",
"controllers",
"[",
"$",
"conf",
"->",
"pressure",
"->",
"name",
"]",
"=",
"new",
"HourlyPressureService",
"(",
"'pressure'",
")",
";",
"break",
";",
"case",
"$",
"conf",
"->",
"airTemperature",
"->",
"name",
":",
"$",
"controllers",
"[",
"$",
"conf",
"->",
"airTemperature",
"->",
"name",
"]",
"=",
"new",
"HourlyAirTemperatureService",
"(",
"'airTemperature'",
")",
";",
"break",
";",
"case",
"$",
"conf",
"->",
"cloudiness",
"->",
"name",
":",
"$",
"controllers",
"[",
"$",
"conf",
"->",
"cloudiness",
"->",
"name",
"]",
"=",
"new",
"HourlyCloudinessService",
"(",
"'cloudiness'",
")",
";",
"break",
";",
"case",
"$",
"conf",
"->",
"precipitation",
"->",
"name",
":",
"$",
"controllers",
"[",
"$",
"conf",
"->",
"precipitation",
"->",
"name",
"]",
"=",
"new",
"HourlyPrecipitationService",
"(",
"'precipitation'",
")",
";",
"break",
";",
"case",
"$",
"conf",
"->",
"soilTemperature",
"->",
"name",
":",
"$",
"controllers",
"[",
"$",
"conf",
"->",
"soilTemperature",
"->",
"name",
"]",
"=",
"new",
"HourlySoilTempService",
"(",
"'soilTemperature'",
")",
";",
"break",
";",
"case",
"$",
"conf",
"->",
"solar",
"->",
"name",
":",
"$",
"controllers",
"[",
"$",
"conf",
"->",
"solar",
"->",
"name",
"]",
"=",
"new",
"HourlySolarService",
"(",
"'solar'",
")",
";",
"break",
";",
"case",
"$",
"conf",
"->",
"sun",
"->",
"name",
":",
"$",
"controllers",
"[",
"$",
"conf",
"->",
"sun",
"->",
"name",
"]",
"=",
"new",
"HourlySunService",
"(",
"'sun'",
")",
";",
"break",
";",
"case",
"$",
"conf",
"->",
"wind",
"->",
"name",
":",
"$",
"controllers",
"[",
"$",
"conf",
"->",
"wind",
"->",
"name",
"]",
"=",
"new",
"HourlyWindService",
"(",
"'wind'",
")",
";",
"break",
";",
"default",
":",
"print",
"(",
"'Unknown variable: var='",
".",
"$",
"var",
".",
"'<br>'",
")",
";",
"}",
"}",
"}",
"return",
"$",
"controllers",
";",
"}"
]
| Create a new instance of the appropriate controller.
@param DWDHourlyParameters $variables
@return AbstractHourlyService
@throws Error
@internal param $var | [
"Create",
"a",
"new",
"instance",
"of",
"the",
"appropriate",
"controller",
"."
]
| 36dec7d84a85af599e9d4fb6a3bcc302378ce4a8 | https://github.com/FWidm/dwd-hourly-crawler/blob/36dec7d84a85af599e9d4fb6a3bcc302378ce4a8/src/fwidm/dwdHourlyCrawler/DWDLib.php#L102-L140 |
14,028 | terdia/legato-framework | src/App.php | App.bootMiddleWares | protected function bootMiddleWares()
{
if (isset($this->middleWares['boot']) && count($this->middleWares['boot'])) {
foreach ($this->middleWares['boot'] as $middleware => $handler) {
$this->container->call([$this->container->make($middleware), $handler]);
}
return [];
}
/**
* Framework development mood.
*/
$CSRFProtection = $this->container->make(CSRFProtection::class);
return $this->container->call([$CSRFProtection, 'handle']);
} | php | protected function bootMiddleWares()
{
if (isset($this->middleWares['boot']) && count($this->middleWares['boot'])) {
foreach ($this->middleWares['boot'] as $middleware => $handler) {
$this->container->call([$this->container->make($middleware), $handler]);
}
return [];
}
/**
* Framework development mood.
*/
$CSRFProtection = $this->container->make(CSRFProtection::class);
return $this->container->call([$CSRFProtection, 'handle']);
} | [
"protected",
"function",
"bootMiddleWares",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"middleWares",
"[",
"'boot'",
"]",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"middleWares",
"[",
"'boot'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"middleWares",
"[",
"'boot'",
"]",
"as",
"$",
"middleware",
"=>",
"$",
"handler",
")",
"{",
"$",
"this",
"->",
"container",
"->",
"call",
"(",
"[",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"$",
"middleware",
")",
",",
"$",
"handler",
"]",
")",
";",
"}",
"return",
"[",
"]",
";",
"}",
"/**\n * Framework development mood.\n */",
"$",
"CSRFProtection",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"CSRFProtection",
"::",
"class",
")",
";",
"return",
"$",
"this",
"->",
"container",
"->",
"call",
"(",
"[",
"$",
"CSRFProtection",
",",
"'handle'",
"]",
")",
";",
"}"
]
| Resolve application boot middleware. | [
"Resolve",
"application",
"boot",
"middleware",
"."
]
| 44057c1c3c6f3e9643e9fade51bd417860fafda8 | https://github.com/terdia/legato-framework/blob/44057c1c3c6f3e9643e9fade51bd417860fafda8/src/App.php#L59-L75 |
14,029 | terdia/legato-framework | src/App.php | App.resolveDependencies | protected function resolveDependencies(array $dependencies)
{
foreach ($dependencies as $dependency => $type) {
call_user_func_array([$this, $type], [$dependency]);
}
} | php | protected function resolveDependencies(array $dependencies)
{
foreach ($dependencies as $dependency => $type) {
call_user_func_array([$this, $type], [$dependency]);
}
} | [
"protected",
"function",
"resolveDependencies",
"(",
"array",
"$",
"dependencies",
")",
"{",
"foreach",
"(",
"$",
"dependencies",
"as",
"$",
"dependency",
"=>",
"$",
"type",
")",
"{",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"$",
"type",
"]",
",",
"[",
"$",
"dependency",
"]",
")",
";",
"}",
"}"
]
| Application dependency binding to container.
@param array $dependencies | [
"Application",
"dependency",
"binding",
"to",
"container",
"."
]
| 44057c1c3c6f3e9643e9fade51bd417860fafda8 | https://github.com/terdia/legato-framework/blob/44057c1c3c6f3e9643e9fade51bd417860fafda8/src/App.php#L82-L87 |
14,030 | keboola/php-csvmap | src/Keboola/CsvMap/Mapper.php | Mapper.expandShorthandDefinitions | private function expandShorthandDefinitions()
{
foreach ($this->mapping as $key => $settings) {
if (is_string($key) && is_string($settings)) {
$this->mapping[$key] = [
'type' => 'column',
'mapping' => [
'destination' => $settings
]
];
}
}
} | php | private function expandShorthandDefinitions()
{
foreach ($this->mapping as $key => $settings) {
if (is_string($key) && is_string($settings)) {
$this->mapping[$key] = [
'type' => 'column',
'mapping' => [
'destination' => $settings
]
];
}
}
} | [
"private",
"function",
"expandShorthandDefinitions",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"mapping",
"as",
"$",
"key",
"=>",
"$",
"settings",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
"&&",
"is_string",
"(",
"$",
"settings",
")",
")",
"{",
"$",
"this",
"->",
"mapping",
"[",
"$",
"key",
"]",
"=",
"[",
"'type'",
"=>",
"'column'",
",",
"'mapping'",
"=>",
"[",
"'destination'",
"=>",
"$",
"settings",
"]",
"]",
";",
"}",
"}",
"}"
]
| Expands shorthand definitions to theirs full definition | [
"Expands",
"shorthand",
"definitions",
"to",
"theirs",
"full",
"definition"
]
| 17ff005e2f00535c48bc71d44629cf8fbf78380e | https://github.com/keboola/php-csvmap/blob/17ff005e2f00535c48bc71d44629cf8fbf78380e/src/Keboola/CsvMap/Mapper.php#L56-L68 |
14,031 | keboola/php-csvmap | src/Keboola/CsvMap/Mapper.php | Mapper.getCsvFiles | public function getCsvFiles()
{
$childResults = [];
foreach ($this->parsers as $type => $parser) {
$childResults += $parser->getCsvFiles();
}
$results = array_merge(
[
$this->type => $this->result
],
$childResults
);
return $results;
} | php | public function getCsvFiles()
{
$childResults = [];
foreach ($this->parsers as $type => $parser) {
$childResults += $parser->getCsvFiles();
}
$results = array_merge(
[
$this->type => $this->result
],
$childResults
);
return $results;
} | [
"public",
"function",
"getCsvFiles",
"(",
")",
"{",
"$",
"childResults",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"parsers",
"as",
"$",
"type",
"=>",
"$",
"parser",
")",
"{",
"$",
"childResults",
"+=",
"$",
"parser",
"->",
"getCsvFiles",
"(",
")",
";",
"}",
"$",
"results",
"=",
"array_merge",
"(",
"[",
"$",
"this",
"->",
"type",
"=>",
"$",
"this",
"->",
"result",
"]",
",",
"$",
"childResults",
")",
";",
"return",
"$",
"results",
";",
"}"
]
| Return own result and all children
@return Table[] | [
"Return",
"own",
"result",
"and",
"all",
"children"
]
| 17ff005e2f00535c48bc71d44629cf8fbf78380e | https://github.com/keboola/php-csvmap/blob/17ff005e2f00535c48bc71d44629cf8fbf78380e/src/Keboola/CsvMap/Mapper.php#L300-L315 |
14,032 | nyeholt/silverstripe-simplewiki | thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Length.php | HTMLPurifier_Length.isValid | public function isValid() {
if ($this->isValid === null) $this->isValid = $this->validate();
return $this->isValid;
} | php | public function isValid() {
if ($this->isValid === null) $this->isValid = $this->validate();
return $this->isValid;
} | [
"public",
"function",
"isValid",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isValid",
"===",
"null",
")",
"$",
"this",
"->",
"isValid",
"=",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"return",
"$",
"this",
"->",
"isValid",
";",
"}"
]
| Returns true if this length unit is valid. | [
"Returns",
"true",
"if",
"this",
"length",
"unit",
"is",
"valid",
"."
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Length.php#L93-L96 |
14,033 | nyeholt/silverstripe-simplewiki | thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Length.php | HTMLPurifier_Length.compareTo | public function compareTo($l) {
if ($l === false) return false;
if ($l->unit !== $this->unit) {
$converter = new HTMLPurifier_UnitConverter();
$l = $converter->convert($l, $this->unit);
if ($l === false) return false;
}
return $this->n - $l->n;
} | php | public function compareTo($l) {
if ($l === false) return false;
if ($l->unit !== $this->unit) {
$converter = new HTMLPurifier_UnitConverter();
$l = $converter->convert($l, $this->unit);
if ($l === false) return false;
}
return $this->n - $l->n;
} | [
"public",
"function",
"compareTo",
"(",
"$",
"l",
")",
"{",
"if",
"(",
"$",
"l",
"===",
"false",
")",
"return",
"false",
";",
"if",
"(",
"$",
"l",
"->",
"unit",
"!==",
"$",
"this",
"->",
"unit",
")",
"{",
"$",
"converter",
"=",
"new",
"HTMLPurifier_UnitConverter",
"(",
")",
";",
"$",
"l",
"=",
"$",
"converter",
"->",
"convert",
"(",
"$",
"l",
",",
"$",
"this",
"->",
"unit",
")",
";",
"if",
"(",
"$",
"l",
"===",
"false",
")",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"n",
"-",
"$",
"l",
"->",
"n",
";",
"}"
]
| Compares two lengths, and returns 1 if greater, -1 if less and 0 if equal.
@warning If both values are too large or small, this calculation will
not work properly | [
"Compares",
"two",
"lengths",
"and",
"returns",
"1",
"if",
"greater",
"-",
"1",
"if",
"less",
"and",
"0",
"if",
"equal",
"."
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Length.php#L103-L111 |
14,034 | ptlis/conneg | src/Preference/Matched/MatchedPreferenceSort.php | MatchedPreferenceSort.sortAscending | public function sortAscending(array $prefList)
{
$comparator = new MatchedPreferenceComparator();
usort(
$prefList,
function (MatchedPreferenceInterface $lValue, MatchedPreferenceInterface $rValue) use ($comparator) {
return -1 * $comparator->compare($lValue, $rValue);
}
);
return $prefList;
} | php | public function sortAscending(array $prefList)
{
$comparator = new MatchedPreferenceComparator();
usort(
$prefList,
function (MatchedPreferenceInterface $lValue, MatchedPreferenceInterface $rValue) use ($comparator) {
return -1 * $comparator->compare($lValue, $rValue);
}
);
return $prefList;
} | [
"public",
"function",
"sortAscending",
"(",
"array",
"$",
"prefList",
")",
"{",
"$",
"comparator",
"=",
"new",
"MatchedPreferenceComparator",
"(",
")",
";",
"usort",
"(",
"$",
"prefList",
",",
"function",
"(",
"MatchedPreferenceInterface",
"$",
"lValue",
",",
"MatchedPreferenceInterface",
"$",
"rValue",
")",
"use",
"(",
"$",
"comparator",
")",
"{",
"return",
"-",
"1",
"*",
"$",
"comparator",
"->",
"compare",
"(",
"$",
"lValue",
",",
"$",
"rValue",
")",
";",
"}",
")",
";",
"return",
"$",
"prefList",
";",
"}"
]
| Sort the array of MatchedPreference instances in ascending order.
@param MatchedPreferenceInterface[] $prefList
@return MatchedPreferenceInterface[] | [
"Sort",
"the",
"array",
"of",
"MatchedPreference",
"instances",
"in",
"ascending",
"order",
"."
]
| 04afb568f368ecdd81c13277006c4be041ccb58b | https://github.com/ptlis/conneg/blob/04afb568f368ecdd81c13277006c4be041ccb58b/src/Preference/Matched/MatchedPreferenceSort.php#L23-L35 |
14,035 | csun-metalab/laravel-directory-authentication | src/Authentication/Factories/HandlerLDAPFactory.php | HandlerLDAPFactory.fromDefaults | public static function fromDefaults() {
$handler = new HandlerLDAP(
config('ldap.host'),
config('ldap.basedn'),
config('ldap.dn'),
config('ldap.password'),
config('ldap.search_user_id'),
config('ldap.search_username'),
config('ldap.search_user_mail'),
config('ldap.search_user_mail_array')
);
$handler->setVersion(config('ldap.version'));
$handler->setOverlayDN(config('ldap.overlay_dn'));
// configuration for add operations
$handler->setAddBaseDN(config('ldap.add_base_dn'));
$handler->setAddDN(config('ldap.add_dn'));
$handler->setAddPassword(config('ldap.add_pw'));
// configuration for modify operations
$handler->setModifyMethod(config('ldap.modify_method'));
$handler->setModifyBaseDN(config('ldap.modify_base_dn'));
$handler->setModifyDN(config('ldap.modify_dn'));
$handler->setModifyPassword(config('ldap.modify_pw'));
return $handler;
} | php | public static function fromDefaults() {
$handler = new HandlerLDAP(
config('ldap.host'),
config('ldap.basedn'),
config('ldap.dn'),
config('ldap.password'),
config('ldap.search_user_id'),
config('ldap.search_username'),
config('ldap.search_user_mail'),
config('ldap.search_user_mail_array')
);
$handler->setVersion(config('ldap.version'));
$handler->setOverlayDN(config('ldap.overlay_dn'));
// configuration for add operations
$handler->setAddBaseDN(config('ldap.add_base_dn'));
$handler->setAddDN(config('ldap.add_dn'));
$handler->setAddPassword(config('ldap.add_pw'));
// configuration for modify operations
$handler->setModifyMethod(config('ldap.modify_method'));
$handler->setModifyBaseDN(config('ldap.modify_base_dn'));
$handler->setModifyDN(config('ldap.modify_dn'));
$handler->setModifyPassword(config('ldap.modify_pw'));
return $handler;
} | [
"public",
"static",
"function",
"fromDefaults",
"(",
")",
"{",
"$",
"handler",
"=",
"new",
"HandlerLDAP",
"(",
"config",
"(",
"'ldap.host'",
")",
",",
"config",
"(",
"'ldap.basedn'",
")",
",",
"config",
"(",
"'ldap.dn'",
")",
",",
"config",
"(",
"'ldap.password'",
")",
",",
"config",
"(",
"'ldap.search_user_id'",
")",
",",
"config",
"(",
"'ldap.search_username'",
")",
",",
"config",
"(",
"'ldap.search_user_mail'",
")",
",",
"config",
"(",
"'ldap.search_user_mail_array'",
")",
")",
";",
"$",
"handler",
"->",
"setVersion",
"(",
"config",
"(",
"'ldap.version'",
")",
")",
";",
"$",
"handler",
"->",
"setOverlayDN",
"(",
"config",
"(",
"'ldap.overlay_dn'",
")",
")",
";",
"// configuration for add operations",
"$",
"handler",
"->",
"setAddBaseDN",
"(",
"config",
"(",
"'ldap.add_base_dn'",
")",
")",
";",
"$",
"handler",
"->",
"setAddDN",
"(",
"config",
"(",
"'ldap.add_dn'",
")",
")",
";",
"$",
"handler",
"->",
"setAddPassword",
"(",
"config",
"(",
"'ldap.add_pw'",
")",
")",
";",
"// configuration for modify operations",
"$",
"handler",
"->",
"setModifyMethod",
"(",
"config",
"(",
"'ldap.modify_method'",
")",
")",
";",
"$",
"handler",
"->",
"setModifyBaseDN",
"(",
"config",
"(",
"'ldap.modify_base_dn'",
")",
")",
";",
"$",
"handler",
"->",
"setModifyDN",
"(",
"config",
"(",
"'ldap.modify_dn'",
")",
")",
";",
"$",
"handler",
"->",
"setModifyPassword",
"(",
"config",
"(",
"'ldap.modify_pw'",
")",
")",
";",
"return",
"$",
"handler",
";",
"}"
]
| Returns a HandlerLDAP instance based on the default configuration.
@return HandlerLDAP | [
"Returns",
"a",
"HandlerLDAP",
"instance",
"based",
"on",
"the",
"default",
"configuration",
"."
]
| b8d4fa64dd646566e508cdf838d6a3d03b1d53ea | https://github.com/csun-metalab/laravel-directory-authentication/blob/b8d4fa64dd646566e508cdf838d6a3d03b1d53ea/src/Authentication/Factories/HandlerLDAPFactory.php#L17-L43 |
14,036 | sifophp/sifo-common-instance | controllers/i18n/actions.php | I18nActionsController.addMessage | protected function addMessage( $instance )
{
$message = \Sifo\FilterPost::getInstance()->getString( 'msgid' );
$translator_model = new I18nTranslatorModel();
// Check if this message exists in the instances parents.
// Get selected instance inheritance.
$instance_domains = $this->getConfig( 'domains', $instance );
$instance_inheritance = array();
if ( isset( $instance_domains['instance_inheritance'] ) )
{
$instance_inheritance = $instance_domains['instance_inheritance'];
}
if ( $translator_model->getMessageInInhertitance( $message, $instance_inheritance ) > 0 )
{
return array( 'status' => 'KO', 'msg' => 'This message already exists in parent instance. Please, customize it.' );
}
elseif ( $translator_model->addMessage( $message, $instance ) )
{
return array( 'status' => 'OK', 'msg' => 'Message successfully saved.' );
}
return array( 'status' => 'KO', 'msg' => 'Failed adding message.' );
} | php | protected function addMessage( $instance )
{
$message = \Sifo\FilterPost::getInstance()->getString( 'msgid' );
$translator_model = new I18nTranslatorModel();
// Check if this message exists in the instances parents.
// Get selected instance inheritance.
$instance_domains = $this->getConfig( 'domains', $instance );
$instance_inheritance = array();
if ( isset( $instance_domains['instance_inheritance'] ) )
{
$instance_inheritance = $instance_domains['instance_inheritance'];
}
if ( $translator_model->getMessageInInhertitance( $message, $instance_inheritance ) > 0 )
{
return array( 'status' => 'KO', 'msg' => 'This message already exists in parent instance. Please, customize it.' );
}
elseif ( $translator_model->addMessage( $message, $instance ) )
{
return array( 'status' => 'OK', 'msg' => 'Message successfully saved.' );
}
return array( 'status' => 'KO', 'msg' => 'Failed adding message.' );
} | [
"protected",
"function",
"addMessage",
"(",
"$",
"instance",
")",
"{",
"$",
"message",
"=",
"\\",
"Sifo",
"\\",
"FilterPost",
"::",
"getInstance",
"(",
")",
"->",
"getString",
"(",
"'msgid'",
")",
";",
"$",
"translator_model",
"=",
"new",
"I18nTranslatorModel",
"(",
")",
";",
"// Check if this message exists in the instances parents.",
"// Get selected instance inheritance.",
"$",
"instance_domains",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'domains'",
",",
"$",
"instance",
")",
";",
"$",
"instance_inheritance",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"instance_domains",
"[",
"'instance_inheritance'",
"]",
")",
")",
"{",
"$",
"instance_inheritance",
"=",
"$",
"instance_domains",
"[",
"'instance_inheritance'",
"]",
";",
"}",
"if",
"(",
"$",
"translator_model",
"->",
"getMessageInInhertitance",
"(",
"$",
"message",
",",
"$",
"instance_inheritance",
")",
">",
"0",
")",
"{",
"return",
"array",
"(",
"'status'",
"=>",
"'KO'",
",",
"'msg'",
"=>",
"'This message already exists in parent instance. Please, customize it.'",
")",
";",
"}",
"elseif",
"(",
"$",
"translator_model",
"->",
"addMessage",
"(",
"$",
"message",
",",
"$",
"instance",
")",
")",
"{",
"return",
"array",
"(",
"'status'",
"=>",
"'OK'",
",",
"'msg'",
"=>",
"'Message successfully saved.'",
")",
";",
"}",
"return",
"array",
"(",
"'status'",
"=>",
"'KO'",
",",
"'msg'",
"=>",
"'Failed adding message.'",
")",
";",
"}"
]
| Add message.
@return mixed | [
"Add",
"message",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/controllers/i18n/actions.php#L39-L64 |
14,037 | sifophp/sifo-common-instance | controllers/i18n/actions.php | I18nActionsController.customizeTranslation | protected function customizeTranslation()
{
$message = \Sifo\FilterPost::getInstance()->getString( 'msgid' );
$id_message = null;
if ( is_numeric( $message ) )
{
$id_message = $message;
}
$instance = $this->getParsedParam( 'instance' );
$translator_model = new I18nTranslatorModel();
$id_message = $translator_model->getTranslation( $message, $id_message );
$result = array( 'status' => 'KO', 'msg' => 'This Message or ID doesn\'t exist.' );
if ( $id_message )
{
$result = array( 'status' => 'OK', 'msg' => 'Message successfully customized.' );
if( !$translator_model->customizeTranslation( $id_message, $instance ) )
{
$result = array( 'status' => 'KO', 'msg' => 'This message is already customized in this instance.' );
}
}
return $result;
} | php | protected function customizeTranslation()
{
$message = \Sifo\FilterPost::getInstance()->getString( 'msgid' );
$id_message = null;
if ( is_numeric( $message ) )
{
$id_message = $message;
}
$instance = $this->getParsedParam( 'instance' );
$translator_model = new I18nTranslatorModel();
$id_message = $translator_model->getTranslation( $message, $id_message );
$result = array( 'status' => 'KO', 'msg' => 'This Message or ID doesn\'t exist.' );
if ( $id_message )
{
$result = array( 'status' => 'OK', 'msg' => 'Message successfully customized.' );
if( !$translator_model->customizeTranslation( $id_message, $instance ) )
{
$result = array( 'status' => 'KO', 'msg' => 'This message is already customized in this instance.' );
}
}
return $result;
} | [
"protected",
"function",
"customizeTranslation",
"(",
")",
"{",
"$",
"message",
"=",
"\\",
"Sifo",
"\\",
"FilterPost",
"::",
"getInstance",
"(",
")",
"->",
"getString",
"(",
"'msgid'",
")",
";",
"$",
"id_message",
"=",
"null",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"message",
")",
")",
"{",
"$",
"id_message",
"=",
"$",
"message",
";",
"}",
"$",
"instance",
"=",
"$",
"this",
"->",
"getParsedParam",
"(",
"'instance'",
")",
";",
"$",
"translator_model",
"=",
"new",
"I18nTranslatorModel",
"(",
")",
";",
"$",
"id_message",
"=",
"$",
"translator_model",
"->",
"getTranslation",
"(",
"$",
"message",
",",
"$",
"id_message",
")",
";",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"'KO'",
",",
"'msg'",
"=>",
"'This Message or ID doesn\\'t exist.'",
")",
";",
"if",
"(",
"$",
"id_message",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"'OK'",
",",
"'msg'",
"=>",
"'Message successfully customized.'",
")",
";",
"if",
"(",
"!",
"$",
"translator_model",
"->",
"customizeTranslation",
"(",
"$",
"id_message",
",",
"$",
"instance",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"'KO'",
",",
"'msg'",
"=>",
"'This message is already customized in this instance.'",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| Customize translation.
@return mixed | [
"Customize",
"translation",
"."
]
| 52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5 | https://github.com/sifophp/sifo-common-instance/blob/52d54ea3e565bd2bccd77e0b0a6a99b5cae3aff5/controllers/i18n/actions.php#L70-L94 |
14,038 | itrnka/ha-framework | src/ha/Access/HTTP/Error/Handler/HTTPErrorHandlerDefault.php | HTTPErrorHandlerDefault.handleError | public function handleError(HTTPInputRequest $request, HTTPOutputResponse $response, \Throwable $e) : void
{
if ($e instanceof HTTPError) {
$e->generateErrorResponse();
}
#$error = (new HTTPServerError([], $e->getMessage()))->generateErrorResponse();
throw $e;
} | php | public function handleError(HTTPInputRequest $request, HTTPOutputResponse $response, \Throwable $e) : void
{
if ($e instanceof HTTPError) {
$e->generateErrorResponse();
}
#$error = (new HTTPServerError([], $e->getMessage()))->generateErrorResponse();
throw $e;
} | [
"public",
"function",
"handleError",
"(",
"HTTPInputRequest",
"$",
"request",
",",
"HTTPOutputResponse",
"$",
"response",
",",
"\\",
"Throwable",
"$",
"e",
")",
":",
"void",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"HTTPError",
")",
"{",
"$",
"e",
"->",
"generateErrorResponse",
"(",
")",
";",
"}",
"#$error = (new HTTPServerError([], $e->getMessage()))->generateErrorResponse();",
"throw",
"$",
"e",
";",
"}"
]
| Handle HTTP error or other \Throwable instance throwed under HTTP access.
@param HTTPInputRequest $request
@param HTTPOutputResponse $response
@param \Throwable $e
@throws \Throwable
@internal param \Throwable $error | [
"Handle",
"HTTP",
"error",
"or",
"other",
"\\",
"Throwable",
"instance",
"throwed",
"under",
"HTTP",
"access",
"."
]
| a72b09c28f8e966c37f98a0004e4fbbce80df42c | https://github.com/itrnka/ha-framework/blob/a72b09c28f8e966c37f98a0004e4fbbce80df42c/src/ha/Access/HTTP/Error/Handler/HTTPErrorHandlerDefault.php#L23-L30 |
14,039 | dphn/ScContent | src/ScContent/Controller/Back/ThemeController.php | ThemeController.indexAction | public function indexAction()
{
$view = new ViewModel();
$service = $this->getThemeService();
$view->registeredThemes = $service->getRegisteredThemes();
$view->options = $this->getModuleOptions();
$flashMessenger = $this->flashMessenger();
if ($flashMessenger->hasMessages()) {
$view->messages = $flashMessenger->getMessages();
}
return $view;
} | php | public function indexAction()
{
$view = new ViewModel();
$service = $this->getThemeService();
$view->registeredThemes = $service->getRegisteredThemes();
$view->options = $this->getModuleOptions();
$flashMessenger = $this->flashMessenger();
if ($flashMessenger->hasMessages()) {
$view->messages = $flashMessenger->getMessages();
}
return $view;
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"service",
"=",
"$",
"this",
"->",
"getThemeService",
"(",
")",
";",
"$",
"view",
"->",
"registeredThemes",
"=",
"$",
"service",
"->",
"getRegisteredThemes",
"(",
")",
";",
"$",
"view",
"->",
"options",
"=",
"$",
"this",
"->",
"getModuleOptions",
"(",
")",
";",
"$",
"flashMessenger",
"=",
"$",
"this",
"->",
"flashMessenger",
"(",
")",
";",
"if",
"(",
"$",
"flashMessenger",
"->",
"hasMessages",
"(",
")",
")",
"{",
"$",
"view",
"->",
"messages",
"=",
"$",
"flashMessenger",
"->",
"getMessages",
"(",
")",
";",
"}",
"return",
"$",
"view",
";",
"}"
]
| Show list of themes.
@return \Zend\View\Model\ViewModel | [
"Show",
"list",
"of",
"themes",
"."
]
| 9dd5732490c45fd788b96cedf7b3c7adfacb30d2 | https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Controller/Back/ThemeController.php#L38-L49 |
14,040 | dphn/ScContent | src/ScContent/Controller/Back/ThemeController.php | ThemeController.enableAction | public function enableAction()
{
$themeName = $this->params()->fromRoute('theme');
if (! $themeName) {
$this->flashMessenger()->addMessage(
$this->scTranslate('Theme was not specified.')
);
return $this->redirect()
->toRoute('sc-admin/theme')
->setStatusCode(303);
}
$service = $this->getThemeService();
if (! $service->enableTheme($themeName)) {
foreach ($service->getMessages() as $message) {
$this->flashMessenger()->addMessage($message);
}
}
return $this->redirect()->toRoute('sc-admin/theme');
} | php | public function enableAction()
{
$themeName = $this->params()->fromRoute('theme');
if (! $themeName) {
$this->flashMessenger()->addMessage(
$this->scTranslate('Theme was not specified.')
);
return $this->redirect()
->toRoute('sc-admin/theme')
->setStatusCode(303);
}
$service = $this->getThemeService();
if (! $service->enableTheme($themeName)) {
foreach ($service->getMessages() as $message) {
$this->flashMessenger()->addMessage($message);
}
}
return $this->redirect()->toRoute('sc-admin/theme');
} | [
"public",
"function",
"enableAction",
"(",
")",
"{",
"$",
"themeName",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'theme'",
")",
";",
"if",
"(",
"!",
"$",
"themeName",
")",
"{",
"$",
"this",
"->",
"flashMessenger",
"(",
")",
"->",
"addMessage",
"(",
"$",
"this",
"->",
"scTranslate",
"(",
"'Theme was not specified.'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toRoute",
"(",
"'sc-admin/theme'",
")",
"->",
"setStatusCode",
"(",
"303",
")",
";",
"}",
"$",
"service",
"=",
"$",
"this",
"->",
"getThemeService",
"(",
")",
";",
"if",
"(",
"!",
"$",
"service",
"->",
"enableTheme",
"(",
"$",
"themeName",
")",
")",
"{",
"foreach",
"(",
"$",
"service",
"->",
"getMessages",
"(",
")",
"as",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"flashMessenger",
"(",
")",
"->",
"addMessage",
"(",
"$",
"message",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toRoute",
"(",
"'sc-admin/theme'",
")",
";",
"}"
]
| Enable theme.
@return \Zend\Stdlib\ResponseInterface | [
"Enable",
"theme",
"."
]
| 9dd5732490c45fd788b96cedf7b3c7adfacb30d2 | https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Controller/Back/ThemeController.php#L56-L75 |
14,041 | dphn/ScContent | src/ScContent/Controller/Back/ThemeController.php | ThemeController.disableAction | public function disableAction()
{
$themeName = $this->params()->fromRoute('theme');
if (! $themeName) {
$this->flashMessenger()->addMessage(
$this->scTranslate('Theme was not specified.')
);
return $this->redirect()
->toRoute('sc-admin/theme')
->setStatusCode(303);
}
$service = $this->getThemeService();
if (! $service->disableTheme($themeName)) {
foreach ($service->getMessages() as $message) {
$this->flashMessenger()->addMessage($message);
}
}
return $this->redirect()->toRoute('sc-admin/theme');
} | php | public function disableAction()
{
$themeName = $this->params()->fromRoute('theme');
if (! $themeName) {
$this->flashMessenger()->addMessage(
$this->scTranslate('Theme was not specified.')
);
return $this->redirect()
->toRoute('sc-admin/theme')
->setStatusCode(303);
}
$service = $this->getThemeService();
if (! $service->disableTheme($themeName)) {
foreach ($service->getMessages() as $message) {
$this->flashMessenger()->addMessage($message);
}
}
return $this->redirect()->toRoute('sc-admin/theme');
} | [
"public",
"function",
"disableAction",
"(",
")",
"{",
"$",
"themeName",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'theme'",
")",
";",
"if",
"(",
"!",
"$",
"themeName",
")",
"{",
"$",
"this",
"->",
"flashMessenger",
"(",
")",
"->",
"addMessage",
"(",
"$",
"this",
"->",
"scTranslate",
"(",
"'Theme was not specified.'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toRoute",
"(",
"'sc-admin/theme'",
")",
"->",
"setStatusCode",
"(",
"303",
")",
";",
"}",
"$",
"service",
"=",
"$",
"this",
"->",
"getThemeService",
"(",
")",
";",
"if",
"(",
"!",
"$",
"service",
"->",
"disableTheme",
"(",
"$",
"themeName",
")",
")",
"{",
"foreach",
"(",
"$",
"service",
"->",
"getMessages",
"(",
")",
"as",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"flashMessenger",
"(",
")",
"->",
"addMessage",
"(",
"$",
"message",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toRoute",
"(",
"'sc-admin/theme'",
")",
";",
"}"
]
| Disable theme.
@return \Zend\Stdlib\ResponseInterface | [
"Disable",
"theme",
"."
]
| 9dd5732490c45fd788b96cedf7b3c7adfacb30d2 | https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Controller/Back/ThemeController.php#L82-L101 |
14,042 | dphn/ScContent | src/ScContent/Controller/Back/ThemeController.php | ThemeController.defaultAction | public function defaultAction()
{
$themeName = $this->params()->fromRoute('theme');
if (! $themeName) {
$this->flashMessenger()->addMessage(
$this->scTranslate('Theme was not specified.')
);
return $this->redirect()
->toRoute('sc-admin/theme')
->setStatusCode(303);
}
$side = $this->params()->fromRoute('side', 'frontend');
$service = $this->getThemeService();
if (! $service->setDefault($themeName, $side)) {
foreach ($service->getMessages() as $message) {
$this->flashMessenger()->addMessage($message);
}
}
return $this->redirect()->toRoute('sc-admin/theme');
} | php | public function defaultAction()
{
$themeName = $this->params()->fromRoute('theme');
if (! $themeName) {
$this->flashMessenger()->addMessage(
$this->scTranslate('Theme was not specified.')
);
return $this->redirect()
->toRoute('sc-admin/theme')
->setStatusCode(303);
}
$side = $this->params()->fromRoute('side', 'frontend');
$service = $this->getThemeService();
if (! $service->setDefault($themeName, $side)) {
foreach ($service->getMessages() as $message) {
$this->flashMessenger()->addMessage($message);
}
}
return $this->redirect()->toRoute('sc-admin/theme');
} | [
"public",
"function",
"defaultAction",
"(",
")",
"{",
"$",
"themeName",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'theme'",
")",
";",
"if",
"(",
"!",
"$",
"themeName",
")",
"{",
"$",
"this",
"->",
"flashMessenger",
"(",
")",
"->",
"addMessage",
"(",
"$",
"this",
"->",
"scTranslate",
"(",
"'Theme was not specified.'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toRoute",
"(",
"'sc-admin/theme'",
")",
"->",
"setStatusCode",
"(",
"303",
")",
";",
"}",
"$",
"side",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'side'",
",",
"'frontend'",
")",
";",
"$",
"service",
"=",
"$",
"this",
"->",
"getThemeService",
"(",
")",
";",
"if",
"(",
"!",
"$",
"service",
"->",
"setDefault",
"(",
"$",
"themeName",
",",
"$",
"side",
")",
")",
"{",
"foreach",
"(",
"$",
"service",
"->",
"getMessages",
"(",
")",
"as",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"flashMessenger",
"(",
")",
"->",
"addMessage",
"(",
"$",
"message",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toRoute",
"(",
"'sc-admin/theme'",
")",
";",
"}"
]
| Set the default theme.
@return \Zend\Stdlib\ResponseInterface | [
"Set",
"the",
"default",
"theme",
"."
]
| 9dd5732490c45fd788b96cedf7b3c7adfacb30d2 | https://github.com/dphn/ScContent/blob/9dd5732490c45fd788b96cedf7b3c7adfacb30d2/src/ScContent/Controller/Back/ThemeController.php#L108-L127 |
14,043 | hfcorriez/php-childprocess | lib/Pagon/ChildProcess.php | ChildProcess.self | public static function self(array $option = array())
{
if (!self::$self) {
self::$self = new self($option);
}
return self::$self;
} | php | public static function self(array $option = array())
{
if (!self::$self) {
self::$self = new self($option);
}
return self::$self;
} | [
"public",
"static",
"function",
"self",
"(",
"array",
"$",
"option",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"self",
")",
"{",
"self",
"::",
"$",
"self",
"=",
"new",
"self",
"(",
"$",
"option",
")",
";",
"}",
"return",
"self",
"::",
"$",
"self",
";",
"}"
]
| Instance for current process | [
"Instance",
"for",
"current",
"process"
]
| 92481a85783cf2a24fef1760930f1252bb83fa5d | https://github.com/hfcorriez/php-childprocess/blob/92481a85783cf2a24fef1760930f1252bb83fa5d/lib/Pagon/ChildProcess.php#L76-L82 |
14,044 | hfcorriez/php-childprocess | lib/Pagon/ChildProcess.php | ChildProcess.parallel | public function parallel($closure, $options = array(), $start = true)
{
// Check auto_start
if (is_bool($options)) {
$start = $options;
$options = array();
}
// Check if process set
if ($closure instanceof Process) {
$child = $closure;
$closure = $child->runner;
$options = $child->options;
} else {
// Build new child
$child = new Process($this, null, $this->pid);
// Get options
$options = $this->getOptions($options);
}
// Auto start
if (!$start) {
$child->register($closure, $options);
if (!in_array($child, $this->prepared_children)) {
$this->prepared_children[] = $child;
}
return $child;
}
// Process init
if ($options['init'] instanceof \Closure) {
$options['init']($child);
}
// Fork
$pid = pcntl_fork();
// Save child process and return
$this->children[$pid] = $child;
// Remove from prepared children
if (($index = array_search($child, $this->prepared_children)) !== false) {
unset($this->prepared_children[$index]);
}
// Parallel works
if ($pid === -1) {
throw new \RuntimeException('Unable to fork child process.');
} else if ($pid) {
// Save child process and return
$child->init($pid);
$child->emit('fork');
return $child;
} else {
// Child initialize
$this->childInitialize($options);
// Support callable
call_user_func($closure, $this->process);
exit;
}
} | php | public function parallel($closure, $options = array(), $start = true)
{
// Check auto_start
if (is_bool($options)) {
$start = $options;
$options = array();
}
// Check if process set
if ($closure instanceof Process) {
$child = $closure;
$closure = $child->runner;
$options = $child->options;
} else {
// Build new child
$child = new Process($this, null, $this->pid);
// Get options
$options = $this->getOptions($options);
}
// Auto start
if (!$start) {
$child->register($closure, $options);
if (!in_array($child, $this->prepared_children)) {
$this->prepared_children[] = $child;
}
return $child;
}
// Process init
if ($options['init'] instanceof \Closure) {
$options['init']($child);
}
// Fork
$pid = pcntl_fork();
// Save child process and return
$this->children[$pid] = $child;
// Remove from prepared children
if (($index = array_search($child, $this->prepared_children)) !== false) {
unset($this->prepared_children[$index]);
}
// Parallel works
if ($pid === -1) {
throw new \RuntimeException('Unable to fork child process.');
} else if ($pid) {
// Save child process and return
$child->init($pid);
$child->emit('fork');
return $child;
} else {
// Child initialize
$this->childInitialize($options);
// Support callable
call_user_func($closure, $this->process);
exit;
}
} | [
"public",
"function",
"parallel",
"(",
"$",
"closure",
",",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"start",
"=",
"true",
")",
"{",
"// Check auto_start",
"if",
"(",
"is_bool",
"(",
"$",
"options",
")",
")",
"{",
"$",
"start",
"=",
"$",
"options",
";",
"$",
"options",
"=",
"array",
"(",
")",
";",
"}",
"// Check if process set",
"if",
"(",
"$",
"closure",
"instanceof",
"Process",
")",
"{",
"$",
"child",
"=",
"$",
"closure",
";",
"$",
"closure",
"=",
"$",
"child",
"->",
"runner",
";",
"$",
"options",
"=",
"$",
"child",
"->",
"options",
";",
"}",
"else",
"{",
"// Build new child",
"$",
"child",
"=",
"new",
"Process",
"(",
"$",
"this",
",",
"null",
",",
"$",
"this",
"->",
"pid",
")",
";",
"// Get options",
"$",
"options",
"=",
"$",
"this",
"->",
"getOptions",
"(",
"$",
"options",
")",
";",
"}",
"// Auto start",
"if",
"(",
"!",
"$",
"start",
")",
"{",
"$",
"child",
"->",
"register",
"(",
"$",
"closure",
",",
"$",
"options",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"child",
",",
"$",
"this",
"->",
"prepared_children",
")",
")",
"{",
"$",
"this",
"->",
"prepared_children",
"[",
"]",
"=",
"$",
"child",
";",
"}",
"return",
"$",
"child",
";",
"}",
"// Process init",
"if",
"(",
"$",
"options",
"[",
"'init'",
"]",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"options",
"[",
"'init'",
"]",
"(",
"$",
"child",
")",
";",
"}",
"// Fork",
"$",
"pid",
"=",
"pcntl_fork",
"(",
")",
";",
"// Save child process and return",
"$",
"this",
"->",
"children",
"[",
"$",
"pid",
"]",
"=",
"$",
"child",
";",
"// Remove from prepared children",
"if",
"(",
"(",
"$",
"index",
"=",
"array_search",
"(",
"$",
"child",
",",
"$",
"this",
"->",
"prepared_children",
")",
")",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"prepared_children",
"[",
"$",
"index",
"]",
")",
";",
"}",
"// Parallel works",
"if",
"(",
"$",
"pid",
"===",
"-",
"1",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Unable to fork child process.'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"pid",
")",
"{",
"// Save child process and return",
"$",
"child",
"->",
"init",
"(",
"$",
"pid",
")",
";",
"$",
"child",
"->",
"emit",
"(",
"'fork'",
")",
";",
"return",
"$",
"child",
";",
"}",
"else",
"{",
"// Child initialize",
"$",
"this",
"->",
"childInitialize",
"(",
"$",
"options",
")",
";",
"// Support callable",
"call_user_func",
"(",
"$",
"closure",
",",
"$",
"this",
"->",
"process",
")",
";",
"exit",
";",
"}",
"}"
]
| Run the closure in parallel space
@param callable|Process $closure
@param array|\Closure $options
@param bool $start
@throws \RuntimeException
@return Process | [
"Run",
"the",
"closure",
"in",
"parallel",
"space"
]
| 92481a85783cf2a24fef1760930f1252bb83fa5d | https://github.com/hfcorriez/php-childprocess/blob/92481a85783cf2a24fef1760930f1252bb83fa5d/lib/Pagon/ChildProcess.php#L109-L170 |
14,045 | hfcorriez/php-childprocess | lib/Pagon/ChildProcess.php | ChildProcess.daemonize | public function daemonize()
{
$pid = pcntl_fork();
if ($pid === -1) {
throw new \RuntimeException('Unable to fork child process.');
} else if ($pid) {
exit;
}
// Make sub process as session leader
posix_setsid();
if ($pid === -1) {
throw new \RuntimeException('Unable to fork child process.');
} else if ($pid) {
exit;
}
// Prepare the resource
$this->prepared = false;
$pid = posix_getpid();
$this->ppid = $this->pid;
$this->pid = $pid;
$this->queue = null;
$this->process = new Process($this, $this->pid, $this->ppid);
$this->children = array();
$this->prepared = true;
return $this;
} | php | public function daemonize()
{
$pid = pcntl_fork();
if ($pid === -1) {
throw new \RuntimeException('Unable to fork child process.');
} else if ($pid) {
exit;
}
// Make sub process as session leader
posix_setsid();
if ($pid === -1) {
throw new \RuntimeException('Unable to fork child process.');
} else if ($pid) {
exit;
}
// Prepare the resource
$this->prepared = false;
$pid = posix_getpid();
$this->ppid = $this->pid;
$this->pid = $pid;
$this->queue = null;
$this->process = new Process($this, $this->pid, $this->ppid);
$this->children = array();
$this->prepared = true;
return $this;
} | [
"public",
"function",
"daemonize",
"(",
")",
"{",
"$",
"pid",
"=",
"pcntl_fork",
"(",
")",
";",
"if",
"(",
"$",
"pid",
"===",
"-",
"1",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Unable to fork child process.'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"pid",
")",
"{",
"exit",
";",
"}",
"// Make sub process as session leader",
"posix_setsid",
"(",
")",
";",
"if",
"(",
"$",
"pid",
"===",
"-",
"1",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Unable to fork child process.'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"pid",
")",
"{",
"exit",
";",
"}",
"// Prepare the resource",
"$",
"this",
"->",
"prepared",
"=",
"false",
";",
"$",
"pid",
"=",
"posix_getpid",
"(",
")",
";",
"$",
"this",
"->",
"ppid",
"=",
"$",
"this",
"->",
"pid",
";",
"$",
"this",
"->",
"pid",
"=",
"$",
"pid",
";",
"$",
"this",
"->",
"queue",
"=",
"null",
";",
"$",
"this",
"->",
"process",
"=",
"new",
"Process",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"pid",
",",
"$",
"this",
"->",
"ppid",
")",
";",
"$",
"this",
"->",
"children",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"prepared",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
]
| Make the process daemonize
@return ChildProcess
@throws \RuntimeException | [
"Make",
"the",
"process",
"daemonize"
]
| 92481a85783cf2a24fef1760930f1252bb83fa5d | https://github.com/hfcorriez/php-childprocess/blob/92481a85783cf2a24fef1760930f1252bb83fa5d/lib/Pagon/ChildProcess.php#L303-L333 |
14,046 | hfcorriez/php-childprocess | lib/Pagon/ChildProcess.php | ChildProcess.listen | public function listen()
{
if (!$this->queue) {
$this->queue = msg_get_queue($this->pid);
$this->emit('listen');
}
return $this;
} | php | public function listen()
{
if (!$this->queue) {
$this->queue = msg_get_queue($this->pid);
$this->emit('listen');
}
return $this;
} | [
"public",
"function",
"listen",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"queue",
")",
"{",
"$",
"this",
"->",
"queue",
"=",
"msg_get_queue",
"(",
"$",
"this",
"->",
"pid",
")",
";",
"$",
"this",
"->",
"emit",
"(",
"'listen'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Register message listener | [
"Register",
"message",
"listener"
]
| 92481a85783cf2a24fef1760930f1252bb83fa5d | https://github.com/hfcorriez/php-childprocess/blob/92481a85783cf2a24fef1760930f1252bb83fa5d/lib/Pagon/ChildProcess.php#L358-L365 |
14,047 | hfcorriez/php-childprocess | lib/Pagon/ChildProcess.php | ChildProcess.childInitialize | protected function childInitialize(array $options = array())
{
$this->prepared = false;
$this->removeAllListeners();
$this->master = false;
$pid = posix_getpid();
$this->ppid = $this->pid;
$this->pid = $pid;
$this->queue = null;
$this->process = new Process($this, $this->pid, $this->ppid);
$this->children = array();
$this->prepared = true;
$options = $options + self::$child_options;
$this->childProcessOptions($options);
} | php | protected function childInitialize(array $options = array())
{
$this->prepared = false;
$this->removeAllListeners();
$this->master = false;
$pid = posix_getpid();
$this->ppid = $this->pid;
$this->pid = $pid;
$this->queue = null;
$this->process = new Process($this, $this->pid, $this->ppid);
$this->children = array();
$this->prepared = true;
$options = $options + self::$child_options;
$this->childProcessOptions($options);
} | [
"protected",
"function",
"childInitialize",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"prepared",
"=",
"false",
";",
"$",
"this",
"->",
"removeAllListeners",
"(",
")",
";",
"$",
"this",
"->",
"master",
"=",
"false",
";",
"$",
"pid",
"=",
"posix_getpid",
"(",
")",
";",
"$",
"this",
"->",
"ppid",
"=",
"$",
"this",
"->",
"pid",
";",
"$",
"this",
"->",
"pid",
"=",
"$",
"pid",
";",
"$",
"this",
"->",
"queue",
"=",
"null",
";",
"$",
"this",
"->",
"process",
"=",
"new",
"Process",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"pid",
",",
"$",
"this",
"->",
"ppid",
")",
";",
"$",
"this",
"->",
"children",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"prepared",
"=",
"true",
";",
"$",
"options",
"=",
"$",
"options",
"+",
"self",
"::",
"$",
"child_options",
";",
"$",
"this",
"->",
"childProcessOptions",
"(",
"$",
"options",
")",
";",
"}"
]
| Init child process
@param array $options | [
"Init",
"child",
"process"
]
| 92481a85783cf2a24fef1760930f1252bb83fa5d | https://github.com/hfcorriez/php-childprocess/blob/92481a85783cf2a24fef1760930f1252bb83fa5d/lib/Pagon/ChildProcess.php#L395-L411 |
14,048 | hfcorriez/php-childprocess | lib/Pagon/ChildProcess.php | ChildProcess.childProcessOptions | protected function childProcessOptions($options)
{
// Process options
if ($options['cwd']) {
chdir($options['cwd']);
}
// User to be change
if ($options['user']) {
$this->childChangeUser($options['user']);
}
// Env set
if ($options['env']) {
$this->childChangeEnv($options['env']);
}
// Env set
if ($options['timeout']) {
$this->childSetTimeout($options['timeout']);
}
// Support callback
if ($options['callback'] instanceof \Closure) {
$options['callback']($this);
}
} | php | protected function childProcessOptions($options)
{
// Process options
if ($options['cwd']) {
chdir($options['cwd']);
}
// User to be change
if ($options['user']) {
$this->childChangeUser($options['user']);
}
// Env set
if ($options['env']) {
$this->childChangeEnv($options['env']);
}
// Env set
if ($options['timeout']) {
$this->childSetTimeout($options['timeout']);
}
// Support callback
if ($options['callback'] instanceof \Closure) {
$options['callback']($this);
}
} | [
"protected",
"function",
"childProcessOptions",
"(",
"$",
"options",
")",
"{",
"// Process options",
"if",
"(",
"$",
"options",
"[",
"'cwd'",
"]",
")",
"{",
"chdir",
"(",
"$",
"options",
"[",
"'cwd'",
"]",
")",
";",
"}",
"// User to be change",
"if",
"(",
"$",
"options",
"[",
"'user'",
"]",
")",
"{",
"$",
"this",
"->",
"childChangeUser",
"(",
"$",
"options",
"[",
"'user'",
"]",
")",
";",
"}",
"// Env set",
"if",
"(",
"$",
"options",
"[",
"'env'",
"]",
")",
"{",
"$",
"this",
"->",
"childChangeEnv",
"(",
"$",
"options",
"[",
"'env'",
"]",
")",
";",
"}",
"// Env set",
"if",
"(",
"$",
"options",
"[",
"'timeout'",
"]",
")",
"{",
"$",
"this",
"->",
"childSetTimeout",
"(",
"$",
"options",
"[",
"'timeout'",
"]",
")",
";",
"}",
"// Support callback",
"if",
"(",
"$",
"options",
"[",
"'callback'",
"]",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"options",
"[",
"'callback'",
"]",
"(",
"$",
"this",
")",
";",
"}",
"}"
]
| Process options in child
@param $options | [
"Process",
"options",
"in",
"child"
]
| 92481a85783cf2a24fef1760930f1252bb83fa5d | https://github.com/hfcorriez/php-childprocess/blob/92481a85783cf2a24fef1760930f1252bb83fa5d/lib/Pagon/ChildProcess.php#L418-L444 |
14,049 | hfcorriez/php-childprocess | lib/Pagon/ChildProcess.php | ChildProcess.tryChangeUser | protected function tryChangeUser($user)
{
$changed_user = false;
// Check user can be changed?
if ($user && posix_getuid() > 0) {
// Not root
throw new \RuntimeException('Only root can change user to spawn the process');
}
// Check user if exists?
if ($user && !($changed_user = posix_getpwnam($user))) {
throw new \RuntimeException('Can not look up user: ' . $user);
}
return $changed_user;
} | php | protected function tryChangeUser($user)
{
$changed_user = false;
// Check user can be changed?
if ($user && posix_getuid() > 0) {
// Not root
throw new \RuntimeException('Only root can change user to spawn the process');
}
// Check user if exists?
if ($user && !($changed_user = posix_getpwnam($user))) {
throw new \RuntimeException('Can not look up user: ' . $user);
}
return $changed_user;
} | [
"protected",
"function",
"tryChangeUser",
"(",
"$",
"user",
")",
"{",
"$",
"changed_user",
"=",
"false",
";",
"// Check user can be changed?",
"if",
"(",
"$",
"user",
"&&",
"posix_getuid",
"(",
")",
">",
"0",
")",
"{",
"// Not root",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Only root can change user to spawn the process'",
")",
";",
"}",
"// Check user if exists?",
"if",
"(",
"$",
"user",
"&&",
"!",
"(",
"$",
"changed_user",
"=",
"posix_getpwnam",
"(",
"$",
"user",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Can not look up user: '",
".",
"$",
"user",
")",
";",
"}",
"return",
"$",
"changed_user",
";",
"}"
]
| Try to change user
@param string $user
@return array|bool
@throws \RuntimeException | [
"Try",
"to",
"change",
"user"
]
| 92481a85783cf2a24fef1760930f1252bb83fa5d | https://github.com/hfcorriez/php-childprocess/blob/92481a85783cf2a24fef1760930f1252bb83fa5d/lib/Pagon/ChildProcess.php#L453-L468 |
14,050 | hfcorriez/php-childprocess | lib/Pagon/ChildProcess.php | ChildProcess.childSetTimeout | protected function childSetTimeout($timeout)
{
$start_time = time();
$self = $this;
$this->on('tick', function () use ($timeout, $start_time, $self) {
if ($start_time + $timeout < time()) $self->shutdown(1);
});
} | php | protected function childSetTimeout($timeout)
{
$start_time = time();
$self = $this;
$this->on('tick', function () use ($timeout, $start_time, $self) {
if ($start_time + $timeout < time()) $self->shutdown(1);
});
} | [
"protected",
"function",
"childSetTimeout",
"(",
"$",
"timeout",
")",
"{",
"$",
"start_time",
"=",
"time",
"(",
")",
";",
"$",
"self",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"on",
"(",
"'tick'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"timeout",
",",
"$",
"start_time",
",",
"$",
"self",
")",
"{",
"if",
"(",
"$",
"start_time",
"+",
"$",
"timeout",
"<",
"time",
"(",
")",
")",
"$",
"self",
"->",
"shutdown",
"(",
"1",
")",
";",
"}",
")",
";",
"}"
]
| Try to set timeout
@param int $timeout | [
"Try",
"to",
"set",
"timeout"
]
| 92481a85783cf2a24fef1760930f1252bb83fa5d | https://github.com/hfcorriez/php-childprocess/blob/92481a85783cf2a24fef1760930f1252bb83fa5d/lib/Pagon/ChildProcess.php#L475-L482 |
14,051 | hfcorriez/php-childprocess | lib/Pagon/ChildProcess.php | ChildProcess.childChangeUser | protected function childChangeUser($user)
{
if (is_array($user) || ($user = $this->tryChangeUser($user))) {
posix_setgid($user['gid']);
posix_setuid($user['uid']);
}
} | php | protected function childChangeUser($user)
{
if (is_array($user) || ($user = $this->tryChangeUser($user))) {
posix_setgid($user['gid']);
posix_setuid($user['uid']);
}
} | [
"protected",
"function",
"childChangeUser",
"(",
"$",
"user",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"user",
")",
"||",
"(",
"$",
"user",
"=",
"$",
"this",
"->",
"tryChangeUser",
"(",
"$",
"user",
")",
")",
")",
"{",
"posix_setgid",
"(",
"$",
"user",
"[",
"'gid'",
"]",
")",
";",
"posix_setuid",
"(",
"$",
"user",
"[",
"'uid'",
"]",
")",
";",
"}",
"}"
]
| Process change user
@param string $user | [
"Process",
"change",
"user"
]
| 92481a85783cf2a24fef1760930f1252bb83fa5d | https://github.com/hfcorriez/php-childprocess/blob/92481a85783cf2a24fef1760930f1252bb83fa5d/lib/Pagon/ChildProcess.php#L514-L520 |
14,052 | hfcorriez/php-childprocess | lib/Pagon/ChildProcess.php | ChildProcess.signalHandlerDefault | protected function signalHandlerDefault($signal)
{
switch ($signal) {
case SIGTERM:
case SIGINT:
// Check children
while ($this->children) {
foreach ($this->children as $child) {
$ok = $child->kill(SIGINT);
/* EPERM */
if (posix_get_last_error() == 1) $ok = false;
if ($ok) {
// Emit exit
$child->emit('abort', $signal);
$child->shutdown($signal);
$this->clear($child);
}
}
}
$this->emit('abort', $signal);
$this->shutdown($signal);
exit;
break;
}
} | php | protected function signalHandlerDefault($signal)
{
switch ($signal) {
case SIGTERM:
case SIGINT:
// Check children
while ($this->children) {
foreach ($this->children as $child) {
$ok = $child->kill(SIGINT);
/* EPERM */
if (posix_get_last_error() == 1) $ok = false;
if ($ok) {
// Emit exit
$child->emit('abort', $signal);
$child->shutdown($signal);
$this->clear($child);
}
}
}
$this->emit('abort', $signal);
$this->shutdown($signal);
exit;
break;
}
} | [
"protected",
"function",
"signalHandlerDefault",
"(",
"$",
"signal",
")",
"{",
"switch",
"(",
"$",
"signal",
")",
"{",
"case",
"SIGTERM",
":",
"case",
"SIGINT",
":",
"// Check children",
"while",
"(",
"$",
"this",
"->",
"children",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"ok",
"=",
"$",
"child",
"->",
"kill",
"(",
"SIGINT",
")",
";",
"/* EPERM */",
"if",
"(",
"posix_get_last_error",
"(",
")",
"==",
"1",
")",
"$",
"ok",
"=",
"false",
";",
"if",
"(",
"$",
"ok",
")",
"{",
"// Emit exit",
"$",
"child",
"->",
"emit",
"(",
"'abort'",
",",
"$",
"signal",
")",
";",
"$",
"child",
"->",
"shutdown",
"(",
"$",
"signal",
")",
";",
"$",
"this",
"->",
"clear",
"(",
"$",
"child",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"emit",
"(",
"'abort'",
",",
"$",
"signal",
")",
";",
"$",
"this",
"->",
"shutdown",
"(",
"$",
"signal",
")",
";",
"exit",
";",
"break",
";",
"}",
"}"
]
| Default signal handler
@param int $signal | [
"Default",
"signal",
"handler"
]
| 92481a85783cf2a24fef1760930f1252bb83fa5d | https://github.com/hfcorriez/php-childprocess/blob/92481a85783cf2a24fef1760930f1252bb83fa5d/lib/Pagon/ChildProcess.php#L571-L596 |
14,053 | hfcorriez/php-childprocess | lib/Pagon/ChildProcess.php | ChildProcess.shutdown | public function shutdown($status = 0, $info = null)
{
if (!$this->process->isExit()) {
$this->process->status = $status;
$this->emit('exit', $status, $info);
$this->process->emit('exit', $status, $info);
}
} | php | public function shutdown($status = 0, $info = null)
{
if (!$this->process->isExit()) {
$this->process->status = $status;
$this->emit('exit', $status, $info);
$this->process->emit('exit', $status, $info);
}
} | [
"public",
"function",
"shutdown",
"(",
"$",
"status",
"=",
"0",
",",
"$",
"info",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"process",
"->",
"isExit",
"(",
")",
")",
"{",
"$",
"this",
"->",
"process",
"->",
"status",
"=",
"$",
"status",
";",
"$",
"this",
"->",
"emit",
"(",
"'exit'",
",",
"$",
"status",
",",
"$",
"info",
")",
";",
"$",
"this",
"->",
"process",
"->",
"emit",
"(",
"'exit'",
",",
"$",
"status",
",",
"$",
"info",
")",
";",
"}",
"}"
]
| Shutdown with status
@param int $status
@param mixed $info | [
"Shutdown",
"with",
"status"
]
| 92481a85783cf2a24fef1760930f1252bb83fa5d | https://github.com/hfcorriez/php-childprocess/blob/92481a85783cf2a24fef1760930f1252bb83fa5d/lib/Pagon/ChildProcess.php#L604-L611 |
14,054 | hfcorriez/php-childprocess | lib/Pagon/ChildProcess.php | ChildProcess.registerTickHandlers | protected function registerTickHandlers()
{
$self = $this;
register_tick_function(function () use ($self) {
if (!$self->prepared) {
return;
}
if ($self->master) {
while ($pid = pcntl_wait($status, WNOHANG)) {
if ($pid === -1) {
pcntl_signal_dispatch();
break;
}
if (empty($self->children[$pid])) continue;
$self->children[$pid]->emit('finish', $status);
$self->children[$pid]->shutdown($status);
$self->clear($pid);
}
}
$self->emit('tick');
if (!is_resource($self->queue) || !msg_stat_queue($self->queue)) {
return;
}
while (msg_receive($self->queue, 1, $null, 1024, $msg, true, MSG_IPC_NOWAIT, $error)) {
if (!is_array($msg) || empty($msg['to']) || $msg['to'] != $self->pid) {
$self->emit('unknown_message', $msg);
} else {
if ($self->master) {
if (!empty($self->children[$msg['from']])
&& ($process = $self->children[$msg['from']])
) {
$process->emit('message', $msg['body']);
} else {
$self->emit('unknown_message', $msg);
}
} else if ($msg['from'] == $self->ppid) {
// Come from parent process
$self->process->emit('message', $msg['body']);
}
}
}
});
} | php | protected function registerTickHandlers()
{
$self = $this;
register_tick_function(function () use ($self) {
if (!$self->prepared) {
return;
}
if ($self->master) {
while ($pid = pcntl_wait($status, WNOHANG)) {
if ($pid === -1) {
pcntl_signal_dispatch();
break;
}
if (empty($self->children[$pid])) continue;
$self->children[$pid]->emit('finish', $status);
$self->children[$pid]->shutdown($status);
$self->clear($pid);
}
}
$self->emit('tick');
if (!is_resource($self->queue) || !msg_stat_queue($self->queue)) {
return;
}
while (msg_receive($self->queue, 1, $null, 1024, $msg, true, MSG_IPC_NOWAIT, $error)) {
if (!is_array($msg) || empty($msg['to']) || $msg['to'] != $self->pid) {
$self->emit('unknown_message', $msg);
} else {
if ($self->master) {
if (!empty($self->children[$msg['from']])
&& ($process = $self->children[$msg['from']])
) {
$process->emit('message', $msg['body']);
} else {
$self->emit('unknown_message', $msg);
}
} else if ($msg['from'] == $self->ppid) {
// Come from parent process
$self->process->emit('message', $msg['body']);
}
}
}
});
} | [
"protected",
"function",
"registerTickHandlers",
"(",
")",
"{",
"$",
"self",
"=",
"$",
"this",
";",
"register_tick_function",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"self",
")",
"{",
"if",
"(",
"!",
"$",
"self",
"->",
"prepared",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"self",
"->",
"master",
")",
"{",
"while",
"(",
"$",
"pid",
"=",
"pcntl_wait",
"(",
"$",
"status",
",",
"WNOHANG",
")",
")",
"{",
"if",
"(",
"$",
"pid",
"===",
"-",
"1",
")",
"{",
"pcntl_signal_dispatch",
"(",
")",
";",
"break",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"self",
"->",
"children",
"[",
"$",
"pid",
"]",
")",
")",
"continue",
";",
"$",
"self",
"->",
"children",
"[",
"$",
"pid",
"]",
"->",
"emit",
"(",
"'finish'",
",",
"$",
"status",
")",
";",
"$",
"self",
"->",
"children",
"[",
"$",
"pid",
"]",
"->",
"shutdown",
"(",
"$",
"status",
")",
";",
"$",
"self",
"->",
"clear",
"(",
"$",
"pid",
")",
";",
"}",
"}",
"$",
"self",
"->",
"emit",
"(",
"'tick'",
")",
";",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"self",
"->",
"queue",
")",
"||",
"!",
"msg_stat_queue",
"(",
"$",
"self",
"->",
"queue",
")",
")",
"{",
"return",
";",
"}",
"while",
"(",
"msg_receive",
"(",
"$",
"self",
"->",
"queue",
",",
"1",
",",
"$",
"null",
",",
"1024",
",",
"$",
"msg",
",",
"true",
",",
"MSG_IPC_NOWAIT",
",",
"$",
"error",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"msg",
")",
"||",
"empty",
"(",
"$",
"msg",
"[",
"'to'",
"]",
")",
"||",
"$",
"msg",
"[",
"'to'",
"]",
"!=",
"$",
"self",
"->",
"pid",
")",
"{",
"$",
"self",
"->",
"emit",
"(",
"'unknown_message'",
",",
"$",
"msg",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"self",
"->",
"master",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"self",
"->",
"children",
"[",
"$",
"msg",
"[",
"'from'",
"]",
"]",
")",
"&&",
"(",
"$",
"process",
"=",
"$",
"self",
"->",
"children",
"[",
"$",
"msg",
"[",
"'from'",
"]",
"]",
")",
")",
"{",
"$",
"process",
"->",
"emit",
"(",
"'message'",
",",
"$",
"msg",
"[",
"'body'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"self",
"->",
"emit",
"(",
"'unknown_message'",
",",
"$",
"msg",
")",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"msg",
"[",
"'from'",
"]",
"==",
"$",
"self",
"->",
"ppid",
")",
"{",
"// Come from parent process",
"$",
"self",
"->",
"process",
"->",
"emit",
"(",
"'message'",
",",
"$",
"msg",
"[",
"'body'",
"]",
")",
";",
"}",
"}",
"}",
"}",
")",
";",
"}"
]
| Register tick handlers | [
"Register",
"tick",
"handlers"
]
| 92481a85783cf2a24fef1760930f1252bb83fa5d | https://github.com/hfcorriez/php-childprocess/blob/92481a85783cf2a24fef1760930f1252bb83fa5d/lib/Pagon/ChildProcess.php#L638-L686 |
14,055 | FWidm/dwd-hourly-crawler | src/fwidm/dwdHourlyCrawler/DWDUtil.php | DWDUtil.getDataFromZip | static function getDataFromZip($zipFile, $extractionPrefix)
{
$zip = new ZipArchive;
self::log(self::class, "zip=" . $zipFile);
if ($zip->open($zipFile)) {
for ($i = 0; $i < $zip->numFiles; $i++) {
$stat = $zip->statIndex($i);
// print_r(basename($stat['name']) . '<br>');
//check if the file starts with the prefix
if (substr($stat['name'], 0, strlen($extractionPrefix)) === $extractionPrefix) {
//echo $zip->getFromName($stat['name']);
return $zip->getFromName($stat['name']);
}
}
$zip->close();
} else {
throw new DWDLibException("zip content is empty! zip file count=" . $zip->numFiles);
}
return null;
} | php | static function getDataFromZip($zipFile, $extractionPrefix)
{
$zip = new ZipArchive;
self::log(self::class, "zip=" . $zipFile);
if ($zip->open($zipFile)) {
for ($i = 0; $i < $zip->numFiles; $i++) {
$stat = $zip->statIndex($i);
// print_r(basename($stat['name']) . '<br>');
//check if the file starts with the prefix
if (substr($stat['name'], 0, strlen($extractionPrefix)) === $extractionPrefix) {
//echo $zip->getFromName($stat['name']);
return $zip->getFromName($stat['name']);
}
}
$zip->close();
} else {
throw new DWDLibException("zip content is empty! zip file count=" . $zip->numFiles);
}
return null;
} | [
"static",
"function",
"getDataFromZip",
"(",
"$",
"zipFile",
",",
"$",
"extractionPrefix",
")",
"{",
"$",
"zip",
"=",
"new",
"ZipArchive",
";",
"self",
"::",
"log",
"(",
"self",
"::",
"class",
",",
"\"zip=\"",
".",
"$",
"zipFile",
")",
";",
"if",
"(",
"$",
"zip",
"->",
"open",
"(",
"$",
"zipFile",
")",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"zip",
"->",
"numFiles",
";",
"$",
"i",
"++",
")",
"{",
"$",
"stat",
"=",
"$",
"zip",
"->",
"statIndex",
"(",
"$",
"i",
")",
";",
"// print_r(basename($stat['name']) . '<br>');",
"//check if the file starts with the prefix",
"if",
"(",
"substr",
"(",
"$",
"stat",
"[",
"'name'",
"]",
",",
"0",
",",
"strlen",
"(",
"$",
"extractionPrefix",
")",
")",
"===",
"$",
"extractionPrefix",
")",
"{",
"//echo $zip->getFromName($stat['name']);",
"return",
"$",
"zip",
"->",
"getFromName",
"(",
"$",
"stat",
"[",
"'name'",
"]",
")",
";",
"}",
"}",
"$",
"zip",
"->",
"close",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"DWDLibException",
"(",
"\"zip content is empty! zip file count=\"",
".",
"$",
"zip",
"->",
"numFiles",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| Extract the single file we need to use to get the data.
@param $zipFile - zip file we want to exctract from
@param $extractionPrefix - part of the file's prefix we want to match
@return null|string | [
"Extract",
"the",
"single",
"file",
"we",
"need",
"to",
"use",
"to",
"get",
"the",
"data",
"."
]
| 36dec7d84a85af599e9d4fb6a3bcc302378ce4a8 | https://github.com/FWidm/dwd-hourly-crawler/blob/36dec7d84a85af599e9d4fb6a3bcc302378ce4a8/src/fwidm/dwdHourlyCrawler/DWDUtil.php#L55-L76 |
14,056 | rokde/laravel-bootstrap-formbuilder | src/BootstrapFormBuilder.php | BootstrapFormBuilder.datetime | public function datetime($name, $value = null, $options = [])
{
$value = $this->getValueAttribute($name, $value);
$timeValue = $dateValue = null;
if($value instanceof \DateTime)
{
$dateValue= $value->format('Y-m-d');
$timeValue = $value->format('H:i');
}
return $this->date($name.'[date]', $dateValue, $options) . $this->time($name.'[time]', $timeValue, $options);
} | php | public function datetime($name, $value = null, $options = [])
{
$value = $this->getValueAttribute($name, $value);
$timeValue = $dateValue = null;
if($value instanceof \DateTime)
{
$dateValue= $value->format('Y-m-d');
$timeValue = $value->format('H:i');
}
return $this->date($name.'[date]', $dateValue, $options) . $this->time($name.'[time]', $timeValue, $options);
} | [
"public",
"function",
"datetime",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getValueAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"$",
"timeValue",
"=",
"$",
"dateValue",
"=",
"null",
";",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"DateTime",
")",
"{",
"$",
"dateValue",
"=",
"$",
"value",
"->",
"format",
"(",
"'Y-m-d'",
")",
";",
"$",
"timeValue",
"=",
"$",
"value",
"->",
"format",
"(",
"'H:i'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"date",
"(",
"$",
"name",
".",
"'[date]'",
",",
"$",
"dateValue",
",",
"$",
"options",
")",
".",
"$",
"this",
"->",
"time",
"(",
"$",
"name",
".",
"'[time]'",
",",
"$",
"timeValue",
",",
"$",
"options",
")",
";",
"}"
]
| Create a date and a time input field.
@param string $name
@param string $value
@param array $options
@return string | [
"Create",
"a",
"date",
"and",
"a",
"time",
"input",
"field",
"."
]
| f3ce43ad3d74b045176e24a03e9deffb71c17cd6 | https://github.com/rokde/laravel-bootstrap-formbuilder/blob/f3ce43ad3d74b045176e24a03e9deffb71c17cd6/src/BootstrapFormBuilder.php#L309-L321 |
14,057 | jordij/sweet-captcha | src/Jordij/SweetCaptcha/SweetCaptchaValidator.php | SweetCaptchaValidator.validateSweetcaptcha | public function validateSweetcaptcha($attribute, $value, $parameters)
{
if (Input::has('scvalue'))
{
$sweetcaptcha = app()->make('SweetCaptcha');
return $sweetcaptcha->check(array('sckey' => $value, 'scvalue' => Input::get('scvalue'))) == "true";
}
else
return false;
} | php | public function validateSweetcaptcha($attribute, $value, $parameters)
{
if (Input::has('scvalue'))
{
$sweetcaptcha = app()->make('SweetCaptcha');
return $sweetcaptcha->check(array('sckey' => $value, 'scvalue' => Input::get('scvalue'))) == "true";
}
else
return false;
} | [
"public",
"function",
"validateSweetcaptcha",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"parameters",
")",
"{",
"if",
"(",
"Input",
"::",
"has",
"(",
"'scvalue'",
")",
")",
"{",
"$",
"sweetcaptcha",
"=",
"app",
"(",
")",
"->",
"make",
"(",
"'SweetCaptcha'",
")",
";",
"return",
"$",
"sweetcaptcha",
"->",
"check",
"(",
"array",
"(",
"'sckey'",
"=>",
"$",
"value",
",",
"'scvalue'",
"=>",
"Input",
"::",
"get",
"(",
"'scvalue'",
")",
")",
")",
"==",
"\"true\"",
";",
"}",
"else",
"return",
"false",
";",
"}"
]
| Validation method for the Sweet Captcha input values.
@param [type] $attribute [description]
@param [type] $value [description]
@param [type] $parameters [description]
@return boolean | [
"Validation",
"method",
"for",
"the",
"Sweet",
"Captcha",
"input",
"values",
"."
]
| 7c98724bcf84a8727c99dc577e893225ee8c0eed | https://github.com/jordij/sweet-captcha/blob/7c98724bcf84a8727c99dc577e893225ee8c0eed/src/Jordij/SweetCaptcha/SweetCaptchaValidator.php#L25-L35 |
14,058 | yidas/php-google-api-client-helper | src/Client.php | Client.setClient | public static function setClient($input=null)
{
// New or encapsulate
self::$client = ($input instanceof Google_client) ? $input : new Google_Client();
// While new and there has the config
if (is_array($input)) {
foreach ($input as $key => $value) {
// ex. 'authConfig' => setAuthConfig()
$method = "set" . ucfirst($key);
// Config method check
if (!method_exists(self::$client, $method)) {
throw new Exception("setClient() Config Key: `{$key}` is invalid referred to Google_Client->{$method}()", 500);
}
// Call set method by Google_Client
call_user_func([self::$client, $method], $value);
}
}
return new self;
} | php | public static function setClient($input=null)
{
// New or encapsulate
self::$client = ($input instanceof Google_client) ? $input : new Google_Client();
// While new and there has the config
if (is_array($input)) {
foreach ($input as $key => $value) {
// ex. 'authConfig' => setAuthConfig()
$method = "set" . ucfirst($key);
// Config method check
if (!method_exists(self::$client, $method)) {
throw new Exception("setClient() Config Key: `{$key}` is invalid referred to Google_Client->{$method}()", 500);
}
// Call set method by Google_Client
call_user_func([self::$client, $method], $value);
}
}
return new self;
} | [
"public",
"static",
"function",
"setClient",
"(",
"$",
"input",
"=",
"null",
")",
"{",
"// New or encapsulate\r",
"self",
"::",
"$",
"client",
"=",
"(",
"$",
"input",
"instanceof",
"Google_client",
")",
"?",
"$",
"input",
":",
"new",
"Google_Client",
"(",
")",
";",
"// While new and there has the config\r",
"if",
"(",
"is_array",
"(",
"$",
"input",
")",
")",
"{",
"foreach",
"(",
"$",
"input",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// ex. 'authConfig' => setAuthConfig()\r",
"$",
"method",
"=",
"\"set\"",
".",
"ucfirst",
"(",
"$",
"key",
")",
";",
"// Config method check\r",
"if",
"(",
"!",
"method_exists",
"(",
"self",
"::",
"$",
"client",
",",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"setClient() Config Key: `{$key}` is invalid referred to Google_Client->{$method}()\"",
",",
"500",
")",
";",
"}",
"// Call set method by Google_Client\r",
"call_user_func",
"(",
"[",
"self",
"::",
"$",
"client",
",",
"$",
"method",
"]",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"new",
"self",
";",
"}"
]
| New a Google_Client with config or set Google_Client by giving
@param array|Google_Client Config array or Google_Client
@return self | [
"New",
"a",
"Google_Client",
"with",
"config",
"or",
"set",
"Google_Client",
"by",
"giving"
]
| e0edfebc41fb4e55bcf4125af58304894a2863fe | https://github.com/yidas/php-google-api-client-helper/blob/e0edfebc41fb4e55bcf4125af58304894a2863fe/src/Client.php#L31-L52 |
14,059 | yidas/php-google-api-client-helper | src/Client.php | Client.verifyAccessToken | public static function verifyAccessToken($accessToken=null)
{
// Check access_token
if (null === $accessToken) {
$token = self::getClient()->getAccessToken();
if (!isset($token['access_token'])) {
throw new Exception(
'access_token must be passed in or set as part of setAccessToken'
);
}
$accessToken = $token['access_token'];
}
// Google API request
$response = (new \GuzzleHttp\Client())
->request('GET', self::TOKENINFO_URI, [
'query' => [
'access_token' => $accessToken,
],
'http_errors' => false,
]);
// var_dump($response);exit;
// Result check
if (200 != $response->getStatusCode()) {
return false;
}
return json_decode($response->getBody(), true);
} | php | public static function verifyAccessToken($accessToken=null)
{
// Check access_token
if (null === $accessToken) {
$token = self::getClient()->getAccessToken();
if (!isset($token['access_token'])) {
throw new Exception(
'access_token must be passed in or set as part of setAccessToken'
);
}
$accessToken = $token['access_token'];
}
// Google API request
$response = (new \GuzzleHttp\Client())
->request('GET', self::TOKENINFO_URI, [
'query' => [
'access_token' => $accessToken,
],
'http_errors' => false,
]);
// var_dump($response);exit;
// Result check
if (200 != $response->getStatusCode()) {
return false;
}
return json_decode($response->getBody(), true);
} | [
"public",
"static",
"function",
"verifyAccessToken",
"(",
"$",
"accessToken",
"=",
"null",
")",
"{",
"// Check access_token\r",
"if",
"(",
"null",
"===",
"$",
"accessToken",
")",
"{",
"$",
"token",
"=",
"self",
"::",
"getClient",
"(",
")",
"->",
"getAccessToken",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"token",
"[",
"'access_token'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'access_token must be passed in or set as part of setAccessToken'",
")",
";",
"}",
"$",
"accessToken",
"=",
"$",
"token",
"[",
"'access_token'",
"]",
";",
"}",
"// Google API request\r",
"$",
"response",
"=",
"(",
"new",
"\\",
"GuzzleHttp",
"\\",
"Client",
"(",
")",
")",
"->",
"request",
"(",
"'GET'",
",",
"self",
"::",
"TOKENINFO_URI",
",",
"[",
"'query'",
"=>",
"[",
"'access_token'",
"=>",
"$",
"accessToken",
",",
"]",
",",
"'http_errors'",
"=>",
"false",
",",
"]",
")",
";",
"// var_dump($response);exit;\r",
"// Result check\r",
"if",
"(",
"200",
"!=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"}"
]
| Verify an access_token. This method will verify the current access_token by Google API,
if one isn't provided.
The Google verification only allow the access_token within the expired time limit, be sure to
refresh the newest access_token for verifying.
@param string|null $accessToken The token (access_token) that should be verified.
@return array|false Returns the token payload as an array if the verification was
successful, false otherwise. | [
"Verify",
"an",
"access_token",
".",
"This",
"method",
"will",
"verify",
"the",
"current",
"access_token",
"by",
"Google",
"API",
"if",
"one",
"isn",
"t",
"provided",
"."
]
| e0edfebc41fb4e55bcf4125af58304894a2863fe | https://github.com/yidas/php-google-api-client-helper/blob/e0edfebc41fb4e55bcf4125af58304894a2863fe/src/Client.php#L110-L139 |
14,060 | yidas/php-google-api-client-helper | src/Client.php | Client.verifyScopes | public static function verifyScopes($scopes, $accessToken=null)
{
// Check access_token
if (!$tokenInfo = self::verifyAccessToken($accessToken)) return false;
$scopeString = $tokenInfo['scope'];
// Check scope for each
foreach ($scopes as $key => $scope) {
if (stripos($scopeString, $scope) === false) return false;
}
return true;
} | php | public static function verifyScopes($scopes, $accessToken=null)
{
// Check access_token
if (!$tokenInfo = self::verifyAccessToken($accessToken)) return false;
$scopeString = $tokenInfo['scope'];
// Check scope for each
foreach ($scopes as $key => $scope) {
if (stripos($scopeString, $scope) === false) return false;
}
return true;
} | [
"public",
"static",
"function",
"verifyScopes",
"(",
"$",
"scopes",
",",
"$",
"accessToken",
"=",
"null",
")",
"{",
"// Check access_token\r",
"if",
"(",
"!",
"$",
"tokenInfo",
"=",
"self",
"::",
"verifyAccessToken",
"(",
"$",
"accessToken",
")",
")",
"return",
"false",
";",
"$",
"scopeString",
"=",
"$",
"tokenInfo",
"[",
"'scope'",
"]",
";",
"// Check scope for each\r",
"foreach",
"(",
"$",
"scopes",
"as",
"$",
"key",
"=>",
"$",
"scope",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"scopeString",
",",
"$",
"scope",
")",
"===",
"false",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Verify scopes of tokenInfo by access_token. This method will verify the current access_token
by Google API, if one isn't provided.
@param array $scopes Google client scope list, ex: ['https://www.googleapis.com/auth/userinfo.profile']
@param string|null $accessToken The token (access_token) that should be verified.
@return array|false Returns the token payload as an array if the verification was
successful, false otherwise.
@example
$result = \yidas\google\apiHelper\Client::verifyScopes([
'https://www.googleapis.com/auth/userinfo.profile',
]); | [
"Verify",
"scopes",
"of",
"tokenInfo",
"by",
"access_token",
".",
"This",
"method",
"will",
"verify",
"the",
"current",
"access_token",
"by",
"Google",
"API",
"if",
"one",
"isn",
"t",
"provided",
"."
]
| e0edfebc41fb4e55bcf4125af58304894a2863fe | https://github.com/yidas/php-google-api-client-helper/blob/e0edfebc41fb4e55bcf4125af58304894a2863fe/src/Client.php#L154-L168 |
14,061 | cpliakas/search-framework | src/Search/Framework/SchemaField.php | SchemaField.setId | public function setId(Schema $schema, $id)
{
$reset_unique_field = ($schema->getUniqueFieldId() === $this->_id);
// Reset the identifier, update the hash tables by re-adding the field.
$schema->removeField($this->_id);
$this->_id = $id;
$schema->attachField($this);
// Update the schema's unique field.
if ($reset_unique_field) {
$schema->setUniqueField($id);
}
return $this;
} | php | public function setId(Schema $schema, $id)
{
$reset_unique_field = ($schema->getUniqueFieldId() === $this->_id);
// Reset the identifier, update the hash tables by re-adding the field.
$schema->removeField($this->_id);
$this->_id = $id;
$schema->attachField($this);
// Update the schema's unique field.
if ($reset_unique_field) {
$schema->setUniqueField($id);
}
return $this;
} | [
"public",
"function",
"setId",
"(",
"Schema",
"$",
"schema",
",",
"$",
"id",
")",
"{",
"$",
"reset_unique_field",
"=",
"(",
"$",
"schema",
"->",
"getUniqueFieldId",
"(",
")",
"===",
"$",
"this",
"->",
"_id",
")",
";",
"// Reset the identifier, update the hash tables by re-adding the field.",
"$",
"schema",
"->",
"removeField",
"(",
"$",
"this",
"->",
"_id",
")",
";",
"$",
"this",
"->",
"_id",
"=",
"$",
"id",
";",
"$",
"schema",
"->",
"attachField",
"(",
"$",
"this",
")",
";",
"// Update the schema's unique field.",
"if",
"(",
"$",
"reset_unique_field",
")",
"{",
"$",
"schema",
"->",
"setUniqueField",
"(",
"$",
"id",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Resets the unique identifier of the field.
The schema is required so that its internal hash table can be updated to
reflect the field's new identifier.
@param Schema $schema
The schema that this field is attached to.
@param string $id
The unique identifier of the field.
@return SchemaField | [
"Resets",
"the",
"unique",
"identifier",
"of",
"the",
"field",
"."
]
| 7c5832d38ed998e04837c26e0daef59115563b98 | https://github.com/cpliakas/search-framework/blob/7c5832d38ed998e04837c26e0daef59115563b98/src/Search/Framework/SchemaField.php#L174-L189 |
14,062 | cpliakas/search-framework | src/Search/Framework/SchemaField.php | SchemaField.setName | public function setName(Schema $schema, $name)
{
$schema->removeField($this->_id);
$this->_name = $name;
$schema->attachField($this);
return $this;
} | php | public function setName(Schema $schema, $name)
{
$schema->removeField($this->_id);
$this->_name = $name;
$schema->attachField($this);
return $this;
} | [
"public",
"function",
"setName",
"(",
"Schema",
"$",
"schema",
",",
"$",
"name",
")",
"{",
"$",
"schema",
"->",
"removeField",
"(",
"$",
"this",
"->",
"_id",
")",
";",
"$",
"this",
"->",
"_name",
"=",
"$",
"name",
";",
"$",
"schema",
"->",
"attachField",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets the name of the field as stored in the index.
The schema is required so that its internal hash table can be updated to
reflect the field's new identifier.
@param Schema $schema
The schema that this field is attached to.
@param string $name
The name of the field as stored in the index.
@return SchemaField | [
"Sets",
"the",
"name",
"of",
"the",
"field",
"as",
"stored",
"in",
"the",
"index",
"."
]
| 7c5832d38ed998e04837c26e0daef59115563b98 | https://github.com/cpliakas/search-framework/blob/7c5832d38ed998e04837c26e0daef59115563b98/src/Search/Framework/SchemaField.php#L214-L220 |
14,063 | cpliakas/search-framework | src/Search/Framework/SchemaField.php | SchemaField.toArray | public function toArray()
{
$schema = array(
'name' => $this->_name,
'label' => $this->_label,
'description' => $this->_description,
'type' => $this->_type,
'store' => $this->_isStored,
'index' => $this->_isIndexd,
'multivalue' => $this->_isMultiValued,
);
if (isset($this->_size)) {
$schema['size'] = $this->_size;
}
return $schema;
} | php | public function toArray()
{
$schema = array(
'name' => $this->_name,
'label' => $this->_label,
'description' => $this->_description,
'type' => $this->_type,
'store' => $this->_isStored,
'index' => $this->_isIndexd,
'multivalue' => $this->_isMultiValued,
);
if (isset($this->_size)) {
$schema['size'] = $this->_size;
}
return $schema;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"schema",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"_name",
",",
"'label'",
"=>",
"$",
"this",
"->",
"_label",
",",
"'description'",
"=>",
"$",
"this",
"->",
"_description",
",",
"'type'",
"=>",
"$",
"this",
"->",
"_type",
",",
"'store'",
"=>",
"$",
"this",
"->",
"_isStored",
",",
"'index'",
"=>",
"$",
"this",
"->",
"_isIndexd",
",",
"'multivalue'",
"=>",
"$",
"this",
"->",
"_isMultiValued",
",",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_size",
")",
")",
"{",
"$",
"schema",
"[",
"'size'",
"]",
"=",
"$",
"this",
"->",
"_size",
";",
"}",
"return",
"$",
"schema",
";",
"}"
]
| Returns the array of field options.
@return array | [
"Returns",
"the",
"array",
"of",
"field",
"options",
"."
]
| 7c5832d38ed998e04837c26e0daef59115563b98 | https://github.com/cpliakas/search-framework/blob/7c5832d38ed998e04837c26e0daef59115563b98/src/Search/Framework/SchemaField.php#L420-L437 |
14,064 | vi-kon/laravel-parser | src/ViKon/Parser/Parser.php | Parser.addRule | public function addRule(AbstractRule $rule) {
if (array_key_exists($rule->getName(), $this->rules)) {
throw new ParserException('Rule with ' . $rule->getName() . ' name already exists');
}
$this->rules[$rule->getName()] = $rule;
return $this;
} | php | public function addRule(AbstractRule $rule) {
if (array_key_exists($rule->getName(), $this->rules)) {
throw new ParserException('Rule with ' . $rule->getName() . ' name already exists');
}
$this->rules[$rule->getName()] = $rule;
return $this;
} | [
"public",
"function",
"addRule",
"(",
"AbstractRule",
"$",
"rule",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"rule",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"rules",
")",
")",
"{",
"throw",
"new",
"ParserException",
"(",
"'Rule with '",
".",
"$",
"rule",
"->",
"getName",
"(",
")",
".",
"' name already exists'",
")",
";",
"}",
"$",
"this",
"->",
"rules",
"[",
"$",
"rule",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"rule",
";",
"return",
"$",
"this",
";",
"}"
]
| Add rule to parser
@param \ViKon\Parser\Rule\AbstractRule $rule rule instance
@throws \ViKon\Parser\ParserException throws if rule already exists with same name
@return $this | [
"Add",
"rule",
"to",
"parser"
]
| 070f0bb9120cb9ca6ff836d4f418e78ee33ee182 | https://github.com/vi-kon/laravel-parser/blob/070f0bb9120cb9ca6ff836d4f418e78ee33ee182/src/ViKon/Parser/Parser.php#L73-L81 |
14,065 | vi-kon/laravel-parser | src/ViKon/Parser/Parser.php | Parser.parse | public function parse($text, TokenList $tokenList = null, $recursive = false) {
if ($this->startRule === null) {
throw new ParserException('Start rule not set');
}
if ($this->lexer === null) {
throw new ParserException('Lexer not set');
}
uasort($this->rules, [$this, 'sortRulesByOrder']);
$this->connectRulesToLexer();
\Event::fire('vikon.parser.before.parse', [&$text]);
$tokenList = $this->lexer->tokenize($text, $this->startRule->getName(), $tokenList);
foreach ($this->rules as $rule) {
$rule->finalize($tokenList, $recursive);
}
return $tokenList;
} | php | public function parse($text, TokenList $tokenList = null, $recursive = false) {
if ($this->startRule === null) {
throw new ParserException('Start rule not set');
}
if ($this->lexer === null) {
throw new ParserException('Lexer not set');
}
uasort($this->rules, [$this, 'sortRulesByOrder']);
$this->connectRulesToLexer();
\Event::fire('vikon.parser.before.parse', [&$text]);
$tokenList = $this->lexer->tokenize($text, $this->startRule->getName(), $tokenList);
foreach ($this->rules as $rule) {
$rule->finalize($tokenList, $recursive);
}
return $tokenList;
} | [
"public",
"function",
"parse",
"(",
"$",
"text",
",",
"TokenList",
"$",
"tokenList",
"=",
"null",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"startRule",
"===",
"null",
")",
"{",
"throw",
"new",
"ParserException",
"(",
"'Start rule not set'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"lexer",
"===",
"null",
")",
"{",
"throw",
"new",
"ParserException",
"(",
"'Lexer not set'",
")",
";",
"}",
"uasort",
"(",
"$",
"this",
"->",
"rules",
",",
"[",
"$",
"this",
",",
"'sortRulesByOrder'",
"]",
")",
";",
"$",
"this",
"->",
"connectRulesToLexer",
"(",
")",
";",
"\\",
"Event",
"::",
"fire",
"(",
"'vikon.parser.before.parse'",
",",
"[",
"&",
"$",
"text",
"]",
")",
";",
"$",
"tokenList",
"=",
"$",
"this",
"->",
"lexer",
"->",
"tokenize",
"(",
"$",
"text",
",",
"$",
"this",
"->",
"startRule",
"->",
"getName",
"(",
")",
",",
"$",
"tokenList",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"rule",
")",
"{",
"$",
"rule",
"->",
"finalize",
"(",
"$",
"tokenList",
",",
"$",
"recursive",
")",
";",
"}",
"return",
"$",
"tokenList",
";",
"}"
]
| Parse text by provided rules
@param string $text raw data
@param TokenList|null $tokenList already initialized token list
@param bool $recursive indicates if parse called inside rule during tokenization
@return \ViKon\Parser\TokenList
@throws \ViKon\Parser\LexerException
@throws \ViKon\Parser\ParserException | [
"Parse",
"text",
"by",
"provided",
"rules"
]
| 070f0bb9120cb9ca6ff836d4f418e78ee33ee182 | https://github.com/vi-kon/laravel-parser/blob/070f0bb9120cb9ca6ff836d4f418e78ee33ee182/src/ViKon/Parser/Parser.php#L95-L117 |
14,066 | vi-kon/laravel-parser | src/ViKon/Parser/Parser.php | Parser.render | public function render($text, $skin) {
if ($this->renderer === null) {
throw new ParserException('Renderer not set');
}
$tokenList = $this->parse($text);
return $this->renderer->render($tokenList, $skin);
} | php | public function render($text, $skin) {
if ($this->renderer === null) {
throw new ParserException('Renderer not set');
}
$tokenList = $this->parse($text);
return $this->renderer->render($tokenList, $skin);
} | [
"public",
"function",
"render",
"(",
"$",
"text",
",",
"$",
"skin",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"renderer",
"===",
"null",
")",
"{",
"throw",
"new",
"ParserException",
"(",
"'Renderer not set'",
")",
";",
"}",
"$",
"tokenList",
"=",
"$",
"this",
"->",
"parse",
"(",
"$",
"text",
")",
";",
"return",
"$",
"this",
"->",
"renderer",
"->",
"render",
"(",
"$",
"tokenList",
",",
"$",
"skin",
")",
";",
"}"
]
| Parse text by provided rules and try to render token list
@param string $text raw data
@param string $skin used skin
@throws \ViKon\Parser\ParserException
@return string | [
"Parse",
"text",
"by",
"provided",
"rules",
"and",
"try",
"to",
"render",
"token",
"list"
]
| 070f0bb9120cb9ca6ff836d4f418e78ee33ee182 | https://github.com/vi-kon/laravel-parser/blob/070f0bb9120cb9ca6ff836d4f418e78ee33ee182/src/ViKon/Parser/Parser.php#L129-L137 |
14,067 | vi-kon/laravel-parser | src/ViKon/Parser/Parser.php | Parser.connectRulesToLexer | protected function connectRulesToLexer() {
foreach ($this->rules as $childRule) {
$childRule->prepare($this->lexer);
if ($childRule->getName() === $this->startRule->getName()) {
continue;
}
if ($this->startRule->acceptRule($childRule->getName())) {
$childRule->embedInto($this->startRule->getName(), $this->lexer);
}
$childRule->finish($this->lexer);
}
} | php | protected function connectRulesToLexer() {
foreach ($this->rules as $childRule) {
$childRule->prepare($this->lexer);
if ($childRule->getName() === $this->startRule->getName()) {
continue;
}
if ($this->startRule->acceptRule($childRule->getName())) {
$childRule->embedInto($this->startRule->getName(), $this->lexer);
}
$childRule->finish($this->lexer);
}
} | [
"protected",
"function",
"connectRulesToLexer",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"childRule",
")",
"{",
"$",
"childRule",
"->",
"prepare",
"(",
"$",
"this",
"->",
"lexer",
")",
";",
"if",
"(",
"$",
"childRule",
"->",
"getName",
"(",
")",
"===",
"$",
"this",
"->",
"startRule",
"->",
"getName",
"(",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"startRule",
"->",
"acceptRule",
"(",
"$",
"childRule",
"->",
"getName",
"(",
")",
")",
")",
"{",
"$",
"childRule",
"->",
"embedInto",
"(",
"$",
"this",
"->",
"startRule",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"lexer",
")",
";",
"}",
"$",
"childRule",
"->",
"finish",
"(",
"$",
"this",
"->",
"lexer",
")",
";",
"}",
"}"
]
| Add rule patterns to lexer | [
"Add",
"rule",
"patterns",
"to",
"lexer"
]
| 070f0bb9120cb9ca6ff836d4f418e78ee33ee182 | https://github.com/vi-kon/laravel-parser/blob/070f0bb9120cb9ca6ff836d4f418e78ee33ee182/src/ViKon/Parser/Parser.php#L162-L176 |
14,068 | vi-kon/laravel-parser | src/ViKon/Parser/Parser.php | Parser.sortRulesByOrder | protected function sortRulesByOrder(AbstractRule $a, AbstractRule $b) {
if ($a->getOrder() === $b->getOrder()) {
return 0;
}
return $a->getOrder() < $b->getOrder()
? -1
: 1;
} | php | protected function sortRulesByOrder(AbstractRule $a, AbstractRule $b) {
if ($a->getOrder() === $b->getOrder()) {
return 0;
}
return $a->getOrder() < $b->getOrder()
? -1
: 1;
} | [
"protected",
"function",
"sortRulesByOrder",
"(",
"AbstractRule",
"$",
"a",
",",
"AbstractRule",
"$",
"b",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"getOrder",
"(",
")",
"===",
"$",
"b",
"->",
"getOrder",
"(",
")",
")",
"{",
"return",
"0",
";",
"}",
"return",
"$",
"a",
"->",
"getOrder",
"(",
")",
"<",
"$",
"b",
"->",
"getOrder",
"(",
")",
"?",
"-",
"1",
":",
"1",
";",
"}"
]
| Sort rules by order ASC
@param \ViKon\Parser\Rule\AbstractRule $a
@param \ViKon\Parser\Rule\AbstractRule $b
@return int | [
"Sort",
"rules",
"by",
"order",
"ASC"
]
| 070f0bb9120cb9ca6ff836d4f418e78ee33ee182 | https://github.com/vi-kon/laravel-parser/blob/070f0bb9120cb9ca6ff836d4f418e78ee33ee182/src/ViKon/Parser/Parser.php#L186-L194 |
14,069 | ssnepenthe/soter | src/class-email-notifier.php | Email_Notifier.render_html_email | public function render_html_email(
Vulnerabilities $vulnerabilities,
CssToInlineStyles $inliner = null
) {
$html = $this->template->render( 'emails/html/vulnerable.php', [
'action_url' => admin_url( 'update-core.php' ),
'vulnerabilities' => $vulnerabilities,
] );
$css = $this->template->render( 'emails/style.css' );
$inliner = $inliner ?: new CssToInlineStyles();
return $inliner->convert( $html, $css );
} | php | public function render_html_email(
Vulnerabilities $vulnerabilities,
CssToInlineStyles $inliner = null
) {
$html = $this->template->render( 'emails/html/vulnerable.php', [
'action_url' => admin_url( 'update-core.php' ),
'vulnerabilities' => $vulnerabilities,
] );
$css = $this->template->render( 'emails/style.css' );
$inliner = $inliner ?: new CssToInlineStyles();
return $inliner->convert( $html, $css );
} | [
"public",
"function",
"render_html_email",
"(",
"Vulnerabilities",
"$",
"vulnerabilities",
",",
"CssToInlineStyles",
"$",
"inliner",
"=",
"null",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"template",
"->",
"render",
"(",
"'emails/html/vulnerable.php'",
",",
"[",
"'action_url'",
"=>",
"admin_url",
"(",
"'update-core.php'",
")",
",",
"'vulnerabilities'",
"=>",
"$",
"vulnerabilities",
",",
"]",
")",
";",
"$",
"css",
"=",
"$",
"this",
"->",
"template",
"->",
"render",
"(",
"'emails/style.css'",
")",
";",
"$",
"inliner",
"=",
"$",
"inliner",
"?",
":",
"new",
"CssToInlineStyles",
"(",
")",
";",
"return",
"$",
"inliner",
"->",
"convert",
"(",
"$",
"html",
",",
"$",
"css",
")",
";",
"}"
]
| Render the contents of the HTML email notification.
@param Vulnerabilities $vulnerabilities Vulnerabilities list.
@param CssToInlineStyles|null $inliner Style inliner.
@return string | [
"Render",
"the",
"contents",
"of",
"the",
"HTML",
"email",
"notification",
"."
]
| f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7 | https://github.com/ssnepenthe/soter/blob/f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7/src/class-email-notifier.php#L84-L96 |
14,070 | terdia/legato-framework | src/TwigGlobal.php | TwigGlobal.getUserDefinedGlobals | protected function getUserDefinedGlobals()
{
if (file_exists(realpath(__DIR__.'/../../../../config/twig.php'))) {
$this->config = require realpath(__DIR__.'/../../../../config/twig.php');
} elseif (file_exists(realpath(__DIR__.'/../config/twig.php'))) {
$this->config = require realpath(__DIR__.'/../config/twig.php');
}
return isset($this->config['twig_global']) ? $this->config['twig_global'] : [];
} | php | protected function getUserDefinedGlobals()
{
if (file_exists(realpath(__DIR__.'/../../../../config/twig.php'))) {
$this->config = require realpath(__DIR__.'/../../../../config/twig.php');
} elseif (file_exists(realpath(__DIR__.'/../config/twig.php'))) {
$this->config = require realpath(__DIR__.'/../config/twig.php');
}
return isset($this->config['twig_global']) ? $this->config['twig_global'] : [];
} | [
"protected",
"function",
"getUserDefinedGlobals",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"realpath",
"(",
"__DIR__",
".",
"'/../../../../config/twig.php'",
")",
")",
")",
"{",
"$",
"this",
"->",
"config",
"=",
"require",
"realpath",
"(",
"__DIR__",
".",
"'/../../../../config/twig.php'",
")",
";",
"}",
"elseif",
"(",
"file_exists",
"(",
"realpath",
"(",
"__DIR__",
".",
"'/../config/twig.php'",
")",
")",
")",
"{",
"$",
"this",
"->",
"config",
"=",
"require",
"realpath",
"(",
"__DIR__",
".",
"'/../config/twig.php'",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'twig_global'",
"]",
")",
"?",
"$",
"this",
"->",
"config",
"[",
"'twig_global'",
"]",
":",
"[",
"]",
";",
"}"
]
| Get the user defined global for twig templates.
@return mixed | [
"Get",
"the",
"user",
"defined",
"global",
"for",
"twig",
"templates",
"."
]
| 44057c1c3c6f3e9643e9fade51bd417860fafda8 | https://github.com/terdia/legato-framework/blob/44057c1c3c6f3e9643e9fade51bd417860fafda8/src/TwigGlobal.php#L47-L56 |
14,071 | ssnepenthe/soter | src/class-notifier-manager.php | Notifier_Manager.notify | public function notify( Vulnerabilities $vulnerabilities ) {
if ( ! $this->should_notify( $vulnerabilities ) ) {
return;
}
foreach ( $this->notifiers as $notifier ) {
if ( $notifier->is_enabled() ) {
$notifier->notify( $vulnerabilities );
}
}
} | php | public function notify( Vulnerabilities $vulnerabilities ) {
if ( ! $this->should_notify( $vulnerabilities ) ) {
return;
}
foreach ( $this->notifiers as $notifier ) {
if ( $notifier->is_enabled() ) {
$notifier->notify( $vulnerabilities );
}
}
} | [
"public",
"function",
"notify",
"(",
"Vulnerabilities",
"$",
"vulnerabilities",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"should_notify",
"(",
"$",
"vulnerabilities",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"notifiers",
"as",
"$",
"notifier",
")",
"{",
"if",
"(",
"$",
"notifier",
"->",
"is_enabled",
"(",
")",
")",
"{",
"$",
"notifier",
"->",
"notify",
"(",
"$",
"vulnerabilities",
")",
";",
"}",
"}",
"}"
]
| Invoke the notify method on all active notifiers.
@param Vulnerabilities $vulnerabilities List of vulnerabilities.
@return void | [
"Invoke",
"the",
"notify",
"method",
"on",
"all",
"active",
"notifiers",
"."
]
| f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7 | https://github.com/ssnepenthe/soter/blob/f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7/src/class-notifier-manager.php#L62-L72 |
14,072 | ssnepenthe/soter | src/class-notifier-manager.php | Notifier_Manager.should_notify | protected function should_notify( Vulnerabilities $vulnerabilities ) {
if ( $vulnerabilities->is_empty() ) {
return false;
}
if ( $this->options->should_nag ) {
return true;
}
return $vulnerabilities->hash() !== $this->options->last_scan_hash;
} | php | protected function should_notify( Vulnerabilities $vulnerabilities ) {
if ( $vulnerabilities->is_empty() ) {
return false;
}
if ( $this->options->should_nag ) {
return true;
}
return $vulnerabilities->hash() !== $this->options->last_scan_hash;
} | [
"protected",
"function",
"should_notify",
"(",
"Vulnerabilities",
"$",
"vulnerabilities",
")",
"{",
"if",
"(",
"$",
"vulnerabilities",
"->",
"is_empty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"options",
"->",
"should_nag",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"vulnerabilities",
"->",
"hash",
"(",
")",
"!==",
"$",
"this",
"->",
"options",
"->",
"last_scan_hash",
";",
"}"
]
| Determine whether a notifications should be sent.
@param Vulnerabilities $vulnerabilities List of vulnerabilities.
@return boolean | [
"Determine",
"whether",
"a",
"notifications",
"should",
"be",
"sent",
"."
]
| f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7 | https://github.com/ssnepenthe/soter/blob/f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7/src/class-notifier-manager.php#L81-L91 |
14,073 | msschl/monolog-http-handler | src/HttpHandler.php | HttpHandler.hasHeader | public function hasHeader(string $key = null) : bool
{
if ($key === null) {
return false;
}
$array = $this->getHeaders();
return isset($array[$key]) || array_key_exists($key, $array);
} | php | public function hasHeader(string $key = null) : bool
{
if ($key === null) {
return false;
}
$array = $this->getHeaders();
return isset($array[$key]) || array_key_exists($key, $array);
} | [
"public",
"function",
"hasHeader",
"(",
"string",
"$",
"key",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"$",
"array",
"=",
"$",
"this",
"->",
"getHeaders",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
"||",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"array",
")",
";",
"}"
]
| Returns whether a header exists or not.
@param string|null $key The header key.
@return bool | [
"Returns",
"whether",
"a",
"header",
"exists",
"or",
"not",
"."
]
| 3f11ea3c2c2691c2e113a9fa681236e74390c541 | https://github.com/msschl/monolog-http-handler/blob/3f11ea3c2c2691c2e113a9fa681236e74390c541/src/HttpHandler.php#L180-L188 |
14,074 | msschl/monolog-http-handler | src/HttpHandler.php | HttpHandler.pushHeader | public function pushHeader(string $key, string $value = null)
{
$headers = $this->getHeaders();
$headers[$key] = $value;
$this->setHeaders($headers);
return $this;
} | php | public function pushHeader(string $key, string $value = null)
{
$headers = $this->getHeaders();
$headers[$key] = $value;
$this->setHeaders($headers);
return $this;
} | [
"public",
"function",
"pushHeader",
"(",
"string",
"$",
"key",
",",
"string",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"getHeaders",
"(",
")",
";",
"$",
"headers",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"setHeaders",
"(",
"$",
"headers",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Pushes a header value onto the headers array.
@param string $key The header key.
@param string|null $value The header value.
@return self | [
"Pushes",
"a",
"header",
"value",
"onto",
"the",
"headers",
"array",
"."
]
| 3f11ea3c2c2691c2e113a9fa681236e74390c541 | https://github.com/msschl/monolog-http-handler/blob/3f11ea3c2c2691c2e113a9fa681236e74390c541/src/HttpHandler.php#L197-L206 |
14,075 | msschl/monolog-http-handler | src/HttpHandler.php | HttpHandler.popHeader | public function popHeader(string $key = null)
{
$value = $this->getHeader($key);
if ($value !== null) {
unset($this->options['headers'][$key]);
}
return $value;
} | php | public function popHeader(string $key = null)
{
$value = $this->getHeader($key);
if ($value !== null) {
unset($this->options['headers'][$key]);
}
return $value;
} | [
"public",
"function",
"popHeader",
"(",
"string",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getHeader",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"options",
"[",
"'headers'",
"]",
"[",
"$",
"key",
"]",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
]
| Pops a header value from the headers array.
@param string|null $key The header key.
@return string|null | [
"Pops",
"a",
"header",
"value",
"from",
"the",
"headers",
"array",
"."
]
| 3f11ea3c2c2691c2e113a9fa681236e74390c541 | https://github.com/msschl/monolog-http-handler/blob/3f11ea3c2c2691c2e113a9fa681236e74390c541/src/HttpHandler.php#L214-L223 |
14,076 | msschl/monolog-http-handler | src/HttpHandler.php | HttpHandler.handleBatch | public function handleBatch(array $records)
{
foreach ($records as $key => $record) {
if ($this->isHandling($record)) {
$record = $this->processRecord($record);
$records['records'][] = $record;
}
unset($records[$key]);
}
$records['formatted'] = $this->getFormatter()->formatBatch($records['records'] ?? []);
$this->write($records);
return false === $this->bubble;
} | php | public function handleBatch(array $records)
{
foreach ($records as $key => $record) {
if ($this->isHandling($record)) {
$record = $this->processRecord($record);
$records['records'][] = $record;
}
unset($records[$key]);
}
$records['formatted'] = $this->getFormatter()->formatBatch($records['records'] ?? []);
$this->write($records);
return false === $this->bubble;
} | [
"public",
"function",
"handleBatch",
"(",
"array",
"$",
"records",
")",
"{",
"foreach",
"(",
"$",
"records",
"as",
"$",
"key",
"=>",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isHandling",
"(",
"$",
"record",
")",
")",
"{",
"$",
"record",
"=",
"$",
"this",
"->",
"processRecord",
"(",
"$",
"record",
")",
";",
"$",
"records",
"[",
"'records'",
"]",
"[",
"]",
"=",
"$",
"record",
";",
"}",
"unset",
"(",
"$",
"records",
"[",
"$",
"key",
"]",
")",
";",
"}",
"$",
"records",
"[",
"'formatted'",
"]",
"=",
"$",
"this",
"->",
"getFormatter",
"(",
")",
"->",
"formatBatch",
"(",
"$",
"records",
"[",
"'records'",
"]",
"??",
"[",
"]",
")",
";",
"$",
"this",
"->",
"write",
"(",
"$",
"records",
")",
";",
"return",
"false",
"===",
"$",
"this",
"->",
"bubble",
";",
"}"
]
| Handles a set of records at once.
@param array $records The records to handle (an array of record arrays)
@return bool | [
"Handles",
"a",
"set",
"of",
"records",
"at",
"once",
"."
]
| 3f11ea3c2c2691c2e113a9fa681236e74390c541 | https://github.com/msschl/monolog-http-handler/blob/3f11ea3c2c2691c2e113a9fa681236e74390c541/src/HttpHandler.php#L254-L270 |
14,077 | msschl/monolog-http-handler | src/HttpHandler.php | HttpHandler.write | protected function write(array $record)
{
$uri = $this->getUri();
if (empty($uri)) {
return;
}
$request = $this->getMessageFactory()->createRequest(
$this->getMethod(),
$this->getUri(),
$this->getHeaders(),
$record['formatted'],
$this->getProtocolVersion()
);
try {
$this->getHttpClient()->sendRequest($request);
/* istanbul ignore next */
} catch (\Exception $e) {
// QUESTION(msschl): How to handle the thrown exceptions???
/* istanbul ignore next */
return;
}
} | php | protected function write(array $record)
{
$uri = $this->getUri();
if (empty($uri)) {
return;
}
$request = $this->getMessageFactory()->createRequest(
$this->getMethod(),
$this->getUri(),
$this->getHeaders(),
$record['formatted'],
$this->getProtocolVersion()
);
try {
$this->getHttpClient()->sendRequest($request);
/* istanbul ignore next */
} catch (\Exception $e) {
// QUESTION(msschl): How to handle the thrown exceptions???
/* istanbul ignore next */
return;
}
} | [
"protected",
"function",
"write",
"(",
"array",
"$",
"record",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"getUri",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"uri",
")",
")",
"{",
"return",
";",
"}",
"$",
"request",
"=",
"$",
"this",
"->",
"getMessageFactory",
"(",
")",
"->",
"createRequest",
"(",
"$",
"this",
"->",
"getMethod",
"(",
")",
",",
"$",
"this",
"->",
"getUri",
"(",
")",
",",
"$",
"this",
"->",
"getHeaders",
"(",
")",
",",
"$",
"record",
"[",
"'formatted'",
"]",
",",
"$",
"this",
"->",
"getProtocolVersion",
"(",
")",
")",
";",
"try",
"{",
"$",
"this",
"->",
"getHttpClient",
"(",
")",
"->",
"sendRequest",
"(",
"$",
"request",
")",
";",
"/* istanbul ignore next */",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// QUESTION(msschl): How to handle the thrown exceptions???",
"/* istanbul ignore next */",
"return",
";",
"}",
"}"
]
| Writes the record.
@param array $record
@return void | [
"Writes",
"the",
"record",
"."
]
| 3f11ea3c2c2691c2e113a9fa681236e74390c541 | https://github.com/msschl/monolog-http-handler/blob/3f11ea3c2c2691c2e113a9fa681236e74390c541/src/HttpHandler.php#L308-L332 |
14,078 | dekuan/delib | src/CMobileDetector.php | CMobileDetector.setHttpHeaders | public function setHttpHeaders($httpHeaders = null)
{
// use global _SERVER if $httpHeaders aren't defined
if (!is_array($httpHeaders) || !count($httpHeaders)) {
$httpHeaders = $_SERVER;
}
// clear existing headers
$this->httpHeaders = array();
// Only save HTTP headers. In PHP land, that means only _SERVER vars that
// start with HTTP_.
foreach ($httpHeaders as $key => $value) {
if (substr($key, 0, 5) === 'HTTP_') {
$this->httpHeaders[$key] = $value;
}
}
// In case we're dealing with CloudFront, we need to know.
$this->setCfHeaders($httpHeaders);
} | php | public function setHttpHeaders($httpHeaders = null)
{
// use global _SERVER if $httpHeaders aren't defined
if (!is_array($httpHeaders) || !count($httpHeaders)) {
$httpHeaders = $_SERVER;
}
// clear existing headers
$this->httpHeaders = array();
// Only save HTTP headers. In PHP land, that means only _SERVER vars that
// start with HTTP_.
foreach ($httpHeaders as $key => $value) {
if (substr($key, 0, 5) === 'HTTP_') {
$this->httpHeaders[$key] = $value;
}
}
// In case we're dealing with CloudFront, we need to know.
$this->setCfHeaders($httpHeaders);
} | [
"public",
"function",
"setHttpHeaders",
"(",
"$",
"httpHeaders",
"=",
"null",
")",
"{",
"// use global _SERVER if $httpHeaders aren't defined",
"if",
"(",
"!",
"is_array",
"(",
"$",
"httpHeaders",
")",
"||",
"!",
"count",
"(",
"$",
"httpHeaders",
")",
")",
"{",
"$",
"httpHeaders",
"=",
"$",
"_SERVER",
";",
"}",
"// clear existing headers",
"$",
"this",
"->",
"httpHeaders",
"=",
"array",
"(",
")",
";",
"// Only save HTTP headers. In PHP land, that means only _SERVER vars that",
"// start with HTTP_.",
"foreach",
"(",
"$",
"httpHeaders",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"5",
")",
"===",
"'HTTP_'",
")",
"{",
"$",
"this",
"->",
"httpHeaders",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"// In case we're dealing with CloudFront, we need to know.",
"$",
"this",
"->",
"setCfHeaders",
"(",
"$",
"httpHeaders",
")",
";",
"}"
]
| Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers.
@param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract
the headers. The default null is left for backwards compatibility. | [
"Set",
"the",
"HTTP",
"Headers",
".",
"Must",
"be",
"PHP",
"-",
"flavored",
".",
"This",
"method",
"will",
"reset",
"existing",
"headers",
"."
]
| a0b82c5f1eb0cf7379eac3670ebf362787a7c6f8 | https://github.com/dekuan/delib/blob/a0b82c5f1eb0cf7379eac3670ebf362787a7c6f8/src/CMobileDetector.php#L699-L719 |
14,079 | mimmi20/Wurfl | src/Device/ModelDevice.php | ModelDevice.getGroupIdCapabilitiesMap | public function getGroupIdCapabilitiesMap()
{
$groupIdCapabilitiesMap = array();
foreach ($this->groupIdCapabilitiesNameMap as $groupId => $capabilitiesName) {
foreach ($capabilitiesName as $capabilityName) {
$groupIdCapabilitiesMap[$groupId][$capabilityName] = $this->capabilities[$capabilityName];
}
}
return $groupIdCapabilitiesMap;
} | php | public function getGroupIdCapabilitiesMap()
{
$groupIdCapabilitiesMap = array();
foreach ($this->groupIdCapabilitiesNameMap as $groupId => $capabilitiesName) {
foreach ($capabilitiesName as $capabilityName) {
$groupIdCapabilitiesMap[$groupId][$capabilityName] = $this->capabilities[$capabilityName];
}
}
return $groupIdCapabilitiesMap;
} | [
"public",
"function",
"getGroupIdCapabilitiesMap",
"(",
")",
"{",
"$",
"groupIdCapabilitiesMap",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"groupIdCapabilitiesNameMap",
"as",
"$",
"groupId",
"=>",
"$",
"capabilitiesName",
")",
"{",
"foreach",
"(",
"$",
"capabilitiesName",
"as",
"$",
"capabilityName",
")",
"{",
"$",
"groupIdCapabilitiesMap",
"[",
"$",
"groupId",
"]",
"[",
"$",
"capabilityName",
"]",
"=",
"$",
"this",
"->",
"capabilities",
"[",
"$",
"capabilityName",
"]",
";",
"}",
"}",
"return",
"$",
"groupIdCapabilitiesMap",
";",
"}"
]
| Returns the capabilities by group name
@return array capabilities | [
"Returns",
"the",
"capabilities",
"by",
"group",
"name"
]
| 443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec | https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/Device/ModelDevice.php#L173-L183 |
14,080 | inpsyde/wp-db-tools | src/Action/MySqlTableCopier.php | MySqlTableCopier.copy | public function copy( Table $src, Table $dest ) {
$this->copy_structure( $src, $dest );
$src_table = $this->database->quote_identifier( $src->name() );
$dest_table = $this->database->quote_identifier( $dest->name() );
$query = "INSERT INTO {$dest_table} SELECT * FROM {$src_table}";
return (bool) $this->database->query( $query );
} | php | public function copy( Table $src, Table $dest ) {
$this->copy_structure( $src, $dest );
$src_table = $this->database->quote_identifier( $src->name() );
$dest_table = $this->database->quote_identifier( $dest->name() );
$query = "INSERT INTO {$dest_table} SELECT * FROM {$src_table}";
return (bool) $this->database->query( $query );
} | [
"public",
"function",
"copy",
"(",
"Table",
"$",
"src",
",",
"Table",
"$",
"dest",
")",
"{",
"$",
"this",
"->",
"copy_structure",
"(",
"$",
"src",
",",
"$",
"dest",
")",
";",
"$",
"src_table",
"=",
"$",
"this",
"->",
"database",
"->",
"quote_identifier",
"(",
"$",
"src",
"->",
"name",
"(",
")",
")",
";",
"$",
"dest_table",
"=",
"$",
"this",
"->",
"database",
"->",
"quote_identifier",
"(",
"$",
"dest",
"->",
"name",
"(",
")",
")",
";",
"$",
"query",
"=",
"\"INSERT INTO {$dest_table} SELECT * FROM {$src_table}\"",
";",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"database",
"->",
"query",
"(",
"$",
"query",
")",
";",
"}"
]
| Duplicates a table structure with the complete content
@param Table $src
@param Table $dest
@return bool | [
"Duplicates",
"a",
"table",
"structure",
"with",
"the",
"complete",
"content"
]
| f16f4a96e1e326733ab0ef940e2c9247b6285694 | https://github.com/inpsyde/wp-db-tools/blob/f16f4a96e1e326733ab0ef940e2c9247b6285694/src/Action/MySqlTableCopier.php#L36-L44 |
14,081 | cauditor/php-analyzer | src/Analyzers/PDepend/JsonGenerator.php | JsonGenerator.addInstability | protected function addInstability(array $metrics)
{
if (isset($metrics['ca']) && isset($metrics['ce'])) {
$metrics['i'] = $metrics['ce'] / (($metrics['ce'] + $metrics['ca']) ?: 1);
}
return $metrics;
} | php | protected function addInstability(array $metrics)
{
if (isset($metrics['ca']) && isset($metrics['ce'])) {
$metrics['i'] = $metrics['ce'] / (($metrics['ce'] + $metrics['ca']) ?: 1);
}
return $metrics;
} | [
"protected",
"function",
"addInstability",
"(",
"array",
"$",
"metrics",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"metrics",
"[",
"'ca'",
"]",
")",
"&&",
"isset",
"(",
"$",
"metrics",
"[",
"'ce'",
"]",
")",
")",
"{",
"$",
"metrics",
"[",
"'i'",
"]",
"=",
"$",
"metrics",
"[",
"'ce'",
"]",
"/",
"(",
"(",
"$",
"metrics",
"[",
"'ce'",
"]",
"+",
"$",
"metrics",
"[",
"'ca'",
"]",
")",
"?",
":",
"1",
")",
";",
"}",
"return",
"$",
"metrics",
";",
"}"
]
| pdepend.analyzer.dependency also calculates instability, but not on a
per-class level, and defaulting to 0 instead of 1.
@param array $metrics
@return array | [
"pdepend",
".",
"analyzer",
".",
"dependency",
"also",
"calculates",
"instability",
"but",
"not",
"on",
"a",
"per",
"-",
"class",
"level",
"and",
"defaulting",
"to",
"0",
"instead",
"of",
"1",
"."
]
| 0d86686d64d01e6aaed433898841894fa3ce1101 | https://github.com/cauditor/php-analyzer/blob/0d86686d64d01e6aaed433898841894fa3ce1101/src/Analyzers/PDepend/JsonGenerator.php#L309-L316 |
14,082 | PandaPlatform/framework | src/Panda/Views/Viewer.php | Viewer.load | public function load($name, $extension = 'html')
{
// Get view file path
$this->view = $this->getViewFilePath($name, $extension);
// Check if there is a valid view
if (empty($this->view)) {
throw new InvalidArgumentException(__METHOD__ . sprintf(': The view file [%s] is a not valid view.', $this->getViewFile($name, $extension)));
}
return $this;
} | php | public function load($name, $extension = 'html')
{
// Get view file path
$this->view = $this->getViewFilePath($name, $extension);
// Check if there is a valid view
if (empty($this->view)) {
throw new InvalidArgumentException(__METHOD__ . sprintf(': The view file [%s] is a not valid view.', $this->getViewFile($name, $extension)));
}
return $this;
} | [
"public",
"function",
"load",
"(",
"$",
"name",
",",
"$",
"extension",
"=",
"'html'",
")",
"{",
"// Get view file path",
"$",
"this",
"->",
"view",
"=",
"$",
"this",
"->",
"getViewFilePath",
"(",
"$",
"name",
",",
"$",
"extension",
")",
";",
"// Check if there is a valid view",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"view",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"__METHOD__",
".",
"sprintf",
"(",
"': The view file [%s] is a not valid view.'",
",",
"$",
"this",
"->",
"getViewFile",
"(",
"$",
"name",
",",
"$",
"extension",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Load a view.
@param string $name
@param string $extension
@return $this
@throws InvalidArgumentException | [
"Load",
"a",
"view",
"."
]
| a78cf051b379896b5a4d5df620988e37a0e632f5 | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Views/Viewer.php#L84-L95 |
14,083 | PandaPlatform/framework | src/Panda/Views/Viewer.php | Viewer.render | public function render()
{
// Check if there is a valid view
if (empty($this->view)) {
throw new InvalidArgumentException(__METHOD__ . ': The view file given is a not valid view.');
}
// Load the view file
$this->output = $this->executable ? include $this->view : file_get_contents($this->view);
// Interpolate parameters on the view
$this->output = StringHelper::interpolate($this->output, $this->parameters);
return $this;
} | php | public function render()
{
// Check if there is a valid view
if (empty($this->view)) {
throw new InvalidArgumentException(__METHOD__ . ': The view file given is a not valid view.');
}
// Load the view file
$this->output = $this->executable ? include $this->view : file_get_contents($this->view);
// Interpolate parameters on the view
$this->output = StringHelper::interpolate($this->output, $this->parameters);
return $this;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"// Check if there is a valid view",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"view",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"__METHOD__",
".",
"': The view file given is a not valid view.'",
")",
";",
"}",
"// Load the view file",
"$",
"this",
"->",
"output",
"=",
"$",
"this",
"->",
"executable",
"?",
"include",
"$",
"this",
"->",
"view",
":",
"file_get_contents",
"(",
"$",
"this",
"->",
"view",
")",
";",
"// Interpolate parameters on the view",
"$",
"this",
"->",
"output",
"=",
"StringHelper",
"::",
"interpolate",
"(",
"$",
"this",
"->",
"output",
",",
"$",
"this",
"->",
"parameters",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Render the view output.
@return $this
@throws InvalidArgumentException | [
"Render",
"the",
"view",
"output",
"."
]
| a78cf051b379896b5a4d5df620988e37a0e632f5 | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Views/Viewer.php#L103-L117 |
14,084 | PandaPlatform/framework | src/Panda/Views/Viewer.php | Viewer.getViewFolder | private function getViewFolder($name)
{
return $this->viewsConfiguration->getViewsPath($this->app->getBasePath()) . DIRECTORY_SEPARATOR . $name . '.view';
} | php | private function getViewFolder($name)
{
return $this->viewsConfiguration->getViewsPath($this->app->getBasePath()) . DIRECTORY_SEPARATOR . $name . '.view';
} | [
"private",
"function",
"getViewFolder",
"(",
"$",
"name",
")",
"{",
"return",
"$",
"this",
"->",
"viewsConfiguration",
"->",
"getViewsPath",
"(",
"$",
"this",
"->",
"app",
"->",
"getBasePath",
"(",
")",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"name",
".",
"'.view'",
";",
"}"
]
| Get the view's base folder.
@param string $name
@return string | [
"Get",
"the",
"view",
"s",
"base",
"folder",
"."
]
| a78cf051b379896b5a4d5df620988e37a0e632f5 | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Views/Viewer.php#L152-L155 |
14,085 | PandaPlatform/framework | src/Panda/Views/Viewer.php | Viewer.getViewFilePath | private function getViewFilePath($name, $extension = 'html')
{
// Check view file
$viewFile = $this->getViewFile($name, $extension);
if (!file_exists($viewFile)) {
// Check for view folder
$viewBaseName = $this->getViewFolder($name) . DIRECTORY_SEPARATOR . 'view';
// Select the view file
$viewFile = (file_exists($viewBaseName . '.php') ? $viewBaseName . '.php' : $viewBaseName . '.html');
$viewFile = (file_exists($viewFile) ? $viewFile : null);
}
// Check if the file is executable (php)
if (preg_match('/\.php$/', $viewFile)) {
$this->executable = true;
}
return $viewFile;
} | php | private function getViewFilePath($name, $extension = 'html')
{
// Check view file
$viewFile = $this->getViewFile($name, $extension);
if (!file_exists($viewFile)) {
// Check for view folder
$viewBaseName = $this->getViewFolder($name) . DIRECTORY_SEPARATOR . 'view';
// Select the view file
$viewFile = (file_exists($viewBaseName . '.php') ? $viewBaseName . '.php' : $viewBaseName . '.html');
$viewFile = (file_exists($viewFile) ? $viewFile : null);
}
// Check if the file is executable (php)
if (preg_match('/\.php$/', $viewFile)) {
$this->executable = true;
}
return $viewFile;
} | [
"private",
"function",
"getViewFilePath",
"(",
"$",
"name",
",",
"$",
"extension",
"=",
"'html'",
")",
"{",
"// Check view file",
"$",
"viewFile",
"=",
"$",
"this",
"->",
"getViewFile",
"(",
"$",
"name",
",",
"$",
"extension",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"viewFile",
")",
")",
"{",
"// Check for view folder",
"$",
"viewBaseName",
"=",
"$",
"this",
"->",
"getViewFolder",
"(",
"$",
"name",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"'view'",
";",
"// Select the view file",
"$",
"viewFile",
"=",
"(",
"file_exists",
"(",
"$",
"viewBaseName",
".",
"'.php'",
")",
"?",
"$",
"viewBaseName",
".",
"'.php'",
":",
"$",
"viewBaseName",
".",
"'.html'",
")",
";",
"$",
"viewFile",
"=",
"(",
"file_exists",
"(",
"$",
"viewFile",
")",
"?",
"$",
"viewFile",
":",
"null",
")",
";",
"}",
"// Check if the file is executable (php)",
"if",
"(",
"preg_match",
"(",
"'/\\.php$/'",
",",
"$",
"viewFile",
")",
")",
"{",
"$",
"this",
"->",
"executable",
"=",
"true",
";",
"}",
"return",
"$",
"viewFile",
";",
"}"
]
| Get the view file to be rendered for output.
@param string $name
@param string $extension
@return null|string | [
"Get",
"the",
"view",
"file",
"to",
"be",
"rendered",
"for",
"output",
"."
]
| a78cf051b379896b5a4d5df620988e37a0e632f5 | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Views/Viewer.php#L176-L195 |
14,086 | joomla-projects/jorobo | src/Tasks/Map.php | Map.processAdministrator | private function processAdministrator()
{
$sourceFolder = $this->getSourceFolder();
$this->processComponents($sourceFolder . '/administrator/components', $this->target . '/administrator');
$this->processLanguage($sourceFolder . '/administrator/language', $this->target . '/administrator');
$this->processModules($sourceFolder . '/administrator/modules', $this->target . '/administrator/modules');
} | php | private function processAdministrator()
{
$sourceFolder = $this->getSourceFolder();
$this->processComponents($sourceFolder . '/administrator/components', $this->target . '/administrator');
$this->processLanguage($sourceFolder . '/administrator/language', $this->target . '/administrator');
$this->processModules($sourceFolder . '/administrator/modules', $this->target . '/administrator/modules');
} | [
"private",
"function",
"processAdministrator",
"(",
")",
"{",
"$",
"sourceFolder",
"=",
"$",
"this",
"->",
"getSourceFolder",
"(",
")",
";",
"$",
"this",
"->",
"processComponents",
"(",
"$",
"sourceFolder",
".",
"'/administrator/components'",
",",
"$",
"this",
"->",
"target",
".",
"'/administrator'",
")",
";",
"$",
"this",
"->",
"processLanguage",
"(",
"$",
"sourceFolder",
".",
"'/administrator/language'",
",",
"$",
"this",
"->",
"target",
".",
"'/administrator'",
")",
";",
"$",
"this",
"->",
"processModules",
"(",
"$",
"sourceFolder",
".",
"'/administrator/modules'",
",",
"$",
"this",
"->",
"target",
".",
"'/administrator/modules'",
")",
";",
"}"
]
| Process Administrator files
@return void
@since 1.0 | [
"Process",
"Administrator",
"files"
]
| e72dd0ed15f387739f67cacdbc2c0bd1b427f317 | https://github.com/joomla-projects/jorobo/blob/e72dd0ed15f387739f67cacdbc2c0bd1b427f317/src/Tasks/Map.php#L111-L117 |
14,087 | joomla-projects/jorobo | src/Tasks/Map.php | Map.linkSubdirectories | private function linkSubdirectories($src, $to)
{
if (is_dir($src))
{
$dirHandle = opendir($src);
while (false !== ($element = readdir($dirHandle)))
{
if (substr($element, 0, 1) != '.')
{
if (is_dir($src . "/" . $element))
{
$this->symlink($src . "/" . $element, $to . '/' . $element);
}
}
}
}
} | php | private function linkSubdirectories($src, $to)
{
if (is_dir($src))
{
$dirHandle = opendir($src);
while (false !== ($element = readdir($dirHandle)))
{
if (substr($element, 0, 1) != '.')
{
if (is_dir($src . "/" . $element))
{
$this->symlink($src . "/" . $element, $to . '/' . $element);
}
}
}
}
} | [
"private",
"function",
"linkSubdirectories",
"(",
"$",
"src",
",",
"$",
"to",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"src",
")",
")",
"{",
"$",
"dirHandle",
"=",
"opendir",
"(",
"$",
"src",
")",
";",
"while",
"(",
"false",
"!==",
"(",
"$",
"element",
"=",
"readdir",
"(",
"$",
"dirHandle",
")",
")",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"element",
",",
"0",
",",
"1",
")",
"!=",
"'.'",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"src",
".",
"\"/\"",
".",
"$",
"element",
")",
")",
"{",
"$",
"this",
"->",
"symlink",
"(",
"$",
"src",
".",
"\"/\"",
".",
"$",
"element",
",",
"$",
"to",
".",
"'/'",
".",
"$",
"element",
")",
";",
"}",
"}",
"}",
"}",
"}"
]
| Link subdirectories into folder
@param string $src The source
@param string $to The target
@return void
@since 1.0 | [
"Link",
"subdirectories",
"into",
"folder"
]
| e72dd0ed15f387739f67cacdbc2c0bd1b427f317 | https://github.com/joomla-projects/jorobo/blob/e72dd0ed15f387739f67cacdbc2c0bd1b427f317/src/Tasks/Map.php#L223-L240 |
14,088 | joomla-projects/jorobo | src/Tasks/Build/Component.php | Component.createInstaller | private function createInstaller()
{
$this->say("Creating component installer");
$adminFolder = $this->getBuildFolder() . "/administrator/components/com_" . $this->getExtensionName();
$xmlFile = $adminFolder . "/" . $this->getExtensionName() . ".xml";
$configFile = $adminFolder . "/config.xml";
$scriptFile = $adminFolder . "/script.php";
$helperFile = $adminFolder . "/helpers/defines.php";
// Version & Date Replace
$this->replaceInFile($xmlFile);
$this->replaceInFile($scriptFile);
$this->replaceInFile($configFile);
$this->replaceInFile($helperFile);
// Files and folders
if ($this->hasAdmin)
{
$f = $this->generateFileList($this->getFiles('backend'));
$this->taskReplaceInFile($xmlFile)
->from('##BACKEND_COMPONENT_FILES##')
->to($f)
->run();
// Language files
$f = $this->generateLanguageFileList($this->getFiles('backendLanguage'));
$this->taskReplaceInFile($xmlFile)
->from('##BACKEND_LANGUAGE_FILES##')
->to($f)
->run();
}
if ($this->hasFront)
{
$f = $this->generateFileList($this->getFiles('frontend'));
$this->taskReplaceInFile($xmlFile)
->from('##FRONTEND_COMPONENT_FILES##')
->to($f)
->run();
// Language files
$f = $this->generateLanguageFileList($this->getFiles('frontendLanguage'));
$this->taskReplaceInFile($xmlFile)
->from('##FRONTEND_LANGUAGE_FILES##')
->to($f)
->run();
}
// Media files
if ($this->hasMedia)
{
$f = $this->generateFileList($this->getFiles('media'));
$this->taskReplaceInFile($xmlFile)
->from('##MEDIA_FILES##')
->to($f)
->run();
}
} | php | private function createInstaller()
{
$this->say("Creating component installer");
$adminFolder = $this->getBuildFolder() . "/administrator/components/com_" . $this->getExtensionName();
$xmlFile = $adminFolder . "/" . $this->getExtensionName() . ".xml";
$configFile = $adminFolder . "/config.xml";
$scriptFile = $adminFolder . "/script.php";
$helperFile = $adminFolder . "/helpers/defines.php";
// Version & Date Replace
$this->replaceInFile($xmlFile);
$this->replaceInFile($scriptFile);
$this->replaceInFile($configFile);
$this->replaceInFile($helperFile);
// Files and folders
if ($this->hasAdmin)
{
$f = $this->generateFileList($this->getFiles('backend'));
$this->taskReplaceInFile($xmlFile)
->from('##BACKEND_COMPONENT_FILES##')
->to($f)
->run();
// Language files
$f = $this->generateLanguageFileList($this->getFiles('backendLanguage'));
$this->taskReplaceInFile($xmlFile)
->from('##BACKEND_LANGUAGE_FILES##')
->to($f)
->run();
}
if ($this->hasFront)
{
$f = $this->generateFileList($this->getFiles('frontend'));
$this->taskReplaceInFile($xmlFile)
->from('##FRONTEND_COMPONENT_FILES##')
->to($f)
->run();
// Language files
$f = $this->generateLanguageFileList($this->getFiles('frontendLanguage'));
$this->taskReplaceInFile($xmlFile)
->from('##FRONTEND_LANGUAGE_FILES##')
->to($f)
->run();
}
// Media files
if ($this->hasMedia)
{
$f = $this->generateFileList($this->getFiles('media'));
$this->taskReplaceInFile($xmlFile)
->from('##MEDIA_FILES##')
->to($f)
->run();
}
} | [
"private",
"function",
"createInstaller",
"(",
")",
"{",
"$",
"this",
"->",
"say",
"(",
"\"Creating component installer\"",
")",
";",
"$",
"adminFolder",
"=",
"$",
"this",
"->",
"getBuildFolder",
"(",
")",
".",
"\"/administrator/components/com_\"",
".",
"$",
"this",
"->",
"getExtensionName",
"(",
")",
";",
"$",
"xmlFile",
"=",
"$",
"adminFolder",
".",
"\"/\"",
".",
"$",
"this",
"->",
"getExtensionName",
"(",
")",
".",
"\".xml\"",
";",
"$",
"configFile",
"=",
"$",
"adminFolder",
".",
"\"/config.xml\"",
";",
"$",
"scriptFile",
"=",
"$",
"adminFolder",
".",
"\"/script.php\"",
";",
"$",
"helperFile",
"=",
"$",
"adminFolder",
".",
"\"/helpers/defines.php\"",
";",
"// Version & Date Replace",
"$",
"this",
"->",
"replaceInFile",
"(",
"$",
"xmlFile",
")",
";",
"$",
"this",
"->",
"replaceInFile",
"(",
"$",
"scriptFile",
")",
";",
"$",
"this",
"->",
"replaceInFile",
"(",
"$",
"configFile",
")",
";",
"$",
"this",
"->",
"replaceInFile",
"(",
"$",
"helperFile",
")",
";",
"// Files and folders",
"if",
"(",
"$",
"this",
"->",
"hasAdmin",
")",
"{",
"$",
"f",
"=",
"$",
"this",
"->",
"generateFileList",
"(",
"$",
"this",
"->",
"getFiles",
"(",
"'backend'",
")",
")",
";",
"$",
"this",
"->",
"taskReplaceInFile",
"(",
"$",
"xmlFile",
")",
"->",
"from",
"(",
"'##BACKEND_COMPONENT_FILES##'",
")",
"->",
"to",
"(",
"$",
"f",
")",
"->",
"run",
"(",
")",
";",
"// Language files",
"$",
"f",
"=",
"$",
"this",
"->",
"generateLanguageFileList",
"(",
"$",
"this",
"->",
"getFiles",
"(",
"'backendLanguage'",
")",
")",
";",
"$",
"this",
"->",
"taskReplaceInFile",
"(",
"$",
"xmlFile",
")",
"->",
"from",
"(",
"'##BACKEND_LANGUAGE_FILES##'",
")",
"->",
"to",
"(",
"$",
"f",
")",
"->",
"run",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasFront",
")",
"{",
"$",
"f",
"=",
"$",
"this",
"->",
"generateFileList",
"(",
"$",
"this",
"->",
"getFiles",
"(",
"'frontend'",
")",
")",
";",
"$",
"this",
"->",
"taskReplaceInFile",
"(",
"$",
"xmlFile",
")",
"->",
"from",
"(",
"'##FRONTEND_COMPONENT_FILES##'",
")",
"->",
"to",
"(",
"$",
"f",
")",
"->",
"run",
"(",
")",
";",
"// Language files",
"$",
"f",
"=",
"$",
"this",
"->",
"generateLanguageFileList",
"(",
"$",
"this",
"->",
"getFiles",
"(",
"'frontendLanguage'",
")",
")",
";",
"$",
"this",
"->",
"taskReplaceInFile",
"(",
"$",
"xmlFile",
")",
"->",
"from",
"(",
"'##FRONTEND_LANGUAGE_FILES##'",
")",
"->",
"to",
"(",
"$",
"f",
")",
"->",
"run",
"(",
")",
";",
"}",
"// Media files",
"if",
"(",
"$",
"this",
"->",
"hasMedia",
")",
"{",
"$",
"f",
"=",
"$",
"this",
"->",
"generateFileList",
"(",
"$",
"this",
"->",
"getFiles",
"(",
"'media'",
")",
")",
";",
"$",
"this",
"->",
"taskReplaceInFile",
"(",
"$",
"xmlFile",
")",
"->",
"from",
"(",
"'##MEDIA_FILES##'",
")",
"->",
"to",
"(",
"$",
"f",
")",
"->",
"run",
"(",
")",
";",
"}",
"}"
]
| Generate the installer xml file for the component
@return void
@since 1.0 | [
"Generate",
"the",
"installer",
"xml",
"file",
"for",
"the",
"component"
]
| e72dd0ed15f387739f67cacdbc2c0bd1b427f317 | https://github.com/joomla-projects/jorobo/blob/e72dd0ed15f387739f67cacdbc2c0bd1b427f317/src/Tasks/Build/Component.php#L188-L251 |
14,089 | fostam/php-getopts | src/Config/Argument.php | Argument.required | public function required() {
$this->validated = false;
$this->config[self::REQUIRED] = true;
return $this;
} | php | public function required() {
$this->validated = false;
$this->config[self::REQUIRED] = true;
return $this;
} | [
"public",
"function",
"required",
"(",
")",
"{",
"$",
"this",
"->",
"validated",
"=",
"false",
";",
"$",
"this",
"->",
"config",
"[",
"self",
"::",
"REQUIRED",
"]",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
]
| change the argument from optional to mandatory
@return $this | [
"change",
"the",
"argument",
"from",
"optional",
"to",
"mandatory"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Config/Argument.php#L40-L44 |
14,090 | fostam/php-getopts | src/Config/Argument.php | Argument.name | public function name($name) {
$this->config[self::NAME] = $name;
if (!self::validateName($name)) {
throw new ArgumentConfigException('illegal characters in name: ' . $name);
}
return $this;
} | php | public function name($name) {
$this->config[self::NAME] = $name;
if (!self::validateName($name)) {
throw new ArgumentConfigException('illegal characters in name: ' . $name);
}
return $this;
} | [
"public",
"function",
"name",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"self",
"::",
"NAME",
"]",
"=",
"$",
"name",
";",
"if",
"(",
"!",
"self",
"::",
"validateName",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"ArgumentConfigException",
"(",
"'illegal characters in name: '",
".",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| set the argument's name
@param string $name
@return $this | [
"set",
"the",
"argument",
"s",
"name"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Config/Argument.php#L52-L58 |
14,091 | fostam/php-getopts | src/Config/Argument.php | Argument.defaultValue | public function defaultValue($value) {
$this->validated = false;
$this->config[self::DEFAULT_VALUE] = $value;
return $this;
} | php | public function defaultValue($value) {
$this->validated = false;
$this->config[self::DEFAULT_VALUE] = $value;
return $this;
} | [
"public",
"function",
"defaultValue",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"validated",
"=",
"false",
";",
"$",
"this",
"->",
"config",
"[",
"self",
"::",
"DEFAULT_VALUE",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
]
| set the argument's default value
@param mixed $value
@return $this | [
"set",
"the",
"argument",
"s",
"default",
"value"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Config/Argument.php#L77-L81 |
14,092 | fostam/php-getopts | src/Config/Argument.php | Argument.get | public function get($param = '') {
$this->validate();
if ($param) {
if (array_key_exists($param, $this->config)) {
return $this->config[$param];
}
else {
throw new ArgumentConfigException('argument param not valid: ' . $param);
}
}
return $this->config;
} | php | public function get($param = '') {
$this->validate();
if ($param) {
if (array_key_exists($param, $this->config)) {
return $this->config[$param];
}
else {
throw new ArgumentConfigException('argument param not valid: ' . $param);
}
}
return $this->config;
} | [
"public",
"function",
"get",
"(",
"$",
"param",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"if",
"(",
"$",
"param",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"param",
",",
"$",
"this",
"->",
"config",
")",
")",
"{",
"return",
"$",
"this",
"->",
"config",
"[",
"$",
"param",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"ArgumentConfigException",
"(",
"'argument param not valid: '",
".",
"$",
"param",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"config",
";",
"}"
]
| return full argument configuration, or a specific parameter of the configuration
@param string $param
@return mixed
@throws ArgumentConfigException | [
"return",
"full",
"argument",
"configuration",
"or",
"a",
"specific",
"parameter",
"of",
"the",
"configuration"
]
| 0d0209eb48201e3e0b28305ae8d28d4657d6d979 | https://github.com/fostam/php-getopts/blob/0d0209eb48201e3e0b28305ae8d28d4657d6d979/src/Config/Argument.php#L101-L114 |
14,093 | eloquent/constance | src/AbstractConstant.php | AbstractConstant.membersToBitmask | final public static function membersToBitmask($members)
{
$mask = 0;
foreach ($members as $member) {
if (!is_integer($member->value())) {
throw new Exception\NonIntegerValueException($member->value());
}
$mask |= $member->value();
}
return $mask;
} | php | final public static function membersToBitmask($members)
{
$mask = 0;
foreach ($members as $member) {
if (!is_integer($member->value())) {
throw new Exception\NonIntegerValueException($member->value());
}
$mask |= $member->value();
}
return $mask;
} | [
"final",
"public",
"static",
"function",
"membersToBitmask",
"(",
"$",
"members",
")",
"{",
"$",
"mask",
"=",
"0",
";",
"foreach",
"(",
"$",
"members",
"as",
"$",
"member",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"member",
"->",
"value",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"NonIntegerValueException",
"(",
"$",
"member",
"->",
"value",
"(",
")",
")",
";",
"}",
"$",
"mask",
"|=",
"$",
"member",
"->",
"value",
"(",
")",
";",
"}",
"return",
"$",
"mask",
";",
"}"
]
| Generates a bitmask representing the suppled members.
@param mixed<ConstantInterface> $members The members to create a bitmask for.
@return integer The bitmask representing the supplied members.
@throws Exception\NonIntegerValueException If any member's value is a non-integer. | [
"Generates",
"a",
"bitmask",
"representing",
"the",
"suppled",
"members",
"."
]
| 4af52e02bb4b074201003b952bb0269cd9e536d5 | https://github.com/eloquent/constance/blob/4af52e02bb4b074201003b952bb0269cd9e536d5/src/AbstractConstant.php#L70-L82 |
14,094 | eloquent/constance | src/AbstractConstant.php | AbstractConstant.valueMatchesBitmask | public function valueMatchesBitmask($mask)
{
if (!is_integer($this->value())) {
throw new Exception\NonIntegerValueException($this->value());
}
return $this->value() === ($this->value() & $mask);
} | php | public function valueMatchesBitmask($mask)
{
if (!is_integer($this->value())) {
throw new Exception\NonIntegerValueException($this->value());
}
return $this->value() === ($this->value() & $mask);
} | [
"public",
"function",
"valueMatchesBitmask",
"(",
"$",
"mask",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"this",
"->",
"value",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"NonIntegerValueException",
"(",
"$",
"this",
"->",
"value",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"value",
"(",
")",
"===",
"(",
"$",
"this",
"->",
"value",
"(",
")",
"&",
"$",
"mask",
")",
";",
"}"
]
| Returns true if this constant's value matches the supplied bitmask.
@param integer $mask The mask to test against.
@return boolean True if the value matches.
@throws Exception\NonIntegerValueException If this constant's value is not an integer. | [
"Returns",
"true",
"if",
"this",
"constant",
"s",
"value",
"matches",
"the",
"supplied",
"bitmask",
"."
]
| 4af52e02bb4b074201003b952bb0269cd9e536d5 | https://github.com/eloquent/constance/blob/4af52e02bb4b074201003b952bb0269cd9e536d5/src/AbstractConstant.php#L102-L109 |
14,095 | psecio/propauth | src/Enforcer.php | Enforcer.denies | public function denies($policyName, $subject, array $addl = array())
{
if (!is_array($policyName)) {
$policyName = [$policyName];
}
foreach ($policyName as $name) {
if (!isset($this->policySet[$name])) {
throw new \InvalidArgumentException('Policy name "'.$name.'" not found');
}
$result = $this->evaluate($subject, $this->policySet[$name], $addl);
if ($result === true) {
return false;
}
}
return true;
} | php | public function denies($policyName, $subject, array $addl = array())
{
if (!is_array($policyName)) {
$policyName = [$policyName];
}
foreach ($policyName as $name) {
if (!isset($this->policySet[$name])) {
throw new \InvalidArgumentException('Policy name "'.$name.'" not found');
}
$result = $this->evaluate($subject, $this->policySet[$name], $addl);
if ($result === true) {
return false;
}
}
return true;
} | [
"public",
"function",
"denies",
"(",
"$",
"policyName",
",",
"$",
"subject",
",",
"array",
"$",
"addl",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"policyName",
")",
")",
"{",
"$",
"policyName",
"=",
"[",
"$",
"policyName",
"]",
";",
"}",
"foreach",
"(",
"$",
"policyName",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"policySet",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Policy name \"'",
".",
"$",
"name",
".",
"'\" not found'",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"evaluate",
"(",
"$",
"subject",
",",
"$",
"this",
"->",
"policySet",
"[",
"$",
"name",
"]",
",",
"$",
"addl",
")",
";",
"if",
"(",
"$",
"result",
"===",
"true",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
]
| Locate a policy by name and evaluate if the subject is denied
by matching against its properties
@param string $policyName Policy key name
@param object $subject Subject to evluate against
@throws \InvalidArgumentException If policy name is not found
@return boolean Pass/fail of evluation | [
"Locate",
"a",
"policy",
"by",
"name",
"and",
"evaluate",
"if",
"the",
"subject",
"is",
"denied",
"by",
"matching",
"against",
"its",
"properties"
]
| cb24fcc0a3fa459f2ef40a867c334951aabf7b83 | https://github.com/psecio/propauth/blob/cb24fcc0a3fa459f2ef40a867c334951aabf7b83/src/Enforcer.php#L83-L98 |
14,096 | psecio/propauth | src/Enforcer.php | Enforcer.resolvePath | public function resolvePath($type, $subject, $path)
{
$resolve = new Resolve($subject);
$resolvedSet = $resolve->execute($path);
$set = [];
if (is_array($resolvedSet)) {
foreach ($resolvedSet as $item) {
$set[] = $this->getPropertyValue($type, $item);
}
} else {
$set = $this->getPropertyValue($type, $subject);
}
return $set;
} | php | public function resolvePath($type, $subject, $path)
{
$resolve = new Resolve($subject);
$resolvedSet = $resolve->execute($path);
$set = [];
if (is_array($resolvedSet)) {
foreach ($resolvedSet as $item) {
$set[] = $this->getPropertyValue($type, $item);
}
} else {
$set = $this->getPropertyValue($type, $subject);
}
return $set;
} | [
"public",
"function",
"resolvePath",
"(",
"$",
"type",
",",
"$",
"subject",
",",
"$",
"path",
")",
"{",
"$",
"resolve",
"=",
"new",
"Resolve",
"(",
"$",
"subject",
")",
";",
"$",
"resolvedSet",
"=",
"$",
"resolve",
"->",
"execute",
"(",
"$",
"path",
")",
";",
"$",
"set",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"resolvedSet",
")",
")",
"{",
"foreach",
"(",
"$",
"resolvedSet",
"as",
"$",
"item",
")",
"{",
"$",
"set",
"[",
"]",
"=",
"$",
"this",
"->",
"getPropertyValue",
"(",
"$",
"type",
",",
"$",
"item",
")",
";",
"}",
"}",
"else",
"{",
"$",
"set",
"=",
"$",
"this",
"->",
"getPropertyValue",
"(",
"$",
"type",
",",
"$",
"subject",
")",
";",
"}",
"return",
"$",
"set",
";",
"}"
]
| Resolve the provided path using a Resolver object instance
@param string $type The "type" of value to look for (key name)
@param mixed $subject The subject of the search
@param string $path The string path to the data requested (ex: permissions.tests.name)
@return array Set of results | [
"Resolve",
"the",
"provided",
"path",
"using",
"a",
"Resolver",
"object",
"instance"
]
| cb24fcc0a3fa459f2ef40a867c334951aabf7b83 | https://github.com/psecio/propauth/blob/cb24fcc0a3fa459f2ef40a867c334951aabf7b83/src/Enforcer.php#L151-L165 |
14,097 | wpup/digster | src/extensions/class-function-extensions.php | Function_Extensions.call_function | public function call_function() {
$args = func_get_args();
$name = array_shift( $args );
return call_user_func_array( trim( $name ), $args );
} | php | public function call_function() {
$args = func_get_args();
$name = array_shift( $args );
return call_user_func_array( trim( $name ), $args );
} | [
"public",
"function",
"call_function",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"name",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"return",
"call_user_func_array",
"(",
"trim",
"(",
"$",
"name",
")",
",",
"$",
"args",
")",
";",
"}"
]
| Call PHP function.
@return mixed | [
"Call",
"PHP",
"function",
"."
]
| 9ef9626ce82673af698bc0976d6c38a532e4a6d9 | https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/extensions/class-function-extensions.php#L12-L17 |
14,098 | wpup/digster | src/extensions/class-function-extensions.php | Function_Extensions.call_static | public function call_static() {
$args = func_get_args();
$class = array_shift( $args );
$name = array_shift( $args );
return call_user_func_array( [$class, $name], $args );
} | php | public function call_static() {
$args = func_get_args();
$class = array_shift( $args );
$name = array_shift( $args );
return call_user_func_array( [$class, $name], $args );
} | [
"public",
"function",
"call_static",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"class",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"name",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"return",
"call_user_func_array",
"(",
"[",
"$",
"class",
",",
"$",
"name",
"]",
",",
"$",
"args",
")",
";",
"}"
]
| Call static method on class.
@return mixed | [
"Call",
"static",
"method",
"on",
"class",
"."
]
| 9ef9626ce82673af698bc0976d6c38a532e4a6d9 | https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/extensions/class-function-extensions.php#L24-L30 |
14,099 | cauditor/php-analyzer | src/Utils.php | Utils.getopts | public static function getopts($options)
{
$opts = getopt(implode('', array_keys($options)), $options);
$result = array();
foreach ($options as $short => $long) {
$short = trim($short, ':');
$long = trim($long, ':');
if (isset($opts[$short])) {
$result[$long] = $opts[$short];
} elseif (isset($opts[$long])) {
$result[$long] = $opts[$long];
}
}
return $result;
} | php | public static function getopts($options)
{
$opts = getopt(implode('', array_keys($options)), $options);
$result = array();
foreach ($options as $short => $long) {
$short = trim($short, ':');
$long = trim($long, ':');
if (isset($opts[$short])) {
$result[$long] = $opts[$short];
} elseif (isset($opts[$long])) {
$result[$long] = $opts[$long];
}
}
return $result;
} | [
"public",
"static",
"function",
"getopts",
"(",
"$",
"options",
")",
"{",
"$",
"opts",
"=",
"getopt",
"(",
"implode",
"(",
"''",
",",
"array_keys",
"(",
"$",
"options",
")",
")",
",",
"$",
"options",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"short",
"=>",
"$",
"long",
")",
"{",
"$",
"short",
"=",
"trim",
"(",
"$",
"short",
",",
"':'",
")",
";",
"$",
"long",
"=",
"trim",
"(",
"$",
"long",
",",
"':'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"opts",
"[",
"$",
"short",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"long",
"]",
"=",
"$",
"opts",
"[",
"$",
"short",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"opts",
"[",
"$",
"long",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"long",
"]",
"=",
"$",
"opts",
"[",
"$",
"long",
"]",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| `getopts` is very convenient, but annoying how one has to check for both
the long & short versions for values; this will always return an array
with the long opt as key, even if the user passed it as short.
@param array $options [short => long]
@return array | [
"getopts",
"is",
"very",
"convenient",
"but",
"annoying",
"how",
"one",
"has",
"to",
"check",
"for",
"both",
"the",
"long",
"&",
"short",
"versions",
"for",
"values",
";",
"this",
"will",
"always",
"return",
"an",
"array",
"with",
"the",
"long",
"opt",
"as",
"key",
"even",
"if",
"the",
"user",
"passed",
"it",
"as",
"short",
"."
]
| 0d86686d64d01e6aaed433898841894fa3ce1101 | https://github.com/cauditor/php-analyzer/blob/0d86686d64d01e6aaed433898841894fa3ce1101/src/Utils.php#L21-L38 |
Subsets and Splits