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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
235,700
|
tacowordpress/util
|
src/Util/Collection.php
|
Collection.uniq
|
public static function uniq($collection = null, $is_sorted = null, $iterator = null)
{
$return = array();
if (count($collection) === 0) {
return $return;
}
$calculated = array();
foreach ($collection as $item) {
$val = (!is_null($iterator)) ? $iterator($item) : $item;
if (is_bool(array_search($val, $calculated, true))) {
$calculated[] = $val;
$return[] = $item;
}
}
return $return;
}
|
php
|
public static function uniq($collection = null, $is_sorted = null, $iterator = null)
{
$return = array();
if (count($collection) === 0) {
return $return;
}
$calculated = array();
foreach ($collection as $item) {
$val = (!is_null($iterator)) ? $iterator($item) : $item;
if (is_bool(array_search($val, $calculated, true))) {
$calculated[] = $val;
$return[] = $item;
}
}
return $return;
}
|
[
"public",
"static",
"function",
"uniq",
"(",
"$",
"collection",
"=",
"null",
",",
"$",
"is_sorted",
"=",
"null",
",",
"$",
"iterator",
"=",
"null",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"collection",
")",
"===",
"0",
")",
"{",
"return",
"$",
"return",
";",
"}",
"$",
"calculated",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"item",
")",
"{",
"$",
"val",
"=",
"(",
"!",
"is_null",
"(",
"$",
"iterator",
")",
")",
"?",
"$",
"iterator",
"(",
"$",
"item",
")",
":",
"$",
"item",
";",
"if",
"(",
"is_bool",
"(",
"array_search",
"(",
"$",
"val",
",",
"$",
"calculated",
",",
"true",
")",
")",
")",
"{",
"$",
"calculated",
"[",
"]",
"=",
"$",
"val",
";",
"$",
"return",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
Return an array of the unique values
|
[
"Return",
"an",
"array",
"of",
"the",
"unique",
"values"
] |
a27f6f1c3f96a908c7480f359fd44028e89f26c3
|
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Collection.php#L64-L81
|
235,701
|
tacowordpress/util
|
src/Util/Collection.php
|
Collection.first
|
public static function first($collection = null, $n = null)
{
if ($n === 0) {
return array();
}
if (is_null($n)) {
return current(array_splice($collection, 0, 1, true));
}
return array_splice($collection, 0, $n, true);
}
|
php
|
public static function first($collection = null, $n = null)
{
if ($n === 0) {
return array();
}
if (is_null($n)) {
return current(array_splice($collection, 0, 1, true));
}
return array_splice($collection, 0, $n, true);
}
|
[
"public",
"static",
"function",
"first",
"(",
"$",
"collection",
"=",
"null",
",",
"$",
"n",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"n",
"===",
"0",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"n",
")",
")",
"{",
"return",
"current",
"(",
"array_splice",
"(",
"$",
"collection",
",",
"0",
",",
"1",
",",
"true",
")",
")",
";",
"}",
"return",
"array_splice",
"(",
"$",
"collection",
",",
"0",
",",
"$",
"n",
",",
"true",
")",
";",
"}"
] |
Get the first element of an array. Passing n returns the first n elements.
|
[
"Get",
"the",
"first",
"element",
"of",
"an",
"array",
".",
"Passing",
"n",
"returns",
"the",
"first",
"n",
"elements",
"."
] |
a27f6f1c3f96a908c7480f359fd44028e89f26c3
|
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Collection.php#L84-L93
|
235,702
|
tacowordpress/util
|
src/Util/Collection.php
|
Collection.rest
|
public static function rest($collection = null, $index = null)
{
if (is_null($index)) {
$index = 1;
}
return array_splice($collection, $index);
}
|
php
|
public static function rest($collection = null, $index = null)
{
if (is_null($index)) {
$index = 1;
}
return array_splice($collection, $index);
}
|
[
"public",
"static",
"function",
"rest",
"(",
"$",
"collection",
"=",
"null",
",",
"$",
"index",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"index",
")",
")",
"{",
"$",
"index",
"=",
"1",
";",
"}",
"return",
"array_splice",
"(",
"$",
"collection",
",",
"$",
"index",
")",
";",
"}"
] |
Get the rest of the array elements. Passing n returns from that index onward.
|
[
"Get",
"the",
"rest",
"of",
"the",
"array",
"elements",
".",
"Passing",
"n",
"returns",
"from",
"that",
"index",
"onward",
"."
] |
a27f6f1c3f96a908c7480f359fd44028e89f26c3
|
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Collection.php#L109-L115
|
235,703
|
tacowordpress/util
|
src/Util/Collection.php
|
Collection.filter
|
public function filter($collection = null, $iterator = null)
{
$return = array();
foreach ($collection as $val) {
if (call_user_func($iterator, $val)) {
$return[] = $val;
}
}
return $return;
}
|
php
|
public function filter($collection = null, $iterator = null)
{
$return = array();
foreach ($collection as $val) {
if (call_user_func($iterator, $val)) {
$return[] = $val;
}
}
return $return;
}
|
[
"public",
"function",
"filter",
"(",
"$",
"collection",
"=",
"null",
",",
"$",
"iterator",
"=",
"null",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"val",
")",
"{",
"if",
"(",
"call_user_func",
"(",
"$",
"iterator",
",",
"$",
"val",
")",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
Return an array of values that pass the truth iterator test
|
[
"Return",
"an",
"array",
"of",
"values",
"that",
"pass",
"the",
"truth",
"iterator",
"test"
] |
a27f6f1c3f96a908c7480f359fd44028e89f26c3
|
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Collection.php#L118-L127
|
235,704
|
loopsframework/base
|
src/Loops/Misc.php
|
Misc.getRelativePath
|
public static function getRelativePath($frompath, $topath = "")
{
if(empty($topath)) {
$topath = $frompath;
$frompath = getcwd();
}
if($frompath == ".") $frompath = getcwd();
if($topath == ".") $topath = getcwd();
if($frompath[0] != DIRECTORY_SEPARATOR) $frompath = getcwd().DIRECTORY_SEPARATOR.$frompath;
if($topath[0] != DIRECTORY_SEPARATOR) $topath = getcwd().DIRECTORY_SEPARATOR.$topath;
$from = explode(DIRECTORY_SEPARATOR, $frompath); // Folders/File
$to = explode(DIRECTORY_SEPARATOR, $topath); // Folders/File
$relpath = '';
$i = 0;
// Find how far the path is the same
while (isset($from[$i]) && isset($to[$i])) {
if ($from[$i] != $to[$i])
break;
$i++;
}
$j = count($from) - 1;
// Add '..' until the path is the same
while ($i <= $j) {
if (!empty($from[$j]))
$relpath .= '..' . DIRECTORY_SEPARATOR;
$j--;
}
// Go to folder from where it starts differing
while (isset($to[$i])) {
if (!empty($to[$i]))
$relpath .= $to[$i] . DIRECTORY_SEPARATOR;
$i++;
}
// Strip last separator
return substr($relpath, 0, -1) ?: ".";
}
|
php
|
public static function getRelativePath($frompath, $topath = "")
{
if(empty($topath)) {
$topath = $frompath;
$frompath = getcwd();
}
if($frompath == ".") $frompath = getcwd();
if($topath == ".") $topath = getcwd();
if($frompath[0] != DIRECTORY_SEPARATOR) $frompath = getcwd().DIRECTORY_SEPARATOR.$frompath;
if($topath[0] != DIRECTORY_SEPARATOR) $topath = getcwd().DIRECTORY_SEPARATOR.$topath;
$from = explode(DIRECTORY_SEPARATOR, $frompath); // Folders/File
$to = explode(DIRECTORY_SEPARATOR, $topath); // Folders/File
$relpath = '';
$i = 0;
// Find how far the path is the same
while (isset($from[$i]) && isset($to[$i])) {
if ($from[$i] != $to[$i])
break;
$i++;
}
$j = count($from) - 1;
// Add '..' until the path is the same
while ($i <= $j) {
if (!empty($from[$j]))
$relpath .= '..' . DIRECTORY_SEPARATOR;
$j--;
}
// Go to folder from where it starts differing
while (isset($to[$i])) {
if (!empty($to[$i]))
$relpath .= $to[$i] . DIRECTORY_SEPARATOR;
$i++;
}
// Strip last separator
return substr($relpath, 0, -1) ?: ".";
}
|
[
"public",
"static",
"function",
"getRelativePath",
"(",
"$",
"frompath",
",",
"$",
"topath",
"=",
"\"\"",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"topath",
")",
")",
"{",
"$",
"topath",
"=",
"$",
"frompath",
";",
"$",
"frompath",
"=",
"getcwd",
"(",
")",
";",
"}",
"if",
"(",
"$",
"frompath",
"==",
"\".\"",
")",
"$",
"frompath",
"=",
"getcwd",
"(",
")",
";",
"if",
"(",
"$",
"topath",
"==",
"\".\"",
")",
"$",
"topath",
"=",
"getcwd",
"(",
")",
";",
"if",
"(",
"$",
"frompath",
"[",
"0",
"]",
"!=",
"DIRECTORY_SEPARATOR",
")",
"$",
"frompath",
"=",
"getcwd",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"frompath",
";",
"if",
"(",
"$",
"topath",
"[",
"0",
"]",
"!=",
"DIRECTORY_SEPARATOR",
")",
"$",
"topath",
"=",
"getcwd",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"topath",
";",
"$",
"from",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"frompath",
")",
";",
"// Folders/File",
"$",
"to",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"topath",
")",
";",
"// Folders/File",
"$",
"relpath",
"=",
"''",
";",
"$",
"i",
"=",
"0",
";",
"// Find how far the path is the same",
"while",
"(",
"isset",
"(",
"$",
"from",
"[",
"$",
"i",
"]",
")",
"&&",
"isset",
"(",
"$",
"to",
"[",
"$",
"i",
"]",
")",
")",
"{",
"if",
"(",
"$",
"from",
"[",
"$",
"i",
"]",
"!=",
"$",
"to",
"[",
"$",
"i",
"]",
")",
"break",
";",
"$",
"i",
"++",
";",
"}",
"$",
"j",
"=",
"count",
"(",
"$",
"from",
")",
"-",
"1",
";",
"// Add '..' until the path is the same",
"while",
"(",
"$",
"i",
"<=",
"$",
"j",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"from",
"[",
"$",
"j",
"]",
")",
")",
"$",
"relpath",
".=",
"'..'",
".",
"DIRECTORY_SEPARATOR",
";",
"$",
"j",
"--",
";",
"}",
"// Go to folder from where it starts differing",
"while",
"(",
"isset",
"(",
"$",
"to",
"[",
"$",
"i",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"to",
"[",
"$",
"i",
"]",
")",
")",
"$",
"relpath",
".=",
"$",
"to",
"[",
"$",
"i",
"]",
".",
"DIRECTORY_SEPARATOR",
";",
"$",
"i",
"++",
";",
"}",
"// Strip last separator",
"return",
"substr",
"(",
"$",
"relpath",
",",
"0",
",",
"-",
"1",
")",
"?",
":",
"\".\"",
";",
"}"
] |
Get the relative path between 2 folders.
@var string $frompath The path from which the relative path should be computed.
@var string $topath The target path. If empty or not specified the current working directory will be used.
@return string The relative path. "$frompath$result" will resolve to $topath
|
[
"Get",
"the",
"relative",
"path",
"between",
"2",
"folders",
"."
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Misc.php#L44-L85
|
235,705
|
loopsframework/base
|
src/Loops/Misc.php
|
Misc.readPartialFile
|
public static function readPartialFile($file, $from = 0, $to = 0, $filesize = FALSE, $force = FALSE, $context = NULL) {
if(!$force) {
if(!@file_exists($file)) {
return 404;
}
if(!@is_readable($file)) {
return 403;
}
}
//open file
if(!($file instanceof SplFileObject)) {
$file = new SplFileObject($file);
}
//get filesize
$filesize = $file->getSize();
if(is_array($from)) {
throw new Exception("Not implemented yet.");
}
if($from < 0) {
$from = $filesize + $from;
}
if($to <= 0) {
$to = $filesize + $to - 1;
}
if($from < 0 || $to >= $filesize || $from > $to) {
throw new Exception("Invalid Range. (filesize: $filesize, from: $from, to: $to)");
}
$file->fseek($from);
$length = $to - $from + 1;
while($length) {
$read = ($length > 8192) ? 8192 : $length;
$length -= $read;
$content = $file->fread($read);
if($content === FALSE) {
return FALSE;
}
else {
print($content);
}
}
return $length;
}
|
php
|
public static function readPartialFile($file, $from = 0, $to = 0, $filesize = FALSE, $force = FALSE, $context = NULL) {
if(!$force) {
if(!@file_exists($file)) {
return 404;
}
if(!@is_readable($file)) {
return 403;
}
}
//open file
if(!($file instanceof SplFileObject)) {
$file = new SplFileObject($file);
}
//get filesize
$filesize = $file->getSize();
if(is_array($from)) {
throw new Exception("Not implemented yet.");
}
if($from < 0) {
$from = $filesize + $from;
}
if($to <= 0) {
$to = $filesize + $to - 1;
}
if($from < 0 || $to >= $filesize || $from > $to) {
throw new Exception("Invalid Range. (filesize: $filesize, from: $from, to: $to)");
}
$file->fseek($from);
$length = $to - $from + 1;
while($length) {
$read = ($length > 8192) ? 8192 : $length;
$length -= $read;
$content = $file->fread($read);
if($content === FALSE) {
return FALSE;
}
else {
print($content);
}
}
return $length;
}
|
[
"public",
"static",
"function",
"readPartialFile",
"(",
"$",
"file",
",",
"$",
"from",
"=",
"0",
",",
"$",
"to",
"=",
"0",
",",
"$",
"filesize",
"=",
"FALSE",
",",
"$",
"force",
"=",
"FALSE",
",",
"$",
"context",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"force",
")",
"{",
"if",
"(",
"!",
"@",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"return",
"404",
";",
"}",
"if",
"(",
"!",
"@",
"is_readable",
"(",
"$",
"file",
")",
")",
"{",
"return",
"403",
";",
"}",
"}",
"//open file",
"if",
"(",
"!",
"(",
"$",
"file",
"instanceof",
"SplFileObject",
")",
")",
"{",
"$",
"file",
"=",
"new",
"SplFileObject",
"(",
"$",
"file",
")",
";",
"}",
"//get filesize",
"$",
"filesize",
"=",
"$",
"file",
"->",
"getSize",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"from",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Not implemented yet.\"",
")",
";",
"}",
"if",
"(",
"$",
"from",
"<",
"0",
")",
"{",
"$",
"from",
"=",
"$",
"filesize",
"+",
"$",
"from",
";",
"}",
"if",
"(",
"$",
"to",
"<=",
"0",
")",
"{",
"$",
"to",
"=",
"$",
"filesize",
"+",
"$",
"to",
"-",
"1",
";",
"}",
"if",
"(",
"$",
"from",
"<",
"0",
"||",
"$",
"to",
">=",
"$",
"filesize",
"||",
"$",
"from",
">",
"$",
"to",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Invalid Range. (filesize: $filesize, from: $from, to: $to)\"",
")",
";",
"}",
"$",
"file",
"->",
"fseek",
"(",
"$",
"from",
")",
";",
"$",
"length",
"=",
"$",
"to",
"-",
"$",
"from",
"+",
"1",
";",
"while",
"(",
"$",
"length",
")",
"{",
"$",
"read",
"=",
"(",
"$",
"length",
">",
"8192",
")",
"?",
"8192",
":",
"$",
"length",
";",
"$",
"length",
"-=",
"$",
"read",
";",
"$",
"content",
"=",
"$",
"file",
"->",
"fread",
"(",
"$",
"read",
")",
";",
"if",
"(",
"$",
"content",
"===",
"FALSE",
")",
"{",
"return",
"FALSE",
";",
"}",
"else",
"{",
"print",
"(",
"$",
"content",
")",
";",
"}",
"}",
"return",
"$",
"length",
";",
"}"
] |
Like PHPs readfile, but the range of the output can be specified
<code>
use Loops\Misc;
Misc::readpartialfile("example.png", 500, 1000);
</code>
Instead of integer ranges an array containing a Content-Range header can be passed.
The values found in this header will be used to output the partial file, making it
possible to use this function in combination with Loops\Misc::servefile
<code>
use Loops\Misc;
$headers = Misc::servefile("example.png", TRUE, TRUE, TRUE);
foreach($headers as $line) {
header($line);
}
Misc::readpartialfile("example.png", $headers);
exit;
</code>
@param string $file The physical location of the file (must be understood by fopen)
@param int|array $from Start file output from this offset or an array containing a Content-Range header line (negative value: n bytes from EOF)
@param int $to Stop file output including this offset (0: EOF, negative value: n bytes from EOF)
@param resource $context The context passed to fopen.
|
[
"Like",
"PHPs",
"readfile",
"but",
"the",
"range",
"of",
"the",
"output",
"can",
"be",
"specified"
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Misc.php#L383-L435
|
235,706
|
loopsframework/base
|
src/Loops/Misc.php
|
Misc.flattenArray
|
public static function flattenArray($array, $delimiter = '.', $prefix = '') {
if(!is_array($array)) {
return $array;
}
$result = array();
foreach($array as $key => $value) {
if(is_array($value)) {
$result = array_merge($result, self::flattenArray($value, $delimiter, $prefix.$key.$delimiter));
}
else {
$result[$prefix.$key] = $value;
}
}
return $result;
}
|
php
|
public static function flattenArray($array, $delimiter = '.', $prefix = '') {
if(!is_array($array)) {
return $array;
}
$result = array();
foreach($array as $key => $value) {
if(is_array($value)) {
$result = array_merge($result, self::flattenArray($value, $delimiter, $prefix.$key.$delimiter));
}
else {
$result[$prefix.$key] = $value;
}
}
return $result;
}
|
[
"public",
"static",
"function",
"flattenArray",
"(",
"$",
"array",
",",
"$",
"delimiter",
"=",
"'.'",
",",
"$",
"prefix",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"return",
"$",
"array",
";",
"}",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"self",
"::",
"flattenArray",
"(",
"$",
"value",
",",
"$",
"delimiter",
",",
"$",
"prefix",
".",
"$",
"key",
".",
"$",
"delimiter",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"prefix",
".",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Flattens an array, preserving keys delimited by a delimiter
@param array $array The array that will be flattened
@param string $delimiter The used delimiter.
@param string $prefix Will be added in front of every key
@return array<mixed> The resulting array
|
[
"Flattens",
"an",
"array",
"preserving",
"keys",
"delimited",
"by",
"a",
"delimiter"
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Misc.php#L445-L462
|
235,707
|
loopsframework/base
|
src/Loops/Misc.php
|
Misc.unflattenArray
|
public static function unflattenArray($array, $delimiter = '.') {
if(!is_array($array)) {
return $array;
}
$add = array();
foreach($array as $key => $value) {
if(strpos($key, $delimiter) === FALSE) {
continue;
}
$add[] = [ explode($delimiter, $key), $value ];
unset($array[$key]);
}
foreach($add as $pair) {
$current = &$array;
while(!is_null($key = array_shift($pair[0]))) {
if(!is_array($current)) {
$current = array();
}
if(!array_key_exists($key, $current)) {
$current[$key] = array();
}
$current = &$current[$key];
}
$current = $pair[1];
}
return $array;
}
|
php
|
public static function unflattenArray($array, $delimiter = '.') {
if(!is_array($array)) {
return $array;
}
$add = array();
foreach($array as $key => $value) {
if(strpos($key, $delimiter) === FALSE) {
continue;
}
$add[] = [ explode($delimiter, $key), $value ];
unset($array[$key]);
}
foreach($add as $pair) {
$current = &$array;
while(!is_null($key = array_shift($pair[0]))) {
if(!is_array($current)) {
$current = array();
}
if(!array_key_exists($key, $current)) {
$current[$key] = array();
}
$current = &$current[$key];
}
$current = $pair[1];
}
return $array;
}
|
[
"public",
"static",
"function",
"unflattenArray",
"(",
"$",
"array",
",",
"$",
"delimiter",
"=",
"'.'",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"return",
"$",
"array",
";",
"}",
"$",
"add",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"$",
"delimiter",
")",
"===",
"FALSE",
")",
"{",
"continue",
";",
"}",
"$",
"add",
"[",
"]",
"=",
"[",
"explode",
"(",
"$",
"delimiter",
",",
"$",
"key",
")",
",",
"$",
"value",
"]",
";",
"unset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"add",
"as",
"$",
"pair",
")",
"{",
"$",
"current",
"=",
"&",
"$",
"array",
";",
"while",
"(",
"!",
"is_null",
"(",
"$",
"key",
"=",
"array_shift",
"(",
"$",
"pair",
"[",
"0",
"]",
")",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"current",
")",
")",
"{",
"$",
"current",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"current",
")",
")",
"{",
"$",
"current",
"[",
"$",
"key",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"current",
"=",
"&",
"$",
"current",
"[",
"$",
"key",
"]",
";",
"}",
"$",
"current",
"=",
"$",
"pair",
"[",
"1",
"]",
";",
"}",
"return",
"$",
"array",
";",
"}"
] |
Unflattens an array by a delimiter.
This is particulary useful to pass complex structures via get/post requests from
forms.
Note: Using a json string should also be considered as an alternative.
<code>
use Loops\Misc;
$flatarray = array(
'a' => 1,
'b.a' => 2,
'b.b' => 3
);
Misc::unflattenArray($flatarray);
// $flatarray = array(
// 'a' => 1,
// 'b' => array(
// 'a' => 2,
// 'b' => 3
// )
// )
</code>
@param array $array The array that will be unflattened.
@param string $delimiter The used delimiter.
@return array The unflattened array
|
[
"Unflattens",
"an",
"array",
"by",
"a",
"delimiter",
"."
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Misc.php#L495-L531
|
235,708
|
loopsframework/base
|
src/Loops/Misc.php
|
Misc.redirect
|
public static function redirect($target, $status_code = 302, $loops = NULL) {
if(!$loops) {
$loops = Loops::getCurrentLoops();
}
$config = $loops->getService("config");
$request = $loops->getService("request");
$response = $loops->getService("response");
$core = $loops->getService("web_core");
if($target instanceof ElementInterface) {
$target = $core->base_url.$target->getPagePath();
}
if(!is_string($target)) {
throw new Exception("Target must be string or implement 'Loops\ElementInterface'.");
}
$response->addHeader("Location: ".$target.$request->getQuery());
return $status_code;
}
|
php
|
public static function redirect($target, $status_code = 302, $loops = NULL) {
if(!$loops) {
$loops = Loops::getCurrentLoops();
}
$config = $loops->getService("config");
$request = $loops->getService("request");
$response = $loops->getService("response");
$core = $loops->getService("web_core");
if($target instanceof ElementInterface) {
$target = $core->base_url.$target->getPagePath();
}
if(!is_string($target)) {
throw new Exception("Target must be string or implement 'Loops\ElementInterface'.");
}
$response->addHeader("Location: ".$target.$request->getQuery());
return $status_code;
}
|
[
"public",
"static",
"function",
"redirect",
"(",
"$",
"target",
",",
"$",
"status_code",
"=",
"302",
",",
"$",
"loops",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"loops",
")",
"{",
"$",
"loops",
"=",
"Loops",
"::",
"getCurrentLoops",
"(",
")",
";",
"}",
"$",
"config",
"=",
"$",
"loops",
"->",
"getService",
"(",
"\"config\"",
")",
";",
"$",
"request",
"=",
"$",
"loops",
"->",
"getService",
"(",
"\"request\"",
")",
";",
"$",
"response",
"=",
"$",
"loops",
"->",
"getService",
"(",
"\"response\"",
")",
";",
"$",
"core",
"=",
"$",
"loops",
"->",
"getService",
"(",
"\"web_core\"",
")",
";",
"if",
"(",
"$",
"target",
"instanceof",
"ElementInterface",
")",
"{",
"$",
"target",
"=",
"$",
"core",
"->",
"base_url",
".",
"$",
"target",
"->",
"getPagePath",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"target",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Target must be string or implement 'Loops\\ElementInterface'.\"",
")",
";",
"}",
"$",
"response",
"->",
"addHeader",
"(",
"\"Location: \"",
".",
"$",
"target",
".",
"$",
"request",
"->",
"getQuery",
"(",
")",
")",
";",
"return",
"$",
"status_code",
";",
"}"
] |
Sets up redirect headers in the response
This function returns the desired http status code and thus can be conveniently use.
If a loops element is passed, the page path of that element will be used for redirection.
<code>
use Loops\Misc;
...
public function action($parameter) {
return Misc::redirect("http://www.example.com")
}
</code>
<code>
use Loops\Misc;
...
public function action($parameter) {
return Misc::redirect($this)
}
</code>
@param string|object $target The location as a string or a loops element
@param integer $status_code The status code for this redirection, defaults to 302 - Temporary redirect
@param Loops $loops An alternate Loops context if the default one should not be used
@return integer The passed status code
|
[
"Sets",
"up",
"redirect",
"headers",
"in",
"the",
"response"
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Misc.php#L560-L581
|
235,709
|
loopsframework/base
|
src/Loops/Misc.php
|
Misc.recursiveUnlink
|
public static function recursiveUnlink($dir) {
$result = TRUE;
if(is_dir($dir)) {
foreach(scandir($dir) as $sub) {
if(in_array($sub, ['.', '..'])) continue;
$result &= self::recursiveUnlink("$dir/$sub");
}
$result &= rmdir($dir);
}
elseif(is_file($dir)) {
$result &= unlink($dir);
}
else {
$result = FALSE;
}
return (bool)$result;
}
|
php
|
public static function recursiveUnlink($dir) {
$result = TRUE;
if(is_dir($dir)) {
foreach(scandir($dir) as $sub) {
if(in_array($sub, ['.', '..'])) continue;
$result &= self::recursiveUnlink("$dir/$sub");
}
$result &= rmdir($dir);
}
elseif(is_file($dir)) {
$result &= unlink($dir);
}
else {
$result = FALSE;
}
return (bool)$result;
}
|
[
"public",
"static",
"function",
"recursiveUnlink",
"(",
"$",
"dir",
")",
"{",
"$",
"result",
"=",
"TRUE",
";",
"if",
"(",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"foreach",
"(",
"scandir",
"(",
"$",
"dir",
")",
"as",
"$",
"sub",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"sub",
",",
"[",
"'.'",
",",
"'..'",
"]",
")",
")",
"continue",
";",
"$",
"result",
"&=",
"self",
"::",
"recursiveUnlink",
"(",
"\"$dir/$sub\"",
")",
";",
"}",
"$",
"result",
"&=",
"rmdir",
"(",
"$",
"dir",
")",
";",
"}",
"elseif",
"(",
"is_file",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"result",
"&=",
"unlink",
"(",
"$",
"dir",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"FALSE",
";",
"}",
"return",
"(",
"bool",
")",
"$",
"result",
";",
"}"
] |
Recursively unlinks a directory
@param string $dir The target directory that will be removed
@param bool TRUE on success or FALSE on failure
|
[
"Recursively",
"unlinks",
"a",
"directory"
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Misc.php#L694-L713
|
235,710
|
loopsframework/base
|
src/Loops/Misc.php
|
Misc.recursiveMkdir
|
public static function recursiveMkdir($pathname, $mode = 0777, $recursive = TRUE, $context = NULL) {
if(is_dir($pathname)) {
return TRUE;
}
if($context) {
return mkdir($pathname, $mode, $recursive, $context);
}
else {
return mkdir($pathname, $mode, $recursive);
}
}
|
php
|
public static function recursiveMkdir($pathname, $mode = 0777, $recursive = TRUE, $context = NULL) {
if(is_dir($pathname)) {
return TRUE;
}
if($context) {
return mkdir($pathname, $mode, $recursive, $context);
}
else {
return mkdir($pathname, $mode, $recursive);
}
}
|
[
"public",
"static",
"function",
"recursiveMkdir",
"(",
"$",
"pathname",
",",
"$",
"mode",
"=",
"0777",
",",
"$",
"recursive",
"=",
"TRUE",
",",
"$",
"context",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"pathname",
")",
")",
"{",
"return",
"TRUE",
";",
"}",
"if",
"(",
"$",
"context",
")",
"{",
"return",
"mkdir",
"(",
"$",
"pathname",
",",
"$",
"mode",
",",
"$",
"recursive",
",",
"$",
"context",
")",
";",
"}",
"else",
"{",
"return",
"mkdir",
"(",
"$",
"pathname",
",",
"$",
"mode",
",",
"$",
"recursive",
")",
";",
"}",
"}"
] |
Recursively created a directory
Like PHPs mkdir but this method will set the recursive flag to TRUE on default
@param string $pathname The directory that should be created
@param integer $mode Permission that the directories are created with
@param string $recursive Set to TRUE on default
@param mixed $context The context
@return TRUE on success and FALSE on failure
|
[
"Recursively",
"created",
"a",
"directory"
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Misc.php#L726-L737
|
235,711
|
loopsframework/base
|
src/Loops/Misc.php
|
Misc.reflectionInstance
|
public static function reflectionInstance($classname, $arguments = [], $set_remaining = FALSE, $set_include = FALSE, $set_exclude = FALSE) {
$reflection = new ReflectionClass($classname);
if(!$constructor = $reflection->getConstructor()) {
return new $classname;
}
$args = self::getReflectionArgs($constructor, $arguments, $missing);
if($missing) {
$parts = [];
foreach($missing as $key => $name) {
$parts[] = "'$name' (or '$key')";
}
$missing = implode(", ", $parts);
throw new Exception("Can not create object of type '$classname'. Argument $missing needs to be set.");
}
$instance = $reflection->newInstanceArgs($args);
if($set_remaining) {
foreach($arguments as $key => $value) {
if(is_array($set_include) && !in_array($key, $set_include)) {
continue;
}
if(is_array($set_exclude) && in_array($key, $set_exclude)) {
continue;
}
$instance->$key = $value;
}
}
return $instance;
}
|
php
|
public static function reflectionInstance($classname, $arguments = [], $set_remaining = FALSE, $set_include = FALSE, $set_exclude = FALSE) {
$reflection = new ReflectionClass($classname);
if(!$constructor = $reflection->getConstructor()) {
return new $classname;
}
$args = self::getReflectionArgs($constructor, $arguments, $missing);
if($missing) {
$parts = [];
foreach($missing as $key => $name) {
$parts[] = "'$name' (or '$key')";
}
$missing = implode(", ", $parts);
throw new Exception("Can not create object of type '$classname'. Argument $missing needs to be set.");
}
$instance = $reflection->newInstanceArgs($args);
if($set_remaining) {
foreach($arguments as $key => $value) {
if(is_array($set_include) && !in_array($key, $set_include)) {
continue;
}
if(is_array($set_exclude) && in_array($key, $set_exclude)) {
continue;
}
$instance->$key = $value;
}
}
return $instance;
}
|
[
"public",
"static",
"function",
"reflectionInstance",
"(",
"$",
"classname",
",",
"$",
"arguments",
"=",
"[",
"]",
",",
"$",
"set_remaining",
"=",
"FALSE",
",",
"$",
"set_include",
"=",
"FALSE",
",",
"$",
"set_exclude",
"=",
"FALSE",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"classname",
")",
";",
"if",
"(",
"!",
"$",
"constructor",
"=",
"$",
"reflection",
"->",
"getConstructor",
"(",
")",
")",
"{",
"return",
"new",
"$",
"classname",
";",
"}",
"$",
"args",
"=",
"self",
"::",
"getReflectionArgs",
"(",
"$",
"constructor",
",",
"$",
"arguments",
",",
"$",
"missing",
")",
";",
"if",
"(",
"$",
"missing",
")",
"{",
"$",
"parts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"missing",
"as",
"$",
"key",
"=>",
"$",
"name",
")",
"{",
"$",
"parts",
"[",
"]",
"=",
"\"'$name' (or '$key')\"",
";",
"}",
"$",
"missing",
"=",
"implode",
"(",
"\", \"",
",",
"$",
"parts",
")",
";",
"throw",
"new",
"Exception",
"(",
"\"Can not create object of type '$classname'. Argument $missing needs to be set.\"",
")",
";",
"}",
"$",
"instance",
"=",
"$",
"reflection",
"->",
"newInstanceArgs",
"(",
"$",
"args",
")",
";",
"if",
"(",
"$",
"set_remaining",
")",
"{",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"set_include",
")",
"&&",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"set_include",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"set_exclude",
")",
"&&",
"in_array",
"(",
"$",
"key",
",",
"$",
"set_exclude",
")",
")",
"{",
"continue",
";",
"}",
"$",
"instance",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"instance",
";",
"}"
] |
Invokes constructors by assembling arguments from an array with the help of the reflection API.
The array values will be passed to the constructor based on the argument names of the constructor signature.
Numeric keys can also be used to specify arguments. A number denotes the n-th argument of the constructor.
This is especially useful for constructors with a long argument list (where most arguments are defined by default).
It can be seen as syntethic sugar to the alternative of passing a single option array as an argument.
An exception is thrown if there are missing arguments.
Example:
<code>
class Test {
public function __construct($arg1, $arg2 = "Default2", $arg3 = "Default3") {
$this->arg1 = $arg1;
$this->arg2 = $arg2;
$this->arg3 = $arg3;
}
}
</code>
you could instantiate it like this:
<code>
// as with the new operator
Misc::reflectionInstance("Test", [ "Value1", "Value2" ]);
// ->arg1 = "Value1"; ->arg2 = "Value2"; ->arg3 = "Default3";
// by specifying argument names directly
Misc::reflectionInstance("Test", [ "Value1", "arg3" => "Value3" ]);
Misc::reflectionInstance("Test", [ "arg1" => "Value1", "arg3" => "Value3" ]);
// ->arg1 = "Value1"; ->arg2 = "Default2"; ->arg3 = "Default3";
</code>
@param string $classname The name of the class that should be instantiated
@param array<mixed> $arguments The arguments that are passed to the constructor
@param bool $set_remaining If set to TRUE unused parameters will be set as properties of the class after instantiation.
@param false|array<string> If set to an array, only use keys that are listed in this array
@param false|array<string> If set to an array, skip keys that are listed in this array
@return object The created object instance
|
[
"Invokes",
"constructors",
"by",
"assembling",
"arguments",
"from",
"an",
"array",
"with",
"the",
"help",
"of",
"the",
"reflection",
"API",
"."
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Misc.php#L800-L834
|
235,712
|
loopsframework/base
|
src/Loops/Misc.php
|
Misc.reflectionFunction
|
public static function reflectionFunction($function, $arguments = []) {
$method = is_array($function);
if($method) {
$reflection = new ReflectionMethod($function[0], $function[1]);
}
else {
$reflection = new ReflectionFunction($function);
}
$args = self::getReflectionArgs($reflection, $arguments, $missing);
if($missing) {
$name = $reflection->getName();
$parts = [];
foreach($missing as $key => $name) {
$parts[] = "'$name' (or '$key')";
}
$missing = implode(", ", $parts);
throw new Exception("Can not call function '$name'. Argument(s) $missing need to be set.");
}
return $method ? $reflection->invokeArgs($function[0], $args) : $reflection->invokeArgs($args);
}
|
php
|
public static function reflectionFunction($function, $arguments = []) {
$method = is_array($function);
if($method) {
$reflection = new ReflectionMethod($function[0], $function[1]);
}
else {
$reflection = new ReflectionFunction($function);
}
$args = self::getReflectionArgs($reflection, $arguments, $missing);
if($missing) {
$name = $reflection->getName();
$parts = [];
foreach($missing as $key => $name) {
$parts[] = "'$name' (or '$key')";
}
$missing = implode(", ", $parts);
throw new Exception("Can not call function '$name'. Argument(s) $missing need to be set.");
}
return $method ? $reflection->invokeArgs($function[0], $args) : $reflection->invokeArgs($args);
}
|
[
"public",
"static",
"function",
"reflectionFunction",
"(",
"$",
"function",
",",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"method",
"=",
"is_array",
"(",
"$",
"function",
")",
";",
"if",
"(",
"$",
"method",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionMethod",
"(",
"$",
"function",
"[",
"0",
"]",
",",
"$",
"function",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionFunction",
"(",
"$",
"function",
")",
";",
"}",
"$",
"args",
"=",
"self",
"::",
"getReflectionArgs",
"(",
"$",
"reflection",
",",
"$",
"arguments",
",",
"$",
"missing",
")",
";",
"if",
"(",
"$",
"missing",
")",
"{",
"$",
"name",
"=",
"$",
"reflection",
"->",
"getName",
"(",
")",
";",
"$",
"parts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"missing",
"as",
"$",
"key",
"=>",
"$",
"name",
")",
"{",
"$",
"parts",
"[",
"]",
"=",
"\"'$name' (or '$key')\"",
";",
"}",
"$",
"missing",
"=",
"implode",
"(",
"\", \"",
",",
"$",
"parts",
")",
";",
"throw",
"new",
"Exception",
"(",
"\"Can not call function '$name'. Argument(s) $missing need to be set.\"",
")",
";",
"}",
"return",
"$",
"method",
"?",
"$",
"reflection",
"->",
"invokeArgs",
"(",
"$",
"function",
"[",
"0",
"]",
",",
"$",
"args",
")",
":",
"$",
"reflection",
"->",
"invokeArgs",
"(",
"$",
"args",
")",
";",
"}"
] |
Invokes functions by assembling arguments from an array with the help of the reflection API.
@todo Better doc here - refer to getReflectionArgs
|
[
"Invokes",
"functions",
"by",
"assembling",
"arguments",
"from",
"an",
"array",
"with",
"the",
"help",
"of",
"the",
"reflection",
"API",
"."
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Misc.php#L842-L865
|
235,713
|
loopsframework/base
|
src/Loops/Misc.php
|
Misc.lastChange
|
public static function lastChange($dirs, Cache $cache = NULL, &$cache_key = "") {
$files = call_user_func_array("array_merge", array_map(function($dir) {
if(!is_dir($dir)) return [];
return iterator_to_array(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)));
}, (array)$dirs));
if(!$files) {
return NULL;
}
$files = array_filter($files, function($file) { return !is_link($file); });
usort($files, function($a, $b) { return $b->getMTime() - $a->getMTime(); });
if(!$cache) {
return $files[0];
}
$lastchange = $files[0]->getMTime();
$cache_key = "Loops-Misc-filesChanged-".implode("-", $dirs);
if($cache->contains($cache_key)) {
$mtime = $cache->fetch($cache_key);
}
else {
$mtime = FALSE;
}
$cache->save($cache_key, $lastchange);
if($mtime != $lastchange) {
return $files[0];
}
return NULL;
}
|
php
|
public static function lastChange($dirs, Cache $cache = NULL, &$cache_key = "") {
$files = call_user_func_array("array_merge", array_map(function($dir) {
if(!is_dir($dir)) return [];
return iterator_to_array(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)));
}, (array)$dirs));
if(!$files) {
return NULL;
}
$files = array_filter($files, function($file) { return !is_link($file); });
usort($files, function($a, $b) { return $b->getMTime() - $a->getMTime(); });
if(!$cache) {
return $files[0];
}
$lastchange = $files[0]->getMTime();
$cache_key = "Loops-Misc-filesChanged-".implode("-", $dirs);
if($cache->contains($cache_key)) {
$mtime = $cache->fetch($cache_key);
}
else {
$mtime = FALSE;
}
$cache->save($cache_key, $lastchange);
if($mtime != $lastchange) {
return $files[0];
}
return NULL;
}
|
[
"public",
"static",
"function",
"lastChange",
"(",
"$",
"dirs",
",",
"Cache",
"$",
"cache",
"=",
"NULL",
",",
"&",
"$",
"cache_key",
"=",
"\"\"",
")",
"{",
"$",
"files",
"=",
"call_user_func_array",
"(",
"\"array_merge\"",
",",
"array_map",
"(",
"function",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"return",
"[",
"]",
";",
"return",
"iterator_to_array",
"(",
"new",
"RecursiveIteratorIterator",
"(",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"dir",
")",
")",
")",
";",
"}",
",",
"(",
"array",
")",
"$",
"dirs",
")",
")",
";",
"if",
"(",
"!",
"$",
"files",
")",
"{",
"return",
"NULL",
";",
"}",
"$",
"files",
"=",
"array_filter",
"(",
"$",
"files",
",",
"function",
"(",
"$",
"file",
")",
"{",
"return",
"!",
"is_link",
"(",
"$",
"file",
")",
";",
"}",
")",
";",
"usort",
"(",
"$",
"files",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"return",
"$",
"b",
"->",
"getMTime",
"(",
")",
"-",
"$",
"a",
"->",
"getMTime",
"(",
")",
";",
"}",
")",
";",
"if",
"(",
"!",
"$",
"cache",
")",
"{",
"return",
"$",
"files",
"[",
"0",
"]",
";",
"}",
"$",
"lastchange",
"=",
"$",
"files",
"[",
"0",
"]",
"->",
"getMTime",
"(",
")",
";",
"$",
"cache_key",
"=",
"\"Loops-Misc-filesChanged-\"",
".",
"implode",
"(",
"\"-\"",
",",
"$",
"dirs",
")",
";",
"if",
"(",
"$",
"cache",
"->",
"contains",
"(",
"$",
"cache_key",
")",
")",
"{",
"$",
"mtime",
"=",
"$",
"cache",
"->",
"fetch",
"(",
"$",
"cache_key",
")",
";",
"}",
"else",
"{",
"$",
"mtime",
"=",
"FALSE",
";",
"}",
"$",
"cache",
"->",
"save",
"(",
"$",
"cache_key",
",",
"$",
"lastchange",
")",
";",
"if",
"(",
"$",
"mtime",
"!=",
"$",
"lastchange",
")",
"{",
"return",
"$",
"files",
"[",
"0",
"]",
";",
"}",
"return",
"NULL",
";",
"}"
] |
Finds the lastest change in a directory since the last call, if there were any.
To implement this feature across requests, the last change time is stored into a Doctrine\Common\Cache\Cache.
@params array<string>|string $dirs A single directories or an array of multiple directories that are going to be checked for changes
@params Doctrine\Common\Cache\Cache $cache A Doctrine cache object
@params string $cache_key The key that has been used to store the last modification time
@params DateTime The last modification time or NULL if no file has been changed since the last call of Misc::lastChange
|
[
"Finds",
"the",
"lastest",
"change",
"in",
"a",
"directory",
"since",
"the",
"last",
"call",
"if",
"there",
"were",
"any",
"."
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Misc.php#L906-L942
|
235,714
|
loopsframework/base
|
src/Loops/Misc.php
|
Misc.fullPath
|
public static function fullPath($path, $cwd = NULL, $allow_parent = FALSE) {
//unix style full paths
if(substr($path, 0, 1) == DIRECTORY_SEPARATOR) {
return $path;
}
//windows style full paths
if(substr($path, 1, 2) == ":\\") {
return $path;
}
//throw exception if there are parent paths
if(!$allow_parent) {
$parts = explode(DIRECTORY_SEPARATOR, $path);
if(array_search("..", $parts) !== FALSE) {
throw new Exception("Parent directory in path '$path' detected. This is currently not allowed.");
}
}
//get paths (with unresolved parent paths)
$path = rtrim($cwd ?: getcwd(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$path;
//adjust windows paths for further processing
if(substr($path, 1, 2) == ":\\") {
$prefix = substr($path, 0, 3);
$path = substr($path, 3);
}
else {
$prefix = "";
}
//get parts
$parts = explode(DIRECTORY_SEPARATOR, $path);
//remove parts in front of .. parts
$result = [];
while($parts) {
$part = array_shift($parts);
if($part == "..") {
if(count($result) <= 1) {
throw new Exception("'$path' can not exist.");
}
array_pop($result);
}
else {
array_push($result, $part);
}
}
//return new assembled path
return $prefix.implode(DIRECTORY_SEPARATOR, $result);
}
|
php
|
public static function fullPath($path, $cwd = NULL, $allow_parent = FALSE) {
//unix style full paths
if(substr($path, 0, 1) == DIRECTORY_SEPARATOR) {
return $path;
}
//windows style full paths
if(substr($path, 1, 2) == ":\\") {
return $path;
}
//throw exception if there are parent paths
if(!$allow_parent) {
$parts = explode(DIRECTORY_SEPARATOR, $path);
if(array_search("..", $parts) !== FALSE) {
throw new Exception("Parent directory in path '$path' detected. This is currently not allowed.");
}
}
//get paths (with unresolved parent paths)
$path = rtrim($cwd ?: getcwd(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$path;
//adjust windows paths for further processing
if(substr($path, 1, 2) == ":\\") {
$prefix = substr($path, 0, 3);
$path = substr($path, 3);
}
else {
$prefix = "";
}
//get parts
$parts = explode(DIRECTORY_SEPARATOR, $path);
//remove parts in front of .. parts
$result = [];
while($parts) {
$part = array_shift($parts);
if($part == "..") {
if(count($result) <= 1) {
throw new Exception("'$path' can not exist.");
}
array_pop($result);
}
else {
array_push($result, $part);
}
}
//return new assembled path
return $prefix.implode(DIRECTORY_SEPARATOR, $result);
}
|
[
"public",
"static",
"function",
"fullPath",
"(",
"$",
"path",
",",
"$",
"cwd",
"=",
"NULL",
",",
"$",
"allow_parent",
"=",
"FALSE",
")",
"{",
"//unix style full paths",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"1",
")",
"==",
"DIRECTORY_SEPARATOR",
")",
"{",
"return",
"$",
"path",
";",
"}",
"//windows style full paths",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"1",
",",
"2",
")",
"==",
"\":\\\\\"",
")",
"{",
"return",
"$",
"path",
";",
"}",
"//throw exception if there are parent paths",
"if",
"(",
"!",
"$",
"allow_parent",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"path",
")",
";",
"if",
"(",
"array_search",
"(",
"\"..\"",
",",
"$",
"parts",
")",
"!==",
"FALSE",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Parent directory in path '$path' detected. This is currently not allowed.\"",
")",
";",
"}",
"}",
"//get paths (with unresolved parent paths)",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"cwd",
"?",
":",
"getcwd",
"(",
")",
",",
"DIRECTORY_SEPARATOR",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"path",
";",
"//adjust windows paths for further processing",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"1",
",",
"2",
")",
"==",
"\":\\\\\"",
")",
"{",
"$",
"prefix",
"=",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"3",
")",
";",
"$",
"path",
"=",
"substr",
"(",
"$",
"path",
",",
"3",
")",
";",
"}",
"else",
"{",
"$",
"prefix",
"=",
"\"\"",
";",
"}",
"//get parts",
"$",
"parts",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"path",
")",
";",
"//remove parts in front of .. parts",
"$",
"result",
"=",
"[",
"]",
";",
"while",
"(",
"$",
"parts",
")",
"{",
"$",
"part",
"=",
"array_shift",
"(",
"$",
"parts",
")",
";",
"if",
"(",
"$",
"part",
"==",
"\"..\"",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"result",
")",
"<=",
"1",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"'$path' can not exist.\"",
")",
";",
"}",
"array_pop",
"(",
"$",
"result",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"result",
",",
"$",
"part",
")",
";",
"}",
"}",
"//return new assembled path",
"return",
"$",
"prefix",
".",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"result",
")",
";",
"}"
] |
Gets the full path from relative paths
This function will leave already full paths as they are.
Parent paths in $path are allowed if $allow_parent is set to true. Otherwise an exception is thrown.
If an impossible parent path was passed, an exception will also be thrown.
@param string $path The input path
@param string|NULL $cwd If path is a relative path, treat it as if is relative to this path. Defaults to current working directory.
@param bool $allow_upper Allow parent directories in $path (for example: ../../test/). If not allowed but detected, an exception will be thrown.
@return string The input path if it was a full path or a full path based on $cwd + $path otherwise.
|
[
"Gets",
"the",
"full",
"path",
"from",
"relative",
"paths"
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Misc.php#L1032-L1086
|
235,715
|
ionutmilica/ionix-framework
|
src/Foundation/App.php
|
App.init
|
public function init()
{
self::$app = $this;
spl_autoload_register(array($this['loader'], 'load'));
$this->registerProviders();
$this->registerAliases();
}
|
php
|
public function init()
{
self::$app = $this;
spl_autoload_register(array($this['loader'], 'load'));
$this->registerProviders();
$this->registerAliases();
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"self",
"::",
"$",
"app",
"=",
"$",
"this",
";",
"spl_autoload_register",
"(",
"array",
"(",
"$",
"this",
"[",
"'loader'",
"]",
",",
"'load'",
")",
")",
";",
"$",
"this",
"->",
"registerProviders",
"(",
")",
";",
"$",
"this",
"->",
"registerAliases",
"(",
")",
";",
"}"
] |
Register the auto-loader
|
[
"Register",
"the",
"auto",
"-",
"loader"
] |
a0363667ff677f1772bdd9ac9530a9f4710f9321
|
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Foundation/App.php#L38-L46
|
235,716
|
ionutmilica/ionix-framework
|
src/Foundation/App.php
|
App.registerProviders
|
public function registerProviders()
{
$providers = $this['config']->get('app.providers');
foreach ($providers as $provider) {
$this->providers[$provider] = new $provider($this);
$this->providers[$provider]->register();
}
}
|
php
|
public function registerProviders()
{
$providers = $this['config']->get('app.providers');
foreach ($providers as $provider) {
$this->providers[$provider] = new $provider($this);
$this->providers[$provider]->register();
}
}
|
[
"public",
"function",
"registerProviders",
"(",
")",
"{",
"$",
"providers",
"=",
"$",
"this",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'app.providers'",
")",
";",
"foreach",
"(",
"$",
"providers",
"as",
"$",
"provider",
")",
"{",
"$",
"this",
"->",
"providers",
"[",
"$",
"provider",
"]",
"=",
"new",
"$",
"provider",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"providers",
"[",
"$",
"provider",
"]",
"->",
"register",
"(",
")",
";",
"}",
"}"
] |
Register all the providers
|
[
"Register",
"all",
"the",
"providers"
] |
a0363667ff677f1772bdd9ac9530a9f4710f9321
|
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Foundation/App.php#L63-L71
|
235,717
|
ionutmilica/ionix-framework
|
src/Foundation/App.php
|
App.initDefaultClasses
|
private function initDefaultClasses()
{
$this['loader'] = $this->share(function ($app) {
return new ClassLoader();
});
$this['config'] = $this->share(function ($app) {
$config = new Config();
$config->addHint($app['path.root'] . '/resources/config/');
return $config;
});
$this->instance('app', $this);
}
|
php
|
private function initDefaultClasses()
{
$this['loader'] = $this->share(function ($app) {
return new ClassLoader();
});
$this['config'] = $this->share(function ($app) {
$config = new Config();
$config->addHint($app['path.root'] . '/resources/config/');
return $config;
});
$this->instance('app', $this);
}
|
[
"private",
"function",
"initDefaultClasses",
"(",
")",
"{",
"$",
"this",
"[",
"'loader'",
"]",
"=",
"$",
"this",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"ClassLoader",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"[",
"'config'",
"]",
"=",
"$",
"this",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"config",
"=",
"new",
"Config",
"(",
")",
";",
"$",
"config",
"->",
"addHint",
"(",
"$",
"app",
"[",
"'path.root'",
"]",
".",
"'/resources/config/'",
")",
";",
"return",
"$",
"config",
";",
"}",
")",
";",
"$",
"this",
"->",
"instance",
"(",
"'app'",
",",
"$",
"this",
")",
";",
"}"
] |
Init default classes used by the application
|
[
"Init",
"default",
"classes",
"used",
"by",
"the",
"application"
] |
a0363667ff677f1772bdd9ac9530a9f4710f9321
|
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Foundation/App.php#L105-L118
|
235,718
|
emaphp/eMapper
|
lib/eMapper/Reflection/ClassProfile.php
|
ClassProfile.isDynamicAttribute
|
protected function isDynamicAttribute(AnnotationBag $propertyAnnotations) {
return $propertyAnnotations->has('Query') ||
$propertyAnnotations->has('Statement') ||
$propertyAnnotations->has('Procedure') ||
$propertyAnnotations->has('Eval');
}
|
php
|
protected function isDynamicAttribute(AnnotationBag $propertyAnnotations) {
return $propertyAnnotations->has('Query') ||
$propertyAnnotations->has('Statement') ||
$propertyAnnotations->has('Procedure') ||
$propertyAnnotations->has('Eval');
}
|
[
"protected",
"function",
"isDynamicAttribute",
"(",
"AnnotationBag",
"$",
"propertyAnnotations",
")",
"{",
"return",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'Query'",
")",
"||",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'Statement'",
")",
"||",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'Procedure'",
")",
"||",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'Eval'",
")",
";",
"}"
] |
Determines if a given property is a dyamic attribute
@param \Omocha\AnnotationBag $propertyAnnotations
@return boolean
|
[
"Determines",
"if",
"a",
"given",
"property",
"is",
"a",
"dyamic",
"attribute"
] |
df7100e601d2a1363d07028a786b6ceb22271829
|
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Reflection/ClassProfile.php#L110-L115
|
235,719
|
emaphp/eMapper
|
lib/eMapper/Reflection/ClassProfile.php
|
ClassProfile.parseDynamicAttribute
|
protected function parseDynamicAttribute($propertyName, \ReflectionProperty $reflectionProperty, AnnotationBag $propertyAnnotations) {
if ($propertyAnnotations->has('Query'))
$attribute = new Query($propertyName, $reflectionProperty, $propertyAnnotations);
elseif ($propertyAnnotations->has('Statement'))
$attribute = new Statement($propertyName, $reflectionProperty, $propertyAnnotations);
elseif ($propertyAnnotations->has('Procedure'))
$attribute = new Procedure($propertyName, $reflectionProperty, $propertyAnnotations);
elseif ($propertyAnnotations->has('Eval'))
$attribute = new Macro($propertyName, $reflectionProperty, $propertyAnnotations);
if ($attribute->isCacheable())
$this->attributes[$propertyName] = $attribute;
else
$this->dynamicAttributes[$propertyName] = $attribute;
}
|
php
|
protected function parseDynamicAttribute($propertyName, \ReflectionProperty $reflectionProperty, AnnotationBag $propertyAnnotations) {
if ($propertyAnnotations->has('Query'))
$attribute = new Query($propertyName, $reflectionProperty, $propertyAnnotations);
elseif ($propertyAnnotations->has('Statement'))
$attribute = new Statement($propertyName, $reflectionProperty, $propertyAnnotations);
elseif ($propertyAnnotations->has('Procedure'))
$attribute = new Procedure($propertyName, $reflectionProperty, $propertyAnnotations);
elseif ($propertyAnnotations->has('Eval'))
$attribute = new Macro($propertyName, $reflectionProperty, $propertyAnnotations);
if ($attribute->isCacheable())
$this->attributes[$propertyName] = $attribute;
else
$this->dynamicAttributes[$propertyName] = $attribute;
}
|
[
"protected",
"function",
"parseDynamicAttribute",
"(",
"$",
"propertyName",
",",
"\\",
"ReflectionProperty",
"$",
"reflectionProperty",
",",
"AnnotationBag",
"$",
"propertyAnnotations",
")",
"{",
"if",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'Query'",
")",
")",
"$",
"attribute",
"=",
"new",
"Query",
"(",
"$",
"propertyName",
",",
"$",
"reflectionProperty",
",",
"$",
"propertyAnnotations",
")",
";",
"elseif",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'Statement'",
")",
")",
"$",
"attribute",
"=",
"new",
"Statement",
"(",
"$",
"propertyName",
",",
"$",
"reflectionProperty",
",",
"$",
"propertyAnnotations",
")",
";",
"elseif",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'Procedure'",
")",
")",
"$",
"attribute",
"=",
"new",
"Procedure",
"(",
"$",
"propertyName",
",",
"$",
"reflectionProperty",
",",
"$",
"propertyAnnotations",
")",
";",
"elseif",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'Eval'",
")",
")",
"$",
"attribute",
"=",
"new",
"Macro",
"(",
"$",
"propertyName",
",",
"$",
"reflectionProperty",
",",
"$",
"propertyAnnotations",
")",
";",
"if",
"(",
"$",
"attribute",
"->",
"isCacheable",
"(",
")",
")",
"$",
"this",
"->",
"attributes",
"[",
"$",
"propertyName",
"]",
"=",
"$",
"attribute",
";",
"else",
"$",
"this",
"->",
"dynamicAttributes",
"[",
"$",
"propertyName",
"]",
"=",
"$",
"attribute",
";",
"}"
] |
Parses a dynamic attribute
@param string$propertyName
@param \ReflectionProperty $reflectionProperty
@param \Omocha\AnnotationBag $propertyAnnotations
|
[
"Parses",
"a",
"dynamic",
"attribute"
] |
df7100e601d2a1363d07028a786b6ceb22271829
|
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Reflection/ClassProfile.php#L123-L137
|
235,720
|
emaphp/eMapper
|
lib/eMapper/Reflection/ClassProfile.php
|
ClassProfile.isAssociation
|
protected function isAssociation(AnnotationBag $propertyAnnotations) {
return $propertyAnnotations->has('OneToOne') ||
$propertyAnnotations->has('OneToMany') ||
$propertyAnnotations->has('ManyToOne') ||
$propertyAnnotations->has('ManyToMany');
}
|
php
|
protected function isAssociation(AnnotationBag $propertyAnnotations) {
return $propertyAnnotations->has('OneToOne') ||
$propertyAnnotations->has('OneToMany') ||
$propertyAnnotations->has('ManyToOne') ||
$propertyAnnotations->has('ManyToMany');
}
|
[
"protected",
"function",
"isAssociation",
"(",
"AnnotationBag",
"$",
"propertyAnnotations",
")",
"{",
"return",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'OneToOne'",
")",
"||",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'OneToMany'",
")",
"||",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'ManyToOne'",
")",
"||",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'ManyToMany'",
")",
";",
"}"
] |
Determines if a given property is an association
@param \Omocha\AnnotationBag $propertyAnnotations
@return boolean
|
[
"Determines",
"if",
"a",
"given",
"property",
"is",
"an",
"association"
] |
df7100e601d2a1363d07028a786b6ceb22271829
|
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Reflection/ClassProfile.php#L144-L149
|
235,721
|
emaphp/eMapper
|
lib/eMapper/Reflection/ClassProfile.php
|
ClassProfile.parseAssociation
|
protected function parseAssociation($propertyName, \ReflectionProperty $reflectionProperty, AnnotationBag $propertyAnnotations) {
if ($propertyAnnotations->has('OneToOne')) {
$association = new OneToOne($propertyName, $reflectionProperty, $propertyAnnotations);
if ($association->isForeignKey()) {
$attribute = $association->getAttribute()->getArgument();
$this->foreignKeys[$attribute] = $propertyName;
}
elseif ($association->isCascade())
$this->references[] = $propertyName;
}
elseif ($propertyAnnotations->has('OneToMany')) {
$association = new OneToMany($propertyName, $reflectionProperty, $propertyAnnotations);
if ($association->isCascade())
$this->references[] = $propertyName;
}
elseif ($propertyAnnotations->has('ManyToOne')) {
$association = new ManyToOne($propertyName, $reflectionProperty, $propertyAnnotations);
$attribute = $association->getAttribute()->getArgument();
$this->foreignKeys[$attribute] = $propertyName;
}
elseif ($propertyAnnotations->has('ManyToMany')) {
$association = new ManyToMany($propertyName, $reflectionProperty, $propertyAnnotations);
if ($association->isCascade())
$this->references[] = $propertyName;
}
$this->associations[$propertyName] = $association;
}
|
php
|
protected function parseAssociation($propertyName, \ReflectionProperty $reflectionProperty, AnnotationBag $propertyAnnotations) {
if ($propertyAnnotations->has('OneToOne')) {
$association = new OneToOne($propertyName, $reflectionProperty, $propertyAnnotations);
if ($association->isForeignKey()) {
$attribute = $association->getAttribute()->getArgument();
$this->foreignKeys[$attribute] = $propertyName;
}
elseif ($association->isCascade())
$this->references[] = $propertyName;
}
elseif ($propertyAnnotations->has('OneToMany')) {
$association = new OneToMany($propertyName, $reflectionProperty, $propertyAnnotations);
if ($association->isCascade())
$this->references[] = $propertyName;
}
elseif ($propertyAnnotations->has('ManyToOne')) {
$association = new ManyToOne($propertyName, $reflectionProperty, $propertyAnnotations);
$attribute = $association->getAttribute()->getArgument();
$this->foreignKeys[$attribute] = $propertyName;
}
elseif ($propertyAnnotations->has('ManyToMany')) {
$association = new ManyToMany($propertyName, $reflectionProperty, $propertyAnnotations);
if ($association->isCascade())
$this->references[] = $propertyName;
}
$this->associations[$propertyName] = $association;
}
|
[
"protected",
"function",
"parseAssociation",
"(",
"$",
"propertyName",
",",
"\\",
"ReflectionProperty",
"$",
"reflectionProperty",
",",
"AnnotationBag",
"$",
"propertyAnnotations",
")",
"{",
"if",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'OneToOne'",
")",
")",
"{",
"$",
"association",
"=",
"new",
"OneToOne",
"(",
"$",
"propertyName",
",",
"$",
"reflectionProperty",
",",
"$",
"propertyAnnotations",
")",
";",
"if",
"(",
"$",
"association",
"->",
"isForeignKey",
"(",
")",
")",
"{",
"$",
"attribute",
"=",
"$",
"association",
"->",
"getAttribute",
"(",
")",
"->",
"getArgument",
"(",
")",
";",
"$",
"this",
"->",
"foreignKeys",
"[",
"$",
"attribute",
"]",
"=",
"$",
"propertyName",
";",
"}",
"elseif",
"(",
"$",
"association",
"->",
"isCascade",
"(",
")",
")",
"$",
"this",
"->",
"references",
"[",
"]",
"=",
"$",
"propertyName",
";",
"}",
"elseif",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'OneToMany'",
")",
")",
"{",
"$",
"association",
"=",
"new",
"OneToMany",
"(",
"$",
"propertyName",
",",
"$",
"reflectionProperty",
",",
"$",
"propertyAnnotations",
")",
";",
"if",
"(",
"$",
"association",
"->",
"isCascade",
"(",
")",
")",
"$",
"this",
"->",
"references",
"[",
"]",
"=",
"$",
"propertyName",
";",
"}",
"elseif",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'ManyToOne'",
")",
")",
"{",
"$",
"association",
"=",
"new",
"ManyToOne",
"(",
"$",
"propertyName",
",",
"$",
"reflectionProperty",
",",
"$",
"propertyAnnotations",
")",
";",
"$",
"attribute",
"=",
"$",
"association",
"->",
"getAttribute",
"(",
")",
"->",
"getArgument",
"(",
")",
";",
"$",
"this",
"->",
"foreignKeys",
"[",
"$",
"attribute",
"]",
"=",
"$",
"propertyName",
";",
"}",
"elseif",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'ManyToMany'",
")",
")",
"{",
"$",
"association",
"=",
"new",
"ManyToMany",
"(",
"$",
"propertyName",
",",
"$",
"reflectionProperty",
",",
"$",
"propertyAnnotations",
")",
";",
"if",
"(",
"$",
"association",
"->",
"isCascade",
"(",
")",
")",
"$",
"this",
"->",
"references",
"[",
"]",
"=",
"$",
"propertyName",
";",
"}",
"$",
"this",
"->",
"associations",
"[",
"$",
"propertyName",
"]",
"=",
"$",
"association",
";",
"}"
] |
Parses an entity association
@param string $propertyName
@param \ReflectionProperty $reflectionProperty
@param \Omocha\AnnotationBag $propertyAnnotations
|
[
"Parses",
"an",
"entity",
"association"
] |
df7100e601d2a1363d07028a786b6ceb22271829
|
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Reflection/ClassProfile.php#L157-L187
|
235,722
|
emaphp/eMapper
|
lib/eMapper/Reflection/ClassProfile.php
|
ClassProfile.parseProperties
|
protected function parseProperties() {
if ($this->isEntity()) {
//property mapping
$this->propertyMap = [];
//associations
$this->foreignkeys = $this->references = [];
//read-only properties
$this->readOnlyProperties = [];
//duplicate checks
$this->duplicateChecks = [];
}
$properties = $this->reflectionClass->getProperties();
foreach ($properties as $reflectionProperty) {
$propertyName = $reflectionProperty->getName();
$propertyAnnotations = Omocha::getAnnotations($reflectionProperty);
if (($this->isEntity() || $this->isResultMap()) && $this->isDynamicAttribute($propertyAnnotations))
$this->parseDynamicAttribute($propertyName, $reflectionProperty, $propertyAnnotations);
elseif ($this->isEntity() && $this->isAssociation($propertyAnnotations))
$this->parseAssociation($propertyName, $reflectionProperty, $propertyAnnotations);
else {
$property = new ClassProperty($propertyName, $reflectionProperty, $propertyAnnotations);
if ($this->isEntity()) {
if ($property->isPrimaryKey())
$this->primaryKey = $propertyName;
elseif ($property->checksForDuplicates())
$this->duplicateChecks[] = $propertyName;
$this->propertyMap[$propertyName] = $property->getColumn();
if ($property->isReadOnly())
$this->readOnlyProperties[] = $propertyName;
}
$this->properties[$propertyName] = $property;
}
}
}
|
php
|
protected function parseProperties() {
if ($this->isEntity()) {
//property mapping
$this->propertyMap = [];
//associations
$this->foreignkeys = $this->references = [];
//read-only properties
$this->readOnlyProperties = [];
//duplicate checks
$this->duplicateChecks = [];
}
$properties = $this->reflectionClass->getProperties();
foreach ($properties as $reflectionProperty) {
$propertyName = $reflectionProperty->getName();
$propertyAnnotations = Omocha::getAnnotations($reflectionProperty);
if (($this->isEntity() || $this->isResultMap()) && $this->isDynamicAttribute($propertyAnnotations))
$this->parseDynamicAttribute($propertyName, $reflectionProperty, $propertyAnnotations);
elseif ($this->isEntity() && $this->isAssociation($propertyAnnotations))
$this->parseAssociation($propertyName, $reflectionProperty, $propertyAnnotations);
else {
$property = new ClassProperty($propertyName, $reflectionProperty, $propertyAnnotations);
if ($this->isEntity()) {
if ($property->isPrimaryKey())
$this->primaryKey = $propertyName;
elseif ($property->checksForDuplicates())
$this->duplicateChecks[] = $propertyName;
$this->propertyMap[$propertyName] = $property->getColumn();
if ($property->isReadOnly())
$this->readOnlyProperties[] = $propertyName;
}
$this->properties[$propertyName] = $property;
}
}
}
|
[
"protected",
"function",
"parseProperties",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEntity",
"(",
")",
")",
"{",
"//property mapping",
"$",
"this",
"->",
"propertyMap",
"=",
"[",
"]",
";",
"//associations",
"$",
"this",
"->",
"foreignkeys",
"=",
"$",
"this",
"->",
"references",
"=",
"[",
"]",
";",
"//read-only properties",
"$",
"this",
"->",
"readOnlyProperties",
"=",
"[",
"]",
";",
"//duplicate checks",
"$",
"this",
"->",
"duplicateChecks",
"=",
"[",
"]",
";",
"}",
"$",
"properties",
"=",
"$",
"this",
"->",
"reflectionClass",
"->",
"getProperties",
"(",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"reflectionProperty",
")",
"{",
"$",
"propertyName",
"=",
"$",
"reflectionProperty",
"->",
"getName",
"(",
")",
";",
"$",
"propertyAnnotations",
"=",
"Omocha",
"::",
"getAnnotations",
"(",
"$",
"reflectionProperty",
")",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"isEntity",
"(",
")",
"||",
"$",
"this",
"->",
"isResultMap",
"(",
")",
")",
"&&",
"$",
"this",
"->",
"isDynamicAttribute",
"(",
"$",
"propertyAnnotations",
")",
")",
"$",
"this",
"->",
"parseDynamicAttribute",
"(",
"$",
"propertyName",
",",
"$",
"reflectionProperty",
",",
"$",
"propertyAnnotations",
")",
";",
"elseif",
"(",
"$",
"this",
"->",
"isEntity",
"(",
")",
"&&",
"$",
"this",
"->",
"isAssociation",
"(",
"$",
"propertyAnnotations",
")",
")",
"$",
"this",
"->",
"parseAssociation",
"(",
"$",
"propertyName",
",",
"$",
"reflectionProperty",
",",
"$",
"propertyAnnotations",
")",
";",
"else",
"{",
"$",
"property",
"=",
"new",
"ClassProperty",
"(",
"$",
"propertyName",
",",
"$",
"reflectionProperty",
",",
"$",
"propertyAnnotations",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isEntity",
"(",
")",
")",
"{",
"if",
"(",
"$",
"property",
"->",
"isPrimaryKey",
"(",
")",
")",
"$",
"this",
"->",
"primaryKey",
"=",
"$",
"propertyName",
";",
"elseif",
"(",
"$",
"property",
"->",
"checksForDuplicates",
"(",
")",
")",
"$",
"this",
"->",
"duplicateChecks",
"[",
"]",
"=",
"$",
"propertyName",
";",
"$",
"this",
"->",
"propertyMap",
"[",
"$",
"propertyName",
"]",
"=",
"$",
"property",
"->",
"getColumn",
"(",
")",
";",
"if",
"(",
"$",
"property",
"->",
"isReadOnly",
"(",
")",
")",
"$",
"this",
"->",
"readOnlyProperties",
"[",
"]",
"=",
"$",
"propertyName",
";",
"}",
"$",
"this",
"->",
"properties",
"[",
"$",
"propertyName",
"]",
"=",
"$",
"property",
";",
"}",
"}",
"}"
] |
Parses the properties of the current class
|
[
"Parses",
"the",
"properties",
"of",
"the",
"current",
"class"
] |
df7100e601d2a1363d07028a786b6ceb22271829
|
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Reflection/ClassProfile.php#L192-L232
|
235,723
|
emaphp/eMapper
|
lib/eMapper/Reflection/ClassProfile.php
|
ClassProfile.isSafe
|
public function isSafe() {
if ($this->classAnnotations->has('Safe'))
return (bool) $this->classAnnotations->get('Safe')->getValue();
return false;
}
|
php
|
public function isSafe() {
if ($this->classAnnotations->has('Safe'))
return (bool) $this->classAnnotations->get('Safe')->getValue();
return false;
}
|
[
"public",
"function",
"isSafe",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"classAnnotations",
"->",
"has",
"(",
"'Safe'",
")",
")",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"classAnnotations",
"->",
"get",
"(",
"'Safe'",
")",
"->",
"getValue",
"(",
")",
";",
"return",
"false",
";",
"}"
] |
DEtermines if a type handler provides safe values
@return boolean
|
[
"DEtermines",
"if",
"a",
"type",
"handler",
"provides",
"safe",
"values"
] |
df7100e601d2a1363d07028a786b6ceb22271829
|
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Reflection/ClassProfile.php#L454-L459
|
235,724
|
phPoirot/Storage
|
src/aDataStore.php
|
aDataStore.import
|
function import($data)
{
if ($data === null)
return $this;
if (!(is_array($data) || $data instanceof \Traversable || $data instanceof \stdClass))
throw new \InvalidArgumentException(sprintf(
'Data must be instance of \Traversable, \stdClass or array. given: (%s)'
, \Poirot\Std\flatten($data)
));
if ($data instanceof \stdClass)
$data = \Poirot\Std\toArrayObject($data);
foreach ($data as $k => $v)
$this->set($k, $v);
return $this;
}
|
php
|
function import($data)
{
if ($data === null)
return $this;
if (!(is_array($data) || $data instanceof \Traversable || $data instanceof \stdClass))
throw new \InvalidArgumentException(sprintf(
'Data must be instance of \Traversable, \stdClass or array. given: (%s)'
, \Poirot\Std\flatten($data)
));
if ($data instanceof \stdClass)
$data = \Poirot\Std\toArrayObject($data);
foreach ($data as $k => $v)
$this->set($k, $v);
return $this;
}
|
[
"function",
"import",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
"===",
"null",
")",
"return",
"$",
"this",
";",
"if",
"(",
"!",
"(",
"is_array",
"(",
"$",
"data",
")",
"||",
"$",
"data",
"instanceof",
"\\",
"Traversable",
"||",
"$",
"data",
"instanceof",
"\\",
"stdClass",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Data must be instance of \\Traversable, \\stdClass or array. given: (%s)'",
",",
"\\",
"Poirot",
"\\",
"Std",
"\\",
"flatten",
"(",
"$",
"data",
")",
")",
")",
";",
"if",
"(",
"$",
"data",
"instanceof",
"\\",
"stdClass",
")",
"$",
"data",
"=",
"\\",
"Poirot",
"\\",
"Std",
"\\",
"toArrayObject",
"(",
"$",
"data",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"$",
"this",
"->",
"set",
"(",
"$",
"k",
",",
"$",
"v",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Import Data Into Current Realm
@param array|\Traversable|null $data
@throws \InvalidArgumentException
@return $this
|
[
"Import",
"Data",
"Into",
"Current",
"Realm"
] |
a942de2f1c4245f5cb564c6a32ec619e4ab63d40
|
https://github.com/phPoirot/Storage/blob/a942de2f1c4245f5cb564c6a32ec619e4ab63d40/src/aDataStore.php#L64-L83
|
235,725
|
wigedev/simple-mvc
|
src/Utility/Configuration.php
|
Configuration.parseFile
|
public function parseFile(string $path): bool
{
static::$iteration++;
if (static::$iteration > 10) exit();
if (in_array($path, $this->parsed_files)) {
// The file has already been parsed, don't parse it again
return true;
}
$this->parsed_files[] = $path;
if (is_readable($path)) {
$array = include($path);
} else {
if (isset(Core::i()->log)) {
Core::i()->log->debug('Config path ' . $path . ' could not be read.');
}
return false;
}
if (!is_array($array)) {
if (isset(Core::i()->log)) {
Core::i()->log->debug('Config file ' . $path . ' is not an array.');
}
return false;
}
$this->parseArray($array);
return true;
}
|
php
|
public function parseFile(string $path): bool
{
static::$iteration++;
if (static::$iteration > 10) exit();
if (in_array($path, $this->parsed_files)) {
// The file has already been parsed, don't parse it again
return true;
}
$this->parsed_files[] = $path;
if (is_readable($path)) {
$array = include($path);
} else {
if (isset(Core::i()->log)) {
Core::i()->log->debug('Config path ' . $path . ' could not be read.');
}
return false;
}
if (!is_array($array)) {
if (isset(Core::i()->log)) {
Core::i()->log->debug('Config file ' . $path . ' is not an array.');
}
return false;
}
$this->parseArray($array);
return true;
}
|
[
"public",
"function",
"parseFile",
"(",
"string",
"$",
"path",
")",
":",
"bool",
"{",
"static",
"::",
"$",
"iteration",
"++",
";",
"if",
"(",
"static",
"::",
"$",
"iteration",
">",
"10",
")",
"exit",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"parsed_files",
")",
")",
"{",
"// The file has already been parsed, don't parse it again",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"parsed_files",
"[",
"]",
"=",
"$",
"path",
";",
"if",
"(",
"is_readable",
"(",
"$",
"path",
")",
")",
"{",
"$",
"array",
"=",
"include",
"(",
"$",
"path",
")",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"Core",
"::",
"i",
"(",
")",
"->",
"log",
")",
")",
"{",
"Core",
"::",
"i",
"(",
")",
"->",
"log",
"->",
"debug",
"(",
"'Config path '",
".",
"$",
"path",
".",
"' could not be read.'",
")",
";",
"}",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"Core",
"::",
"i",
"(",
")",
"->",
"log",
")",
")",
"{",
"Core",
"::",
"i",
"(",
")",
"->",
"log",
"->",
"debug",
"(",
"'Config file '",
".",
"$",
"path",
".",
"' is not an array.'",
")",
";",
"}",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"parseArray",
"(",
"$",
"array",
")",
";",
"return",
"true",
";",
"}"
] |
Process a single file's configuration settings.
@param string $path The path to the configuration file
@return bool True if the file is parsed successfully or skipped because it has already been parsed
|
[
"Process",
"a",
"single",
"file",
"s",
"configuration",
"settings",
"."
] |
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
|
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Utility/Configuration.php#L51-L76
|
235,726
|
pickles2/lib-plum
|
php/main.php
|
main.init
|
private function init() {
$current_dir = realpath('.');
$output = "";
$result = array('status' => true,
'message' => '');
$server_list = $this->options->preview_server;
array_push($server_list, json_decode(json_encode(array(
'name'=>'master',
'path'=>$this->options->git->repository,
))));
set_time_limit(0);
foreach ( $server_list as $preview_server ) {
chdir($current_dir);
try {
if ( strlen($preview_server->path) ) {
// デプロイ先のディレクトリが無い場合は作成
if ( !file_exists( $preview_server->path) ) {
// 存在しない場合
// ディレクトリ作成
if ( !mkdir( $preview_server->path, 0777) ) {
// ディレクトリが作成できない場合
// エラー処理
throw new \Exception('Creation of preview server directory failed.');
}
}
// 「.git」フォルダが存在すれば初期化済みと判定
if ( !file_exists( $preview_server->path . "/.git") ) {
// 存在しない場合
// ディレクトリ移動
if ( chdir( $preview_server->path ) ) {
// git セットアップ
exec('git init', $output);
// git urlのセット
$url = $this->options->git->protocol . "://";
if( strlen(@$this->options->git->username) ){
// ID/PW が設定されていない場合は、認証情報なしでアクセスする。
$url .= urlencode($this->options->git->username) . ":" . urlencode($this->options->git->password) . "@";
}
$url .= $this->options->git->url;
exec('git remote add origin ' . escapeshellarg($url), $output);
// git fetch
exec( 'git fetch origin', $output);
// git pull
exec( 'git pull origin master', $output);
chdir($current_dir);
} else {
// プレビューサーバのディレクトリが存在しない場合
// エラー処理
throw new \Exception('Preview server directory not found.');
}
}
}
} catch (\Exception $e) {
set_time_limit(30);
$result['status'] = false;
$result['message'] = $e->getMessage();
chdir($current_dir);
return $result;
}
}
set_time_limit(30);
$result['status'] = true;
return $result;
}
|
php
|
private function init() {
$current_dir = realpath('.');
$output = "";
$result = array('status' => true,
'message' => '');
$server_list = $this->options->preview_server;
array_push($server_list, json_decode(json_encode(array(
'name'=>'master',
'path'=>$this->options->git->repository,
))));
set_time_limit(0);
foreach ( $server_list as $preview_server ) {
chdir($current_dir);
try {
if ( strlen($preview_server->path) ) {
// デプロイ先のディレクトリが無い場合は作成
if ( !file_exists( $preview_server->path) ) {
// 存在しない場合
// ディレクトリ作成
if ( !mkdir( $preview_server->path, 0777) ) {
// ディレクトリが作成できない場合
// エラー処理
throw new \Exception('Creation of preview server directory failed.');
}
}
// 「.git」フォルダが存在すれば初期化済みと判定
if ( !file_exists( $preview_server->path . "/.git") ) {
// 存在しない場合
// ディレクトリ移動
if ( chdir( $preview_server->path ) ) {
// git セットアップ
exec('git init', $output);
// git urlのセット
$url = $this->options->git->protocol . "://";
if( strlen(@$this->options->git->username) ){
// ID/PW が設定されていない場合は、認証情報なしでアクセスする。
$url .= urlencode($this->options->git->username) . ":" . urlencode($this->options->git->password) . "@";
}
$url .= $this->options->git->url;
exec('git remote add origin ' . escapeshellarg($url), $output);
// git fetch
exec( 'git fetch origin', $output);
// git pull
exec( 'git pull origin master', $output);
chdir($current_dir);
} else {
// プレビューサーバのディレクトリが存在しない場合
// エラー処理
throw new \Exception('Preview server directory not found.');
}
}
}
} catch (\Exception $e) {
set_time_limit(30);
$result['status'] = false;
$result['message'] = $e->getMessage();
chdir($current_dir);
return $result;
}
}
set_time_limit(30);
$result['status'] = true;
return $result;
}
|
[
"private",
"function",
"init",
"(",
")",
"{",
"$",
"current_dir",
"=",
"realpath",
"(",
"'.'",
")",
";",
"$",
"output",
"=",
"\"\"",
";",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"true",
",",
"'message'",
"=>",
"''",
")",
";",
"$",
"server_list",
"=",
"$",
"this",
"->",
"options",
"->",
"preview_server",
";",
"array_push",
"(",
"$",
"server_list",
",",
"json_decode",
"(",
"json_encode",
"(",
"array",
"(",
"'name'",
"=>",
"'master'",
",",
"'path'",
"=>",
"$",
"this",
"->",
"options",
"->",
"git",
"->",
"repository",
",",
")",
")",
")",
")",
";",
"set_time_limit",
"(",
"0",
")",
";",
"foreach",
"(",
"$",
"server_list",
"as",
"$",
"preview_server",
")",
"{",
"chdir",
"(",
"$",
"current_dir",
")",
";",
"try",
"{",
"if",
"(",
"strlen",
"(",
"$",
"preview_server",
"->",
"path",
")",
")",
"{",
"// デプロイ先のディレクトリが無い場合は作成",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"preview_server",
"->",
"path",
")",
")",
"{",
"// 存在しない場合",
"// ディレクトリ作成",
"if",
"(",
"!",
"mkdir",
"(",
"$",
"preview_server",
"->",
"path",
",",
"0777",
")",
")",
"{",
"// ディレクトリが作成できない場合",
"// エラー処理",
"throw",
"new",
"\\",
"Exception",
"(",
"'Creation of preview server directory failed.'",
")",
";",
"}",
"}",
"// 「.git」フォルダが存在すれば初期化済みと判定",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"preview_server",
"->",
"path",
".",
"\"/.git\"",
")",
")",
"{",
"// 存在しない場合",
"// ディレクトリ移動",
"if",
"(",
"chdir",
"(",
"$",
"preview_server",
"->",
"path",
")",
")",
"{",
"// git セットアップ",
"exec",
"(",
"'git init'",
",",
"$",
"output",
")",
";",
"// git urlのセット",
"$",
"url",
"=",
"$",
"this",
"->",
"options",
"->",
"git",
"->",
"protocol",
".",
"\"://\"",
";",
"if",
"(",
"strlen",
"(",
"@",
"$",
"this",
"->",
"options",
"->",
"git",
"->",
"username",
")",
")",
"{",
"// ID/PW が設定されていない場合は、認証情報なしでアクセスする。",
"$",
"url",
".=",
"urlencode",
"(",
"$",
"this",
"->",
"options",
"->",
"git",
"->",
"username",
")",
".",
"\":\"",
".",
"urlencode",
"(",
"$",
"this",
"->",
"options",
"->",
"git",
"->",
"password",
")",
".",
"\"@\"",
";",
"}",
"$",
"url",
".=",
"$",
"this",
"->",
"options",
"->",
"git",
"->",
"url",
";",
"exec",
"(",
"'git remote add origin '",
".",
"escapeshellarg",
"(",
"$",
"url",
")",
",",
"$",
"output",
")",
";",
"// git fetch",
"exec",
"(",
"'git fetch origin'",
",",
"$",
"output",
")",
";",
"// git pull",
"exec",
"(",
"'git pull origin master'",
",",
"$",
"output",
")",
";",
"chdir",
"(",
"$",
"current_dir",
")",
";",
"}",
"else",
"{",
"// プレビューサーバのディレクトリが存在しない場合",
"// エラー処理",
"throw",
"new",
"\\",
"Exception",
"(",
"'Preview server directory not found.'",
")",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"set_time_limit",
"(",
"30",
")",
";",
"$",
"result",
"[",
"'status'",
"]",
"=",
"false",
";",
"$",
"result",
"[",
"'message'",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"chdir",
"(",
"$",
"current_dir",
")",
";",
"return",
"$",
"result",
";",
"}",
"}",
"set_time_limit",
"(",
"30",
")",
";",
"$",
"result",
"[",
"'status'",
"]",
"=",
"true",
";",
"return",
"$",
"result",
";",
"}"
] |
initialize GIT Repository
Gitリポジトリをクローンし、ローカル環境を整えます。
ツールのセットアップ時に1回実行してください。
GUIから、 "Initialize" ボタンを実行すると呼び出されます。
@return array result
- $result['status'] boolean 初期化に成功した場合に true
- $result['message'] string エラー発生時にエラーメッセージが格納される
|
[
"initialize",
"GIT",
"Repository"
] |
8e656727573eb767dd44645c708d5cf3d6c1fc21
|
https://github.com/pickles2/lib-plum/blob/8e656727573eb767dd44645c708d5cf3d6c1fc21/php/main.php#L94-L181
|
235,727
|
ViPErCZ/composer_slimORM
|
src/EntityManager.php
|
EntityManager.generateRepository
|
private function generateRepository($className) {
$table = EntityReflexion::getTable($className);
if ($table === NULL) {
throw new RepositoryException("Entity \"" . $className . " has no annotation \"table\"");
} else {
$genClassName = $this->generateRepositoryName($className);
if (!class_exists($genClassName)) {
$class = $this->cache->load($genClassName);
if ($class) {
$repository = $class;
} else {
$repository = new ClassType($genClassName);
$repository->addExtend('\slimORM\BaseRepository');
$repository->setFinal(TRUE);
$repository->addComment($genClassName);
$repository->addComment("@generated");
$repository->addProperty("connection")
->setVisibility("protected")
->addComment('@var \Nette\Database\Context');
$repository->addProperty("entityManager")
->setVisibility("protected")
->addComment('@var \slimORM\EntityManager');
$parameter = new Parameter("connection");
$parameter->setTypeHint('\Nette\Database\Context');
$parameter2 = new Parameter("entityManager");
$parameter2->setTypeHint('\slimORM\EntityManager');
$entity = EntityManager::PREFIX . str_replace("\\", "", $className) . "Entity";
$repository->addMethod("__construct")
->addComment($genClassName . " constructor")
->addComment('@param \Nette\Database\Context $connection')
->addComment('@param \slimORM\EntityManager $entityManager')
->setParameters(array($parameter, $parameter2))
->setBody("\$this->connection = \$connection;\n\$this->entityManager = \$entityManager;\nparent::__construct(\$connection, \"$table\", \"$entity\");");
$parameter = new Parameter("key");
$repository->addMethod("get")
->addComment("Find item by primary key")
->addComment("@param int \$key")
->addComment("@return $entity|null")
->setParameters(array($parameter))
->setBody("return parent::get(\$key);");
//FileSystem::write(WWW_DIR . '/temp/' . $genClassName . ".php", "<?php\n" . $repository);
$this->cache->save($genClassName, $repository, array(
Cache::FILES => EntityReflexion::getFile($className), // lze uvést i pole souborů
));
}
$res = eval('?><?php ' . $repository);
if ($res === FALSE && ($error = error_get_last()) && $error['type'] === E_PARSE) {
throw new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']);
}
$this->repositories[$genClassName] = new $genClassName($this->connection, $this);
} else if (!isset($this->repositories[$genClassName])) {
$this->repositories[$genClassName] = new $genClassName($this->connection, $this);
}
}
}
|
php
|
private function generateRepository($className) {
$table = EntityReflexion::getTable($className);
if ($table === NULL) {
throw new RepositoryException("Entity \"" . $className . " has no annotation \"table\"");
} else {
$genClassName = $this->generateRepositoryName($className);
if (!class_exists($genClassName)) {
$class = $this->cache->load($genClassName);
if ($class) {
$repository = $class;
} else {
$repository = new ClassType($genClassName);
$repository->addExtend('\slimORM\BaseRepository');
$repository->setFinal(TRUE);
$repository->addComment($genClassName);
$repository->addComment("@generated");
$repository->addProperty("connection")
->setVisibility("protected")
->addComment('@var \Nette\Database\Context');
$repository->addProperty("entityManager")
->setVisibility("protected")
->addComment('@var \slimORM\EntityManager');
$parameter = new Parameter("connection");
$parameter->setTypeHint('\Nette\Database\Context');
$parameter2 = new Parameter("entityManager");
$parameter2->setTypeHint('\slimORM\EntityManager');
$entity = EntityManager::PREFIX . str_replace("\\", "", $className) . "Entity";
$repository->addMethod("__construct")
->addComment($genClassName . " constructor")
->addComment('@param \Nette\Database\Context $connection')
->addComment('@param \slimORM\EntityManager $entityManager')
->setParameters(array($parameter, $parameter2))
->setBody("\$this->connection = \$connection;\n\$this->entityManager = \$entityManager;\nparent::__construct(\$connection, \"$table\", \"$entity\");");
$parameter = new Parameter("key");
$repository->addMethod("get")
->addComment("Find item by primary key")
->addComment("@param int \$key")
->addComment("@return $entity|null")
->setParameters(array($parameter))
->setBody("return parent::get(\$key);");
//FileSystem::write(WWW_DIR . '/temp/' . $genClassName . ".php", "<?php\n" . $repository);
$this->cache->save($genClassName, $repository, array(
Cache::FILES => EntityReflexion::getFile($className), // lze uvést i pole souborů
));
}
$res = eval('?><?php ' . $repository);
if ($res === FALSE && ($error = error_get_last()) && $error['type'] === E_PARSE) {
throw new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']);
}
$this->repositories[$genClassName] = new $genClassName($this->connection, $this);
} else if (!isset($this->repositories[$genClassName])) {
$this->repositories[$genClassName] = new $genClassName($this->connection, $this);
}
}
}
|
[
"private",
"function",
"generateRepository",
"(",
"$",
"className",
")",
"{",
"$",
"table",
"=",
"EntityReflexion",
"::",
"getTable",
"(",
"$",
"className",
")",
";",
"if",
"(",
"$",
"table",
"===",
"NULL",
")",
"{",
"throw",
"new",
"RepositoryException",
"(",
"\"Entity \\\"\"",
".",
"$",
"className",
".",
"\" has no annotation \\\"table\\\"\"",
")",
";",
"}",
"else",
"{",
"$",
"genClassName",
"=",
"$",
"this",
"->",
"generateRepositoryName",
"(",
"$",
"className",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"genClassName",
")",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"cache",
"->",
"load",
"(",
"$",
"genClassName",
")",
";",
"if",
"(",
"$",
"class",
")",
"{",
"$",
"repository",
"=",
"$",
"class",
";",
"}",
"else",
"{",
"$",
"repository",
"=",
"new",
"ClassType",
"(",
"$",
"genClassName",
")",
";",
"$",
"repository",
"->",
"addExtend",
"(",
"'\\slimORM\\BaseRepository'",
")",
";",
"$",
"repository",
"->",
"setFinal",
"(",
"TRUE",
")",
";",
"$",
"repository",
"->",
"addComment",
"(",
"$",
"genClassName",
")",
";",
"$",
"repository",
"->",
"addComment",
"(",
"\"@generated\"",
")",
";",
"$",
"repository",
"->",
"addProperty",
"(",
"\"connection\"",
")",
"->",
"setVisibility",
"(",
"\"protected\"",
")",
"->",
"addComment",
"(",
"'@var \\Nette\\Database\\Context'",
")",
";",
"$",
"repository",
"->",
"addProperty",
"(",
"\"entityManager\"",
")",
"->",
"setVisibility",
"(",
"\"protected\"",
")",
"->",
"addComment",
"(",
"'@var \\slimORM\\EntityManager'",
")",
";",
"$",
"parameter",
"=",
"new",
"Parameter",
"(",
"\"connection\"",
")",
";",
"$",
"parameter",
"->",
"setTypeHint",
"(",
"'\\Nette\\Database\\Context'",
")",
";",
"$",
"parameter2",
"=",
"new",
"Parameter",
"(",
"\"entityManager\"",
")",
";",
"$",
"parameter2",
"->",
"setTypeHint",
"(",
"'\\slimORM\\EntityManager'",
")",
";",
"$",
"entity",
"=",
"EntityManager",
"::",
"PREFIX",
".",
"str_replace",
"(",
"\"\\\\\"",
",",
"\"\"",
",",
"$",
"className",
")",
".",
"\"Entity\"",
";",
"$",
"repository",
"->",
"addMethod",
"(",
"\"__construct\"",
")",
"->",
"addComment",
"(",
"$",
"genClassName",
".",
"\" constructor\"",
")",
"->",
"addComment",
"(",
"'@param \\Nette\\Database\\Context $connection'",
")",
"->",
"addComment",
"(",
"'@param \\slimORM\\EntityManager $entityManager'",
")",
"->",
"setParameters",
"(",
"array",
"(",
"$",
"parameter",
",",
"$",
"parameter2",
")",
")",
"->",
"setBody",
"(",
"\"\\$this->connection = \\$connection;\\n\\$this->entityManager = \\$entityManager;\\nparent::__construct(\\$connection, \\\"$table\\\", \\\"$entity\\\");\"",
")",
";",
"$",
"parameter",
"=",
"new",
"Parameter",
"(",
"\"key\"",
")",
";",
"$",
"repository",
"->",
"addMethod",
"(",
"\"get\"",
")",
"->",
"addComment",
"(",
"\"Find item by primary key\"",
")",
"->",
"addComment",
"(",
"\"@param int \\$key\"",
")",
"->",
"addComment",
"(",
"\"@return $entity|null\"",
")",
"->",
"setParameters",
"(",
"array",
"(",
"$",
"parameter",
")",
")",
"->",
"setBody",
"(",
"\"return parent::get(\\$key);\"",
")",
";",
"//FileSystem::write(WWW_DIR . '/temp/' . $genClassName . \".php\", \"<?php\\n\" . $repository);",
"$",
"this",
"->",
"cache",
"->",
"save",
"(",
"$",
"genClassName",
",",
"$",
"repository",
",",
"array",
"(",
"Cache",
"::",
"FILES",
"=>",
"EntityReflexion",
"::",
"getFile",
"(",
"$",
"className",
")",
",",
"// lze uvést i pole souborů",
")",
")",
";",
"}",
"$",
"res",
"=",
"eval",
"(",
"'?><?php '",
".",
"$",
"repository",
")",
";",
"if",
"(",
"$",
"res",
"===",
"FALSE",
"&&",
"(",
"$",
"error",
"=",
"error_get_last",
"(",
")",
")",
"&&",
"$",
"error",
"[",
"'type'",
"]",
"===",
"E_PARSE",
")",
"{",
"throw",
"new",
"\\",
"ErrorException",
"(",
"$",
"error",
"[",
"'message'",
"]",
",",
"0",
",",
"$",
"error",
"[",
"'type'",
"]",
",",
"$",
"error",
"[",
"'file'",
"]",
",",
"$",
"error",
"[",
"'line'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"repositories",
"[",
"$",
"genClassName",
"]",
"=",
"new",
"$",
"genClassName",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"this",
")",
";",
"}",
"else",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"repositories",
"[",
"$",
"genClassName",
"]",
")",
")",
"{",
"$",
"this",
"->",
"repositories",
"[",
"$",
"genClassName",
"]",
"=",
"new",
"$",
"genClassName",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"this",
")",
";",
"}",
"}",
"}"
] |
Generate repository class
@param $className
@throws RepositoryException
@throws \ErrorException
|
[
"Generate",
"repository",
"class"
] |
2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf
|
https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/EntityManager.php#L101-L156
|
235,728
|
ViPErCZ/composer_slimORM
|
src/EntityManager.php
|
EntityManager.generateEntity
|
private function generateEntity($className) {
$genClassName = EntityManager::PREFIX . str_replace("\\", "", $className) . "Entity";
$table = EntityReflexion::getTable($className);
if ($table === NULL) {
throw new RepositoryException("Entity \"" . $className . " has no annotation \"table\"");
} else {
if (in_array($genClassName, $this->entities) || class_exists($genClassName)) {
return;
} else {
$this->entities[$genClassName] = $genClassName;
$class = $this->cache->load($genClassName);
if ($class) {
$repository = $class;
$references = $this->getReferences($className);
$this->generateReferences($references);
} else {
$repository = new ClassType($genClassName);
$repository->addExtend($className);
$repository->setFinal(TRUE);
$repository->addComment($genClassName);
$repository->addComment("@table " . $table);
$columns = $this->getColumns($className);
$this->generateGetters($columns, $repository);
$references = $this->getReferences($className);
$this->generateReferences($references, $repository);
$this->generateAddMethods($references, $repository);
$this->generateOverrides($repository);
//FileSystem::write(WWW_DIR . '/temp/' . $genClassName . ".php", "<?php\n" . $repository);
$this->cache->save($genClassName, $repository, array(
Cache::FILES => EntityReflexion::getFile($className), // lze uvést i pole souborů
));
}
if (!class_exists($genClassName)) {
$res = eval('?><?php ' . $repository);
if ($res === FALSE && ($error = error_get_last()) && $error['type'] === E_PARSE) {
throw new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']);
}
}
}
}
}
|
php
|
private function generateEntity($className) {
$genClassName = EntityManager::PREFIX . str_replace("\\", "", $className) . "Entity";
$table = EntityReflexion::getTable($className);
if ($table === NULL) {
throw new RepositoryException("Entity \"" . $className . " has no annotation \"table\"");
} else {
if (in_array($genClassName, $this->entities) || class_exists($genClassName)) {
return;
} else {
$this->entities[$genClassName] = $genClassName;
$class = $this->cache->load($genClassName);
if ($class) {
$repository = $class;
$references = $this->getReferences($className);
$this->generateReferences($references);
} else {
$repository = new ClassType($genClassName);
$repository->addExtend($className);
$repository->setFinal(TRUE);
$repository->addComment($genClassName);
$repository->addComment("@table " . $table);
$columns = $this->getColumns($className);
$this->generateGetters($columns, $repository);
$references = $this->getReferences($className);
$this->generateReferences($references, $repository);
$this->generateAddMethods($references, $repository);
$this->generateOverrides($repository);
//FileSystem::write(WWW_DIR . '/temp/' . $genClassName . ".php", "<?php\n" . $repository);
$this->cache->save($genClassName, $repository, array(
Cache::FILES => EntityReflexion::getFile($className), // lze uvést i pole souborů
));
}
if (!class_exists($genClassName)) {
$res = eval('?><?php ' . $repository);
if ($res === FALSE && ($error = error_get_last()) && $error['type'] === E_PARSE) {
throw new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']);
}
}
}
}
}
|
[
"private",
"function",
"generateEntity",
"(",
"$",
"className",
")",
"{",
"$",
"genClassName",
"=",
"EntityManager",
"::",
"PREFIX",
".",
"str_replace",
"(",
"\"\\\\\"",
",",
"\"\"",
",",
"$",
"className",
")",
".",
"\"Entity\"",
";",
"$",
"table",
"=",
"EntityReflexion",
"::",
"getTable",
"(",
"$",
"className",
")",
";",
"if",
"(",
"$",
"table",
"===",
"NULL",
")",
"{",
"throw",
"new",
"RepositoryException",
"(",
"\"Entity \\\"\"",
".",
"$",
"className",
".",
"\" has no annotation \\\"table\\\"\"",
")",
";",
"}",
"else",
"{",
"if",
"(",
"in_array",
"(",
"$",
"genClassName",
",",
"$",
"this",
"->",
"entities",
")",
"||",
"class_exists",
"(",
"$",
"genClassName",
")",
")",
"{",
"return",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"entities",
"[",
"$",
"genClassName",
"]",
"=",
"$",
"genClassName",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"cache",
"->",
"load",
"(",
"$",
"genClassName",
")",
";",
"if",
"(",
"$",
"class",
")",
"{",
"$",
"repository",
"=",
"$",
"class",
";",
"$",
"references",
"=",
"$",
"this",
"->",
"getReferences",
"(",
"$",
"className",
")",
";",
"$",
"this",
"->",
"generateReferences",
"(",
"$",
"references",
")",
";",
"}",
"else",
"{",
"$",
"repository",
"=",
"new",
"ClassType",
"(",
"$",
"genClassName",
")",
";",
"$",
"repository",
"->",
"addExtend",
"(",
"$",
"className",
")",
";",
"$",
"repository",
"->",
"setFinal",
"(",
"TRUE",
")",
";",
"$",
"repository",
"->",
"addComment",
"(",
"$",
"genClassName",
")",
";",
"$",
"repository",
"->",
"addComment",
"(",
"\"@table \"",
".",
"$",
"table",
")",
";",
"$",
"columns",
"=",
"$",
"this",
"->",
"getColumns",
"(",
"$",
"className",
")",
";",
"$",
"this",
"->",
"generateGetters",
"(",
"$",
"columns",
",",
"$",
"repository",
")",
";",
"$",
"references",
"=",
"$",
"this",
"->",
"getReferences",
"(",
"$",
"className",
")",
";",
"$",
"this",
"->",
"generateReferences",
"(",
"$",
"references",
",",
"$",
"repository",
")",
";",
"$",
"this",
"->",
"generateAddMethods",
"(",
"$",
"references",
",",
"$",
"repository",
")",
";",
"$",
"this",
"->",
"generateOverrides",
"(",
"$",
"repository",
")",
";",
"//FileSystem::write(WWW_DIR . '/temp/' . $genClassName . \".php\", \"<?php\\n\" . $repository);",
"$",
"this",
"->",
"cache",
"->",
"save",
"(",
"$",
"genClassName",
",",
"$",
"repository",
",",
"array",
"(",
"Cache",
"::",
"FILES",
"=>",
"EntityReflexion",
"::",
"getFile",
"(",
"$",
"className",
")",
",",
"// lze uvést i pole souborů",
")",
")",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"genClassName",
")",
")",
"{",
"$",
"res",
"=",
"eval",
"(",
"'?><?php '",
".",
"$",
"repository",
")",
";",
"if",
"(",
"$",
"res",
"===",
"FALSE",
"&&",
"(",
"$",
"error",
"=",
"error_get_last",
"(",
")",
")",
"&&",
"$",
"error",
"[",
"'type'",
"]",
"===",
"E_PARSE",
")",
"{",
"throw",
"new",
"\\",
"ErrorException",
"(",
"$",
"error",
"[",
"'message'",
"]",
",",
"0",
",",
"$",
"error",
"[",
"'type'",
"]",
",",
"$",
"error",
"[",
"'file'",
"]",
",",
"$",
"error",
"[",
"'line'",
"]",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Generate entity class
@param $className
@throws RepositoryException
@throws \ErrorException
|
[
"Generate",
"entity",
"class"
] |
2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf
|
https://github.com/ViPErCZ/composer_slimORM/blob/2206f4ab4557e2b21b2ae4e2ded7cb5ca3d829bf/src/EntityManager.php#L164-L207
|
235,729
|
dan-har/presentit
|
src/Resource/Item.php
|
Item.transform
|
public function transform()
{
if( ! $this->transformer) {
return [];
}
$presentation = $this->transformer->transform($this->resource);
return $this->transformToArray($presentation);
}
|
php
|
public function transform()
{
if( ! $this->transformer) {
return [];
}
$presentation = $this->transformer->transform($this->resource);
return $this->transformToArray($presentation);
}
|
[
"public",
"function",
"transform",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"transformer",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"presentation",
"=",
"$",
"this",
"->",
"transformer",
"->",
"transform",
"(",
"$",
"this",
"->",
"resource",
")",
";",
"return",
"$",
"this",
"->",
"transformToArray",
"(",
"$",
"presentation",
")",
";",
"}"
] |
Present the item using a transformer.
@return array
|
[
"Present",
"the",
"item",
"using",
"a",
"transformer",
"."
] |
283db977d5b6d91bc2c139ec377c05010935682d
|
https://github.com/dan-har/presentit/blob/283db977d5b6d91bc2c139ec377c05010935682d/src/Resource/Item.php#L53-L62
|
235,730
|
dan-har/presentit
|
src/Resource/Item.php
|
Item.transformToArray
|
protected function transformToArray(array $presentation)
{
$array = [];
// iterate over all the presentation values and search for arrays and
// for the nested special entities, Presentation and Hidden objects
// and handle each entity in the appropriate way.
foreach ($presentation as $key => $item) {
// in case of an array recursively iterate over all the array
// value and check for special entities.
if(is_array($item)) {
$array[$key] = $this->transformToArray($item);
}
// if we find an hidden entity ignore the key so it won't be shown in the
// final presentation then continue to the next item in the presentation
else if($item instanceof Hidden) {
continue;
}
// if an item is a presentation object run the show function on it to transform
// the resource presentation tree and save the presentation on the array.
else if($item instanceof Presentation) {
$array[$key] = $item->show();
}
// on any other value we just save the value and key and move on
// to the next item.
else {
$array[$key] = $item;
}
}
return $array;
}
|
php
|
protected function transformToArray(array $presentation)
{
$array = [];
// iterate over all the presentation values and search for arrays and
// for the nested special entities, Presentation and Hidden objects
// and handle each entity in the appropriate way.
foreach ($presentation as $key => $item) {
// in case of an array recursively iterate over all the array
// value and check for special entities.
if(is_array($item)) {
$array[$key] = $this->transformToArray($item);
}
// if we find an hidden entity ignore the key so it won't be shown in the
// final presentation then continue to the next item in the presentation
else if($item instanceof Hidden) {
continue;
}
// if an item is a presentation object run the show function on it to transform
// the resource presentation tree and save the presentation on the array.
else if($item instanceof Presentation) {
$array[$key] = $item->show();
}
// on any other value we just save the value and key and move on
// to the next item.
else {
$array[$key] = $item;
}
}
return $array;
}
|
[
"protected",
"function",
"transformToArray",
"(",
"array",
"$",
"presentation",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"// iterate over all the presentation values and search for arrays and",
"// for the nested special entities, Presentation and Hidden objects",
"// and handle each entity in the appropriate way.",
"foreach",
"(",
"$",
"presentation",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"// in case of an array recursively iterate over all the array",
"// value and check for special entities.",
"if",
"(",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"transformToArray",
"(",
"$",
"item",
")",
";",
"}",
"// if we find an hidden entity ignore the key so it won't be shown in the",
"// final presentation then continue to the next item in the presentation",
"else",
"if",
"(",
"$",
"item",
"instanceof",
"Hidden",
")",
"{",
"continue",
";",
"}",
"// if an item is a presentation object run the show function on it to transform",
"// the resource presentation tree and save the presentation on the array.",
"else",
"if",
"(",
"$",
"item",
"instanceof",
"Presentation",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"item",
"->",
"show",
"(",
")",
";",
"}",
"// on any other value we just save the value and key and move on",
"// to the next item.",
"else",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] |
Transform a presentation to an array.
@param array $presentation
@return array
|
[
"Transform",
"a",
"presentation",
"to",
"an",
"array",
"."
] |
283db977d5b6d91bc2c139ec377c05010935682d
|
https://github.com/dan-har/presentit/blob/283db977d5b6d91bc2c139ec377c05010935682d/src/Resource/Item.php#L70-L105
|
235,731
|
WellCommerce/CmsBundle
|
Form/Admin/PageFormBuilder.php
|
PageFormBuilder.addMainFieldset
|
private function addMainFieldset(FormInterface $form)
{
$mainData = $form->addChild($this->getElement('nested_fieldset', [
'name' => 'main_data',
'label' => 'common.fieldset.general',
]));
$languageData = $mainData->addChild($this->getElement('language_fieldset', [
'name' => 'translations',
'label' => 'common.fieldset.translations',
'transformer' => $this->getRepositoryTransformer('translation', $this->get('page.repository')),
]));
$name = $languageData->addChild($this->getElement('text_field', [
'name' => 'name',
'label' => 'common.label.name',
'rules' => [
$this->getRule('required'),
],
]));
$languageData->addChild($this->getElement('slug_field', [
'name' => 'slug',
'label' => 'common.label.slug',
'name_field' => $name,
'generate_route' => 'route.generate',
'translatable_id' => $this->getRequestHelper()->getAttributesBagParam('id'),
'rules' => [
$this->getRule('required'),
],
]));
$mainData->addChild($this->getElement('checkbox', [
'name' => 'publish',
'label' => 'common.label.publish',
'comment' => 'page.comment.publish',
'default' => 1,
]));
$mainData->addChild($this->getElement('text_field', [
'name' => 'hierarchy',
'label' => 'common.label.hierarchy',
'rules' => [
$this->getRule('required'),
],
]));
$mainData->addChild($this->getElement('text_field', [
'name' => 'section',
'label' => 'page.label.section',
]));
$mainData->addChild($this->getElement('tree', [
'name' => 'parent',
'label' => 'page.label.parent',
'choosable' => true,
'selectable' => false,
'sortable' => false,
'clickable' => false,
'items' => $this->get('page.dataset.admin')->getResult('flat_tree'),
'restrict' => $this->getRequestHelper()->getAttributesBagParam('id'),
'transformer' => $this->getRepositoryTransformer('entity', $this->get('page.repository')),
]));
$mainData->addChild($this->getElement('tip', [
'tip' => $this->trans('page.tip.client_groups'),
]));
$mainData->addChild($this->getElement('multi_select', [
'name' => 'clientGroups',
'label' => 'page.label.client_groups',
'options' => $this->get('client_group.dataset.admin')->getResult('select'),
'transformer' => $this->getRepositoryTransformer('collection', $this->get('client_group.repository')),
]));
}
|
php
|
private function addMainFieldset(FormInterface $form)
{
$mainData = $form->addChild($this->getElement('nested_fieldset', [
'name' => 'main_data',
'label' => 'common.fieldset.general',
]));
$languageData = $mainData->addChild($this->getElement('language_fieldset', [
'name' => 'translations',
'label' => 'common.fieldset.translations',
'transformer' => $this->getRepositoryTransformer('translation', $this->get('page.repository')),
]));
$name = $languageData->addChild($this->getElement('text_field', [
'name' => 'name',
'label' => 'common.label.name',
'rules' => [
$this->getRule('required'),
],
]));
$languageData->addChild($this->getElement('slug_field', [
'name' => 'slug',
'label' => 'common.label.slug',
'name_field' => $name,
'generate_route' => 'route.generate',
'translatable_id' => $this->getRequestHelper()->getAttributesBagParam('id'),
'rules' => [
$this->getRule('required'),
],
]));
$mainData->addChild($this->getElement('checkbox', [
'name' => 'publish',
'label' => 'common.label.publish',
'comment' => 'page.comment.publish',
'default' => 1,
]));
$mainData->addChild($this->getElement('text_field', [
'name' => 'hierarchy',
'label' => 'common.label.hierarchy',
'rules' => [
$this->getRule('required'),
],
]));
$mainData->addChild($this->getElement('text_field', [
'name' => 'section',
'label' => 'page.label.section',
]));
$mainData->addChild($this->getElement('tree', [
'name' => 'parent',
'label' => 'page.label.parent',
'choosable' => true,
'selectable' => false,
'sortable' => false,
'clickable' => false,
'items' => $this->get('page.dataset.admin')->getResult('flat_tree'),
'restrict' => $this->getRequestHelper()->getAttributesBagParam('id'),
'transformer' => $this->getRepositoryTransformer('entity', $this->get('page.repository')),
]));
$mainData->addChild($this->getElement('tip', [
'tip' => $this->trans('page.tip.client_groups'),
]));
$mainData->addChild($this->getElement('multi_select', [
'name' => 'clientGroups',
'label' => 'page.label.client_groups',
'options' => $this->get('client_group.dataset.admin')->getResult('select'),
'transformer' => $this->getRepositoryTransformer('collection', $this->get('client_group.repository')),
]));
}
|
[
"private",
"function",
"addMainFieldset",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"$",
"mainData",
"=",
"$",
"form",
"->",
"addChild",
"(",
"$",
"this",
"->",
"getElement",
"(",
"'nested_fieldset'",
",",
"[",
"'name'",
"=>",
"'main_data'",
",",
"'label'",
"=>",
"'common.fieldset.general'",
",",
"]",
")",
")",
";",
"$",
"languageData",
"=",
"$",
"mainData",
"->",
"addChild",
"(",
"$",
"this",
"->",
"getElement",
"(",
"'language_fieldset'",
",",
"[",
"'name'",
"=>",
"'translations'",
",",
"'label'",
"=>",
"'common.fieldset.translations'",
",",
"'transformer'",
"=>",
"$",
"this",
"->",
"getRepositoryTransformer",
"(",
"'translation'",
",",
"$",
"this",
"->",
"get",
"(",
"'page.repository'",
")",
")",
",",
"]",
")",
")",
";",
"$",
"name",
"=",
"$",
"languageData",
"->",
"addChild",
"(",
"$",
"this",
"->",
"getElement",
"(",
"'text_field'",
",",
"[",
"'name'",
"=>",
"'name'",
",",
"'label'",
"=>",
"'common.label.name'",
",",
"'rules'",
"=>",
"[",
"$",
"this",
"->",
"getRule",
"(",
"'required'",
")",
",",
"]",
",",
"]",
")",
")",
";",
"$",
"languageData",
"->",
"addChild",
"(",
"$",
"this",
"->",
"getElement",
"(",
"'slug_field'",
",",
"[",
"'name'",
"=>",
"'slug'",
",",
"'label'",
"=>",
"'common.label.slug'",
",",
"'name_field'",
"=>",
"$",
"name",
",",
"'generate_route'",
"=>",
"'route.generate'",
",",
"'translatable_id'",
"=>",
"$",
"this",
"->",
"getRequestHelper",
"(",
")",
"->",
"getAttributesBagParam",
"(",
"'id'",
")",
",",
"'rules'",
"=>",
"[",
"$",
"this",
"->",
"getRule",
"(",
"'required'",
")",
",",
"]",
",",
"]",
")",
")",
";",
"$",
"mainData",
"->",
"addChild",
"(",
"$",
"this",
"->",
"getElement",
"(",
"'checkbox'",
",",
"[",
"'name'",
"=>",
"'publish'",
",",
"'label'",
"=>",
"'common.label.publish'",
",",
"'comment'",
"=>",
"'page.comment.publish'",
",",
"'default'",
"=>",
"1",
",",
"]",
")",
")",
";",
"$",
"mainData",
"->",
"addChild",
"(",
"$",
"this",
"->",
"getElement",
"(",
"'text_field'",
",",
"[",
"'name'",
"=>",
"'hierarchy'",
",",
"'label'",
"=>",
"'common.label.hierarchy'",
",",
"'rules'",
"=>",
"[",
"$",
"this",
"->",
"getRule",
"(",
"'required'",
")",
",",
"]",
",",
"]",
")",
")",
";",
"$",
"mainData",
"->",
"addChild",
"(",
"$",
"this",
"->",
"getElement",
"(",
"'text_field'",
",",
"[",
"'name'",
"=>",
"'section'",
",",
"'label'",
"=>",
"'page.label.section'",
",",
"]",
")",
")",
";",
"$",
"mainData",
"->",
"addChild",
"(",
"$",
"this",
"->",
"getElement",
"(",
"'tree'",
",",
"[",
"'name'",
"=>",
"'parent'",
",",
"'label'",
"=>",
"'page.label.parent'",
",",
"'choosable'",
"=>",
"true",
",",
"'selectable'",
"=>",
"false",
",",
"'sortable'",
"=>",
"false",
",",
"'clickable'",
"=>",
"false",
",",
"'items'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'page.dataset.admin'",
")",
"->",
"getResult",
"(",
"'flat_tree'",
")",
",",
"'restrict'",
"=>",
"$",
"this",
"->",
"getRequestHelper",
"(",
")",
"->",
"getAttributesBagParam",
"(",
"'id'",
")",
",",
"'transformer'",
"=>",
"$",
"this",
"->",
"getRepositoryTransformer",
"(",
"'entity'",
",",
"$",
"this",
"->",
"get",
"(",
"'page.repository'",
")",
")",
",",
"]",
")",
")",
";",
"$",
"mainData",
"->",
"addChild",
"(",
"$",
"this",
"->",
"getElement",
"(",
"'tip'",
",",
"[",
"'tip'",
"=>",
"$",
"this",
"->",
"trans",
"(",
"'page.tip.client_groups'",
")",
",",
"]",
")",
")",
";",
"$",
"mainData",
"->",
"addChild",
"(",
"$",
"this",
"->",
"getElement",
"(",
"'multi_select'",
",",
"[",
"'name'",
"=>",
"'clientGroups'",
",",
"'label'",
"=>",
"'page.label.client_groups'",
",",
"'options'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'client_group.dataset.admin'",
")",
"->",
"getResult",
"(",
"'select'",
")",
",",
"'transformer'",
"=>",
"$",
"this",
"->",
"getRepositoryTransformer",
"(",
"'collection'",
",",
"$",
"this",
"->",
"get",
"(",
"'client_group.repository'",
")",
")",
",",
"]",
")",
")",
";",
"}"
] |
Adds main settings fieldset to form
@param FormInterface $form
|
[
"Adds",
"main",
"settings",
"fieldset",
"to",
"form"
] |
2056ab01e17d3402ffae5dd01b4df61279fa60f9
|
https://github.com/WellCommerce/CmsBundle/blob/2056ab01e17d3402ffae5dd01b4df61279fa60f9/Form/Admin/PageFormBuilder.php#L48-L122
|
235,732
|
mimmi20/ua-data-mapper
|
src/MakerMapper.php
|
MakerMapper.mapMaker
|
public function mapMaker(?string $maker): ?string
{
if (null === $maker) {
return null;
}
switch (mb_strtolower(trim($maker))) {
case '':
case 'unknown':
case 'other':
case 'bot':
case 'various':
$maker = null;
break;
case 'microsoft':
case 'microsoft corporation.':
$maker = 'Microsoft Corporation';
break;
case 'apple':
case 'apple inc.':
case 'apple computer, inc.':
$maker = 'Apple Inc';
break;
case 'google':
case 'google inc.':
case 'google, inc.':
$maker = 'Google Inc';
break;
case 'lunascape & co., ltd.':
$maker = 'Lunascape Corporation';
break;
case 'opera software asa.':
$maker = 'Opera Software ASA';
break;
case 'sun microsystems, inc.':
$maker = 'Oracle';
break;
case 'postbox, inc.':
$maker = 'Postbox Inc';
break;
case 'comodo group, inc.':
$maker = 'Comodo Group Inc';
break;
case 'canonical ltd.':
$maker = 'Canonical Ltd';
break;
case 'gentoo foundation, inc.':
$maker = 'Gentoo Foundation Inc';
break;
case 'omni development, inc.':
$maker = 'Omni Development Inc';
break;
case 'slackware linux, inc.':
$maker = 'Slackware Linux Inc';
break;
case 'red hat, inc.':
$maker = 'Red Hat Inc';
break;
case 'rim':
$maker = 'Research In Motion Limited';
break;
case 'mozilla':
$maker = 'Mozilla Foundation';
break;
case 'majestic-12':
$maker = 'Majestic-12 Ltd';
break;
case 'zum internet':
$maker = 'ZUMinternet Corp';
break;
case 'mojeek ltd.':
$maker = 'Linkdex Limited';
break;
default:
// nothing to do here
break;
}
return $maker;
}
|
php
|
public function mapMaker(?string $maker): ?string
{
if (null === $maker) {
return null;
}
switch (mb_strtolower(trim($maker))) {
case '':
case 'unknown':
case 'other':
case 'bot':
case 'various':
$maker = null;
break;
case 'microsoft':
case 'microsoft corporation.':
$maker = 'Microsoft Corporation';
break;
case 'apple':
case 'apple inc.':
case 'apple computer, inc.':
$maker = 'Apple Inc';
break;
case 'google':
case 'google inc.':
case 'google, inc.':
$maker = 'Google Inc';
break;
case 'lunascape & co., ltd.':
$maker = 'Lunascape Corporation';
break;
case 'opera software asa.':
$maker = 'Opera Software ASA';
break;
case 'sun microsystems, inc.':
$maker = 'Oracle';
break;
case 'postbox, inc.':
$maker = 'Postbox Inc';
break;
case 'comodo group, inc.':
$maker = 'Comodo Group Inc';
break;
case 'canonical ltd.':
$maker = 'Canonical Ltd';
break;
case 'gentoo foundation, inc.':
$maker = 'Gentoo Foundation Inc';
break;
case 'omni development, inc.':
$maker = 'Omni Development Inc';
break;
case 'slackware linux, inc.':
$maker = 'Slackware Linux Inc';
break;
case 'red hat, inc.':
$maker = 'Red Hat Inc';
break;
case 'rim':
$maker = 'Research In Motion Limited';
break;
case 'mozilla':
$maker = 'Mozilla Foundation';
break;
case 'majestic-12':
$maker = 'Majestic-12 Ltd';
break;
case 'zum internet':
$maker = 'ZUMinternet Corp';
break;
case 'mojeek ltd.':
$maker = 'Linkdex Limited';
break;
default:
// nothing to do here
break;
}
return $maker;
}
|
[
"public",
"function",
"mapMaker",
"(",
"?",
"string",
"$",
"maker",
")",
":",
"?",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"maker",
")",
"{",
"return",
"null",
";",
"}",
"switch",
"(",
"mb_strtolower",
"(",
"trim",
"(",
"$",
"maker",
")",
")",
")",
"{",
"case",
"''",
":",
"case",
"'unknown'",
":",
"case",
"'other'",
":",
"case",
"'bot'",
":",
"case",
"'various'",
":",
"$",
"maker",
"=",
"null",
";",
"break",
";",
"case",
"'microsoft'",
":",
"case",
"'microsoft corporation.'",
":",
"$",
"maker",
"=",
"'Microsoft Corporation'",
";",
"break",
";",
"case",
"'apple'",
":",
"case",
"'apple inc.'",
":",
"case",
"'apple computer, inc.'",
":",
"$",
"maker",
"=",
"'Apple Inc'",
";",
"break",
";",
"case",
"'google'",
":",
"case",
"'google inc.'",
":",
"case",
"'google, inc.'",
":",
"$",
"maker",
"=",
"'Google Inc'",
";",
"break",
";",
"case",
"'lunascape & co., ltd.'",
":",
"$",
"maker",
"=",
"'Lunascape Corporation'",
";",
"break",
";",
"case",
"'opera software asa.'",
":",
"$",
"maker",
"=",
"'Opera Software ASA'",
";",
"break",
";",
"case",
"'sun microsystems, inc.'",
":",
"$",
"maker",
"=",
"'Oracle'",
";",
"break",
";",
"case",
"'postbox, inc.'",
":",
"$",
"maker",
"=",
"'Postbox Inc'",
";",
"break",
";",
"case",
"'comodo group, inc.'",
":",
"$",
"maker",
"=",
"'Comodo Group Inc'",
";",
"break",
";",
"case",
"'canonical ltd.'",
":",
"$",
"maker",
"=",
"'Canonical Ltd'",
";",
"break",
";",
"case",
"'gentoo foundation, inc.'",
":",
"$",
"maker",
"=",
"'Gentoo Foundation Inc'",
";",
"break",
";",
"case",
"'omni development, inc.'",
":",
"$",
"maker",
"=",
"'Omni Development Inc'",
";",
"break",
";",
"case",
"'slackware linux, inc.'",
":",
"$",
"maker",
"=",
"'Slackware Linux Inc'",
";",
"break",
";",
"case",
"'red hat, inc.'",
":",
"$",
"maker",
"=",
"'Red Hat Inc'",
";",
"break",
";",
"case",
"'rim'",
":",
"$",
"maker",
"=",
"'Research In Motion Limited'",
";",
"break",
";",
"case",
"'mozilla'",
":",
"$",
"maker",
"=",
"'Mozilla Foundation'",
";",
"break",
";",
"case",
"'majestic-12'",
":",
"$",
"maker",
"=",
"'Majestic-12 Ltd'",
";",
"break",
";",
"case",
"'zum internet'",
":",
"$",
"maker",
"=",
"'ZUMinternet Corp'",
";",
"break",
";",
"case",
"'mojeek ltd.'",
":",
"$",
"maker",
"=",
"'Linkdex Limited'",
";",
"break",
";",
"default",
":",
"// nothing to do here",
"break",
";",
"}",
"return",
"$",
"maker",
";",
"}"
] |
maps the maker of the browser, os, engine or device
@param string|null $maker
@return string|null
|
[
"maps",
"the",
"maker",
"of",
"the",
"browser",
"os",
"engine",
"or",
"device"
] |
fdb249045066a4e793fb481c6304c736605996eb
|
https://github.com/mimmi20/ua-data-mapper/blob/fdb249045066a4e793fb481c6304c736605996eb/src/MakerMapper.php#L31-L110
|
235,733
|
webforge-labs/webforge-dom
|
lib/Webforge/DOM/XMLUtil.php
|
XMLUtil.docPart
|
public static function docPart($htmlPart, $encoding = 'utf-8', $docType = NULL) {
if (!is_string($htmlPart))
$htmlPart = self::export($htmlPart);
if (mb_strpos(trim($htmlPart), '<!DOCTYPE') === 0) {
$document = $htmlPart;
} else {
// DOMDocument setzt so oder so einen default, also können wir das auch explizit machen
$docType = $docType ?: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
// ebenso das encoding ist utf8
$document = $docType."\n";
if (mb_strpos(trim($htmlPart),'<html') === 0) {
$document .= $htmlPart;
} else {
$document .= '<html><head><meta http-equiv="Content-Type" content="text/html; charset='.$encoding.'"/></head><body>'.$htmlPart.'</body></html>';
}
}
return self::doc($document);
}
|
php
|
public static function docPart($htmlPart, $encoding = 'utf-8', $docType = NULL) {
if (!is_string($htmlPart))
$htmlPart = self::export($htmlPart);
if (mb_strpos(trim($htmlPart), '<!DOCTYPE') === 0) {
$document = $htmlPart;
} else {
// DOMDocument setzt so oder so einen default, also können wir das auch explizit machen
$docType = $docType ?: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
// ebenso das encoding ist utf8
$document = $docType."\n";
if (mb_strpos(trim($htmlPart),'<html') === 0) {
$document .= $htmlPart;
} else {
$document .= '<html><head><meta http-equiv="Content-Type" content="text/html; charset='.$encoding.'"/></head><body>'.$htmlPart.'</body></html>';
}
}
return self::doc($document);
}
|
[
"public",
"static",
"function",
"docPart",
"(",
"$",
"htmlPart",
",",
"$",
"encoding",
"=",
"'utf-8'",
",",
"$",
"docType",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"htmlPart",
")",
")",
"$",
"htmlPart",
"=",
"self",
"::",
"export",
"(",
"$",
"htmlPart",
")",
";",
"if",
"(",
"mb_strpos",
"(",
"trim",
"(",
"$",
"htmlPart",
")",
",",
"'<!DOCTYPE'",
")",
"===",
"0",
")",
"{",
"$",
"document",
"=",
"$",
"htmlPart",
";",
"}",
"else",
"{",
"// DOMDocument setzt so oder so einen default, also können wir das auch explizit machen",
"$",
"docType",
"=",
"$",
"docType",
"?",
":",
"'<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">'",
";",
"// ebenso das encoding ist utf8",
"$",
"document",
"=",
"$",
"docType",
".",
"\"\\n\"",
";",
"if",
"(",
"mb_strpos",
"(",
"trim",
"(",
"$",
"htmlPart",
")",
",",
"'<html'",
")",
"===",
"0",
")",
"{",
"$",
"document",
".=",
"$",
"htmlPart",
";",
"}",
"else",
"{",
"$",
"document",
".=",
"'<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset='",
".",
"$",
"encoding",
".",
"'\"/></head><body>'",
".",
"$",
"htmlPart",
".",
"'</body></html>'",
";",
"}",
"}",
"return",
"self",
"::",
"doc",
"(",
"$",
"document",
")",
";",
"}"
] |
Takes any HTML snippet and makes a correct DOMDocument out of it
nimmt als default
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">';
an
@param string $html ein HTML Schnipsel
@return DOMDocument
|
[
"Takes",
"any",
"HTML",
"snippet",
"and",
"makes",
"a",
"correct",
"DOMDocument",
"out",
"of",
"it"
] |
79bc03e8cb1a483e122e700d15bbb9ac607dd39b
|
https://github.com/webforge-labs/webforge-dom/blob/79bc03e8cb1a483e122e700d15bbb9ac607dd39b/lib/Webforge/DOM/XMLUtil.php#L43-L64
|
235,734
|
linusshops/behat-contexts
|
src/LinusShops/Contexts/Generic.php
|
Generic.waitFor
|
public function waitFor(callable $lambda, $attempts = 10, $waitInterval = 1)
{
for ($i = 0; $i < $attempts; $i++) {
try {
if ($lambda($this) === true) {
return;
}
} catch (\Exception $e) {
//Do nothing and pass on to next iteration
}
$this->wait($waitInterval);
}
throw new \Exception(
"Step did not succeed after {$attempts} attempts."
);
}
|
php
|
public function waitFor(callable $lambda, $attempts = 10, $waitInterval = 1)
{
for ($i = 0; $i < $attempts; $i++) {
try {
if ($lambda($this) === true) {
return;
}
} catch (\Exception $e) {
//Do nothing and pass on to next iteration
}
$this->wait($waitInterval);
}
throw new \Exception(
"Step did not succeed after {$attempts} attempts."
);
}
|
[
"public",
"function",
"waitFor",
"(",
"callable",
"$",
"lambda",
",",
"$",
"attempts",
"=",
"10",
",",
"$",
"waitInterval",
"=",
"1",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"attempts",
";",
"$",
"i",
"++",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"lambda",
"(",
"$",
"this",
")",
"===",
"true",
")",
"{",
"return",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"//Do nothing and pass on to next iteration",
"}",
"$",
"this",
"->",
"wait",
"(",
"$",
"waitInterval",
")",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Step did not succeed after {$attempts} attempts.\"",
")",
";",
"}"
] |
Attempt the given function a configurable number of times, waiting X seconds
between each attempt. If the step does not succeed in any of the attempts,
success being defined as the lambda returning true, then throw an exception.
@param callable $lambda - some action to attempt. Will be reattempted until
successful or the specified number of attempts is reached. Only a return
value of true is considered successful, anything else will be reattempted.
@param int $attempts - the number of times to run the lambda before giving up.
@param int $waitInterval - how long to wait between attempts
@throws \Exception - thrown if the lambda is never successful.
|
[
"Attempt",
"the",
"given",
"function",
"a",
"configurable",
"number",
"of",
"times",
"waiting",
"X",
"seconds",
"between",
"each",
"attempt",
".",
"If",
"the",
"step",
"does",
"not",
"succeed",
"in",
"any",
"of",
"the",
"attempts",
"success",
"being",
"defined",
"as",
"the",
"lambda",
"returning",
"true",
"then",
"throw",
"an",
"exception",
"."
] |
b90fc268114de2a71c441cfaaa2964b55fca2dbf
|
https://github.com/linusshops/behat-contexts/blob/b90fc268114de2a71c441cfaaa2964b55fca2dbf/src/LinusShops/Contexts/Generic.php#L26-L43
|
235,735
|
lciolecki/zf-extensions-library
|
library/Extlib/Paginator/Adapter/Doctrine.php
|
Doctrine.setRowCount
|
public function setRowCount($rowCount)
{
if ($rowCount instanceof \Doctrine_Query) {
$sql = $rowCount->getSql();
if (false === strpos($sql, self::ROW_COUNT_COLUMN)) {
throw new \Zend_Paginator_Exception('Row count column not found');
}
$result = $rowCount->fetchOne()->toArray();
$this->_rowCount = count($result) > 0 ? $result[self::ROW_COUNT_COLUMN] : 0;
} else if (is_integer($rowCount)) {
$this->_rowCount = $rowCount;
} else {
throw new \Zend_Paginator_Exception('Invalid row count');
}
return $this;
}
|
php
|
public function setRowCount($rowCount)
{
if ($rowCount instanceof \Doctrine_Query) {
$sql = $rowCount->getSql();
if (false === strpos($sql, self::ROW_COUNT_COLUMN)) {
throw new \Zend_Paginator_Exception('Row count column not found');
}
$result = $rowCount->fetchOne()->toArray();
$this->_rowCount = count($result) > 0 ? $result[self::ROW_COUNT_COLUMN] : 0;
} else if (is_integer($rowCount)) {
$this->_rowCount = $rowCount;
} else {
throw new \Zend_Paginator_Exception('Invalid row count');
}
return $this;
}
|
[
"public",
"function",
"setRowCount",
"(",
"$",
"rowCount",
")",
"{",
"if",
"(",
"$",
"rowCount",
"instanceof",
"\\",
"Doctrine_Query",
")",
"{",
"$",
"sql",
"=",
"$",
"rowCount",
"->",
"getSql",
"(",
")",
";",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"sql",
",",
"self",
"::",
"ROW_COUNT_COLUMN",
")",
")",
"{",
"throw",
"new",
"\\",
"Zend_Paginator_Exception",
"(",
"'Row count column not found'",
")",
";",
"}",
"$",
"result",
"=",
"$",
"rowCount",
"->",
"fetchOne",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"this",
"->",
"_rowCount",
"=",
"count",
"(",
"$",
"result",
")",
">",
"0",
"?",
"$",
"result",
"[",
"self",
"::",
"ROW_COUNT_COLUMN",
"]",
":",
"0",
";",
"}",
"else",
"if",
"(",
"is_integer",
"(",
"$",
"rowCount",
")",
")",
"{",
"$",
"this",
"->",
"_rowCount",
"=",
"$",
"rowCount",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Zend_Paginator_Exception",
"(",
"'Invalid row count'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets the total row count, either directly or through a supplied query
@param \Doctrine_Query|integer $totalRowCount Total row count integer
or query
@return \Zend_Paginator_Adapter_Doctrine $this
@throws \Zend_Paginator_Exception
|
[
"Sets",
"the",
"total",
"row",
"count",
"either",
"directly",
"or",
"through",
"a",
"supplied",
"query"
] |
f479a63188d17f1488b392d4fc14fe47a417ea55
|
https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Paginator/Adapter/Doctrine.php#L68-L87
|
235,736
|
znframework/package-generator
|
GrandVision.php
|
GrandVision.generate
|
public function generate(...$database)
{
$databases = $this->getDatabaseList($database);
foreach( $databases as $connection => $database )
{
$this->setDatabaseConfiguration($connection, $database, $configs);
$this->createVisionDirectoryByDatabaseName($database);
$this->createVisionModelFile($database, $configs);
}
}
|
php
|
public function generate(...$database)
{
$databases = $this->getDatabaseList($database);
foreach( $databases as $connection => $database )
{
$this->setDatabaseConfiguration($connection, $database, $configs);
$this->createVisionDirectoryByDatabaseName($database);
$this->createVisionModelFile($database, $configs);
}
}
|
[
"public",
"function",
"generate",
"(",
"...",
"$",
"database",
")",
"{",
"$",
"databases",
"=",
"$",
"this",
"->",
"getDatabaseList",
"(",
"$",
"database",
")",
";",
"foreach",
"(",
"$",
"databases",
"as",
"$",
"connection",
"=>",
"$",
"database",
")",
"{",
"$",
"this",
"->",
"setDatabaseConfiguration",
"(",
"$",
"connection",
",",
"$",
"database",
",",
"$",
"configs",
")",
";",
"$",
"this",
"->",
"createVisionDirectoryByDatabaseName",
"(",
"$",
"database",
")",
";",
"$",
"this",
"->",
"createVisionModelFile",
"(",
"$",
"database",
",",
"$",
"configs",
")",
";",
"}",
"}"
] |
Generate Grand Vision
@param mixed ...$database
|
[
"Generate",
"Grand",
"Vision"
] |
4524c28c607d8a5799b60bd39bee8be4fd1e7fba
|
https://github.com/znframework/package-generator/blob/4524c28c607d8a5799b60bd39bee8be4fd1e7fba/GrandVision.php#L42-L54
|
235,737
|
znframework/package-generator
|
GrandVision.php
|
GrandVision.setDatabaseConfiguration
|
protected function setDatabaseConfiguration($connection, &$database, &$configs)
{
$configs = [];
if( is_array($database) )
{
$configs = $database;
$database = $connection;
}
$configs['database'] = $database ?: $this->defaultDatabaseName;
}
|
php
|
protected function setDatabaseConfiguration($connection, &$database, &$configs)
{
$configs = [];
if( is_array($database) )
{
$configs = $database;
$database = $connection;
}
$configs['database'] = $database ?: $this->defaultDatabaseName;
}
|
[
"protected",
"function",
"setDatabaseConfiguration",
"(",
"$",
"connection",
",",
"&",
"$",
"database",
",",
"&",
"$",
"configs",
")",
"{",
"$",
"configs",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"database",
")",
")",
"{",
"$",
"configs",
"=",
"$",
"database",
";",
"$",
"database",
"=",
"$",
"connection",
";",
"}",
"$",
"configs",
"[",
"'database'",
"]",
"=",
"$",
"database",
"?",
":",
"$",
"this",
"->",
"defaultDatabaseName",
";",
"}"
] |
Protected set database configuration
|
[
"Protected",
"set",
"database",
"configuration"
] |
4524c28c607d8a5799b60bd39bee8be4fd1e7fba
|
https://github.com/znframework/package-generator/blob/4524c28c607d8a5799b60bd39bee8be4fd1e7fba/GrandVision.php#L84-L95
|
235,738
|
znframework/package-generator
|
GrandVision.php
|
GrandVision.createVisionModelFile
|
protected function createVisionModelFile($database, $configs)
{
$tables = $this->getTableList($database);
$database = ucfirst($database);
foreach( $tables as $table )
{
(new File)->object
(
'model',
$this->getDatabaseVisionClassName($database, $table),
[
'path' => $this->getDatabaseVisionDirectory($database),
'namespace' => $this->getDatabaseVisionNamespace($database),
'use' => ['GrandModel'],
'extends' => 'GrandModel',
'constants' =>
[
'table' => "'".ucfirst($table)."'",
'connection' => $this->stringArray($configs)
]
]
);
}
}
|
php
|
protected function createVisionModelFile($database, $configs)
{
$tables = $this->getTableList($database);
$database = ucfirst($database);
foreach( $tables as $table )
{
(new File)->object
(
'model',
$this->getDatabaseVisionClassName($database, $table),
[
'path' => $this->getDatabaseVisionDirectory($database),
'namespace' => $this->getDatabaseVisionNamespace($database),
'use' => ['GrandModel'],
'extends' => 'GrandModel',
'constants' =>
[
'table' => "'".ucfirst($table)."'",
'connection' => $this->stringArray($configs)
]
]
);
}
}
|
[
"protected",
"function",
"createVisionModelFile",
"(",
"$",
"database",
",",
"$",
"configs",
")",
"{",
"$",
"tables",
"=",
"$",
"this",
"->",
"getTableList",
"(",
"$",
"database",
")",
";",
"$",
"database",
"=",
"ucfirst",
"(",
"$",
"database",
")",
";",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"table",
")",
"{",
"(",
"new",
"File",
")",
"->",
"object",
"(",
"'model'",
",",
"$",
"this",
"->",
"getDatabaseVisionClassName",
"(",
"$",
"database",
",",
"$",
"table",
")",
",",
"[",
"'path'",
"=>",
"$",
"this",
"->",
"getDatabaseVisionDirectory",
"(",
"$",
"database",
")",
",",
"'namespace'",
"=>",
"$",
"this",
"->",
"getDatabaseVisionNamespace",
"(",
"$",
"database",
")",
",",
"'use'",
"=>",
"[",
"'GrandModel'",
"]",
",",
"'extends'",
"=>",
"'GrandModel'",
",",
"'constants'",
"=>",
"[",
"'table'",
"=>",
"\"'\"",
".",
"ucfirst",
"(",
"$",
"table",
")",
".",
"\"'\"",
",",
"'connection'",
"=>",
"$",
"this",
"->",
"stringArray",
"(",
"$",
"configs",
")",
"]",
"]",
")",
";",
"}",
"}"
] |
Protected create vision model file
|
[
"Protected",
"create",
"vision",
"model",
"file"
] |
4524c28c607d8a5799b60bd39bee8be4fd1e7fba
|
https://github.com/znframework/package-generator/blob/4524c28c607d8a5799b60bd39bee8be4fd1e7fba/GrandVision.php#L116-L141
|
235,739
|
znframework/package-generator
|
GrandVision.php
|
GrandVision.getDatabaseList
|
protected function getDatabaseList($database)
{
$databases = $database;
if( is_array(($database[0] ?? NULL)) )
{
$databases = $database[0];
}
if( empty($database) )
{
$databases = $this->tool->listDatabases();
}
return $databases;
}
|
php
|
protected function getDatabaseList($database)
{
$databases = $database;
if( is_array(($database[0] ?? NULL)) )
{
$databases = $database[0];
}
if( empty($database) )
{
$databases = $this->tool->listDatabases();
}
return $databases;
}
|
[
"protected",
"function",
"getDatabaseList",
"(",
"$",
"database",
")",
"{",
"$",
"databases",
"=",
"$",
"database",
";",
"if",
"(",
"is_array",
"(",
"(",
"$",
"database",
"[",
"0",
"]",
"??",
"NULL",
")",
")",
")",
"{",
"$",
"databases",
"=",
"$",
"database",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"database",
")",
")",
"{",
"$",
"databases",
"=",
"$",
"this",
"->",
"tool",
"->",
"listDatabases",
"(",
")",
";",
"}",
"return",
"$",
"databases",
";",
"}"
] |
Protected get database list
|
[
"Protected",
"get",
"database",
"list"
] |
4524c28c607d8a5799b60bd39bee8be4fd1e7fba
|
https://github.com/znframework/package-generator/blob/4524c28c607d8a5799b60bd39bee8be4fd1e7fba/GrandVision.php#L154-L169
|
235,740
|
znframework/package-generator
|
GrandVision.php
|
GrandVision.deleteVisionFile
|
protected function deleteVisionFile($database, $tables)
{
foreach( $tables as $table )
{
unlink($this->getVisionFilePath($database, $table));
}
}
|
php
|
protected function deleteVisionFile($database, $tables)
{
foreach( $tables as $table )
{
unlink($this->getVisionFilePath($database, $table));
}
}
|
[
"protected",
"function",
"deleteVisionFile",
"(",
"$",
"database",
",",
"$",
"tables",
")",
"{",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"table",
")",
"{",
"unlink",
"(",
"$",
"this",
"->",
"getVisionFilePath",
"(",
"$",
"database",
",",
"$",
"table",
")",
")",
";",
"}",
"}"
] |
Protected delete vision file
|
[
"Protected",
"delete",
"vision",
"file"
] |
4524c28c607d8a5799b60bd39bee8be4fd1e7fba
|
https://github.com/znframework/package-generator/blob/4524c28c607d8a5799b60bd39bee8be4fd1e7fba/GrandVision.php#L198-L204
|
235,741
|
znframework/package-generator
|
GrandVision.php
|
GrandVision.getDatabaseVisionClassName
|
protected function getDatabaseVisionClassName($database, $table)
{
return INTERNAL_ACCESS . ( strtolower($database) === strtolower($this->defaultDatabaseName) ? NULL : ucfirst($database) ) . ucfirst($table) . 'Vision';
}
|
php
|
protected function getDatabaseVisionClassName($database, $table)
{
return INTERNAL_ACCESS . ( strtolower($database) === strtolower($this->defaultDatabaseName) ? NULL : ucfirst($database) ) . ucfirst($table) . 'Vision';
}
|
[
"protected",
"function",
"getDatabaseVisionClassName",
"(",
"$",
"database",
",",
"$",
"table",
")",
"{",
"return",
"INTERNAL_ACCESS",
".",
"(",
"strtolower",
"(",
"$",
"database",
")",
"===",
"strtolower",
"(",
"$",
"this",
"->",
"defaultDatabaseName",
")",
"?",
"NULL",
":",
"ucfirst",
"(",
"$",
"database",
")",
")",
".",
"ucfirst",
"(",
"$",
"table",
")",
".",
"'Vision'",
";",
"}"
] |
Protected get database vision class name
|
[
"Protected",
"get",
"database",
"vision",
"class",
"name"
] |
4524c28c607d8a5799b60bd39bee8be4fd1e7fba
|
https://github.com/znframework/package-generator/blob/4524c28c607d8a5799b60bd39bee8be4fd1e7fba/GrandVision.php#L217-L220
|
235,742
|
znframework/package-generator
|
GrandVision.php
|
GrandVision.getVisionFilePath
|
protected function getVisionFilePath($database, $table)
{
return $this->getVisionDirectory() . Base::suffix(ucfirst($database)) . $this->getDatabaseVisionClassName($database, $table) . '.php';
}
|
php
|
protected function getVisionFilePath($database, $table)
{
return $this->getVisionDirectory() . Base::suffix(ucfirst($database)) . $this->getDatabaseVisionClassName($database, $table) . '.php';
}
|
[
"protected",
"function",
"getVisionFilePath",
"(",
"$",
"database",
",",
"$",
"table",
")",
"{",
"return",
"$",
"this",
"->",
"getVisionDirectory",
"(",
")",
".",
"Base",
"::",
"suffix",
"(",
"ucfirst",
"(",
"$",
"database",
")",
")",
".",
"$",
"this",
"->",
"getDatabaseVisionClassName",
"(",
"$",
"database",
",",
"$",
"table",
")",
".",
"'.php'",
";",
"}"
] |
Protected get vision file path
|
[
"Protected",
"get",
"vision",
"file",
"path"
] |
4524c28c607d8a5799b60bd39bee8be4fd1e7fba
|
https://github.com/znframework/package-generator/blob/4524c28c607d8a5799b60bd39bee8be4fd1e7fba/GrandVision.php#L225-L228
|
235,743
|
znframework/package-generator
|
GrandVision.php
|
GrandVision.stringArray
|
protected function stringArray(Array $data)
{
$str = EOL . HT . '[' . EOL;
foreach( $data as $key => $val )
{
$str .= HT . HT . "'" . $key . "' => '" . $val . "'," . EOL;
}
$str = Base::removeSuffix($str, ',' . EOL);
$str .= EOL . HT . ']';
return $str;
}
|
php
|
protected function stringArray(Array $data)
{
$str = EOL . HT . '[' . EOL;
foreach( $data as $key => $val )
{
$str .= HT . HT . "'" . $key . "' => '" . $val . "'," . EOL;
}
$str = Base::removeSuffix($str, ',' . EOL);
$str .= EOL . HT . ']';
return $str;
}
|
[
"protected",
"function",
"stringArray",
"(",
"Array",
"$",
"data",
")",
"{",
"$",
"str",
"=",
"EOL",
".",
"HT",
".",
"'['",
".",
"EOL",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"str",
".=",
"HT",
".",
"HT",
".",
"\"'\"",
".",
"$",
"key",
".",
"\"' => '\"",
".",
"$",
"val",
".",
"\"',\"",
".",
"EOL",
";",
"}",
"$",
"str",
"=",
"Base",
"::",
"removeSuffix",
"(",
"$",
"str",
",",
"','",
".",
"EOL",
")",
";",
"$",
"str",
".=",
"EOL",
".",
"HT",
".",
"']'",
";",
"return",
"$",
"str",
";",
"}"
] |
Protected String Array
@param array $data
@return string
|
[
"Protected",
"String",
"Array"
] |
4524c28c607d8a5799b60bd39bee8be4fd1e7fba
|
https://github.com/znframework/package-generator/blob/4524c28c607d8a5799b60bd39bee8be4fd1e7fba/GrandVision.php#L245-L258
|
235,744
|
comodojo/rpcserver
|
src/Comodojo/RpcServer/RpcServer.php
|
RpcServer.uncan
|
private function uncan($payload) {
$decoded = null;
if ( empty($payload) || !is_string($payload) ) throw new RpcException("Invalid Request", -32600);
if ( substr($payload, 0, 27) == 'comodojo_encrypted_request-' ) {
if ( empty($this->encrypt) ) throw new RpcException("Transport error", -32300);
$this->request_is_encrypted = true;
$aes = new AES();
$aes->setKey($this->encrypt);
$payload = $aes->decrypt(base64_decode(substr($payload, 27)));
if ( $payload == false ) throw new RpcException("Transport error", -32300);
}
if ( $this->protocol == 'xml' ) {
$decoder = new XmlrpcDecoder();
try {
$decoded = $decoder->decodeCall($payload);
} catch (XmlrpcException $xe) {
throw new RpcException("Parse error", -32700);
}
} else if ( $this->protocol == 'json' ) {
if ( strtolower($this->encoding) != 'utf-8' ) {
$payload = mb_convert_encoding($payload, "UTF-8", strtoupper($this->encoding));
}
$decoded = json_decode($payload, false /*DO RAW conversion*/);
if ( is_null($decoded) ) throw new RpcException("Parse error", -32700);
} else {
throw new RpcException("Transport error", -32300);
}
return $decoded;
}
|
php
|
private function uncan($payload) {
$decoded = null;
if ( empty($payload) || !is_string($payload) ) throw new RpcException("Invalid Request", -32600);
if ( substr($payload, 0, 27) == 'comodojo_encrypted_request-' ) {
if ( empty($this->encrypt) ) throw new RpcException("Transport error", -32300);
$this->request_is_encrypted = true;
$aes = new AES();
$aes->setKey($this->encrypt);
$payload = $aes->decrypt(base64_decode(substr($payload, 27)));
if ( $payload == false ) throw new RpcException("Transport error", -32300);
}
if ( $this->protocol == 'xml' ) {
$decoder = new XmlrpcDecoder();
try {
$decoded = $decoder->decodeCall($payload);
} catch (XmlrpcException $xe) {
throw new RpcException("Parse error", -32700);
}
} else if ( $this->protocol == 'json' ) {
if ( strtolower($this->encoding) != 'utf-8' ) {
$payload = mb_convert_encoding($payload, "UTF-8", strtoupper($this->encoding));
}
$decoded = json_decode($payload, false /*DO RAW conversion*/);
if ( is_null($decoded) ) throw new RpcException("Parse error", -32700);
} else {
throw new RpcException("Transport error", -32300);
}
return $decoded;
}
|
[
"private",
"function",
"uncan",
"(",
"$",
"payload",
")",
"{",
"$",
"decoded",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"payload",
")",
"||",
"!",
"is_string",
"(",
"$",
"payload",
")",
")",
"throw",
"new",
"RpcException",
"(",
"\"Invalid Request\"",
",",
"-",
"32600",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"payload",
",",
"0",
",",
"27",
")",
"==",
"'comodojo_encrypted_request-'",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"encrypt",
")",
")",
"throw",
"new",
"RpcException",
"(",
"\"Transport error\"",
",",
"-",
"32300",
")",
";",
"$",
"this",
"->",
"request_is_encrypted",
"=",
"true",
";",
"$",
"aes",
"=",
"new",
"AES",
"(",
")",
";",
"$",
"aes",
"->",
"setKey",
"(",
"$",
"this",
"->",
"encrypt",
")",
";",
"$",
"payload",
"=",
"$",
"aes",
"->",
"decrypt",
"(",
"base64_decode",
"(",
"substr",
"(",
"$",
"payload",
",",
"27",
")",
")",
")",
";",
"if",
"(",
"$",
"payload",
"==",
"false",
")",
"throw",
"new",
"RpcException",
"(",
"\"Transport error\"",
",",
"-",
"32300",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"protocol",
"==",
"'xml'",
")",
"{",
"$",
"decoder",
"=",
"new",
"XmlrpcDecoder",
"(",
")",
";",
"try",
"{",
"$",
"decoded",
"=",
"$",
"decoder",
"->",
"decodeCall",
"(",
"$",
"payload",
")",
";",
"}",
"catch",
"(",
"XmlrpcException",
"$",
"xe",
")",
"{",
"throw",
"new",
"RpcException",
"(",
"\"Parse error\"",
",",
"-",
"32700",
")",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"protocol",
"==",
"'json'",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"encoding",
")",
"!=",
"'utf-8'",
")",
"{",
"$",
"payload",
"=",
"mb_convert_encoding",
"(",
"$",
"payload",
",",
"\"UTF-8\"",
",",
"strtoupper",
"(",
"$",
"this",
"->",
"encoding",
")",
")",
";",
"}",
"$",
"decoded",
"=",
"json_decode",
"(",
"$",
"payload",
",",
"false",
"/*DO RAW conversion*/",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"decoded",
")",
")",
"throw",
"new",
"RpcException",
"(",
"\"Parse error\"",
",",
"-",
"32700",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RpcException",
"(",
"\"Transport error\"",
",",
"-",
"32300",
")",
";",
"}",
"return",
"$",
"decoded",
";",
"}"
] |
Uncan the provided payload
@param string $payload
@return mixed
@throws RpcException
|
[
"Uncan",
"the",
"provided",
"payload"
] |
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
|
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcServer.php#L386-L442
|
235,745
|
comodojo/rpcserver
|
src/Comodojo/RpcServer/RpcServer.php
|
RpcServer.can
|
private function can($response, $error) {
$encoded = null;
if ( $this->protocol == 'xml' ) {
$encoder = new XmlrpcEncoder();
$encoder->setEncoding($this->encoding);
try {
$encoded = $error ? $encoder->encodeError($response->getCode(), $response->getMessage()) : $encoder->encodeResponse($response);
} catch (XmlrpcException $xe) {
$this->logger->error($xe->getMessage());
$encoded = $encoder->encodeError(-32500, "Application error");
}
} else {
if ( strtolower($this->encoding) != 'utf-8' && !is_null($response) ) {
array_walk_recursive($response, function(&$entry) {
if ( is_string($entry) ) {
$entry = mb_convert_encoding($entry, strtoupper($this->encoding), "UTF-8");
}
});
}
// json will not return any RpcException; errors (in case) are handled directly by processor
$encoded = is_null($response) ? null : json_encode($response/*, JSON_NUMERIC_CHECK*/);
}
$this->logger->debug("Plain response: $encoded");
if ( $this->request_is_encrypted /* && !empty($encoded) */ ) {
$aes = new AES();
$aes->setKey($this->encrypt);
$encoded = 'comodojo_encrypted_response-'.base64_encode($aes->encrypt($encoded));
$this->logger->debug("Encrypted response: $encoded");
}
return $encoded;
}
|
php
|
private function can($response, $error) {
$encoded = null;
if ( $this->protocol == 'xml' ) {
$encoder = new XmlrpcEncoder();
$encoder->setEncoding($this->encoding);
try {
$encoded = $error ? $encoder->encodeError($response->getCode(), $response->getMessage()) : $encoder->encodeResponse($response);
} catch (XmlrpcException $xe) {
$this->logger->error($xe->getMessage());
$encoded = $encoder->encodeError(-32500, "Application error");
}
} else {
if ( strtolower($this->encoding) != 'utf-8' && !is_null($response) ) {
array_walk_recursive($response, function(&$entry) {
if ( is_string($entry) ) {
$entry = mb_convert_encoding($entry, strtoupper($this->encoding), "UTF-8");
}
});
}
// json will not return any RpcException; errors (in case) are handled directly by processor
$encoded = is_null($response) ? null : json_encode($response/*, JSON_NUMERIC_CHECK*/);
}
$this->logger->debug("Plain response: $encoded");
if ( $this->request_is_encrypted /* && !empty($encoded) */ ) {
$aes = new AES();
$aes->setKey($this->encrypt);
$encoded = 'comodojo_encrypted_response-'.base64_encode($aes->encrypt($encoded));
$this->logger->debug("Encrypted response: $encoded");
}
return $encoded;
}
|
[
"private",
"function",
"can",
"(",
"$",
"response",
",",
"$",
"error",
")",
"{",
"$",
"encoded",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"protocol",
"==",
"'xml'",
")",
"{",
"$",
"encoder",
"=",
"new",
"XmlrpcEncoder",
"(",
")",
";",
"$",
"encoder",
"->",
"setEncoding",
"(",
"$",
"this",
"->",
"encoding",
")",
";",
"try",
"{",
"$",
"encoded",
"=",
"$",
"error",
"?",
"$",
"encoder",
"->",
"encodeError",
"(",
"$",
"response",
"->",
"getCode",
"(",
")",
",",
"$",
"response",
"->",
"getMessage",
"(",
")",
")",
":",
"$",
"encoder",
"->",
"encodeResponse",
"(",
"$",
"response",
")",
";",
"}",
"catch",
"(",
"XmlrpcException",
"$",
"xe",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"$",
"xe",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"encoded",
"=",
"$",
"encoder",
"->",
"encodeError",
"(",
"-",
"32500",
",",
"\"Application error\"",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"encoding",
")",
"!=",
"'utf-8'",
"&&",
"!",
"is_null",
"(",
"$",
"response",
")",
")",
"{",
"array_walk_recursive",
"(",
"$",
"response",
",",
"function",
"(",
"&",
"$",
"entry",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"entry",
")",
")",
"{",
"$",
"entry",
"=",
"mb_convert_encoding",
"(",
"$",
"entry",
",",
"strtoupper",
"(",
"$",
"this",
"->",
"encoding",
")",
",",
"\"UTF-8\"",
")",
";",
"}",
"}",
")",
";",
"}",
"// json will not return any RpcException; errors (in case) are handled directly by processor",
"$",
"encoded",
"=",
"is_null",
"(",
"$",
"response",
")",
"?",
"null",
":",
"json_encode",
"(",
"$",
"response",
"/*, JSON_NUMERIC_CHECK*/",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"Plain response: $encoded\"",
")",
";",
"if",
"(",
"$",
"this",
"->",
"request_is_encrypted",
"/* && !empty($encoded) */",
")",
"{",
"$",
"aes",
"=",
"new",
"AES",
"(",
")",
";",
"$",
"aes",
"->",
"setKey",
"(",
"$",
"this",
"->",
"encrypt",
")",
";",
"$",
"encoded",
"=",
"'comodojo_encrypted_response-'",
".",
"base64_encode",
"(",
"$",
"aes",
"->",
"encrypt",
"(",
"$",
"encoded",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"Encrypted response: $encoded\"",
")",
";",
"}",
"return",
"$",
"encoded",
";",
"}"
] |
Can the RPC response
@param mixed $response
@param boolean $error
@return string
@throws RpcException
|
[
"Can",
"the",
"RPC",
"response"
] |
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
|
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcServer.php#L453-L513
|
235,746
|
comodojo/rpcserver
|
src/Comodojo/RpcServer/RpcServer.php
|
RpcServer.setIntrospectionMethods
|
private static function setIntrospectionMethods($methods) {
$methods->add(RpcMethod::create("system.getCapabilities", '\Comodojo\RpcServer\Reserved\GetCapabilities::execute')
->setDescription("This method lists all the capabilites that the RPC server has: the (more or less standard) extensions to the RPC spec that it adheres to")
->setReturnType('struct')
);
$methods->add(RpcMethod::create("system.listMethods", '\Comodojo\RpcServer\Introspection\ListMethods::execute')
->setDescription("This method lists all the methods that the RPC server knows how to dispatch")
->setReturnType('array')
);
$methods->add(RpcMethod::create("system.methodHelp", '\Comodojo\RpcServer\Introspection\MethodHelp::execute')
->setDescription("Returns help text if defined for the method passed, otherwise returns an empty string")
->setReturnType('string')
->addParameter('string', 'method')
);
$methods->add(RpcMethod::create("system.methodSignature", '\Comodojo\RpcServer\Introspection\MethodSignature::execute')
->setDescription("Returns an array of known signatures (an array of arrays) for the method name passed.".
"If no signatures are known, returns a none-array (test for type != array to detect missing signature)")
->setReturnType('array')
->addParameter('string', 'method')
);
$methods->add(RpcMethod::create("system.multicall", '\Comodojo\RpcServer\Reserved\Multicall::execute')
->setDescription("Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader\$1208 for details")
->setReturnType('array')
->addParameter('array', 'requests')
);
}
|
php
|
private static function setIntrospectionMethods($methods) {
$methods->add(RpcMethod::create("system.getCapabilities", '\Comodojo\RpcServer\Reserved\GetCapabilities::execute')
->setDescription("This method lists all the capabilites that the RPC server has: the (more or less standard) extensions to the RPC spec that it adheres to")
->setReturnType('struct')
);
$methods->add(RpcMethod::create("system.listMethods", '\Comodojo\RpcServer\Introspection\ListMethods::execute')
->setDescription("This method lists all the methods that the RPC server knows how to dispatch")
->setReturnType('array')
);
$methods->add(RpcMethod::create("system.methodHelp", '\Comodojo\RpcServer\Introspection\MethodHelp::execute')
->setDescription("Returns help text if defined for the method passed, otherwise returns an empty string")
->setReturnType('string')
->addParameter('string', 'method')
);
$methods->add(RpcMethod::create("system.methodSignature", '\Comodojo\RpcServer\Introspection\MethodSignature::execute')
->setDescription("Returns an array of known signatures (an array of arrays) for the method name passed.".
"If no signatures are known, returns a none-array (test for type != array to detect missing signature)")
->setReturnType('array')
->addParameter('string', 'method')
);
$methods->add(RpcMethod::create("system.multicall", '\Comodojo\RpcServer\Reserved\Multicall::execute')
->setDescription("Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader\$1208 for details")
->setReturnType('array')
->addParameter('array', 'requests')
);
}
|
[
"private",
"static",
"function",
"setIntrospectionMethods",
"(",
"$",
"methods",
")",
"{",
"$",
"methods",
"->",
"add",
"(",
"RpcMethod",
"::",
"create",
"(",
"\"system.getCapabilities\"",
",",
"'\\Comodojo\\RpcServer\\Reserved\\GetCapabilities::execute'",
")",
"->",
"setDescription",
"(",
"\"This method lists all the capabilites that the RPC server has: the (more or less standard) extensions to the RPC spec that it adheres to\"",
")",
"->",
"setReturnType",
"(",
"'struct'",
")",
")",
";",
"$",
"methods",
"->",
"add",
"(",
"RpcMethod",
"::",
"create",
"(",
"\"system.listMethods\"",
",",
"'\\Comodojo\\RpcServer\\Introspection\\ListMethods::execute'",
")",
"->",
"setDescription",
"(",
"\"This method lists all the methods that the RPC server knows how to dispatch\"",
")",
"->",
"setReturnType",
"(",
"'array'",
")",
")",
";",
"$",
"methods",
"->",
"add",
"(",
"RpcMethod",
"::",
"create",
"(",
"\"system.methodHelp\"",
",",
"'\\Comodojo\\RpcServer\\Introspection\\MethodHelp::execute'",
")",
"->",
"setDescription",
"(",
"\"Returns help text if defined for the method passed, otherwise returns an empty string\"",
")",
"->",
"setReturnType",
"(",
"'string'",
")",
"->",
"addParameter",
"(",
"'string'",
",",
"'method'",
")",
")",
";",
"$",
"methods",
"->",
"add",
"(",
"RpcMethod",
"::",
"create",
"(",
"\"system.methodSignature\"",
",",
"'\\Comodojo\\RpcServer\\Introspection\\MethodSignature::execute'",
")",
"->",
"setDescription",
"(",
"\"Returns an array of known signatures (an array of arrays) for the method name passed.\"",
".",
"\"If no signatures are known, returns a none-array (test for type != array to detect missing signature)\"",
")",
"->",
"setReturnType",
"(",
"'array'",
")",
"->",
"addParameter",
"(",
"'string'",
",",
"'method'",
")",
")",
";",
"$",
"methods",
"->",
"add",
"(",
"RpcMethod",
"::",
"create",
"(",
"\"system.multicall\"",
",",
"'\\Comodojo\\RpcServer\\Reserved\\Multicall::execute'",
")",
"->",
"setDescription",
"(",
"\"Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader\\$1208 for details\"",
")",
"->",
"setReturnType",
"(",
"'array'",
")",
"->",
"addParameter",
"(",
"'array'",
",",
"'requests'",
")",
")",
";",
"}"
] |
Inject introspection and reserved RPC methods
@param Methods $methods
|
[
"Inject",
"introspection",
"and",
"reserved",
"RPC",
"methods"
] |
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
|
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcServer.php#L520-L551
|
235,747
|
comodojo/rpcserver
|
src/Comodojo/RpcServer/RpcServer.php
|
RpcServer.setCapabilities
|
private static function setCapabilities($capabilities) {
$supported_capabilities = array(
'xmlrpc' => array('http://www.xmlrpc.com/spec', 1),
'system.multicall' => array('http://www.xmlrpc.com/discuss/msgReader$1208', 1),
'introspection' => array('http://phpxmlrpc.sourceforge.net/doc-2/ch10.html', 2),
'nil' => array('http://www.ontosys.com/xml-rpc/extensions.php', 1),
'faults_interop' => array('http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php', 20010516),
'json-rpc' => array('http://www.jsonrpc.org/specification', 2)
);
foreach ( $supported_capabilities as $capability => $values ) {
$capabilities->add($capability, $values[0], $values[1]);
}
}
|
php
|
private static function setCapabilities($capabilities) {
$supported_capabilities = array(
'xmlrpc' => array('http://www.xmlrpc.com/spec', 1),
'system.multicall' => array('http://www.xmlrpc.com/discuss/msgReader$1208', 1),
'introspection' => array('http://phpxmlrpc.sourceforge.net/doc-2/ch10.html', 2),
'nil' => array('http://www.ontosys.com/xml-rpc/extensions.php', 1),
'faults_interop' => array('http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php', 20010516),
'json-rpc' => array('http://www.jsonrpc.org/specification', 2)
);
foreach ( $supported_capabilities as $capability => $values ) {
$capabilities->add($capability, $values[0], $values[1]);
}
}
|
[
"private",
"static",
"function",
"setCapabilities",
"(",
"$",
"capabilities",
")",
"{",
"$",
"supported_capabilities",
"=",
"array",
"(",
"'xmlrpc'",
"=>",
"array",
"(",
"'http://www.xmlrpc.com/spec'",
",",
"1",
")",
",",
"'system.multicall'",
"=>",
"array",
"(",
"'http://www.xmlrpc.com/discuss/msgReader$1208'",
",",
"1",
")",
",",
"'introspection'",
"=>",
"array",
"(",
"'http://phpxmlrpc.sourceforge.net/doc-2/ch10.html'",
",",
"2",
")",
",",
"'nil'",
"=>",
"array",
"(",
"'http://www.ontosys.com/xml-rpc/extensions.php'",
",",
"1",
")",
",",
"'faults_interop'",
"=>",
"array",
"(",
"'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php'",
",",
"20010516",
")",
",",
"'json-rpc'",
"=>",
"array",
"(",
"'http://www.jsonrpc.org/specification'",
",",
"2",
")",
")",
";",
"foreach",
"(",
"$",
"supported_capabilities",
"as",
"$",
"capability",
"=>",
"$",
"values",
")",
"{",
"$",
"capabilities",
"->",
"add",
"(",
"$",
"capability",
",",
"$",
"values",
"[",
"0",
"]",
",",
"$",
"values",
"[",
"1",
"]",
")",
";",
"}",
"}"
] |
Inject supported capabilities
@param Capabilities $capabilities
|
[
"Inject",
"supported",
"capabilities"
] |
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
|
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcServer.php#L558-L575
|
235,748
|
comodojo/rpcserver
|
src/Comodojo/RpcServer/RpcServer.php
|
RpcServer.setErrors
|
private static function setErrors($errors) {
$std_rpc_errors = array(
-32700 => "Parse error",
-32701 => "Parse error - Unsupported encoding",
-32702 => "Parse error - Invalid character for encoding",
-32600 => "Invalid Request",
-32601 => "Method not found",
-32602 => "Invalid params",
-32603 => "Internal error",
-32500 => "Application error",
-32400 => "System error",
-32300 => "Transport error",
// Predefined Comodojo Errors
-31000 => "Multicall is available only in XMLRPC",
-31001 => "Recursive system.multicall forbidden"
);
foreach ( $std_rpc_errors as $code => $message ) {
$errors->add($code, $message);
}
}
|
php
|
private static function setErrors($errors) {
$std_rpc_errors = array(
-32700 => "Parse error",
-32701 => "Parse error - Unsupported encoding",
-32702 => "Parse error - Invalid character for encoding",
-32600 => "Invalid Request",
-32601 => "Method not found",
-32602 => "Invalid params",
-32603 => "Internal error",
-32500 => "Application error",
-32400 => "System error",
-32300 => "Transport error",
// Predefined Comodojo Errors
-31000 => "Multicall is available only in XMLRPC",
-31001 => "Recursive system.multicall forbidden"
);
foreach ( $std_rpc_errors as $code => $message ) {
$errors->add($code, $message);
}
}
|
[
"private",
"static",
"function",
"setErrors",
"(",
"$",
"errors",
")",
"{",
"$",
"std_rpc_errors",
"=",
"array",
"(",
"-",
"32700",
"=>",
"\"Parse error\"",
",",
"-",
"32701",
"=>",
"\"Parse error - Unsupported encoding\"",
",",
"-",
"32702",
"=>",
"\"Parse error - Invalid character for encoding\"",
",",
"-",
"32600",
"=>",
"\"Invalid Request\"",
",",
"-",
"32601",
"=>",
"\"Method not found\"",
",",
"-",
"32602",
"=>",
"\"Invalid params\"",
",",
"-",
"32603",
"=>",
"\"Internal error\"",
",",
"-",
"32500",
"=>",
"\"Application error\"",
",",
"-",
"32400",
"=>",
"\"System error\"",
",",
"-",
"32300",
"=>",
"\"Transport error\"",
",",
"// Predefined Comodojo Errors",
"-",
"31000",
"=>",
"\"Multicall is available only in XMLRPC\"",
",",
"-",
"31001",
"=>",
"\"Recursive system.multicall forbidden\"",
")",
";",
"foreach",
"(",
"$",
"std_rpc_errors",
"as",
"$",
"code",
"=>",
"$",
"message",
")",
"{",
"$",
"errors",
"->",
"add",
"(",
"$",
"code",
",",
"$",
"message",
")",
";",
"}",
"}"
] |
Inject standard and RPC errors
@param Errors $errors
|
[
"Inject",
"standard",
"and",
"RPC",
"errors"
] |
6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c
|
https://github.com/comodojo/rpcserver/blob/6b4766f1554f6fe6b06199c0c1fb97e1b5a8bb1c/src/Comodojo/RpcServer/RpcServer.php#L582-L606
|
235,749
|
wasabi-cms/core
|
src/Model/Table/UsersGroupsTable.php
|
UsersGroupsTable.findUserIdsWithOnlyOneGroup
|
public function findUserIdsWithOnlyOneGroup()
{
$query = $this->find();
return $query
->select([
'user_id',
'group_count' => $query->func()->count('*')
])
->group('user_id')
->having([
'group_count = 1'
])
->extract('user_id')
->toArray();
}
|
php
|
public function findUserIdsWithOnlyOneGroup()
{
$query = $this->find();
return $query
->select([
'user_id',
'group_count' => $query->func()->count('*')
])
->group('user_id')
->having([
'group_count = 1'
])
->extract('user_id')
->toArray();
}
|
[
"public",
"function",
"findUserIdsWithOnlyOneGroup",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"find",
"(",
")",
";",
"return",
"$",
"query",
"->",
"select",
"(",
"[",
"'user_id'",
",",
"'group_count'",
"=>",
"$",
"query",
"->",
"func",
"(",
")",
"->",
"count",
"(",
"'*'",
")",
"]",
")",
"->",
"group",
"(",
"'user_id'",
")",
"->",
"having",
"(",
"[",
"'group_count = 1'",
"]",
")",
"->",
"extract",
"(",
"'user_id'",
")",
"->",
"toArray",
"(",
")",
";",
"}"
] |
Find all user ids of users assigned to only one group.
@return array
|
[
"Find",
"all",
"user",
"ids",
"of",
"users",
"assigned",
"to",
"only",
"one",
"group",
"."
] |
0eadbb64d2fc201bacc63c93814adeca70e08f90
|
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Model/Table/UsersGroupsTable.php#L56-L70
|
235,750
|
prototypemvc/prototypemvc
|
Core/Text.php
|
Text.contains
|
public static function contains($string = false, $substring = false) {
if ($substring && $substring && strpos($string, $substring) !== false) {
return true;
}
return false;
}
|
php
|
public static function contains($string = false, $substring = false) {
if ($substring && $substring && strpos($string, $substring) !== false) {
return true;
}
return false;
}
|
[
"public",
"static",
"function",
"contains",
"(",
"$",
"string",
"=",
"false",
",",
"$",
"substring",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"substring",
"&&",
"$",
"substring",
"&&",
"strpos",
"(",
"$",
"string",
",",
"$",
"substring",
")",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check if the given string contains a specific substring.
@param string full string
@param string substring
@return boolean
|
[
"Check",
"if",
"the",
"given",
"string",
"contains",
"a",
"specific",
"substring",
"."
] |
039e238857d4b627e40ba681a376583b0821cd36
|
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Text.php#L13-L21
|
235,751
|
prototypemvc/prototypemvc
|
Core/Text.php
|
Text.count
|
public static function count($string = false, $selector = false) {
if ($string) {
switch ($selector) {
case 'words':
return str_word_count($string);
default:
if (self::substring($selector, 0, 1) === ':') {
return substr_count($string, self::substring($selector, 1));
}
return self::length($string);
}
}
return false;
}
|
php
|
public static function count($string = false, $selector = false) {
if ($string) {
switch ($selector) {
case 'words':
return str_word_count($string);
default:
if (self::substring($selector, 0, 1) === ':') {
return substr_count($string, self::substring($selector, 1));
}
return self::length($string);
}
}
return false;
}
|
[
"public",
"static",
"function",
"count",
"(",
"$",
"string",
"=",
"false",
",",
"$",
"selector",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"string",
")",
"{",
"switch",
"(",
"$",
"selector",
")",
"{",
"case",
"'words'",
":",
"return",
"str_word_count",
"(",
"$",
"string",
")",
";",
"default",
":",
"if",
"(",
"self",
"::",
"substring",
"(",
"$",
"selector",
",",
"0",
",",
"1",
")",
"===",
"':'",
")",
"{",
"return",
"substr_count",
"(",
"$",
"string",
",",
"self",
"::",
"substring",
"(",
"$",
"selector",
",",
"1",
")",
")",
";",
"}",
"return",
"self",
"::",
"length",
"(",
"$",
"string",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Get string length, number of words or the occurences of specific word.
@param string full string
@param string selector
@example count('hello world') - will return length of string which is 11
@example count('hello world', 'words') - will return number of words which is 2
@example count('hello world', ':hello') - will return number of occurences of string 'hello' which is 1
@return boolean
|
[
"Get",
"string",
"length",
"number",
"of",
"words",
"or",
"the",
"occurences",
"of",
"specific",
"word",
"."
] |
039e238857d4b627e40ba681a376583b0821cd36
|
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Text.php#L32-L48
|
235,752
|
prototypemvc/prototypemvc
|
Core/Text.php
|
Text.lowercase
|
public static function lowercase($string = false, $selector = false) {
if ($string) {
switch ($selector) {
case 'first':
return lcfirst($string);
case 'words':
return lcwords($string);
default:
return strtolower($string);
}
}
return false;
}
|
php
|
public static function lowercase($string = false, $selector = false) {
if ($string) {
switch ($selector) {
case 'first':
return lcfirst($string);
case 'words':
return lcwords($string);
default:
return strtolower($string);
}
}
return false;
}
|
[
"public",
"static",
"function",
"lowercase",
"(",
"$",
"string",
"=",
"false",
",",
"$",
"selector",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"string",
")",
"{",
"switch",
"(",
"$",
"selector",
")",
"{",
"case",
"'first'",
":",
"return",
"lcfirst",
"(",
"$",
"string",
")",
";",
"case",
"'words'",
":",
"return",
"lcwords",
"(",
"$",
"string",
")",
";",
"default",
":",
"return",
"strtolower",
"(",
"$",
"string",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Get string in lowercase.
@param string full string
@return string in lowercase
|
[
"Get",
"string",
"in",
"lowercase",
"."
] |
039e238857d4b627e40ba681a376583b0821cd36
|
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Text.php#L85-L100
|
235,753
|
prototypemvc/prototypemvc
|
Core/Text.php
|
Text.replace
|
public static function replace($string = false, $find = false, $replaceWith = '') {
if ($string && $find) {
return str_replace($find, $replaceWith, $string);
}
return false;
}
|
php
|
public static function replace($string = false, $find = false, $replaceWith = '') {
if ($string && $find) {
return str_replace($find, $replaceWith, $string);
}
return false;
}
|
[
"public",
"static",
"function",
"replace",
"(",
"$",
"string",
"=",
"false",
",",
"$",
"find",
"=",
"false",
",",
"$",
"replaceWith",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"string",
"&&",
"$",
"find",
")",
"{",
"return",
"str_replace",
"(",
"$",
"find",
",",
"$",
"replaceWith",
",",
"$",
"string",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Get string with specific substring replaced.
@param string full string
@param string substring to find and replace
@param string replace with this value
@return string trimmed
|
[
"Get",
"string",
"with",
"specific",
"substring",
"replaced",
"."
] |
039e238857d4b627e40ba681a376583b0821cd36
|
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Text.php#L109-L117
|
235,754
|
prototypemvc/prototypemvc
|
Core/Text.php
|
Text.substring
|
public static function substring($string = false, $firstIndex = 0, $maxStringLength = false) {
if ($string) {
if (!$maxStringLength) {
$maxStringLength = (self::length($string) - $firstIndex);
}
return substr($string, $firstIndex, $maxStringLength);
}
return false;
}
|
php
|
public static function substring($string = false, $firstIndex = 0, $maxStringLength = false) {
if ($string) {
if (!$maxStringLength) {
$maxStringLength = (self::length($string) - $firstIndex);
}
return substr($string, $firstIndex, $maxStringLength);
}
return false;
}
|
[
"public",
"static",
"function",
"substring",
"(",
"$",
"string",
"=",
"false",
",",
"$",
"firstIndex",
"=",
"0",
",",
"$",
"maxStringLength",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"$",
"maxStringLength",
")",
"{",
"$",
"maxStringLength",
"=",
"(",
"self",
"::",
"length",
"(",
"$",
"string",
")",
"-",
"$",
"firstIndex",
")",
";",
"}",
"return",
"substr",
"(",
"$",
"string",
",",
"$",
"firstIndex",
",",
"$",
"maxStringLength",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Get substring.
@param string full string
@param int first index (starting point)
@param int max string length
@return string substring
|
[
"Get",
"substring",
"."
] |
039e238857d4b627e40ba681a376583b0821cd36
|
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Text.php#L210-L223
|
235,755
|
prototypemvc/prototypemvc
|
Core/Text.php
|
Text.uppercase
|
public static function uppercase($string = false, $selector = false) {
if ($string) {
switch ($selector) {
case 'first':
return ucfirst($string);
case 'words':
return ucwords($string);
default:
return strtoupper($string);
}
}
return false;
}
|
php
|
public static function uppercase($string = false, $selector = false) {
if ($string) {
switch ($selector) {
case 'first':
return ucfirst($string);
case 'words':
return ucwords($string);
default:
return strtoupper($string);
}
}
return false;
}
|
[
"public",
"static",
"function",
"uppercase",
"(",
"$",
"string",
"=",
"false",
",",
"$",
"selector",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"string",
")",
"{",
"switch",
"(",
"$",
"selector",
")",
"{",
"case",
"'first'",
":",
"return",
"ucfirst",
"(",
"$",
"string",
")",
";",
"case",
"'words'",
":",
"return",
"ucwords",
"(",
"$",
"string",
")",
";",
"default",
":",
"return",
"strtoupper",
"(",
"$",
"string",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Get string in uppercase.
@param string full string
@return string in uppercase
|
[
"Get",
"string",
"in",
"uppercase",
"."
] |
039e238857d4b627e40ba681a376583b0821cd36
|
https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Text.php#L230-L245
|
235,756
|
kambo-1st/HttpMessage
|
src/ServerRequest.php
|
ServerRequest.validateUploadedFiles
|
private function validateUploadedFiles(array $uploadedFiles)
{
foreach ($uploadedFiles as $file) {
if (is_array($file)) {
$this->validateUploadedFiles($file);
} elseif (!$file instanceof UploadedFileInterface) {
throw new InvalidArgumentException('Invalid entry in uploaded files structure');
}
}
}
|
php
|
private function validateUploadedFiles(array $uploadedFiles)
{
foreach ($uploadedFiles as $file) {
if (is_array($file)) {
$this->validateUploadedFiles($file);
} elseif (!$file instanceof UploadedFileInterface) {
throw new InvalidArgumentException('Invalid entry in uploaded files structure');
}
}
}
|
[
"private",
"function",
"validateUploadedFiles",
"(",
"array",
"$",
"uploadedFiles",
")",
"{",
"foreach",
"(",
"$",
"uploadedFiles",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"validateUploadedFiles",
"(",
"$",
"file",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"file",
"instanceof",
"UploadedFileInterface",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid entry in uploaded files structure'",
")",
";",
"}",
"}",
"}"
] |
Validate the structure in an uploaded files array.
@param array $uploadedFiles
@throws InvalidArgumentException if any entry is not an UploadedFileInterface instance.
|
[
"Validate",
"the",
"structure",
"in",
"an",
"uploaded",
"files",
"array",
"."
] |
38877b9d895f279fdd5bdf957d8f23f9808a940a
|
https://github.com/kambo-1st/HttpMessage/blob/38877b9d895f279fdd5bdf957d8f23f9808a940a/src/ServerRequest.php#L491-L500
|
235,757
|
Niirrty/Niirrty.Locale
|
src/Locale.php
|
Locale.Create
|
public static function Create(
Locale $fallbackLocale, bool $useUrlPath = true, array $acceptedRequestParams = [ 'locale', 'language', 'lang' ] )
: Locale
{
if ( $useUrlPath && static::TryParseUrlPath( $refLocale ) )
{
return $refLocale;
}
if ( Locale::TryParseBrowserInfo( $refLocale ) )
{
return $refLocale;
}
if ( Locale::TryParseSystem( $refLocale ) )
{
return $refLocale;
}
if ( \count( $acceptedRequestParams ) > 0 )
{
if ( Locale::TryParseArray( $refLocale, $_POST, $acceptedRequestParams ) )
{
return $refLocale;
}
if ( Locale::TryParseArray( $refLocale, $_GET, $acceptedRequestParams ) )
{
return $refLocale;
}
/** @noinspection UnSafeIsSetOverArrayInspection */
if ( isset( $_SESSION ) && Locale::TryParseArray( $refLocale, $_SESSION, $acceptedRequestParams ) )
{
return $refLocale;
}
}
return $fallbackLocale;
}
|
php
|
public static function Create(
Locale $fallbackLocale, bool $useUrlPath = true, array $acceptedRequestParams = [ 'locale', 'language', 'lang' ] )
: Locale
{
if ( $useUrlPath && static::TryParseUrlPath( $refLocale ) )
{
return $refLocale;
}
if ( Locale::TryParseBrowserInfo( $refLocale ) )
{
return $refLocale;
}
if ( Locale::TryParseSystem( $refLocale ) )
{
return $refLocale;
}
if ( \count( $acceptedRequestParams ) > 0 )
{
if ( Locale::TryParseArray( $refLocale, $_POST, $acceptedRequestParams ) )
{
return $refLocale;
}
if ( Locale::TryParseArray( $refLocale, $_GET, $acceptedRequestParams ) )
{
return $refLocale;
}
/** @noinspection UnSafeIsSetOverArrayInspection */
if ( isset( $_SESSION ) && Locale::TryParseArray( $refLocale, $_SESSION, $acceptedRequestParams ) )
{
return $refLocale;
}
}
return $fallbackLocale;
}
|
[
"public",
"static",
"function",
"Create",
"(",
"Locale",
"$",
"fallbackLocale",
",",
"bool",
"$",
"useUrlPath",
"=",
"true",
",",
"array",
"$",
"acceptedRequestParams",
"=",
"[",
"'locale'",
",",
"'language'",
",",
"'lang'",
"]",
")",
":",
"Locale",
"{",
"if",
"(",
"$",
"useUrlPath",
"&&",
"static",
"::",
"TryParseUrlPath",
"(",
"$",
"refLocale",
")",
")",
"{",
"return",
"$",
"refLocale",
";",
"}",
"if",
"(",
"Locale",
"::",
"TryParseBrowserInfo",
"(",
"$",
"refLocale",
")",
")",
"{",
"return",
"$",
"refLocale",
";",
"}",
"if",
"(",
"Locale",
"::",
"TryParseSystem",
"(",
"$",
"refLocale",
")",
")",
"{",
"return",
"$",
"refLocale",
";",
"}",
"if",
"(",
"\\",
"count",
"(",
"$",
"acceptedRequestParams",
")",
">",
"0",
")",
"{",
"if",
"(",
"Locale",
"::",
"TryParseArray",
"(",
"$",
"refLocale",
",",
"$",
"_POST",
",",
"$",
"acceptedRequestParams",
")",
")",
"{",
"return",
"$",
"refLocale",
";",
"}",
"if",
"(",
"Locale",
"::",
"TryParseArray",
"(",
"$",
"refLocale",
",",
"$",
"_GET",
",",
"$",
"acceptedRequestParams",
")",
")",
"{",
"return",
"$",
"refLocale",
";",
"}",
"/** @noinspection UnSafeIsSetOverArrayInspection */",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
")",
"&&",
"Locale",
"::",
"TryParseArray",
"(",
"$",
"refLocale",
",",
"$",
"_SESSION",
",",
"$",
"acceptedRequestParams",
")",
")",
"{",
"return",
"$",
"refLocale",
";",
"}",
"}",
"return",
"$",
"fallbackLocale",
";",
"}"
] |
Creates a locale with all available methods. If no method can create a Locale the defined fallback locale is used.
First a locale
@param \Niirrty\Locale\Locale $fallbackLocale
@param bool $useUrlPath
@param array $acceptedRequestParams
@return \Niirrty\Locale\Locale
|
[
"Creates",
"a",
"locale",
"with",
"all",
"available",
"methods",
".",
"If",
"no",
"method",
"can",
"create",
"a",
"Locale",
"the",
"defined",
"fallback",
"locale",
"is",
"used",
"."
] |
704ac3b56734c0bbbe8e3b2e2f038242495704ab
|
https://github.com/Niirrty/Niirrty.Locale/blob/704ac3b56734c0bbbe8e3b2e2f038242495704ab/src/Locale.php#L659-L702
|
235,758
|
jinraynor1/threading
|
src/Pcntl/ThreadQueue.php
|
ThreadQueue.cleanup
|
private function cleanup()
{
foreach ($this->threads as $i => $szal)
if (!$szal->isAlive()) {
$this->results[] = $this->threads[$i]->result;
unset($this->threads[$i]);
}
return count($this->threads);
}
|
php
|
private function cleanup()
{
foreach ($this->threads as $i => $szal)
if (!$szal->isAlive()) {
$this->results[] = $this->threads[$i]->result;
unset($this->threads[$i]);
}
return count($this->threads);
}
|
[
"private",
"function",
"cleanup",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"threads",
"as",
"$",
"i",
"=>",
"$",
"szal",
")",
"if",
"(",
"!",
"$",
"szal",
"->",
"isAlive",
"(",
")",
")",
"{",
"$",
"this",
"->",
"results",
"[",
"]",
"=",
"$",
"this",
"->",
"threads",
"[",
"$",
"i",
"]",
"->",
"result",
";",
"unset",
"(",
"$",
"this",
"->",
"threads",
"[",
"$",
"i",
"]",
")",
";",
"}",
"return",
"count",
"(",
"$",
"this",
"->",
"threads",
")",
";",
"}"
] |
Removes closed threads from queue
|
[
"Removes",
"closed",
"threads",
"from",
"queue"
] |
8b63c75fe4fcc2523d26f060a75af1694dd020d4
|
https://github.com/jinraynor1/threading/blob/8b63c75fe4fcc2523d26f060a75af1694dd020d4/src/Pcntl/ThreadQueue.php#L59-L67
|
235,759
|
jinraynor1/threading
|
src/Pcntl/ThreadQueue.php
|
ThreadQueue.tick
|
public function tick()
{
$this->cleanup();
if ((count($this->threads) < $this->queueSize) && count($this->jobs)) {
$this->threads[] = $szal = new Thread($this->callable, $this->message_length);
$szal->start(array_shift($this->jobs));
}
usleep(ThreadQueue::TICK_DELAY);
return $this->queueSize();
}
|
php
|
public function tick()
{
$this->cleanup();
if ((count($this->threads) < $this->queueSize) && count($this->jobs)) {
$this->threads[] = $szal = new Thread($this->callable, $this->message_length);
$szal->start(array_shift($this->jobs));
}
usleep(ThreadQueue::TICK_DELAY);
return $this->queueSize();
}
|
[
"public",
"function",
"tick",
"(",
")",
"{",
"$",
"this",
"->",
"cleanup",
"(",
")",
";",
"if",
"(",
"(",
"count",
"(",
"$",
"this",
"->",
"threads",
")",
"<",
"$",
"this",
"->",
"queueSize",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"jobs",
")",
")",
"{",
"$",
"this",
"->",
"threads",
"[",
"]",
"=",
"$",
"szal",
"=",
"new",
"Thread",
"(",
"$",
"this",
"->",
"callable",
",",
"$",
"this",
"->",
"message_length",
")",
";",
"$",
"szal",
"->",
"start",
"(",
"array_shift",
"(",
"$",
"this",
"->",
"jobs",
")",
")",
";",
"}",
"usleep",
"(",
"ThreadQueue",
"::",
"TICK_DELAY",
")",
";",
"return",
"$",
"this",
"->",
"queueSize",
"(",
")",
";",
"}"
] |
Starts new threads if needed
@return int queue size
|
[
"Starts",
"new",
"threads",
"if",
"needed"
] |
8b63c75fe4fcc2523d26f060a75af1694dd020d4
|
https://github.com/jinraynor1/threading/blob/8b63c75fe4fcc2523d26f060a75af1694dd020d4/src/Pcntl/ThreadQueue.php#L76-L87
|
235,760
|
vnejedly/database
|
src/Query/Param/MultiParam.php
|
MultiParam._transform
|
protected function _transform()
{
$index = 1;
foreach ($this->_values as $value) {
$paramName = "{$this->_name}_{$index}";
$this->_params[$paramName] = new Param($this->_type, $value);
$index++;
}
}
|
php
|
protected function _transform()
{
$index = 1;
foreach ($this->_values as $value) {
$paramName = "{$this->_name}_{$index}";
$this->_params[$paramName] = new Param($this->_type, $value);
$index++;
}
}
|
[
"protected",
"function",
"_transform",
"(",
")",
"{",
"$",
"index",
"=",
"1",
";",
"foreach",
"(",
"$",
"this",
"->",
"_values",
"as",
"$",
"value",
")",
"{",
"$",
"paramName",
"=",
"\"{$this->_name}_{$index}\"",
";",
"$",
"this",
"->",
"_params",
"[",
"$",
"paramName",
"]",
"=",
"new",
"Param",
"(",
"$",
"this",
"->",
"_type",
",",
"$",
"value",
")",
";",
"$",
"index",
"++",
";",
"}",
"}"
] |
Transforms values to new params
|
[
"Transforms",
"values",
"to",
"new",
"params"
] |
015daae19cd497de6fecf6b1eb14bc7f48287a92
|
https://github.com/vnejedly/database/blob/015daae19cd497de6fecf6b1eb14bc7f48287a92/src/Query/Param/MultiParam.php#L62-L70
|
235,761
|
anklimsk/cakephp-basic-functions
|
Lib/Utility/Language.php
|
Language.getCurrentUiLang
|
public function getCurrentUiLang($isTwoLetter = false) {
$uiLcid3 = Configure::read('Config.language');
if (empty($uiLcid3)) {
$uiLcid3 = 'eng';
}
$uiLcid3 = mb_strtolower($uiLcid3);
if (!$isTwoLetter) {
return $uiLcid3;
}
return $this->convertLangCode($uiLcid3, 'iso639-1');
}
|
php
|
public function getCurrentUiLang($isTwoLetter = false) {
$uiLcid3 = Configure::read('Config.language');
if (empty($uiLcid3)) {
$uiLcid3 = 'eng';
}
$uiLcid3 = mb_strtolower($uiLcid3);
if (!$isTwoLetter) {
return $uiLcid3;
}
return $this->convertLangCode($uiLcid3, 'iso639-1');
}
|
[
"public",
"function",
"getCurrentUiLang",
"(",
"$",
"isTwoLetter",
"=",
"false",
")",
"{",
"$",
"uiLcid3",
"=",
"Configure",
"::",
"read",
"(",
"'Config.language'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"uiLcid3",
")",
")",
"{",
"$",
"uiLcid3",
"=",
"'eng'",
";",
"}",
"$",
"uiLcid3",
"=",
"mb_strtolower",
"(",
"$",
"uiLcid3",
")",
";",
"if",
"(",
"!",
"$",
"isTwoLetter",
")",
"{",
"return",
"$",
"uiLcid3",
";",
"}",
"return",
"$",
"this",
"->",
"convertLangCode",
"(",
"$",
"uiLcid3",
",",
"'iso639-1'",
")",
";",
"}"
] |
Get current UI language in format `ISO 639-1` or `ISO 693-2`
@param bool $isTwoLetter Flag of using `ISO 639-1` if True.
Use `ISO 693-2` otherwise.
@return string Current UI language
|
[
"Get",
"current",
"UI",
"language",
"in",
"format",
"ISO",
"639",
"-",
"1",
"or",
"ISO",
"693",
"-",
"2"
] |
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
|
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Lib/Utility/Language.php#L60-L71
|
235,762
|
anklimsk/cakephp-basic-functions
|
Lib/Utility/Language.php
|
Language.convertLangCode
|
public function convertLangCode($langCode = null, $output = null) {
$result = '';
if (empty($langCode) || empty($output)) {
return $result;
}
$cachePath = 'lang_code_info_' . md5(serialize(func_get_args()));
$cached = Cache::read($cachePath, CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE);
if (!empty($cached)) {
return $cached;
}
$langCode = mb_strtolower($langCode);
$this->options->setOutput($output);
$result = (string)$this->converter->filter($langCode);
Cache::write($cachePath, $result, CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE);
return $result;
}
|
php
|
public function convertLangCode($langCode = null, $output = null) {
$result = '';
if (empty($langCode) || empty($output)) {
return $result;
}
$cachePath = 'lang_code_info_' . md5(serialize(func_get_args()));
$cached = Cache::read($cachePath, CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE);
if (!empty($cached)) {
return $cached;
}
$langCode = mb_strtolower($langCode);
$this->options->setOutput($output);
$result = (string)$this->converter->filter($langCode);
Cache::write($cachePath, $result, CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE);
return $result;
}
|
[
"public",
"function",
"convertLangCode",
"(",
"$",
"langCode",
"=",
"null",
",",
"$",
"output",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"empty",
"(",
"$",
"langCode",
")",
"||",
"empty",
"(",
"$",
"output",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"cachePath",
"=",
"'lang_code_info_'",
".",
"md5",
"(",
"serialize",
"(",
"func_get_args",
"(",
")",
")",
")",
";",
"$",
"cached",
"=",
"Cache",
"::",
"read",
"(",
"$",
"cachePath",
",",
"CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"cached",
")",
")",
"{",
"return",
"$",
"cached",
";",
"}",
"$",
"langCode",
"=",
"mb_strtolower",
"(",
"$",
"langCode",
")",
";",
"$",
"this",
"->",
"options",
"->",
"setOutput",
"(",
"$",
"output",
")",
";",
"$",
"result",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"converter",
"->",
"filter",
"(",
"$",
"langCode",
")",
";",
"Cache",
"::",
"write",
"(",
"$",
"cachePath",
",",
"$",
"result",
",",
"CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Convert language from format `ISO 693-2` to `ISO 639-1`
@param string $langCode Languge code for converting
@param string $output Output format:
- name: The international (often english) name of the language;
- native: The language name written in native representation/s;
- iso639-1: The ISO 639-1 (two-letters code) language representation;
- iso639-2/t: The ISO 639-2/T (three-letters code for terminology applications) language representation;
- iso639-2/b: The ISO 639-2/B (three-letters code, for bibliographic applications) language representation;
- iso639-3: The ISO 639-3 (same as ISO 639-2/T except that for the macrolanguages) language representation.
@return string Language code in format `ISO 639-1`,
or empty string on failure.
@link https://github.com/leodido/langcode-conv Language Codes Converter
|
[
"Convert",
"language",
"from",
"format",
"ISO",
"693",
"-",
"2",
"to",
"ISO",
"639",
"-",
"1"
] |
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
|
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Lib/Utility/Language.php#L88-L106
|
235,763
|
anklimsk/cakephp-basic-functions
|
Lib/Utility/Language.php
|
Language.getLangForNumberText
|
public function getLangForNumberText($langCode = null) {
$cachePath = 'lang_code_number_name_' . md5(serialize(func_get_args()));
$cached = Cache::read($cachePath, CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE);
if (!empty($cached)) {
return $cached;
}
if (!empty($langCode)) {
$langUI = $this->convertLangCode($langCode, 'iso639-1');
} else {
$langUI = $this->getCurrentUiLang(true);
}
$result = 'en_US';
$locales = [
'af' => 'af_ZA',
'ca' => 'ca_ES',
'cs' => 'cs_CZ',
'da' => 'da_DK',
'de' => 'de_DE',
'el' => 'el_EL',
'en' => 'en_US',
'es' => 'es_ES',
'fi' => 'fi_FI',
'fr' => 'fr_FR',
'he' => 'he_IL',
'hu' => 'hu_HU',
'id' => 'id_ID',
'it' => 'it_IT',
'ja' => 'ja_JP',
'ko' => 'ko_KR',
'lb' => 'lb_LU',
'lt' => 'lt_LT',
'lv' => 'lv_LV',
'nl' => 'nl_NL',
'pl' => 'pl_PL',
'pt' => 'pt_PT',
'ro' => 'ro_RO',
'ru' => 'ru_RU',
'sh' => 'sh_RS',
'sl' => 'sl_SI',
'sr' => 'sr_RS',
'sv' => 'sv_SE',
'th' => 'th_TH',
'tr' => 'tr_TR',
'vi' => 'vi_VN',
'zh' => 'zh_ZH',
];
if (isset($locales[$langUI])) {
$result = $locales[$langUI];
}
Cache::write($cachePath, $result, CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE);
return $result;
}
|
php
|
public function getLangForNumberText($langCode = null) {
$cachePath = 'lang_code_number_name_' . md5(serialize(func_get_args()));
$cached = Cache::read($cachePath, CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE);
if (!empty($cached)) {
return $cached;
}
if (!empty($langCode)) {
$langUI = $this->convertLangCode($langCode, 'iso639-1');
} else {
$langUI = $this->getCurrentUiLang(true);
}
$result = 'en_US';
$locales = [
'af' => 'af_ZA',
'ca' => 'ca_ES',
'cs' => 'cs_CZ',
'da' => 'da_DK',
'de' => 'de_DE',
'el' => 'el_EL',
'en' => 'en_US',
'es' => 'es_ES',
'fi' => 'fi_FI',
'fr' => 'fr_FR',
'he' => 'he_IL',
'hu' => 'hu_HU',
'id' => 'id_ID',
'it' => 'it_IT',
'ja' => 'ja_JP',
'ko' => 'ko_KR',
'lb' => 'lb_LU',
'lt' => 'lt_LT',
'lv' => 'lv_LV',
'nl' => 'nl_NL',
'pl' => 'pl_PL',
'pt' => 'pt_PT',
'ro' => 'ro_RO',
'ru' => 'ru_RU',
'sh' => 'sh_RS',
'sl' => 'sl_SI',
'sr' => 'sr_RS',
'sv' => 'sv_SE',
'th' => 'th_TH',
'tr' => 'tr_TR',
'vi' => 'vi_VN',
'zh' => 'zh_ZH',
];
if (isset($locales[$langUI])) {
$result = $locales[$langUI];
}
Cache::write($cachePath, $result, CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE);
return $result;
}
|
[
"public",
"function",
"getLangForNumberText",
"(",
"$",
"langCode",
"=",
"null",
")",
"{",
"$",
"cachePath",
"=",
"'lang_code_number_name_'",
".",
"md5",
"(",
"serialize",
"(",
"func_get_args",
"(",
")",
")",
")",
";",
"$",
"cached",
"=",
"Cache",
"::",
"read",
"(",
"$",
"cachePath",
",",
"CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"cached",
")",
")",
"{",
"return",
"$",
"cached",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"langCode",
")",
")",
"{",
"$",
"langUI",
"=",
"$",
"this",
"->",
"convertLangCode",
"(",
"$",
"langCode",
",",
"'iso639-1'",
")",
";",
"}",
"else",
"{",
"$",
"langUI",
"=",
"$",
"this",
"->",
"getCurrentUiLang",
"(",
"true",
")",
";",
"}",
"$",
"result",
"=",
"'en_US'",
";",
"$",
"locales",
"=",
"[",
"'af'",
"=>",
"'af_ZA'",
",",
"'ca'",
"=>",
"'ca_ES'",
",",
"'cs'",
"=>",
"'cs_CZ'",
",",
"'da'",
"=>",
"'da_DK'",
",",
"'de'",
"=>",
"'de_DE'",
",",
"'el'",
"=>",
"'el_EL'",
",",
"'en'",
"=>",
"'en_US'",
",",
"'es'",
"=>",
"'es_ES'",
",",
"'fi'",
"=>",
"'fi_FI'",
",",
"'fr'",
"=>",
"'fr_FR'",
",",
"'he'",
"=>",
"'he_IL'",
",",
"'hu'",
"=>",
"'hu_HU'",
",",
"'id'",
"=>",
"'id_ID'",
",",
"'it'",
"=>",
"'it_IT'",
",",
"'ja'",
"=>",
"'ja_JP'",
",",
"'ko'",
"=>",
"'ko_KR'",
",",
"'lb'",
"=>",
"'lb_LU'",
",",
"'lt'",
"=>",
"'lt_LT'",
",",
"'lv'",
"=>",
"'lv_LV'",
",",
"'nl'",
"=>",
"'nl_NL'",
",",
"'pl'",
"=>",
"'pl_PL'",
",",
"'pt'",
"=>",
"'pt_PT'",
",",
"'ro'",
"=>",
"'ro_RO'",
",",
"'ru'",
"=>",
"'ru_RU'",
",",
"'sh'",
"=>",
"'sh_RS'",
",",
"'sl'",
"=>",
"'sl_SI'",
",",
"'sr'",
"=>",
"'sr_RS'",
",",
"'sv'",
"=>",
"'sv_SE'",
",",
"'th'",
"=>",
"'th_TH'",
",",
"'tr'",
"=>",
"'tr_TR'",
",",
"'vi'",
"=>",
"'vi_VN'",
",",
"'zh'",
"=>",
"'zh_ZH'",
",",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"locales",
"[",
"$",
"langUI",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"locales",
"[",
"$",
"langUI",
"]",
";",
"}",
"Cache",
"::",
"write",
"(",
"$",
"cachePath",
",",
"$",
"result",
",",
"CAKE_BASIC_FUNC_CACHE_KEY_LANG_CODE",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Return current UI language name for library Tools.NumberTextLib in format RFC5646.
@param string $langCode Languge code in format `ISO 639-1` or `ISO 639-2`
@return string Return language name in format RFC5646.
@link http://numbertext.org/ Universal number to text conversion languag
|
[
"Return",
"current",
"UI",
"language",
"name",
"for",
"library",
"Tools",
".",
"NumberTextLib",
"in",
"format",
"RFC5646",
"."
] |
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
|
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Lib/Utility/Language.php#L115-L170
|
235,764
|
zicht/goggle
|
src/Zicht/ConfigTool/Writer/Impl/AbstractTextWriter.php
|
AbstractTextWriter.toScalarTable
|
public static function toScalarTable($list)
{
return iter\iterable($list)
->map(
function ($record) {
return self::toScalarValues($record);
}
);
}
|
php
|
public static function toScalarTable($list)
{
return iter\iterable($list)
->map(
function ($record) {
return self::toScalarValues($record);
}
);
}
|
[
"public",
"static",
"function",
"toScalarTable",
"(",
"$",
"list",
")",
"{",
"return",
"iter",
"\\",
"iterable",
"(",
"$",
"list",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"record",
")",
"{",
"return",
"self",
"::",
"toScalarValues",
"(",
"$",
"record",
")",
";",
"}",
")",
";",
"}"
] |
Helper to convert a n-dimensional array with n > 2 to all scalar values
@param mixed[][] $list
@return string[][]
|
[
"Helper",
"to",
"convert",
"a",
"n",
"-",
"dimensional",
"array",
"with",
"n",
">",
"2",
"to",
"all",
"scalar",
"values"
] |
f3b42bda9d3821ef2d387aef1091cba8afe2cff2
|
https://github.com/zicht/goggle/blob/f3b42bda9d3821ef2d387aef1091cba8afe2cff2/src/Zicht/ConfigTool/Writer/Impl/AbstractTextWriter.php#L45-L53
|
235,765
|
razielsd/webdriverlib
|
WebDriver/WebDriver.php
|
WebDriver.forward
|
public function forward()
{
$this->getDriver()->curl($this->getDriver()->factoryCommand('forward', WebDriver_Command::METHOD_POST));
return $this;
}
|
php
|
public function forward()
{
$this->getDriver()->curl($this->getDriver()->factoryCommand('forward', WebDriver_Command::METHOD_POST));
return $this;
}
|
[
"public",
"function",
"forward",
"(",
")",
"{",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"curl",
"(",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"factoryCommand",
"(",
"'forward'",
",",
"WebDriver_Command",
"::",
"METHOD_POST",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Navigate forwards in the browser history, if possible.
|
[
"Navigate",
"forwards",
"in",
"the",
"browser",
"history",
"if",
"possible",
"."
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver.php#L310-L314
|
235,766
|
razielsd/webdriverlib
|
WebDriver/WebDriver.php
|
WebDriver.back
|
public function back()
{
$this->getDriver()->curl($this->getDriver()->factoryCommand('back', WebDriver_Command::METHOD_POST));
return $this;
}
|
php
|
public function back()
{
$this->getDriver()->curl($this->getDriver()->factoryCommand('back', WebDriver_Command::METHOD_POST));
return $this;
}
|
[
"public",
"function",
"back",
"(",
")",
"{",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"curl",
"(",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"factoryCommand",
"(",
"'back'",
",",
"WebDriver_Command",
"::",
"METHOD_POST",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Navigate backwards in the browser history, if possible.
|
[
"Navigate",
"backwards",
"in",
"the",
"browser",
"history",
"if",
"possible",
"."
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver.php#L320-L324
|
235,767
|
razielsd/webdriverlib
|
WebDriver/WebDriver.php
|
WebDriver.refresh
|
public function refresh()
{
$this->getDriver()->curl($this->getDriver()->factoryCommand('refresh', WebDriver_Command::METHOD_POST));
return $this;
}
|
php
|
public function refresh()
{
$this->getDriver()->curl($this->getDriver()->factoryCommand('refresh', WebDriver_Command::METHOD_POST));
return $this;
}
|
[
"public",
"function",
"refresh",
"(",
")",
"{",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"curl",
"(",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"factoryCommand",
"(",
"'refresh'",
",",
"WebDriver_Command",
"::",
"METHOD_POST",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Refresh the current page.
|
[
"Refresh",
"the",
"current",
"page",
"."
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver.php#L330-L334
|
235,768
|
razielsd/webdriverlib
|
WebDriver/WebDriver.php
|
WebDriver.execute
|
public function execute($js, $args = [])
{
$params = ['script' => $js, 'args' => $args];
$result = $this->getDriver()->curl(
$this->getDriver()->factoryCommand('execute', WebDriver_Command::METHOD_POST, $params)
);
return isset($result['value'])?$result['value']:false;
}
|
php
|
public function execute($js, $args = [])
{
$params = ['script' => $js, 'args' => $args];
$result = $this->getDriver()->curl(
$this->getDriver()->factoryCommand('execute', WebDriver_Command::METHOD_POST, $params)
);
return isset($result['value'])?$result['value']:false;
}
|
[
"public",
"function",
"execute",
"(",
"$",
"js",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"[",
"'script'",
"=>",
"$",
"js",
",",
"'args'",
"=>",
"$",
"args",
"]",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"curl",
"(",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"factoryCommand",
"(",
"'execute'",
",",
"WebDriver_Command",
"::",
"METHOD_POST",
",",
"$",
"params",
")",
")",
";",
"return",
"isset",
"(",
"$",
"result",
"[",
"'value'",
"]",
")",
"?",
"$",
"result",
"[",
"'value'",
"]",
":",
"false",
";",
"}"
] |
Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame
@param string $js
@param array $args
@return mixed
|
[
"Inject",
"a",
"snippet",
"of",
"JavaScript",
"into",
"the",
"page",
"for",
"execution",
"in",
"the",
"context",
"of",
"the",
"currently",
"selected",
"frame"
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver.php#L344-L351
|
235,769
|
razielsd/webdriverlib
|
WebDriver/WebDriver.php
|
WebDriver.screenshotAsImage
|
public function screenshotAsImage($asBase64 = false)
{
$image = $this->getDriver()->curl(
$this->getDriver()->factoryCommand('screenshot', WebDriver_Command::METHOD_GET)
);
$image = $image['value'];
if (!$asBase64) {
$image = base64_decode($image);
}
return $image;
}
|
php
|
public function screenshotAsImage($asBase64 = false)
{
$image = $this->getDriver()->curl(
$this->getDriver()->factoryCommand('screenshot', WebDriver_Command::METHOD_GET)
);
$image = $image['value'];
if (!$asBase64) {
$image = base64_decode($image);
}
return $image;
}
|
[
"public",
"function",
"screenshotAsImage",
"(",
"$",
"asBase64",
"=",
"false",
")",
"{",
"$",
"image",
"=",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"curl",
"(",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"factoryCommand",
"(",
"'screenshot'",
",",
"WebDriver_Command",
"::",
"METHOD_GET",
")",
")",
";",
"$",
"image",
"=",
"$",
"image",
"[",
"'value'",
"]",
";",
"if",
"(",
"!",
"$",
"asBase64",
")",
"{",
"$",
"image",
"=",
"base64_decode",
"(",
"$",
"image",
")",
";",
"}",
"return",
"$",
"image",
";",
"}"
] |
Returns screenshot of current page as binary string.
@param bool $asBase64 - return base64 data, "as is" from server
@return string;
|
[
"Returns",
"screenshot",
"of",
"current",
"page",
"as",
"binary",
"string",
"."
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver.php#L384-L394
|
235,770
|
razielsd/webdriverlib
|
WebDriver/WebDriver.php
|
WebDriver.findAll
|
public function findAll($locator, $parent = null)
{
$commandUri = empty($parent) ? "elements" : "element/{$parent->getElementId()}/elements";
$command = $this->getDriver()->factoryCommand(
$commandUri,
WebDriver_Command::METHOD_POST,
WebDriver_Util::parseLocator($locator)
);
try {
$elementList = $this->getDriver()->curl($command);
} catch (WebDriver_Exception $e) {
$parentText = empty($parent) ? '' : " (parent: {$parent->getLocator()})";
throw new WebDriver_Exception("Elements not found: {$locator}{$parentText} with error: {$e->getMessage()}");
}
$result = [];
foreach ($elementList['value'] as $value) {
$elementClass = $this->elementClass;
$result[] = new $elementClass($this, $locator, $parent, $value['ELEMENT']);
}
return $result;
}
|
php
|
public function findAll($locator, $parent = null)
{
$commandUri = empty($parent) ? "elements" : "element/{$parent->getElementId()}/elements";
$command = $this->getDriver()->factoryCommand(
$commandUri,
WebDriver_Command::METHOD_POST,
WebDriver_Util::parseLocator($locator)
);
try {
$elementList = $this->getDriver()->curl($command);
} catch (WebDriver_Exception $e) {
$parentText = empty($parent) ? '' : " (parent: {$parent->getLocator()})";
throw new WebDriver_Exception("Elements not found: {$locator}{$parentText} with error: {$e->getMessage()}");
}
$result = [];
foreach ($elementList['value'] as $value) {
$elementClass = $this->elementClass;
$result[] = new $elementClass($this, $locator, $parent, $value['ELEMENT']);
}
return $result;
}
|
[
"public",
"function",
"findAll",
"(",
"$",
"locator",
",",
"$",
"parent",
"=",
"null",
")",
"{",
"$",
"commandUri",
"=",
"empty",
"(",
"$",
"parent",
")",
"?",
"\"elements\"",
":",
"\"element/{$parent->getElementId()}/elements\"",
";",
"$",
"command",
"=",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"factoryCommand",
"(",
"$",
"commandUri",
",",
"WebDriver_Command",
"::",
"METHOD_POST",
",",
"WebDriver_Util",
"::",
"parseLocator",
"(",
"$",
"locator",
")",
")",
";",
"try",
"{",
"$",
"elementList",
"=",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"curl",
"(",
"$",
"command",
")",
";",
"}",
"catch",
"(",
"WebDriver_Exception",
"$",
"e",
")",
"{",
"$",
"parentText",
"=",
"empty",
"(",
"$",
"parent",
")",
"?",
"''",
":",
"\" (parent: {$parent->getLocator()})\"",
";",
"throw",
"new",
"WebDriver_Exception",
"(",
"\"Elements not found: {$locator}{$parentText} with error: {$e->getMessage()}\"",
")",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"elementList",
"[",
"'value'",
"]",
"as",
"$",
"value",
")",
"{",
"$",
"elementClass",
"=",
"$",
"this",
"->",
"elementClass",
";",
"$",
"result",
"[",
"]",
"=",
"new",
"$",
"elementClass",
"(",
"$",
"this",
",",
"$",
"locator",
",",
"$",
"parent",
",",
"$",
"value",
"[",
"'ELEMENT'",
"]",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Search for multiple elements on the page
@param $locator
@param WebDriver_Element $parent
@throws WebDriver_Exception
@return WebDriver_Element[]
|
[
"Search",
"for",
"multiple",
"elements",
"on",
"the",
"page"
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver.php#L420-L440
|
235,771
|
razielsd/webdriverlib
|
WebDriver/WebDriver.php
|
WebDriver.keys
|
public function keys($charList)
{
$this->getDriver()->curl(
$this->getDriver()->factoryCommand(
'keys',
WebDriver_Command::METHOD_POST,
['value' => WebDriver_Util::prepareKeyStrokes($charList)]
)
);
return $this;
}
|
php
|
public function keys($charList)
{
$this->getDriver()->curl(
$this->getDriver()->factoryCommand(
'keys',
WebDriver_Command::METHOD_POST,
['value' => WebDriver_Util::prepareKeyStrokes($charList)]
)
);
return $this;
}
|
[
"public",
"function",
"keys",
"(",
"$",
"charList",
")",
"{",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"curl",
"(",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"factoryCommand",
"(",
"'keys'",
",",
"WebDriver_Command",
"::",
"METHOD_POST",
",",
"[",
"'value'",
"=>",
"WebDriver_Util",
"::",
"prepareKeyStrokes",
"(",
"$",
"charList",
")",
"]",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sends keystroke sequence. Active modifiers are not cancelled after call, which lets to use them
with mouse events.
@param array|int|string $charList
@return $this
@throws WebDriver_Exception
|
[
"Sends",
"keystroke",
"sequence",
".",
"Active",
"modifiers",
"are",
"not",
"cancelled",
"after",
"call",
"which",
"lets",
"to",
"use",
"them",
"with",
"mouse",
"events",
"."
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver.php#L480-L490
|
235,772
|
razielsd/webdriverlib
|
WebDriver/WebDriver.php
|
WebDriver.source
|
public function source()
{
$command = $this->getDriver()->factoryCommand('source', WebDriver_Command::METHOD_GET);
$result = $this->getDriver()->curl($command);
return $result['value'];
}
|
php
|
public function source()
{
$command = $this->getDriver()->factoryCommand('source', WebDriver_Command::METHOD_GET);
$result = $this->getDriver()->curl($command);
return $result['value'];
}
|
[
"public",
"function",
"source",
"(",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"factoryCommand",
"(",
"'source'",
",",
"WebDriver_Command",
"::",
"METHOD_GET",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"curl",
"(",
"$",
"command",
")",
";",
"return",
"$",
"result",
"[",
"'value'",
"]",
";",
"}"
] |
Get the current page source.
@return string
|
[
"Get",
"the",
"current",
"page",
"source",
"."
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver.php#L507-L512
|
235,773
|
razielsd/webdriverlib
|
WebDriver/WebDriver.php
|
WebDriver.cache
|
public function cache()
{
if (null === $this->cache) {
$this->cache = new WebDriver_Cache($this);
}
return $this->cache;
}
|
php
|
public function cache()
{
if (null === $this->cache) {
$this->cache = new WebDriver_Cache($this);
}
return $this->cache;
}
|
[
"public",
"function",
"cache",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"cache",
")",
"{",
"$",
"this",
"->",
"cache",
"=",
"new",
"WebDriver_Cache",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
";",
"}"
] |
Get current context.
@return WebDriver_Cache
|
[
"Get",
"current",
"context",
"."
] |
e498afc36a8cdeab5b6ca95016420557baf32f36
|
https://github.com/razielsd/webdriverlib/blob/e498afc36a8cdeab5b6ca95016420557baf32f36/WebDriver/WebDriver.php#L533-L539
|
235,774
|
in2pire/in2pire-utility
|
NestedArray.php
|
NestedArray.mergeDeepArray
|
public static function mergeDeepArray(array $arrays, $preserve_integer_keys = false)
{
$result = [];
foreach ($arrays as $array) {
foreach ($array as $key => $value) {
if (is_integer($key) && !$preserve_integer_keys) {
// Renumber integer keys as array_merge_recursive() does unless
// $preserve_integer_keys is set to true. Note that PHP automatically
// converts array keys that are integer strings (e.g., '1') to integers.
$result[] = $value;
} elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value)) {
// Recurse when both values are arrays.
$result[$key] = self::mergeDeepArray(array($result[$key], $value), $preserve_integer_keys);
} else {
// Otherwise, use the latter value, overriding any previous value.
$result[$key] = $value;
}
}
}
return $result;
}
|
php
|
public static function mergeDeepArray(array $arrays, $preserve_integer_keys = false)
{
$result = [];
foreach ($arrays as $array) {
foreach ($array as $key => $value) {
if (is_integer($key) && !$preserve_integer_keys) {
// Renumber integer keys as array_merge_recursive() does unless
// $preserve_integer_keys is set to true. Note that PHP automatically
// converts array keys that are integer strings (e.g., '1') to integers.
$result[] = $value;
} elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value)) {
// Recurse when both values are arrays.
$result[$key] = self::mergeDeepArray(array($result[$key], $value), $preserve_integer_keys);
} else {
// Otherwise, use the latter value, overriding any previous value.
$result[$key] = $value;
}
}
}
return $result;
}
|
[
"public",
"static",
"function",
"mergeDeepArray",
"(",
"array",
"$",
"arrays",
",",
"$",
"preserve_integer_keys",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"arrays",
"as",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_integer",
"(",
"$",
"key",
")",
"&&",
"!",
"$",
"preserve_integer_keys",
")",
"{",
"// Renumber integer keys as array_merge_recursive() does unless",
"// $preserve_integer_keys is set to true. Note that PHP automatically",
"// converts array keys that are integer strings (e.g., '1') to integers.",
"$",
"result",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
")",
"&&",
"is_array",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
")",
"&&",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"// Recurse when both values are arrays.",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"self",
"::",
"mergeDeepArray",
"(",
"array",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
",",
"$",
"value",
")",
",",
"$",
"preserve_integer_keys",
")",
";",
"}",
"else",
"{",
"// Otherwise, use the latter value, overriding any previous value.",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Merges multiple arrays, recursively, and returns the merged array.
This function is equivalent to NestedArray::mergeDeep(), except the
input arrays are passed as a single array parameter rather than a variable
parameter list.
The following are equivalent:
- NestedArray::mergeDeep($a, $b);
- NestedArray::mergeDeepArray(array($a, $b));
The following are also equivalent:
- call_user_func_array('NestedArray::mergeDeep', $arrays_to_merge);
- NestedArray::mergeDeepArray($arrays_to_merge);
@param array $arrays
An arrays of arrays to merge.
@param bool $preserve_integer_keys
(optional) If given, integer keys will be preserved and merged instead of
appended. Defaults to false.
@return array
The merged array.
@see NestedArray::mergeDeep()
|
[
"Merges",
"multiple",
"arrays",
"recursively",
"and",
"returns",
"the",
"merged",
"array",
"."
] |
c16776e98ef45bd9733dd508ec07e38daf9b875f
|
https://github.com/in2pire/in2pire-utility/blob/c16776e98ef45bd9733dd508ec07e38daf9b875f/NestedArray.php#L353-L375
|
235,775
|
emaphp/eMapper
|
lib/eMapper/ORM/Dynamic/DynamicAttribute.php
|
DynamicAttribute.parseArguments
|
protected function parseArguments(AnnotationBag $propertyAnnotations) {
$this->args = [];
//parse additional arguments
$parameters = $propertyAnnotations->find('Param');
foreach ($parameters as $param) {
if ($param->hasArgument()) {
$arg = $param->getArgument();
if (strtolower($arg) == 'self')
$this->useDefaultArgument = true;
else
$this->args[] = Attr::__callstatic($arg);
}
else
$this->args[] = $param->getValue();
}
//use default argument if no arguments are specified
if (empty($this->args))
$this->useDefaultArgument = true;
}
|
php
|
protected function parseArguments(AnnotationBag $propertyAnnotations) {
$this->args = [];
//parse additional arguments
$parameters = $propertyAnnotations->find('Param');
foreach ($parameters as $param) {
if ($param->hasArgument()) {
$arg = $param->getArgument();
if (strtolower($arg) == 'self')
$this->useDefaultArgument = true;
else
$this->args[] = Attr::__callstatic($arg);
}
else
$this->args[] = $param->getValue();
}
//use default argument if no arguments are specified
if (empty($this->args))
$this->useDefaultArgument = true;
}
|
[
"protected",
"function",
"parseArguments",
"(",
"AnnotationBag",
"$",
"propertyAnnotations",
")",
"{",
"$",
"this",
"->",
"args",
"=",
"[",
"]",
";",
"//parse additional arguments",
"$",
"parameters",
"=",
"$",
"propertyAnnotations",
"->",
"find",
"(",
"'Param'",
")",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"$",
"param",
"->",
"hasArgument",
"(",
")",
")",
"{",
"$",
"arg",
"=",
"$",
"param",
"->",
"getArgument",
"(",
")",
";",
"if",
"(",
"strtolower",
"(",
"$",
"arg",
")",
"==",
"'self'",
")",
"$",
"this",
"->",
"useDefaultArgument",
"=",
"true",
";",
"else",
"$",
"this",
"->",
"args",
"[",
"]",
"=",
"Attr",
"::",
"__callstatic",
"(",
"$",
"arg",
")",
";",
"}",
"else",
"$",
"this",
"->",
"args",
"[",
"]",
"=",
"$",
"param",
"->",
"getValue",
"(",
")",
";",
"}",
"//use default argument if no arguments are specified",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"args",
")",
")",
"$",
"this",
"->",
"useDefaultArgument",
"=",
"true",
";",
"}"
] |
Parses attribute argument list
@param \Omocha\AnnotationBag $propertyAnnotations
|
[
"Parses",
"attribute",
"argument",
"list"
] |
df7100e601d2a1363d07028a786b6ceb22271829
|
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/ORM/Dynamic/DynamicAttribute.php#L82-L104
|
235,776
|
emaphp/eMapper
|
lib/eMapper/ORM/Dynamic/DynamicAttribute.php
|
DynamicAttribute.parseConfig
|
protected function parseConfig(AnnotationBag $propertyAnnotations) {
$this->config = [];
//mapping type expression
if (isset($this->type))
$this->config['map.type'] = $this->type;
//result map
if ($propertyAnnotations->has('ResultMap'))
$this->config['map.result'] = $propertyAnnotations->get('ResultMap')->getValue();
//cache
if ($propertyAnnotations->has('Cache')) {
$this->config['cache.ttl'] = intval($propertyAnnotations->get('Cache')->getArgument());
$this->config['cache.key'] = $propertyAnnotations->get('Cache')->getValue();
}
//custom options
$options = $propertyAnnotations->find('Option', Filter::HAS_ARGUMENT);
foreach ($options as $option)
$this->config[$option->getArgument()] = $option->getValue();
//cacheable
if ($propertyAnnotations->has('Cacheable')) {
//check type before assuming is cacheable
$this->cacheable = !empty($this->type) && !preg_match('/^[arr|array|obj|object]:/', $this->type);
}
//get evaluation condition
if ($propertyAnnotations->has('If')) {
$this->program = new DynamicSQLProgram($propertyAnnotations->get('If')->getValue());
$this->condition = function ($row, $config) {
return (bool) $this->program->execute($this->buildEnvironment($config), $row);
};
}
elseif ($propertyAnnotations->has('IfNot')) {
$this->program = new DynamicSQLProgram($propertyAnnotations->get('IfNot')->getValue());
$this->condition = function ($row, $config) {
return !(bool) $this->program->execute($this->buildEnvironment($config), $row);
};
}
elseif ($propertyAnnotations->has('IfNotNull')) {
$attribute = $propertyAnnotations->get('IfNotNull')->getArgument();
$this->condition = function($row, $_) use ($attribute) {
$argument = ArgumentWrapper::wrap($row);
return !($argument->offsetExists($attribute) && $argument->offsetGet($attribute) === null);
};
}
}
|
php
|
protected function parseConfig(AnnotationBag $propertyAnnotations) {
$this->config = [];
//mapping type expression
if (isset($this->type))
$this->config['map.type'] = $this->type;
//result map
if ($propertyAnnotations->has('ResultMap'))
$this->config['map.result'] = $propertyAnnotations->get('ResultMap')->getValue();
//cache
if ($propertyAnnotations->has('Cache')) {
$this->config['cache.ttl'] = intval($propertyAnnotations->get('Cache')->getArgument());
$this->config['cache.key'] = $propertyAnnotations->get('Cache')->getValue();
}
//custom options
$options = $propertyAnnotations->find('Option', Filter::HAS_ARGUMENT);
foreach ($options as $option)
$this->config[$option->getArgument()] = $option->getValue();
//cacheable
if ($propertyAnnotations->has('Cacheable')) {
//check type before assuming is cacheable
$this->cacheable = !empty($this->type) && !preg_match('/^[arr|array|obj|object]:/', $this->type);
}
//get evaluation condition
if ($propertyAnnotations->has('If')) {
$this->program = new DynamicSQLProgram($propertyAnnotations->get('If')->getValue());
$this->condition = function ($row, $config) {
return (bool) $this->program->execute($this->buildEnvironment($config), $row);
};
}
elseif ($propertyAnnotations->has('IfNot')) {
$this->program = new DynamicSQLProgram($propertyAnnotations->get('IfNot')->getValue());
$this->condition = function ($row, $config) {
return !(bool) $this->program->execute($this->buildEnvironment($config), $row);
};
}
elseif ($propertyAnnotations->has('IfNotNull')) {
$attribute = $propertyAnnotations->get('IfNotNull')->getArgument();
$this->condition = function($row, $_) use ($attribute) {
$argument = ArgumentWrapper::wrap($row);
return !($argument->offsetExists($attribute) && $argument->offsetGet($attribute) === null);
};
}
}
|
[
"protected",
"function",
"parseConfig",
"(",
"AnnotationBag",
"$",
"propertyAnnotations",
")",
"{",
"$",
"this",
"->",
"config",
"=",
"[",
"]",
";",
"//mapping type expression",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"type",
")",
")",
"$",
"this",
"->",
"config",
"[",
"'map.type'",
"]",
"=",
"$",
"this",
"->",
"type",
";",
"//result map",
"if",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'ResultMap'",
")",
")",
"$",
"this",
"->",
"config",
"[",
"'map.result'",
"]",
"=",
"$",
"propertyAnnotations",
"->",
"get",
"(",
"'ResultMap'",
")",
"->",
"getValue",
"(",
")",
";",
"//cache",
"if",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'Cache'",
")",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'cache.ttl'",
"]",
"=",
"intval",
"(",
"$",
"propertyAnnotations",
"->",
"get",
"(",
"'Cache'",
")",
"->",
"getArgument",
"(",
")",
")",
";",
"$",
"this",
"->",
"config",
"[",
"'cache.key'",
"]",
"=",
"$",
"propertyAnnotations",
"->",
"get",
"(",
"'Cache'",
")",
"->",
"getValue",
"(",
")",
";",
"}",
"//custom options",
"$",
"options",
"=",
"$",
"propertyAnnotations",
"->",
"find",
"(",
"'Option'",
",",
"Filter",
"::",
"HAS_ARGUMENT",
")",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"option",
")",
"$",
"this",
"->",
"config",
"[",
"$",
"option",
"->",
"getArgument",
"(",
")",
"]",
"=",
"$",
"option",
"->",
"getValue",
"(",
")",
";",
"//cacheable",
"if",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'Cacheable'",
")",
")",
"{",
"//check type before assuming is cacheable",
"$",
"this",
"->",
"cacheable",
"=",
"!",
"empty",
"(",
"$",
"this",
"->",
"type",
")",
"&&",
"!",
"preg_match",
"(",
"'/^[arr|array|obj|object]:/'",
",",
"$",
"this",
"->",
"type",
")",
";",
"}",
"//get evaluation condition",
"if",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'If'",
")",
")",
"{",
"$",
"this",
"->",
"program",
"=",
"new",
"DynamicSQLProgram",
"(",
"$",
"propertyAnnotations",
"->",
"get",
"(",
"'If'",
")",
"->",
"getValue",
"(",
")",
")",
";",
"$",
"this",
"->",
"condition",
"=",
"function",
"(",
"$",
"row",
",",
"$",
"config",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"program",
"->",
"execute",
"(",
"$",
"this",
"->",
"buildEnvironment",
"(",
"$",
"config",
")",
",",
"$",
"row",
")",
";",
"}",
";",
"}",
"elseif",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'IfNot'",
")",
")",
"{",
"$",
"this",
"->",
"program",
"=",
"new",
"DynamicSQLProgram",
"(",
"$",
"propertyAnnotations",
"->",
"get",
"(",
"'IfNot'",
")",
"->",
"getValue",
"(",
")",
")",
";",
"$",
"this",
"->",
"condition",
"=",
"function",
"(",
"$",
"row",
",",
"$",
"config",
")",
"{",
"return",
"!",
"(",
"bool",
")",
"$",
"this",
"->",
"program",
"->",
"execute",
"(",
"$",
"this",
"->",
"buildEnvironment",
"(",
"$",
"config",
")",
",",
"$",
"row",
")",
";",
"}",
";",
"}",
"elseif",
"(",
"$",
"propertyAnnotations",
"->",
"has",
"(",
"'IfNotNull'",
")",
")",
"{",
"$",
"attribute",
"=",
"$",
"propertyAnnotations",
"->",
"get",
"(",
"'IfNotNull'",
")",
"->",
"getArgument",
"(",
")",
";",
"$",
"this",
"->",
"condition",
"=",
"function",
"(",
"$",
"row",
",",
"$",
"_",
")",
"use",
"(",
"$",
"attribute",
")",
"{",
"$",
"argument",
"=",
"ArgumentWrapper",
"::",
"wrap",
"(",
"$",
"row",
")",
";",
"return",
"!",
"(",
"$",
"argument",
"->",
"offsetExists",
"(",
"$",
"attribute",
")",
"&&",
"$",
"argument",
"->",
"offsetGet",
"(",
"$",
"attribute",
")",
"===",
"null",
")",
";",
"}",
";",
"}",
"}"
] |
Parses attribute configuration
@param \Omocha\AnnotationBag $propertyAnnotations
|
[
"Parses",
"attribute",
"configuration"
] |
df7100e601d2a1363d07028a786b6ceb22271829
|
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/ORM/Dynamic/DynamicAttribute.php#L110-L159
|
235,777
|
emaphp/eMapper
|
lib/eMapper/ORM/Dynamic/DynamicAttribute.php
|
DynamicAttribute.evaluateCondition
|
protected function evaluateCondition($row, $config) {
if (isset($this->condition))
return call_user_func($this->condition, $row, $config);
return true;
}
|
php
|
protected function evaluateCondition($row, $config) {
if (isset($this->condition))
return call_user_func($this->condition, $row, $config);
return true;
}
|
[
"protected",
"function",
"evaluateCondition",
"(",
"$",
"row",
",",
"$",
"config",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"condition",
")",
")",
"return",
"call_user_func",
"(",
"$",
"this",
"->",
"condition",
",",
"$",
"row",
",",
"$",
"config",
")",
";",
"return",
"true",
";",
"}"
] |
Evaluates attribute condition
@param array | object $row
@param array $config
@return bool
|
[
"Evaluates",
"attribute",
"condition"
] |
df7100e601d2a1363d07028a786b6ceb22271829
|
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/ORM/Dynamic/DynamicAttribute.php#L189-L193
|
235,778
|
activecollab/payments
|
src/Subscription/SubscriptionEvent/Implementation.php
|
Implementation.getSubscription
|
public function getSubscription()
{
if ($this->getGateway() instanceof GatewayInterface) {
return $this->getGateway()->getSubscriptionByReference($this->getSubscriptionReference());
}
throw new RuntimeException('Gateway is not set');
}
|
php
|
public function getSubscription()
{
if ($this->getGateway() instanceof GatewayInterface) {
return $this->getGateway()->getSubscriptionByReference($this->getSubscriptionReference());
}
throw new RuntimeException('Gateway is not set');
}
|
[
"public",
"function",
"getSubscription",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getGateway",
"(",
")",
"instanceof",
"GatewayInterface",
")",
"{",
"return",
"$",
"this",
"->",
"getGateway",
"(",
")",
"->",
"getSubscriptionByReference",
"(",
"$",
"this",
"->",
"getSubscriptionReference",
"(",
")",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"'Gateway is not set'",
")",
";",
"}"
] |
Return subscription by subscription reference.
@return SubscriptionInterface
|
[
"Return",
"subscription",
"by",
"subscription",
"reference",
"."
] |
9fab8060ccc496756cf6aed36e3006acfa0c1546
|
https://github.com/activecollab/payments/blob/9fab8060ccc496756cf6aed36e3006acfa0c1546/src/Subscription/SubscriptionEvent/Implementation.php#L42-L49
|
235,779
|
ideil/generic-file
|
src/Tools/Hasher.php
|
Hasher.file
|
public function file(SplFileInfo $file)
{
return substr($this->base(hash_file('sha256', $file->getRealPath(), true)), 0, 32);
}
|
php
|
public function file(SplFileInfo $file)
{
return substr($this->base(hash_file('sha256', $file->getRealPath(), true)), 0, 32);
}
|
[
"public",
"function",
"file",
"(",
"SplFileInfo",
"$",
"file",
")",
"{",
"return",
"substr",
"(",
"$",
"this",
"->",
"base",
"(",
"hash_file",
"(",
"'sha256'",
",",
"$",
"file",
"->",
"getRealPath",
"(",
")",
",",
"true",
")",
")",
",",
"0",
",",
"32",
")",
";",
"}"
] |
Make hash from uploaded file.
@param SplFileInfo $file
@return string
|
[
"Make",
"hash",
"from",
"uploaded",
"file",
"."
] |
0506ab15dc88f2acbd59c99d6c679a670735d0f9
|
https://github.com/ideil/generic-file/blob/0506ab15dc88f2acbd59c99d6c679a670735d0f9/src/Tools/Hasher.php#L15-L18
|
235,780
|
arvici/framework
|
src/Arvici/Heart/Database/Query/Parser.php
|
Parser.parse
|
private function parse()
{
// Skip if already parsed!
if ($this->parsed) {
return;
}
// Type switch
switch($this->query->mode){
case Query::MODE_SELECT:
$this->parseSelectQuery(); break;
case Query::MODE_INSERT:
$this->parseInsertQuery(); break;
case Query::MODE_UPDATE:
$this->parseUpdateQuery(); break;
case Query::MODE_DELETE:
$this->parseDeleteQuery(); break;
case Query::MODE_TRUNCATE:
$this->parseTruncateQuery(); break;
case Query::MODE_ADVANCED:
throw new QueryBuilderParseException("Query mode not yet implemented!"); break; // @codeCoverageIgnore
case Query::MODE_NONE:
throw new QueryBuilderParseException("Query has no mode yet!"); break; // @codeCoverageIgnore
default:
throw new QueryBuilderParseException("Query mode is invalid!"); break; // @codeCoverageIgnore
}
// Set parsed to true.
$this->parsed = true;
}
|
php
|
private function parse()
{
// Skip if already parsed!
if ($this->parsed) {
return;
}
// Type switch
switch($this->query->mode){
case Query::MODE_SELECT:
$this->parseSelectQuery(); break;
case Query::MODE_INSERT:
$this->parseInsertQuery(); break;
case Query::MODE_UPDATE:
$this->parseUpdateQuery(); break;
case Query::MODE_DELETE:
$this->parseDeleteQuery(); break;
case Query::MODE_TRUNCATE:
$this->parseTruncateQuery(); break;
case Query::MODE_ADVANCED:
throw new QueryBuilderParseException("Query mode not yet implemented!"); break; // @codeCoverageIgnore
case Query::MODE_NONE:
throw new QueryBuilderParseException("Query has no mode yet!"); break; // @codeCoverageIgnore
default:
throw new QueryBuilderParseException("Query mode is invalid!"); break; // @codeCoverageIgnore
}
// Set parsed to true.
$this->parsed = true;
}
|
[
"private",
"function",
"parse",
"(",
")",
"{",
"// Skip if already parsed!",
"if",
"(",
"$",
"this",
"->",
"parsed",
")",
"{",
"return",
";",
"}",
"// Type switch",
"switch",
"(",
"$",
"this",
"->",
"query",
"->",
"mode",
")",
"{",
"case",
"Query",
"::",
"MODE_SELECT",
":",
"$",
"this",
"->",
"parseSelectQuery",
"(",
")",
";",
"break",
";",
"case",
"Query",
"::",
"MODE_INSERT",
":",
"$",
"this",
"->",
"parseInsertQuery",
"(",
")",
";",
"break",
";",
"case",
"Query",
"::",
"MODE_UPDATE",
":",
"$",
"this",
"->",
"parseUpdateQuery",
"(",
")",
";",
"break",
";",
"case",
"Query",
"::",
"MODE_DELETE",
":",
"$",
"this",
"->",
"parseDeleteQuery",
"(",
")",
";",
"break",
";",
"case",
"Query",
"::",
"MODE_TRUNCATE",
":",
"$",
"this",
"->",
"parseTruncateQuery",
"(",
")",
";",
"break",
";",
"case",
"Query",
"::",
"MODE_ADVANCED",
":",
"throw",
"new",
"QueryBuilderParseException",
"(",
"\"Query mode not yet implemented!\"",
")",
";",
"break",
";",
"// @codeCoverageIgnore",
"case",
"Query",
"::",
"MODE_NONE",
":",
"throw",
"new",
"QueryBuilderParseException",
"(",
"\"Query has no mode yet!\"",
")",
";",
"break",
";",
"// @codeCoverageIgnore",
"default",
":",
"throw",
"new",
"QueryBuilderParseException",
"(",
"\"Query mode is invalid!\"",
")",
";",
"break",
";",
"// @codeCoverageIgnore",
"}",
"// Set parsed to true.",
"$",
"this",
"->",
"parsed",
"=",
"true",
";",
"}"
] |
Parse the Query object.
@throws QueryBuilderParseException
@throws \Exception
|
[
"Parse",
"the",
"Query",
"object",
"."
] |
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
|
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Database/Query/Parser.php#L95-L125
|
235,781
|
arvici/framework
|
src/Arvici/Heart/Database/Query/Parser.php
|
Parser.parseSelectQuery
|
private function parseSelectQuery()
{
// Parse select ?
$selectSql = Column::generateQueryString($this->query->select);
// Parse table
$fromSql = Table::generateQueryString($this->query->table);
$whereSql = null;
$whereBind = array();
$sql = [
'select' => $selectSql,
'from' => $fromSql,
'where' => $whereSql
// TODO: Add other parts.
];
$this->bind = array_merge(
$this->bind,
$whereBind
);
$this->sql = $this->combineSelectQuery($sql);
}
|
php
|
private function parseSelectQuery()
{
// Parse select ?
$selectSql = Column::generateQueryString($this->query->select);
// Parse table
$fromSql = Table::generateQueryString($this->query->table);
$whereSql = null;
$whereBind = array();
$sql = [
'select' => $selectSql,
'from' => $fromSql,
'where' => $whereSql
// TODO: Add other parts.
];
$this->bind = array_merge(
$this->bind,
$whereBind
);
$this->sql = $this->combineSelectQuery($sql);
}
|
[
"private",
"function",
"parseSelectQuery",
"(",
")",
"{",
"// Parse select ?",
"$",
"selectSql",
"=",
"Column",
"::",
"generateQueryString",
"(",
"$",
"this",
"->",
"query",
"->",
"select",
")",
";",
"// Parse table",
"$",
"fromSql",
"=",
"Table",
"::",
"generateQueryString",
"(",
"$",
"this",
"->",
"query",
"->",
"table",
")",
";",
"$",
"whereSql",
"=",
"null",
";",
"$",
"whereBind",
"=",
"array",
"(",
")",
";",
"$",
"sql",
"=",
"[",
"'select'",
"=>",
"$",
"selectSql",
",",
"'from'",
"=>",
"$",
"fromSql",
",",
"'where'",
"=>",
"$",
"whereSql",
"// TODO: Add other parts.",
"]",
";",
"$",
"this",
"->",
"bind",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"bind",
",",
"$",
"whereBind",
")",
";",
"$",
"this",
"->",
"sql",
"=",
"$",
"this",
"->",
"combineSelectQuery",
"(",
"$",
"sql",
")",
";",
"}"
] |
Select Mode Parser.
|
[
"Select",
"Mode",
"Parser",
"."
] |
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
|
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Database/Query/Parser.php#L131-L156
|
235,782
|
arvici/framework
|
src/Arvici/Heart/Database/Query/Parser.php
|
Parser.combineSelectQuery
|
private function combineSelectQuery($sqlParts)
{
// Add select columns and tables.
$output = "SELECT " . $sqlParts['select'] . " FROM " . $sqlParts['from'];
// Add where when defined.
if ($sqlParts['where'] !== null) {
// Add where
$output .= " WHERE " . $sqlParts['where'];
}
// TODO: Add other parts.
return $output;
}
|
php
|
private function combineSelectQuery($sqlParts)
{
// Add select columns and tables.
$output = "SELECT " . $sqlParts['select'] . " FROM " . $sqlParts['from'];
// Add where when defined.
if ($sqlParts['where'] !== null) {
// Add where
$output .= " WHERE " . $sqlParts['where'];
}
// TODO: Add other parts.
return $output;
}
|
[
"private",
"function",
"combineSelectQuery",
"(",
"$",
"sqlParts",
")",
"{",
"// Add select columns and tables.",
"$",
"output",
"=",
"\"SELECT \"",
".",
"$",
"sqlParts",
"[",
"'select'",
"]",
".",
"\" FROM \"",
".",
"$",
"sqlParts",
"[",
"'from'",
"]",
";",
"// Add where when defined.",
"if",
"(",
"$",
"sqlParts",
"[",
"'where'",
"]",
"!==",
"null",
")",
"{",
"// Add where",
"$",
"output",
".=",
"\" WHERE \"",
".",
"$",
"sqlParts",
"[",
"'where'",
"]",
";",
"}",
"// TODO: Add other parts.",
"return",
"$",
"output",
";",
"}"
] |
Combine select query.
@param array $sqlParts
@return string
|
[
"Combine",
"select",
"query",
"."
] |
4d0933912fef8f9edc756ef1ace009e96d9fc4b1
|
https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Database/Query/Parser.php#L165-L180
|
235,783
|
ManifestWebDesign/dabl-adapter
|
src/Propel/Model/Diff/PropelIndexComparator.php
|
PropelIndexComparator.computeDiff
|
static public function computeDiff(Index $fromIndex, Index $toIndex, $caseInsensitive = false)
{
// Check for removed index columns in $toIndex
$fromIndexColumns = $fromIndex->getColumns();
for($i = 0; $i < count($fromIndexColumns); $i++) {
$indexColumn = $fromIndexColumns[$i];
if (!$toIndex->hasColumnAtPosition($i, $indexColumn, null, $caseInsensitive)) {
return true;
}
}
// Check for new index columns in $toIndex
$toIndexColumns = $toIndex->getColumns();
for($i = 0; $i < count($toIndexColumns); $i++) {
$indexColumn = $toIndexColumns[$i];
if (!$fromIndex->hasColumnAtPosition($i, $indexColumn, null, $caseInsensitive)) {
return true;
}
}
// Check for difference in unicity
if ($fromIndex->isUnique() != $toIndex->isUnique()) {
return true;
}
return false;
}
|
php
|
static public function computeDiff(Index $fromIndex, Index $toIndex, $caseInsensitive = false)
{
// Check for removed index columns in $toIndex
$fromIndexColumns = $fromIndex->getColumns();
for($i = 0; $i < count($fromIndexColumns); $i++) {
$indexColumn = $fromIndexColumns[$i];
if (!$toIndex->hasColumnAtPosition($i, $indexColumn, null, $caseInsensitive)) {
return true;
}
}
// Check for new index columns in $toIndex
$toIndexColumns = $toIndex->getColumns();
for($i = 0; $i < count($toIndexColumns); $i++) {
$indexColumn = $toIndexColumns[$i];
if (!$fromIndex->hasColumnAtPosition($i, $indexColumn, null, $caseInsensitive)) {
return true;
}
}
// Check for difference in unicity
if ($fromIndex->isUnique() != $toIndex->isUnique()) {
return true;
}
return false;
}
|
[
"static",
"public",
"function",
"computeDiff",
"(",
"Index",
"$",
"fromIndex",
",",
"Index",
"$",
"toIndex",
",",
"$",
"caseInsensitive",
"=",
"false",
")",
"{",
"// Check for removed index columns in $toIndex",
"$",
"fromIndexColumns",
"=",
"$",
"fromIndex",
"->",
"getColumns",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"fromIndexColumns",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"indexColumn",
"=",
"$",
"fromIndexColumns",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"!",
"$",
"toIndex",
"->",
"hasColumnAtPosition",
"(",
"$",
"i",
",",
"$",
"indexColumn",
",",
"null",
",",
"$",
"caseInsensitive",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"// Check for new index columns in $toIndex",
"$",
"toIndexColumns",
"=",
"$",
"toIndex",
"->",
"getColumns",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"toIndexColumns",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"indexColumn",
"=",
"$",
"toIndexColumns",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"!",
"$",
"fromIndex",
"->",
"hasColumnAtPosition",
"(",
"$",
"i",
",",
"$",
"indexColumn",
",",
"null",
",",
"$",
"caseInsensitive",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"// Check for difference in unicity",
"if",
"(",
"$",
"fromIndex",
"->",
"isUnique",
"(",
")",
"!=",
"$",
"toIndex",
"->",
"isUnique",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Compute the difference between two index objects
@param Index $fromIndex
@param Index $toIndex
@param boolean $caseInsensitive Whether the comparison is case insensitive.
False by default.
@return boolean false if the two indices are similar, true if they have differences
|
[
"Compute",
"the",
"difference",
"between",
"two",
"index",
"objects"
] |
98579ed23bec832d764e762ee2f93f0a88ef9cd3
|
https://github.com/ManifestWebDesign/dabl-adapter/blob/98579ed23bec832d764e762ee2f93f0a88ef9cd3/src/Propel/Model/Diff/PropelIndexComparator.php#L33-L59
|
235,784
|
jelix/php-redis-plugin
|
plugins/cache/redis_php/redis_php.cache.php
|
redis_phpCacheDriver.get
|
public function get($key) {
$used_key = $this->getUsedKey($key);
$res = $this->redis->get($used_key);
if ($res === null)
return false;
$res = $this->unesc($res);
if (is_array($key)) {
return array_combine($key, $res);
}
else {
return $res;
}
}
|
php
|
public function get($key) {
$used_key = $this->getUsedKey($key);
$res = $this->redis->get($used_key);
if ($res === null)
return false;
$res = $this->unesc($res);
if (is_array($key)) {
return array_combine($key, $res);
}
else {
return $res;
}
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"used_key",
"=",
"$",
"this",
"->",
"getUsedKey",
"(",
"$",
"key",
")",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"redis",
"->",
"get",
"(",
"$",
"used_key",
")",
";",
"if",
"(",
"$",
"res",
"===",
"null",
")",
"return",
"false",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"unesc",
"(",
"$",
"res",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"return",
"array_combine",
"(",
"$",
"key",
",",
"$",
"res",
")",
";",
"}",
"else",
"{",
"return",
"$",
"res",
";",
"}",
"}"
] |
read a specific data in the cache.
@param mixed $key key or array of keys used for storing data in the cache
@return mixed $data array of data or false if failure
|
[
"read",
"a",
"specific",
"data",
"in",
"the",
"cache",
"."
] |
bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b
|
https://github.com/jelix/php-redis-plugin/blob/bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b/plugins/cache/redis_php/redis_php.cache.php#L130-L142
|
235,785
|
jelix/php-redis-plugin
|
plugins/cache/redis_php/redis_php.cache.php
|
redis_phpCacheDriver.set
|
public function set($key, $value, $ttl = 0) {
if (is_resource($value)) {
return false;
}
$used_key = $this->getUsedKey($key);
$res = $this->redis->set($used_key, $this->esc($value));
if ($res !== 'OK') {
return false;
}
if ($ttl === 0) {
return true;
}
if ($ttl != 0 && $ttl > 2592000) {
$ttl -= time();
}
if ($ttl <= 0) {
return true;
}
return ($this->redis->expire($used_key, $ttl) == 1);
}
|
php
|
public function set($key, $value, $ttl = 0) {
if (is_resource($value)) {
return false;
}
$used_key = $this->getUsedKey($key);
$res = $this->redis->set($used_key, $this->esc($value));
if ($res !== 'OK') {
return false;
}
if ($ttl === 0) {
return true;
}
if ($ttl != 0 && $ttl > 2592000) {
$ttl -= time();
}
if ($ttl <= 0) {
return true;
}
return ($this->redis->expire($used_key, $ttl) == 1);
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"ttl",
"=",
"0",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"used_key",
"=",
"$",
"this",
"->",
"getUsedKey",
"(",
"$",
"key",
")",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"redis",
"->",
"set",
"(",
"$",
"used_key",
",",
"$",
"this",
"->",
"esc",
"(",
"$",
"value",
")",
")",
";",
"if",
"(",
"$",
"res",
"!==",
"'OK'",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"ttl",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"ttl",
"!=",
"0",
"&&",
"$",
"ttl",
">",
"2592000",
")",
"{",
"$",
"ttl",
"-=",
"time",
"(",
")",
";",
"}",
"if",
"(",
"$",
"ttl",
"<=",
"0",
")",
"{",
"return",
"true",
";",
"}",
"return",
"(",
"$",
"this",
"->",
"redis",
"->",
"expire",
"(",
"$",
"used_key",
",",
"$",
"ttl",
")",
"==",
"1",
")",
";",
"}"
] |
set a specific data in the cache
@param string $key key used for storing data
@param mixed $var data to store
@param int $ttl data time expiration
@return boolean false if failure
|
[
"set",
"a",
"specific",
"data",
"in",
"the",
"cache"
] |
bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b
|
https://github.com/jelix/php-redis-plugin/blob/bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b/plugins/cache/redis_php/redis_php.cache.php#L151-L173
|
235,786
|
jelix/php-redis-plugin
|
plugins/cache/redis_php/redis_php.cache.php
|
redis_phpCacheDriver.delete
|
public function delete($key) {
$used_key = $this->getUsedKey($key);
return ($this->redis->delete($used_key) > 0);
}
|
php
|
public function delete($key) {
$used_key = $this->getUsedKey($key);
return ($this->redis->delete($used_key) > 0);
}
|
[
"public",
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"$",
"used_key",
"=",
"$",
"this",
"->",
"getUsedKey",
"(",
"$",
"key",
")",
";",
"return",
"(",
"$",
"this",
"->",
"redis",
"->",
"delete",
"(",
"$",
"used_key",
")",
">",
"0",
")",
";",
"}"
] |
delete a specific data in the cache
@param string $key key used for storing data in the cache
@return boolean false if failure
|
[
"delete",
"a",
"specific",
"data",
"in",
"the",
"cache"
] |
bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b
|
https://github.com/jelix/php-redis-plugin/blob/bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b/plugins/cache/redis_php/redis_php.cache.php#L180-L183
|
235,787
|
jelix/php-redis-plugin
|
plugins/cache/redis_php/redis_php.cache.php
|
redis_phpCacheDriver.flush
|
public function flush() {
if (!$this->key_prefix) {
return ($this->redis->flushdb() == 'OK');
}
switch($this->key_prefix_flush_method) {
case 'direct':
$this->redis->flushByPrefix($this->key_prefix);
return true;
case 'event':
jEvent::notify('jCacheRedisFlushKeyPrefix', array('prefix'=>$this->key_prefix,
'profile' =>$this->profileName));
return true;
case 'jcacheredisworker':
$this->redis->rpush('jcacheredisdelkeys', $this->key_prefix);
return true;
}
return false;
}
|
php
|
public function flush() {
if (!$this->key_prefix) {
return ($this->redis->flushdb() == 'OK');
}
switch($this->key_prefix_flush_method) {
case 'direct':
$this->redis->flushByPrefix($this->key_prefix);
return true;
case 'event':
jEvent::notify('jCacheRedisFlushKeyPrefix', array('prefix'=>$this->key_prefix,
'profile' =>$this->profileName));
return true;
case 'jcacheredisworker':
$this->redis->rpush('jcacheredisdelkeys', $this->key_prefix);
return true;
}
return false;
}
|
[
"public",
"function",
"flush",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"key_prefix",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"redis",
"->",
"flushdb",
"(",
")",
"==",
"'OK'",
")",
";",
"}",
"switch",
"(",
"$",
"this",
"->",
"key_prefix_flush_method",
")",
"{",
"case",
"'direct'",
":",
"$",
"this",
"->",
"redis",
"->",
"flushByPrefix",
"(",
"$",
"this",
"->",
"key_prefix",
")",
";",
"return",
"true",
";",
"case",
"'event'",
":",
"jEvent",
"::",
"notify",
"(",
"'jCacheRedisFlushKeyPrefix'",
",",
"array",
"(",
"'prefix'",
"=>",
"$",
"this",
"->",
"key_prefix",
",",
"'profile'",
"=>",
"$",
"this",
"->",
"profileName",
")",
")",
";",
"return",
"true",
";",
"case",
"'jcacheredisworker'",
":",
"$",
"this",
"->",
"redis",
"->",
"rpush",
"(",
"'jcacheredisdelkeys'",
",",
"$",
"this",
"->",
"key_prefix",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
clear all data in the cache.
If key_prefix is set, only keys with that prefix will be removed.
Note that in that case, it can result in a huge performance issue.
See key_prefix_flush_method to configure the best method for your
app and your server.
@return boolean false if failure
|
[
"clear",
"all",
"data",
"in",
"the",
"cache",
"."
] |
bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b
|
https://github.com/jelix/php-redis-plugin/blob/bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b/plugins/cache/redis_php/redis_php.cache.php#L266-L283
|
235,788
|
lazyguru/jira
|
src/JiraService.php
|
JiraService.setWorklog
|
public function setWorklog($date, $ticket, $timeSpent, $comment = '')
{
$this->uri = "{$this->site}/rest/api/2/issue/{$ticket}/worklog";
if (is_numeric($timeSpent)) {
$timeSpent .= 'h';
}
$startedDate = $this->_formatTimestamp($date);
$data = [
'timeSpent' => $timeSpent,
'started' => $startedDate,
'comment' => $comment
];
$this->output->debug(print_r($data, true));
$data = json_encode($data);
$response = $this->processRequest($data);
$this->_handleError($data, $response);
return $response;
}
|
php
|
public function setWorklog($date, $ticket, $timeSpent, $comment = '')
{
$this->uri = "{$this->site}/rest/api/2/issue/{$ticket}/worklog";
if (is_numeric($timeSpent)) {
$timeSpent .= 'h';
}
$startedDate = $this->_formatTimestamp($date);
$data = [
'timeSpent' => $timeSpent,
'started' => $startedDate,
'comment' => $comment
];
$this->output->debug(print_r($data, true));
$data = json_encode($data);
$response = $this->processRequest($data);
$this->_handleError($data, $response);
return $response;
}
|
[
"public",
"function",
"setWorklog",
"(",
"$",
"date",
",",
"$",
"ticket",
",",
"$",
"timeSpent",
",",
"$",
"comment",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"uri",
"=",
"\"{$this->site}/rest/api/2/issue/{$ticket}/worklog\"",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"timeSpent",
")",
")",
"{",
"$",
"timeSpent",
".=",
"'h'",
";",
"}",
"$",
"startedDate",
"=",
"$",
"this",
"->",
"_formatTimestamp",
"(",
"$",
"date",
")",
";",
"$",
"data",
"=",
"[",
"'timeSpent'",
"=>",
"$",
"timeSpent",
",",
"'started'",
"=>",
"$",
"startedDate",
",",
"'comment'",
"=>",
"$",
"comment",
"]",
";",
"$",
"this",
"->",
"output",
"->",
"debug",
"(",
"print_r",
"(",
"$",
"data",
",",
"true",
")",
")",
";",
"$",
"data",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"processRequest",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"_handleError",
"(",
"$",
"data",
",",
"$",
"response",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Create worklog entry in Jira
@param array $site
@param string $date
@param string $ticket
@param mixed $timeSpent
@param string $comment
@throws Exception
@return mixed
|
[
"Create",
"worklog",
"entry",
"in",
"Jira"
] |
79e5e1f2b2c65b45faae5f8fe0f045e3eaba048b
|
https://github.com/lazyguru/jira/blob/79e5e1f2b2c65b45faae5f8fe0f045e3eaba048b/src/JiraService.php#L48-L69
|
235,789
|
tenside/core
|
src/Task/Composer/ComposerTaskFactory.php
|
ComposerTaskFactory.createUpgrade
|
protected function createUpgrade($metaData)
{
$this->ensureHomePath($metaData);
if (!$metaData->has(UpgradeTask::SETTING_DATA_DIR)) {
$metaData->set(UpgradeTask::SETTING_DATA_DIR, $this->home->tensideDataDir());
}
return new UpgradeTask($metaData);
}
|
php
|
protected function createUpgrade($metaData)
{
$this->ensureHomePath($metaData);
if (!$metaData->has(UpgradeTask::SETTING_DATA_DIR)) {
$metaData->set(UpgradeTask::SETTING_DATA_DIR, $this->home->tensideDataDir());
}
return new UpgradeTask($metaData);
}
|
[
"protected",
"function",
"createUpgrade",
"(",
"$",
"metaData",
")",
"{",
"$",
"this",
"->",
"ensureHomePath",
"(",
"$",
"metaData",
")",
";",
"if",
"(",
"!",
"$",
"metaData",
"->",
"has",
"(",
"UpgradeTask",
"::",
"SETTING_DATA_DIR",
")",
")",
"{",
"$",
"metaData",
"->",
"set",
"(",
"UpgradeTask",
"::",
"SETTING_DATA_DIR",
",",
"$",
"this",
"->",
"home",
"->",
"tensideDataDir",
"(",
")",
")",
";",
"}",
"return",
"new",
"UpgradeTask",
"(",
"$",
"metaData",
")",
";",
"}"
] |
Create an upgrade task instance.
@param JsonArray $metaData The meta data for the task.
@return UpgradeTask
|
[
"Create",
"an",
"upgrade",
"task",
"instance",
"."
] |
56422fa8cdecf03cb431bb6654c2942ade39bf7b
|
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Task/Composer/ComposerTaskFactory.php#L68-L75
|
235,790
|
tenside/core
|
src/Task/Composer/ComposerTaskFactory.php
|
ComposerTaskFactory.ensureHomePath
|
private function ensureHomePath(JsonArray $metaData)
{
if ($metaData->has(AbstractPackageManipulatingTask::SETTING_HOME)) {
return;
}
$metaData->set(AbstractPackageManipulatingTask::SETTING_HOME, $this->home->homeDir());
}
|
php
|
private function ensureHomePath(JsonArray $metaData)
{
if ($metaData->has(AbstractPackageManipulatingTask::SETTING_HOME)) {
return;
}
$metaData->set(AbstractPackageManipulatingTask::SETTING_HOME, $this->home->homeDir());
}
|
[
"private",
"function",
"ensureHomePath",
"(",
"JsonArray",
"$",
"metaData",
")",
"{",
"if",
"(",
"$",
"metaData",
"->",
"has",
"(",
"AbstractPackageManipulatingTask",
"::",
"SETTING_HOME",
")",
")",
"{",
"return",
";",
"}",
"$",
"metaData",
"->",
"set",
"(",
"AbstractPackageManipulatingTask",
"::",
"SETTING_HOME",
",",
"$",
"this",
"->",
"home",
"->",
"homeDir",
"(",
")",
")",
";",
"}"
] |
Ensure the home path has been set in the passed meta data.
@param JsonArray $metaData The meta data to examine.
@return void
|
[
"Ensure",
"the",
"home",
"path",
"has",
"been",
"set",
"in",
"the",
"passed",
"meta",
"data",
"."
] |
56422fa8cdecf03cb431bb6654c2942ade39bf7b
|
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Task/Composer/ComposerTaskFactory.php#L110-L116
|
235,791
|
SergioMadness/framework
|
framework/components/eventhandler/traits/EventTrait.php
|
EventTrait.on
|
public function on($type, $callback)
{
if (!isset($this->callbacks[$type])) {
$this->callbacks[$type] = [];
}
$this->callbacks[$type][] = $callback;
return $this;
}
|
php
|
public function on($type, $callback)
{
if (!isset($this->callbacks[$type])) {
$this->callbacks[$type] = [];
}
$this->callbacks[$type][] = $callback;
return $this;
}
|
[
"public",
"function",
"on",
"(",
"$",
"type",
",",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"type",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"type",
"]",
"[",
"]",
"=",
"$",
"callback",
";",
"return",
"$",
"this",
";",
"}"
] |
Register event handler
@param string $type
@param \Closure|array|string $callback
@return $this
|
[
"Register",
"event",
"handler"
] |
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
|
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/components/eventhandler/traits/EventTrait.php#L17-L24
|
235,792
|
asbsoft/yii2module-news_2b_161124
|
models/NewsArchieve.php
|
NewsArchieve.preSaveText
|
public static function preSaveText($text, $controller, $transTable = [])
{
$module = Module::getModuleByClassname(Module::className());
$editorContentHelper = $module->contentHelper;
$text = trim($text);
if (empty($text)) return '';
$text = $editorContentHelper::afterSelectBody($text); // convert @uploads/.../ID to realpath
$text = strtr($text, $transTable);
$html = $text;
$viewFile = dirname(__DIR__) . '/views/news-archieve-text.php';
if (is_file($viewFile)) {
$text = static::START_TEXT_TAG . $text . static::END_TEXT_TAG;
$html = Yii::$app->view->renderFile($viewFile, ['text' => $text], $controller);
}
return $html;
}
|
php
|
public static function preSaveText($text, $controller, $transTable = [])
{
$module = Module::getModuleByClassname(Module::className());
$editorContentHelper = $module->contentHelper;
$text = trim($text);
if (empty($text)) return '';
$text = $editorContentHelper::afterSelectBody($text); // convert @uploads/.../ID to realpath
$text = strtr($text, $transTable);
$html = $text;
$viewFile = dirname(__DIR__) . '/views/news-archieve-text.php';
if (is_file($viewFile)) {
$text = static::START_TEXT_TAG . $text . static::END_TEXT_TAG;
$html = Yii::$app->view->renderFile($viewFile, ['text' => $text], $controller);
}
return $html;
}
|
[
"public",
"static",
"function",
"preSaveText",
"(",
"$",
"text",
",",
"$",
"controller",
",",
"$",
"transTable",
"=",
"[",
"]",
")",
"{",
"$",
"module",
"=",
"Module",
"::",
"getModuleByClassname",
"(",
"Module",
"::",
"className",
"(",
")",
")",
";",
"$",
"editorContentHelper",
"=",
"$",
"module",
"->",
"contentHelper",
";",
"$",
"text",
"=",
"trim",
"(",
"$",
"text",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"text",
")",
")",
"return",
"''",
";",
"$",
"text",
"=",
"$",
"editorContentHelper",
"::",
"afterSelectBody",
"(",
"$",
"text",
")",
";",
"// convert @uploads/.../ID to realpath\r",
"$",
"text",
"=",
"strtr",
"(",
"$",
"text",
",",
"$",
"transTable",
")",
";",
"$",
"html",
"=",
"$",
"text",
";",
"$",
"viewFile",
"=",
"dirname",
"(",
"__DIR__",
")",
".",
"'/views/news-archieve-text.php'",
";",
"if",
"(",
"is_file",
"(",
"$",
"viewFile",
")",
")",
"{",
"$",
"text",
"=",
"static",
"::",
"START_TEXT_TAG",
".",
"$",
"text",
".",
"static",
"::",
"END_TEXT_TAG",
";",
"$",
"html",
"=",
"Yii",
"::",
"$",
"app",
"->",
"view",
"->",
"renderFile",
"(",
"$",
"viewFile",
",",
"[",
"'text'",
"=>",
"$",
"text",
"]",
",",
"$",
"controller",
")",
";",
"}",
"return",
"$",
"html",
";",
"}"
] |
Processing text before saving.
@param string $text
@param Controller $controller
@param array $transTable
@return string
|
[
"Processing",
"text",
"before",
"saving",
"."
] |
9e9a7fdb458c88c7cdcd060cdc07cc4a7664690d
|
https://github.com/asbsoft/yii2module-news_2b_161124/blob/9e9a7fdb458c88c7cdcd060cdc07cc4a7664690d/models/NewsArchieve.php#L112-L131
|
235,793
|
asbsoft/yii2module-news_2b_161124
|
models/NewsArchieve.php
|
NewsArchieve.getSlug
|
public static function getSlug($model)
{
$i18nModels = $model->i18n;
$slugs = [];
foreach ($i18nModels as $i18nModel) {
if (empty($i18nModel->body)) continue; // skip languages for news without body
$slugs[$i18nModel->lang_code] = $i18nModel->slug;
}
//$langs = array_keys(LangHelper::activeLanguages()); // better use as container-module's member:
$module = Module::getModuleByClassname(Module::className());
$langHelper = $module->langHelper;
$langs = array_keys($langHelper::activeLanguages());
$slug = '';
foreach ($langs as $lang) {
if (!empty($slugs[$lang])) {
$slug = $slugs[$lang];
break;
}
}
if (strlen($slug) > static::$slugMaxLen) {
$slug = substr($slug, 0, static::$slugMaxLen);
}
$slug = trim($slug, '-');
return $slug;
}
|
php
|
public static function getSlug($model)
{
$i18nModels = $model->i18n;
$slugs = [];
foreach ($i18nModels as $i18nModel) {
if (empty($i18nModel->body)) continue; // skip languages for news without body
$slugs[$i18nModel->lang_code] = $i18nModel->slug;
}
//$langs = array_keys(LangHelper::activeLanguages()); // better use as container-module's member:
$module = Module::getModuleByClassname(Module::className());
$langHelper = $module->langHelper;
$langs = array_keys($langHelper::activeLanguages());
$slug = '';
foreach ($langs as $lang) {
if (!empty($slugs[$lang])) {
$slug = $slugs[$lang];
break;
}
}
if (strlen($slug) > static::$slugMaxLen) {
$slug = substr($slug, 0, static::$slugMaxLen);
}
$slug = trim($slug, '-');
return $slug;
}
|
[
"public",
"static",
"function",
"getSlug",
"(",
"$",
"model",
")",
"{",
"$",
"i18nModels",
"=",
"$",
"model",
"->",
"i18n",
";",
"$",
"slugs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"i18nModels",
"as",
"$",
"i18nModel",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"i18nModel",
"->",
"body",
")",
")",
"continue",
";",
"// skip languages for news without body\r",
"$",
"slugs",
"[",
"$",
"i18nModel",
"->",
"lang_code",
"]",
"=",
"$",
"i18nModel",
"->",
"slug",
";",
"}",
"//$langs = array_keys(LangHelper::activeLanguages()); // better use as container-module's member:\r",
"$",
"module",
"=",
"Module",
"::",
"getModuleByClassname",
"(",
"Module",
"::",
"className",
"(",
")",
")",
";",
"$",
"langHelper",
"=",
"$",
"module",
"->",
"langHelper",
";",
"$",
"langs",
"=",
"array_keys",
"(",
"$",
"langHelper",
"::",
"activeLanguages",
"(",
")",
")",
";",
"$",
"slug",
"=",
"''",
";",
"foreach",
"(",
"$",
"langs",
"as",
"$",
"lang",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"slugs",
"[",
"$",
"lang",
"]",
")",
")",
"{",
"$",
"slug",
"=",
"$",
"slugs",
"[",
"$",
"lang",
"]",
";",
"break",
";",
"}",
"}",
"if",
"(",
"strlen",
"(",
"$",
"slug",
")",
">",
"static",
"::",
"$",
"slugMaxLen",
")",
"{",
"$",
"slug",
"=",
"substr",
"(",
"$",
"slug",
",",
"0",
",",
"static",
"::",
"$",
"slugMaxLen",
")",
";",
"}",
"$",
"slug",
"=",
"trim",
"(",
"$",
"slug",
",",
"'-'",
")",
";",
"return",
"$",
"slug",
";",
"}"
] |
Get first non-empty slug of news. Search in default languages priority.
@param News $model
@return string
|
[
"Get",
"first",
"non",
"-",
"empty",
"slug",
"of",
"news",
".",
"Search",
"in",
"default",
"languages",
"priority",
"."
] |
9e9a7fdb458c88c7cdcd060cdc07cc4a7664690d
|
https://github.com/asbsoft/yii2module-news_2b_161124/blob/9e9a7fdb458c88c7cdcd060cdc07cc4a7664690d/models/NewsArchieve.php#L138-L163
|
235,794
|
bmdevel/php-index
|
classes/Range.php
|
Range.contains
|
public function contains($key)
{
if ($this->inclusive && in_array($key, array($this->min, $this->max))) {
return true;
}
return $key > $this->min && $key < $this->max;
}
|
php
|
public function contains($key)
{
if ($this->inclusive && in_array($key, array($this->min, $this->max))) {
return true;
}
return $key > $this->min && $key < $this->max;
}
|
[
"public",
"function",
"contains",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"inclusive",
"&&",
"in_array",
"(",
"$",
"key",
",",
"array",
"(",
"$",
"this",
"->",
"min",
",",
"$",
"this",
"->",
"max",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"key",
">",
"$",
"this",
"->",
"min",
"&&",
"$",
"key",
"<",
"$",
"this",
"->",
"max",
";",
"}"
] |
Returns true if key is inside this range
@param String $key
@return bool
|
[
"Returns",
"true",
"if",
"key",
"is",
"inside",
"this",
"range"
] |
6a6b476f1706b9524bfb34f6ce0963b1aea91259
|
https://github.com/bmdevel/php-index/blob/6a6b476f1706b9524bfb34f6ce0963b1aea91259/classes/Range.php#L70-L77
|
235,795
|
mickeyhead7/mickeyhead7-rsvp
|
src/Response/JsonapiResponse.php
|
JsonApiResponse.setLinks
|
public function setLinks()
{
// Only required for collections as items contain links by default
if ($this->resource instanceof Collection && $paginator = $this->resource->getPaginator()) {
$pagination = new Pagination($paginator);
$this->links = $pagination->generateCollectionLinks();
} else {
unset($this->links);
}
return $this;
}
|
php
|
public function setLinks()
{
// Only required for collections as items contain links by default
if ($this->resource instanceof Collection && $paginator = $this->resource->getPaginator()) {
$pagination = new Pagination($paginator);
$this->links = $pagination->generateCollectionLinks();
} else {
unset($this->links);
}
return $this;
}
|
[
"public",
"function",
"setLinks",
"(",
")",
"{",
"// Only required for collections as items contain links by default",
"if",
"(",
"$",
"this",
"->",
"resource",
"instanceof",
"Collection",
"&&",
"$",
"paginator",
"=",
"$",
"this",
"->",
"resource",
"->",
"getPaginator",
"(",
")",
")",
"{",
"$",
"pagination",
"=",
"new",
"Pagination",
"(",
"$",
"paginator",
")",
";",
"$",
"this",
"->",
"links",
"=",
"$",
"pagination",
"->",
"generateCollectionLinks",
"(",
")",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"links",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the response links data
@return $this Instance of self
|
[
"Set",
"the",
"response",
"links",
"data"
] |
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
|
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Response/JsonapiResponse.php#L49-L60
|
235,796
|
mickeyhead7/mickeyhead7-rsvp
|
src/Response/JsonapiResponse.php
|
JsonApiResponse.setData
|
public function setData()
{
// Process a collection
if ($this->resource instanceof Collection) {
$this->data = [];
foreach ($this->resource->getData() as $resource) {
$this->parseItem(new Item($resource, $this->resource->getTransformer()));
}
}
// Process an item
elseif ($this->resource instanceof Item) {
$this->parseItem($this->resource);
}
return $this;
}
|
php
|
public function setData()
{
// Process a collection
if ($this->resource instanceof Collection) {
$this->data = [];
foreach ($this->resource->getData() as $resource) {
$this->parseItem(new Item($resource, $this->resource->getTransformer()));
}
}
// Process an item
elseif ($this->resource instanceof Item) {
$this->parseItem($this->resource);
}
return $this;
}
|
[
"public",
"function",
"setData",
"(",
")",
"{",
"// Process a collection",
"if",
"(",
"$",
"this",
"->",
"resource",
"instanceof",
"Collection",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"resource",
"->",
"getData",
"(",
")",
"as",
"$",
"resource",
")",
"{",
"$",
"this",
"->",
"parseItem",
"(",
"new",
"Item",
"(",
"$",
"resource",
",",
"$",
"this",
"->",
"resource",
"->",
"getTransformer",
"(",
")",
")",
")",
";",
"}",
"}",
"// Process an item",
"elseif",
"(",
"$",
"this",
"->",
"resource",
"instanceof",
"Item",
")",
"{",
"$",
"this",
"->",
"parseItem",
"(",
"$",
"this",
"->",
"resource",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Creates the response
@return $this Instance of self
|
[
"Creates",
"the",
"response"
] |
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
|
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Response/JsonapiResponse.php#L67-L84
|
235,797
|
mickeyhead7/mickeyhead7-rsvp
|
src/Response/JsonapiResponse.php
|
JsonApiResponse.parseItem
|
private function parseItem(Item $item)
{
// Get and format an item
$tmp = $this->getFormattedItem($item);
// Get related data
$relationships = $this->getRelationships($item);
// Closure function to internally parse related includes
$parseRelationships = function($key, Item $item, array $relationships = []) {
$related = $this->getFormattedItem($item);
if (!in_array($related, $this->relationships)) {
$this->relationships[] = $related;
}
unset($related['attributes']);
unset($related['links']);
$relationships[$key]['data'][] = $related;
return $relationships;
};
// Loop data to create includes response data
foreach ($relationships as $key => $value) {
if ($value instanceof Collection) {
foreach ($value->getData() as $include_value) {
$relationships = $parseRelationships($key, new Item($include_value, $value->getTransformer()), $relationships);
}
} else if ($value instanceof Item) {
$relationships = $parseRelationships($key, $value, $relationships);
}
}
// Pass the relationships data into the item
$tmp['relationships'] = $relationships;
// Set the response data
if (is_array($this->data)) {
$this->data[] = $tmp;
} else {
$this->data = $tmp;
}
return $this;
}
|
php
|
private function parseItem(Item $item)
{
// Get and format an item
$tmp = $this->getFormattedItem($item);
// Get related data
$relationships = $this->getRelationships($item);
// Closure function to internally parse related includes
$parseRelationships = function($key, Item $item, array $relationships = []) {
$related = $this->getFormattedItem($item);
if (!in_array($related, $this->relationships)) {
$this->relationships[] = $related;
}
unset($related['attributes']);
unset($related['links']);
$relationships[$key]['data'][] = $related;
return $relationships;
};
// Loop data to create includes response data
foreach ($relationships as $key => $value) {
if ($value instanceof Collection) {
foreach ($value->getData() as $include_value) {
$relationships = $parseRelationships($key, new Item($include_value, $value->getTransformer()), $relationships);
}
} else if ($value instanceof Item) {
$relationships = $parseRelationships($key, $value, $relationships);
}
}
// Pass the relationships data into the item
$tmp['relationships'] = $relationships;
// Set the response data
if (is_array($this->data)) {
$this->data[] = $tmp;
} else {
$this->data = $tmp;
}
return $this;
}
|
[
"private",
"function",
"parseItem",
"(",
"Item",
"$",
"item",
")",
"{",
"// Get and format an item",
"$",
"tmp",
"=",
"$",
"this",
"->",
"getFormattedItem",
"(",
"$",
"item",
")",
";",
"// Get related data",
"$",
"relationships",
"=",
"$",
"this",
"->",
"getRelationships",
"(",
"$",
"item",
")",
";",
"// Closure function to internally parse related includes",
"$",
"parseRelationships",
"=",
"function",
"(",
"$",
"key",
",",
"Item",
"$",
"item",
",",
"array",
"$",
"relationships",
"=",
"[",
"]",
")",
"{",
"$",
"related",
"=",
"$",
"this",
"->",
"getFormattedItem",
"(",
"$",
"item",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"related",
",",
"$",
"this",
"->",
"relationships",
")",
")",
"{",
"$",
"this",
"->",
"relationships",
"[",
"]",
"=",
"$",
"related",
";",
"}",
"unset",
"(",
"$",
"related",
"[",
"'attributes'",
"]",
")",
";",
"unset",
"(",
"$",
"related",
"[",
"'links'",
"]",
")",
";",
"$",
"relationships",
"[",
"$",
"key",
"]",
"[",
"'data'",
"]",
"[",
"]",
"=",
"$",
"related",
";",
"return",
"$",
"relationships",
";",
"}",
";",
"// Loop data to create includes response data",
"foreach",
"(",
"$",
"relationships",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Collection",
")",
"{",
"foreach",
"(",
"$",
"value",
"->",
"getData",
"(",
")",
"as",
"$",
"include_value",
")",
"{",
"$",
"relationships",
"=",
"$",
"parseRelationships",
"(",
"$",
"key",
",",
"new",
"Item",
"(",
"$",
"include_value",
",",
"$",
"value",
"->",
"getTransformer",
"(",
")",
")",
",",
"$",
"relationships",
")",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"value",
"instanceof",
"Item",
")",
"{",
"$",
"relationships",
"=",
"$",
"parseRelationships",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"relationships",
")",
";",
"}",
"}",
"// Pass the relationships data into the item",
"$",
"tmp",
"[",
"'relationships'",
"]",
"=",
"$",
"relationships",
";",
"// Set the response data",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"data",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"]",
"=",
"$",
"tmp",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"tmp",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Parses an item into response data
@param Item $item Resource item
@return $this Instance of self
|
[
"Parses",
"an",
"item",
"into",
"response",
"data"
] |
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
|
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Response/JsonapiResponse.php#L92-L137
|
235,798
|
mickeyhead7/mickeyhead7-rsvp
|
src/Response/JsonapiResponse.php
|
JsonApiResponse.getFormattedItem
|
private function getFormattedItem(Item $item)
{
$data = [
'type' => $this->getFormattedName($item->getTransformer()),
'id' => $item->getData()->id,
'attributes' => $item->sanitize(),
];
if ($links = $item->getLinks()) {
$data['links'] = $links;
}
return $data;
}
|
php
|
private function getFormattedItem(Item $item)
{
$data = [
'type' => $this->getFormattedName($item->getTransformer()),
'id' => $item->getData()->id,
'attributes' => $item->sanitize(),
];
if ($links = $item->getLinks()) {
$data['links'] = $links;
}
return $data;
}
|
[
"private",
"function",
"getFormattedItem",
"(",
"Item",
"$",
"item",
")",
"{",
"$",
"data",
"=",
"[",
"'type'",
"=>",
"$",
"this",
"->",
"getFormattedName",
"(",
"$",
"item",
"->",
"getTransformer",
"(",
")",
")",
",",
"'id'",
"=>",
"$",
"item",
"->",
"getData",
"(",
")",
"->",
"id",
",",
"'attributes'",
"=>",
"$",
"item",
"->",
"sanitize",
"(",
")",
",",
"]",
";",
"if",
"(",
"$",
"links",
"=",
"$",
"item",
"->",
"getLinks",
"(",
")",
")",
"{",
"$",
"data",
"[",
"'links'",
"]",
"=",
"$",
"links",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Formats an item ready for response
@param Item $item Resource item
@return array Formatted item data
|
[
"Formats",
"an",
"item",
"ready",
"for",
"response"
] |
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
|
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Response/JsonapiResponse.php#L145-L158
|
235,799
|
mickeyhead7/mickeyhead7-rsvp
|
src/Response/JsonapiResponse.php
|
JsonApiResponse.getFormattedName
|
private function getFormattedName($class)
{
$class_name = (substr(strrchr(get_class($class), "\\"), 1));
$underscored = preg_replace('/([a-z])([A-Z])/', '$1_$2', $class_name);
return strtolower($underscored);
}
|
php
|
private function getFormattedName($class)
{
$class_name = (substr(strrchr(get_class($class), "\\"), 1));
$underscored = preg_replace('/([a-z])([A-Z])/', '$1_$2', $class_name);
return strtolower($underscored);
}
|
[
"private",
"function",
"getFormattedName",
"(",
"$",
"class",
")",
"{",
"$",
"class_name",
"=",
"(",
"substr",
"(",
"strrchr",
"(",
"get_class",
"(",
"$",
"class",
")",
",",
"\"\\\\\"",
")",
",",
"1",
")",
")",
";",
"$",
"underscored",
"=",
"preg_replace",
"(",
"'/([a-z])([A-Z])/'",
",",
"'$1_$2'",
",",
"$",
"class_name",
")",
";",
"return",
"strtolower",
"(",
"$",
"underscored",
")",
";",
"}"
] |
Formats a class name for readable use in the response
@param $class Class name to format
@return string Formatted name
|
[
"Formats",
"a",
"class",
"name",
"for",
"readable",
"use",
"in",
"the",
"response"
] |
36a780acd8b26bc9f313d7d2ebe44250f1aa6731
|
https://github.com/mickeyhead7/mickeyhead7-rsvp/blob/36a780acd8b26bc9f313d7d2ebe44250f1aa6731/src/Response/JsonapiResponse.php#L166-L172
|
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.