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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
11,600
|
bfitech/zapmin
|
src/AdminStoreInit.php
|
AdminStoreInit.store_is_logged_in
|
protected function store_is_logged_in() {
$this->init();
if ($this->user_data === null)
$this->adm_status();
return $this->user_data;
}
|
php
|
protected function store_is_logged_in() {
$this->init();
if ($this->user_data === null)
$this->adm_status();
return $this->user_data;
}
|
[
"protected",
"function",
"store_is_logged_in",
"(",
")",
"{",
"$",
"this",
"->",
"init",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"user_data",
"===",
"null",
")",
"$",
"this",
"->",
"adm_status",
"(",
")",
";",
"return",
"$",
"this",
"->",
"user_data",
";",
"}"
] |
Check if current user is signed in.
|
[
"Check",
"if",
"current",
"user",
"is",
"signed",
"in",
"."
] |
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
|
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreInit.php#L327-L332
|
11,601
|
bfitech/zapmin
|
src/AdminStoreInit.php
|
AdminStoreInit.store_close_session
|
protected function store_close_session($sid) {
$now = $this->store->stmt_fragment('datetime');
$this->store->query_raw(sprintf(
"UPDATE usess SET expire=(%s) WHERE sid='%s'",
$now, $sid));
$this->store_redis_cache_del($this->user_token);
}
|
php
|
protected function store_close_session($sid) {
$now = $this->store->stmt_fragment('datetime');
$this->store->query_raw(sprintf(
"UPDATE usess SET expire=(%s) WHERE sid='%s'",
$now, $sid));
$this->store_redis_cache_del($this->user_token);
}
|
[
"protected",
"function",
"store_close_session",
"(",
"$",
"sid",
")",
"{",
"$",
"now",
"=",
"$",
"this",
"->",
"store",
"->",
"stmt_fragment",
"(",
"'datetime'",
")",
";",
"$",
"this",
"->",
"store",
"->",
"query_raw",
"(",
"sprintf",
"(",
"\"UPDATE usess SET expire=(%s) WHERE sid='%s'\"",
",",
"$",
"now",
",",
"$",
"sid",
")",
")",
";",
"$",
"this",
"->",
"store_redis_cache_del",
"(",
"$",
"this",
"->",
"user_token",
")",
";",
"}"
] |
Close session record in the database.
@param int $sid Session ID.
|
[
"Close",
"session",
"record",
"in",
"the",
"database",
"."
] |
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
|
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreInit.php#L339-L345
|
11,602
|
bellisq/fundamental
|
src/Config/ConfigAbstract.php
|
ConfigAbstract.existOrFail
|
final protected function existOrFail(string $key): void
{
if (!isset($this->env[$key])) {
throw new MissingConfigException($key, static::class);
}
}
|
php
|
final protected function existOrFail(string $key): void
{
if (!isset($this->env[$key])) {
throw new MissingConfigException($key, static::class);
}
}
|
[
"final",
"protected",
"function",
"existOrFail",
"(",
"string",
"$",
"key",
")",
":",
"void",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"env",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"MissingConfigException",
"(",
"$",
"key",
",",
"static",
"::",
"class",
")",
";",
"}",
"}"
] |
Check if a specific env variable is set or not.
If it isn't set, throw an exception.
@param string $key
@throws MissingConfigException
|
[
"Check",
"if",
"a",
"specific",
"env",
"variable",
"is",
"set",
"or",
"not",
".",
"If",
"it",
"isn",
"t",
"set",
"throw",
"an",
"exception",
"."
] |
39e09d693e46d2566102efbee27301698191a4ea
|
https://github.com/bellisq/fundamental/blob/39e09d693e46d2566102efbee27301698191a4ea/src/Config/ConfigAbstract.php#L45-L50
|
11,603
|
bellisq/fundamental
|
src/Config/ConfigAbstract.php
|
ConfigAbstract.getBool
|
final protected function getBool(string $key, bool $default = false): bool
{
if (!isset($this->env[$key]) or !is_string($this->env[$key])) {
return $default;
}
$t = strtolower(trim($this->env[$key]));
$allowed = [
'true' => true,
'on' => true,
'1' => true,
'false' => false,
'off' => false,
'0' => false,
];
if (isset($allowed[$t])) {
return $allowed[$t];
}
if (is_numeric($t)) {
// if $t == 0, false is already returned.
return true;
}
throw new InvalidConfigException($key, static::class);
}
|
php
|
final protected function getBool(string $key, bool $default = false): bool
{
if (!isset($this->env[$key]) or !is_string($this->env[$key])) {
return $default;
}
$t = strtolower(trim($this->env[$key]));
$allowed = [
'true' => true,
'on' => true,
'1' => true,
'false' => false,
'off' => false,
'0' => false,
];
if (isset($allowed[$t])) {
return $allowed[$t];
}
if (is_numeric($t)) {
// if $t == 0, false is already returned.
return true;
}
throw new InvalidConfigException($key, static::class);
}
|
[
"final",
"protected",
"function",
"getBool",
"(",
"string",
"$",
"key",
",",
"bool",
"$",
"default",
"=",
"false",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"env",
"[",
"$",
"key",
"]",
")",
"or",
"!",
"is_string",
"(",
"$",
"this",
"->",
"env",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"$",
"t",
"=",
"strtolower",
"(",
"trim",
"(",
"$",
"this",
"->",
"env",
"[",
"$",
"key",
"]",
")",
")",
";",
"$",
"allowed",
"=",
"[",
"'true'",
"=>",
"true",
",",
"'on'",
"=>",
"true",
",",
"'1'",
"=>",
"true",
",",
"'false'",
"=>",
"false",
",",
"'off'",
"=>",
"false",
",",
"'0'",
"=>",
"false",
",",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"allowed",
"[",
"$",
"t",
"]",
")",
")",
"{",
"return",
"$",
"allowed",
"[",
"$",
"t",
"]",
";",
"}",
"if",
"(",
"is_numeric",
"(",
"$",
"t",
")",
")",
"{",
"// if $t == 0, false is already returned.",
"return",
"true",
";",
"}",
"throw",
"new",
"InvalidConfigException",
"(",
"$",
"key",
",",
"static",
"::",
"class",
")",
";",
"}"
] |
Get bool value from env variables.
@param string $key
@param bool $default
@return bool
|
[
"Get",
"bool",
"value",
"from",
"env",
"variables",
"."
] |
39e09d693e46d2566102efbee27301698191a4ea
|
https://github.com/bellisq/fundamental/blob/39e09d693e46d2566102efbee27301698191a4ea/src/Config/ConfigAbstract.php#L59-L85
|
11,604
|
treehouselabs/feeder
|
src/TreeHouse/Feeder/Modifier/Data/Transformer/LocalizedStringToNumberTransformer.php
|
LocalizedStringToNumberTransformer.round
|
private function round($number)
{
if (null !== $this->precision && null !== $this->roundingMode) {
// shift number to maintain the correct precision during rounding
$roundingCoef = pow(10, $this->precision);
$number *= $roundingCoef;
switch ($this->roundingMode) {
case \NumberFormatter::ROUND_CEILING:
$number = ceil($number);
break;
case \NumberFormatter::ROUND_FLOOR:
$number = floor($number);
break;
case \NumberFormatter::ROUND_UP:
$number = $number > 0 ? ceil($number) : floor($number);
break;
case \NumberFormatter::ROUND_DOWN:
$number = $number > 0 ? floor($number) : ceil($number);
break;
case \NumberFormatter::ROUND_HALFEVEN:
$number = round($number, 0, PHP_ROUND_HALF_EVEN);
break;
case \NumberFormatter::ROUND_HALFUP:
$number = round($number, 0, PHP_ROUND_HALF_UP);
break;
case \NumberFormatter::ROUND_HALFDOWN:
$number = round($number, 0, PHP_ROUND_HALF_DOWN);
break;
}
$number /= $roundingCoef;
}
return $number;
}
|
php
|
private function round($number)
{
if (null !== $this->precision && null !== $this->roundingMode) {
// shift number to maintain the correct precision during rounding
$roundingCoef = pow(10, $this->precision);
$number *= $roundingCoef;
switch ($this->roundingMode) {
case \NumberFormatter::ROUND_CEILING:
$number = ceil($number);
break;
case \NumberFormatter::ROUND_FLOOR:
$number = floor($number);
break;
case \NumberFormatter::ROUND_UP:
$number = $number > 0 ? ceil($number) : floor($number);
break;
case \NumberFormatter::ROUND_DOWN:
$number = $number > 0 ? floor($number) : ceil($number);
break;
case \NumberFormatter::ROUND_HALFEVEN:
$number = round($number, 0, PHP_ROUND_HALF_EVEN);
break;
case \NumberFormatter::ROUND_HALFUP:
$number = round($number, 0, PHP_ROUND_HALF_UP);
break;
case \NumberFormatter::ROUND_HALFDOWN:
$number = round($number, 0, PHP_ROUND_HALF_DOWN);
break;
}
$number /= $roundingCoef;
}
return $number;
}
|
[
"private",
"function",
"round",
"(",
"$",
"number",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"precision",
"&&",
"null",
"!==",
"$",
"this",
"->",
"roundingMode",
")",
"{",
"// shift number to maintain the correct precision during rounding",
"$",
"roundingCoef",
"=",
"pow",
"(",
"10",
",",
"$",
"this",
"->",
"precision",
")",
";",
"$",
"number",
"*=",
"$",
"roundingCoef",
";",
"switch",
"(",
"$",
"this",
"->",
"roundingMode",
")",
"{",
"case",
"\\",
"NumberFormatter",
"::",
"ROUND_CEILING",
":",
"$",
"number",
"=",
"ceil",
"(",
"$",
"number",
")",
";",
"break",
";",
"case",
"\\",
"NumberFormatter",
"::",
"ROUND_FLOOR",
":",
"$",
"number",
"=",
"floor",
"(",
"$",
"number",
")",
";",
"break",
";",
"case",
"\\",
"NumberFormatter",
"::",
"ROUND_UP",
":",
"$",
"number",
"=",
"$",
"number",
">",
"0",
"?",
"ceil",
"(",
"$",
"number",
")",
":",
"floor",
"(",
"$",
"number",
")",
";",
"break",
";",
"case",
"\\",
"NumberFormatter",
"::",
"ROUND_DOWN",
":",
"$",
"number",
"=",
"$",
"number",
">",
"0",
"?",
"floor",
"(",
"$",
"number",
")",
":",
"ceil",
"(",
"$",
"number",
")",
";",
"break",
";",
"case",
"\\",
"NumberFormatter",
"::",
"ROUND_HALFEVEN",
":",
"$",
"number",
"=",
"round",
"(",
"$",
"number",
",",
"0",
",",
"PHP_ROUND_HALF_EVEN",
")",
";",
"break",
";",
"case",
"\\",
"NumberFormatter",
"::",
"ROUND_HALFUP",
":",
"$",
"number",
"=",
"round",
"(",
"$",
"number",
",",
"0",
",",
"PHP_ROUND_HALF_UP",
")",
";",
"break",
";",
"case",
"\\",
"NumberFormatter",
"::",
"ROUND_HALFDOWN",
":",
"$",
"number",
"=",
"round",
"(",
"$",
"number",
",",
"0",
",",
"PHP_ROUND_HALF_DOWN",
")",
";",
"break",
";",
"}",
"$",
"number",
"/=",
"$",
"roundingCoef",
";",
"}",
"return",
"$",
"number",
";",
"}"
] |
Rounds a number according to the configured precision and rounding mode.
@param int|float $number A number.
@return int|float The rounded number.
|
[
"Rounds",
"a",
"number",
"according",
"to",
"the",
"configured",
"precision",
"and",
"rounding",
"mode",
"."
] |
756018648ae28e028cef572559bfebd4eb77127a
|
https://github.com/treehouselabs/feeder/blob/756018648ae28e028cef572559bfebd4eb77127a/src/TreeHouse/Feeder/Modifier/Data/Transformer/LocalizedStringToNumberTransformer.php#L156-L191
|
11,605
|
1g0rbm/prettycurl
|
src/OptionManager.php
|
OptionManager.cookie
|
public function cookie($domain)
{
$this->bag->set(CURLOPT_COOKIEJAR, $this->getPath($domain, 'cookie'));
$this->bag->set(CURLOPT_COOKIEFILE, $this->getPath($domain, 'cookie'));
return $this;
}
|
php
|
public function cookie($domain)
{
$this->bag->set(CURLOPT_COOKIEJAR, $this->getPath($domain, 'cookie'));
$this->bag->set(CURLOPT_COOKIEFILE, $this->getPath($domain, 'cookie'));
return $this;
}
|
[
"public",
"function",
"cookie",
"(",
"$",
"domain",
")",
"{",
"$",
"this",
"->",
"bag",
"->",
"set",
"(",
"CURLOPT_COOKIEJAR",
",",
"$",
"this",
"->",
"getPath",
"(",
"$",
"domain",
",",
"'cookie'",
")",
")",
";",
"$",
"this",
"->",
"bag",
"->",
"set",
"(",
"CURLOPT_COOKIEFILE",
",",
"$",
"this",
"->",
"getPath",
"(",
"$",
"domain",
",",
"'cookie'",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Enable saving and reading cookies
@param string $domain
@return $this
|
[
"Enable",
"saving",
"and",
"reading",
"cookies"
] |
afe0bd6e323c4096ae15749848dd19cba38f970a
|
https://github.com/1g0rbm/prettycurl/blob/afe0bd6e323c4096ae15749848dd19cba38f970a/src/OptionManager.php#L104-L110
|
11,606
|
diatem-net/jin-filesystem
|
src/FileSystem/Folder.php
|
Folder.deleteContent
|
public function deleteContent()
{
$files = glob($this->folderPath . '*');
foreach ($files as $file) {
if (is_file($file)) {
unlink($file);
}
}
}
|
php
|
public function deleteContent()
{
$files = glob($this->folderPath . '*');
foreach ($files as $file) {
if (is_file($file)) {
unlink($file);
}
}
}
|
[
"public",
"function",
"deleteContent",
"(",
")",
"{",
"$",
"files",
"=",
"glob",
"(",
"$",
"this",
"->",
"folderPath",
".",
"'*'",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"unlink",
"(",
"$",
"file",
")",
";",
"}",
"}",
"}"
] |
Supprime le contenu du dossier
|
[
"Supprime",
"le",
"contenu",
"du",
"dossier"
] |
0a97844284ca48cb47e28ef2834f20b8a42ef798
|
https://github.com/diatem-net/jin-filesystem/blob/0a97844284ca48cb47e28ef2834f20b8a42ef798/src/FileSystem/Folder.php#L128-L136
|
11,607
|
diatem-net/jin-filesystem
|
src/FileSystem/Folder.php
|
Folder.findCommonPath
|
public static function findCommonPath($directories)
{
while(count($directories) !== 1) {
usort($directories, function($a, $b) {
return strlen($b) - strlen($a);
});
$directories[0] = dirname($directories[0]);
$directories = array_unique($directories);
}
return reset($directories);
}
|
php
|
public static function findCommonPath($directories)
{
while(count($directories) !== 1) {
usort($directories, function($a, $b) {
return strlen($b) - strlen($a);
});
$directories[0] = dirname($directories[0]);
$directories = array_unique($directories);
}
return reset($directories);
}
|
[
"public",
"static",
"function",
"findCommonPath",
"(",
"$",
"directories",
")",
"{",
"while",
"(",
"count",
"(",
"$",
"directories",
")",
"!==",
"1",
")",
"{",
"usort",
"(",
"$",
"directories",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"return",
"strlen",
"(",
"$",
"b",
")",
"-",
"strlen",
"(",
"$",
"a",
")",
";",
"}",
")",
";",
"$",
"directories",
"[",
"0",
"]",
"=",
"dirname",
"(",
"$",
"directories",
"[",
"0",
"]",
")",
";",
"$",
"directories",
"=",
"array_unique",
"(",
"$",
"directories",
")",
";",
"}",
"return",
"reset",
"(",
"$",
"directories",
")",
";",
"}"
] |
Retourne la partie commune des chemins de plusieurs dossiers
@param array $directories Liste de dossiers
@return string Partie commune des paths
|
[
"Retourne",
"la",
"partie",
"commune",
"des",
"chemins",
"de",
"plusieurs",
"dossiers"
] |
0a97844284ca48cb47e28ef2834f20b8a42ef798
|
https://github.com/diatem-net/jin-filesystem/blob/0a97844284ca48cb47e28ef2834f20b8a42ef798/src/FileSystem/Folder.php#L153-L163
|
11,608
|
phramework/query-log
|
src/QueryLog.php
|
QueryLog.register
|
public function register($additionalParameters = null)
{
if ($additionalParameters && !is_object($additionalParameters)) {
throw new \Exception('additionalParameters must be an object');
}
//Ignore registration if disabled setting is set to true
if (isset($this->settings->disabled) && $this->settings->disabled) {
return false;
}
//Get current global adapter
$internalAdapter = \Phramework\Database\Database::getAdapter();
if (!$internalAdapter) {
throw new \Exception('Global database adapter is not initialized');
}
//Create new QueryLogAdapter instance, using current global adapter
$queryLogAdapter = new QueryLogAdapter(
$this->settings,
$internalAdapter,
$additionalParameters
);
//Set newly created QueryLogAdapter instance as global adapter
\Phramework\Database\Database::setAdapter($queryLogAdapter);
return true;
}
|
php
|
public function register($additionalParameters = null)
{
if ($additionalParameters && !is_object($additionalParameters)) {
throw new \Exception('additionalParameters must be an object');
}
//Ignore registration if disabled setting is set to true
if (isset($this->settings->disabled) && $this->settings->disabled) {
return false;
}
//Get current global adapter
$internalAdapter = \Phramework\Database\Database::getAdapter();
if (!$internalAdapter) {
throw new \Exception('Global database adapter is not initialized');
}
//Create new QueryLogAdapter instance, using current global adapter
$queryLogAdapter = new QueryLogAdapter(
$this->settings,
$internalAdapter,
$additionalParameters
);
//Set newly created QueryLogAdapter instance as global adapter
\Phramework\Database\Database::setAdapter($queryLogAdapter);
return true;
}
|
[
"public",
"function",
"register",
"(",
"$",
"additionalParameters",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"additionalParameters",
"&&",
"!",
"is_object",
"(",
"$",
"additionalParameters",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'additionalParameters must be an object'",
")",
";",
"}",
"//Ignore registration if disabled setting is set to true",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"settings",
"->",
"disabled",
")",
"&&",
"$",
"this",
"->",
"settings",
"->",
"disabled",
")",
"{",
"return",
"false",
";",
"}",
"//Get current global adapter",
"$",
"internalAdapter",
"=",
"\\",
"Phramework",
"\\",
"Database",
"\\",
"Database",
"::",
"getAdapter",
"(",
")",
";",
"if",
"(",
"!",
"$",
"internalAdapter",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Global database adapter is not initialized'",
")",
";",
"}",
"//Create new QueryLogAdapter instance, using current global adapter",
"$",
"queryLogAdapter",
"=",
"new",
"QueryLogAdapter",
"(",
"$",
"this",
"->",
"settings",
",",
"$",
"internalAdapter",
",",
"$",
"additionalParameters",
")",
";",
"//Set newly created QueryLogAdapter instance as global adapter",
"\\",
"Phramework",
"\\",
"Database",
"\\",
"Database",
"::",
"setAdapter",
"(",
"$",
"queryLogAdapter",
")",
";",
"return",
"true",
";",
"}"
] |
Activate query-log
@param null|object $additionalParameters
Additional parameters to be stored in query logs
@return boolean Returns false if query log is disabled
@throws \Exception
@uses Phramework\Database\Database
|
[
"Activate",
"query",
"-",
"log"
] |
ca0dc58ba11f02e427cad66a2d1b558ac88f0b92
|
https://github.com/phramework/query-log/blob/ca0dc58ba11f02e427cad66a2d1b558ac88f0b92/src/QueryLog.php#L140-L169
|
11,609
|
atorscho/laravel-helpers
|
src/Kinds/Assertions.php
|
Assertions.isHome
|
public function isHome(): bool
{
return $this->url->current() == $this->url->to($this->config->get('helpers.paths.home'));
}
|
php
|
public function isHome(): bool
{
return $this->url->current() == $this->url->to($this->config->get('helpers.paths.home'));
}
|
[
"public",
"function",
"isHome",
"(",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"url",
"->",
"current",
"(",
")",
"==",
"$",
"this",
"->",
"url",
"->",
"to",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'helpers.paths.home'",
")",
")",
";",
"}"
] |
Return true if current page is home.
|
[
"Return",
"true",
"if",
"current",
"page",
"is",
"home",
"."
] |
ef07510559db91a84e37fa1894f85ca338f25137
|
https://github.com/atorscho/laravel-helpers/blob/ef07510559db91a84e37fa1894f85ca338f25137/src/Kinds/Assertions.php#L53-L56
|
11,610
|
atorscho/laravel-helpers
|
src/Kinds/Assertions.php
|
Assertions.isAdmin
|
public function isAdmin(): bool
{
return str_contains($this->url->current(), $this->request->root() . '/' . $this->config->get('helpers.paths.admin'));
}
|
php
|
public function isAdmin(): bool
{
return str_contains($this->url->current(), $this->request->root() . '/' . $this->config->get('helpers.paths.admin'));
}
|
[
"public",
"function",
"isAdmin",
"(",
")",
":",
"bool",
"{",
"return",
"str_contains",
"(",
"$",
"this",
"->",
"url",
"->",
"current",
"(",
")",
",",
"$",
"this",
"->",
"request",
"->",
"root",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'helpers.paths.admin'",
")",
")",
";",
"}"
] |
Return true if current page is an admin page.
|
[
"Return",
"true",
"if",
"current",
"page",
"is",
"an",
"admin",
"page",
"."
] |
ef07510559db91a84e37fa1894f85ca338f25137
|
https://github.com/atorscho/laravel-helpers/blob/ef07510559db91a84e37fa1894f85ca338f25137/src/Kinds/Assertions.php#L69-L72
|
11,611
|
atorscho/laravel-helpers
|
src/Kinds/Assertions.php
|
Assertions.sectionExists
|
public function sectionExists(string $section): bool
{
return (bool) trim($this->view->yieldContent($section));
}
|
php
|
public function sectionExists(string $section): bool
{
return (bool) trim($this->view->yieldContent($section));
}
|
[
"public",
"function",
"sectionExists",
"(",
"string",
"$",
"section",
")",
":",
"bool",
"{",
"return",
"(",
"bool",
")",
"trim",
"(",
"$",
"this",
"->",
"view",
"->",
"yieldContent",
"(",
"$",
"section",
")",
")",
";",
"}"
] |
Check if a view section exists.
|
[
"Check",
"if",
"a",
"view",
"section",
"exists",
"."
] |
ef07510559db91a84e37fa1894f85ca338f25137
|
https://github.com/atorscho/laravel-helpers/blob/ef07510559db91a84e37fa1894f85ca338f25137/src/Kinds/Assertions.php#L94-L97
|
11,612
|
Jinxes/layton
|
Layton/Struct/DependentStruct.php
|
DependentStruct.injectionByClosure
|
public function injectionByClosure($closure, $method, $inherentParams=[])
{
if (! ($closure instanceof \Closure)) {
throw new \InvalidArgumentException('Method 0 must be a Closure.');
}
$instances = $this->dependentService->getParams($this->reflection, $method, count($inherentParams));
$params = array_merge($instances, $inherentParams);
return call_user_func_array($closure, $params);
}
|
php
|
public function injectionByClosure($closure, $method, $inherentParams=[])
{
if (! ($closure instanceof \Closure)) {
throw new \InvalidArgumentException('Method 0 must be a Closure.');
}
$instances = $this->dependentService->getParams($this->reflection, $method, count($inherentParams));
$params = array_merge($instances, $inherentParams);
return call_user_func_array($closure, $params);
}
|
[
"public",
"function",
"injectionByClosure",
"(",
"$",
"closure",
",",
"$",
"method",
",",
"$",
"inherentParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"closure",
"instanceof",
"\\",
"Closure",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Method 0 must be a Closure.'",
")",
";",
"}",
"$",
"instances",
"=",
"$",
"this",
"->",
"dependentService",
"->",
"getParams",
"(",
"$",
"this",
"->",
"reflection",
",",
"$",
"method",
",",
"count",
"(",
"$",
"inherentParams",
")",
")",
";",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"instances",
",",
"$",
"inherentParams",
")",
";",
"return",
"call_user_func_array",
"(",
"$",
"closure",
",",
"$",
"params",
")",
";",
"}"
] |
Injection a Closure
@param \Closure $closure
@param string $method
@param array $inherentParams
@return mixed
@throws \InvalidArgumentException
|
[
"Injection",
"a",
"Closure"
] |
27b8eab2c59b9887eb93e40a533eb77cc5690584
|
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Struct/DependentStruct.php#L111-L119
|
11,613
|
rikby/console-helper
|
src/Helper/GitDirHelper.php
|
GitDirHelper.getGitDirectory
|
public function getGitDirectory(InputInterface $input, OutputInterface $output, $optionDir = null)
{
$dir = $optionDir;
if (!$dir) {
$dir = $this->getVcsDirectory();
}
if (!$dir) {
$dir = $this->getCommandDir();
}
$validator = $this->getValidator();
try {
return $validator($dir);
} catch (\Exception $e) {
}
return $this->askProjectDir($input, $output, $dir);
}
|
php
|
public function getGitDirectory(InputInterface $input, OutputInterface $output, $optionDir = null)
{
$dir = $optionDir;
if (!$dir) {
$dir = $this->getVcsDirectory();
}
if (!$dir) {
$dir = $this->getCommandDir();
}
$validator = $this->getValidator();
try {
return $validator($dir);
} catch (\Exception $e) {
}
return $this->askProjectDir($input, $output, $dir);
}
|
[
"public",
"function",
"getGitDirectory",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
",",
"$",
"optionDir",
"=",
"null",
")",
"{",
"$",
"dir",
"=",
"$",
"optionDir",
";",
"if",
"(",
"!",
"$",
"dir",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"getVcsDirectory",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"dir",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"getCommandDir",
"(",
")",
";",
"}",
"$",
"validator",
"=",
"$",
"this",
"->",
"getValidator",
"(",
")",
";",
"try",
"{",
"return",
"$",
"validator",
"(",
"$",
"dir",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"return",
"$",
"this",
"->",
"askProjectDir",
"(",
"$",
"input",
",",
"$",
"output",
",",
"$",
"dir",
")",
";",
"}"
] |
Get GIT directory
@param InputInterface $input
@param OutputInterface $output
@param null|string $optionDir
@return string
|
[
"Get",
"GIT",
"directory"
] |
c618daf79e01439ea6cd60a75c9ff5b09de9b75d
|
https://github.com/rikby/console-helper/blob/c618daf79e01439ea6cd60a75c9ff5b09de9b75d/src/Helper/GitDirHelper.php#L42-L58
|
11,614
|
rikby/console-helper
|
src/Helper/GitDirHelper.php
|
GitDirHelper.askProjectDir
|
public function askProjectDir(
InputInterface $input,
OutputInterface $output,
$dir = null,
SymfonyStyle $style = null
) {
$question = $this->getSimpleQuestion()
->getQuestion('Please set your root project directory.', $dir);
$question->setValidator(
$this->getValidator()
);
$style = $style ?: new SymfonyStyle($input, $output);
$dir = $style->askQuestion($question);
return rtrim($dir, '\\/');
}
|
php
|
public function askProjectDir(
InputInterface $input,
OutputInterface $output,
$dir = null,
SymfonyStyle $style = null
) {
$question = $this->getSimpleQuestion()
->getQuestion('Please set your root project directory.', $dir);
$question->setValidator(
$this->getValidator()
);
$style = $style ?: new SymfonyStyle($input, $output);
$dir = $style->askQuestion($question);
return rtrim($dir, '\\/');
}
|
[
"public",
"function",
"askProjectDir",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
",",
"$",
"dir",
"=",
"null",
",",
"SymfonyStyle",
"$",
"style",
"=",
"null",
")",
"{",
"$",
"question",
"=",
"$",
"this",
"->",
"getSimpleQuestion",
"(",
")",
"->",
"getQuestion",
"(",
"'Please set your root project directory.'",
",",
"$",
"dir",
")",
";",
"$",
"question",
"->",
"setValidator",
"(",
"$",
"this",
"->",
"getValidator",
"(",
")",
")",
";",
"$",
"style",
"=",
"$",
"style",
"?",
":",
"new",
"SymfonyStyle",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"dir",
"=",
"$",
"style",
"->",
"askQuestion",
"(",
"$",
"question",
")",
";",
"return",
"rtrim",
"(",
"$",
"dir",
",",
"'\\\\/'",
")",
";",
"}"
] |
Ask about GIT project root dir
It will skip asking if system is able to identify it.
@param InputInterface $input
@param OutputInterface $output
@param string|null $dir
@param SymfonyStyle $style
@return string
|
[
"Ask",
"about",
"GIT",
"project",
"root",
"dir"
] |
c618daf79e01439ea6cd60a75c9ff5b09de9b75d
|
https://github.com/rikby/console-helper/blob/c618daf79e01439ea6cd60a75c9ff5b09de9b75d/src/Helper/GitDirHelper.php#L127-L143
|
11,615
|
rikby/console-helper
|
src/Helper/GitDirHelper.php
|
GitDirHelper.getValidator
|
protected function getValidator()
{
$helper = $this;
// @codingStandardsIgnoreStart
return function ($dir) use ($helper) {
$dir = rtrim($dir, '\\/');
if (!is_dir($helper->getDotGitDirectory($dir))) {
throw new LogicException('No information about git directory.');
}
return $dir;
};
// @codingStandardsIgnoreEnd
}
|
php
|
protected function getValidator()
{
$helper = $this;
// @codingStandardsIgnoreStart
return function ($dir) use ($helper) {
$dir = rtrim($dir, '\\/');
if (!is_dir($helper->getDotGitDirectory($dir))) {
throw new LogicException('No information about git directory.');
}
return $dir;
};
// @codingStandardsIgnoreEnd
}
|
[
"protected",
"function",
"getValidator",
"(",
")",
"{",
"$",
"helper",
"=",
"$",
"this",
";",
"// @codingStandardsIgnoreStart",
"return",
"function",
"(",
"$",
"dir",
")",
"use",
"(",
"$",
"helper",
")",
"{",
"$",
"dir",
"=",
"rtrim",
"(",
"$",
"dir",
",",
"'\\\\/'",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"helper",
"->",
"getDotGitDirectory",
"(",
"$",
"dir",
")",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'No information about git directory.'",
")",
";",
"}",
"return",
"$",
"dir",
";",
"}",
";",
"// @codingStandardsIgnoreEnd",
"}"
] |
Get GIT root directory validator
@return \Closure
|
[
"Get",
"GIT",
"root",
"directory",
"validator"
] |
c618daf79e01439ea6cd60a75c9ff5b09de9b75d
|
https://github.com/rikby/console-helper/blob/c618daf79e01439ea6cd60a75c9ff5b09de9b75d/src/Helper/GitDirHelper.php#L150-L164
|
11,616
|
rikby/console-helper
|
src/Helper/GitDirHelper.php
|
GitDirHelper.getSimpleQuestion
|
protected function getSimpleQuestion()
{
if (!$this->getHelperSet()->has('simple_question')) {
$this->getHelperSet()->set(new SimpleQuestionHelper());
}
return $this->getHelperSet()->get('simple_question');
}
|
php
|
protected function getSimpleQuestion()
{
if (!$this->getHelperSet()->has('simple_question')) {
$this->getHelperSet()->set(new SimpleQuestionHelper());
}
return $this->getHelperSet()->get('simple_question');
}
|
[
"protected",
"function",
"getSimpleQuestion",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getHelperSet",
"(",
")",
"->",
"has",
"(",
"'simple_question'",
")",
")",
"{",
"$",
"this",
"->",
"getHelperSet",
"(",
")",
"->",
"set",
"(",
"new",
"SimpleQuestionHelper",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getHelperSet",
"(",
")",
"->",
"get",
"(",
"'simple_question'",
")",
";",
"}"
] |
Get question helper
@return SimpleQuestionHelper
|
[
"Get",
"question",
"helper"
] |
c618daf79e01439ea6cd60a75c9ff5b09de9b75d
|
https://github.com/rikby/console-helper/blob/c618daf79e01439ea6cd60a75c9ff5b09de9b75d/src/Helper/GitDirHelper.php#L171-L178
|
11,617
|
webriq/core
|
module/Customize/src/Grid/Customize/Model/Rule/Structure.php
|
Structure.getRawProperty
|
public function getRawProperty( $rawName )
{
if ( isset( $this->properties[$rawName] ) )
{
return (object) $this->properties[$rawName];
}
return null;
}
|
php
|
public function getRawProperty( $rawName )
{
if ( isset( $this->properties[$rawName] ) )
{
return (object) $this->properties[$rawName];
}
return null;
}
|
[
"public",
"function",
"getRawProperty",
"(",
"$",
"rawName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"properties",
"[",
"$",
"rawName",
"]",
")",
")",
"{",
"return",
"(",
"object",
")",
"$",
"this",
"->",
"properties",
"[",
"$",
"rawName",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Get raw property
@param string $rawName
@return object (name, value, priority)
|
[
"Get",
"raw",
"property"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Rule/Structure.php#L168-L176
|
11,618
|
webriq/core
|
module/Customize/src/Grid/Customize/Model/Rule/Structure.php
|
Structure.setRawProperty
|
public function setRawProperty( $rawName, $value,
$priority = self::PRIORITY_NORMAL )
{
if ( is_array( $value ) )
{
$value = (object) $value;
}
if ( is_object( $value ) )
{
if ( isset( $value->priority ) )
{
$priority = $value->priority;
}
if ( isset( $value->value ) )
{
$value = $value->value;
}
else
{
$value = null;
}
}
$rawName = (string) $rawName;
$value = (string) $value;
$priority = ( (string) $priority ) ?: self::PRIORITY_NORMAL;
if ( '' === $value )
{
return $this->removeRawProperty( $rawName );
}
$this->properties[$rawName] = array(
'name' => $rawName,
'value' => $value,
'priority' => $priority,
);
return $this;
}
|
php
|
public function setRawProperty( $rawName, $value,
$priority = self::PRIORITY_NORMAL )
{
if ( is_array( $value ) )
{
$value = (object) $value;
}
if ( is_object( $value ) )
{
if ( isset( $value->priority ) )
{
$priority = $value->priority;
}
if ( isset( $value->value ) )
{
$value = $value->value;
}
else
{
$value = null;
}
}
$rawName = (string) $rawName;
$value = (string) $value;
$priority = ( (string) $priority ) ?: self::PRIORITY_NORMAL;
if ( '' === $value )
{
return $this->removeRawProperty( $rawName );
}
$this->properties[$rawName] = array(
'name' => $rawName,
'value' => $value,
'priority' => $priority,
);
return $this;
}
|
[
"public",
"function",
"setRawProperty",
"(",
"$",
"rawName",
",",
"$",
"value",
",",
"$",
"priority",
"=",
"self",
"::",
"PRIORITY_NORMAL",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"(",
"object",
")",
"$",
"value",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"value",
"->",
"priority",
")",
")",
"{",
"$",
"priority",
"=",
"$",
"value",
"->",
"priority",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"value",
"->",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"value",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"null",
";",
"}",
"}",
"$",
"rawName",
"=",
"(",
"string",
")",
"$",
"rawName",
";",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"$",
"priority",
"=",
"(",
"(",
"string",
")",
"$",
"priority",
")",
"?",
":",
"self",
"::",
"PRIORITY_NORMAL",
";",
"if",
"(",
"''",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"removeRawProperty",
"(",
"$",
"rawName",
")",
";",
"}",
"$",
"this",
"->",
"properties",
"[",
"$",
"rawName",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"rawName",
",",
"'value'",
"=>",
"$",
"value",
",",
"'priority'",
"=>",
"$",
"priority",
",",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set raw property
@param string $rawName
@param mixed $value
@param string $priority
@return \Customize\Model\Rule\Structure
|
[
"Set",
"raw",
"property"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Rule/Structure.php#L186-L227
|
11,619
|
webriq/core
|
module/Customize/src/Grid/Customize/Model/Rule/Structure.php
|
Structure.getRawPropertyValue
|
public function getRawPropertyValue( $rawName )
{
if ( isset( $this->properties[$rawName]['value'] ) )
{
return $this->properties[$rawName]['value'];
}
return null;
}
|
php
|
public function getRawPropertyValue( $rawName )
{
if ( isset( $this->properties[$rawName]['value'] ) )
{
return $this->properties[$rawName]['value'];
}
return null;
}
|
[
"public",
"function",
"getRawPropertyValue",
"(",
"$",
"rawName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"properties",
"[",
"$",
"rawName",
"]",
"[",
"'value'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"properties",
"[",
"$",
"rawName",
"]",
"[",
"'value'",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Get raw property value
@param string $rawName
@return mixed
|
[
"Get",
"raw",
"property",
"value"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Rule/Structure.php#L258-L266
|
11,620
|
webriq/core
|
module/Customize/src/Grid/Customize/Model/Rule/Structure.php
|
Structure.getRawPropertyPriority
|
public function getRawPropertyPriority( $rawName )
{
if ( isset( $this->properties[$rawName]['priority'] ) )
{
return $this->properties[$rawName]['priority'];
}
return null;
}
|
php
|
public function getRawPropertyPriority( $rawName )
{
if ( isset( $this->properties[$rawName]['priority'] ) )
{
return $this->properties[$rawName]['priority'];
}
return null;
}
|
[
"public",
"function",
"getRawPropertyPriority",
"(",
"$",
"rawName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"properties",
"[",
"$",
"rawName",
"]",
"[",
"'priority'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"properties",
"[",
"$",
"rawName",
"]",
"[",
"'priority'",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Get raw property priority
@param string $rawName
@return mixed
|
[
"Get",
"raw",
"property",
"priority"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Rule/Structure.php#L274-L282
|
11,621
|
webriq/core
|
module/Customize/src/Grid/Customize/Model/Rule/Structure.php
|
Structure.setRawProperties
|
public function setRawProperties( $properties )
{
if ( ! empty( $properties ) )
{
foreach ( $properties as $name => $value )
{
switch ( true )
{
case is_array( $value ) &&
array_key_exists( 'value', $value ):
$value = (object) $value;
case is_object( $value ):
if ( ! isset( $value->value ) )
{
$value->value = null;
}
if ( ! isset( $value->priority ) )
{
$value->priority = null;
}
if ( ! isset( $value->name ) )
{
$value->name = $name;
}
$this->setRawProperty(
$value->name,
$value->value,
$value->priority
);
break;
case is_array( $value ):
if ( count( $value ) > 2 )
{
list( $rawName, $value, $priority ) = $value;
if ( empty( $rawName ) )
{
$rawName = $name;
}
}
else if ( count( $value ) > 1 )
{
$rawName = $name;
list( $value, $priority ) = $value;
}
else
{
$rawName = $name;
$priority = null;
$value = empty( $value ) ? null : current( $value );
}
$this->setRawProperty( $rawName, $value, $priority );
break;
default:
$this->setRawProperty( $name, $value );
break;
}
}
}
return $this;
}
|
php
|
public function setRawProperties( $properties )
{
if ( ! empty( $properties ) )
{
foreach ( $properties as $name => $value )
{
switch ( true )
{
case is_array( $value ) &&
array_key_exists( 'value', $value ):
$value = (object) $value;
case is_object( $value ):
if ( ! isset( $value->value ) )
{
$value->value = null;
}
if ( ! isset( $value->priority ) )
{
$value->priority = null;
}
if ( ! isset( $value->name ) )
{
$value->name = $name;
}
$this->setRawProperty(
$value->name,
$value->value,
$value->priority
);
break;
case is_array( $value ):
if ( count( $value ) > 2 )
{
list( $rawName, $value, $priority ) = $value;
if ( empty( $rawName ) )
{
$rawName = $name;
}
}
else if ( count( $value ) > 1 )
{
$rawName = $name;
list( $value, $priority ) = $value;
}
else
{
$rawName = $name;
$priority = null;
$value = empty( $value ) ? null : current( $value );
}
$this->setRawProperty( $rawName, $value, $priority );
break;
default:
$this->setRawProperty( $name, $value );
break;
}
}
}
return $this;
}
|
[
"public",
"function",
"setRawProperties",
"(",
"$",
"properties",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"properties",
")",
")",
"{",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"is_array",
"(",
"$",
"value",
")",
"&&",
"array_key_exists",
"(",
"'value'",
",",
"$",
"value",
")",
":",
"$",
"value",
"=",
"(",
"object",
")",
"$",
"value",
";",
"case",
"is_object",
"(",
"$",
"value",
")",
":",
"if",
"(",
"!",
"isset",
"(",
"$",
"value",
"->",
"value",
")",
")",
"{",
"$",
"value",
"->",
"value",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"value",
"->",
"priority",
")",
")",
"{",
"$",
"value",
"->",
"priority",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"value",
"->",
"name",
")",
")",
"{",
"$",
"value",
"->",
"name",
"=",
"$",
"name",
";",
"}",
"$",
"this",
"->",
"setRawProperty",
"(",
"$",
"value",
"->",
"name",
",",
"$",
"value",
"->",
"value",
",",
"$",
"value",
"->",
"priority",
")",
";",
"break",
";",
"case",
"is_array",
"(",
"$",
"value",
")",
":",
"if",
"(",
"count",
"(",
"$",
"value",
")",
">",
"2",
")",
"{",
"list",
"(",
"$",
"rawName",
",",
"$",
"value",
",",
"$",
"priority",
")",
"=",
"$",
"value",
";",
"if",
"(",
"empty",
"(",
"$",
"rawName",
")",
")",
"{",
"$",
"rawName",
"=",
"$",
"name",
";",
"}",
"}",
"else",
"if",
"(",
"count",
"(",
"$",
"value",
")",
">",
"1",
")",
"{",
"$",
"rawName",
"=",
"$",
"name",
";",
"list",
"(",
"$",
"value",
",",
"$",
"priority",
")",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"rawName",
"=",
"$",
"name",
";",
"$",
"priority",
"=",
"null",
";",
"$",
"value",
"=",
"empty",
"(",
"$",
"value",
")",
"?",
"null",
":",
"current",
"(",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"setRawProperty",
"(",
"$",
"rawName",
",",
"$",
"value",
",",
"$",
"priority",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"setRawProperty",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set raw properties
@param array $properties
@return \Customize\Model\Rule\Structure
|
[
"Set",
"raw",
"properties"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Rule/Structure.php#L333-L401
|
11,622
|
webriq/core
|
module/Customize/src/Grid/Customize/Model/Rule/Structure.php
|
Structure.setBackgroundPositionXProperty
|
protected function setBackgroundPositionXProperty( $value, $priority = self::PRIORITY_NORMAL )
{
$x = (string) $value;
$y = (string) $this->getRawPropertyValue( 'background-position-y' );
if ( '' !== $x && '' !== $y )
{
$this->setRawProperty(
'background-position',
$x . ' ' . $y,
$priority ?: $this->getRawPropertyPriority(
'background-position-y'
)
);
}
return $this->setRawProperty( 'background-position-x', $x, $priority );
}
|
php
|
protected function setBackgroundPositionXProperty( $value, $priority = self::PRIORITY_NORMAL )
{
$x = (string) $value;
$y = (string) $this->getRawPropertyValue( 'background-position-y' );
if ( '' !== $x && '' !== $y )
{
$this->setRawProperty(
'background-position',
$x . ' ' . $y,
$priority ?: $this->getRawPropertyPriority(
'background-position-y'
)
);
}
return $this->setRawProperty( 'background-position-x', $x, $priority );
}
|
[
"protected",
"function",
"setBackgroundPositionXProperty",
"(",
"$",
"value",
",",
"$",
"priority",
"=",
"self",
"::",
"PRIORITY_NORMAL",
")",
"{",
"$",
"x",
"=",
"(",
"string",
")",
"$",
"value",
";",
"$",
"y",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getRawPropertyValue",
"(",
"'background-position-y'",
")",
";",
"if",
"(",
"''",
"!==",
"$",
"x",
"&&",
"''",
"!==",
"$",
"y",
")",
"{",
"$",
"this",
"->",
"setRawProperty",
"(",
"'background-position'",
",",
"$",
"x",
".",
"' '",
".",
"$",
"y",
",",
"$",
"priority",
"?",
":",
"$",
"this",
"->",
"getRawPropertyPriority",
"(",
"'background-position-y'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"setRawProperty",
"(",
"'background-position-x'",
",",
"$",
"x",
",",
"$",
"priority",
")",
";",
"}"
] |
Set background-position-x
@param string $value
@param string $priority
@return \Customize\Model\Rule\Structure
|
[
"Set",
"background",
"-",
"position",
"-",
"x"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Rule/Structure.php#L432-L449
|
11,623
|
webriq/core
|
module/Customize/src/Grid/Customize/Model/Rule/Structure.php
|
Structure.setBackgroundPositionProperty
|
protected function setBackgroundPositionProperty( $value, $priority = self::PRIORITY_NORMAL )
{
$parts = preg_split( '/\s+/', trim( $value ), 2 );
$this->setRawProperty( 'background-position', $value, $priority );
if ( count( $parts ) < 2 )
{
return $this;
}
list( $x, $y ) = $parts;
return $this->setRawProperty( 'background-position-x', $x, $priority )
->setRawProperty( 'background-position-y', $y, $priority );
}
|
php
|
protected function setBackgroundPositionProperty( $value, $priority = self::PRIORITY_NORMAL )
{
$parts = preg_split( '/\s+/', trim( $value ), 2 );
$this->setRawProperty( 'background-position', $value, $priority );
if ( count( $parts ) < 2 )
{
return $this;
}
list( $x, $y ) = $parts;
return $this->setRawProperty( 'background-position-x', $x, $priority )
->setRawProperty( 'background-position-y', $y, $priority );
}
|
[
"protected",
"function",
"setBackgroundPositionProperty",
"(",
"$",
"value",
",",
"$",
"priority",
"=",
"self",
"::",
"PRIORITY_NORMAL",
")",
"{",
"$",
"parts",
"=",
"preg_split",
"(",
"'/\\s+/'",
",",
"trim",
"(",
"$",
"value",
")",
",",
"2",
")",
";",
"$",
"this",
"->",
"setRawProperty",
"(",
"'background-position'",
",",
"$",
"value",
",",
"$",
"priority",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"<",
"2",
")",
"{",
"return",
"$",
"this",
";",
"}",
"list",
"(",
"$",
"x",
",",
"$",
"y",
")",
"=",
"$",
"parts",
";",
"return",
"$",
"this",
"->",
"setRawProperty",
"(",
"'background-position-x'",
",",
"$",
"x",
",",
"$",
"priority",
")",
"->",
"setRawProperty",
"(",
"'background-position-y'",
",",
"$",
"y",
",",
"$",
"priority",
")",
";",
"}"
] |
Set background-position
@param string $value
@param string $priority
@return \Customize\Model\Rule\Structure
|
[
"Set",
"background",
"-",
"position"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Rule/Structure.php#L484-L497
|
11,624
|
webriq/core
|
module/Customize/src/Grid/Customize/Model/Rule/Structure.php
|
Structure.getPropertyNames
|
public function getPropertyNames()
{
$result = array();
foreach ( $this->getRawPropertyNames() as $rawName )
{
$result[] = String::camelize( $rawName );
}
return $result;
}
|
php
|
public function getPropertyNames()
{
$result = array();
foreach ( $this->getRawPropertyNames() as $rawName )
{
$result[] = String::camelize( $rawName );
}
return $result;
}
|
[
"public",
"function",
"getPropertyNames",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getRawPropertyNames",
"(",
")",
"as",
"$",
"rawName",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"String",
"::",
"camelize",
"(",
"$",
"rawName",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get property names
@return array
|
[
"Get",
"property",
"names"
] |
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
|
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Customize/src/Grid/Customize/Model/Rule/Structure.php#L585-L595
|
11,625
|
axypro/callbacks
|
Callback.php
|
Callback.call
|
public static function call($callback, array $args = null)
{
$callback = Helper::toNative($callback);
if ($callback['bind']) {
$native = $callback['native'];
$first = $native[0];
if (is_object($first)) {
$callback = Helper::bindInstance($first, $native[1], $callback['args']);
} elseif (is_string($first)) {
$callback = Helper::bindStatic($first, $native[1], $callback['args']);
} else {
throw new InvalidFormat('Invalid callback for bind context');
}
} else {
$args = array_merge($callback['args'], $args ?: []);
$callback = $callback['native'];
if (!is_callable($callback, false)) {
throw new NotCallable();
}
}
return call_user_func_array($callback, $args ?: []);
}
|
php
|
public static function call($callback, array $args = null)
{
$callback = Helper::toNative($callback);
if ($callback['bind']) {
$native = $callback['native'];
$first = $native[0];
if (is_object($first)) {
$callback = Helper::bindInstance($first, $native[1], $callback['args']);
} elseif (is_string($first)) {
$callback = Helper::bindStatic($first, $native[1], $callback['args']);
} else {
throw new InvalidFormat('Invalid callback for bind context');
}
} else {
$args = array_merge($callback['args'], $args ?: []);
$callback = $callback['native'];
if (!is_callable($callback, false)) {
throw new NotCallable();
}
}
return call_user_func_array($callback, $args ?: []);
}
|
[
"public",
"static",
"function",
"call",
"(",
"$",
"callback",
",",
"array",
"$",
"args",
"=",
"null",
")",
"{",
"$",
"callback",
"=",
"Helper",
"::",
"toNative",
"(",
"$",
"callback",
")",
";",
"if",
"(",
"$",
"callback",
"[",
"'bind'",
"]",
")",
"{",
"$",
"native",
"=",
"$",
"callback",
"[",
"'native'",
"]",
";",
"$",
"first",
"=",
"$",
"native",
"[",
"0",
"]",
";",
"if",
"(",
"is_object",
"(",
"$",
"first",
")",
")",
"{",
"$",
"callback",
"=",
"Helper",
"::",
"bindInstance",
"(",
"$",
"first",
",",
"$",
"native",
"[",
"1",
"]",
",",
"$",
"callback",
"[",
"'args'",
"]",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"first",
")",
")",
"{",
"$",
"callback",
"=",
"Helper",
"::",
"bindStatic",
"(",
"$",
"first",
",",
"$",
"native",
"[",
"1",
"]",
",",
"$",
"callback",
"[",
"'args'",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidFormat",
"(",
"'Invalid callback for bind context'",
")",
";",
"}",
"}",
"else",
"{",
"$",
"args",
"=",
"array_merge",
"(",
"$",
"callback",
"[",
"'args'",
"]",
",",
"$",
"args",
"?",
":",
"[",
"]",
")",
";",
"$",
"callback",
"=",
"$",
"callback",
"[",
"'native'",
"]",
";",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
",",
"false",
")",
")",
"{",
"throw",
"new",
"NotCallable",
"(",
")",
";",
"}",
"}",
"return",
"call_user_func_array",
"(",
"$",
"callback",
",",
"$",
"args",
"?",
":",
"[",
"]",
")",
";",
"}"
] |
Executes a callback
@param mixed $callback
a callback in the extended format
@param array $args [optional]
an argument list of the call
@return mixed
the result of the call
@throws \axy\callbacks\errors\InvalidFormat
invalid format of the callback
@throws \axy\callbacks\errors\NotCallable
the callback is not callable
|
[
"Executes",
"a",
"callback"
] |
210981a2a864aff696ef4e34ba856dc229c4ec8f
|
https://github.com/axypro/callbacks/blob/210981a2a864aff696ef4e34ba856dc229c4ec8f/Callback.php#L33-L54
|
11,626
|
axypro/callbacks
|
Callback.php
|
Callback.createNative
|
public static function createNative($callback, $forceObj = false)
{
$callback = Helper::toNative($callback);
if (empty($callback['args']) && (!$forceObj)) {
return $callback['native'];
}
return new self($callback['native'], $callback['args']);
}
|
php
|
public static function createNative($callback, $forceObj = false)
{
$callback = Helper::toNative($callback);
if (empty($callback['args']) && (!$forceObj)) {
return $callback['native'];
}
return new self($callback['native'], $callback['args']);
}
|
[
"public",
"static",
"function",
"createNative",
"(",
"$",
"callback",
",",
"$",
"forceObj",
"=",
"false",
")",
"{",
"$",
"callback",
"=",
"Helper",
"::",
"toNative",
"(",
"$",
"callback",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"callback",
"[",
"'args'",
"]",
")",
"&&",
"(",
"!",
"$",
"forceObj",
")",
")",
"{",
"return",
"$",
"callback",
"[",
"'native'",
"]",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"callback",
"[",
"'native'",
"]",
",",
"$",
"callback",
"[",
"'args'",
"]",
")",
";",
"}"
] |
Creates a native callback
@param mixed $callback
an extended callback
@param boolean $forceObj [optional]
create a Callback instance in any case
@return \axy\callbacks\Callback
a callback in native format
@throws \axy\callbacks\errors\InvalidFormat
invalid format of the callback
|
[
"Creates",
"a",
"native",
"callback"
] |
210981a2a864aff696ef4e34ba856dc229c4ec8f
|
https://github.com/axypro/callbacks/blob/210981a2a864aff696ef4e34ba856dc229c4ec8f/Callback.php#L68-L75
|
11,627
|
axypro/callbacks
|
Callback.php
|
Callback.isCallable
|
public function isCallable()
{
if ($this->isCallable === null) {
$this->isCallable = is_callable($this->native, false);
}
return $this->isCallable;
}
|
php
|
public function isCallable()
{
if ($this->isCallable === null) {
$this->isCallable = is_callable($this->native, false);
}
return $this->isCallable;
}
|
[
"public",
"function",
"isCallable",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isCallable",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"isCallable",
"=",
"is_callable",
"(",
"$",
"this",
"->",
"native",
",",
"false",
")",
";",
"}",
"return",
"$",
"this",
"->",
"isCallable",
";",
"}"
] |
Checks if the callback is callable
@return boolean
|
[
"Checks",
"if",
"the",
"callback",
"is",
"callable"
] |
210981a2a864aff696ef4e34ba856dc229c4ec8f
|
https://github.com/axypro/callbacks/blob/210981a2a864aff696ef4e34ba856dc229c4ec8f/Callback.php#L133-L139
|
11,628
|
pinnackl/Sophwork
|
dist/autoloader.php
|
Autoloader.autoload
|
public function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, dirname(__FILE__). DIRECTORY_SEPARATOR . $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
if(file_exists($fileName))
require $fileName;
}
|
php
|
public function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, dirname(__FILE__). DIRECTORY_SEPARATOR . $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
if(file_exists($fileName))
require $fileName;
}
|
[
"public",
"function",
"autoload",
"(",
"$",
"className",
")",
"{",
"$",
"className",
"=",
"ltrim",
"(",
"$",
"className",
",",
"'\\\\'",
")",
";",
"$",
"fileName",
"=",
"''",
";",
"$",
"namespace",
"=",
"''",
";",
"if",
"(",
"$",
"lastNsPos",
"=",
"strrpos",
"(",
"$",
"className",
",",
"'\\\\'",
")",
")",
"{",
"$",
"namespace",
"=",
"substr",
"(",
"$",
"className",
",",
"0",
",",
"$",
"lastNsPos",
")",
";",
"$",
"className",
"=",
"substr",
"(",
"$",
"className",
",",
"$",
"lastNsPos",
"+",
"1",
")",
";",
"$",
"fileName",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"DIRECTORY_SEPARATOR",
",",
"dirname",
"(",
"__FILE__",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"namespace",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"}",
"$",
"fileName",
".=",
"str_replace",
"(",
"'_'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"className",
")",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"require",
"$",
"fileName",
";",
"}"
] |
Sophwork system autoloader
@param Object $className
@return node
|
[
"Sophwork",
"system",
"autoloader"
] |
53f55905fd06ccb87669c2824152a2a642902f78
|
https://github.com/pinnackl/Sophwork/blob/53f55905fd06ccb87669c2824152a2a642902f78/dist/autoloader.php#L42-L55
|
11,629
|
pinnackl/Sophwork
|
dist/autoloader.php
|
Autoloader.thirdPartyAutoload
|
public function thirdPartyAutoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $this->sources . DIRECTORY_SEPARATOR . $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
if(file_exists($fileName))
require $fileName;
}
|
php
|
public function thirdPartyAutoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $this->sources . DIRECTORY_SEPARATOR . $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
if(file_exists($fileName))
require $fileName;
}
|
[
"public",
"function",
"thirdPartyAutoload",
"(",
"$",
"className",
")",
"{",
"$",
"className",
"=",
"ltrim",
"(",
"$",
"className",
",",
"'\\\\'",
")",
";",
"$",
"fileName",
"=",
"''",
";",
"$",
"namespace",
"=",
"''",
";",
"if",
"(",
"$",
"lastNsPos",
"=",
"strrpos",
"(",
"$",
"className",
",",
"'\\\\'",
")",
")",
"{",
"$",
"namespace",
"=",
"substr",
"(",
"$",
"className",
",",
"0",
",",
"$",
"lastNsPos",
")",
";",
"$",
"className",
"=",
"substr",
"(",
"$",
"className",
",",
"$",
"lastNsPos",
"+",
"1",
")",
";",
"$",
"fileName",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"this",
"->",
"sources",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"namespace",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"}",
"$",
"fileName",
".=",
"str_replace",
"(",
"'_'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"className",
")",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"require",
"$",
"fileName",
";",
"}"
] |
Third party autoloader
@param Object $className
@return none
|
[
"Third",
"party",
"autoloader"
] |
53f55905fd06ccb87669c2824152a2a642902f78
|
https://github.com/pinnackl/Sophwork/blob/53f55905fd06ccb87669c2824152a2a642902f78/dist/autoloader.php#L62-L75
|
11,630
|
AnonymPHP/Anonym-Library
|
src/Anonym/Crypt/McryptCipher.php
|
McryptCipher.createIvSizeAndIvString
|
private function createIvSizeAndIvString()
{
$ivSize = mcrypt_get_iv_size($this->algorithm, $this->mode);
return mcrypt_create_iv($ivSize, $this->rand);
}
|
php
|
private function createIvSizeAndIvString()
{
$ivSize = mcrypt_get_iv_size($this->algorithm, $this->mode);
return mcrypt_create_iv($ivSize, $this->rand);
}
|
[
"private",
"function",
"createIvSizeAndIvString",
"(",
")",
"{",
"$",
"ivSize",
"=",
"mcrypt_get_iv_size",
"(",
"$",
"this",
"->",
"algorithm",
",",
"$",
"this",
"->",
"mode",
")",
";",
"return",
"mcrypt_create_iv",
"(",
"$",
"ivSize",
",",
"$",
"this",
"->",
"rand",
")",
";",
"}"
] |
create your special iv value
@return string
|
[
"create",
"your",
"special",
"iv",
"value"
] |
c967ad804f84e8fb204593a0959cda2fed5ae075
|
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Crypt/McryptCipher.php#L80-L85
|
11,631
|
laradic/service-provider
|
src/Plugins/Config.php
|
Config.startConfigPlugin
|
protected function startConfigPlugin($app)
{
$this->getVariables['config'] = function () {
return $this->app->make('config');
};
$this->requiresPlugins(Resources::class, Paths::class);
$this->onRegister('config', function ($app) {
$this->registerConfigFiles();
});
$this->onBoot('config', function ($app) {
$this->bootConfigFiles();
});
}
|
php
|
protected function startConfigPlugin($app)
{
$this->getVariables['config'] = function () {
return $this->app->make('config');
};
$this->requiresPlugins(Resources::class, Paths::class);
$this->onRegister('config', function ($app) {
$this->registerConfigFiles();
});
$this->onBoot('config', function ($app) {
$this->bootConfigFiles();
});
}
|
[
"protected",
"function",
"startConfigPlugin",
"(",
"$",
"app",
")",
"{",
"$",
"this",
"->",
"getVariables",
"[",
"'config'",
"]",
"=",
"function",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'config'",
")",
";",
"}",
";",
"$",
"this",
"->",
"requiresPlugins",
"(",
"Resources",
"::",
"class",
",",
"Paths",
"::",
"class",
")",
";",
"$",
"this",
"->",
"onRegister",
"(",
"'config'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"this",
"->",
"registerConfigFiles",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"onBoot",
"(",
"'config'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"this",
"->",
"bootConfigFiles",
"(",
")",
";",
"}",
")",
";",
"}"
] |
bootConfigPlugin method.
@param Application $app
|
[
"bootConfigPlugin",
"method",
"."
] |
b1428d566b97b3662b405c64ff0cad8a89102033
|
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/Plugins/Config.php#L37-L50
|
11,632
|
nicholasnet/common
|
src/Utils/ProcessManager.php
|
ProcessManager.getIterator
|
private function getIterator($value)
{
if ($value instanceof \Iterator) {
return $value;
}
if (is_array($value)) {
return new \ArrayIterator($value);
}
return new \ArrayIterator([$value]);
}
|
php
|
private function getIterator($value)
{
if ($value instanceof \Iterator) {
return $value;
}
if (is_array($value)) {
return new \ArrayIterator($value);
}
return new \ArrayIterator([$value]);
}
|
[
"private",
"function",
"getIterator",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"Iterator",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"new",
"\\",
"ArrayIterator",
"(",
"$",
"value",
")",
";",
"}",
"return",
"new",
"\\",
"ArrayIterator",
"(",
"[",
"$",
"value",
"]",
")",
";",
"}"
] |
Returns an iterator for the given value.
@param mixed $value
@return \Iterator
|
[
"Returns",
"an",
"iterator",
"for",
"the",
"given",
"value",
"."
] |
8b948592ecf2a3a9060d05d04f12e30058dabf3f
|
https://github.com/nicholasnet/common/blob/8b948592ecf2a3a9060d05d04f12e30058dabf3f/src/Utils/ProcessManager.php#L68-L81
|
11,633
|
nicholasnet/common
|
src/Utils/ProcessManager.php
|
ProcessManager.run
|
public function run()
{
$this->addPending();
$this->ran = true;
while (count($this->inProcess) !== 0) {
$this->monitorPending();
}
// Clear the references for callbacks.
$this->onSuccess = null;
$this->onError = null;
}
|
php
|
public function run()
{
$this->addPending();
$this->ran = true;
while (count($this->inProcess) !== 0) {
$this->monitorPending();
}
// Clear the references for callbacks.
$this->onSuccess = null;
$this->onError = null;
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"addPending",
"(",
")",
";",
"$",
"this",
"->",
"ran",
"=",
"true",
";",
"while",
"(",
"count",
"(",
"$",
"this",
"->",
"inProcess",
")",
"!==",
"0",
")",
"{",
"$",
"this",
"->",
"monitorPending",
"(",
")",
";",
"}",
"// Clear the references for callbacks.",
"$",
"this",
"->",
"onSuccess",
"=",
"null",
";",
"$",
"this",
"->",
"onError",
"=",
"null",
";",
"}"
] |
Executes the processes.
|
[
"Executes",
"the",
"processes",
"."
] |
8b948592ecf2a3a9060d05d04f12e30058dabf3f
|
https://github.com/nicholasnet/common/blob/8b948592ecf2a3a9060d05d04f12e30058dabf3f/src/Utils/ProcessManager.php#L125-L138
|
11,634
|
nicholasnet/common
|
src/Utils/ProcessManager.php
|
ProcessManager.addPending
|
private function addPending()
{
while (count($this->inProcess) < $this->concurrency) {
$item = $this->getUnprocessed();
if (empty($item)) {
break;
}
$this->inProcess[$item['index']] = $item['process'];
$item['process']->start();
if (count($this->inProcess) >= $this->concurrency) {
break;
}
}
}
|
php
|
private function addPending()
{
while (count($this->inProcess) < $this->concurrency) {
$item = $this->getUnprocessed();
if (empty($item)) {
break;
}
$this->inProcess[$item['index']] = $item['process'];
$item['process']->start();
if (count($this->inProcess) >= $this->concurrency) {
break;
}
}
}
|
[
"private",
"function",
"addPending",
"(",
")",
"{",
"while",
"(",
"count",
"(",
"$",
"this",
"->",
"inProcess",
")",
"<",
"$",
"this",
"->",
"concurrency",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"getUnprocessed",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"item",
")",
")",
"{",
"break",
";",
"}",
"$",
"this",
"->",
"inProcess",
"[",
"$",
"item",
"[",
"'index'",
"]",
"]",
"=",
"$",
"item",
"[",
"'process'",
"]",
";",
"$",
"item",
"[",
"'process'",
"]",
"->",
"start",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"inProcess",
")",
">=",
"$",
"this",
"->",
"concurrency",
")",
"{",
"break",
";",
"}",
"}",
"}"
] |
Adds the pending
|
[
"Adds",
"the",
"pending"
] |
8b948592ecf2a3a9060d05d04f12e30058dabf3f
|
https://github.com/nicholasnet/common/blob/8b948592ecf2a3a9060d05d04f12e30058dabf3f/src/Utils/ProcessManager.php#L143-L163
|
11,635
|
nicholasnet/common
|
src/Utils/ProcessManager.php
|
ProcessManager.monitorPending
|
private function monitorPending()
{
foreach ($this->inProcess as $index => $process) {
/** @var Process $process */
if ($process->isTerminated()) {
if ($process->isSuccessful()) {
call_user_func($this->onSuccess, $process->getOutput(), $index);
} else {
call_user_func($this->onError, $process->getErrorOutput(), $index);
}
unset($this->inProcess[$index]);
$this->addPending();
}
}
}
|
php
|
private function monitorPending()
{
foreach ($this->inProcess as $index => $process) {
/** @var Process $process */
if ($process->isTerminated()) {
if ($process->isSuccessful()) {
call_user_func($this->onSuccess, $process->getOutput(), $index);
} else {
call_user_func($this->onError, $process->getErrorOutput(), $index);
}
unset($this->inProcess[$index]);
$this->addPending();
}
}
}
|
[
"private",
"function",
"monitorPending",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"inProcess",
"as",
"$",
"index",
"=>",
"$",
"process",
")",
"{",
"/** @var Process $process */",
"if",
"(",
"$",
"process",
"->",
"isTerminated",
"(",
")",
")",
"{",
"if",
"(",
"$",
"process",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"call_user_func",
"(",
"$",
"this",
"->",
"onSuccess",
",",
"$",
"process",
"->",
"getOutput",
"(",
")",
",",
"$",
"index",
")",
";",
"}",
"else",
"{",
"call_user_func",
"(",
"$",
"this",
"->",
"onError",
",",
"$",
"process",
"->",
"getErrorOutput",
"(",
")",
",",
"$",
"index",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"inProcess",
"[",
"$",
"index",
"]",
")",
";",
"$",
"this",
"->",
"addPending",
"(",
")",
";",
"}",
"}",
"}"
] |
Monitors the pending process.
|
[
"Monitors",
"the",
"pending",
"process",
"."
] |
8b948592ecf2a3a9060d05d04f12e30058dabf3f
|
https://github.com/nicholasnet/common/blob/8b948592ecf2a3a9060d05d04f12e30058dabf3f/src/Utils/ProcessManager.php#L193-L214
|
11,636
|
bkdotcom/Toolbox
|
src/Pdf.php
|
Pdf.blockNameTrans
|
private function blockNameTrans($name, $block, &$opts)
{
$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
$func = $opts['name_trans_func'][0];
$params = array_slice($opts['name_trans_func'], 1);
$strObj = new Str();
if (!isset($opts['trans_func_params_sub'])) {
$opts['trans_func_params_sub'] = array();
foreach ($params as $k => $v) {
$params[$k] = $strObj->quickTemp($v, $block);
if ($params[$k] != $v) {
$opts['trans_func_params_sub'][] = $k;
}
}
} else {
foreach ($opts['trans_func_params_sub'] as $k) {
$params[$k] = $strObj->quickTemp($params[$k], $block);
}
}
$name_new = call_user_func_array($func, $params);
$this->debug->groupEnd();
return $name_new;
}
|
php
|
private function blockNameTrans($name, $block, &$opts)
{
$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
$func = $opts['name_trans_func'][0];
$params = array_slice($opts['name_trans_func'], 1);
$strObj = new Str();
if (!isset($opts['trans_func_params_sub'])) {
$opts['trans_func_params_sub'] = array();
foreach ($params as $k => $v) {
$params[$k] = $strObj->quickTemp($v, $block);
if ($params[$k] != $v) {
$opts['trans_func_params_sub'][] = $k;
}
}
} else {
foreach ($opts['trans_func_params_sub'] as $k) {
$params[$k] = $strObj->quickTemp($params[$k], $block);
}
}
$name_new = call_user_func_array($func, $params);
$this->debug->groupEnd();
return $name_new;
}
|
[
"private",
"function",
"blockNameTrans",
"(",
"$",
"name",
",",
"$",
"block",
",",
"&",
"$",
"opts",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"groupCollapsed",
"(",
"__CLASS__",
".",
"'->'",
".",
"__FUNCTION__",
")",
";",
"$",
"func",
"=",
"$",
"opts",
"[",
"'name_trans_func'",
"]",
"[",
"0",
"]",
";",
"$",
"params",
"=",
"array_slice",
"(",
"$",
"opts",
"[",
"'name_trans_func'",
"]",
",",
"1",
")",
";",
"$",
"strObj",
"=",
"new",
"Str",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"opts",
"[",
"'trans_func_params_sub'",
"]",
")",
")",
"{",
"$",
"opts",
"[",
"'trans_func_params_sub'",
"]",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"params",
"[",
"$",
"k",
"]",
"=",
"$",
"strObj",
"->",
"quickTemp",
"(",
"$",
"v",
",",
"$",
"block",
")",
";",
"if",
"(",
"$",
"params",
"[",
"$",
"k",
"]",
"!=",
"$",
"v",
")",
"{",
"$",
"opts",
"[",
"'trans_func_params_sub'",
"]",
"[",
"]",
"=",
"$",
"k",
";",
"}",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"opts",
"[",
"'trans_func_params_sub'",
"]",
"as",
"$",
"k",
")",
"{",
"$",
"params",
"[",
"$",
"k",
"]",
"=",
"$",
"strObj",
"->",
"quickTemp",
"(",
"$",
"params",
"[",
"$",
"k",
"]",
",",
"$",
"block",
")",
";",
"}",
"}",
"$",
"name_new",
"=",
"call_user_func_array",
"(",
"$",
"func",
",",
"$",
"params",
")",
";",
"$",
"this",
"->",
"debug",
"->",
"groupEnd",
"(",
")",
";",
"return",
"$",
"name_new",
";",
"}"
] |
attempt to transform the block name
@param string $name name
@param array $block block as returned by getBlocks() and getProperties()
@param array $opts options
@return string
|
[
"attempt",
"to",
"transform",
"the",
"block",
"name"
] |
2f9d34fd57bd8382baee4c29aac13a6710e3a994
|
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Pdf.php#L73-L95
|
11,637
|
bkdotcom/Toolbox
|
src/Pdf.php
|
Pdf.fillText
|
private function fillText($page, $block, $value, $fillOpts = array())
{
$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__, $block['Name'], $value);
$p = $this->p;
$opts['fillcolor'] = $fillOpts['fillcolor'];
if (!empty($block['Custom']['PDFlib:field:type'])
&& in_array($block['Custom']['PDFlib:field:type'], array('checkbox','radiobutton'))
) {
$field_type = $block['Custom']['PDFlib:field:type'];
$value_block = $block['Custom']['PDFlib:field:value'];
#$this->debug->log('type', $field_type);
#$this->debug->log('value_block', $value_block);
#$this->debug->log('value', $value);
if ($field_type == 'checkbox') {
$opts = array_merge($opts, $fillOpts['checkbox_opts']);
#$this->debug->log('checkbox_opts', $opts);
if ($value == $value_block || is_array($value) && in_array($value_block, $value)) {
$value = $fillOpts['checkbox_value'];
}
} else {
$opts = array_merge($opts, $fillOpts['radio_opts']);
#$this->debug->log('radio_opts', $opts);
if ($value == $value_block) {
$value = $fillOpts['radio_value'];
}
}
if (!$value) {
$opts['textformat'] = null;
$value = ' '; // gives the border
}
} else {
$opts = array_merge($opts, $fillOpts['text_opts']);
}
/*
@todo - better determination of if font is embedded or avail -> better fallback choice
*/
/*
$fontname = !empty($opts['fontname'])
? $opts['fontname']
: $block['fontname'];
if ( !in_array($fontname, $this->embeddedFonts) ) {
$this->debug->info(font not embedded', $fontname);
$opts['fallbackfonts'] = '{{fontname=Courier encoding=unicode}}';
}
*/
// $opts['fontname'] = 'Courier';
$this->debug->log($block['Name'], $value, $this->stringifyOpts($opts));
$ret = $p->fill_textblock($page, $block['Name'], $value, $this->stringifyOpts($opts));
if ($ret == 0) {
// try again with a different font
$opts['fontname'] = 'Courier';
$ret = $p->fill_textblock($page, $block['Name'], $value, $this->stringifyOpts($opts));
}
$this->debug->groupEnd();
}
|
php
|
private function fillText($page, $block, $value, $fillOpts = array())
{
$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__, $block['Name'], $value);
$p = $this->p;
$opts['fillcolor'] = $fillOpts['fillcolor'];
if (!empty($block['Custom']['PDFlib:field:type'])
&& in_array($block['Custom']['PDFlib:field:type'], array('checkbox','radiobutton'))
) {
$field_type = $block['Custom']['PDFlib:field:type'];
$value_block = $block['Custom']['PDFlib:field:value'];
#$this->debug->log('type', $field_type);
#$this->debug->log('value_block', $value_block);
#$this->debug->log('value', $value);
if ($field_type == 'checkbox') {
$opts = array_merge($opts, $fillOpts['checkbox_opts']);
#$this->debug->log('checkbox_opts', $opts);
if ($value == $value_block || is_array($value) && in_array($value_block, $value)) {
$value = $fillOpts['checkbox_value'];
}
} else {
$opts = array_merge($opts, $fillOpts['radio_opts']);
#$this->debug->log('radio_opts', $opts);
if ($value == $value_block) {
$value = $fillOpts['radio_value'];
}
}
if (!$value) {
$opts['textformat'] = null;
$value = ' '; // gives the border
}
} else {
$opts = array_merge($opts, $fillOpts['text_opts']);
}
/*
@todo - better determination of if font is embedded or avail -> better fallback choice
*/
/*
$fontname = !empty($opts['fontname'])
? $opts['fontname']
: $block['fontname'];
if ( !in_array($fontname, $this->embeddedFonts) ) {
$this->debug->info(font not embedded', $fontname);
$opts['fallbackfonts'] = '{{fontname=Courier encoding=unicode}}';
}
*/
// $opts['fontname'] = 'Courier';
$this->debug->log($block['Name'], $value, $this->stringifyOpts($opts));
$ret = $p->fill_textblock($page, $block['Name'], $value, $this->stringifyOpts($opts));
if ($ret == 0) {
// try again with a different font
$opts['fontname'] = 'Courier';
$ret = $p->fill_textblock($page, $block['Name'], $value, $this->stringifyOpts($opts));
}
$this->debug->groupEnd();
}
|
[
"private",
"function",
"fillText",
"(",
"$",
"page",
",",
"$",
"block",
",",
"$",
"value",
",",
"$",
"fillOpts",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"groupCollapsed",
"(",
"__CLASS__",
".",
"'->'",
".",
"__FUNCTION__",
",",
"$",
"block",
"[",
"'Name'",
"]",
",",
"$",
"value",
")",
";",
"$",
"p",
"=",
"$",
"this",
"->",
"p",
";",
"$",
"opts",
"[",
"'fillcolor'",
"]",
"=",
"$",
"fillOpts",
"[",
"'fillcolor'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"block",
"[",
"'Custom'",
"]",
"[",
"'PDFlib:field:type'",
"]",
")",
"&&",
"in_array",
"(",
"$",
"block",
"[",
"'Custom'",
"]",
"[",
"'PDFlib:field:type'",
"]",
",",
"array",
"(",
"'checkbox'",
",",
"'radiobutton'",
")",
")",
")",
"{",
"$",
"field_type",
"=",
"$",
"block",
"[",
"'Custom'",
"]",
"[",
"'PDFlib:field:type'",
"]",
";",
"$",
"value_block",
"=",
"$",
"block",
"[",
"'Custom'",
"]",
"[",
"'PDFlib:field:value'",
"]",
";",
"#$this->debug->log('type', $field_type);",
"#$this->debug->log('value_block', $value_block);",
"#$this->debug->log('value', $value);",
"if",
"(",
"$",
"field_type",
"==",
"'checkbox'",
")",
"{",
"$",
"opts",
"=",
"array_merge",
"(",
"$",
"opts",
",",
"$",
"fillOpts",
"[",
"'checkbox_opts'",
"]",
")",
";",
"#$this->debug->log('checkbox_opts', $opts);",
"if",
"(",
"$",
"value",
"==",
"$",
"value_block",
"||",
"is_array",
"(",
"$",
"value",
")",
"&&",
"in_array",
"(",
"$",
"value_block",
",",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"fillOpts",
"[",
"'checkbox_value'",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"opts",
"=",
"array_merge",
"(",
"$",
"opts",
",",
"$",
"fillOpts",
"[",
"'radio_opts'",
"]",
")",
";",
"#$this->debug->log('radio_opts', $opts);",
"if",
"(",
"$",
"value",
"==",
"$",
"value_block",
")",
"{",
"$",
"value",
"=",
"$",
"fillOpts",
"[",
"'radio_value'",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"$",
"opts",
"[",
"'textformat'",
"]",
"=",
"null",
";",
"$",
"value",
"=",
"' '",
";",
"// gives the border",
"}",
"}",
"else",
"{",
"$",
"opts",
"=",
"array_merge",
"(",
"$",
"opts",
",",
"$",
"fillOpts",
"[",
"'text_opts'",
"]",
")",
";",
"}",
"/*\n\t\t\t@todo - better determination of if font is embedded or avail -> better fallback choice\n\t\t*/",
"/*\n\t\t$fontname = !empty($opts['fontname'])\n\t\t\t? $opts['fontname']\n\t\t\t: $block['fontname'];\n\t\tif ( !in_array($fontname, $this->embeddedFonts) ) {\n\t\t\t$this->debug->info(font not embedded', $fontname);\n\t\t\t$opts['fallbackfonts'] = '{{fontname=Courier encoding=unicode}}';\n\t\t}\n\t\t*/",
"// $opts['fontname'] = 'Courier';",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"$",
"block",
"[",
"'Name'",
"]",
",",
"$",
"value",
",",
"$",
"this",
"->",
"stringifyOpts",
"(",
"$",
"opts",
")",
")",
";",
"$",
"ret",
"=",
"$",
"p",
"->",
"fill_textblock",
"(",
"$",
"page",
",",
"$",
"block",
"[",
"'Name'",
"]",
",",
"$",
"value",
",",
"$",
"this",
"->",
"stringifyOpts",
"(",
"$",
"opts",
")",
")",
";",
"if",
"(",
"$",
"ret",
"==",
"0",
")",
"{",
"// try again with a different font",
"$",
"opts",
"[",
"'fontname'",
"]",
"=",
"'Courier'",
";",
"$",
"ret",
"=",
"$",
"p",
"->",
"fill_textblock",
"(",
"$",
"page",
",",
"$",
"block",
"[",
"'Name'",
"]",
",",
"$",
"value",
",",
"$",
"this",
"->",
"stringifyOpts",
"(",
"$",
"opts",
")",
")",
";",
"}",
"$",
"this",
"->",
"debug",
"->",
"groupEnd",
"(",
")",
";",
"}"
] |
fill text block
@param integer $page page
@param array $block block
@param string $value value
@param array $fillOpts options
@return void
|
[
"fill",
"text",
"block"
] |
2f9d34fd57bd8382baee4c29aac13a6710e3a994
|
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Pdf.php#L293-L347
|
11,638
|
bkdotcom/Toolbox
|
src/Pdf.php
|
Pdf.getBlocks
|
public function getBlocks($pdiNo, $opts = array())
{
$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
$p = $this->p;
$arrayUtil = new ArrayUtil();
$opts = array_merge(array(
'page' => null,
'props' => array(), // the properties to return (or all if empty)
), $opts);
#debug('opts', $opts);
$blocks = array();
try {
if ($opts['page'] === null) {
$this->debug->log('get blocks for all pages');
$page_count = $p->pcos_get_number($pdiNo, '/Root/Pages/Count');
$page_start = 0;
$page_end = $page_count - 1;
} else {
$page_start = $opts['page'];
$page_end = $opts['page'];
}
if (!empty($opts['props']) && !in_array('ID', $opts['props'])) {
$opts['props'][] = 'ID'; // need ID for sorting
}
for ($pageNo = $page_start; $pageNo <= $page_end; $pageNo++) {
$this->debug->log('pageNo', $pageNo);
$block_count = $p->pcos_get_number($pdiNo, 'length:pages['.$pageNo.']/blocks');
for ($i = 0; $i < $block_count; $i++) {
$path = 'pages['.$pageNo.']/blocks['.$i.']';
$block = $this->getProperties($pdiNo, $path, $opts);
$block['page'] = $pageNo;
#$this->debug->log('block',$block);
$blocks[ $block['Name'] ] = $block;
}
}
} catch ( PDFlibException $e ) {
$this->debug->warn('exception: '.$e->faultcode.', faultstring: '.$e->faultstring);
}
$blocks = $arrayUtil->fieldSort($blocks, array('page','ID'));
$this->debug->log('blocks', $blocks);
$this->debug->groupEnd();
return $blocks;
}
|
php
|
public function getBlocks($pdiNo, $opts = array())
{
$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
$p = $this->p;
$arrayUtil = new ArrayUtil();
$opts = array_merge(array(
'page' => null,
'props' => array(), // the properties to return (or all if empty)
), $opts);
#debug('opts', $opts);
$blocks = array();
try {
if ($opts['page'] === null) {
$this->debug->log('get blocks for all pages');
$page_count = $p->pcos_get_number($pdiNo, '/Root/Pages/Count');
$page_start = 0;
$page_end = $page_count - 1;
} else {
$page_start = $opts['page'];
$page_end = $opts['page'];
}
if (!empty($opts['props']) && !in_array('ID', $opts['props'])) {
$opts['props'][] = 'ID'; // need ID for sorting
}
for ($pageNo = $page_start; $pageNo <= $page_end; $pageNo++) {
$this->debug->log('pageNo', $pageNo);
$block_count = $p->pcos_get_number($pdiNo, 'length:pages['.$pageNo.']/blocks');
for ($i = 0; $i < $block_count; $i++) {
$path = 'pages['.$pageNo.']/blocks['.$i.']';
$block = $this->getProperties($pdiNo, $path, $opts);
$block['page'] = $pageNo;
#$this->debug->log('block',$block);
$blocks[ $block['Name'] ] = $block;
}
}
} catch ( PDFlibException $e ) {
$this->debug->warn('exception: '.$e->faultcode.', faultstring: '.$e->faultstring);
}
$blocks = $arrayUtil->fieldSort($blocks, array('page','ID'));
$this->debug->log('blocks', $blocks);
$this->debug->groupEnd();
return $blocks;
}
|
[
"public",
"function",
"getBlocks",
"(",
"$",
"pdiNo",
",",
"$",
"opts",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"groupCollapsed",
"(",
"__CLASS__",
".",
"'->'",
".",
"__FUNCTION__",
")",
";",
"$",
"p",
"=",
"$",
"this",
"->",
"p",
";",
"$",
"arrayUtil",
"=",
"new",
"ArrayUtil",
"(",
")",
";",
"$",
"opts",
"=",
"array_merge",
"(",
"array",
"(",
"'page'",
"=>",
"null",
",",
"'props'",
"=>",
"array",
"(",
")",
",",
"// the properties to return (or all if empty)",
")",
",",
"$",
"opts",
")",
";",
"#debug('opts', $opts);",
"$",
"blocks",
"=",
"array",
"(",
")",
";",
"try",
"{",
"if",
"(",
"$",
"opts",
"[",
"'page'",
"]",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'get blocks for all pages'",
")",
";",
"$",
"page_count",
"=",
"$",
"p",
"->",
"pcos_get_number",
"(",
"$",
"pdiNo",
",",
"'/Root/Pages/Count'",
")",
";",
"$",
"page_start",
"=",
"0",
";",
"$",
"page_end",
"=",
"$",
"page_count",
"-",
"1",
";",
"}",
"else",
"{",
"$",
"page_start",
"=",
"$",
"opts",
"[",
"'page'",
"]",
";",
"$",
"page_end",
"=",
"$",
"opts",
"[",
"'page'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"opts",
"[",
"'props'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"'ID'",
",",
"$",
"opts",
"[",
"'props'",
"]",
")",
")",
"{",
"$",
"opts",
"[",
"'props'",
"]",
"[",
"]",
"=",
"'ID'",
";",
"// need ID for sorting",
"}",
"for",
"(",
"$",
"pageNo",
"=",
"$",
"page_start",
";",
"$",
"pageNo",
"<=",
"$",
"page_end",
";",
"$",
"pageNo",
"++",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'pageNo'",
",",
"$",
"pageNo",
")",
";",
"$",
"block_count",
"=",
"$",
"p",
"->",
"pcos_get_number",
"(",
"$",
"pdiNo",
",",
"'length:pages['",
".",
"$",
"pageNo",
".",
"']/blocks'",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"block_count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"path",
"=",
"'pages['",
".",
"$",
"pageNo",
".",
"']/blocks['",
".",
"$",
"i",
".",
"']'",
";",
"$",
"block",
"=",
"$",
"this",
"->",
"getProperties",
"(",
"$",
"pdiNo",
",",
"$",
"path",
",",
"$",
"opts",
")",
";",
"$",
"block",
"[",
"'page'",
"]",
"=",
"$",
"pageNo",
";",
"#$this->debug->log('block',$block);",
"$",
"blocks",
"[",
"$",
"block",
"[",
"'Name'",
"]",
"]",
"=",
"$",
"block",
";",
"}",
"}",
"}",
"catch",
"(",
"PDFlibException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"warn",
"(",
"'exception: '",
".",
"$",
"e",
"->",
"faultcode",
".",
"', faultstring: '",
".",
"$",
"e",
"->",
"faultstring",
")",
";",
"}",
"$",
"blocks",
"=",
"$",
"arrayUtil",
"->",
"fieldSort",
"(",
"$",
"blocks",
",",
"array",
"(",
"'page'",
",",
"'ID'",
")",
")",
";",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'blocks'",
",",
"$",
"blocks",
")",
";",
"$",
"this",
"->",
"debug",
"->",
"groupEnd",
"(",
")",
";",
"return",
"$",
"blocks",
";",
"}"
] |
Get PDF blocks
@param integer $pdiNo document number
@param array $opts options
@return array
|
[
"Get",
"PDF",
"blocks"
] |
2f9d34fd57bd8382baee4c29aac13a6710e3a994
|
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Pdf.php#L357-L399
|
11,639
|
bkdotcom/Toolbox
|
src/Pdf.php
|
Pdf.getPDFlib
|
public function getPDFlib($opts = array())
{
$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
debug('opts', $opts);
$optsDefault = array(
'errorpolicy' => 'return', // This means we must check return values of load_font() etc.
'license' => null,
'textformat' => 'utf8',
// 'avoiddemostamp'=> true, // throws exception when true && invalid license
'SearchPath' => $_SERVER['DOCUMENT_ROOT'],
// 'escapesequence' => 'true',
);
$opts = array_merge($optsDefault, $opts);
if (empty($opts['license'])) {
if (isset($this->cfg['license'])) {
$opts['license'] = $this->cfg['license'];
} elseif (file_exists($this->cfg['licensefile'])) {
$this->debug->info('licensefile found', $this->cfg['licensefile']);
$opts['license'] = trim(file_get_contents($this->cfg['licensefile']));
}
}
$p = new \PDFlib();
$this->p = $p;
$pdflibVer = $p->get_parameter('version', 0);
$this->debug->info('pdflib version', $pdflibVer);
$this->debug->log('opts', $opts);
try {
if (version_compare($pdflibVer, '9.0.0', '>=')) {
$opt_string = $this->stringifyOpts($opts);
$response = $p->set_option($opt_string);
} else {
foreach ($opts as $k => $v) {
$response = $p->set_parameter($k, $v);
}
}
} catch ( PDFlibException $e ) {
trigger_error('PDFlib exception ['.$e->get_errnum().'] '.$e->get_apiname().' : '.$e->get_errmsg());
}
$this->debug->groupEnd();
return $p;
}
|
php
|
public function getPDFlib($opts = array())
{
$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
debug('opts', $opts);
$optsDefault = array(
'errorpolicy' => 'return', // This means we must check return values of load_font() etc.
'license' => null,
'textformat' => 'utf8',
// 'avoiddemostamp'=> true, // throws exception when true && invalid license
'SearchPath' => $_SERVER['DOCUMENT_ROOT'],
// 'escapesequence' => 'true',
);
$opts = array_merge($optsDefault, $opts);
if (empty($opts['license'])) {
if (isset($this->cfg['license'])) {
$opts['license'] = $this->cfg['license'];
} elseif (file_exists($this->cfg['licensefile'])) {
$this->debug->info('licensefile found', $this->cfg['licensefile']);
$opts['license'] = trim(file_get_contents($this->cfg['licensefile']));
}
}
$p = new \PDFlib();
$this->p = $p;
$pdflibVer = $p->get_parameter('version', 0);
$this->debug->info('pdflib version', $pdflibVer);
$this->debug->log('opts', $opts);
try {
if (version_compare($pdflibVer, '9.0.0', '>=')) {
$opt_string = $this->stringifyOpts($opts);
$response = $p->set_option($opt_string);
} else {
foreach ($opts as $k => $v) {
$response = $p->set_parameter($k, $v);
}
}
} catch ( PDFlibException $e ) {
trigger_error('PDFlib exception ['.$e->get_errnum().'] '.$e->get_apiname().' : '.$e->get_errmsg());
}
$this->debug->groupEnd();
return $p;
}
|
[
"public",
"function",
"getPDFlib",
"(",
"$",
"opts",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"groupCollapsed",
"(",
"__CLASS__",
".",
"'->'",
".",
"__FUNCTION__",
")",
";",
"debug",
"(",
"'opts'",
",",
"$",
"opts",
")",
";",
"$",
"optsDefault",
"=",
"array",
"(",
"'errorpolicy'",
"=>",
"'return'",
",",
"// This means we must check return values of load_font() etc.",
"'license'",
"=>",
"null",
",",
"'textformat'",
"=>",
"'utf8'",
",",
"// 'avoiddemostamp'=> true,\t\t\t// throws exception when true && invalid license",
"'SearchPath'",
"=>",
"$",
"_SERVER",
"[",
"'DOCUMENT_ROOT'",
"]",
",",
"// 'escapesequence'\t=> 'true',",
")",
";",
"$",
"opts",
"=",
"array_merge",
"(",
"$",
"optsDefault",
",",
"$",
"opts",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"opts",
"[",
"'license'",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'license'",
"]",
")",
")",
"{",
"$",
"opts",
"[",
"'license'",
"]",
"=",
"$",
"this",
"->",
"cfg",
"[",
"'license'",
"]",
";",
"}",
"elseif",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'licensefile'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"info",
"(",
"'licensefile found'",
",",
"$",
"this",
"->",
"cfg",
"[",
"'licensefile'",
"]",
")",
";",
"$",
"opts",
"[",
"'license'",
"]",
"=",
"trim",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'licensefile'",
"]",
")",
")",
";",
"}",
"}",
"$",
"p",
"=",
"new",
"\\",
"PDFlib",
"(",
")",
";",
"$",
"this",
"->",
"p",
"=",
"$",
"p",
";",
"$",
"pdflibVer",
"=",
"$",
"p",
"->",
"get_parameter",
"(",
"'version'",
",",
"0",
")",
";",
"$",
"this",
"->",
"debug",
"->",
"info",
"(",
"'pdflib version'",
",",
"$",
"pdflibVer",
")",
";",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'opts'",
",",
"$",
"opts",
")",
";",
"try",
"{",
"if",
"(",
"version_compare",
"(",
"$",
"pdflibVer",
",",
"'9.0.0'",
",",
"'>='",
")",
")",
"{",
"$",
"opt_string",
"=",
"$",
"this",
"->",
"stringifyOpts",
"(",
"$",
"opts",
")",
";",
"$",
"response",
"=",
"$",
"p",
"->",
"set_option",
"(",
"$",
"opt_string",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"opts",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"response",
"=",
"$",
"p",
"->",
"set_parameter",
"(",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"PDFlibException",
"$",
"e",
")",
"{",
"trigger_error",
"(",
"'PDFlib exception ['",
".",
"$",
"e",
"->",
"get_errnum",
"(",
")",
".",
"'] '",
".",
"$",
"e",
"->",
"get_apiname",
"(",
")",
".",
"' : '",
".",
"$",
"e",
"->",
"get_errmsg",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"debug",
"->",
"groupEnd",
"(",
")",
";",
"return",
"$",
"p",
";",
"}"
] |
Create & return PDFlib instance
@param array $opts options
@return object PDFlib
|
[
"Create",
"&",
"return",
"PDFlib",
"instance"
] |
2f9d34fd57bd8382baee4c29aac13a6710e3a994
|
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Pdf.php#L454-L494
|
11,640
|
bkdotcom/Toolbox
|
src/Pdf.php
|
Pdf.openPdf
|
public function openPdf($pdfTemplate)
{
$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
$p = $this->p;
$pdiOpts = 'errorpolicy=return';
if (is_object($pdfTemplate) || preg_match('/[\\x00-\\x1f]/', $pdfTemplate)) {
if (is_object($pdfTemplate)) {
$this->debug->log('pdfTemplate is object');
$p->create_pvf($this->pvf, $pdfTemplate->get_buffer(), '');
$pdfTemplate->delete();
} else {
$this->debug->log('pdfTemplate is raw pdf data');
$p->create_pvf($this->pvf, $pdfTemplate, '');
}
$pdfTemplate = null;
$pdiNo = $p->open_pdi_document($this->pvf, $pdiOpts);
} else {
$this->debug->log('pdfTemplate', $pdfTemplate);
$this->debug->log('file_exists', file_exists($pdfTemplate));
try {
$pdiNo = $p->open_pdi_document($pdfTemplate, $pdiOpts);
} catch ( PDFlibException $e ) {
trigger_error('PDFlib exception ['.$e->get_errnum().'] '.$e->get_apiname().' : '.$e->get_errmsg());
}
$this->debug->info('get_errmsg', $p->get_errmsg());
}
$this->debug->groupEnd();
return $pdiNo;
}
|
php
|
public function openPdf($pdfTemplate)
{
$this->debug->groupCollapsed(__CLASS__.'->'.__FUNCTION__);
$p = $this->p;
$pdiOpts = 'errorpolicy=return';
if (is_object($pdfTemplate) || preg_match('/[\\x00-\\x1f]/', $pdfTemplate)) {
if (is_object($pdfTemplate)) {
$this->debug->log('pdfTemplate is object');
$p->create_pvf($this->pvf, $pdfTemplate->get_buffer(), '');
$pdfTemplate->delete();
} else {
$this->debug->log('pdfTemplate is raw pdf data');
$p->create_pvf($this->pvf, $pdfTemplate, '');
}
$pdfTemplate = null;
$pdiNo = $p->open_pdi_document($this->pvf, $pdiOpts);
} else {
$this->debug->log('pdfTemplate', $pdfTemplate);
$this->debug->log('file_exists', file_exists($pdfTemplate));
try {
$pdiNo = $p->open_pdi_document($pdfTemplate, $pdiOpts);
} catch ( PDFlibException $e ) {
trigger_error('PDFlib exception ['.$e->get_errnum().'] '.$e->get_apiname().' : '.$e->get_errmsg());
}
$this->debug->info('get_errmsg', $p->get_errmsg());
}
$this->debug->groupEnd();
return $pdiNo;
}
|
[
"public",
"function",
"openPdf",
"(",
"$",
"pdfTemplate",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"groupCollapsed",
"(",
"__CLASS__",
".",
"'->'",
".",
"__FUNCTION__",
")",
";",
"$",
"p",
"=",
"$",
"this",
"->",
"p",
";",
"$",
"pdiOpts",
"=",
"'errorpolicy=return'",
";",
"if",
"(",
"is_object",
"(",
"$",
"pdfTemplate",
")",
"||",
"preg_match",
"(",
"'/[\\\\x00-\\\\x1f]/'",
",",
"$",
"pdfTemplate",
")",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"pdfTemplate",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'pdfTemplate is object'",
")",
";",
"$",
"p",
"->",
"create_pvf",
"(",
"$",
"this",
"->",
"pvf",
",",
"$",
"pdfTemplate",
"->",
"get_buffer",
"(",
")",
",",
"''",
")",
";",
"$",
"pdfTemplate",
"->",
"delete",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'pdfTemplate is raw pdf data'",
")",
";",
"$",
"p",
"->",
"create_pvf",
"(",
"$",
"this",
"->",
"pvf",
",",
"$",
"pdfTemplate",
",",
"''",
")",
";",
"}",
"$",
"pdfTemplate",
"=",
"null",
";",
"$",
"pdiNo",
"=",
"$",
"p",
"->",
"open_pdi_document",
"(",
"$",
"this",
"->",
"pvf",
",",
"$",
"pdiOpts",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'pdfTemplate'",
",",
"$",
"pdfTemplate",
")",
";",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'file_exists'",
",",
"file_exists",
"(",
"$",
"pdfTemplate",
")",
")",
";",
"try",
"{",
"$",
"pdiNo",
"=",
"$",
"p",
"->",
"open_pdi_document",
"(",
"$",
"pdfTemplate",
",",
"$",
"pdiOpts",
")",
";",
"}",
"catch",
"(",
"PDFlibException",
"$",
"e",
")",
"{",
"trigger_error",
"(",
"'PDFlib exception ['",
".",
"$",
"e",
"->",
"get_errnum",
"(",
")",
".",
"'] '",
".",
"$",
"e",
"->",
"get_apiname",
"(",
")",
".",
"' : '",
".",
"$",
"e",
"->",
"get_errmsg",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"debug",
"->",
"info",
"(",
"'get_errmsg'",
",",
"$",
"p",
"->",
"get_errmsg",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"debug",
"->",
"groupEnd",
"(",
")",
";",
"return",
"$",
"pdiNo",
";",
"}"
] |
Get PDI document
@param mixed $pdfTemplate input pdf filepath, raw pdf, or object
@return integer
|
[
"Get",
"PDI",
"document"
] |
2f9d34fd57bd8382baee4c29aac13a6710e3a994
|
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Pdf.php#L679-L707
|
11,641
|
bkdotcom/Toolbox
|
src/Pdf.php
|
Pdf.stringifyOpts
|
public function stringifyOpts($opts)
{
$pairs = array();
foreach ($opts as $k => $v) {
if (is_null($v)) {
continue;
}
if ($v === true) {
$pairs[] = $k;
} elseif ($v === false) {
$pairs[] = $k.'=false';
} else {
$pairs[] = $k.'='.$v;
}
}
return implode(' ', $pairs);
}
|
php
|
public function stringifyOpts($opts)
{
$pairs = array();
foreach ($opts as $k => $v) {
if (is_null($v)) {
continue;
}
if ($v === true) {
$pairs[] = $k;
} elseif ($v === false) {
$pairs[] = $k.'=false';
} else {
$pairs[] = $k.'='.$v;
}
}
return implode(' ', $pairs);
}
|
[
"public",
"function",
"stringifyOpts",
"(",
"$",
"opts",
")",
"{",
"$",
"pairs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"opts",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"v",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"v",
"===",
"true",
")",
"{",
"$",
"pairs",
"[",
"]",
"=",
"$",
"k",
";",
"}",
"elseif",
"(",
"$",
"v",
"===",
"false",
")",
"{",
"$",
"pairs",
"[",
"]",
"=",
"$",
"k",
".",
"'=false'",
";",
"}",
"else",
"{",
"$",
"pairs",
"[",
"]",
"=",
"$",
"k",
".",
"'='",
".",
"$",
"v",
";",
"}",
"}",
"return",
"implode",
"(",
"' '",
",",
"$",
"pairs",
")",
";",
"}"
] |
Create option string as used by pdflib
@param array $opts key/values to stringify
@return string
|
[
"Create",
"option",
"string",
"as",
"used",
"by",
"pdflib"
] |
2f9d34fd57bd8382baee4c29aac13a6710e3a994
|
https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Pdf.php#L716-L732
|
11,642
|
themichaelhall/bluemvc-core
|
src/Controller.php
|
Controller.setViewItem
|
public function setViewItem(string $name, $value): void
{
$this->viewItems->set($name, $value);
}
|
php
|
public function setViewItem(string $name, $value): void
{
$this->viewItems->set($name, $value);
}
|
[
"public",
"function",
"setViewItem",
"(",
"string",
"$",
"name",
",",
"$",
"value",
")",
":",
"void",
"{",
"$",
"this",
"->",
"viewItems",
"->",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}"
] |
Sets a view item.
@since 1.0.0
@param string $name The view item name.
@param mixed $value The view item value.
|
[
"Sets",
"a",
"view",
"item",
"."
] |
cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680
|
https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Controller.php#L114-L117
|
11,643
|
themichaelhall/bluemvc-core
|
src/Controller.php
|
Controller.getViewPath
|
protected function getViewPath(): string
{
$result = (new \ReflectionClass($this))->getShortName();
if (strlen($result) > 10 && substr(strtolower($result), -10) === 'controller') {
$result = substr($result, 0, -10);
}
return $result;
}
|
php
|
protected function getViewPath(): string
{
$result = (new \ReflectionClass($this))->getShortName();
if (strlen($result) > 10 && substr(strtolower($result), -10) === 'controller') {
$result = substr($result, 0, -10);
}
return $result;
}
|
[
"protected",
"function",
"getViewPath",
"(",
")",
":",
"string",
"{",
"$",
"result",
"=",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
")",
"->",
"getShortName",
"(",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"result",
")",
">",
"10",
"&&",
"substr",
"(",
"strtolower",
"(",
"$",
"result",
")",
",",
"-",
"10",
")",
"===",
"'controller'",
")",
"{",
"$",
"result",
"=",
"substr",
"(",
"$",
"result",
",",
"0",
",",
"-",
"10",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns the path to the view files.
@since 1.0.0
@return string The path to the view files.
|
[
"Returns",
"the",
"path",
"to",
"the",
"view",
"files",
"."
] |
cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680
|
https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Controller.php#L138-L146
|
11,644
|
themichaelhall/bluemvc-core
|
src/Controller.php
|
Controller.getActionName
|
private static function getActionName(string $action): string
{
if ($action === '') {
return 'index';
}
if (in_array(strtolower($action), self::$magicActionMethods)) {
return '_' . $action;
}
return $action;
}
|
php
|
private static function getActionName(string $action): string
{
if ($action === '') {
return 'index';
}
if (in_array(strtolower($action), self::$magicActionMethods)) {
return '_' . $action;
}
return $action;
}
|
[
"private",
"static",
"function",
"getActionName",
"(",
"string",
"$",
"action",
")",
":",
"string",
"{",
"if",
"(",
"$",
"action",
"===",
"''",
")",
"{",
"return",
"'index'",
";",
"}",
"if",
"(",
"in_array",
"(",
"strtolower",
"(",
"$",
"action",
")",
",",
"self",
"::",
"$",
"magicActionMethods",
")",
")",
"{",
"return",
"'_'",
".",
"$",
"action",
";",
"}",
"return",
"$",
"action",
";",
"}"
] |
Returns the action name for a specific action.
@param string $action The action.
@return string The action name.
|
[
"Returns",
"the",
"action",
"name",
"for",
"a",
"specific",
"action",
"."
] |
cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680
|
https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Controller.php#L195-L206
|
11,645
|
unyx/utils
|
math/Vector.php
|
Vector.zero
|
public static function zero(int $dimension = 0) : Vector
{
if ($dimension === 0) {
return new static([]);
}
if ($dimension < 0) {
throw new \InvalidArgumentException('Expected dimension to be at least 0, got ['.$dimension.'] instead.');
}
return new static(array_fill(0, $dimension, 0));
}
|
php
|
public static function zero(int $dimension = 0) : Vector
{
if ($dimension === 0) {
return new static([]);
}
if ($dimension < 0) {
throw new \InvalidArgumentException('Expected dimension to be at least 0, got ['.$dimension.'] instead.');
}
return new static(array_fill(0, $dimension, 0));
}
|
[
"public",
"static",
"function",
"zero",
"(",
"int",
"$",
"dimension",
"=",
"0",
")",
":",
"Vector",
"{",
"if",
"(",
"$",
"dimension",
"===",
"0",
")",
"{",
"return",
"new",
"static",
"(",
"[",
"]",
")",
";",
"}",
"if",
"(",
"$",
"dimension",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Expected dimension to be at least 0, got ['",
".",
"$",
"dimension",
".",
"'] instead.'",
")",
";",
"}",
"return",
"new",
"static",
"(",
"array_fill",
"(",
"0",
",",
"$",
"dimension",
",",
"0",
")",
")",
";",
"}"
] |
Creates a zero-length vector of the given dimension.
@param int $dimension The dimension of the Vector to create. Must be >= 0.
@return Vector A zero-length vector of the given dimension.
@throws \InvalidArgumentException When $dimension is less than 0.
|
[
"Creates",
"a",
"zero",
"-",
"length",
"vector",
"of",
"the",
"given",
"dimension",
"."
] |
503a3dd46fd2216024ab771b6e830be16d36b358
|
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/Vector.php#L50-L61
|
11,646
|
unyx/utils
|
math/Vector.php
|
Vector.abs
|
public function abs() : Vector
{
$result = [];
foreach ($this->components as $i => $component) {
$result[$i] = abs($component);
}
return new static($result);
}
|
php
|
public function abs() : Vector
{
$result = [];
foreach ($this->components as $i => $component) {
$result[$i] = abs($component);
}
return new static($result);
}
|
[
"public",
"function",
"abs",
"(",
")",
":",
"Vector",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"i",
"=>",
"$",
"component",
")",
"{",
"$",
"result",
"[",
"$",
"i",
"]",
"=",
"abs",
"(",
"$",
"component",
")",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"result",
")",
";",
"}"
] |
Returns the absolute value of this Vector as a new Vector instance.
@return Vector
|
[
"Returns",
"the",
"absolute",
"value",
"of",
"this",
"Vector",
"as",
"a",
"new",
"Vector",
"instance",
"."
] |
503a3dd46fd2216024ab771b6e830be16d36b358
|
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/Vector.php#L114-L123
|
11,647
|
unyx/utils
|
math/Vector.php
|
Vector.distance
|
public function distance(Vector $that, int $type = null) : float
{
if (null === $type) {
$type = static::$defaultDistanceType;
}
switch ($type) {
case self::DISTANCE_CARTESIAN:
return $this->cartesianDistanceTo($that);
case self::DISTANCE_CHEBYSHEV:
case self::DISTANCE_CHESSBOARD:
return $this->chebyshevDistanceTo($that);
case self::DISTANCE_TAXICAB:
case self::DISTANCE_MANHATTAN:
return $this->taxicabDistanceTo($that);
}
throw new \InvalidArgumentException('Unsupported distance type ['.$type.'] given.');
}
|
php
|
public function distance(Vector $that, int $type = null) : float
{
if (null === $type) {
$type = static::$defaultDistanceType;
}
switch ($type) {
case self::DISTANCE_CARTESIAN:
return $this->cartesianDistanceTo($that);
case self::DISTANCE_CHEBYSHEV:
case self::DISTANCE_CHESSBOARD:
return $this->chebyshevDistanceTo($that);
case self::DISTANCE_TAXICAB:
case self::DISTANCE_MANHATTAN:
return $this->taxicabDistanceTo($that);
}
throw new \InvalidArgumentException('Unsupported distance type ['.$type.'] given.');
}
|
[
"public",
"function",
"distance",
"(",
"Vector",
"$",
"that",
",",
"int",
"$",
"type",
"=",
"null",
")",
":",
"float",
"{",
"if",
"(",
"null",
"===",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"static",
"::",
"$",
"defaultDistanceType",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"self",
"::",
"DISTANCE_CARTESIAN",
":",
"return",
"$",
"this",
"->",
"cartesianDistanceTo",
"(",
"$",
"that",
")",
";",
"case",
"self",
"::",
"DISTANCE_CHEBYSHEV",
":",
"case",
"self",
"::",
"DISTANCE_CHESSBOARD",
":",
"return",
"$",
"this",
"->",
"chebyshevDistanceTo",
"(",
"$",
"that",
")",
";",
"case",
"self",
"::",
"DISTANCE_TAXICAB",
":",
"case",
"self",
"::",
"DISTANCE_MANHATTAN",
":",
"return",
"$",
"this",
"->",
"taxicabDistanceTo",
"(",
"$",
"that",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unsupported distance type ['",
".",
"$",
"type",
".",
"'] given.'",
")",
";",
"}"
] |
Returns the distance of this Vector to the given Vector.
@param Vector $that The Vector to calculate the distance to.
@param int|null $type The type of the distance (one of the DISTANCE_* class constants) or null
to use the value of the public static $defaultDistanceType (Cartesian
distance by default).
@return float The distance of the specified type.
@throws \InvalidArgumentException When an unsupported distance type was given.
|
[
"Returns",
"the",
"distance",
"of",
"this",
"Vector",
"to",
"the",
"given",
"Vector",
"."
] |
503a3dd46fd2216024ab771b6e830be16d36b358
|
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/Vector.php#L319-L339
|
11,648
|
unyx/utils
|
math/Vector.php
|
Vector.cartesianDistanceTo
|
public function cartesianDistanceTo(Vector $that) : float
{
if (!$this->isSameDimension($that)) {
throw new \DomainException('The given input Vector is not in the same dimension as this Vector.');
}
$result = 0;
foreach ($this->components as $i => $component) {
$result += pow($component - $that->components[$i], 2);
}
return sqrt($result);
}
|
php
|
public function cartesianDistanceTo(Vector $that) : float
{
if (!$this->isSameDimension($that)) {
throw new \DomainException('The given input Vector is not in the same dimension as this Vector.');
}
$result = 0;
foreach ($this->components as $i => $component) {
$result += pow($component - $that->components[$i], 2);
}
return sqrt($result);
}
|
[
"public",
"function",
"cartesianDistanceTo",
"(",
"Vector",
"$",
"that",
")",
":",
"float",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isSameDimension",
"(",
"$",
"that",
")",
")",
"{",
"throw",
"new",
"\\",
"DomainException",
"(",
"'The given input Vector is not in the same dimension as this Vector.'",
")",
";",
"}",
"$",
"result",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"i",
"=>",
"$",
"component",
")",
"{",
"$",
"result",
"+=",
"pow",
"(",
"$",
"component",
"-",
"$",
"that",
"->",
"components",
"[",
"$",
"i",
"]",
",",
"2",
")",
";",
"}",
"return",
"sqrt",
"(",
"$",
"result",
")",
";",
"}"
] |
Returns the cartesian distance of this Vector to the given Vector.
@param Vector $that The Vector to calculate the distance to.
@return float The cartesian distance.
@throws \DomainException When the given Vector is not in the same space as this Vector.
|
[
"Returns",
"the",
"cartesian",
"distance",
"of",
"this",
"Vector",
"to",
"the",
"given",
"Vector",
"."
] |
503a3dd46fd2216024ab771b6e830be16d36b358
|
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/Vector.php#L348-L361
|
11,649
|
unyx/utils
|
math/Vector.php
|
Vector.divide
|
public function divide(float $scale) : Vector
{
if ($scale == 0) {
throw new exceptions\DivisionByZero;
}
return $this->multiply(1.0 / $scale);
}
|
php
|
public function divide(float $scale) : Vector
{
if ($scale == 0) {
throw new exceptions\DivisionByZero;
}
return $this->multiply(1.0 / $scale);
}
|
[
"public",
"function",
"divide",
"(",
"float",
"$",
"scale",
")",
":",
"Vector",
"{",
"if",
"(",
"$",
"scale",
"==",
"0",
")",
"{",
"throw",
"new",
"exceptions",
"\\",
"DivisionByZero",
";",
"}",
"return",
"$",
"this",
"->",
"multiply",
"(",
"1.0",
"/",
"$",
"scale",
")",
";",
"}"
] |
Divides the Vector by the given scale and returns the result as a new Vector.
@param float $scale The scale to divide by.
@return Vector The result of the division.
@throws exceptions\DivisionByZero When $scale is 0.f.
|
[
"Divides",
"the",
"Vector",
"by",
"the",
"given",
"scale",
"and",
"returns",
"the",
"result",
"as",
"a",
"new",
"Vector",
"."
] |
503a3dd46fd2216024ab771b6e830be16d36b358
|
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/Vector.php#L414-L421
|
11,650
|
unyx/utils
|
math/Vector.php
|
Vector.length
|
public function length() : float
{
static $result;
return null !== $result ? $result : $result = sqrt($this->lengthSquared());
}
|
php
|
public function length() : float
{
static $result;
return null !== $result ? $result : $result = sqrt($this->lengthSquared());
}
|
[
"public",
"function",
"length",
"(",
")",
":",
"float",
"{",
"static",
"$",
"result",
";",
"return",
"null",
"!==",
"$",
"result",
"?",
"$",
"result",
":",
"$",
"result",
"=",
"sqrt",
"(",
"$",
"this",
"->",
"lengthSquared",
"(",
")",
")",
";",
"}"
] |
Returns the length of the Vector.
@return float
|
[
"Returns",
"the",
"length",
"of",
"the",
"Vector",
"."
] |
503a3dd46fd2216024ab771b6e830be16d36b358
|
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/Vector.php#L467-L472
|
11,651
|
unyx/utils
|
math/Vector.php
|
Vector.lengthSquared
|
public function lengthSquared() : float
{
static $result;
// Return the cached result if it's available.
if ($result !== null) {
return $result;
}
// Compute the square sum.
$sum = 0;
foreach ($this->components as $component) {
$sum += $component * $component;
}
return $result = $sum;
}
|
php
|
public function lengthSquared() : float
{
static $result;
// Return the cached result if it's available.
if ($result !== null) {
return $result;
}
// Compute the square sum.
$sum = 0;
foreach ($this->components as $component) {
$sum += $component * $component;
}
return $result = $sum;
}
|
[
"public",
"function",
"lengthSquared",
"(",
")",
":",
"float",
"{",
"static",
"$",
"result",
";",
"// Return the cached result if it's available.",
"if",
"(",
"$",
"result",
"!==",
"null",
")",
"{",
"return",
"$",
"result",
";",
"}",
"// Compute the square sum.",
"$",
"sum",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"component",
")",
"{",
"$",
"sum",
"+=",
"$",
"component",
"*",
"$",
"component",
";",
"}",
"return",
"$",
"result",
"=",
"$",
"sum",
";",
"}"
] |
Returns the square of the Vector's length.
@return float
|
[
"Returns",
"the",
"square",
"of",
"the",
"Vector",
"s",
"length",
"."
] |
503a3dd46fd2216024ab771b6e830be16d36b358
|
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/Vector.php#L479-L496
|
11,652
|
unyx/utils
|
math/Vector.php
|
Vector.multiply
|
public function multiply(float $scale) : Vector
{
$result = [];
foreach ($this->components as $i => $component) {
$result[$i] = $component * $scale;
}
return new static($result);
}
|
php
|
public function multiply(float $scale) : Vector
{
$result = [];
foreach ($this->components as $i => $component) {
$result[$i] = $component * $scale;
}
return new static($result);
}
|
[
"public",
"function",
"multiply",
"(",
"float",
"$",
"scale",
")",
":",
"Vector",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"i",
"=>",
"$",
"component",
")",
"{",
"$",
"result",
"[",
"$",
"i",
"]",
"=",
"$",
"component",
"*",
"$",
"scale",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"result",
")",
";",
"}"
] |
Multiplies the Vector by the given scale and returns the result as a new Vector.
@param float $scale The scale to multiply by.
@return Vector The result of the multiplication.
|
[
"Multiplies",
"the",
"Vector",
"by",
"the",
"given",
"scale",
"and",
"returns",
"the",
"result",
"as",
"a",
"new",
"Vector",
"."
] |
503a3dd46fd2216024ab771b6e830be16d36b358
|
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/Vector.php#L524-L533
|
11,653
|
unyx/utils
|
math/Vector.php
|
Vector.projectOnto
|
public function projectOnto(Vector $that) : Vector
{
$that = $that->normalize();
return $that->multiply($this->dotProduct($that));
}
|
php
|
public function projectOnto(Vector $that) : Vector
{
$that = $that->normalize();
return $that->multiply($this->dotProduct($that));
}
|
[
"public",
"function",
"projectOnto",
"(",
"Vector",
"$",
"that",
")",
":",
"Vector",
"{",
"$",
"that",
"=",
"$",
"that",
"->",
"normalize",
"(",
")",
";",
"return",
"$",
"that",
"->",
"multiply",
"(",
"$",
"this",
"->",
"dotProduct",
"(",
"$",
"that",
")",
")",
";",
"}"
] |
Projects this Vector onto another Vector.
@param Vector $that The vector to project this vector onto.
@return Vector
|
[
"Projects",
"this",
"Vector",
"onto",
"another",
"Vector",
"."
] |
503a3dd46fd2216024ab771b6e830be16d36b358
|
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/Vector.php#L552-L557
|
11,654
|
unyx/utils
|
math/Vector.php
|
Vector.reverse
|
public function reverse()
{
$result = [];
foreach ($this->components as $i => $component) {
$result[$i] = $component * -1;
}
return new static($result);
}
|
php
|
public function reverse()
{
$result = [];
foreach ($this->components as $i => $component) {
$result[$i] = $component * -1;
}
return new static($result);
}
|
[
"public",
"function",
"reverse",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"i",
"=>",
"$",
"component",
")",
"{",
"$",
"result",
"[",
"$",
"i",
"]",
"=",
"$",
"component",
"*",
"-",
"1",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"result",
")",
";",
"}"
] |
Reverses the direction of this Vector.
@return Vector
|
[
"Reverses",
"the",
"direction",
"of",
"this",
"Vector",
"."
] |
503a3dd46fd2216024ab771b6e830be16d36b358
|
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/math/Vector.php#L564-L573
|
11,655
|
kaecyra/app-common
|
src/Event/EventManager.php
|
EventManager.bind
|
public function bind(string $event, callable $callback) {
// We can't bind to something that isn't callable
if (!is_callable($callback)) {
return false;
}
if (!isset($this->bindings[$event]) || !is_array($this->bindings[$event])) {
$this->bindings[$event] = [];
}
// Check if this event is already registered
$signature = $this->hash($callback);
if (array_key_exists($signature, $this->bindings[$event])) {
return $signature;
}
$this->bindings[$event][$signature] = $callback;
return $signature;
}
|
php
|
public function bind(string $event, callable $callback) {
// We can't bind to something that isn't callable
if (!is_callable($callback)) {
return false;
}
if (!isset($this->bindings[$event]) || !is_array($this->bindings[$event])) {
$this->bindings[$event] = [];
}
// Check if this event is already registered
$signature = $this->hash($callback);
if (array_key_exists($signature, $this->bindings[$event])) {
return $signature;
}
$this->bindings[$event][$signature] = $callback;
return $signature;
}
|
[
"public",
"function",
"bind",
"(",
"string",
"$",
"event",
",",
"callable",
"$",
"callback",
")",
"{",
"// We can't bind to something that isn't callable",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"bindings",
"[",
"$",
"event",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"this",
"->",
"bindings",
"[",
"$",
"event",
"]",
")",
")",
"{",
"$",
"this",
"->",
"bindings",
"[",
"$",
"event",
"]",
"=",
"[",
"]",
";",
"}",
"// Check if this event is already registered",
"$",
"signature",
"=",
"$",
"this",
"->",
"hash",
"(",
"$",
"callback",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"signature",
",",
"$",
"this",
"->",
"bindings",
"[",
"$",
"event",
"]",
")",
")",
"{",
"return",
"$",
"signature",
";",
"}",
"$",
"this",
"->",
"bindings",
"[",
"$",
"event",
"]",
"[",
"$",
"signature",
"]",
"=",
"$",
"callback",
";",
"return",
"$",
"signature",
";",
"}"
] |
Register an event binding
@param string $event
@param callable $callback
@return string|boolean:false
|
[
"Register",
"an",
"event",
"binding"
] |
8dbcf70c575fb587614b45da8ec02d098e3e843b
|
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Event/EventManager.php#L148-L166
|
11,656
|
kaecyra/app-common
|
src/Event/EventManager.php
|
EventManager.getBindings
|
protected function getBindings(string $event) {
if (!isset($this->bindings[$event]) || !is_array($this->bindings[$event])) {
return [];
}
return $this->bindings[$event];
}
|
php
|
protected function getBindings(string $event) {
if (!isset($this->bindings[$event]) || !is_array($this->bindings[$event])) {
return [];
}
return $this->bindings[$event];
}
|
[
"protected",
"function",
"getBindings",
"(",
"string",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"bindings",
"[",
"$",
"event",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"this",
"->",
"bindings",
"[",
"$",
"event",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"bindings",
"[",
"$",
"event",
"]",
";",
"}"
] |
Get all bindings for an event
@param string $event
@return array
|
[
"Get",
"all",
"bindings",
"for",
"an",
"event"
] |
8dbcf70c575fb587614b45da8ec02d098e3e843b
|
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Event/EventManager.php#L174-L179
|
11,657
|
kaecyra/app-common
|
src/Event/EventManager.php
|
EventManager.unbind
|
public function unbind(string $event, string $signature) {
if (!isset($this->bindings[$event]) || !is_array($this->bindings[$event]) || !array_key_exists($signature, $this->bindings[$event])) {
return false;
}
unset($this->bindings[$event][$signature]);
return true;
}
|
php
|
public function unbind(string $event, string $signature) {
if (!isset($this->bindings[$event]) || !is_array($this->bindings[$event]) || !array_key_exists($signature, $this->bindings[$event])) {
return false;
}
unset($this->bindings[$event][$signature]);
return true;
}
|
[
"public",
"function",
"unbind",
"(",
"string",
"$",
"event",
",",
"string",
"$",
"signature",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"bindings",
"[",
"$",
"event",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"this",
"->",
"bindings",
"[",
"$",
"event",
"]",
")",
"||",
"!",
"array_key_exists",
"(",
"$",
"signature",
",",
"$",
"this",
"->",
"bindings",
"[",
"$",
"event",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"bindings",
"[",
"$",
"event",
"]",
"[",
"$",
"signature",
"]",
")",
";",
"return",
"true",
";",
"}"
] |
Remove an event binding
@param string $event
@param string $signature
@return boolean successfully removed, or didn't exist
|
[
"Remove",
"an",
"event",
"binding"
] |
8dbcf70c575fb587614b45da8ec02d098e3e843b
|
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Event/EventManager.php#L188-L195
|
11,658
|
kaecyra/app-common
|
src/Event/EventManager.php
|
EventManager.reflect
|
protected function reflect($reflect, array $arguments) {
$pass = [];
foreach ($reflect->getParameters() as $param) {
if (isset($arguments[$param->getName()])) {
$pass[] = $arguments[$param->getName()];
} else {
$pass[] = $param->getDefaultValue();
}
}
return $pass;
}
|
php
|
protected function reflect($reflect, array $arguments) {
$pass = [];
foreach ($reflect->getParameters() as $param) {
if (isset($arguments[$param->getName()])) {
$pass[] = $arguments[$param->getName()];
} else {
$pass[] = $param->getDefaultValue();
}
}
return $pass;
}
|
[
"protected",
"function",
"reflect",
"(",
"$",
"reflect",
",",
"array",
"$",
"arguments",
")",
"{",
"$",
"pass",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"reflect",
"->",
"getParameters",
"(",
")",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"arguments",
"[",
"$",
"param",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"$",
"pass",
"[",
"]",
"=",
"$",
"arguments",
"[",
"$",
"param",
"->",
"getName",
"(",
")",
"]",
";",
"}",
"else",
"{",
"$",
"pass",
"[",
"]",
"=",
"$",
"param",
"->",
"getDefaultValue",
"(",
")",
";",
"}",
"}",
"return",
"$",
"pass",
";",
"}"
] |
Reflect on the object or function and format an ordered arguement list
@param Reflector $reflect
@param array $arguments
|
[
"Reflect",
"on",
"the",
"object",
"or",
"function",
"and",
"format",
"an",
"ordered",
"arguement",
"list"
] |
8dbcf70c575fb587614b45da8ec02d098e3e843b
|
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Event/EventManager.php#L203-L213
|
11,659
|
kaecyra/app-common
|
src/Event/EventManager.php
|
EventManager.enableTicks
|
public function enableTicks(int $tickFreq = null) {
if (is_null($tickFreq)) {
$tickFreq = self::$tickFreq;
}
// Change ticking frequency
self::$tickFreq = $tickFreq;
self::$lastTick = microtime(true);
// If we're already ticking, don't register again
if (self::$ticking) {
return true;
}
register_tick_function(['\Kaecyra\AppCommon\Event', 'tick']);
}
|
php
|
public function enableTicks(int $tickFreq = null) {
if (is_null($tickFreq)) {
$tickFreq = self::$tickFreq;
}
// Change ticking frequency
self::$tickFreq = $tickFreq;
self::$lastTick = microtime(true);
// If we're already ticking, don't register again
if (self::$ticking) {
return true;
}
register_tick_function(['\Kaecyra\AppCommon\Event', 'tick']);
}
|
[
"public",
"function",
"enableTicks",
"(",
"int",
"$",
"tickFreq",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"tickFreq",
")",
")",
"{",
"$",
"tickFreq",
"=",
"self",
"::",
"$",
"tickFreq",
";",
"}",
"// Change ticking frequency",
"self",
"::",
"$",
"tickFreq",
"=",
"$",
"tickFreq",
";",
"self",
"::",
"$",
"lastTick",
"=",
"microtime",
"(",
"true",
")",
";",
"// If we're already ticking, don't register again",
"if",
"(",
"self",
"::",
"$",
"ticking",
")",
"{",
"return",
"true",
";",
"}",
"register_tick_function",
"(",
"[",
"'\\Kaecyra\\AppCommon\\Event'",
",",
"'tick'",
"]",
")",
";",
"}"
] |
Enable periodic tick event
@param integer $tickFreq optional
@return boolean
|
[
"Enable",
"periodic",
"tick",
"event"
] |
8dbcf70c575fb587614b45da8ec02d098e3e843b
|
https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Event/EventManager.php#L254-L270
|
11,660
|
pgraham/opal
|
src/CompanionLoader.php
|
CompanionLoader.get
|
public function get($className, $ctorArgs = [], $useCache = true) {
if (!$useCache) {
return $this->instantiate($className, $ctorArgs);
}
if (!array_key_exists($className, $this->instances)) {
$instance = $this->instantiate($className, $ctorArgs);
$this->instances[$className] = $instance;
}
return $this->instances[$className];
}
|
php
|
public function get($className, $ctorArgs = [], $useCache = true) {
if (!$useCache) {
return $this->instantiate($className, $ctorArgs);
}
if (!array_key_exists($className, $this->instances)) {
$instance = $this->instantiate($className, $ctorArgs);
$this->instances[$className] = $instance;
}
return $this->instances[$className];
}
|
[
"public",
"function",
"get",
"(",
"$",
"className",
",",
"$",
"ctorArgs",
"=",
"[",
"]",
",",
"$",
"useCache",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"useCache",
")",
"{",
"return",
"$",
"this",
"->",
"instantiate",
"(",
"$",
"className",
",",
"$",
"ctorArgs",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"className",
",",
"$",
"this",
"->",
"instances",
")",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"instantiate",
"(",
"$",
"className",
",",
"$",
"ctorArgs",
")",
";",
"$",
"this",
"->",
"instances",
"[",
"$",
"className",
"]",
"=",
"$",
"instance",
";",
"}",
"return",
"$",
"this",
"->",
"instances",
"[",
"$",
"className",
"]",
";",
"}"
] |
Get the generated class instance for the given lonely class.
@param string $className
The class for which a companion, of they type provided by this loader,
should be provided.
@param array $ctorArgs
Array of arguments to pass to the companion constructor. The given
arguments are not unpacked and are passed as an array. This may change
with PHP 5.6. A single argument could be passed instead of an array.
@param boolean $useCache
Whether or not a retrieve a cached instance if available. If a cached
instance is used then any given constructor args will be ignored.
|
[
"Get",
"the",
"generated",
"class",
"instance",
"for",
"the",
"given",
"lonely",
"class",
"."
] |
73139069567b223423472c81c2f8ed645a3adafc
|
https://github.com/pgraham/opal/blob/73139069567b223423472c81c2f8ed645a3adafc/src/CompanionLoader.php#L75-L85
|
11,661
|
pletfix/core
|
src/Services/Database.php
|
Database.createPDO
|
protected function createPDO($dsn, $username, $password, array $options)
{
return new PDO($dsn, $username, $password, $options);
}
|
php
|
protected function createPDO($dsn, $username, $password, array $options)
{
return new PDO($dsn, $username, $password, $options);
}
|
[
"protected",
"function",
"createPDO",
"(",
"$",
"dsn",
",",
"$",
"username",
",",
"$",
"password",
",",
"array",
"$",
"options",
")",
"{",
"return",
"new",
"PDO",
"(",
"$",
"dsn",
",",
"$",
"username",
",",
"$",
"password",
",",
"$",
"options",
")",
";",
"}"
] |
Create a new PDO instance.
This method creates the internal PDO instance.
@see http://php.net/manual/en/pdo.construct.php
@param string $dsn
@param string $username
@param string $password
@param array $options
@return PDO
|
[
"Create",
"a",
"new",
"PDO",
"instance",
"."
] |
974945500f278eb6c1779832e08bbfca1007a7b3
|
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Database.php#L206-L209
|
11,662
|
pletfix/core
|
src/Services/Database.php
|
Database.perform
|
protected function perform($statement, array $bindings = [], $class = null)
{
$this->connect();
if (empty($bindings)) {
try {
if (($sth = $this->pdo->query($statement)) === false) {
throw new PDOException('Execute SQL query failed!');
}
}
catch (PDOException $e) {
throw new QueryException($statement, $bindings, $statement, $e);
}
}
else {
try {
$sth = $this->pdo->prepare($statement);
foreach ($bindings as $key => $value) {
if (is_int($key)) {
$key += 1;
}
if ($value instanceof DateTimeInterface) {
$value = $value->format($this->dateFormat);
}
else if ($value === false) { // das macht Eloquent!
$value = 0;
}
$type = is_int($value) ? PDO::PARAM_INT : PDO::PARAM_STR;
$sth->bindValue($key, $value, $type);
}
if ($sth->execute() === false) {
throw new PDOException('Execute SQL query failed!');
}
}
catch (PDOException $e) {
throw new QueryException($statement, $bindings, $this->dump($statement, $bindings, true), $e);
}
}
if ($class !== null) {
/** @noinspection PhpMethodParametersCountMismatchInspection */
$sth->setFetchMode(PDO::FETCH_CLASS, $class);
}
return $sth;
}
|
php
|
protected function perform($statement, array $bindings = [], $class = null)
{
$this->connect();
if (empty($bindings)) {
try {
if (($sth = $this->pdo->query($statement)) === false) {
throw new PDOException('Execute SQL query failed!');
}
}
catch (PDOException $e) {
throw new QueryException($statement, $bindings, $statement, $e);
}
}
else {
try {
$sth = $this->pdo->prepare($statement);
foreach ($bindings as $key => $value) {
if (is_int($key)) {
$key += 1;
}
if ($value instanceof DateTimeInterface) {
$value = $value->format($this->dateFormat);
}
else if ($value === false) { // das macht Eloquent!
$value = 0;
}
$type = is_int($value) ? PDO::PARAM_INT : PDO::PARAM_STR;
$sth->bindValue($key, $value, $type);
}
if ($sth->execute() === false) {
throw new PDOException('Execute SQL query failed!');
}
}
catch (PDOException $e) {
throw new QueryException($statement, $bindings, $this->dump($statement, $bindings, true), $e);
}
}
if ($class !== null) {
/** @noinspection PhpMethodParametersCountMismatchInspection */
$sth->setFetchMode(PDO::FETCH_CLASS, $class);
}
return $sth;
}
|
[
"protected",
"function",
"perform",
"(",
"$",
"statement",
",",
"array",
"$",
"bindings",
"=",
"[",
"]",
",",
"$",
"class",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"bindings",
")",
")",
"{",
"try",
"{",
"if",
"(",
"(",
"$",
"sth",
"=",
"$",
"this",
"->",
"pdo",
"->",
"query",
"(",
"$",
"statement",
")",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"PDOException",
"(",
"'Execute SQL query failed!'",
")",
";",
"}",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"$",
"statement",
",",
"$",
"bindings",
",",
"$",
"statement",
",",
"$",
"e",
")",
";",
"}",
"}",
"else",
"{",
"try",
"{",
"$",
"sth",
"=",
"$",
"this",
"->",
"pdo",
"->",
"prepare",
"(",
"$",
"statement",
")",
";",
"foreach",
"(",
"$",
"bindings",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"$",
"key",
"+=",
"1",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"DateTimeInterface",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"format",
"(",
"$",
"this",
"->",
"dateFormat",
")",
";",
"}",
"else",
"if",
"(",
"$",
"value",
"===",
"false",
")",
"{",
"// das macht Eloquent!",
"$",
"value",
"=",
"0",
";",
"}",
"$",
"type",
"=",
"is_int",
"(",
"$",
"value",
")",
"?",
"PDO",
"::",
"PARAM_INT",
":",
"PDO",
"::",
"PARAM_STR",
";",
"$",
"sth",
"->",
"bindValue",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"type",
")",
";",
"}",
"if",
"(",
"$",
"sth",
"->",
"execute",
"(",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"PDOException",
"(",
"'Execute SQL query failed!'",
")",
";",
"}",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"throw",
"new",
"QueryException",
"(",
"$",
"statement",
",",
"$",
"bindings",
",",
"$",
"this",
"->",
"dump",
"(",
"$",
"statement",
",",
"$",
"bindings",
",",
"true",
")",
",",
"$",
"e",
")",
";",
"}",
"}",
"if",
"(",
"$",
"class",
"!==",
"null",
")",
"{",
"/** @noinspection PhpMethodParametersCountMismatchInspection */",
"$",
"sth",
"->",
"setFetchMode",
"(",
"PDO",
"::",
"FETCH_CLASS",
",",
"$",
"class",
")",
";",
"}",
"return",
"$",
"sth",
";",
"}"
] |
Performs a sql statement with bound values and returns the resulting PDOStatement.
* @see http://php.net/manual/en/pdo.prepare.php
@param string $statement The SQL statement to perform.
@param array $bindings Values to bind to the statement
@param string|null $class Name of the class where the data are mapped to
@return PDOStatement
@throws Exception
|
[
"Performs",
"a",
"sql",
"statement",
"with",
"bound",
"values",
"and",
"returns",
"the",
"resulting",
"PDOStatement",
"."
] |
974945500f278eb6c1779832e08bbfca1007a7b3
|
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Database.php#L493-L542
|
11,663
|
dlabas/DlcUseCase
|
src/DlcUseCase/Controller/UseCaseController.php
|
UseCaseController.showWikiTemplateAction
|
public function showWikiTemplateAction()
{
$view = new ViewModel(array(
'template' => file_get_contents($this->getOptions()->getUseCaseDokuWikiTemplate()),
'options' => $this->getOptions(),
));
return $view;
}
|
php
|
public function showWikiTemplateAction()
{
$view = new ViewModel(array(
'template' => file_get_contents($this->getOptions()->getUseCaseDokuWikiTemplate()),
'options' => $this->getOptions(),
));
return $view;
}
|
[
"public",
"function",
"showWikiTemplateAction",
"(",
")",
"{",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
"array",
"(",
"'template'",
"=>",
"file_get_contents",
"(",
"$",
"this",
"->",
"getOptions",
"(",
")",
"->",
"getUseCaseDokuWikiTemplate",
"(",
")",
")",
",",
"'options'",
"=>",
"$",
"this",
"->",
"getOptions",
"(",
")",
",",
")",
")",
";",
"return",
"$",
"view",
";",
"}"
] |
Show wiki template action
@return \Zend\View\Model\ViewModel
|
[
"Show",
"wiki",
"template",
"action"
] |
6a15aa7628594c343c334dabf0253ce2ae5d7f0b
|
https://github.com/dlabas/DlcUseCase/blob/6a15aa7628594c343c334dabf0253ce2ae5d7f0b/src/DlcUseCase/Controller/UseCaseController.php#L127-L135
|
11,664
|
dlabas/DlcUseCase
|
src/DlcUseCase/Controller/UseCaseController.php
|
UseCaseController.editWikiTemplateAction
|
public function editWikiTemplateAction()
{
$templateFile = $this->getOptions()->getUseCaseDokuWikiTemplate();
if (!is_writeable($templateFile)) {
throw new \RuntimeException(sprintf(
'Template file "%s" is not writeable. Please fix the file priviliges first!',
$templateFile
));
}
$request = $this->getRequest();
$form = $this->getServiceLocator()->get('dlcusecase_editwikitemplate_form');
if ($request->getQuery()->get('redirect')) {
$redirect = $request->getQuery()->get('redirect');
} else {
$redirect = false;
}
$redirectUrl = $this->url()->fromRoute($this->getRouteIdentifierPrefix() . '/edit-wiki-template')
. ($redirect ? '?redirect=' . $redirect : '');
$prg = $this->prg($redirectUrl, true);
if ($prg instanceof Response) {
return $prg;
} elseif ($prg === false) {
return array(
'form' => $form,
'options' => $this->getOptions(),
);
}
$post = $prg;
$redirect = isset($prg['redirect']) ? $prg['redirect'] : null;
$form->setData($post);
if (!$form->isValid()) {
return array(
'options' => $this->getOptions(),
'form' => $form,
'redirect' => $redirect,
);
}
$formData = $form->getData();
file_put_contents($this->getOptions()->getUseCaseDokuWikiTemplate(), $formData['wiki-template']);
// TODO: Add the redirect parameter here...
return $this->redirect()->toUrl($this->url()->fromRoute($this->getRouteIdentifierPrefix() . '/show-wiki-template') . ($redirect ? '?redirect='.$redirect : ''));
}
|
php
|
public function editWikiTemplateAction()
{
$templateFile = $this->getOptions()->getUseCaseDokuWikiTemplate();
if (!is_writeable($templateFile)) {
throw new \RuntimeException(sprintf(
'Template file "%s" is not writeable. Please fix the file priviliges first!',
$templateFile
));
}
$request = $this->getRequest();
$form = $this->getServiceLocator()->get('dlcusecase_editwikitemplate_form');
if ($request->getQuery()->get('redirect')) {
$redirect = $request->getQuery()->get('redirect');
} else {
$redirect = false;
}
$redirectUrl = $this->url()->fromRoute($this->getRouteIdentifierPrefix() . '/edit-wiki-template')
. ($redirect ? '?redirect=' . $redirect : '');
$prg = $this->prg($redirectUrl, true);
if ($prg instanceof Response) {
return $prg;
} elseif ($prg === false) {
return array(
'form' => $form,
'options' => $this->getOptions(),
);
}
$post = $prg;
$redirect = isset($prg['redirect']) ? $prg['redirect'] : null;
$form->setData($post);
if (!$form->isValid()) {
return array(
'options' => $this->getOptions(),
'form' => $form,
'redirect' => $redirect,
);
}
$formData = $form->getData();
file_put_contents($this->getOptions()->getUseCaseDokuWikiTemplate(), $formData['wiki-template']);
// TODO: Add the redirect parameter here...
return $this->redirect()->toUrl($this->url()->fromRoute($this->getRouteIdentifierPrefix() . '/show-wiki-template') . ($redirect ? '?redirect='.$redirect : ''));
}
|
[
"public",
"function",
"editWikiTemplateAction",
"(",
")",
"{",
"$",
"templateFile",
"=",
"$",
"this",
"->",
"getOptions",
"(",
")",
"->",
"getUseCaseDokuWikiTemplate",
"(",
")",
";",
"if",
"(",
"!",
"is_writeable",
"(",
"$",
"templateFile",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Template file \"%s\" is not writeable. Please fix the file priviliges first!'",
",",
"$",
"templateFile",
")",
")",
";",
"}",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'dlcusecase_editwikitemplate_form'",
")",
";",
"if",
"(",
"$",
"request",
"->",
"getQuery",
"(",
")",
"->",
"get",
"(",
"'redirect'",
")",
")",
"{",
"$",
"redirect",
"=",
"$",
"request",
"->",
"getQuery",
"(",
")",
"->",
"get",
"(",
"'redirect'",
")",
";",
"}",
"else",
"{",
"$",
"redirect",
"=",
"false",
";",
"}",
"$",
"redirectUrl",
"=",
"$",
"this",
"->",
"url",
"(",
")",
"->",
"fromRoute",
"(",
"$",
"this",
"->",
"getRouteIdentifierPrefix",
"(",
")",
".",
"'/edit-wiki-template'",
")",
".",
"(",
"$",
"redirect",
"?",
"'?redirect='",
".",
"$",
"redirect",
":",
"''",
")",
";",
"$",
"prg",
"=",
"$",
"this",
"->",
"prg",
"(",
"$",
"redirectUrl",
",",
"true",
")",
";",
"if",
"(",
"$",
"prg",
"instanceof",
"Response",
")",
"{",
"return",
"$",
"prg",
";",
"}",
"elseif",
"(",
"$",
"prg",
"===",
"false",
")",
"{",
"return",
"array",
"(",
"'form'",
"=>",
"$",
"form",
",",
"'options'",
"=>",
"$",
"this",
"->",
"getOptions",
"(",
")",
",",
")",
";",
"}",
"$",
"post",
"=",
"$",
"prg",
";",
"$",
"redirect",
"=",
"isset",
"(",
"$",
"prg",
"[",
"'redirect'",
"]",
")",
"?",
"$",
"prg",
"[",
"'redirect'",
"]",
":",
"null",
";",
"$",
"form",
"->",
"setData",
"(",
"$",
"post",
")",
";",
"if",
"(",
"!",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"array",
"(",
"'options'",
"=>",
"$",
"this",
"->",
"getOptions",
"(",
")",
",",
"'form'",
"=>",
"$",
"form",
",",
"'redirect'",
"=>",
"$",
"redirect",
",",
")",
";",
"}",
"$",
"formData",
"=",
"$",
"form",
"->",
"getData",
"(",
")",
";",
"file_put_contents",
"(",
"$",
"this",
"->",
"getOptions",
"(",
")",
"->",
"getUseCaseDokuWikiTemplate",
"(",
")",
",",
"$",
"formData",
"[",
"'wiki-template'",
"]",
")",
";",
"// TODO: Add the redirect parameter here...",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
"->",
"toUrl",
"(",
"$",
"this",
"->",
"url",
"(",
")",
"->",
"fromRoute",
"(",
"$",
"this",
"->",
"getRouteIdentifierPrefix",
"(",
")",
".",
"'/show-wiki-template'",
")",
".",
"(",
"$",
"redirect",
"?",
"'?redirect='",
".",
"$",
"redirect",
":",
"''",
")",
")",
";",
"}"
] |
Edit wiki template action
@return \Zend\View\Model\ViewModel
|
[
"Edit",
"wiki",
"template",
"action"
] |
6a15aa7628594c343c334dabf0253ce2ae5d7f0b
|
https://github.com/dlabas/DlcUseCase/blob/6a15aa7628594c343c334dabf0253ce2ae5d7f0b/src/DlcUseCase/Controller/UseCaseController.php#L142-L195
|
11,665
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/oil/classes/refine.php
|
Refine._discover_tasks
|
protected static function _discover_tasks()
{
$result = array();
$files = \Finder::instance()->list_files('tasks');
if (count($files) > 0)
{
foreach ($files as $file)
{
$task_name = str_replace('.php', '', basename($file));
$class_name = '\\Fuel\\Tasks\\'.$task_name;
require $file;
$reflect = new \ReflectionClass($class_name);
// Ensure we only pull out the public methods
$methods = $reflect->getMethods(\ReflectionMethod::IS_PUBLIC);
$result[$task_name] = array();
if (count($methods) > 0)
{
foreach ($methods as $method)
{
strpos($method->name, '_') !== 0 and $result[$task_name][] = $method->name;
}
}
}
}
return $result;
}
|
php
|
protected static function _discover_tasks()
{
$result = array();
$files = \Finder::instance()->list_files('tasks');
if (count($files) > 0)
{
foreach ($files as $file)
{
$task_name = str_replace('.php', '', basename($file));
$class_name = '\\Fuel\\Tasks\\'.$task_name;
require $file;
$reflect = new \ReflectionClass($class_name);
// Ensure we only pull out the public methods
$methods = $reflect->getMethods(\ReflectionMethod::IS_PUBLIC);
$result[$task_name] = array();
if (count($methods) > 0)
{
foreach ($methods as $method)
{
strpos($method->name, '_') !== 0 and $result[$task_name][] = $method->name;
}
}
}
}
return $result;
}
|
[
"protected",
"static",
"function",
"_discover_tasks",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"files",
"=",
"\\",
"Finder",
"::",
"instance",
"(",
")",
"->",
"list_files",
"(",
"'tasks'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"files",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"task_name",
"=",
"str_replace",
"(",
"'.php'",
",",
"''",
",",
"basename",
"(",
"$",
"file",
")",
")",
";",
"$",
"class_name",
"=",
"'\\\\Fuel\\\\Tasks\\\\'",
".",
"$",
"task_name",
";",
"require",
"$",
"file",
";",
"$",
"reflect",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class_name",
")",
";",
"// Ensure we only pull out the public methods",
"$",
"methods",
"=",
"$",
"reflect",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
";",
"$",
"result",
"[",
"$",
"task_name",
"]",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"methods",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"strpos",
"(",
"$",
"method",
"->",
"name",
",",
"'_'",
")",
"!==",
"0",
"and",
"$",
"result",
"[",
"$",
"task_name",
"]",
"[",
"]",
"=",
"$",
"method",
"->",
"name",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Find all of the task classes in the system and use reflection to discover the
commands we can call.
@return array $taskname => array($taskmethods)
|
[
"Find",
"all",
"of",
"the",
"task",
"classes",
"in",
"the",
"system",
"and",
"use",
"reflection",
"to",
"discover",
"the",
"commands",
"we",
"can",
"call",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/oil/classes/refine.php#L182-L214
|
11,666
|
axelspringer/wp-bootstrap
|
src/Plugin/Setup.php
|
Setup.load_options
|
public function load_options( string $options )
{
// get constants
$reflect = new \ReflectionClass( $options );
$options = $reflect->getConstants();
// iterate needed params
foreach ( $options as $option => $default ) {
$key = strtolower( $option ); //
$env = getenv( $option );
$this->options[ $key ] = get_option( $key, $default );
// overload env variables
$this->options[ $key ] = ! $env ? $this->options[ $key ] : $env;
}
}
|
php
|
public function load_options( string $options )
{
// get constants
$reflect = new \ReflectionClass( $options );
$options = $reflect->getConstants();
// iterate needed params
foreach ( $options as $option => $default ) {
$key = strtolower( $option ); //
$env = getenv( $option );
$this->options[ $key ] = get_option( $key, $default );
// overload env variables
$this->options[ $key ] = ! $env ? $this->options[ $key ] : $env;
}
}
|
[
"public",
"function",
"load_options",
"(",
"string",
"$",
"options",
")",
"{",
"// get constants",
"$",
"reflect",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"options",
")",
";",
"$",
"options",
"=",
"$",
"reflect",
"->",
"getConstants",
"(",
")",
";",
"// iterate needed params",
"foreach",
"(",
"$",
"options",
"as",
"$",
"option",
"=>",
"$",
"default",
")",
"{",
"$",
"key",
"=",
"strtolower",
"(",
"$",
"option",
")",
";",
"//",
"$",
"env",
"=",
"getenv",
"(",
"$",
"option",
")",
";",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
"=",
"get_option",
"(",
"$",
"key",
",",
"$",
"default",
")",
";",
"// overload env variables",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
"=",
"!",
"$",
"env",
"?",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
":",
"$",
"env",
";",
"}",
"}"
] |
Load required options
@param string $options
|
[
"Load",
"required",
"options"
] |
3e181ded8229ef1f125a2dcd3f9777694871f68e
|
https://github.com/axelspringer/wp-bootstrap/blob/3e181ded8229ef1f125a2dcd3f9777694871f68e/src/Plugin/Setup.php#L60-L74
|
11,667
|
axelspringer/wp-bootstrap
|
src/Plugin/Setup.php
|
Setup.update_version
|
public function update_version()
{
$option = $this->slug . '_version';
$old_version = get_option( $option );
if ( false === $old_version ||
version_compare( $old_version, $this->version, '<' ) ) {
return update_option( $option, $this->version );
}
return true;
}
|
php
|
public function update_version()
{
$option = $this->slug . '_version';
$old_version = get_option( $option );
if ( false === $old_version ||
version_compare( $old_version, $this->version, '<' ) ) {
return update_option( $option, $this->version );
}
return true;
}
|
[
"public",
"function",
"update_version",
"(",
")",
"{",
"$",
"option",
"=",
"$",
"this",
"->",
"slug",
".",
"'_version'",
";",
"$",
"old_version",
"=",
"get_option",
"(",
"$",
"option",
")",
";",
"if",
"(",
"false",
"===",
"$",
"old_version",
"||",
"version_compare",
"(",
"$",
"old_version",
",",
"$",
"this",
"->",
"version",
",",
"'<'",
")",
")",
"{",
"return",
"update_option",
"(",
"$",
"option",
",",
"$",
"this",
"->",
"version",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Updates the version of the plugin
@return bool
|
[
"Updates",
"the",
"version",
"of",
"the",
"plugin"
] |
3e181ded8229ef1f125a2dcd3f9777694871f68e
|
https://github.com/axelspringer/wp-bootstrap/blob/3e181ded8229ef1f125a2dcd3f9777694871f68e/src/Plugin/Setup.php#L98-L109
|
11,668
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_throws_an_exception_when_attempting_to_register_the_same_type_twice
|
function it_throws_an_exception_when_attempting_to_register_the_same_type_twice($converter)
{
$this->setType('decimal', $converter);
$this->shouldThrow(new ResourceHandlerAlreadyDefinedException( 'An handler for resource "decimal" has already been registered.'))->duringSetType('decimal', $converter);
}
|
php
|
function it_throws_an_exception_when_attempting_to_register_the_same_type_twice($converter)
{
$this->setType('decimal', $converter);
$this->shouldThrow(new ResourceHandlerAlreadyDefinedException( 'An handler for resource "decimal" has already been registered.'))->duringSetType('decimal', $converter);
}
|
[
"function",
"it_throws_an_exception_when_attempting_to_register_the_same_type_twice",
"(",
"$",
"converter",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
")",
";",
"$",
"this",
"->",
"shouldThrow",
"(",
"new",
"ResourceHandlerAlreadyDefinedException",
"(",
"'An handler for resource \"decimal\" has already been registered.'",
")",
")",
"->",
"duringSetType",
"(",
"'decimal'",
",",
"$",
"converter",
")",
";",
"}"
] |
It throws an exception when attempting to register the same type twice.
@param \Phn\Mapping\Converter\ConverterInterface $converter
|
[
"It",
"throws",
"an",
"exception",
"when",
"attempting",
"to",
"register",
"the",
"same",
"type",
"twice",
"."
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L76-L80
|
11,669
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_converts_and_normalizes_values_from_pg
|
function it_converts_and_normalizes_values_from_pg($converter, $normalizer)
{
$this->setType('decimal', $converter, $normalizer);
$this->fromPg('1.66180339887', 'decimal')->shouldBeLike((object) [
'value' => 1.66180339887
]);
}
|
php
|
function it_converts_and_normalizes_values_from_pg($converter, $normalizer)
{
$this->setType('decimal', $converter, $normalizer);
$this->fromPg('1.66180339887', 'decimal')->shouldBeLike((object) [
'value' => 1.66180339887
]);
}
|
[
"function",
"it_converts_and_normalizes_values_from_pg",
"(",
"$",
"converter",
",",
"$",
"normalizer",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
",",
"$",
"normalizer",
")",
";",
"$",
"this",
"->",
"fromPg",
"(",
"'1.66180339887'",
",",
"'decimal'",
")",
"->",
"shouldBeLike",
"(",
"(",
"object",
")",
"[",
"'value'",
"=>",
"1.66180339887",
"]",
")",
";",
"}"
] |
It converts and normalizes values from pg.
@param \Phn\Mapping\Converter\ConverterInterface $converter
@param \Phn\Mapping\Normalizer\NormalizerInterface $normalizer
|
[
"It",
"converts",
"and",
"normalizes",
"values",
"from",
"pg",
"."
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L131-L138
|
11,670
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_converts_and_normalizes_sets_from_pg
|
function it_converts_and_normalizes_sets_from_pg($converter, $normalizer)
{
$this->setType('decimal', $converter, $normalizer);
$this->fromPg(['3.14159265359', '1.66180339887'], 'decimal[]')->shouldBeLike([
(object) [
'value' => 3.14159265359
],
(object) [
'value' => 1.66180339887
]
]);
}
|
php
|
function it_converts_and_normalizes_sets_from_pg($converter, $normalizer)
{
$this->setType('decimal', $converter, $normalizer);
$this->fromPg(['3.14159265359', '1.66180339887'], 'decimal[]')->shouldBeLike([
(object) [
'value' => 3.14159265359
],
(object) [
'value' => 1.66180339887
]
]);
}
|
[
"function",
"it_converts_and_normalizes_sets_from_pg",
"(",
"$",
"converter",
",",
"$",
"normalizer",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
",",
"$",
"normalizer",
")",
";",
"$",
"this",
"->",
"fromPg",
"(",
"[",
"'3.14159265359'",
",",
"'1.66180339887'",
"]",
",",
"'decimal[]'",
")",
"->",
"shouldBeLike",
"(",
"[",
"(",
"object",
")",
"[",
"'value'",
"=>",
"3.14159265359",
"]",
",",
"(",
"object",
")",
"[",
"'value'",
"=>",
"1.66180339887",
"]",
"]",
")",
";",
"}"
] |
It converts and normalizes sets from pg.
@param \Phn\Mapping\Converter\ConverterInterface $converter
@param \Phn\Mapping\Normalizer\NormalizerInterface $normalizer
|
[
"It",
"converts",
"and",
"normalizes",
"sets",
"from",
"pg",
"."
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L158-L170
|
11,671
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_converts_and_normalizes_nested_sets_from_pg
|
function it_converts_and_normalizes_nested_sets_from_pg($converter, $normalizer)
{
$this->setType('decimal', $converter, $normalizer);
$this->fromPg([['3.14159265359'], ['1.66180339887']], 'decimal[][]')->shouldBeLike([
[
(object) [
'value' => 3.14159265359
]
],
[
(object) [
'value' => 1.66180339887
]
]
]);
}
|
php
|
function it_converts_and_normalizes_nested_sets_from_pg($converter, $normalizer)
{
$this->setType('decimal', $converter, $normalizer);
$this->fromPg([['3.14159265359'], ['1.66180339887']], 'decimal[][]')->shouldBeLike([
[
(object) [
'value' => 3.14159265359
]
],
[
(object) [
'value' => 1.66180339887
]
]
]);
}
|
[
"function",
"it_converts_and_normalizes_nested_sets_from_pg",
"(",
"$",
"converter",
",",
"$",
"normalizer",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
",",
"$",
"normalizer",
")",
";",
"$",
"this",
"->",
"fromPg",
"(",
"[",
"[",
"'3.14159265359'",
"]",
",",
"[",
"'1.66180339887'",
"]",
"]",
",",
"'decimal[][]'",
")",
"->",
"shouldBeLike",
"(",
"[",
"[",
"(",
"object",
")",
"[",
"'value'",
"=>",
"3.14159265359",
"]",
"]",
",",
"[",
"(",
"object",
")",
"[",
"'value'",
"=>",
"1.66180339887",
"]",
"]",
"]",
")",
";",
"}"
] |
It converts and normalizes nested sets from pg.
@param \Phn\Mapping\Converter\ConverterInterface $converter
@param \Phn\Mapping\Normalizer\NormalizerInterface $normalizer
|
[
"It",
"converts",
"and",
"normalizes",
"nested",
"sets",
"from",
"pg",
"."
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L190-L206
|
11,672
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_converts_rows_from_pg
|
function it_converts_rows_from_pg($converter)
{
$this->setType('decimal', $converter);
$this->setCompositeType('real', [
'pi' => 'decimal',
'phi' => 'decimal'
]);
$this
->fromPg(
[
'pi' => '3.14159265359',
'phi' => '1.66180339887'
],
'real'
)
->shouldBeLike([
'pi' => 3.14159265359,
'phi' => 1.66180339887
])
;
}
|
php
|
function it_converts_rows_from_pg($converter)
{
$this->setType('decimal', $converter);
$this->setCompositeType('real', [
'pi' => 'decimal',
'phi' => 'decimal'
]);
$this
->fromPg(
[
'pi' => '3.14159265359',
'phi' => '1.66180339887'
],
'real'
)
->shouldBeLike([
'pi' => 3.14159265359,
'phi' => 1.66180339887
])
;
}
|
[
"function",
"it_converts_rows_from_pg",
"(",
"$",
"converter",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
")",
";",
"$",
"this",
"->",
"setCompositeType",
"(",
"'real'",
",",
"[",
"'pi'",
"=>",
"'decimal'",
",",
"'phi'",
"=>",
"'decimal'",
"]",
")",
";",
"$",
"this",
"->",
"fromPg",
"(",
"[",
"'pi'",
"=>",
"'3.14159265359'",
",",
"'phi'",
"=>",
"'1.66180339887'",
"]",
",",
"'real'",
")",
"->",
"shouldBeLike",
"(",
"[",
"'pi'",
"=>",
"3.14159265359",
",",
"'phi'",
"=>",
"1.66180339887",
"]",
")",
";",
"}"
] |
It converts rows from pg.
@param \Phn\Mapping\Converter\ConverterInterface $converter
|
[
"It",
"converts",
"rows",
"from",
"pg",
"."
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L213-L234
|
11,673
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_converts_and_normalizes_rows_from_pg
|
function it_converts_and_normalizes_rows_from_pg($converter, $normalizer)
{
$this->setType('decimal', $converter, $normalizer);
$this->setCompositeType('real', [
'pi' => 'decimal',
'phi' => 'decimal'
]);
$this
->fromPg(
[
'pi' => '3.14159265359',
'phi' => '1.66180339887'
],
'real'
)
->shouldBeLike([
'pi' => (object) [
'value' => 3.14159265359
],
'phi' => (object) [
'value' => 1.66180339887
]
])
;
}
|
php
|
function it_converts_and_normalizes_rows_from_pg($converter, $normalizer)
{
$this->setType('decimal', $converter, $normalizer);
$this->setCompositeType('real', [
'pi' => 'decimal',
'phi' => 'decimal'
]);
$this
->fromPg(
[
'pi' => '3.14159265359',
'phi' => '1.66180339887'
],
'real'
)
->shouldBeLike([
'pi' => (object) [
'value' => 3.14159265359
],
'phi' => (object) [
'value' => 1.66180339887
]
])
;
}
|
[
"function",
"it_converts_and_normalizes_rows_from_pg",
"(",
"$",
"converter",
",",
"$",
"normalizer",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
",",
"$",
"normalizer",
")",
";",
"$",
"this",
"->",
"setCompositeType",
"(",
"'real'",
",",
"[",
"'pi'",
"=>",
"'decimal'",
",",
"'phi'",
"=>",
"'decimal'",
"]",
")",
";",
"$",
"this",
"->",
"fromPg",
"(",
"[",
"'pi'",
"=>",
"'3.14159265359'",
",",
"'phi'",
"=>",
"'1.66180339887'",
"]",
",",
"'real'",
")",
"->",
"shouldBeLike",
"(",
"[",
"'pi'",
"=>",
"(",
"object",
")",
"[",
"'value'",
"=>",
"3.14159265359",
"]",
",",
"'phi'",
"=>",
"(",
"object",
")",
"[",
"'value'",
"=>",
"1.66180339887",
"]",
"]",
")",
";",
"}"
] |
It converts and normalizes rows from pg.
@param \Phn\Mapping\Converter\ConverterInterface $converter
@param \Phn\Mapping\Normalizer\NormalizerInterface $normalizer
|
[
"It",
"converts",
"and",
"normalizes",
"rows",
"from",
"pg",
"."
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L242-L267
|
11,674
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_converts_values_to_pg
|
function it_converts_values_to_pg($converter)
{
$this->setType('decimal', $converter);
$this->toPg(1.66180339887, 'decimal')->shouldBeLike(new Value('1.66180339887', new Type('decimal')));
}
|
php
|
function it_converts_values_to_pg($converter)
{
$this->setType('decimal', $converter);
$this->toPg(1.66180339887, 'decimal')->shouldBeLike(new Value('1.66180339887', new Type('decimal')));
}
|
[
"function",
"it_converts_values_to_pg",
"(",
"$",
"converter",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
")",
";",
"$",
"this",
"->",
"toPg",
"(",
"1.66180339887",
",",
"'decimal'",
")",
"->",
"shouldBeLike",
"(",
"new",
"Value",
"(",
"'1.66180339887'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
")",
";",
"}"
] |
It converts values to pg
@param \Phn\Mapping\Converter\ConverterInterface $converter
|
[
"It",
"converts",
"values",
"to",
"pg"
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L274-L279
|
11,675
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_converts_and_normalizes_values_to_pg
|
function it_converts_and_normalizes_values_to_pg($normalizer, $converter)
{
$this->setType('decimal', $converter, $normalizer);
$this
->toPg(
(object) [
'value' => 1.66180339887
],
'decimal'
)
->shouldBeLike(new Value('1.66180339887', new Type('decimal')))
;
}
|
php
|
function it_converts_and_normalizes_values_to_pg($normalizer, $converter)
{
$this->setType('decimal', $converter, $normalizer);
$this
->toPg(
(object) [
'value' => 1.66180339887
],
'decimal'
)
->shouldBeLike(new Value('1.66180339887', new Type('decimal')))
;
}
|
[
"function",
"it_converts_and_normalizes_values_to_pg",
"(",
"$",
"normalizer",
",",
"$",
"converter",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
",",
"$",
"normalizer",
")",
";",
"$",
"this",
"->",
"toPg",
"(",
"(",
"object",
")",
"[",
"'value'",
"=>",
"1.66180339887",
"]",
",",
"'decimal'",
")",
"->",
"shouldBeLike",
"(",
"new",
"Value",
"(",
"'1.66180339887'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
")",
";",
"}"
] |
It converts and normalizes values to pg
@param \Phn\Mapping\Normalizer\NormalizerInterface $normalizer
@param \Phn\Mapping\Converter\ConverterInterface $converter
|
[
"It",
"converts",
"and",
"normalizes",
"values",
"to",
"pg"
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L287-L300
|
11,676
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_converts_sets_to_pg
|
function it_converts_sets_to_pg($converter)
{
$this->setType('decimal', $converter);
$this->toPg([3.14159265359, 1.66180339887], 'decimal[]')->shouldBeLike(new Set(
[
new Value('3.14159265359', new Type('decimal')),
new Value('1.66180339887', new Type('decimal'))
],
new ArrayType(new Type('decimal'))
));
}
|
php
|
function it_converts_sets_to_pg($converter)
{
$this->setType('decimal', $converter);
$this->toPg([3.14159265359, 1.66180339887], 'decimal[]')->shouldBeLike(new Set(
[
new Value('3.14159265359', new Type('decimal')),
new Value('1.66180339887', new Type('decimal'))
],
new ArrayType(new Type('decimal'))
));
}
|
[
"function",
"it_converts_sets_to_pg",
"(",
"$",
"converter",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
")",
";",
"$",
"this",
"->",
"toPg",
"(",
"[",
"3.14159265359",
",",
"1.66180339887",
"]",
",",
"'decimal[]'",
")",
"->",
"shouldBeLike",
"(",
"new",
"Set",
"(",
"[",
"new",
"Value",
"(",
"'3.14159265359'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
",",
"new",
"Value",
"(",
"'1.66180339887'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
"]",
",",
"new",
"ArrayType",
"(",
"new",
"Type",
"(",
"'decimal'",
")",
")",
")",
")",
";",
"}"
] |
It converts sets to pg.
@param \Phn\Mapping\Converter\ConverterInterface $converter
|
[
"It",
"converts",
"sets",
"to",
"pg",
"."
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L307-L318
|
11,677
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_converts_and_normalizes_sets_to_pg
|
function it_converts_and_normalizes_sets_to_pg($normalizer, $converter)
{
$this->setType('decimal', $converter, $normalizer);
$this
->toPg(
[
(object) [
'value' => 3.14159265359
],
(object) [
'value' => 1.66180339887
]
],
'decimal[]'
)
->shouldBeLike(new Set(
[
new Value('3.14159265359', new Type('decimal')),
new Value('1.66180339887', new Type('decimal'))
],
new ArrayType(new Type('decimal'))
))
;
}
|
php
|
function it_converts_and_normalizes_sets_to_pg($normalizer, $converter)
{
$this->setType('decimal', $converter, $normalizer);
$this
->toPg(
[
(object) [
'value' => 3.14159265359
],
(object) [
'value' => 1.66180339887
]
],
'decimal[]'
)
->shouldBeLike(new Set(
[
new Value('3.14159265359', new Type('decimal')),
new Value('1.66180339887', new Type('decimal'))
],
new ArrayType(new Type('decimal'))
))
;
}
|
[
"function",
"it_converts_and_normalizes_sets_to_pg",
"(",
"$",
"normalizer",
",",
"$",
"converter",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
",",
"$",
"normalizer",
")",
";",
"$",
"this",
"->",
"toPg",
"(",
"[",
"(",
"object",
")",
"[",
"'value'",
"=>",
"3.14159265359",
"]",
",",
"(",
"object",
")",
"[",
"'value'",
"=>",
"1.66180339887",
"]",
"]",
",",
"'decimal[]'",
")",
"->",
"shouldBeLike",
"(",
"new",
"Set",
"(",
"[",
"new",
"Value",
"(",
"'3.14159265359'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
",",
"new",
"Value",
"(",
"'1.66180339887'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
"]",
",",
"new",
"ArrayType",
"(",
"new",
"Type",
"(",
"'decimal'",
")",
")",
")",
")",
";",
"}"
] |
It converts and normalizes sets to pg.
@param \Phn\Mapping\Normalizer\NormalizerInterface $normalizer
@param \Phn\Mapping\Converter\ConverterInterface $converter
|
[
"It",
"converts",
"and",
"normalizes",
"sets",
"to",
"pg",
"."
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L326-L350
|
11,678
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_converts_nested_sets_to_pg
|
function it_converts_nested_sets_to_pg($converter)
{
$this->setType('decimal', $converter);
$this->toPg([[3.14159265359], [1.66180339887]], 'decimal[][]')->shouldBeLike(new Set(
[
new Set(
[
new Value('3.14159265359', new Type('decimal'))
],
new ArrayType(new Type('decimal'))
),
new Set(
[
new Value('1.66180339887', new Type('decimal'))
],
new ArrayType(new Type('decimal'))
)
],
new ArrayType(new ArrayType(new Type('decimal')))
));
}
|
php
|
function it_converts_nested_sets_to_pg($converter)
{
$this->setType('decimal', $converter);
$this->toPg([[3.14159265359], [1.66180339887]], 'decimal[][]')->shouldBeLike(new Set(
[
new Set(
[
new Value('3.14159265359', new Type('decimal'))
],
new ArrayType(new Type('decimal'))
),
new Set(
[
new Value('1.66180339887', new Type('decimal'))
],
new ArrayType(new Type('decimal'))
)
],
new ArrayType(new ArrayType(new Type('decimal')))
));
}
|
[
"function",
"it_converts_nested_sets_to_pg",
"(",
"$",
"converter",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
")",
";",
"$",
"this",
"->",
"toPg",
"(",
"[",
"[",
"3.14159265359",
"]",
",",
"[",
"1.66180339887",
"]",
"]",
",",
"'decimal[][]'",
")",
"->",
"shouldBeLike",
"(",
"new",
"Set",
"(",
"[",
"new",
"Set",
"(",
"[",
"new",
"Value",
"(",
"'3.14159265359'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
"]",
",",
"new",
"ArrayType",
"(",
"new",
"Type",
"(",
"'decimal'",
")",
")",
")",
",",
"new",
"Set",
"(",
"[",
"new",
"Value",
"(",
"'1.66180339887'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
"]",
",",
"new",
"ArrayType",
"(",
"new",
"Type",
"(",
"'decimal'",
")",
")",
")",
"]",
",",
"new",
"ArrayType",
"(",
"new",
"ArrayType",
"(",
"new",
"Type",
"(",
"'decimal'",
")",
")",
")",
")",
")",
";",
"}"
] |
It converts nested sets to pg.
@param \Phn\Mapping\Converter\ConverterInterface $converter
|
[
"It",
"converts",
"nested",
"sets",
"to",
"pg",
"."
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L357-L378
|
11,679
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_converts_and_normalizes_nested_sets_to_pg
|
function it_converts_and_normalizes_nested_sets_to_pg($normalizer, $converter)
{
$this->setType('decimal', $converter, $normalizer);
$this
->toPg(
[
[
(object) [
'value' => 3.14159265359
]
],
[
(object) [
'value' => 1.66180339887
]
]
],
'decimal[][]'
)
->shouldBeLike(new Set(
[
new Set(
[
new Value('3.14159265359', new Type('decimal'))
],
new ArrayType(new Type('decimal'))
),
new Set(
[
new Value('1.66180339887', new Type('decimal'))
],
new ArrayType(new Type('decimal'))
)
],
new ArrayType(new ArrayType(new Type('decimal')))
))
;
}
|
php
|
function it_converts_and_normalizes_nested_sets_to_pg($normalizer, $converter)
{
$this->setType('decimal', $converter, $normalizer);
$this
->toPg(
[
[
(object) [
'value' => 3.14159265359
]
],
[
(object) [
'value' => 1.66180339887
]
]
],
'decimal[][]'
)
->shouldBeLike(new Set(
[
new Set(
[
new Value('3.14159265359', new Type('decimal'))
],
new ArrayType(new Type('decimal'))
),
new Set(
[
new Value('1.66180339887', new Type('decimal'))
],
new ArrayType(new Type('decimal'))
)
],
new ArrayType(new ArrayType(new Type('decimal')))
))
;
}
|
[
"function",
"it_converts_and_normalizes_nested_sets_to_pg",
"(",
"$",
"normalizer",
",",
"$",
"converter",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
",",
"$",
"normalizer",
")",
";",
"$",
"this",
"->",
"toPg",
"(",
"[",
"[",
"(",
"object",
")",
"[",
"'value'",
"=>",
"3.14159265359",
"]",
"]",
",",
"[",
"(",
"object",
")",
"[",
"'value'",
"=>",
"1.66180339887",
"]",
"]",
"]",
",",
"'decimal[][]'",
")",
"->",
"shouldBeLike",
"(",
"new",
"Set",
"(",
"[",
"new",
"Set",
"(",
"[",
"new",
"Value",
"(",
"'3.14159265359'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
"]",
",",
"new",
"ArrayType",
"(",
"new",
"Type",
"(",
"'decimal'",
")",
")",
")",
",",
"new",
"Set",
"(",
"[",
"new",
"Value",
"(",
"'1.66180339887'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
"]",
",",
"new",
"ArrayType",
"(",
"new",
"Type",
"(",
"'decimal'",
")",
")",
")",
"]",
",",
"new",
"ArrayType",
"(",
"new",
"ArrayType",
"(",
"new",
"Type",
"(",
"'decimal'",
")",
")",
")",
")",
")",
";",
"}"
] |
It converts and normalizes nested sets to pg.
@param \Phn\Mapping\Normalizer\NormalizerInterface $normalizer
@param \Phn\Mapping\Converter\ConverterInterface $converter
|
[
"It",
"converts",
"and",
"normalizes",
"nested",
"sets",
"to",
"pg",
"."
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L386-L424
|
11,680
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_converts_rows_to_pg
|
function it_converts_rows_to_pg($converter)
{
$this->setType('decimal', $converter);
$this->setCompositeType('real', [
'pi' => 'decimal',
'phi' => 'decimal'
]);
$this
->toPg(
[
'pi' => 3.14159265359,
'phi' => 1.66180339887
],
'real'
)
->shouldBeLike(new Row(
[
'pi' => new Value('3.14159265359', new Type('decimal')),
'phi' => new Value('1.66180339887', new Type('decimal'))
],
new Type('real')
))
;
}
|
php
|
function it_converts_rows_to_pg($converter)
{
$this->setType('decimal', $converter);
$this->setCompositeType('real', [
'pi' => 'decimal',
'phi' => 'decimal'
]);
$this
->toPg(
[
'pi' => 3.14159265359,
'phi' => 1.66180339887
],
'real'
)
->shouldBeLike(new Row(
[
'pi' => new Value('3.14159265359', new Type('decimal')),
'phi' => new Value('1.66180339887', new Type('decimal'))
],
new Type('real')
))
;
}
|
[
"function",
"it_converts_rows_to_pg",
"(",
"$",
"converter",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
")",
";",
"$",
"this",
"->",
"setCompositeType",
"(",
"'real'",
",",
"[",
"'pi'",
"=>",
"'decimal'",
",",
"'phi'",
"=>",
"'decimal'",
"]",
")",
";",
"$",
"this",
"->",
"toPg",
"(",
"[",
"'pi'",
"=>",
"3.14159265359",
",",
"'phi'",
"=>",
"1.66180339887",
"]",
",",
"'real'",
")",
"->",
"shouldBeLike",
"(",
"new",
"Row",
"(",
"[",
"'pi'",
"=>",
"new",
"Value",
"(",
"'3.14159265359'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
",",
"'phi'",
"=>",
"new",
"Value",
"(",
"'1.66180339887'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
"]",
",",
"new",
"Type",
"(",
"'real'",
")",
")",
")",
";",
"}"
] |
It converts rows to pg.
@param \Phn\Mapping\Converter\ConverterInterface $converter
|
[
"It",
"converts",
"rows",
"to",
"pg",
"."
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L431-L455
|
11,681
|
phn-io/mapping
|
spec/Phn/Mapping/HierarchicalMapperSpec.php
|
HierarchicalMapperSpec.it_converts_and_normalizes_rows_to_pg
|
function it_converts_and_normalizes_rows_to_pg($normalizer, $converter)
{
$this->setType('decimal', $converter, $normalizer);
$this->setCompositeType('real', [
'pi' => 'decimal',
'phi' => 'decimal'
]);
$this
->toPg(
[
'pi' => (object) [
'value' => 3.14159265359
],
'phi' => (object) [
'value' => 1.66180339887
]
],
'real'
)
->shouldBeLike(new Row(
[
'pi' => new Value('3.14159265359', new Type('decimal')),
'phi' => new Value('1.66180339887', new Type('decimal'))
],
new Type('real')
))
;
}
|
php
|
function it_converts_and_normalizes_rows_to_pg($normalizer, $converter)
{
$this->setType('decimal', $converter, $normalizer);
$this->setCompositeType('real', [
'pi' => 'decimal',
'phi' => 'decimal'
]);
$this
->toPg(
[
'pi' => (object) [
'value' => 3.14159265359
],
'phi' => (object) [
'value' => 1.66180339887
]
],
'real'
)
->shouldBeLike(new Row(
[
'pi' => new Value('3.14159265359', new Type('decimal')),
'phi' => new Value('1.66180339887', new Type('decimal'))
],
new Type('real')
))
;
}
|
[
"function",
"it_converts_and_normalizes_rows_to_pg",
"(",
"$",
"normalizer",
",",
"$",
"converter",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"'decimal'",
",",
"$",
"converter",
",",
"$",
"normalizer",
")",
";",
"$",
"this",
"->",
"setCompositeType",
"(",
"'real'",
",",
"[",
"'pi'",
"=>",
"'decimal'",
",",
"'phi'",
"=>",
"'decimal'",
"]",
")",
";",
"$",
"this",
"->",
"toPg",
"(",
"[",
"'pi'",
"=>",
"(",
"object",
")",
"[",
"'value'",
"=>",
"3.14159265359",
"]",
",",
"'phi'",
"=>",
"(",
"object",
")",
"[",
"'value'",
"=>",
"1.66180339887",
"]",
"]",
",",
"'real'",
")",
"->",
"shouldBeLike",
"(",
"new",
"Row",
"(",
"[",
"'pi'",
"=>",
"new",
"Value",
"(",
"'3.14159265359'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
",",
"'phi'",
"=>",
"new",
"Value",
"(",
"'1.66180339887'",
",",
"new",
"Type",
"(",
"'decimal'",
")",
")",
"]",
",",
"new",
"Type",
"(",
"'real'",
")",
")",
")",
";",
"}"
] |
It converts and normalizes rows to pg.
@param \Phn\Mapping\Normalizer\NormalizerInterface $normalizer
@param \Phn\Mapping\Converter\ConverterInterface $converter
|
[
"It",
"converts",
"and",
"normalizes",
"rows",
"to",
"pg",
"."
] |
20742acf44072cea11ac1f26158c1f9d119a6c1b
|
https://github.com/phn-io/mapping/blob/20742acf44072cea11ac1f26158c1f9d119a6c1b/spec/Phn/Mapping/HierarchicalMapperSpec.php#L463-L491
|
11,682
|
ddehart/dilmun
|
src/Anshar/Utils/ArrayHelper.php
|
ArrayHelper.valueLookup
|
public function valueLookup($key)
{
$value = false;
if (array_key_exists($key, $this->array)) {
$value = $this->array[$key];
}
return $value;
}
|
php
|
public function valueLookup($key)
{
$value = false;
if (array_key_exists($key, $this->array)) {
$value = $this->array[$key];
}
return $value;
}
|
[
"public",
"function",
"valueLookup",
"(",
"$",
"key",
")",
"{",
"$",
"value",
"=",
"false",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"array",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Returns the value corresponding with a supplied key; returns FALSE if the supplied key does not exist within
the array.
**WARNING** This function may return FALSE or a non-Boolean value that evaluates to FALSE even if a supplied
key exists
@param int|string $key The key to look up
@return bool|mixed Returns FALSE if the supplied key does not exist within the array
Returns the value corresponding with the key otherwise
|
[
"Returns",
"the",
"value",
"corresponding",
"with",
"a",
"supplied",
"key",
";",
"returns",
"FALSE",
"if",
"the",
"supplied",
"key",
"does",
"not",
"exist",
"within",
"the",
"array",
"."
] |
e2a294dbcd4c6754063c247be64930c5ee91378f
|
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Anshar/Utils/ArrayHelper.php#L35-L44
|
11,683
|
Kylob/Table
|
src/Component.php
|
Component.close
|
public function close()
{
$html = $this->wrapUp('table')."\n";
$this->head = false;
$this->foot = false;
$this->body = false;
$this->cell = '';
$this->vars = '';
return $html.'</table>';
}
|
php
|
public function close()
{
$html = $this->wrapUp('table')."\n";
$this->head = false;
$this->foot = false;
$this->body = false;
$this->cell = '';
$this->vars = '';
return $html.'</table>';
}
|
[
"public",
"function",
"close",
"(",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"wrapUp",
"(",
"'table'",
")",
".",
"\"\\n\"",
";",
"$",
"this",
"->",
"head",
"=",
"false",
";",
"$",
"this",
"->",
"foot",
"=",
"false",
";",
"$",
"this",
"->",
"body",
"=",
"false",
";",
"$",
"this",
"->",
"cell",
"=",
"''",
";",
"$",
"this",
"->",
"vars",
"=",
"''",
";",
"return",
"$",
"html",
".",
"'</table>'",
";",
"}"
] |
Closes any remaining open tags.
@return string
|
[
"Closes",
"any",
"remaining",
"open",
"tags",
"."
] |
49bc032658b9a57892bdf4041e1b39e5dec0eb0f
|
https://github.com/Kylob/Table/blob/49bc032658b9a57892bdf4041e1b39e5dec0eb0f/src/Component.php#L115-L125
|
11,684
|
Kylob/Table
|
src/Component.php
|
Component.wrapUp
|
private function wrapUp($section)
{
$html = $this->cell;
$this->cell = '';
switch ($section) {
case 'head':
if ($this->head) {
$html .= '</tr>';
} else {
if ($this->foot) {
$html .= '</tr></tfoot>';
$this->foot = false;
} elseif ($this->body) {
$html .= '</tr></tbody>';
$this->body = false;
}
$html .= '<thead>';
}
break;
case 'foot':
if ($this->foot) {
$html .= '</tr>';
} else {
if ($this->head) {
$html .= '</tr></thead>';
$this->head = false;
} elseif ($this->body) {
$html .= '</tr></tbody>';
$this->body = false;
}
$html .= '<tfoot>';
}
break;
case 'row':
if ($this->body) {
$html .= '</tr>';
} else {
if ($this->head) {
$html .= '</tr></thead>';
$this->head = false;
} elseif ($this->foot) {
$html .= '</tr></tfoot>';
$this->foot = false;
}
$html .= '<tbody>';
}
break;
case 'table':
if ($this->head) {
$html .= '</tr></thead>';
} elseif ($this->foot) {
$html .= '</tr></tfoot>';
} elseif ($this->body) {
$html .= '</tr></tbody>';
}
break;
}
return $html;
}
|
php
|
private function wrapUp($section)
{
$html = $this->cell;
$this->cell = '';
switch ($section) {
case 'head':
if ($this->head) {
$html .= '</tr>';
} else {
if ($this->foot) {
$html .= '</tr></tfoot>';
$this->foot = false;
} elseif ($this->body) {
$html .= '</tr></tbody>';
$this->body = false;
}
$html .= '<thead>';
}
break;
case 'foot':
if ($this->foot) {
$html .= '</tr>';
} else {
if ($this->head) {
$html .= '</tr></thead>';
$this->head = false;
} elseif ($this->body) {
$html .= '</tr></tbody>';
$this->body = false;
}
$html .= '<tfoot>';
}
break;
case 'row':
if ($this->body) {
$html .= '</tr>';
} else {
if ($this->head) {
$html .= '</tr></thead>';
$this->head = false;
} elseif ($this->foot) {
$html .= '</tr></tfoot>';
$this->foot = false;
}
$html .= '<tbody>';
}
break;
case 'table':
if ($this->head) {
$html .= '</tr></thead>';
} elseif ($this->foot) {
$html .= '</tr></tfoot>';
} elseif ($this->body) {
$html .= '</tr></tbody>';
}
break;
}
return $html;
}
|
[
"private",
"function",
"wrapUp",
"(",
"$",
"section",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"cell",
";",
"$",
"this",
"->",
"cell",
"=",
"''",
";",
"switch",
"(",
"$",
"section",
")",
"{",
"case",
"'head'",
":",
"if",
"(",
"$",
"this",
"->",
"head",
")",
"{",
"$",
"html",
".=",
"'</tr>'",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"foot",
")",
"{",
"$",
"html",
".=",
"'</tr></tfoot>'",
";",
"$",
"this",
"->",
"foot",
"=",
"false",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"body",
")",
"{",
"$",
"html",
".=",
"'</tr></tbody>'",
";",
"$",
"this",
"->",
"body",
"=",
"false",
";",
"}",
"$",
"html",
".=",
"'<thead>'",
";",
"}",
"break",
";",
"case",
"'foot'",
":",
"if",
"(",
"$",
"this",
"->",
"foot",
")",
"{",
"$",
"html",
".=",
"'</tr>'",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"head",
")",
"{",
"$",
"html",
".=",
"'</tr></thead>'",
";",
"$",
"this",
"->",
"head",
"=",
"false",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"body",
")",
"{",
"$",
"html",
".=",
"'</tr></tbody>'",
";",
"$",
"this",
"->",
"body",
"=",
"false",
";",
"}",
"$",
"html",
".=",
"'<tfoot>'",
";",
"}",
"break",
";",
"case",
"'row'",
":",
"if",
"(",
"$",
"this",
"->",
"body",
")",
"{",
"$",
"html",
".=",
"'</tr>'",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"head",
")",
"{",
"$",
"html",
".=",
"'</tr></thead>'",
";",
"$",
"this",
"->",
"head",
"=",
"false",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"foot",
")",
"{",
"$",
"html",
".=",
"'</tr></tfoot>'",
";",
"$",
"this",
"->",
"foot",
"=",
"false",
";",
"}",
"$",
"html",
".=",
"'<tbody>'",
";",
"}",
"break",
";",
"case",
"'table'",
":",
"if",
"(",
"$",
"this",
"->",
"head",
")",
"{",
"$",
"html",
".=",
"'</tr></thead>'",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"foot",
")",
"{",
"$",
"html",
".=",
"'</tr></tfoot>'",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"body",
")",
"{",
"$",
"html",
".=",
"'</tr></tbody>'",
";",
"}",
"break",
";",
"}",
"return",
"$",
"html",
";",
"}"
] |
Closes a row's open tags to be ready for the next one.
@param <type> $section
@return <type>
|
[
"Closes",
"a",
"row",
"s",
"open",
"tags",
"to",
"be",
"ready",
"for",
"the",
"next",
"one",
"."
] |
49bc032658b9a57892bdf4041e1b39e5dec0eb0f
|
https://github.com/Kylob/Table/blob/49bc032658b9a57892bdf4041e1b39e5dec0eb0f/src/Component.php#L157-L216
|
11,685
|
jivoo/core
|
src/Cli/CommandBase.php
|
CommandBase.put
|
protected function put($line = '', $eol = PHP_EOL)
{
$this->m->shell->put($line, $eol);
}
|
php
|
protected function put($line = '', $eol = PHP_EOL)
{
$this->m->shell->put($line, $eol);
}
|
[
"protected",
"function",
"put",
"(",
"$",
"line",
"=",
"''",
",",
"$",
"eol",
"=",
"PHP_EOL",
")",
"{",
"$",
"this",
"->",
"m",
"->",
"shell",
"->",
"put",
"(",
"$",
"line",
",",
"$",
"eol",
")",
";",
"}"
] |
Print a line of text to standard output.
@param string $line
Line.
@param string $eol
Line ending, set to '' to prevent line break.
|
[
"Print",
"a",
"line",
"of",
"text",
"to",
"standard",
"output",
"."
] |
4ef3445068f0ff9c0a6512cb741831a847013b76
|
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Cli/CommandBase.php#L114-L117
|
11,686
|
railsphp/framework
|
src/Rails/ActiveModel/Collection.php
|
Collection.remove
|
public function remove(Closure $criteria)
{
foreach ($this->members as $k => $member) {
if ($criteria($member)) {
unset($this->members[$k]);
}
}
$this->members = array_values($this->members);
return $this;
}
|
php
|
public function remove(Closure $criteria)
{
foreach ($this->members as $k => $member) {
if ($criteria($member)) {
unset($this->members[$k]);
}
}
$this->members = array_values($this->members);
return $this;
}
|
[
"public",
"function",
"remove",
"(",
"Closure",
"$",
"criteria",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"members",
"as",
"$",
"k",
"=>",
"$",
"member",
")",
"{",
"if",
"(",
"$",
"criteria",
"(",
"$",
"member",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"members",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"members",
"=",
"array_values",
"(",
"$",
"this",
"->",
"members",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
If criteria returns a non-empty value, that member is removed.
|
[
"If",
"criteria",
"returns",
"a",
"non",
"-",
"empty",
"value",
"that",
"member",
"is",
"removed",
"."
] |
2ac9d3e493035dcc68f3c3812423327127327cd5
|
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActiveModel/Collection.php#L332-L341
|
11,687
|
konservs/brilliant.framework
|
libraries/ConfigCategories/BConfigGeneral.php
|
BConfigGeneral.addgroup_database
|
protected function addgroup_database(){
$this->registerGroup(BLang::_('ADMIN_CONFIG_GENERAL_MYSQL'),'database',array(
new BConfigFieldString(
'MYSQL_DB_HOST',
BLang::_('ADMIN_CONFIG_GENERAL_MYSQL_DBHOST'),
'127.0.0.1'),
new BConfigFieldString(
'MYSQL_DB_USERNAME',
BLang::_('ADMIN_CONFIG_GENERAL_MYSQL_DBUSERNAME'),
'root'),
new BConfigFieldPassword(
'MYSQL_DB_PASSWORD',
BLang::_('ADMIN_CONFIG_GENERAL_MYSQL_DBPASSWORD'),
''),
new BConfigFieldString(
'MYSQL_DB_NAME',
BLang::_('ADMIN_CONFIG_GENERAL_MYSQL_DBNAME'),
'vidido')
));
}
|
php
|
protected function addgroup_database(){
$this->registerGroup(BLang::_('ADMIN_CONFIG_GENERAL_MYSQL'),'database',array(
new BConfigFieldString(
'MYSQL_DB_HOST',
BLang::_('ADMIN_CONFIG_GENERAL_MYSQL_DBHOST'),
'127.0.0.1'),
new BConfigFieldString(
'MYSQL_DB_USERNAME',
BLang::_('ADMIN_CONFIG_GENERAL_MYSQL_DBUSERNAME'),
'root'),
new BConfigFieldPassword(
'MYSQL_DB_PASSWORD',
BLang::_('ADMIN_CONFIG_GENERAL_MYSQL_DBPASSWORD'),
''),
new BConfigFieldString(
'MYSQL_DB_NAME',
BLang::_('ADMIN_CONFIG_GENERAL_MYSQL_DBNAME'),
'vidido')
));
}
|
[
"protected",
"function",
"addgroup_database",
"(",
")",
"{",
"$",
"this",
"->",
"registerGroup",
"(",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_MYSQL'",
")",
",",
"'database'",
",",
"array",
"(",
"new",
"BConfigFieldString",
"(",
"'MYSQL_DB_HOST'",
",",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_MYSQL_DBHOST'",
")",
",",
"'127.0.0.1'",
")",
",",
"new",
"BConfigFieldString",
"(",
"'MYSQL_DB_USERNAME'",
",",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_MYSQL_DBUSERNAME'",
")",
",",
"'root'",
")",
",",
"new",
"BConfigFieldPassword",
"(",
"'MYSQL_DB_PASSWORD'",
",",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_MYSQL_DBPASSWORD'",
")",
",",
"''",
")",
",",
"new",
"BConfigFieldString",
"(",
"'MYSQL_DB_NAME'",
",",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_MYSQL_DBNAME'",
")",
",",
"'vidido'",
")",
")",
")",
";",
"}"
] |
Adding the group of database settings - MySQL host, username, password
and database name
|
[
"Adding",
"the",
"group",
"of",
"database",
"settings",
"-",
"MySQL",
"host",
"username",
"password",
"and",
"database",
"name"
] |
95f03f1917f746fee98bea8a906ba0588c87762d
|
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/ConfigCategories/BConfigGeneral.php#L124-L143
|
11,688
|
konservs/brilliant.framework
|
libraries/ConfigCategories/BConfigGeneral.php
|
BConfigGeneral.addgroup_email
|
protected function addgroup_email(){
$this->registerGroup(BLang::_('ADMIN_CONFIG_GENERAL_EMAIL'),'email',array(
new BConfigFieldString(
'EMAIL_SEND_EFROM',
BLang::_('ADMIN_CONFIG_GENERAL_EMAIL_SENDEFROM'),
'noreply@vidido.ua'),
new BConfigFieldString(
'EMAIL_SEND_NFROM',
BLang::_('ADMIN_CONFIG_GENERAL_EMAIL_SENDNFROM'),
'Vid i DO noreply'),
new BConfigFieldList(
'EMAIL_SEND_TYPE',
BLang::_('ADMIN_CONFIG_GENERAL_EMAIL_SENDTYPE'),
array(
1=>BLang::_('ADMIN_CONFIG_GENERAL_EMAIL_SENDTYPE1'),
2=>BLang::_('ADMIN_CONFIG_GENERAL_EMAIL_SENDTYPE2')
)
),
));
}
|
php
|
protected function addgroup_email(){
$this->registerGroup(BLang::_('ADMIN_CONFIG_GENERAL_EMAIL'),'email',array(
new BConfigFieldString(
'EMAIL_SEND_EFROM',
BLang::_('ADMIN_CONFIG_GENERAL_EMAIL_SENDEFROM'),
'noreply@vidido.ua'),
new BConfigFieldString(
'EMAIL_SEND_NFROM',
BLang::_('ADMIN_CONFIG_GENERAL_EMAIL_SENDNFROM'),
'Vid i DO noreply'),
new BConfigFieldList(
'EMAIL_SEND_TYPE',
BLang::_('ADMIN_CONFIG_GENERAL_EMAIL_SENDTYPE'),
array(
1=>BLang::_('ADMIN_CONFIG_GENERAL_EMAIL_SENDTYPE1'),
2=>BLang::_('ADMIN_CONFIG_GENERAL_EMAIL_SENDTYPE2')
)
),
));
}
|
[
"protected",
"function",
"addgroup_email",
"(",
")",
"{",
"$",
"this",
"->",
"registerGroup",
"(",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_EMAIL'",
")",
",",
"'email'",
",",
"array",
"(",
"new",
"BConfigFieldString",
"(",
"'EMAIL_SEND_EFROM'",
",",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_EMAIL_SENDEFROM'",
")",
",",
"'noreply@vidido.ua'",
")",
",",
"new",
"BConfigFieldString",
"(",
"'EMAIL_SEND_NFROM'",
",",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_EMAIL_SENDNFROM'",
")",
",",
"'Vid i DO noreply'",
")",
",",
"new",
"BConfigFieldList",
"(",
"'EMAIL_SEND_TYPE'",
",",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_EMAIL_SENDTYPE'",
")",
",",
"array",
"(",
"1",
"=>",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_EMAIL_SENDTYPE1'",
")",
",",
"2",
"=>",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_EMAIL_SENDTYPE2'",
")",
")",
")",
",",
")",
")",
";",
"}"
] |
Adding the group of email & contacts settings
|
[
"Adding",
"the",
"group",
"of",
"email",
"&",
"contacts",
"settings"
] |
95f03f1917f746fee98bea8a906ba0588c87762d
|
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/ConfigCategories/BConfigGeneral.php#L147-L166
|
11,689
|
konservs/brilliant.framework
|
libraries/ConfigCategories/BConfigGeneral.php
|
BConfigGeneral.addgroup_hostnames
|
protected function addgroup_hostnames(){
$this->registerGroup(BLang::_('ADMIN_CONFIG_GENERAL_HOSTNAMES'),'hostnames',array(
new BConfigFieldString(
'BHOSTNAME',
BLang::_('ADMIN_CONFIG_GENERAL_BHOSTNAME'),
'vidido.ua'),
new BConfigFieldString(
'BHOSTNAME_STATIC',
BLang::_('ADMIN_CONFIG_GENERAL_BHOSTNAME_STATIC'),
'static.vidido.ua'),
new BConfigFieldString(
'BHOSTNAME_MEDIA',
BLang::_('ADMIN_CONFIG_GENERAL_BHOSTNAME_MEDIA'),
'media.vidido.ua')
));
}
|
php
|
protected function addgroup_hostnames(){
$this->registerGroup(BLang::_('ADMIN_CONFIG_GENERAL_HOSTNAMES'),'hostnames',array(
new BConfigFieldString(
'BHOSTNAME',
BLang::_('ADMIN_CONFIG_GENERAL_BHOSTNAME'),
'vidido.ua'),
new BConfigFieldString(
'BHOSTNAME_STATIC',
BLang::_('ADMIN_CONFIG_GENERAL_BHOSTNAME_STATIC'),
'static.vidido.ua'),
new BConfigFieldString(
'BHOSTNAME_MEDIA',
BLang::_('ADMIN_CONFIG_GENERAL_BHOSTNAME_MEDIA'),
'media.vidido.ua')
));
}
|
[
"protected",
"function",
"addgroup_hostnames",
"(",
")",
"{",
"$",
"this",
"->",
"registerGroup",
"(",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_HOSTNAMES'",
")",
",",
"'hostnames'",
",",
"array",
"(",
"new",
"BConfigFieldString",
"(",
"'BHOSTNAME'",
",",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_BHOSTNAME'",
")",
",",
"'vidido.ua'",
")",
",",
"new",
"BConfigFieldString",
"(",
"'BHOSTNAME_STATIC'",
",",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_BHOSTNAME_STATIC'",
")",
",",
"'static.vidido.ua'",
")",
",",
"new",
"BConfigFieldString",
"(",
"'BHOSTNAME_MEDIA'",
",",
"BLang",
"::",
"_",
"(",
"'ADMIN_CONFIG_GENERAL_BHOSTNAME_MEDIA'",
")",
",",
"'media.vidido.ua'",
")",
")",
")",
";",
"}"
] |
Adding fields group with hostnames
|
[
"Adding",
"fields",
"group",
"with",
"hostnames"
] |
95f03f1917f746fee98bea8a906ba0588c87762d
|
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/ConfigCategories/BConfigGeneral.php#L218-L233
|
11,690
|
crisu83/yii-caviar
|
src/components/Compiler.php
|
Compiler.compile
|
public function compile($template, $data)
{
foreach ($data as $key => $value) {
// TODO refactor code so that we do not need this check
if (!is_string($value)) {
continue;
}
$template = preg_replace("/\\$$key\\$/i", $value, $template);
}
return preg_replace('/(<?php)/', "$1\n" . $this->renderBanner(), $template, 1);
}
|
php
|
public function compile($template, $data)
{
foreach ($data as $key => $value) {
// TODO refactor code so that we do not need this check
if (!is_string($value)) {
continue;
}
$template = preg_replace("/\\$$key\\$/i", $value, $template);
}
return preg_replace('/(<?php)/', "$1\n" . $this->renderBanner(), $template, 1);
}
|
[
"public",
"function",
"compile",
"(",
"$",
"template",
",",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// TODO refactor code so that we do not need this check",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"continue",
";",
"}",
"$",
"template",
"=",
"preg_replace",
"(",
"\"/\\\\$$key\\\\$/i\"",
",",
"$",
"value",
",",
"$",
"template",
")",
";",
"}",
"return",
"preg_replace",
"(",
"'/(<?php)/'",
",",
"\"$1\\n\"",
".",
"$",
"this",
"->",
"renderBanner",
"(",
")",
",",
"$",
"template",
",",
"1",
")",
";",
"}"
] |
Compiles a template using the given data.
@param string $template
@param array $data
@return string
|
[
"Compiles",
"a",
"template",
"using",
"the",
"given",
"data",
"."
] |
c85286b88e68558224e7f2ea7fff8f6975e46283
|
https://github.com/crisu83/yii-caviar/blob/c85286b88e68558224e7f2ea7fff8f6975e46283/src/components/Compiler.php#L22-L34
|
11,691
|
mxc-commons/mxc-servicemanager
|
src/AbstractFactory/ConfigAbstractFactory.php
|
ConfigAbstractFactory.canCreate
|
public function canCreate(\Interop\Container\ContainerInterface $container, $requestedName)
{
$this->getConfig($container, $requestedName);
return isset($this->dependencies[$requestedName]);
}
|
php
|
public function canCreate(\Interop\Container\ContainerInterface $container, $requestedName)
{
$this->getConfig($container, $requestedName);
return isset($this->dependencies[$requestedName]);
}
|
[
"public",
"function",
"canCreate",
"(",
"\\",
"Interop",
"\\",
"Container",
"\\",
"ContainerInterface",
"$",
"container",
",",
"$",
"requestedName",
")",
"{",
"$",
"this",
"->",
"getConfig",
"(",
"$",
"container",
",",
"$",
"requestedName",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"requestedName",
"]",
")",
";",
"}"
] |
Factory can create the service if there is a key for it in the config
{@inheritdoc}
|
[
"Factory",
"can",
"create",
"the",
"service",
"if",
"there",
"is",
"a",
"key",
"for",
"it",
"in",
"the",
"config"
] |
547a9ed579b96d32cb54db5723510d75fcad71be
|
https://github.com/mxc-commons/mxc-servicemanager/blob/547a9ed579b96d32cb54db5723510d75fcad71be/src/AbstractFactory/ConfigAbstractFactory.php#L51-L55
|
11,692
|
Koudela/eArc-tree
|
src/Traits/NodeTrait.php
|
NodeTrait.initNodeTrait
|
protected function initNodeTrait(?NodeInterface $parent = null, ?string $name = null)
{
$this->nodeName = $name ?? spl_object_hash($this);
if (!$parent) {
$this->nodeRoot = $this;
$this->nodeParent = $this;
} else {
$this->nodeRoot = $parent->getRoot();
$this->nodeParent = $parent;
/** @noinspection PhpParamsInspection */
$parent->addChild($this);
}
}
|
php
|
protected function initNodeTrait(?NodeInterface $parent = null, ?string $name = null)
{
$this->nodeName = $name ?? spl_object_hash($this);
if (!$parent) {
$this->nodeRoot = $this;
$this->nodeParent = $this;
} else {
$this->nodeRoot = $parent->getRoot();
$this->nodeParent = $parent;
/** @noinspection PhpParamsInspection */
$parent->addChild($this);
}
}
|
[
"protected",
"function",
"initNodeTrait",
"(",
"?",
"NodeInterface",
"$",
"parent",
"=",
"null",
",",
"?",
"string",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"nodeName",
"=",
"$",
"name",
"??",
"spl_object_hash",
"(",
"$",
"this",
")",
";",
"if",
"(",
"!",
"$",
"parent",
")",
"{",
"$",
"this",
"->",
"nodeRoot",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"nodeParent",
"=",
"$",
"this",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"nodeRoot",
"=",
"$",
"parent",
"->",
"getRoot",
"(",
")",
";",
"$",
"this",
"->",
"nodeParent",
"=",
"$",
"parent",
";",
"/** @noinspection PhpParamsInspection */",
"$",
"parent",
"->",
"addChild",
"(",
"$",
"this",
")",
";",
"}",
"}"
] |
Call this function in the constructor.
@param NodeInterface|null $parent
@param string|null $name
@throws NodeOverwriteException
|
[
"Call",
"this",
"function",
"in",
"the",
"constructor",
"."
] |
811c4341e0eda6e85ae535a87af87f3ed461a7f2
|
https://github.com/Koudela/eArc-tree/blob/811c4341e0eda6e85ae535a87af87f3ed461a7f2/src/Traits/NodeTrait.php#L45-L58
|
11,693
|
remi-san/mini-game
|
src/Entity/PlayTrait.php
|
PlayTrait.play
|
public function play(PlayerId $playerId, Move $move)
{
$playMethod = 'play' . $this->getClassName($move);
if (! method_exists($this, $playMethod)) {
throw new IllegalMoveException($move, 'Error: move was not recognized!');
}
return $this->$playMethod($playerId, $move);
}
|
php
|
public function play(PlayerId $playerId, Move $move)
{
$playMethod = 'play' . $this->getClassName($move);
if (! method_exists($this, $playMethod)) {
throw new IllegalMoveException($move, 'Error: move was not recognized!');
}
return $this->$playMethod($playerId, $move);
}
|
[
"public",
"function",
"play",
"(",
"PlayerId",
"$",
"playerId",
",",
"Move",
"$",
"move",
")",
"{",
"$",
"playMethod",
"=",
"'play'",
".",
"$",
"this",
"->",
"getClassName",
"(",
"$",
"move",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"playMethod",
")",
")",
"{",
"throw",
"new",
"IllegalMoveException",
"(",
"$",
"move",
",",
"'Error: move was not recognized!'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"$",
"playMethod",
"(",
"$",
"playerId",
",",
"$",
"move",
")",
";",
"}"
] |
Allows the player to play the game
@param PlayerId $playerId
@param Move $move
@throws IllegalMoveException
@return GameResult
|
[
"Allows",
"the",
"player",
"to",
"play",
"the",
"game"
] |
9e0e61bad58c82102f551cc2e9d46ddc7599b063
|
https://github.com/remi-san/mini-game/blob/9e0e61bad58c82102f551cc2e9d46ddc7599b063/src/Entity/PlayTrait.php#L21-L30
|
11,694
|
zozlak/PHPutil
|
src/zozlak/util/SqlCopy.php
|
SqlCopy.insertRow
|
public function insertRow($row): void {
if ($this->connection === null) {
throw new \RuntimeException('Copying already ended. Create a new object');
}
if (is_array($row)) {
$row = $this->escape($row);
}
$wynik = @pg_put_line($this->connection, $row);
if ($wynik === false) {
throw new \RuntimeException('Failed to insert the row');
}
}
|
php
|
public function insertRow($row): void {
if ($this->connection === null) {
throw new \RuntimeException('Copying already ended. Create a new object');
}
if (is_array($row)) {
$row = $this->escape($row);
}
$wynik = @pg_put_line($this->connection, $row);
if ($wynik === false) {
throw new \RuntimeException('Failed to insert the row');
}
}
|
[
"public",
"function",
"insertRow",
"(",
"$",
"row",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"connection",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Copying already ended. Create a new object'",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"row",
")",
")",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"escape",
"(",
"$",
"row",
")",
";",
"}",
"$",
"wynik",
"=",
"@",
"pg_put_line",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"row",
")",
";",
"if",
"(",
"$",
"wynik",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Failed to insert the row'",
")",
";",
"}",
"}"
] |
Ingests a row of data.
@param type $row row to be ingested into the database (an array or an
already properly escaped input row)
@return void
@throws \RuntimeException
|
[
"Ingests",
"a",
"row",
"of",
"data",
"."
] |
85a5fd64dd762047cfcee3ba3d21e50d7bd7afec
|
https://github.com/zozlak/PHPutil/blob/85a5fd64dd762047cfcee3ba3d21e50d7bd7afec/src/zozlak/util/SqlCopy.php#L85-L96
|
11,695
|
lucifurious/kisma
|
src/Kisma/Core/Services/Session.php
|
Session.initialize
|
public static function initialize( $startSession = true )
{
\ini_set( 'session.gc_maxlifetime', self::SessionCookieGcTimeout + self::SessionCookieLifetime );
\session_set_cookie_params( self::SessionCookieLifetime, self::SessionCookiePath );
\session_start();
// Ensure we can write by registering a shutdown function
\register_shutdown_function( 'session_write_close' );
}
|
php
|
public static function initialize( $startSession = true )
{
\ini_set( 'session.gc_maxlifetime', self::SessionCookieGcTimeout + self::SessionCookieLifetime );
\session_set_cookie_params( self::SessionCookieLifetime, self::SessionCookiePath );
\session_start();
// Ensure we can write by registering a shutdown function
\register_shutdown_function( 'session_write_close' );
}
|
[
"public",
"static",
"function",
"initialize",
"(",
"$",
"startSession",
"=",
"true",
")",
"{",
"\\",
"ini_set",
"(",
"'session.gc_maxlifetime'",
",",
"self",
"::",
"SessionCookieGcTimeout",
"+",
"self",
"::",
"SessionCookieLifetime",
")",
";",
"\\",
"session_set_cookie_params",
"(",
"self",
"::",
"SessionCookieLifetime",
",",
"self",
"::",
"SessionCookiePath",
")",
";",
"\\",
"session_start",
"(",
")",
";",
"//\tEnsure we can write by registering a shutdown function",
"\\",
"register_shutdown_function",
"(",
"'session_write_close'",
")",
";",
"}"
] |
Initializes the database
@static
@param bool $startSession
|
[
"Initializes",
"the",
"database"
] |
4cc9954249da4e535b52f154e728935f07e648ae
|
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Services/Session.php#L73-L81
|
11,696
|
carno-php/monitor
|
src/Daemon.php
|
Daemon.starting
|
protected function starting() : void
{
$this->agg = (new Aggregator($this))->start();
$this->out = (new Prometheus($this->host, $this->app, $this->agg))->start($this->listener, $this->gateway);
$this->cls = (new Cleaner($this))->start();
}
|
php
|
protected function starting() : void
{
$this->agg = (new Aggregator($this))->start();
$this->out = (new Prometheus($this->host, $this->app, $this->agg))->start($this->listener, $this->gateway);
$this->cls = (new Cleaner($this))->start();
}
|
[
"protected",
"function",
"starting",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"agg",
"=",
"(",
"new",
"Aggregator",
"(",
"$",
"this",
")",
")",
"->",
"start",
"(",
")",
";",
"$",
"this",
"->",
"out",
"=",
"(",
"new",
"Prometheus",
"(",
"$",
"this",
"->",
"host",
",",
"$",
"this",
"->",
"app",
",",
"$",
"this",
"->",
"agg",
")",
")",
"->",
"start",
"(",
"$",
"this",
"->",
"listener",
",",
"$",
"this",
"->",
"gateway",
")",
";",
"$",
"this",
"->",
"cls",
"=",
"(",
"new",
"Cleaner",
"(",
"$",
"this",
")",
")",
"->",
"start",
"(",
")",
";",
"}"
] |
triggered when process started
|
[
"triggered",
"when",
"process",
"started"
] |
7a6f82df92d65f0fba9337b5f503664f69c54324
|
https://github.com/carno-php/monitor/blob/7a6f82df92d65f0fba9337b5f503664f69c54324/src/Daemon.php#L90-L95
|
11,697
|
carno-php/monitor
|
src/Daemon.php
|
Daemon.stopping
|
protected function stopping(Promised $wait) : void
{
$this->cls->stop();
$this->out->stop();
$this->agg->stop()->sync($wait);
}
|
php
|
protected function stopping(Promised $wait) : void
{
$this->cls->stop();
$this->out->stop();
$this->agg->stop()->sync($wait);
}
|
[
"protected",
"function",
"stopping",
"(",
"Promised",
"$",
"wait",
")",
":",
"void",
"{",
"$",
"this",
"->",
"cls",
"->",
"stop",
"(",
")",
";",
"$",
"this",
"->",
"out",
"->",
"stop",
"(",
")",
";",
"$",
"this",
"->",
"agg",
"->",
"stop",
"(",
")",
"->",
"sync",
"(",
"$",
"wait",
")",
";",
"}"
] |
triggered when process exiting
@param Promised $wait
|
[
"triggered",
"when",
"process",
"exiting"
] |
7a6f82df92d65f0fba9337b5f503664f69c54324
|
https://github.com/carno-php/monitor/blob/7a6f82df92d65f0fba9337b5f503664f69c54324/src/Daemon.php#L101-L106
|
11,698
|
asgardmodules/captcha
|
Libs/Captcha.php
|
Captcha.image
|
public static function image($width='120', $height='40', $characters='6') {
$font = __DIR__.'/../'.static::$font;
$code = static::generateCode($characters);
#todo, utiliser comme service?
\Asgard\Container\Container::singleton()['httpKernel']->getRequest()->session->set('captcha', $code);
/* font size will be 75% of the image height */
$font_size = $height * 0.75;
if(!$image = imagecreate($width, $height))
throw new Exception('Cannot initialize new GD image stream');
/* set the colours */
$background_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 20, 40, 100);
$noise_color = imagecolorallocate($image, 100, 120, 180);
/* generate random dots in background */
for($i=0; $i<($width*$height)/3; $i++)
imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
/* generate random lines in background */
for( $i=0; $i<($width*$height)/150; $i++ )
imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
/* create textbox and add text */
if(!$textbox = imagettfbbox($font_size, 0, $font, $code))
throw new Exception('Error in imagettfbbox function');
$x = ($width - $textbox[4])/2;
$y = ($height - $textbox[5])/2;
if(!imagettftext($image, $font_size, 0, $x, $y, $text_color, $font , $code))
throw new Exception('Error in imagettftext function');
return $image;
}
|
php
|
public static function image($width='120', $height='40', $characters='6') {
$font = __DIR__.'/../'.static::$font;
$code = static::generateCode($characters);
#todo, utiliser comme service?
\Asgard\Container\Container::singleton()['httpKernel']->getRequest()->session->set('captcha', $code);
/* font size will be 75% of the image height */
$font_size = $height * 0.75;
if(!$image = imagecreate($width, $height))
throw new Exception('Cannot initialize new GD image stream');
/* set the colours */
$background_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 20, 40, 100);
$noise_color = imagecolorallocate($image, 100, 120, 180);
/* generate random dots in background */
for($i=0; $i<($width*$height)/3; $i++)
imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
/* generate random lines in background */
for( $i=0; $i<($width*$height)/150; $i++ )
imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
/* create textbox and add text */
if(!$textbox = imagettfbbox($font_size, 0, $font, $code))
throw new Exception('Error in imagettfbbox function');
$x = ($width - $textbox[4])/2;
$y = ($height - $textbox[5])/2;
if(!imagettftext($image, $font_size, 0, $x, $y, $text_color, $font , $code))
throw new Exception('Error in imagettftext function');
return $image;
}
|
[
"public",
"static",
"function",
"image",
"(",
"$",
"width",
"=",
"'120'",
",",
"$",
"height",
"=",
"'40'",
",",
"$",
"characters",
"=",
"'6'",
")",
"{",
"$",
"font",
"=",
"__DIR__",
".",
"'/../'",
".",
"static",
"::",
"$",
"font",
";",
"$",
"code",
"=",
"static",
"::",
"generateCode",
"(",
"$",
"characters",
")",
";",
"#todo, utiliser comme service?",
"\\",
"Asgard",
"\\",
"Container",
"\\",
"Container",
"::",
"singleton",
"(",
")",
"[",
"'httpKernel'",
"]",
"->",
"getRequest",
"(",
")",
"->",
"session",
"->",
"set",
"(",
"'captcha'",
",",
"$",
"code",
")",
";",
"/* font size will be 75% of the image height */",
"$",
"font_size",
"=",
"$",
"height",
"*",
"0.75",
";",
"if",
"(",
"!",
"$",
"image",
"=",
"imagecreate",
"(",
"$",
"width",
",",
"$",
"height",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Cannot initialize new GD image stream'",
")",
";",
"/* set the colours */",
"$",
"background_color",
"=",
"imagecolorallocate",
"(",
"$",
"image",
",",
"255",
",",
"255",
",",
"255",
")",
";",
"$",
"text_color",
"=",
"imagecolorallocate",
"(",
"$",
"image",
",",
"20",
",",
"40",
",",
"100",
")",
";",
"$",
"noise_color",
"=",
"imagecolorallocate",
"(",
"$",
"image",
",",
"100",
",",
"120",
",",
"180",
")",
";",
"/* generate random dots in background */",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"(",
"$",
"width",
"*",
"$",
"height",
")",
"/",
"3",
";",
"$",
"i",
"++",
")",
"imagefilledellipse",
"(",
"$",
"image",
",",
"mt_rand",
"(",
"0",
",",
"$",
"width",
")",
",",
"mt_rand",
"(",
"0",
",",
"$",
"height",
")",
",",
"1",
",",
"1",
",",
"$",
"noise_color",
")",
";",
"/* generate random lines in background */",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"(",
"$",
"width",
"*",
"$",
"height",
")",
"/",
"150",
";",
"$",
"i",
"++",
")",
"imageline",
"(",
"$",
"image",
",",
"mt_rand",
"(",
"0",
",",
"$",
"width",
")",
",",
"mt_rand",
"(",
"0",
",",
"$",
"height",
")",
",",
"mt_rand",
"(",
"0",
",",
"$",
"width",
")",
",",
"mt_rand",
"(",
"0",
",",
"$",
"height",
")",
",",
"$",
"noise_color",
")",
";",
"/* create textbox and add text */",
"if",
"(",
"!",
"$",
"textbox",
"=",
"imagettfbbox",
"(",
"$",
"font_size",
",",
"0",
",",
"$",
"font",
",",
"$",
"code",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Error in imagettfbbox function'",
")",
";",
"$",
"x",
"=",
"(",
"$",
"width",
"-",
"$",
"textbox",
"[",
"4",
"]",
")",
"/",
"2",
";",
"$",
"y",
"=",
"(",
"$",
"height",
"-",
"$",
"textbox",
"[",
"5",
"]",
")",
"/",
"2",
";",
"if",
"(",
"!",
"imagettftext",
"(",
"$",
"image",
",",
"$",
"font_size",
",",
"0",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"text_color",
",",
"$",
"font",
",",
"$",
"code",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Error in imagettftext function'",
")",
";",
"return",
"$",
"image",
";",
"}"
] |
Generates a captcha image.
@param integer width Image width.
@param integer height Image height.
@param integer characters String length.
@throws \Exception Problem with GD.
@return Ressource Image ressource.
@api
|
[
"Generates",
"a",
"captcha",
"image",
"."
] |
448c2bcaef7a0142d483a8bb6ca00bf7dedf310b
|
https://github.com/asgardmodules/captcha/blob/448c2bcaef7a0142d483a8bb6ca00bf7dedf310b/Libs/Captcha.php#L42-L70
|
11,699
|
BapCat/Persist
|
src/Driver.php
|
Driver.getFile
|
public function getFile(string $path): File {
if($this->isDir($path)) {
throw new NotAFileException($path);
}
return $this->instantiateFile($path);
}
|
php
|
public function getFile(string $path): File {
if($this->isDir($path)) {
throw new NotAFileException($path);
}
return $this->instantiateFile($path);
}
|
[
"public",
"function",
"getFile",
"(",
"string",
"$",
"path",
")",
":",
"File",
"{",
"if",
"(",
"$",
"this",
"->",
"isDir",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"NotAFileException",
"(",
"$",
"path",
")",
";",
"}",
"return",
"$",
"this",
"->",
"instantiateFile",
"(",
"$",
"path",
")",
";",
"}"
] |
Gets a file from the storage medium
@param string $path The path of the file
@return File A file object
@throws NotAFileException if <tt>$path</tt> is not a file
|
[
"Gets",
"a",
"file",
"from",
"the",
"storage",
"medium"
] |
0bc53dc50d0c40ecb519c88e33d77889619dbc20
|
https://github.com/BapCat/Persist/blob/0bc53dc50d0c40ecb519c88e33d77889619dbc20/src/Driver.php#L17-L23
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.