id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
1,600 | xmlsquad/capture-lookups | src/Service/GoogleApiService.php | GoogleApiService.setCredentials | public function setCredentials(?string $gApiServiceAccountCredentialsFilePath = null): string
{
$this->client = null;
$this->getClient($gApiServiceAccountCredentialsFilePath);
return $this->getCredentialsFilePath();
} | php | public function setCredentials(?string $gApiServiceAccountCredentialsFilePath = null): string
{
$this->client = null;
$this->getClient($gApiServiceAccountCredentialsFilePath);
return $this->getCredentialsFilePath();
} | [
"public",
"function",
"setCredentials",
"(",
"?",
"string",
"$",
"gApiServiceAccountCredentialsFilePath",
"=",
"null",
")",
":",
"string",
"{",
"$",
"this",
"->",
"client",
"=",
"null",
";",
"$",
"this",
"->",
"getClient",
"(",
"$",
"gApiServiceAccountCredentialsFilePath",
")",
";",
"return",
"$",
"this",
"->",
"getCredentialsFilePath",
"(",
")",
";",
"}"
] | A helper method allowing to use different credentials during the lifecycle of the application.
@param null|string $gApiServiceAccountCredentialsFilePath
@return string
@throws \Exception | [
"A",
"helper",
"method",
"allowing",
"to",
"use",
"different",
"credentials",
"during",
"the",
"lifecycle",
"of",
"the",
"application",
"."
] | 8696a4a425176c39417c3b925615d3e6171d9546 | https://github.com/xmlsquad/capture-lookups/blob/8696a4a425176c39417c3b925615d3e6171d9546/src/Service/GoogleApiService.php#L54-L60 |
1,601 | xmlsquad/capture-lookups | src/Service/GoogleApiService.php | GoogleApiService.getMapping | public function getMapping()
{
if (null === $this->mapping) {
$mappingFilePath = $this->locateFile($this->mappingFileName);
if (is_array($mappingFilePath)) {
throw new \Exception("The mapping file wasn't found. Locations we tried: ".join(', ', $mappingFilePath));
} elseif (!is_readable($mappingFilePath)) {
throw new \RuntimeException(sprintf('The mapping.yaml was not found at %s or is not readable.', $mappingFilePath));
} else {
$this->mappingFilePath = $mappingFilePath;
$this->mapping = Yaml::parse(file_get_contents($mappingFilePath));
}
}
return $this->mapping;
} | php | public function getMapping()
{
if (null === $this->mapping) {
$mappingFilePath = $this->locateFile($this->mappingFileName);
if (is_array($mappingFilePath)) {
throw new \Exception("The mapping file wasn't found. Locations we tried: ".join(', ', $mappingFilePath));
} elseif (!is_readable($mappingFilePath)) {
throw new \RuntimeException(sprintf('The mapping.yaml was not found at %s or is not readable.', $mappingFilePath));
} else {
$this->mappingFilePath = $mappingFilePath;
$this->mapping = Yaml::parse(file_get_contents($mappingFilePath));
}
}
return $this->mapping;
} | [
"public",
"function",
"getMapping",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"mapping",
")",
"{",
"$",
"mappingFilePath",
"=",
"$",
"this",
"->",
"locateFile",
"(",
"$",
"this",
"->",
"mappingFileName",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"mappingFilePath",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"The mapping file wasn't found. Locations we tried: \"",
".",
"join",
"(",
"', '",
",",
"$",
"mappingFilePath",
")",
")",
";",
"}",
"elseif",
"(",
"!",
"is_readable",
"(",
"$",
"mappingFilePath",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'The mapping.yaml was not found at %s or is not readable.'",
",",
"$",
"mappingFilePath",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"mappingFilePath",
"=",
"$",
"mappingFilePath",
";",
"$",
"this",
"->",
"mapping",
"=",
"Yaml",
"::",
"parse",
"(",
"file_get_contents",
"(",
"$",
"mappingFilePath",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"mapping",
";",
"}"
] | Returns the array resulting from mapping.yaml.
@return array|mixed
@throws \Exception | [
"Returns",
"the",
"array",
"resulting",
"from",
"mapping",
".",
"yaml",
"."
] | 8696a4a425176c39417c3b925615d3e6171d9546 | https://github.com/xmlsquad/capture-lookups/blob/8696a4a425176c39417c3b925615d3e6171d9546/src/Service/GoogleApiService.php#L89-L105 |
1,602 | xmlsquad/capture-lookups | src/Service/GoogleApiService.php | GoogleApiService.locateFile | private function locateFile($fileName, ?string $userSuppliedPath = null)
{
// These are the primary gApiServiceAccountCredentialsFile file locations
$locations = [
// First check the project file
$this->projectDir.DIRECTORY_SEPARATOR.$fileName,
];
// Then the current working directory, providing it is different from the project directory
if (getcwd() !== $this->projectDir) {
$locations[] = getcwd().DIRECTORY_SEPARATOR.$fileName;
}
$locationsFailed = [];
// Prepend the requested location if specified
if (null !== $userSuppliedPath) {
array_unshift($locations, $userSuppliedPath);
}
// In the first loop, we go through the primary locations.
for ($loop = 1; $loop <= 2; ++$loop) {
while ($path = array_shift($locations)) {
if (file_exists($path) && is_readable($path)) {
// When a file is found, we break free from both loops and just carry on with our life
return $path;
}
$locationsFailed[] = $path;
}
// If we made it here during the first loop, primary locations didn't work. We'll work out all the directories above us and try them
if (1 === $loop) {
// This means we didn't fin'd the file when checking the default locations, so let's try everything we can
// Add the root directory first
$locations[] = DIRECTORY_SEPARATOR.$fileName;
// We'll take CWD and project directory and will try to crawl all the way up to the root to attempt to load the file
foreach ([$this->projectDir, getcwd()] as $leafDirectory) {
$path = '/';
foreach (array_filter(explode(DIRECTORY_SEPARATOR, dirname($leafDirectory))) as $directory) {
$path .= $directory.DIRECTORY_SEPARATOR;
// Don't add one location twice
if (false === array_search($path.$fileName, $locationsFailed)
&& false === array_search($path.$fileName, $locations)
&& is_dir($path)
&& is_readable($path)
) {
array_unshift($locations, $path.$fileName);
}
}
}
}
// If we made it here during the second loop, neither primary nor secondary locations worked. We can't continue.
}
return $locationsFailed;
} | php | private function locateFile($fileName, ?string $userSuppliedPath = null)
{
// These are the primary gApiServiceAccountCredentialsFile file locations
$locations = [
// First check the project file
$this->projectDir.DIRECTORY_SEPARATOR.$fileName,
];
// Then the current working directory, providing it is different from the project directory
if (getcwd() !== $this->projectDir) {
$locations[] = getcwd().DIRECTORY_SEPARATOR.$fileName;
}
$locationsFailed = [];
// Prepend the requested location if specified
if (null !== $userSuppliedPath) {
array_unshift($locations, $userSuppliedPath);
}
// In the first loop, we go through the primary locations.
for ($loop = 1; $loop <= 2; ++$loop) {
while ($path = array_shift($locations)) {
if (file_exists($path) && is_readable($path)) {
// When a file is found, we break free from both loops and just carry on with our life
return $path;
}
$locationsFailed[] = $path;
}
// If we made it here during the first loop, primary locations didn't work. We'll work out all the directories above us and try them
if (1 === $loop) {
// This means we didn't fin'd the file when checking the default locations, so let's try everything we can
// Add the root directory first
$locations[] = DIRECTORY_SEPARATOR.$fileName;
// We'll take CWD and project directory and will try to crawl all the way up to the root to attempt to load the file
foreach ([$this->projectDir, getcwd()] as $leafDirectory) {
$path = '/';
foreach (array_filter(explode(DIRECTORY_SEPARATOR, dirname($leafDirectory))) as $directory) {
$path .= $directory.DIRECTORY_SEPARATOR;
// Don't add one location twice
if (false === array_search($path.$fileName, $locationsFailed)
&& false === array_search($path.$fileName, $locations)
&& is_dir($path)
&& is_readable($path)
) {
array_unshift($locations, $path.$fileName);
}
}
}
}
// If we made it here during the second loop, neither primary nor secondary locations worked. We can't continue.
}
return $locationsFailed;
} | [
"private",
"function",
"locateFile",
"(",
"$",
"fileName",
",",
"?",
"string",
"$",
"userSuppliedPath",
"=",
"null",
")",
"{",
"// These are the primary gApiServiceAccountCredentialsFile file locations",
"$",
"locations",
"=",
"[",
"// First check the project file",
"$",
"this",
"->",
"projectDir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"fileName",
",",
"]",
";",
"// Then the current working directory, providing it is different from the project directory",
"if",
"(",
"getcwd",
"(",
")",
"!==",
"$",
"this",
"->",
"projectDir",
")",
"{",
"$",
"locations",
"[",
"]",
"=",
"getcwd",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"fileName",
";",
"}",
"$",
"locationsFailed",
"=",
"[",
"]",
";",
"// Prepend the requested location if specified",
"if",
"(",
"null",
"!==",
"$",
"userSuppliedPath",
")",
"{",
"array_unshift",
"(",
"$",
"locations",
",",
"$",
"userSuppliedPath",
")",
";",
"}",
"// In the first loop, we go through the primary locations.",
"for",
"(",
"$",
"loop",
"=",
"1",
";",
"$",
"loop",
"<=",
"2",
";",
"++",
"$",
"loop",
")",
"{",
"while",
"(",
"$",
"path",
"=",
"array_shift",
"(",
"$",
"locations",
")",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
"&&",
"is_readable",
"(",
"$",
"path",
")",
")",
"{",
"// When a file is found, we break free from both loops and just carry on with our life",
"return",
"$",
"path",
";",
"}",
"$",
"locationsFailed",
"[",
"]",
"=",
"$",
"path",
";",
"}",
"// If we made it here during the first loop, primary locations didn't work. We'll work out all the directories above us and try them",
"if",
"(",
"1",
"===",
"$",
"loop",
")",
"{",
"// This means we didn't fin'd the file when checking the default locations, so let's try everything we can",
"// Add the root directory first",
"$",
"locations",
"[",
"]",
"=",
"DIRECTORY_SEPARATOR",
".",
"$",
"fileName",
";",
"// We'll take CWD and project directory and will try to crawl all the way up to the root to attempt to load the file",
"foreach",
"(",
"[",
"$",
"this",
"->",
"projectDir",
",",
"getcwd",
"(",
")",
"]",
"as",
"$",
"leafDirectory",
")",
"{",
"$",
"path",
"=",
"'/'",
";",
"foreach",
"(",
"array_filter",
"(",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"dirname",
"(",
"$",
"leafDirectory",
")",
")",
")",
"as",
"$",
"directory",
")",
"{",
"$",
"path",
".=",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
";",
"// Don't add one location twice",
"if",
"(",
"false",
"===",
"array_search",
"(",
"$",
"path",
".",
"$",
"fileName",
",",
"$",
"locationsFailed",
")",
"&&",
"false",
"===",
"array_search",
"(",
"$",
"path",
".",
"$",
"fileName",
",",
"$",
"locations",
")",
"&&",
"is_dir",
"(",
"$",
"path",
")",
"&&",
"is_readable",
"(",
"$",
"path",
")",
")",
"{",
"array_unshift",
"(",
"$",
"locations",
",",
"$",
"path",
".",
"$",
"fileName",
")",
";",
"}",
"}",
"}",
"}",
"// If we made it here during the second loop, neither primary nor secondary locations worked. We can't continue.",
"}",
"return",
"$",
"locationsFailed",
";",
"}"
] | Looks for a specified file name in various locations.
Returns path to the file if found, or array of tried locations if not found.
Locations checked:
- Project root dir
- Current working directory
@param $fileName
@param null|string $userSuppliedPath
@return string|array | [
"Looks",
"for",
"a",
"specified",
"file",
"name",
"in",
"various",
"locations",
"."
] | 8696a4a425176c39417c3b925615d3e6171d9546 | https://github.com/xmlsquad/capture-lookups/blob/8696a4a425176c39417c3b925615d3e6171d9546/src/Service/GoogleApiService.php#L237-L297 |
1,603 | eghojansu/nutrition | src/App.php | App.error | public function error(Base $app, array $params)
{
$eol = PHP_EOL;
$req = $app['VERB'].' '.$app['PATH'];
$error = ($app['ERROR']?:[]) + [
'text' => 'No-Message',
'trace' => 'No-Trace',
'status' => 'No-Status',
'code' => '000',
];
$this->log(sprintf(
"[%s] %s %s",
$req,
$error['text'] ?: 'No-Message',
$error['trace']
));
if ($app['CLI']) {
return;
}
if ($app['AJAX']) {
echo json_decode($error);
return;
}
if ($app['ERROR_TEMPLATE']) {
echo ExtendedTemplate::instance()->render($app['ERROR_TEMPLATE']);
return;
}
echo '<!DOCTYPE html>'.$eol.
'<html lang="en">'.$eol.
'<head>'.$eol.
'<meta charset="utf-8">'.$eol.
'<meta http-equiv="X-UA-Compatible" content="IE=edge">'.$eol.
'<meta name="viewport" content="width=device-width, initial-scale=1">'.$eol.
'<meta name="author" content="Eko Kurniawan">'.$eol.
'<title>'.$error['code'].' '.$error['status'].'</title>'.$eol.
'<style>'.$eol.
'code{word-wrap:break-word;color:black}.comment,.doc_comment,.ml_comment{color:dimgray;font-style:italic}.variable{color:blueviolet}.const,.constant_encapsed_string,.class_c,.dir,.file,.func_c,.halt_compiler,.line,.method_c,.lnumber,.dnumber{color:crimson}.string,.and_equal,.boolean_and,.boolean_or,.concat_equal,.dec,.div_equal,.inc,.is_equal,.is_greater_or_equal,.is_identical,.is_not_equal,.is_not_identical,.is_smaller_or_equal,.logical_and,.logical_or,.logical_xor,.minus_equal,.mod_equal,.mul_equal,.ns_c,.ns_separator,.or_equal,.plus_equal,.sl,.sl_equal,.sr,.sr_equal,.xor_equal,.start_heredoc,.end_heredoc,.object_operator,.paamayim_nekudotayim{color:black}.abstract,.array,.array_cast,.as,.break,.case,.catch,.class,.clone,.continue,.declare,.default,.do,.echo,.else,.elseif,.empty.enddeclare,.endfor,.endforach,.endif,.endswitch,.endwhile,.eval,.exit,.extends,.final,.for,.foreach,.function,.global,.goto,.if,.implements,.include,.include_once,.instanceof,.interface,.isset,.list,.namespace,.new,.print,.private,.public,.protected,.require,.require_once,.return,.static,.switch,.throw,.try,.unset,.use,.var,.while{color:royalblue}.open_tag,.open_tag_with_echo,.close_tag{color:orange}.ini_section{color:black}.ini_key{color:royalblue}.ini_value{color:crimson}.xml_tag{color:dodgerblue}.xml_attr{color:blueviolet}.xml_data{color:red}.section{color:black}.directive{color:blue}.data{color:dimgray}'.
'</style>'.$eol.
'</head>'.$eol.
'<body>'.$eol.
'<h1>'.$error['status'].'</h1>'.$eol.
'<p>'.$app->encode($error['text']?:$req).'</p>'.$eol.
($app['DEBUG']?('<pre>'.$error['trace'].'</pre>'.$eol):'').
'</body>'.$eol.
'</html>';
} | php | public function error(Base $app, array $params)
{
$eol = PHP_EOL;
$req = $app['VERB'].' '.$app['PATH'];
$error = ($app['ERROR']?:[]) + [
'text' => 'No-Message',
'trace' => 'No-Trace',
'status' => 'No-Status',
'code' => '000',
];
$this->log(sprintf(
"[%s] %s %s",
$req,
$error['text'] ?: 'No-Message',
$error['trace']
));
if ($app['CLI']) {
return;
}
if ($app['AJAX']) {
echo json_decode($error);
return;
}
if ($app['ERROR_TEMPLATE']) {
echo ExtendedTemplate::instance()->render($app['ERROR_TEMPLATE']);
return;
}
echo '<!DOCTYPE html>'.$eol.
'<html lang="en">'.$eol.
'<head>'.$eol.
'<meta charset="utf-8">'.$eol.
'<meta http-equiv="X-UA-Compatible" content="IE=edge">'.$eol.
'<meta name="viewport" content="width=device-width, initial-scale=1">'.$eol.
'<meta name="author" content="Eko Kurniawan">'.$eol.
'<title>'.$error['code'].' '.$error['status'].'</title>'.$eol.
'<style>'.$eol.
'code{word-wrap:break-word;color:black}.comment,.doc_comment,.ml_comment{color:dimgray;font-style:italic}.variable{color:blueviolet}.const,.constant_encapsed_string,.class_c,.dir,.file,.func_c,.halt_compiler,.line,.method_c,.lnumber,.dnumber{color:crimson}.string,.and_equal,.boolean_and,.boolean_or,.concat_equal,.dec,.div_equal,.inc,.is_equal,.is_greater_or_equal,.is_identical,.is_not_equal,.is_not_identical,.is_smaller_or_equal,.logical_and,.logical_or,.logical_xor,.minus_equal,.mod_equal,.mul_equal,.ns_c,.ns_separator,.or_equal,.plus_equal,.sl,.sl_equal,.sr,.sr_equal,.xor_equal,.start_heredoc,.end_heredoc,.object_operator,.paamayim_nekudotayim{color:black}.abstract,.array,.array_cast,.as,.break,.case,.catch,.class,.clone,.continue,.declare,.default,.do,.echo,.else,.elseif,.empty.enddeclare,.endfor,.endforach,.endif,.endswitch,.endwhile,.eval,.exit,.extends,.final,.for,.foreach,.function,.global,.goto,.if,.implements,.include,.include_once,.instanceof,.interface,.isset,.list,.namespace,.new,.print,.private,.public,.protected,.require,.require_once,.return,.static,.switch,.throw,.try,.unset,.use,.var,.while{color:royalblue}.open_tag,.open_tag_with_echo,.close_tag{color:orange}.ini_section{color:black}.ini_key{color:royalblue}.ini_value{color:crimson}.xml_tag{color:dodgerblue}.xml_attr{color:blueviolet}.xml_data{color:red}.section{color:black}.directive{color:blue}.data{color:dimgray}'.
'</style>'.$eol.
'</head>'.$eol.
'<body>'.$eol.
'<h1>'.$error['status'].'</h1>'.$eol.
'<p>'.$app->encode($error['text']?:$req).'</p>'.$eol.
($app['DEBUG']?('<pre>'.$error['trace'].'</pre>'.$eol):'').
'</body>'.$eol.
'</html>';
} | [
"public",
"function",
"error",
"(",
"Base",
"$",
"app",
",",
"array",
"$",
"params",
")",
"{",
"$",
"eol",
"=",
"PHP_EOL",
";",
"$",
"req",
"=",
"$",
"app",
"[",
"'VERB'",
"]",
".",
"' '",
".",
"$",
"app",
"[",
"'PATH'",
"]",
";",
"$",
"error",
"=",
"(",
"$",
"app",
"[",
"'ERROR'",
"]",
"?",
":",
"[",
"]",
")",
"+",
"[",
"'text'",
"=>",
"'No-Message'",
",",
"'trace'",
"=>",
"'No-Trace'",
",",
"'status'",
"=>",
"'No-Status'",
",",
"'code'",
"=>",
"'000'",
",",
"]",
";",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"\"[%s] %s %s\"",
",",
"$",
"req",
",",
"$",
"error",
"[",
"'text'",
"]",
"?",
":",
"'No-Message'",
",",
"$",
"error",
"[",
"'trace'",
"]",
")",
")",
";",
"if",
"(",
"$",
"app",
"[",
"'CLI'",
"]",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"app",
"[",
"'AJAX'",
"]",
")",
"{",
"echo",
"json_decode",
"(",
"$",
"error",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"app",
"[",
"'ERROR_TEMPLATE'",
"]",
")",
"{",
"echo",
"ExtendedTemplate",
"::",
"instance",
"(",
")",
"->",
"render",
"(",
"$",
"app",
"[",
"'ERROR_TEMPLATE'",
"]",
")",
";",
"return",
";",
"}",
"echo",
"'<!DOCTYPE html>'",
".",
"$",
"eol",
".",
"'<html lang=\"en\">'",
".",
"$",
"eol",
".",
"'<head>'",
".",
"$",
"eol",
".",
"'<meta charset=\"utf-8\">'",
".",
"$",
"eol",
".",
"'<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">'",
".",
"$",
"eol",
".",
"'<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">'",
".",
"$",
"eol",
".",
"'<meta name=\"author\" content=\"Eko Kurniawan\">'",
".",
"$",
"eol",
".",
"'<title>'",
".",
"$",
"error",
"[",
"'code'",
"]",
".",
"' '",
".",
"$",
"error",
"[",
"'status'",
"]",
".",
"'</title>'",
".",
"$",
"eol",
".",
"'<style>'",
".",
"$",
"eol",
".",
"'code{word-wrap:break-word;color:black}.comment,.doc_comment,.ml_comment{color:dimgray;font-style:italic}.variable{color:blueviolet}.const,.constant_encapsed_string,.class_c,.dir,.file,.func_c,.halt_compiler,.line,.method_c,.lnumber,.dnumber{color:crimson}.string,.and_equal,.boolean_and,.boolean_or,.concat_equal,.dec,.div_equal,.inc,.is_equal,.is_greater_or_equal,.is_identical,.is_not_equal,.is_not_identical,.is_smaller_or_equal,.logical_and,.logical_or,.logical_xor,.minus_equal,.mod_equal,.mul_equal,.ns_c,.ns_separator,.or_equal,.plus_equal,.sl,.sl_equal,.sr,.sr_equal,.xor_equal,.start_heredoc,.end_heredoc,.object_operator,.paamayim_nekudotayim{color:black}.abstract,.array,.array_cast,.as,.break,.case,.catch,.class,.clone,.continue,.declare,.default,.do,.echo,.else,.elseif,.empty.enddeclare,.endfor,.endforach,.endif,.endswitch,.endwhile,.eval,.exit,.extends,.final,.for,.foreach,.function,.global,.goto,.if,.implements,.include,.include_once,.instanceof,.interface,.isset,.list,.namespace,.new,.print,.private,.public,.protected,.require,.require_once,.return,.static,.switch,.throw,.try,.unset,.use,.var,.while{color:royalblue}.open_tag,.open_tag_with_echo,.close_tag{color:orange}.ini_section{color:black}.ini_key{color:royalblue}.ini_value{color:crimson}.xml_tag{color:dodgerblue}.xml_attr{color:blueviolet}.xml_data{color:red}.section{color:black}.directive{color:blue}.data{color:dimgray}'",
".",
"'</style>'",
".",
"$",
"eol",
".",
"'</head>'",
".",
"$",
"eol",
".",
"'<body>'",
".",
"$",
"eol",
".",
"'<h1>'",
".",
"$",
"error",
"[",
"'status'",
"]",
".",
"'</h1>'",
".",
"$",
"eol",
".",
"'<p>'",
".",
"$",
"app",
"->",
"encode",
"(",
"$",
"error",
"[",
"'text'",
"]",
"?",
":",
"$",
"req",
")",
".",
"'</p>'",
".",
"$",
"eol",
".",
"(",
"$",
"app",
"[",
"'DEBUG'",
"]",
"?",
"(",
"'<pre>'",
".",
"$",
"error",
"[",
"'trace'",
"]",
".",
"'</pre>'",
".",
"$",
"eol",
")",
":",
"''",
")",
".",
"'</body>'",
".",
"$",
"eol",
".",
"'</html>'",
";",
"}"
] | Custom error handler with ability to log error and its trace
@param Base $app
@param array $params
@return void | [
"Custom",
"error",
"handler",
"with",
"ability",
"to",
"log",
"error",
"and",
"its",
"trace"
] | 3941c62aeb6dafda55349a38dd4107d521f8964a | https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/App.php#L94-L147 |
1,604 | agalbourdin/agl-core | src/Auth/Acl.php | Acl._loadRoles | private function _loadRoles(array $aclConfig)
{
foreach ($aclConfig as $role => $acl) {
if (isset($acl[self::CONFIG_FIELD_RESOURCE])
and is_array($acl[self::CONFIG_FIELD_RESOURCE])) {
$this->_roles[$role] = $acl[self::CONFIG_FIELD_RESOURCE];
} else {
$this->_roles[$role] = array();
}
if (isset($acl[self::CONFIG_FIELD_INHERIT])
and is_array($acl[self::CONFIG_FIELD_INHERIT])) {
foreach ($acl[self::CONFIG_FIELD_INHERIT] as $inherit) {
if (isset($aclConfig[$inherit][self::CONFIG_FIELD_RESOURCE])
and is_array($aclConfig[$inherit][self::CONFIG_FIELD_RESOURCE])) {
$this->_roles[$role] = array_merge($this->_roles[$role], $aclConfig[$inherit][self::CONFIG_FIELD_RESOURCE]);
}
}
}
}
return $this->_roles;
} | php | private function _loadRoles(array $aclConfig)
{
foreach ($aclConfig as $role => $acl) {
if (isset($acl[self::CONFIG_FIELD_RESOURCE])
and is_array($acl[self::CONFIG_FIELD_RESOURCE])) {
$this->_roles[$role] = $acl[self::CONFIG_FIELD_RESOURCE];
} else {
$this->_roles[$role] = array();
}
if (isset($acl[self::CONFIG_FIELD_INHERIT])
and is_array($acl[self::CONFIG_FIELD_INHERIT])) {
foreach ($acl[self::CONFIG_FIELD_INHERIT] as $inherit) {
if (isset($aclConfig[$inherit][self::CONFIG_FIELD_RESOURCE])
and is_array($aclConfig[$inherit][self::CONFIG_FIELD_RESOURCE])) {
$this->_roles[$role] = array_merge($this->_roles[$role], $aclConfig[$inherit][self::CONFIG_FIELD_RESOURCE]);
}
}
}
}
return $this->_roles;
} | [
"private",
"function",
"_loadRoles",
"(",
"array",
"$",
"aclConfig",
")",
"{",
"foreach",
"(",
"$",
"aclConfig",
"as",
"$",
"role",
"=>",
"$",
"acl",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"acl",
"[",
"self",
"::",
"CONFIG_FIELD_RESOURCE",
"]",
")",
"and",
"is_array",
"(",
"$",
"acl",
"[",
"self",
"::",
"CONFIG_FIELD_RESOURCE",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_roles",
"[",
"$",
"role",
"]",
"=",
"$",
"acl",
"[",
"self",
"::",
"CONFIG_FIELD_RESOURCE",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_roles",
"[",
"$",
"role",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"acl",
"[",
"self",
"::",
"CONFIG_FIELD_INHERIT",
"]",
")",
"and",
"is_array",
"(",
"$",
"acl",
"[",
"self",
"::",
"CONFIG_FIELD_INHERIT",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"acl",
"[",
"self",
"::",
"CONFIG_FIELD_INHERIT",
"]",
"as",
"$",
"inherit",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"aclConfig",
"[",
"$",
"inherit",
"]",
"[",
"self",
"::",
"CONFIG_FIELD_RESOURCE",
"]",
")",
"and",
"is_array",
"(",
"$",
"aclConfig",
"[",
"$",
"inherit",
"]",
"[",
"self",
"::",
"CONFIG_FIELD_RESOURCE",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_roles",
"[",
"$",
"role",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_roles",
"[",
"$",
"role",
"]",
",",
"$",
"aclConfig",
"[",
"$",
"inherit",
"]",
"[",
"self",
"::",
"CONFIG_FIELD_RESOURCE",
"]",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"_roles",
";",
"}"
] | Load the roles from the ACL configuration file.
@param array $aclConfig Roles and Resources configuration
@return array | [
"Load",
"the",
"roles",
"from",
"the",
"ACL",
"configuration",
"file",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Auth/Acl.php#L63-L85 |
1,605 | agalbourdin/agl-core | src/Auth/Acl.php | Acl.isAllowed | public function isAllowed($pRole, array $pResources)
{
foreach ($pResources as $resource) {
if (! isset($this->_roles[$pRole]) or ! in_array($resource, $this->_roles[$pRole])) {
return false;
}
}
return true;
} | php | public function isAllowed($pRole, array $pResources)
{
foreach ($pResources as $resource) {
if (! isset($this->_roles[$pRole]) or ! in_array($resource, $this->_roles[$pRole])) {
return false;
}
}
return true;
} | [
"public",
"function",
"isAllowed",
"(",
"$",
"pRole",
",",
"array",
"$",
"pResources",
")",
"{",
"foreach",
"(",
"$",
"pResources",
"as",
"$",
"resource",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_roles",
"[",
"$",
"pRole",
"]",
")",
"or",
"!",
"in_array",
"(",
"$",
"resource",
",",
"$",
"this",
"->",
"_roles",
"[",
"$",
"pRole",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Check if the role exists and if the resource is available with this role.
@param string $pRole Role identifier
@param array $pResource Required resources | [
"Check",
"if",
"the",
"role",
"exists",
"and",
"if",
"the",
"resource",
"is",
"available",
"with",
"this",
"role",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Auth/Acl.php#L93-L102 |
1,606 | ironedgesoftware/file-utils | src/File/Json.php | Json.decode | public function decode(array $options = [])
{
$json = json_decode($this->getContents(), true);
if ($json === null && json_last_error() === JSON_ERROR_NONE) {
$this->validateSyntax();
return $this;
}
$this->validateSchema();
return $json;
} | php | public function decode(array $options = [])
{
$json = json_decode($this->getContents(), true);
if ($json === null && json_last_error() === JSON_ERROR_NONE) {
$this->validateSyntax();
return $this;
}
$this->validateSchema();
return $json;
} | [
"public",
"function",
"decode",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"json",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"getContents",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"$",
"json",
"===",
"null",
"&&",
"json_last_error",
"(",
")",
"===",
"JSON_ERROR_NONE",
")",
"{",
"$",
"this",
"->",
"validateSyntax",
"(",
")",
";",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"validateSchema",
"(",
")",
";",
"return",
"$",
"json",
";",
"}"
] | Decodes JSON data.
@param array $options - Options.
@throws DecodeException
@return array | [
"Decodes",
"JSON",
"data",
"."
] | d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb | https://github.com/ironedgesoftware/file-utils/blob/d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb/src/File/Json.php#L34-L47 |
1,607 | ironedgesoftware/file-utils | src/File/Json.php | Json.validateSchema | protected function validateSchema()
{
$schemaPath = $this->getOption('schemaPath');
if ($schemaPath === null) {
return;
}
$schemaData = json_decode(file_get_contents($schemaPath));
if (!class_exists('\\JsonSchema\\Validator')) {
throw new \RuntimeException(
'If you want to validate a JSON schema, you must require package "justinrainbow/json-schema"-'
);
}
$validator = new \JsonSchema\Validator();
$validator->check($this->getContents(), $schemaData);
if (!$validator->isValid()) {
$errors = [];
foreach ((array) $validator->getErrors() as $error) {
$errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
}
throw DecodeException::create($this->getPath(), ['errors' => $errors]);
}
} | php | protected function validateSchema()
{
$schemaPath = $this->getOption('schemaPath');
if ($schemaPath === null) {
return;
}
$schemaData = json_decode(file_get_contents($schemaPath));
if (!class_exists('\\JsonSchema\\Validator')) {
throw new \RuntimeException(
'If you want to validate a JSON schema, you must require package "justinrainbow/json-schema"-'
);
}
$validator = new \JsonSchema\Validator();
$validator->check($this->getContents(), $schemaData);
if (!$validator->isValid()) {
$errors = [];
foreach ((array) $validator->getErrors() as $error) {
$errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
}
throw DecodeException::create($this->getPath(), ['errors' => $errors]);
}
} | [
"protected",
"function",
"validateSchema",
"(",
")",
"{",
"$",
"schemaPath",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'schemaPath'",
")",
";",
"if",
"(",
"$",
"schemaPath",
"===",
"null",
")",
"{",
"return",
";",
"}",
"$",
"schemaData",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"schemaPath",
")",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"'\\\\JsonSchema\\\\Validator'",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'If you want to validate a JSON schema, you must require package \"justinrainbow/json-schema\"-'",
")",
";",
"}",
"$",
"validator",
"=",
"new",
"\\",
"JsonSchema",
"\\",
"Validator",
"(",
")",
";",
"$",
"validator",
"->",
"check",
"(",
"$",
"this",
"->",
"getContents",
"(",
")",
",",
"$",
"schemaData",
")",
";",
"if",
"(",
"!",
"$",
"validator",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"validator",
"->",
"getErrors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"(",
"$",
"error",
"[",
"'property'",
"]",
"?",
"$",
"error",
"[",
"'property'",
"]",
".",
"' : '",
":",
"''",
")",
".",
"$",
"error",
"[",
"'message'",
"]",
";",
"}",
"throw",
"DecodeException",
"::",
"create",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
",",
"[",
"'errors'",
"=>",
"$",
"errors",
"]",
")",
";",
"}",
"}"
] | Validates JSON schema.
@throws DecodeException
@return void | [
"Validates",
"JSON",
"schema",
"."
] | d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb | https://github.com/ironedgesoftware/file-utils/blob/d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb/src/File/Json.php#L120-L148 |
1,608 | ironedgesoftware/file-utils | src/File/Json.php | Json.validateSyntax | protected function validateSyntax()
{
if (!class_exists('\\Seld\\JsonLint\\JsonParser')) {
throw new \RuntimeException(
'If you want to validate JSON syntax using lint, you must require package "seld/jsonlint".'
);
}
$parser = new \Seld\JsonLint\JsonParser();
$result = $parser->lint($this->getContents());
if ($result === null) {
if (JSON_ERROR_UTF8 === json_last_error()) {
throw new \UnexpectedValueException(
'"'.$this->getPath().'" is not encoded in UTF-8, could not parse as JSON'
);
}
return true;
}
throw DecodeException::create(
$this->getPath(),
['message' => $result->getMessage(), 'details' => $result->getDetails()]
);
} | php | protected function validateSyntax()
{
if (!class_exists('\\Seld\\JsonLint\\JsonParser')) {
throw new \RuntimeException(
'If you want to validate JSON syntax using lint, you must require package "seld/jsonlint".'
);
}
$parser = new \Seld\JsonLint\JsonParser();
$result = $parser->lint($this->getContents());
if ($result === null) {
if (JSON_ERROR_UTF8 === json_last_error()) {
throw new \UnexpectedValueException(
'"'.$this->getPath().'" is not encoded in UTF-8, could not parse as JSON'
);
}
return true;
}
throw DecodeException::create(
$this->getPath(),
['message' => $result->getMessage(), 'details' => $result->getDetails()]
);
} | [
"protected",
"function",
"validateSyntax",
"(",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"'\\\\Seld\\\\JsonLint\\\\JsonParser'",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'If you want to validate JSON syntax using lint, you must require package \"seld/jsonlint\".'",
")",
";",
"}",
"$",
"parser",
"=",
"new",
"\\",
"Seld",
"\\",
"JsonLint",
"\\",
"JsonParser",
"(",
")",
";",
"$",
"result",
"=",
"$",
"parser",
"->",
"lint",
"(",
"$",
"this",
"->",
"getContents",
"(",
")",
")",
";",
"if",
"(",
"$",
"result",
"===",
"null",
")",
"{",
"if",
"(",
"JSON_ERROR_UTF8",
"===",
"json_last_error",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'\"'",
".",
"$",
"this",
"->",
"getPath",
"(",
")",
".",
"'\" is not encoded in UTF-8, could not parse as JSON'",
")",
";",
"}",
"return",
"true",
";",
"}",
"throw",
"DecodeException",
"::",
"create",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
",",
"[",
"'message'",
"=>",
"$",
"result",
"->",
"getMessage",
"(",
")",
",",
"'details'",
"=>",
"$",
"result",
"->",
"getDetails",
"(",
")",
"]",
")",
";",
"}"
] | Validates JSON syntax using lint.
@throws DecodeException
@return bool | [
"Validates",
"JSON",
"syntax",
"using",
"lint",
"."
] | d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb | https://github.com/ironedgesoftware/file-utils/blob/d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb/src/File/Json.php#L157-L182 |
1,609 | jeromeklam/freefw | src/FreeFW/Model/Query.php | Query.addSimpleCondition | public function addSimpleCondition(string $p_operator, string $p_left, $p_right = null)
{
/**
* condition
* @var \FreeFW\Model\Condition $condition
*/
$condition = \FreeFW\DI\DI::get('FreeFW::Model::Condition');
$left = null;
if (strpos($p_left, '::Model::') !== false) {
$left = new \FreeFW\Model\ConditionMember();
$left->setField($p_left);
} else {
$left = new \FreeFW\Model\ConditionValue();
$left->setField($p_left);
}
$right = null;
if ($p_right !== null) {
if (strpos($p_right, '::Model::') !== false) {
$right = new \FreeFW\Model\ConditionMember();
$right->setField($p_right);
} else {
$right = new \FreeFW\Model\ConditionValue();
$right->setField($p_right);
}
}
$condition
->setLeftMember($left)
->setOperator($p_operator)
;
if ($right !== null) {
$condition->setRightMember($right);
}
return $this->addCondition($condition);
} | php | public function addSimpleCondition(string $p_operator, string $p_left, $p_right = null)
{
/**
* condition
* @var \FreeFW\Model\Condition $condition
*/
$condition = \FreeFW\DI\DI::get('FreeFW::Model::Condition');
$left = null;
if (strpos($p_left, '::Model::') !== false) {
$left = new \FreeFW\Model\ConditionMember();
$left->setField($p_left);
} else {
$left = new \FreeFW\Model\ConditionValue();
$left->setField($p_left);
}
$right = null;
if ($p_right !== null) {
if (strpos($p_right, '::Model::') !== false) {
$right = new \FreeFW\Model\ConditionMember();
$right->setField($p_right);
} else {
$right = new \FreeFW\Model\ConditionValue();
$right->setField($p_right);
}
}
$condition
->setLeftMember($left)
->setOperator($p_operator)
;
if ($right !== null) {
$condition->setRightMember($right);
}
return $this->addCondition($condition);
} | [
"public",
"function",
"addSimpleCondition",
"(",
"string",
"$",
"p_operator",
",",
"string",
"$",
"p_left",
",",
"$",
"p_right",
"=",
"null",
")",
"{",
"/**\n * condition\n * @var \\FreeFW\\Model\\Condition $condition\n */",
"$",
"condition",
"=",
"\\",
"FreeFW",
"\\",
"DI",
"\\",
"DI",
"::",
"get",
"(",
"'FreeFW::Model::Condition'",
")",
";",
"$",
"left",
"=",
"null",
";",
"if",
"(",
"strpos",
"(",
"$",
"p_left",
",",
"'::Model::'",
")",
"!==",
"false",
")",
"{",
"$",
"left",
"=",
"new",
"\\",
"FreeFW",
"\\",
"Model",
"\\",
"ConditionMember",
"(",
")",
";",
"$",
"left",
"->",
"setField",
"(",
"$",
"p_left",
")",
";",
"}",
"else",
"{",
"$",
"left",
"=",
"new",
"\\",
"FreeFW",
"\\",
"Model",
"\\",
"ConditionValue",
"(",
")",
";",
"$",
"left",
"->",
"setField",
"(",
"$",
"p_left",
")",
";",
"}",
"$",
"right",
"=",
"null",
";",
"if",
"(",
"$",
"p_right",
"!==",
"null",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"p_right",
",",
"'::Model::'",
")",
"!==",
"false",
")",
"{",
"$",
"right",
"=",
"new",
"\\",
"FreeFW",
"\\",
"Model",
"\\",
"ConditionMember",
"(",
")",
";",
"$",
"right",
"->",
"setField",
"(",
"$",
"p_right",
")",
";",
"}",
"else",
"{",
"$",
"right",
"=",
"new",
"\\",
"FreeFW",
"\\",
"Model",
"\\",
"ConditionValue",
"(",
")",
";",
"$",
"right",
"->",
"setField",
"(",
"$",
"p_right",
")",
";",
"}",
"}",
"$",
"condition",
"->",
"setLeftMember",
"(",
"$",
"left",
")",
"->",
"setOperator",
"(",
"$",
"p_operator",
")",
";",
"if",
"(",
"$",
"right",
"!==",
"null",
")",
"{",
"$",
"condition",
"->",
"setRightMember",
"(",
"$",
"right",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addCondition",
"(",
"$",
"condition",
")",
";",
"}"
] | Add simple condition
@param string $p_operator
@param string $p_left
@param mixed $p_right
@return \FreeFW\Model\Query | [
"Add",
"simple",
"condition"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Model/Query.php#L141-L174 |
1,610 | jeromeklam/freefw | src/FreeFW/Model/Query.php | Query.conditionLower | public function conditionLower(string $p_member, $p_value)
{
return $this->addSimpleCondition(\FreeFW\Storage\Storage::COND_LOWER, $p_member, $p_value);
} | php | public function conditionLower(string $p_member, $p_value)
{
return $this->addSimpleCondition(\FreeFW\Storage\Storage::COND_LOWER, $p_member, $p_value);
} | [
"public",
"function",
"conditionLower",
"(",
"string",
"$",
"p_member",
",",
"$",
"p_value",
")",
"{",
"return",
"$",
"this",
"->",
"addSimpleCondition",
"(",
"\\",
"FreeFW",
"\\",
"Storage",
"\\",
"Storage",
"::",
"COND_LOWER",
",",
"$",
"p_member",
",",
"$",
"p_value",
")",
";",
"}"
] | Simple lower condition
@param string $p_member
@param mixed $p_value
@return \FreeFW\Core\StorageModel | [
"Simple",
"lower",
"condition"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Model/Query.php#L184-L187 |
1,611 | bmdevel/php-index | classes/binarySearch/BinarySearch.php | BinarySearch.search | public function search($key)
{
// split the range
$splitOffset = $this->getSplitOffset();
// search right side
$keys = $this->index->getKeyReader()->readKeys($splitOffset, self::DIRECTION_FORWARD);
$foundKey = $this->findKey($key, $keys);
// found
if (! is_null($foundKey)) {
return $foundKey;
}
// check if search should terminate
if ($this->isKeyRange($key, $keys)) {
return \reset($keys);
}
// If found keys are smaller continue in the right side
if (! empty($keys) && \end($keys)->getKey() < $key) {
$newOffset = $splitOffset + $this->index->getKeyReader()->getReadLength();
// Stop if beyond index
if ($newOffset >= $this->index->getFile()->getFileSize()) {
return \end($keys);
}
$newLength =
$this->range->getLength() - ($newOffset - $this->range->getOffset());
$this->range->setOffset($newOffset);
$this->range->setLength($newLength);
return $this->search($key);
}
// Look at the key, which lies in both sides
$centerKeyOffset = empty($keys)
? $this->range->getNextByteOffset()
: \reset($keys)->getOffset();
$keys = $this->index->getKeyReader()->readKeys($centerKeyOffset, self::DIRECTION_BACKWARD);
$foundKey = $this->findKey($key, $keys);
// found
if (! is_null($foundKey)) {
return $foundKey;
}
// terminate if no more keys in the index
if (empty($keys)) {
return null;
}
// check if search should terminate
if ($this->isKeyRange($key, $keys)) {
return \reset($keys);
}
// Finally continue searching in the left side
$newLength = \reset($keys)->getOffset() - $this->range->getOffset() - 1;
if ($newLength >= $this->range->getLength()) {
return \reset($keys);
}
$this->range->setLength($newLength);
return $this->search($key);
} | php | public function search($key)
{
// split the range
$splitOffset = $this->getSplitOffset();
// search right side
$keys = $this->index->getKeyReader()->readKeys($splitOffset, self::DIRECTION_FORWARD);
$foundKey = $this->findKey($key, $keys);
// found
if (! is_null($foundKey)) {
return $foundKey;
}
// check if search should terminate
if ($this->isKeyRange($key, $keys)) {
return \reset($keys);
}
// If found keys are smaller continue in the right side
if (! empty($keys) && \end($keys)->getKey() < $key) {
$newOffset = $splitOffset + $this->index->getKeyReader()->getReadLength();
// Stop if beyond index
if ($newOffset >= $this->index->getFile()->getFileSize()) {
return \end($keys);
}
$newLength =
$this->range->getLength() - ($newOffset - $this->range->getOffset());
$this->range->setOffset($newOffset);
$this->range->setLength($newLength);
return $this->search($key);
}
// Look at the key, which lies in both sides
$centerKeyOffset = empty($keys)
? $this->range->getNextByteOffset()
: \reset($keys)->getOffset();
$keys = $this->index->getKeyReader()->readKeys($centerKeyOffset, self::DIRECTION_BACKWARD);
$foundKey = $this->findKey($key, $keys);
// found
if (! is_null($foundKey)) {
return $foundKey;
}
// terminate if no more keys in the index
if (empty($keys)) {
return null;
}
// check if search should terminate
if ($this->isKeyRange($key, $keys)) {
return \reset($keys);
}
// Finally continue searching in the left side
$newLength = \reset($keys)->getOffset() - $this->range->getOffset() - 1;
if ($newLength >= $this->range->getLength()) {
return \reset($keys);
}
$this->range->setLength($newLength);
return $this->search($key);
} | [
"public",
"function",
"search",
"(",
"$",
"key",
")",
"{",
"// split the range",
"$",
"splitOffset",
"=",
"$",
"this",
"->",
"getSplitOffset",
"(",
")",
";",
"// search right side",
"$",
"keys",
"=",
"$",
"this",
"->",
"index",
"->",
"getKeyReader",
"(",
")",
"->",
"readKeys",
"(",
"$",
"splitOffset",
",",
"self",
"::",
"DIRECTION_FORWARD",
")",
";",
"$",
"foundKey",
"=",
"$",
"this",
"->",
"findKey",
"(",
"$",
"key",
",",
"$",
"keys",
")",
";",
"// found",
"if",
"(",
"!",
"is_null",
"(",
"$",
"foundKey",
")",
")",
"{",
"return",
"$",
"foundKey",
";",
"}",
"// check if search should terminate",
"if",
"(",
"$",
"this",
"->",
"isKeyRange",
"(",
"$",
"key",
",",
"$",
"keys",
")",
")",
"{",
"return",
"\\",
"reset",
"(",
"$",
"keys",
")",
";",
"}",
"// If found keys are smaller continue in the right side",
"if",
"(",
"!",
"empty",
"(",
"$",
"keys",
")",
"&&",
"\\",
"end",
"(",
"$",
"keys",
")",
"->",
"getKey",
"(",
")",
"<",
"$",
"key",
")",
"{",
"$",
"newOffset",
"=",
"$",
"splitOffset",
"+",
"$",
"this",
"->",
"index",
"->",
"getKeyReader",
"(",
")",
"->",
"getReadLength",
"(",
")",
";",
"// Stop if beyond index",
"if",
"(",
"$",
"newOffset",
">=",
"$",
"this",
"->",
"index",
"->",
"getFile",
"(",
")",
"->",
"getFileSize",
"(",
")",
")",
"{",
"return",
"\\",
"end",
"(",
"$",
"keys",
")",
";",
"}",
"$",
"newLength",
"=",
"$",
"this",
"->",
"range",
"->",
"getLength",
"(",
")",
"-",
"(",
"$",
"newOffset",
"-",
"$",
"this",
"->",
"range",
"->",
"getOffset",
"(",
")",
")",
";",
"$",
"this",
"->",
"range",
"->",
"setOffset",
"(",
"$",
"newOffset",
")",
";",
"$",
"this",
"->",
"range",
"->",
"setLength",
"(",
"$",
"newLength",
")",
";",
"return",
"$",
"this",
"->",
"search",
"(",
"$",
"key",
")",
";",
"}",
"// Look at the key, which lies in both sides",
"$",
"centerKeyOffset",
"=",
"empty",
"(",
"$",
"keys",
")",
"?",
"$",
"this",
"->",
"range",
"->",
"getNextByteOffset",
"(",
")",
":",
"\\",
"reset",
"(",
"$",
"keys",
")",
"->",
"getOffset",
"(",
")",
";",
"$",
"keys",
"=",
"$",
"this",
"->",
"index",
"->",
"getKeyReader",
"(",
")",
"->",
"readKeys",
"(",
"$",
"centerKeyOffset",
",",
"self",
"::",
"DIRECTION_BACKWARD",
")",
";",
"$",
"foundKey",
"=",
"$",
"this",
"->",
"findKey",
"(",
"$",
"key",
",",
"$",
"keys",
")",
";",
"// found",
"if",
"(",
"!",
"is_null",
"(",
"$",
"foundKey",
")",
")",
"{",
"return",
"$",
"foundKey",
";",
"}",
"// terminate if no more keys in the index",
"if",
"(",
"empty",
"(",
"$",
"keys",
")",
")",
"{",
"return",
"null",
";",
"}",
"// check if search should terminate",
"if",
"(",
"$",
"this",
"->",
"isKeyRange",
"(",
"$",
"key",
",",
"$",
"keys",
")",
")",
"{",
"return",
"\\",
"reset",
"(",
"$",
"keys",
")",
";",
"}",
"// Finally continue searching in the left side",
"$",
"newLength",
"=",
"\\",
"reset",
"(",
"$",
"keys",
")",
"->",
"getOffset",
"(",
")",
"-",
"$",
"this",
"->",
"range",
"->",
"getOffset",
"(",
")",
"-",
"1",
";",
"if",
"(",
"$",
"newLength",
">=",
"$",
"this",
"->",
"range",
"->",
"getLength",
"(",
")",
")",
"{",
"return",
"\\",
"reset",
"(",
"$",
"keys",
")",
";",
"}",
"$",
"this",
"->",
"range",
"->",
"setLength",
"(",
"$",
"newLength",
")",
";",
"return",
"$",
"this",
"->",
"search",
"(",
"$",
"key",
")",
";",
"}"
] | Searches for a key or some neighbour
If it doesn't find the key. A neighbour will be returned. The
neighbour mustn't be the closest neighbour. It's just a good hint
where the key should be expected.
Returns null if no key could be found at all.
@param string $key Key
@return Result
@throws IOIndexException | [
"Searches",
"for",
"a",
"key",
"or",
"some",
"neighbour"
] | 6a6b476f1706b9524bfb34f6ce0963b1aea91259 | https://github.com/bmdevel/php-index/blob/6a6b476f1706b9524bfb34f6ce0963b1aea91259/classes/binarySearch/BinarySearch.php#L54-L119 |
1,612 | bmdevel/php-index | classes/binarySearch/BinarySearch.php | BinarySearch.isKeyRange | private function isKeyRange($key, Array $keys)
{
if (empty($keys)) {
return false;
}
return \reset($keys)->getKey() <= $key
&& \end($keys)->getKey() >= $key;
} | php | private function isKeyRange($key, Array $keys)
{
if (empty($keys)) {
return false;
}
return \reset($keys)->getKey() <= $key
&& \end($keys)->getKey() >= $key;
} | [
"private",
"function",
"isKeyRange",
"(",
"$",
"key",
",",
"Array",
"$",
"keys",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"keys",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"\\",
"reset",
"(",
"$",
"keys",
")",
"->",
"getKey",
"(",
")",
"<=",
"$",
"key",
"&&",
"\\",
"end",
"(",
"$",
"keys",
")",
"->",
"getKey",
"(",
")",
">=",
"$",
"key",
";",
"}"
] | Returns true if the key is expected to be in the key list
If the key list is a subset of the index, and the key sould not be in
this list, the key is nowhere else in the index.
@param type $key
@param array $keys
@return bool | [
"Returns",
"true",
"if",
"the",
"key",
"is",
"expected",
"to",
"be",
"in",
"the",
"key",
"list"
] | 6a6b476f1706b9524bfb34f6ce0963b1aea91259 | https://github.com/bmdevel/php-index/blob/6a6b476f1706b9524bfb34f6ce0963b1aea91259/classes/binarySearch/BinarySearch.php#L132-L140 |
1,613 | bmdevel/php-index | classes/binarySearch/BinarySearch.php | BinarySearch.getSplitOffset | private function getSplitOffset()
{
$blocks = (int) $this->range->getLength() / $this->index->getKeyReader()->getReadLength();
$centerBlock = (int) $blocks / 2;
return $this->range->getOffset() + $centerBlock * $this->index->getKeyReader()->getReadLength();
} | php | private function getSplitOffset()
{
$blocks = (int) $this->range->getLength() / $this->index->getKeyReader()->getReadLength();
$centerBlock = (int) $blocks / 2;
return $this->range->getOffset() + $centerBlock * $this->index->getKeyReader()->getReadLength();
} | [
"private",
"function",
"getSplitOffset",
"(",
")",
"{",
"$",
"blocks",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"range",
"->",
"getLength",
"(",
")",
"/",
"$",
"this",
"->",
"index",
"->",
"getKeyReader",
"(",
")",
"->",
"getReadLength",
"(",
")",
";",
"$",
"centerBlock",
"=",
"(",
"int",
")",
"$",
"blocks",
"/",
"2",
";",
"return",
"$",
"this",
"->",
"range",
"->",
"getOffset",
"(",
")",
"+",
"$",
"centerBlock",
"*",
"$",
"this",
"->",
"index",
"->",
"getKeyReader",
"(",
")",
"->",
"getReadLength",
"(",
")",
";",
"}"
] | Returns the offset for the split
@return int | [
"Returns",
"the",
"offset",
"for",
"the",
"split"
] | 6a6b476f1706b9524bfb34f6ce0963b1aea91259 | https://github.com/bmdevel/php-index/blob/6a6b476f1706b9524bfb34f6ce0963b1aea91259/classes/binarySearch/BinarySearch.php#L163-L168 |
1,614 | mothepro/YQL-Builder | src/Query.php | Query.execute | public static function execute($q) {
if(!isset(self::$pest))
$p = new \Pest(self::API);
$json = $p->get('', [
'q' => $q,
'format' => 'json',
'diagnostics' => false,
'env' => 'http://datatables.org/alltables.env',
]);
return new Result($json);
} | php | public static function execute($q) {
if(!isset(self::$pest))
$p = new \Pest(self::API);
$json = $p->get('', [
'q' => $q,
'format' => 'json',
'diagnostics' => false,
'env' => 'http://datatables.org/alltables.env',
]);
return new Result($json);
} | [
"public",
"static",
"function",
"execute",
"(",
"$",
"q",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"pest",
")",
")",
"$",
"p",
"=",
"new",
"\\",
"Pest",
"(",
"self",
"::",
"API",
")",
";",
"$",
"json",
"=",
"$",
"p",
"->",
"get",
"(",
"''",
",",
"[",
"'q'",
"=>",
"$",
"q",
",",
"'format'",
"=>",
"'json'",
",",
"'diagnostics'",
"=>",
"false",
",",
"'env'",
"=>",
"'http://datatables.org/alltables.env'",
",",
"]",
")",
";",
"return",
"new",
"Result",
"(",
"$",
"json",
")",
";",
"}"
] | Runs the Query against Yahoo's Database
@param string $q the query to run
@return Result | [
"Runs",
"the",
"Query",
"against",
"Yahoo",
"s",
"Database"
] | 814c8ea142546fa08d0b28be728d865451efddcd | https://github.com/mothepro/YQL-Builder/blob/814c8ea142546fa08d0b28be728d865451efddcd/src/Query.php#L29-L41 |
1,615 | squire-assistant/config | Definition/Dumper/XmlReferenceDumper.php | XmlReferenceDumper.writeLine | private function writeLine($text, $indent = 0)
{
$indent = strlen($text) + $indent;
$format = '%'.$indent.'s';
$this->reference .= sprintf($format, $text).PHP_EOL;
} | php | private function writeLine($text, $indent = 0)
{
$indent = strlen($text) + $indent;
$format = '%'.$indent.'s';
$this->reference .= sprintf($format, $text).PHP_EOL;
} | [
"private",
"function",
"writeLine",
"(",
"$",
"text",
",",
"$",
"indent",
"=",
"0",
")",
"{",
"$",
"indent",
"=",
"strlen",
"(",
"$",
"text",
")",
"+",
"$",
"indent",
";",
"$",
"format",
"=",
"'%'",
".",
"$",
"indent",
".",
"'s'",
";",
"$",
"this",
"->",
"reference",
".=",
"sprintf",
"(",
"$",
"format",
",",
"$",
"text",
")",
".",
"PHP_EOL",
";",
"}"
] | Outputs a single config reference line.
@param string $text
@param int $indent | [
"Outputs",
"a",
"single",
"config",
"reference",
"line",
"."
] | 474835b35fa34fbba4fe15a484299a526c082cc5 | https://github.com/squire-assistant/config/blob/474835b35fa34fbba4fe15a484299a526c082cc5/Definition/Dumper/XmlReferenceDumper.php#L262-L268 |
1,616 | o3co/query.core | Criteria/SimpleParser.php | SimpleParser.parse | public function parse(array $criteria, array $orderBy = array(), $limit = null, $offset = null)
{
$statement = new Expr\Statement();
if(!empty($criteria)) {
$statement->setClause('condition', $this->parseCriteria($criteria));
}
if(!empty($orderBy))
$statement->setClause('order', $this->parseOrderBy($orderBy));
if($limit)
$statement->setClause('limit', $this->parseLimit($limit));
if($offset)
$statement->setClause('offset', $this->parseOffset($offset));
return new Query($statement, $this->persister);
} | php | public function parse(array $criteria, array $orderBy = array(), $limit = null, $offset = null)
{
$statement = new Expr\Statement();
if(!empty($criteria)) {
$statement->setClause('condition', $this->parseCriteria($criteria));
}
if(!empty($orderBy))
$statement->setClause('order', $this->parseOrderBy($orderBy));
if($limit)
$statement->setClause('limit', $this->parseLimit($limit));
if($offset)
$statement->setClause('offset', $this->parseOffset($offset));
return new Query($statement, $this->persister);
} | [
"public",
"function",
"parse",
"(",
"array",
"$",
"criteria",
",",
"array",
"$",
"orderBy",
"=",
"array",
"(",
")",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"$",
"statement",
"=",
"new",
"Expr",
"\\",
"Statement",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"criteria",
")",
")",
"{",
"$",
"statement",
"->",
"setClause",
"(",
"'condition'",
",",
"$",
"this",
"->",
"parseCriteria",
"(",
"$",
"criteria",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"orderBy",
")",
")",
"$",
"statement",
"->",
"setClause",
"(",
"'order'",
",",
"$",
"this",
"->",
"parseOrderBy",
"(",
"$",
"orderBy",
")",
")",
";",
"if",
"(",
"$",
"limit",
")",
"$",
"statement",
"->",
"setClause",
"(",
"'limit'",
",",
"$",
"this",
"->",
"parseLimit",
"(",
"$",
"limit",
")",
")",
";",
"if",
"(",
"$",
"offset",
")",
"$",
"statement",
"->",
"setClause",
"(",
"'offset'",
",",
"$",
"this",
"->",
"parseOffset",
"(",
"$",
"offset",
")",
")",
";",
"return",
"new",
"Query",
"(",
"$",
"statement",
",",
"$",
"this",
"->",
"persister",
")",
";",
"}"
] | parse
Parse fields criteria and order
@param array $criteria
@param array $order
@access public
@return void | [
"parse",
"Parse",
"fields",
"criteria",
"and",
"order"
] | 92478f21d2b04e21fef936944c7b688a092a4bf4 | https://github.com/o3co/query.core/blob/92478f21d2b04e21fef936944c7b688a092a4bf4/Criteria/SimpleParser.php#L76-L92 |
1,617 | o3co/query.core | Criteria/SimpleParser.php | SimpleParser.parseOrXValues | protected function parseOrXValues($field, $values)
{
$exprs = array();
foreach($values as $value) {
$exprs[] = $this->parseFieldValue($field, $value);
}
return $this->expr()->orX($exprs);
} | php | protected function parseOrXValues($field, $values)
{
$exprs = array();
foreach($values as $value) {
$exprs[] = $this->parseFieldValue($field, $value);
}
return $this->expr()->orX($exprs);
} | [
"protected",
"function",
"parseOrXValues",
"(",
"$",
"field",
",",
"$",
"values",
")",
"{",
"$",
"exprs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"exprs",
"[",
"]",
"=",
"$",
"this",
"->",
"parseFieldValue",
"(",
"$",
"field",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
"$",
"exprs",
")",
";",
"}"
] | parseOrXValues
parse deep array as a orx
@param mixed $field
@param mixed $values
@access protected
@return void | [
"parseOrXValues",
"parse",
"deep",
"array",
"as",
"a",
"orx"
] | 92478f21d2b04e21fef936944c7b688a092a4bf4 | https://github.com/o3co/query.core/blob/92478f21d2b04e21fef936944c7b688a092a4bf4/Criteria/SimpleParser.php#L151-L159 |
1,618 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/query/builder/update.php | Database_Query_Builder_Update.set | public function set(array $pairs)
{
foreach ($pairs as $column => $value)
{
$this->_set[] = array($column, $value);
}
return $this;
} | php | public function set(array $pairs)
{
foreach ($pairs as $column => $value)
{
$this->_set[] = array($column, $value);
}
return $this;
} | [
"public",
"function",
"set",
"(",
"array",
"$",
"pairs",
")",
"{",
"foreach",
"(",
"$",
"pairs",
"as",
"$",
"column",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_set",
"[",
"]",
"=",
"array",
"(",
"$",
"column",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the values to update with an associative array.
@param array $pairs associative (column => value) list
@return $this | [
"Set",
"the",
"values",
"to",
"update",
"with",
"an",
"associative",
"array",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/query/builder/update.php#L76-L84 |
1,619 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/query/builder/update.php | Database_Query_Builder_Update.on | public function on($c1, $op, $c2)
{
$this->_last_join->on($c1, $op, $c2);
return $this;
} | php | public function on($c1, $op, $c2)
{
$this->_last_join->on($c1, $op, $c2);
return $this;
} | [
"public",
"function",
"on",
"(",
"$",
"c1",
",",
"$",
"op",
",",
"$",
"c2",
")",
"{",
"$",
"this",
"->",
"_last_join",
"->",
"on",
"(",
"$",
"c1",
",",
"$",
"op",
",",
"$",
"c2",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds "ON ..." conditions for the last created JOIN statement.
@param mixed $c1 column name or array($column, $alias) or object
@param string $op logic operator
@param mixed $c2 column name or array($column, $alias) or object
@return $this | [
"Adds",
"ON",
"...",
"conditions",
"for",
"the",
"last",
"created",
"JOIN",
"statement",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/query/builder/update.php#L192-L197 |
1,620 | atanvarno69/test-util | src/CallProtectedMethodTrait.php | CallProtectedMethodTrait.callProtectedMethod | public function callProtectedMethod(
$object,
string $method,
array $arguments = []
) {
if (!is_object($object)) {
$msg = $this->getErrorMessage(1, __METHOD__, $object);
throw new InvalidArgumentException($msg);
}
$class = new ReflectionClass($object);
$method = $class->getMethod($method);
$method->setAccessible(true);
return $method->invokeArgs($object, $arguments);
} | php | public function callProtectedMethod(
$object,
string $method,
array $arguments = []
) {
if (!is_object($object)) {
$msg = $this->getErrorMessage(1, __METHOD__, $object);
throw new InvalidArgumentException($msg);
}
$class = new ReflectionClass($object);
$method = $class->getMethod($method);
$method->setAccessible(true);
return $method->invokeArgs($object, $arguments);
} | [
"public",
"function",
"callProtectedMethod",
"(",
"$",
"object",
",",
"string",
"$",
"method",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"$",
"msg",
"=",
"$",
"this",
"->",
"getErrorMessage",
"(",
"1",
",",
"__METHOD__",
",",
"$",
"object",
")",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
")",
";",
"}",
"$",
"class",
"=",
"new",
"ReflectionClass",
"(",
"$",
"object",
")",
";",
"$",
"method",
"=",
"$",
"class",
"->",
"getMethod",
"(",
"$",
"method",
")",
";",
"$",
"method",
"->",
"setAccessible",
"(",
"true",
")",
";",
"return",
"$",
"method",
"->",
"invokeArgs",
"(",
"$",
"object",
",",
"$",
"arguments",
")",
";",
"}"
] | Calls a protected or private method and returns its result.
@param object $object The instance containing the method to call.
@param string $method The method name.
@param array $arguments Arguments to pass to the method.
@throws InvalidArgumentException Non-object passed as first parameter.
@return mixed The return value of the method call. | [
"Calls",
"a",
"protected",
"or",
"private",
"method",
"and",
"returns",
"its",
"result",
"."
] | b4e2623118c0489caab883acc832ec9e3787d876 | https://github.com/atanvarno69/test-util/blob/b4e2623118c0489caab883acc832ec9e3787d876/src/CallProtectedMethodTrait.php#L38-L51 |
1,621 | masando/eDemyMainBundle | Controller/CssController.php | CssController.onCssLastModified | public function onCssLastModified(ContentEvent $event)
{
// @TODO lastmodified files from themeBundle templates
$reflection = new \ReflectionClass(get_class($this));
// @TODO
if(strpos($reflection->getFileName(), '/cache/')) {
$dir = dirname($reflection->getFileName()) . '/../../..';
} else {
$dir = dirname($reflection->getFileName()) . '/../../../../../..';
}
if(get_class($this) != "eDemy\MainBundle\Controller\MainController") {
}
$finder = new Finder();
// @TODO
$finder
->files()
->in($dir . '/vendor/edemy/mainbundle/eDemy/*/Resources/views/assets')
->name('*.css.twig')
->sortByModifiedTime();
foreach ($finder as $file) {
//$lastmodified = new \DateTime();
$lastmodified = \DateTime::createFromFormat( 'U', $file->getMTime() );
//$formattedString = $currentTime->format( 'c' );
if($event->getLastModified() > $lastmodified) {
//$event->setLastModified($lastmodified);
} else {
$event->setLastModified($lastmodified);
}
}
} | php | public function onCssLastModified(ContentEvent $event)
{
// @TODO lastmodified files from themeBundle templates
$reflection = new \ReflectionClass(get_class($this));
// @TODO
if(strpos($reflection->getFileName(), '/cache/')) {
$dir = dirname($reflection->getFileName()) . '/../../..';
} else {
$dir = dirname($reflection->getFileName()) . '/../../../../../..';
}
if(get_class($this) != "eDemy\MainBundle\Controller\MainController") {
}
$finder = new Finder();
// @TODO
$finder
->files()
->in($dir . '/vendor/edemy/mainbundle/eDemy/*/Resources/views/assets')
->name('*.css.twig')
->sortByModifiedTime();
foreach ($finder as $file) {
//$lastmodified = new \DateTime();
$lastmodified = \DateTime::createFromFormat( 'U', $file->getMTime() );
//$formattedString = $currentTime->format( 'c' );
if($event->getLastModified() > $lastmodified) {
//$event->setLastModified($lastmodified);
} else {
$event->setLastModified($lastmodified);
}
}
} | [
"public",
"function",
"onCssLastModified",
"(",
"ContentEvent",
"$",
"event",
")",
"{",
"// @TODO lastmodified files from themeBundle templates",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"// @TODO",
"if",
"(",
"strpos",
"(",
"$",
"reflection",
"->",
"getFileName",
"(",
")",
",",
"'/cache/'",
")",
")",
"{",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"reflection",
"->",
"getFileName",
"(",
")",
")",
".",
"'/../../..'",
";",
"}",
"else",
"{",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"reflection",
"->",
"getFileName",
"(",
")",
")",
".",
"'/../../../../../..'",
";",
"}",
"if",
"(",
"get_class",
"(",
"$",
"this",
")",
"!=",
"\"eDemy\\MainBundle\\Controller\\MainController\"",
")",
"{",
"}",
"$",
"finder",
"=",
"new",
"Finder",
"(",
")",
";",
"// @TODO",
"$",
"finder",
"->",
"files",
"(",
")",
"->",
"in",
"(",
"$",
"dir",
".",
"'/vendor/edemy/mainbundle/eDemy/*/Resources/views/assets'",
")",
"->",
"name",
"(",
"'*.css.twig'",
")",
"->",
"sortByModifiedTime",
"(",
")",
";",
"foreach",
"(",
"$",
"finder",
"as",
"$",
"file",
")",
"{",
"//$lastmodified = new \\DateTime();",
"$",
"lastmodified",
"=",
"\\",
"DateTime",
"::",
"createFromFormat",
"(",
"'U'",
",",
"$",
"file",
"->",
"getMTime",
"(",
")",
")",
";",
"//$formattedString = $currentTime->format( 'c' );",
"if",
"(",
"$",
"event",
"->",
"getLastModified",
"(",
")",
">",
"$",
"lastmodified",
")",
"{",
"//$event->setLastModified($lastmodified);",
"}",
"else",
"{",
"$",
"event",
"->",
"setLastModified",
"(",
"$",
"lastmodified",
")",
";",
"}",
"}",
"}"
] | Este listener calcula lastmodified de la ruta
@param ContentEvent $event
@return bool | [
"Este",
"listener",
"calcula",
"lastmodified",
"de",
"la",
"ruta"
] | cd9058e58d3a5ab06824f7ebc217a32c42f56a23 | https://github.com/masando/eDemyMainBundle/blob/cd9058e58d3a5ab06824f7ebc217a32c42f56a23/Controller/CssController.php#L78-L111 |
1,622 | GrupaZero/core | src/Gzero/Core/Models/User.php | User.hasPermission | public function hasPermission($permission)
{
if (!is_array($this->permissionsMap)) {
$permissionsMap = cache()->get('permissions:' . $this->id, null);
if ($permissionsMap === null) { // Not in cache
$this->permissionsMap = $this->buildPermissionsMap();
cache()->forever('permissions:' . $this->id, $this->permissionsMap);
} else {
$this->permissionsMap = $permissionsMap;
}
}
return in_array($permission, $this->permissionsMap);
} | php | public function hasPermission($permission)
{
if (!is_array($this->permissionsMap)) {
$permissionsMap = cache()->get('permissions:' . $this->id, null);
if ($permissionsMap === null) { // Not in cache
$this->permissionsMap = $this->buildPermissionsMap();
cache()->forever('permissions:' . $this->id, $this->permissionsMap);
} else {
$this->permissionsMap = $permissionsMap;
}
}
return in_array($permission, $this->permissionsMap);
} | [
"public",
"function",
"hasPermission",
"(",
"$",
"permission",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"permissionsMap",
")",
")",
"{",
"$",
"permissionsMap",
"=",
"cache",
"(",
")",
"->",
"get",
"(",
"'permissions:'",
".",
"$",
"this",
"->",
"id",
",",
"null",
")",
";",
"if",
"(",
"$",
"permissionsMap",
"===",
"null",
")",
"{",
"// Not in cache",
"$",
"this",
"->",
"permissionsMap",
"=",
"$",
"this",
"->",
"buildPermissionsMap",
"(",
")",
";",
"cache",
"(",
")",
"->",
"forever",
"(",
"'permissions:'",
".",
"$",
"this",
"->",
"id",
",",
"$",
"this",
"->",
"permissionsMap",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"permissionsMap",
"=",
"$",
"permissionsMap",
";",
"}",
"}",
"return",
"in_array",
"(",
"$",
"permission",
",",
"$",
"this",
"->",
"permissionsMap",
")",
";",
"}"
] | It checks if given user have specified permission
@param string $permission Permission name
@return bool | [
"It",
"checks",
"if",
"given",
"user",
"have",
"specified",
"permission"
] | 093e515234fa0385b259ba4d8bc7832174a44eab | https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Models/User.php#L121-L133 |
1,623 | GrupaZero/core | src/Gzero/Core/Models/User.php | User.buildPermissionsMap | private function buildPermissionsMap()
{
$permissionsMap = [];
$roles = $this->roles()->with('permissions')->get()->toArray();
foreach ($roles as $role) {
if (!empty($role['permissions'])) {
foreach ($role['permissions'] as $permission) {
$permissionsMap[] = $permission['name'];
}
}
}
return array_unique($permissionsMap);
} | php | private function buildPermissionsMap()
{
$permissionsMap = [];
$roles = $this->roles()->with('permissions')->get()->toArray();
foreach ($roles as $role) {
if (!empty($role['permissions'])) {
foreach ($role['permissions'] as $permission) {
$permissionsMap[] = $permission['name'];
}
}
}
return array_unique($permissionsMap);
} | [
"private",
"function",
"buildPermissionsMap",
"(",
")",
"{",
"$",
"permissionsMap",
"=",
"[",
"]",
";",
"$",
"roles",
"=",
"$",
"this",
"->",
"roles",
"(",
")",
"->",
"with",
"(",
"'permissions'",
")",
"->",
"get",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"role",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"role",
"[",
"'permissions'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"role",
"[",
"'permissions'",
"]",
"as",
"$",
"permission",
")",
"{",
"$",
"permissionsMap",
"[",
"]",
"=",
"$",
"permission",
"[",
"'name'",
"]",
";",
"}",
"}",
"}",
"return",
"array_unique",
"(",
"$",
"permissionsMap",
")",
";",
"}"
] | It build permission map.
Later we store this map cache.
@return array | [
"It",
"build",
"permission",
"map",
".",
"Later",
"we",
"store",
"this",
"map",
"cache",
"."
] | 093e515234fa0385b259ba4d8bc7832174a44eab | https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Models/User.php#L168-L180 |
1,624 | j-arens/container | src/Container.php | Container.singleton | public function singleton($className) {
$closure = function(ContainerInterface $container) use($className) {
static $instance;
if (is_null($instance)) {
$instance = $container->make($className);
}
return $instance;
};
$this->bind($className, $closure);
} | php | public function singleton($className) {
$closure = function(ContainerInterface $container) use($className) {
static $instance;
if (is_null($instance)) {
$instance = $container->make($className);
}
return $instance;
};
$this->bind($className, $closure);
} | [
"public",
"function",
"singleton",
"(",
"$",
"className",
")",
"{",
"$",
"closure",
"=",
"function",
"(",
"ContainerInterface",
"$",
"container",
")",
"use",
"(",
"$",
"className",
")",
"{",
"static",
"$",
"instance",
";",
"if",
"(",
"is_null",
"(",
"$",
"instance",
")",
")",
"{",
"$",
"instance",
"=",
"$",
"container",
"->",
"make",
"(",
"$",
"className",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}",
";",
"$",
"this",
"->",
"bind",
"(",
"$",
"className",
",",
"$",
"closure",
")",
";",
"}"
] | Register a shared binding
@param string $className | [
"Register",
"a",
"shared",
"binding"
] | 8fec5bf358ff83e88d3b13c1c5500314bc5c873b | https://github.com/j-arens/container/blob/8fec5bf358ff83e88d3b13c1c5500314bc5c873b/src/Container.php#L41-L53 |
1,625 | j-arens/container | src/Container.php | Container.resolve | public function resolve($key) {
if (!array_key_exists($key, $this->bindings)) {
throw new InvalidArgumentException("{$key} is not bound.");
}
$binding = $this->bindings[$key];
$value = $binding['value'];
// singleton
if ($value instanceof Closure) {
return $value($this);
}
// anonymous object
if (is_null($value) && class_exists('\\' . $key)) {
return $this->make($key);
}
// labeled object
if (is_string($value) && class_exists('\\' . $value)) {
return $this->make($value);
}
return $value;
} | php | public function resolve($key) {
if (!array_key_exists($key, $this->bindings)) {
throw new InvalidArgumentException("{$key} is not bound.");
}
$binding = $this->bindings[$key];
$value = $binding['value'];
// singleton
if ($value instanceof Closure) {
return $value($this);
}
// anonymous object
if (is_null($value) && class_exists('\\' . $key)) {
return $this->make($key);
}
// labeled object
if (is_string($value) && class_exists('\\' . $value)) {
return $this->make($value);
}
return $value;
} | [
"public",
"function",
"resolve",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"bindings",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"{$key} is not bound.\"",
")",
";",
"}",
"$",
"binding",
"=",
"$",
"this",
"->",
"bindings",
"[",
"$",
"key",
"]",
";",
"$",
"value",
"=",
"$",
"binding",
"[",
"'value'",
"]",
";",
"// singleton",
"if",
"(",
"$",
"value",
"instanceof",
"Closure",
")",
"{",
"return",
"$",
"value",
"(",
"$",
"this",
")",
";",
"}",
"// anonymous object",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
"&&",
"class_exists",
"(",
"'\\\\'",
".",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"make",
"(",
"$",
"key",
")",
";",
"}",
"// labeled object",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
"&&",
"class_exists",
"(",
"'\\\\'",
".",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"make",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Resolve the value from the given offset
@param string $key
@return mixed | [
"Resolve",
"the",
"value",
"from",
"the",
"given",
"offset"
] | 8fec5bf358ff83e88d3b13c1c5500314bc5c873b | https://github.com/j-arens/container/blob/8fec5bf358ff83e88d3b13c1c5500314bc5c873b/src/Container.php#L61-L85 |
1,626 | j-arens/container | src/Container.php | Container.getDependencies | protected function getDependencies(ReflectionClass $refl) {
if (!$refl->isInstantiable()) {
return [];
}
$constr = $refl->getConstructor();
if (!$constr) {
return [];
}
return $constr->getParameters();
} | php | protected function getDependencies(ReflectionClass $refl) {
if (!$refl->isInstantiable()) {
return [];
}
$constr = $refl->getConstructor();
if (!$constr) {
return [];
}
return $constr->getParameters();
} | [
"protected",
"function",
"getDependencies",
"(",
"ReflectionClass",
"$",
"refl",
")",
"{",
"if",
"(",
"!",
"$",
"refl",
"->",
"isInstantiable",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"constr",
"=",
"$",
"refl",
"->",
"getConstructor",
"(",
")",
";",
"if",
"(",
"!",
"$",
"constr",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"$",
"constr",
"->",
"getParameters",
"(",
")",
";",
"}"
] | Get an array of object dependencies
@param ReflectionClass $refl
@return array | [
"Get",
"an",
"array",
"of",
"object",
"dependencies"
] | 8fec5bf358ff83e88d3b13c1c5500314bc5c873b | https://github.com/j-arens/container/blob/8fec5bf358ff83e88d3b13c1c5500314bc5c873b/src/Container.php#L112-L124 |
1,627 | j-arens/container | src/Container.php | Container.resolveDependency | protected function resolveDependency(ReflectionParameter $dep) {
$depName = $dep->getName();
if ($dep->getClass()) {
$depName = $dep->getClass()->name;
}
// bound
if (array_key_exists($depName, $this->bindings)) {
return $this->resolve($depName);
}
// unbound
if (class_exists('\\' . $depName)) {
return $this->make($depName);
}
// check for default val
if ($dep->isDefaultValueAvailable()) {
return $dep->getDefaultValue();
}
throw new ResolutionException(
"Unable to resolve dependency {$depName} for {$dep->getDeclaringClass()->name}"
);
} | php | protected function resolveDependency(ReflectionParameter $dep) {
$depName = $dep->getName();
if ($dep->getClass()) {
$depName = $dep->getClass()->name;
}
// bound
if (array_key_exists($depName, $this->bindings)) {
return $this->resolve($depName);
}
// unbound
if (class_exists('\\' . $depName)) {
return $this->make($depName);
}
// check for default val
if ($dep->isDefaultValueAvailable()) {
return $dep->getDefaultValue();
}
throw new ResolutionException(
"Unable to resolve dependency {$depName} for {$dep->getDeclaringClass()->name}"
);
} | [
"protected",
"function",
"resolveDependency",
"(",
"ReflectionParameter",
"$",
"dep",
")",
"{",
"$",
"depName",
"=",
"$",
"dep",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"$",
"dep",
"->",
"getClass",
"(",
")",
")",
"{",
"$",
"depName",
"=",
"$",
"dep",
"->",
"getClass",
"(",
")",
"->",
"name",
";",
"}",
"// bound",
"if",
"(",
"array_key_exists",
"(",
"$",
"depName",
",",
"$",
"this",
"->",
"bindings",
")",
")",
"{",
"return",
"$",
"this",
"->",
"resolve",
"(",
"$",
"depName",
")",
";",
"}",
"// unbound",
"if",
"(",
"class_exists",
"(",
"'\\\\'",
".",
"$",
"depName",
")",
")",
"{",
"return",
"$",
"this",
"->",
"make",
"(",
"$",
"depName",
")",
";",
"}",
"// check for default val",
"if",
"(",
"$",
"dep",
"->",
"isDefaultValueAvailable",
"(",
")",
")",
"{",
"return",
"$",
"dep",
"->",
"getDefaultValue",
"(",
")",
";",
"}",
"throw",
"new",
"ResolutionException",
"(",
"\"Unable to resolve dependency {$depName} for {$dep->getDeclaringClass()->name}\"",
")",
";",
"}"
] | Resolve object dependency
@param ReflectionParameter $dep
@return mixed | [
"Resolve",
"object",
"dependency"
] | 8fec5bf358ff83e88d3b13c1c5500314bc5c873b | https://github.com/j-arens/container/blob/8fec5bf358ff83e88d3b13c1c5500314bc5c873b/src/Container.php#L132-L157 |
1,628 | allebb/git-version-number | src/Version.php | Version.getVersionString | public function getVersionString($bits = null)
{
if (is_null($bits)) {
return $this->version;
}
return implode('.', $this->versionFromBits($bits));
} | php | public function getVersionString($bits = null)
{
if (is_null($bits)) {
return $this->version;
}
return implode('.', $this->versionFromBits($bits));
} | [
"public",
"function",
"getVersionString",
"(",
"$",
"bits",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"bits",
")",
")",
"{",
"return",
"$",
"this",
"->",
"version",
";",
"}",
"return",
"implode",
"(",
"'.'",
",",
"$",
"this",
"->",
"versionFromBits",
"(",
"$",
"bits",
")",
")",
";",
"}"
] | Get the version number as a dot seperated string.
@param int $bits Optional version number bits to return.
@return string | [
"Get",
"the",
"version",
"number",
"as",
"a",
"dot",
"seperated",
"string",
"."
] | fc75f52e714d363627f02ff6df82e3097ffa7148 | https://github.com/allebb/git-version-number/blob/fc75f52e714d363627f02ff6df82e3097ffa7148/src/Version.php#L61-L67 |
1,629 | allebb/git-version-number | src/Version.php | Version.extractVersion | private function extractVersion()
{
$git = Executable::make($this->gitBin)
->addArgument(sprintf('--git-dir=%s', $this->gitPath))
->addArgument('describe')
->addArgument('--tags')
->addArgument('--always');
try {
$git->execute();
} catch (\Ballen\Executioner\Exceptions\ExecutionException $exception) {
// We could not obtain/execute the git command.
}
$version = trim($git->resultAsText());
$this->version = '0.0.0-0-' . $version;
if (strlen($version) > 7) {
$this->version = str_replace('v', '', $version);
}
$this->versionBits();
} | php | private function extractVersion()
{
$git = Executable::make($this->gitBin)
->addArgument(sprintf('--git-dir=%s', $this->gitPath))
->addArgument('describe')
->addArgument('--tags')
->addArgument('--always');
try {
$git->execute();
} catch (\Ballen\Executioner\Exceptions\ExecutionException $exception) {
// We could not obtain/execute the git command.
}
$version = trim($git->resultAsText());
$this->version = '0.0.0-0-' . $version;
if (strlen($version) > 7) {
$this->version = str_replace('v', '', $version);
}
$this->versionBits();
} | [
"private",
"function",
"extractVersion",
"(",
")",
"{",
"$",
"git",
"=",
"Executable",
"::",
"make",
"(",
"$",
"this",
"->",
"gitBin",
")",
"->",
"addArgument",
"(",
"sprintf",
"(",
"'--git-dir=%s'",
",",
"$",
"this",
"->",
"gitPath",
")",
")",
"->",
"addArgument",
"(",
"'describe'",
")",
"->",
"addArgument",
"(",
"'--tags'",
")",
"->",
"addArgument",
"(",
"'--always'",
")",
";",
"try",
"{",
"$",
"git",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Ballen",
"\\",
"Executioner",
"\\",
"Exceptions",
"\\",
"ExecutionException",
"$",
"exception",
")",
"{",
"// We could not obtain/execute the git command.",
"}",
"$",
"version",
"=",
"trim",
"(",
"$",
"git",
"->",
"resultAsText",
"(",
")",
")",
";",
"$",
"this",
"->",
"version",
"=",
"'0.0.0-0-'",
".",
"$",
"version",
";",
"if",
"(",
"strlen",
"(",
"$",
"version",
")",
">",
"7",
")",
"{",
"$",
"this",
"->",
"version",
"=",
"str_replace",
"(",
"'v'",
",",
"''",
",",
"$",
"version",
")",
";",
"}",
"$",
"this",
"->",
"versionBits",
"(",
")",
";",
"}"
] | Extracts the version from the Git repository.
@return void | [
"Extracts",
"the",
"version",
"from",
"the",
"Git",
"repository",
"."
] | fc75f52e714d363627f02ff6df82e3097ffa7148 | https://github.com/allebb/git-version-number/blob/fc75f52e714d363627f02ff6df82e3097ffa7148/src/Version.php#L122-L143 |
1,630 | allebb/git-version-number | src/Version.php | Version.versionBits | private function versionBits()
{
$versionBits = explode('-', $this->version);
if (strlen($versionBits[0])) {
$this->version = $versionBits[0];
if (isset($versionBits[1])) {
$this->version = $versionBits[0] . '.' . $versionBits[1];
}
if (isset($versionBits[2])) {
$this->hash = $versionBits[2];
}
}
} | php | private function versionBits()
{
$versionBits = explode('-', $this->version);
if (strlen($versionBits[0])) {
$this->version = $versionBits[0];
if (isset($versionBits[1])) {
$this->version = $versionBits[0] . '.' . $versionBits[1];
}
if (isset($versionBits[2])) {
$this->hash = $versionBits[2];
}
}
} | [
"private",
"function",
"versionBits",
"(",
")",
"{",
"$",
"versionBits",
"=",
"explode",
"(",
"'-'",
",",
"$",
"this",
"->",
"version",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"versionBits",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"version",
"=",
"$",
"versionBits",
"[",
"0",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"versionBits",
"[",
"1",
"]",
")",
")",
"{",
"$",
"this",
"->",
"version",
"=",
"$",
"versionBits",
"[",
"0",
"]",
".",
"'.'",
".",
"$",
"versionBits",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"versionBits",
"[",
"2",
"]",
")",
")",
"{",
"$",
"this",
"->",
"hash",
"=",
"$",
"versionBits",
"[",
"2",
"]",
";",
"}",
"}",
"}"
] | Computes and sets the version number and object hash properties.
@return void | [
"Computes",
"and",
"sets",
"the",
"version",
"number",
"and",
"object",
"hash",
"properties",
"."
] | fc75f52e714d363627f02ff6df82e3097ffa7148 | https://github.com/allebb/git-version-number/blob/fc75f52e714d363627f02ff6df82e3097ffa7148/src/Version.php#L149-L161 |
1,631 | allebb/git-version-number | src/Version.php | Version.versionFromBits | private function versionFromBits($bits)
{
$version = [];
foreach (range(0, ($bits - 1)) as $bit) {
$version[$bit] = $this->getVersionBits()[$bit];
}
return $version;
} | php | private function versionFromBits($bits)
{
$version = [];
foreach (range(0, ($bits - 1)) as $bit) {
$version[$bit] = $this->getVersionBits()[$bit];
}
return $version;
} | [
"private",
"function",
"versionFromBits",
"(",
"$",
"bits",
")",
"{",
"$",
"version",
"=",
"[",
"]",
";",
"foreach",
"(",
"range",
"(",
"0",
",",
"(",
"$",
"bits",
"-",
"1",
")",
")",
"as",
"$",
"bit",
")",
"{",
"$",
"version",
"[",
"$",
"bit",
"]",
"=",
"$",
"this",
"->",
"getVersionBits",
"(",
")",
"[",
"$",
"bit",
"]",
";",
"}",
"return",
"$",
"version",
";",
"}"
] | Returns an customised array of the total number of version bits.
@param int $bits The total number of bits (segments) to return.
@return array | [
"Returns",
"an",
"customised",
"array",
"of",
"the",
"total",
"number",
"of",
"version",
"bits",
"."
] | fc75f52e714d363627f02ff6df82e3097ffa7148 | https://github.com/allebb/git-version-number/blob/fc75f52e714d363627f02ff6df82e3097ffa7148/src/Version.php#L168-L175 |
1,632 | integratedfordevelopers/integrated-solr-bundle | DependencyInjection/IntegratedSolrExtension.php | IntegratedSolrExtension.load | public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('converter.xml');
$loader->load('event.xml');
$loader->load('event_listeners.xml');
$loader->load('command.xml');
$loader->load('indexer.xml');
$loader->load('queue.xml');
$loader->load('solarium.xml');
$loader->load('task.xml');
$loader->load('types.xml');
$loader->load('worker.xml');
if ($container->getParameter('kernel.debug')) {
$loader->load('collector.xml');
}
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$endpoints = [];
foreach ($config['endpoints'] as $name => $options) {
$options['key'] = $name;
$container->setDefinition(
'solarium.client.endpoint.' . $name,
new Definition(Endpoint::class, [$options])
);
$endpoints[] = new Reference('solarium.client.endpoint.' . $name);
}
$container->setDefinition(
'solarium.client',
new Definition(
Client::class,
[
['endpoint' => $endpoints],
new Reference('integrated_solr.event.dispatcher')
]
)
);
if ($container->getParameter('kernel.debug')) {
$container->getDefinition('solarium.client')->addMethodCall(
'registerPlugin',
['solarium.client.logger', new Reference('integrated_solr.solarium.data_collector')]
);
}
} | php | public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('converter.xml');
$loader->load('event.xml');
$loader->load('event_listeners.xml');
$loader->load('command.xml');
$loader->load('indexer.xml');
$loader->load('queue.xml');
$loader->load('solarium.xml');
$loader->load('task.xml');
$loader->load('types.xml');
$loader->load('worker.xml');
if ($container->getParameter('kernel.debug')) {
$loader->load('collector.xml');
}
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$endpoints = [];
foreach ($config['endpoints'] as $name => $options) {
$options['key'] = $name;
$container->setDefinition(
'solarium.client.endpoint.' . $name,
new Definition(Endpoint::class, [$options])
);
$endpoints[] = new Reference('solarium.client.endpoint.' . $name);
}
$container->setDefinition(
'solarium.client',
new Definition(
Client::class,
[
['endpoint' => $endpoints],
new Reference('integrated_solr.event.dispatcher')
]
)
);
if ($container->getParameter('kernel.debug')) {
$container->getDefinition('solarium.client')->addMethodCall(
'registerPlugin',
['solarium.client.logger', new Reference('integrated_solr.solarium.data_collector')]
);
}
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"loader",
"=",
"new",
"XmlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"__DIR__",
".",
"'/../Resources/config'",
")",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'converter.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'event.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'event_listeners.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'command.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'indexer.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'queue.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'solarium.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'task.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'types.xml'",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'worker.xml'",
")",
";",
"if",
"(",
"$",
"container",
"->",
"getParameter",
"(",
"'kernel.debug'",
")",
")",
"{",
"$",
"loader",
"->",
"load",
"(",
"'collector.xml'",
")",
";",
"}",
"$",
"configuration",
"=",
"new",
"Configuration",
"(",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"processConfiguration",
"(",
"$",
"configuration",
",",
"$",
"configs",
")",
";",
"$",
"endpoints",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"config",
"[",
"'endpoints'",
"]",
"as",
"$",
"name",
"=>",
"$",
"options",
")",
"{",
"$",
"options",
"[",
"'key'",
"]",
"=",
"$",
"name",
";",
"$",
"container",
"->",
"setDefinition",
"(",
"'solarium.client.endpoint.'",
".",
"$",
"name",
",",
"new",
"Definition",
"(",
"Endpoint",
"::",
"class",
",",
"[",
"$",
"options",
"]",
")",
")",
";",
"$",
"endpoints",
"[",
"]",
"=",
"new",
"Reference",
"(",
"'solarium.client.endpoint.'",
".",
"$",
"name",
")",
";",
"}",
"$",
"container",
"->",
"setDefinition",
"(",
"'solarium.client'",
",",
"new",
"Definition",
"(",
"Client",
"::",
"class",
",",
"[",
"[",
"'endpoint'",
"=>",
"$",
"endpoints",
"]",
",",
"new",
"Reference",
"(",
"'integrated_solr.event.dispatcher'",
")",
"]",
")",
")",
";",
"if",
"(",
"$",
"container",
"->",
"getParameter",
"(",
"'kernel.debug'",
")",
")",
"{",
"$",
"container",
"->",
"getDefinition",
"(",
"'solarium.client'",
")",
"->",
"addMethodCall",
"(",
"'registerPlugin'",
",",
"[",
"'solarium.client.logger'",
",",
"new",
"Reference",
"(",
"'integrated_solr.solarium.data_collector'",
")",
"]",
")",
";",
"}",
"}"
] | Load the configuration
@param array $configs
@param ContainerBuilder $container | [
"Load",
"the",
"configuration"
] | 9d9bb4071e13ed4686fbc97b6286a475ac5b2162 | https://github.com/integratedfordevelopers/integrated-solr-bundle/blob/9d9bb4071e13ed4686fbc97b6286a475ac5b2162/DependencyInjection/IntegratedSolrExtension.php#L37-L88 |
1,633 | xmmedia/XMSecurityBundle | Entity/User.php | User.setEmail | public function setEmail($email)
{
$email = is_null($email) ? '' : $email;
parent::setEmail($email);
$this->setUsername($email);
return $this;
} | php | public function setEmail($email)
{
$email = is_null($email) ? '' : $email;
parent::setEmail($email);
$this->setUsername($email);
return $this;
} | [
"public",
"function",
"setEmail",
"(",
"$",
"email",
")",
"{",
"$",
"email",
"=",
"is_null",
"(",
"$",
"email",
")",
"?",
"''",
":",
"$",
"email",
";",
"parent",
"::",
"setEmail",
"(",
"$",
"email",
")",
";",
"$",
"this",
"->",
"setUsername",
"(",
"$",
"email",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set email
Also sets the username to the email
@param string $email
@return User | [
"Set",
"email",
"Also",
"sets",
"the",
"username",
"to",
"the",
"email"
] | ee71a1bb4fe038e5a08e44f73247c4e03631a840 | https://github.com/xmmedia/XMSecurityBundle/blob/ee71a1bb4fe038e5a08e44f73247c4e03631a840/Entity/User.php#L103-L110 |
1,634 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/User/AbstractUser.php | AbstractUser.login | public function login($force=false) {
if( !$force && static::isLogged() ) {
static::throwException('alreadyLoggedin');
}
/**
* @var AbstractUser $USER
* @deprecated
*/
global $USER;
$_SESSION['USER'] = $USER = $this;
$this->login = $force ? self::LOGGED_FORCED : self::IS_LOGGED;
if( !$force ) {
static::logEvent('login');
}
static::logEvent('activity');
} | php | public function login($force=false) {
if( !$force && static::isLogged() ) {
static::throwException('alreadyLoggedin');
}
/**
* @var AbstractUser $USER
* @deprecated
*/
global $USER;
$_SESSION['USER'] = $USER = $this;
$this->login = $force ? self::LOGGED_FORCED : self::IS_LOGGED;
if( !$force ) {
static::logEvent('login');
}
static::logEvent('activity');
} | [
"public",
"function",
"login",
"(",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"force",
"&&",
"static",
"::",
"isLogged",
"(",
")",
")",
"{",
"static",
"::",
"throwException",
"(",
"'alreadyLoggedin'",
")",
";",
"}",
"/**\n\t\t * @var AbstractUser $USER\n\t\t * @deprecated\n\t\t */",
"global",
"$",
"USER",
";",
"$",
"_SESSION",
"[",
"'USER'",
"]",
"=",
"$",
"USER",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"login",
"=",
"$",
"force",
"?",
"self",
"::",
"LOGGED_FORCED",
":",
"self",
"::",
"IS_LOGGED",
";",
"if",
"(",
"!",
"$",
"force",
")",
"{",
"static",
"::",
"logEvent",
"(",
"'login'",
")",
";",
"}",
"static",
"::",
"logEvent",
"(",
"'activity'",
")",
";",
"}"
] | Log in this user to the current session.
@param string $force | [
"Log",
"in",
"this",
"user",
"to",
"the",
"current",
"session",
"."
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/User/AbstractUser.php#L110-L125 |
1,635 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/User/AbstractUser.php | AbstractUser.logout | public function logout($reason=null) {
global $USER;
if( !$this->login ) {
// debug('user is not logged in');
return false;
}
$this->login = self::NOT_LOGGED;
$_SESSION['USER'] = $USER = null;
$_SESSION['LOGOUT_REASON'] = $reason;
//debug('Session updated');
return true;
} | php | public function logout($reason=null) {
global $USER;
if( !$this->login ) {
// debug('user is not logged in');
return false;
}
$this->login = self::NOT_LOGGED;
$_SESSION['USER'] = $USER = null;
$_SESSION['LOGOUT_REASON'] = $reason;
//debug('Session updated');
return true;
} | [
"public",
"function",
"logout",
"(",
"$",
"reason",
"=",
"null",
")",
"{",
"global",
"$",
"USER",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"login",
")",
"{",
"// \t\t\tdebug('user is not logged in');",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"login",
"=",
"self",
"::",
"NOT_LOGGED",
";",
"$",
"_SESSION",
"[",
"'USER'",
"]",
"=",
"$",
"USER",
"=",
"null",
";",
"$",
"_SESSION",
"[",
"'LOGOUT_REASON'",
"]",
"=",
"$",
"reason",
";",
"//debug('Session updated');",
"return",
"true",
";",
"}"
] | Log out this user from the current session.
@param string $reason
@return boolean | [
"Log",
"out",
"this",
"user",
"from",
"the",
"current",
"session",
"."
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/User/AbstractUser.php#L133-L144 |
1,636 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/User/AbstractUser.php | AbstractUser.checkAccess | public function checkAccess($module) {
//$module pdoit être un nom de module.
if( !isset($GLOBALS['ACCESS']->$module) ) {
return true;
}
return $this->checkPerm((int) $GLOBALS['ACCESS']->$module);
} | php | public function checkAccess($module) {
//$module pdoit être un nom de module.
if( !isset($GLOBALS['ACCESS']->$module) ) {
return true;
}
return $this->checkPerm((int) $GLOBALS['ACCESS']->$module);
} | [
"public",
"function",
"checkAccess",
"(",
"$",
"module",
")",
"{",
"//$module pdoit être un nom de module.",
"if",
"(",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'ACCESS'",
"]",
"->",
"$",
"module",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"checkPerm",
"(",
"(",
"int",
")",
"$",
"GLOBALS",
"[",
"'ACCESS'",
"]",
"->",
"$",
"module",
")",
";",
"}"
] | Check access permissions
@param string $module The module to check
@return boolean True if this user has enough acess level to access to this module
@see checkPerm()
@warning Obsolete | [
"Check",
"access",
"permissions"
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/User/AbstractUser.php#L173-L179 |
1,637 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/User/AbstractUser.php | AbstractUser.canDo | public function canDo($action, $object=null) {
return $this->equals($object) || ( $this->checkPerm($action) && ( !($object instanceof AbstractUser) || $this->canAlter($object) ) );
} | php | public function canDo($action, $object=null) {
return $this->equals($object) || ( $this->checkPerm($action) && ( !($object instanceof AbstractUser) || $this->canAlter($object) ) );
} | [
"public",
"function",
"canDo",
"(",
"$",
"action",
",",
"$",
"object",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"equals",
"(",
"$",
"object",
")",
"||",
"(",
"$",
"this",
"->",
"checkPerm",
"(",
"$",
"action",
")",
"&&",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"AbstractUser",
")",
"||",
"$",
"this",
"->",
"canAlter",
"(",
"$",
"object",
")",
")",
")",
";",
"}"
] | Check if this user can affect data on the given user
@param string $action The action to look for
@param object $object The object we want to edit
@return boolean True if this user has enough access level to alter $object (or he is altering himself)
@see loggedCanDo()
@see canAlter()
Check if this user can affect $object. | [
"Check",
"if",
"this",
"user",
"can",
"affect",
"data",
"on",
"the",
"given",
"user"
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/User/AbstractUser.php#L215-L217 |
1,638 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/User/AbstractUser.php | AbstractUser.userLogin | public static function userLogin($data, $loginField='email') {
if( empty($data[$loginField]) ) {
static::throwException('invalidLoginID');
}
$name = $data[$loginField];
if( empty($data['password']) ) {
static::throwException('invalidPassword');
}
$password = hashString($data['password']);
//self::checkForEntry() does not return password and id now.
$user = static::get(array(
// 'where' => 'name LIKE '.static::formatValue($name),
'where' => static::formatValue($name).' IN ('.implode(',', static::listLoginFields()).')',
'number' => 1,
'output' => SQLAdapter::OBJECT
));
if( empty($user) ) {
static::throwException("invalidLoginID");
}
if( isset($user->published) && !$user->published ) {
static::throwException('forbiddenLogin');
}
if( $user->password != $password ) {
static::throwException('wrongPassword');
}
$user->logout();
$user->login();
return $user;
} | php | public static function userLogin($data, $loginField='email') {
if( empty($data[$loginField]) ) {
static::throwException('invalidLoginID');
}
$name = $data[$loginField];
if( empty($data['password']) ) {
static::throwException('invalidPassword');
}
$password = hashString($data['password']);
//self::checkForEntry() does not return password and id now.
$user = static::get(array(
// 'where' => 'name LIKE '.static::formatValue($name),
'where' => static::formatValue($name).' IN ('.implode(',', static::listLoginFields()).')',
'number' => 1,
'output' => SQLAdapter::OBJECT
));
if( empty($user) ) {
static::throwException("invalidLoginID");
}
if( isset($user->published) && !$user->published ) {
static::throwException('forbiddenLogin');
}
if( $user->password != $password ) {
static::throwException('wrongPassword');
}
$user->logout();
$user->login();
return $user;
} | [
"public",
"static",
"function",
"userLogin",
"(",
"$",
"data",
",",
"$",
"loginField",
"=",
"'email'",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"$",
"loginField",
"]",
")",
")",
"{",
"static",
"::",
"throwException",
"(",
"'invalidLoginID'",
")",
";",
"}",
"$",
"name",
"=",
"$",
"data",
"[",
"$",
"loginField",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'password'",
"]",
")",
")",
"{",
"static",
"::",
"throwException",
"(",
"'invalidPassword'",
")",
";",
"}",
"$",
"password",
"=",
"hashString",
"(",
"$",
"data",
"[",
"'password'",
"]",
")",
";",
"//self::checkForEntry() does not return password and id now.",
"$",
"user",
"=",
"static",
"::",
"get",
"(",
"array",
"(",
"// \t\t\t'where' => 'name LIKE '.static::formatValue($name),",
"'where'",
"=>",
"static",
"::",
"formatValue",
"(",
"$",
"name",
")",
".",
"' IN ('",
".",
"implode",
"(",
"','",
",",
"static",
"::",
"listLoginFields",
"(",
")",
")",
".",
"')'",
",",
"'number'",
"=>",
"1",
",",
"'output'",
"=>",
"SQLAdapter",
"::",
"OBJECT",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"user",
")",
")",
"{",
"static",
"::",
"throwException",
"(",
"\"invalidLoginID\"",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"user",
"->",
"published",
")",
"&&",
"!",
"$",
"user",
"->",
"published",
")",
"{",
"static",
"::",
"throwException",
"(",
"'forbiddenLogin'",
")",
";",
"}",
"if",
"(",
"$",
"user",
"->",
"password",
"!=",
"$",
"password",
")",
"{",
"static",
"::",
"throwException",
"(",
"'wrongPassword'",
")",
";",
"}",
"$",
"user",
"->",
"logout",
"(",
")",
";",
"$",
"user",
"->",
"login",
"(",
")",
";",
"return",
"$",
"user",
";",
"}"
] | Logs in an user using data
@param array $data
@param string $loginField
@return \Orpheus\SQLRequest\SQLSelectRequest|\Orpheus\EntityDescriptor\User\AbstractUser|\Orpheus\Publisher\PermanentObject\static[] | [
"Logs",
"in",
"an",
"user",
"using",
"data"
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/User/AbstractUser.php#L226-L255 |
1,639 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/User/AbstractUser.php | AbstractUser.httpLogin | public static function httpLogin() {
$user = static::get(array(
'where' => 'name LIKE '.static::formatValue($_SERVER['PHP_AUTH_USER']),
// 'number' => 1,
'output' => SQLAdapter::OBJECT
));
if( empty($user) ) {
static::throwNotFound();
}
if( $user->password != static::hashPassword($_SERVER['PHP_AUTH_PW']) ) {
static::throwException("wrongPassword");
}
$user->logout();
$user->login();
} | php | public static function httpLogin() {
$user = static::get(array(
'where' => 'name LIKE '.static::formatValue($_SERVER['PHP_AUTH_USER']),
// 'number' => 1,
'output' => SQLAdapter::OBJECT
));
if( empty($user) ) {
static::throwNotFound();
}
if( $user->password != static::hashPassword($_SERVER['PHP_AUTH_PW']) ) {
static::throwException("wrongPassword");
}
$user->logout();
$user->login();
} | [
"public",
"static",
"function",
"httpLogin",
"(",
")",
"{",
"$",
"user",
"=",
"static",
"::",
"get",
"(",
"array",
"(",
"'where'",
"=>",
"'name LIKE '",
".",
"static",
"::",
"formatValue",
"(",
"$",
"_SERVER",
"[",
"'PHP_AUTH_USER'",
"]",
")",
",",
"// \t\t\t'number' => 1,",
"'output'",
"=>",
"SQLAdapter",
"::",
"OBJECT",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"user",
")",
")",
"{",
"static",
"::",
"throwNotFound",
"(",
")",
";",
"}",
"if",
"(",
"$",
"user",
"->",
"password",
"!=",
"static",
"::",
"hashPassword",
"(",
"$",
"_SERVER",
"[",
"'PHP_AUTH_PW'",
"]",
")",
")",
"{",
"static",
"::",
"throwException",
"(",
"\"wrongPassword\"",
")",
";",
"}",
"$",
"user",
"->",
"logout",
"(",
")",
";",
"$",
"user",
"->",
"login",
"(",
")",
";",
"}"
] | Log in an user from HTTP authentication according to server variables PHP_AUTH_USER and PHP_AUTH_PW | [
"Log",
"in",
"an",
"user",
"from",
"HTTP",
"authentication",
"according",
"to",
"server",
"variables",
"PHP_AUTH_USER",
"and",
"PHP_AUTH_PW"
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/User/AbstractUser.php#L279-L293 |
1,640 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/User/AbstractUser.php | AbstractUser.httpAuthenticate | public static function httpAuthenticate() {
try {
static::httpLogin();
return true;
} catch( NotFoundException $e ) {
if( Config::get('httpauth_autocreate') ) {
$user = static::httpCreate();
$user->login();
return true;
}
} catch( UserException $e ) { }
return false;
} | php | public static function httpAuthenticate() {
try {
static::httpLogin();
return true;
} catch( NotFoundException $e ) {
if( Config::get('httpauth_autocreate') ) {
$user = static::httpCreate();
$user->login();
return true;
}
} catch( UserException $e ) { }
return false;
} | [
"public",
"static",
"function",
"httpAuthenticate",
"(",
")",
"{",
"try",
"{",
"static",
"::",
"httpLogin",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"NotFoundException",
"$",
"e",
")",
"{",
"if",
"(",
"Config",
"::",
"get",
"(",
"'httpauth_autocreate'",
")",
")",
"{",
"$",
"user",
"=",
"static",
"::",
"httpCreate",
"(",
")",
";",
"$",
"user",
"->",
"login",
"(",
")",
";",
"return",
"true",
";",
"}",
"}",
"catch",
"(",
"UserException",
"$",
"e",
")",
"{",
"}",
"return",
"false",
";",
"}"
] | Login from HTTP authentication, create user if not existing
@return boolean
@warning Require other data than name and password are optional
Create user from HTTP authentication | [
"Login",
"from",
"HTTP",
"authentication",
"create",
"user",
"if",
"not",
"existing"
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/User/AbstractUser.php#L315-L327 |
1,641 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/User/AbstractUser.php | AbstractUser.load | public static function load($id, $nullable=true, $usingCache=true) {
if( static::getLoggedUserID() == $id ) {
return $GLOBALS['USER'];
}
return parent::load($id, $nullable, $usingCache);
} | php | public static function load($id, $nullable=true, $usingCache=true) {
if( static::getLoggedUserID() == $id ) {
return $GLOBALS['USER'];
}
return parent::load($id, $nullable, $usingCache);
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"id",
",",
"$",
"nullable",
"=",
"true",
",",
"$",
"usingCache",
"=",
"true",
")",
"{",
"if",
"(",
"static",
"::",
"getLoggedUserID",
"(",
")",
"==",
"$",
"id",
")",
"{",
"return",
"$",
"GLOBALS",
"[",
"'USER'",
"]",
";",
"}",
"return",
"parent",
"::",
"load",
"(",
"$",
"id",
",",
"$",
"nullable",
",",
"$",
"usingCache",
")",
";",
"}"
] | Load an user object
@param mixed|mixed[] $id The object ID to load or a valid array of the object's data
@param boolean $nullable True to silent errors row and return null
@param boolean $usingCache True to cache load and set cache, false to not cache
@return PermanentObject The object
It tries to optimize by getting directly the logged user if he has the same ID. | [
"Load",
"an",
"user",
"object"
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/User/AbstractUser.php#L384-L389 |
1,642 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/User/AbstractUser.php | AbstractUser.loggedCanAccessToRoute | public static function loggedCanAccessToRoute($route, $accesslevel) {
$user = static::getLoggedUser();
if( !ctype_digit($accesslevel) ) {
$accesslevel = static::getRoleAccesslevel($accesslevel);
}
$accesslevel = (int) $accesslevel;
return ( empty($user) && $accesslevel < 0 ) ||
( !empty($user) && $accesslevel >= 0 &&
$user instanceof AbstractUser && $user->checkPerm($accesslevel));
} | php | public static function loggedCanAccessToRoute($route, $accesslevel) {
$user = static::getLoggedUser();
if( !ctype_digit($accesslevel) ) {
$accesslevel = static::getRoleAccesslevel($accesslevel);
}
$accesslevel = (int) $accesslevel;
return ( empty($user) && $accesslevel < 0 ) ||
( !empty($user) && $accesslevel >= 0 &&
$user instanceof AbstractUser && $user->checkPerm($accesslevel));
} | [
"public",
"static",
"function",
"loggedCanAccessToRoute",
"(",
"$",
"route",
",",
"$",
"accesslevel",
")",
"{",
"$",
"user",
"=",
"static",
"::",
"getLoggedUser",
"(",
")",
";",
"if",
"(",
"!",
"ctype_digit",
"(",
"$",
"accesslevel",
")",
")",
"{",
"$",
"accesslevel",
"=",
"static",
"::",
"getRoleAccesslevel",
"(",
"$",
"accesslevel",
")",
";",
"}",
"$",
"accesslevel",
"=",
"(",
"int",
")",
"$",
"accesslevel",
";",
"return",
"(",
"empty",
"(",
"$",
"user",
")",
"&&",
"$",
"accesslevel",
"<",
"0",
")",
"||",
"(",
"!",
"empty",
"(",
"$",
"user",
")",
"&&",
"$",
"accesslevel",
">=",
"0",
"&&",
"$",
"user",
"instanceof",
"AbstractUser",
"&&",
"$",
"user",
"->",
"checkPerm",
"(",
"$",
"accesslevel",
")",
")",
";",
"}"
] | Check if this user can access to a module
@param string $route The route to look for
@param int $accesslevel The access level
@return boolean True if this user can access to $module | [
"Check",
"if",
"this",
"user",
"can",
"access",
"to",
"a",
"module"
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/User/AbstractUser.php#L411-L420 |
1,643 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/User/AbstractUser.php | AbstractUser.loggedHasDeveloperAccess | public static function loggedHasDeveloperAccess() {
$user = static::getLoggedUser();
$requiredAccessLevel = (int) static::getRoleAccesslevel('developer');
return $user && $user->checkPerm($requiredAccessLevel);
} | php | public static function loggedHasDeveloperAccess() {
$user = static::getLoggedUser();
$requiredAccessLevel = (int) static::getRoleAccesslevel('developer');
return $user && $user->checkPerm($requiredAccessLevel);
} | [
"public",
"static",
"function",
"loggedHasDeveloperAccess",
"(",
")",
"{",
"$",
"user",
"=",
"static",
"::",
"getLoggedUser",
"(",
")",
";",
"$",
"requiredAccessLevel",
"=",
"(",
"int",
")",
"static",
"::",
"getRoleAccesslevel",
"(",
"'developer'",
")",
";",
"return",
"$",
"user",
"&&",
"$",
"user",
"->",
"checkPerm",
"(",
"$",
"requiredAccessLevel",
")",
";",
"}"
] | Check if this user has developer access
@return boolean True if this user has developer access | [
"Check",
"if",
"this",
"user",
"has",
"developer",
"access"
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/User/AbstractUser.php#L427-L431 |
1,644 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/User/AbstractUser.php | AbstractUser.loggedCanDo | public static function loggedCanDo($action, AbstractUser $object=null) {
global $USER;
return !empty($USER) && $USER->canDo($action, $object);
} | php | public static function loggedCanDo($action, AbstractUser $object=null) {
global $USER;
return !empty($USER) && $USER->canDo($action, $object);
} | [
"public",
"static",
"function",
"loggedCanDo",
"(",
"$",
"action",
",",
"AbstractUser",
"$",
"object",
"=",
"null",
")",
"{",
"global",
"$",
"USER",
";",
"return",
"!",
"empty",
"(",
"$",
"USER",
")",
"&&",
"$",
"USER",
"->",
"canDo",
"(",
"$",
"action",
",",
"$",
"object",
")",
";",
"}"
] | Check if this user can do a restricted action
@param string $action The action to look for
@param AbstractUser $object The object to edit if editing one or null. Default value is null
@return boolean True if this user can do this $action | [
"Check",
"if",
"this",
"user",
"can",
"do",
"a",
"restricted",
"action"
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/User/AbstractUser.php#L469-L472 |
1,645 | Sowapps/orpheus-entitydescriptor | src/EntityDescriptor/User/AbstractUser.php | AbstractUser.checkForObject | public static function checkForObject($data, $ref=null) {
if( empty($data['email']) ) {
return;//Nothing to check. Email is mandatory.
}
$where = 'email LIKE '.static::formatValue($data['email']);
$what = 'email';
if( !empty($data['name']) ) {
$what .= ', name';
$where .= ' OR name LIKE '.static::formatValue($data['name']);
}
$user = static::get(array(
'what' => $what,
'where' => $where,
'output' => SQLAdapter::ARR_FIRST
));
if( !empty($user) ) {
if( $user['email'] === $data['email'] ) {
static::throwException("emailAlreadyUsed");
} else {
static::throwException("entryExisting");
}
}
} | php | public static function checkForObject($data, $ref=null) {
if( empty($data['email']) ) {
return;//Nothing to check. Email is mandatory.
}
$where = 'email LIKE '.static::formatValue($data['email']);
$what = 'email';
if( !empty($data['name']) ) {
$what .= ', name';
$where .= ' OR name LIKE '.static::formatValue($data['name']);
}
$user = static::get(array(
'what' => $what,
'where' => $where,
'output' => SQLAdapter::ARR_FIRST
));
if( !empty($user) ) {
if( $user['email'] === $data['email'] ) {
static::throwException("emailAlreadyUsed");
} else {
static::throwException("entryExisting");
}
}
} | [
"public",
"static",
"function",
"checkForObject",
"(",
"$",
"data",
",",
"$",
"ref",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'email'",
"]",
")",
")",
"{",
"return",
";",
"//Nothing to check. Email is mandatory.",
"}",
"$",
"where",
"=",
"'email LIKE '",
".",
"static",
"::",
"formatValue",
"(",
"$",
"data",
"[",
"'email'",
"]",
")",
";",
"$",
"what",
"=",
"'email'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"what",
".=",
"', name'",
";",
"$",
"where",
".=",
"' OR name LIKE '",
".",
"static",
"::",
"formatValue",
"(",
"$",
"data",
"[",
"'name'",
"]",
")",
";",
"}",
"$",
"user",
"=",
"static",
"::",
"get",
"(",
"array",
"(",
"'what'",
"=>",
"$",
"what",
",",
"'where'",
"=>",
"$",
"where",
",",
"'output'",
"=>",
"SQLAdapter",
"::",
"ARR_FIRST",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"user",
")",
")",
"{",
"if",
"(",
"$",
"user",
"[",
"'email'",
"]",
"===",
"$",
"data",
"[",
"'email'",
"]",
")",
"{",
"static",
"::",
"throwException",
"(",
"\"emailAlreadyUsed\"",
")",
";",
"}",
"else",
"{",
"static",
"::",
"throwException",
"(",
"\"entryExisting\"",
")",
";",
"}",
"}",
"}"
] | Check for object
@param $data The new data to process.
@param $ref The referenced object (update only). Default value is null.
@see create()
@see update()
This function is called by create() after checking user input data and before running for them.
In the base class, this method does nothing. | [
"Check",
"for",
"object"
] | b9cc04c42e7955b11f37a70ee7cd2a518f5983b2 | https://github.com/Sowapps/orpheus-entitydescriptor/blob/b9cc04c42e7955b11f37a70ee7cd2a518f5983b2/src/EntityDescriptor/User/AbstractUser.php#L485-L508 |
1,646 | nattreid/latte | src/Filters.php | Filters.localeNumber | private static function localeNumber($number, int $decimal = 2): string
{
return Number::getNumber(self::prepareFloat($number), $decimal);
} | php | private static function localeNumber($number, int $decimal = 2): string
{
return Number::getNumber(self::prepareFloat($number), $decimal);
} | [
"private",
"static",
"function",
"localeNumber",
"(",
"$",
"number",
",",
"int",
"$",
"decimal",
"=",
"2",
")",
":",
"string",
"{",
"return",
"Number",
"::",
"getNumber",
"(",
"self",
"::",
"prepareFloat",
"(",
"$",
"number",
")",
",",
"$",
"decimal",
")",
";",
"}"
] | Vrati zformatovane cislo
@param float|string|null $number
@param int $decimal
@return string | [
"Vrati",
"zformatovane",
"cislo"
] | f80f8de758b259c320dca0eb68d8b39982a1e172 | https://github.com/nattreid/latte/blob/f80f8de758b259c320dca0eb68d8b39982a1e172/src/Filters.php#L57-L60 |
1,647 | nattreid/latte | src/Filters.php | Filters.localeDateTime | private static function localeDateTime($datetime, bool $withSeconds = false): string
{
return Date::getDateTime($datetime, $withSeconds);
} | php | private static function localeDateTime($datetime, bool $withSeconds = false): string
{
return Date::getDateTime($datetime, $withSeconds);
} | [
"private",
"static",
"function",
"localeDateTime",
"(",
"$",
"datetime",
",",
"bool",
"$",
"withSeconds",
"=",
"false",
")",
":",
"string",
"{",
"return",
"Date",
"::",
"getDateTime",
"(",
"$",
"datetime",
",",
"$",
"withSeconds",
")",
";",
"}"
] | Lokalizovane datum s casem
@param Datetime|int $datetime
@param bool $withSeconds
@return string | [
"Lokalizovane",
"datum",
"s",
"casem"
] | f80f8de758b259c320dca0eb68d8b39982a1e172 | https://github.com/nattreid/latte/blob/f80f8de758b259c320dca0eb68d8b39982a1e172/src/Filters.php#L102-L105 |
1,648 | cosmow/riak | lib/CosmoW/Riak/Collection.php | Collection.aggregate | public function aggregate(array $pipeline, array $options = array() /* , array $op, ... */)
{
/* If the single array argument contains a zeroth index, consider it an
* array of pipeline operators. Otherwise, assume that each argument is
* a pipeline operator.
*/
if ( ! array_key_exists(0, $pipeline)) {
$pipeline = func_get_args();
$options = array();
}
if ($this->eventManager->hasListeners(Events::preAggregate)) {
$this->eventManager->dispatchEvent(Events::preAggregate, new AggregateEventArgs($this, $pipeline, $options));
}
$result = $this->doAggregate($pipeline, $options);
if ($this->eventManager->hasListeners(Events::postAggregate)) {
$eventArgs = new MutableEventArgs($this, $result);
$this->eventManager->dispatchEvent(Events::postAggregate, $eventArgs);
$result = $eventArgs->getData();
}
return $result;
} | php | public function aggregate(array $pipeline, array $options = array() /* , array $op, ... */)
{
/* If the single array argument contains a zeroth index, consider it an
* array of pipeline operators. Otherwise, assume that each argument is
* a pipeline operator.
*/
if ( ! array_key_exists(0, $pipeline)) {
$pipeline = func_get_args();
$options = array();
}
if ($this->eventManager->hasListeners(Events::preAggregate)) {
$this->eventManager->dispatchEvent(Events::preAggregate, new AggregateEventArgs($this, $pipeline, $options));
}
$result = $this->doAggregate($pipeline, $options);
if ($this->eventManager->hasListeners(Events::postAggregate)) {
$eventArgs = new MutableEventArgs($this, $result);
$this->eventManager->dispatchEvent(Events::postAggregate, $eventArgs);
$result = $eventArgs->getData();
}
return $result;
} | [
"public",
"function",
"aggregate",
"(",
"array",
"$",
"pipeline",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
"/* , array $op, ... */",
")",
"{",
"/* If the single array argument contains a zeroth index, consider it an\n * array of pipeline operators. Otherwise, assume that each argument is\n * a pipeline operator.\n */",
"if",
"(",
"!",
"array_key_exists",
"(",
"0",
",",
"$",
"pipeline",
")",
")",
"{",
"$",
"pipeline",
"=",
"func_get_args",
"(",
")",
";",
"$",
"options",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"eventManager",
"->",
"hasListeners",
"(",
"Events",
"::",
"preAggregate",
")",
")",
"{",
"$",
"this",
"->",
"eventManager",
"->",
"dispatchEvent",
"(",
"Events",
"::",
"preAggregate",
",",
"new",
"AggregateEventArgs",
"(",
"$",
"this",
",",
"$",
"pipeline",
",",
"$",
"options",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"doAggregate",
"(",
"$",
"pipeline",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"this",
"->",
"eventManager",
"->",
"hasListeners",
"(",
"Events",
"::",
"postAggregate",
")",
")",
"{",
"$",
"eventArgs",
"=",
"new",
"MutableEventArgs",
"(",
"$",
"this",
",",
"$",
"result",
")",
";",
"$",
"this",
"->",
"eventManager",
"->",
"dispatchEvent",
"(",
"Events",
"::",
"postAggregate",
",",
"$",
"eventArgs",
")",
";",
"$",
"result",
"=",
"$",
"eventArgs",
"->",
"getData",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Invokes the aggregate command.
This method will dispatch preAggregate and postAggregate events.
By default, the results from a non-cursor aggregate command will be
returned as an ArrayIterator; however, if the pipeline ends in an $out
operator, a cursor on the output collection will be returned instead.
If the "cursor" option is true or an array, a command cursor will be
returned (requires driver >= 1.5.0 and Riak >= 2.6).
@see http://php.net/manual/en/mongocollection.aggregate.php
@see http://docs.mongodb.org/manual/reference/command/aggregate/
@param array $pipeline Array of pipeline operators, or the first operator
@param array $options Command options (if $pipeline was an array of pipeline operators)
@param array $op,... Additional operators (if $pipeline was the first)
@return Iterator
@throws ResultException if the command fails | [
"Invokes",
"the",
"aggregate",
"command",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Collection.php#L111-L135 |
1,649 | cosmow/riak | lib/CosmoW/Riak/Collection.php | Collection.count | public function count(array $query = array(), $limitOrOptions = 0, $skip = 0)
{
$options = is_array($limitOrOptions)
? array_merge(array('limit' => 0, 'skip' => 0), $limitOrOptions)
: array('limit' => $limitOrOptions, 'skip' => $skip);
$options['limit'] = (integer) $options['limit'];
$options['skip'] = (integer) $options['skip'];
return $this->doCount($query, $options);
} | php | public function count(array $query = array(), $limitOrOptions = 0, $skip = 0)
{
$options = is_array($limitOrOptions)
? array_merge(array('limit' => 0, 'skip' => 0), $limitOrOptions)
: array('limit' => $limitOrOptions, 'skip' => $skip);
$options['limit'] = (integer) $options['limit'];
$options['skip'] = (integer) $options['skip'];
return $this->doCount($query, $options);
} | [
"public",
"function",
"count",
"(",
"array",
"$",
"query",
"=",
"array",
"(",
")",
",",
"$",
"limitOrOptions",
"=",
"0",
",",
"$",
"skip",
"=",
"0",
")",
"{",
"$",
"options",
"=",
"is_array",
"(",
"$",
"limitOrOptions",
")",
"?",
"array_merge",
"(",
"array",
"(",
"'limit'",
"=>",
"0",
",",
"'skip'",
"=>",
"0",
")",
",",
"$",
"limitOrOptions",
")",
":",
"array",
"(",
"'limit'",
"=>",
"$",
"limitOrOptions",
",",
"'skip'",
"=>",
"$",
"skip",
")",
";",
"$",
"options",
"[",
"'limit'",
"]",
"=",
"(",
"integer",
")",
"$",
"options",
"[",
"'limit'",
"]",
";",
"$",
"options",
"[",
"'skip'",
"]",
"=",
"(",
"integer",
")",
"$",
"options",
"[",
"'skip'",
"]",
";",
"return",
"$",
"this",
"->",
"doCount",
"(",
"$",
"query",
",",
"$",
"options",
")",
";",
"}"
] | Invokes the count command.
@see http://php.net/manual/en/mongocollection.count.php
@see http://docs.mongodb.org/manual/reference/command/count/
@param array $query
@param integer|array $limitOrOptions Limit or options array
@param integer $skip
@return integer | [
"Invokes",
"the",
"count",
"command",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Collection.php#L174-L184 |
1,650 | cosmow/riak | lib/CosmoW/Riak/Collection.php | Collection.distinct | public function distinct($field, array $query = array(), array $options = array())
{
if ($this->eventManager->hasListeners(Events::preDistinct)) {
/* The distinct command currently does not have options beyond field
* and query, so do not include it in the event args.
*/
$this->eventManager->dispatchEvent(Events::preDistinct, new DistinctEventArgs($this, $field, $query));
}
$result = $this->doDistinct($field, $query, $options);
if ($this->eventManager->hasListeners(Events::postDistinct)) {
$eventArgs = new MutableEventArgs($this, $result);
$this->eventManager->dispatchEvent(Events::postDistinct, $eventArgs);
$result = $eventArgs->getData();
}
return $result;
} | php | public function distinct($field, array $query = array(), array $options = array())
{
if ($this->eventManager->hasListeners(Events::preDistinct)) {
/* The distinct command currently does not have options beyond field
* and query, so do not include it in the event args.
*/
$this->eventManager->dispatchEvent(Events::preDistinct, new DistinctEventArgs($this, $field, $query));
}
$result = $this->doDistinct($field, $query, $options);
if ($this->eventManager->hasListeners(Events::postDistinct)) {
$eventArgs = new MutableEventArgs($this, $result);
$this->eventManager->dispatchEvent(Events::postDistinct, $eventArgs);
$result = $eventArgs->getData();
}
return $result;
} | [
"public",
"function",
"distinct",
"(",
"$",
"field",
",",
"array",
"$",
"query",
"=",
"array",
"(",
")",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"eventManager",
"->",
"hasListeners",
"(",
"Events",
"::",
"preDistinct",
")",
")",
"{",
"/* The distinct command currently does not have options beyond field\n * and query, so do not include it in the event args.\n */",
"$",
"this",
"->",
"eventManager",
"->",
"dispatchEvent",
"(",
"Events",
"::",
"preDistinct",
",",
"new",
"DistinctEventArgs",
"(",
"$",
"this",
",",
"$",
"field",
",",
"$",
"query",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"doDistinct",
"(",
"$",
"field",
",",
"$",
"query",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"this",
"->",
"eventManager",
"->",
"hasListeners",
"(",
"Events",
"::",
"postDistinct",
")",
")",
"{",
"$",
"eventArgs",
"=",
"new",
"MutableEventArgs",
"(",
"$",
"this",
",",
"$",
"result",
")",
";",
"$",
"this",
"->",
"eventManager",
"->",
"dispatchEvent",
"(",
"Events",
"::",
"postDistinct",
",",
"$",
"eventArgs",
")",
";",
"$",
"result",
"=",
"$",
"eventArgs",
"->",
"getData",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Invokes the distinct command.
This method will dispatch preDistinct and postDistinct events.
@see http://php.net/manual/en/mongocollection.distinct.php
@see http://docs.mongodb.org/manual/reference/command/distinct/
@param string $field
@param array $query
@param array $options
@return ArrayIterator
@throws ResultException if the command fails | [
"Invokes",
"the",
"distinct",
"command",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Collection.php#L254-L272 |
1,651 | cosmow/riak | lib/CosmoW/Riak/Collection.php | Collection.near | public function near($near, array $query = array(), array $options = array())
{
if ($this->eventManager->hasListeners(Events::preNear)) {
$this->eventManager->dispatchEvent(Events::preNear, new NearEventArgs($this, $query, $near, $options));
}
$result = $this->doNear($near, $query, $options);
if ($this->eventManager->hasListeners(Events::postNear)) {
$eventArgs = new MutableEventArgs($this, $result);
$this->eventManager->dispatchEvent(Events::postNear, $eventArgs);
$result = $eventArgs->getData();
}
return $result;
} | php | public function near($near, array $query = array(), array $options = array())
{
if ($this->eventManager->hasListeners(Events::preNear)) {
$this->eventManager->dispatchEvent(Events::preNear, new NearEventArgs($this, $query, $near, $options));
}
$result = $this->doNear($near, $query, $options);
if ($this->eventManager->hasListeners(Events::postNear)) {
$eventArgs = new MutableEventArgs($this, $result);
$this->eventManager->dispatchEvent(Events::postNear, $eventArgs);
$result = $eventArgs->getData();
}
return $result;
} | [
"public",
"function",
"near",
"(",
"$",
"near",
",",
"array",
"$",
"query",
"=",
"array",
"(",
")",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"eventManager",
"->",
"hasListeners",
"(",
"Events",
"::",
"preNear",
")",
")",
"{",
"$",
"this",
"->",
"eventManager",
"->",
"dispatchEvent",
"(",
"Events",
"::",
"preNear",
",",
"new",
"NearEventArgs",
"(",
"$",
"this",
",",
"$",
"query",
",",
"$",
"near",
",",
"$",
"options",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"doNear",
"(",
"$",
"near",
",",
"$",
"query",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"this",
"->",
"eventManager",
"->",
"hasListeners",
"(",
"Events",
"::",
"postNear",
")",
")",
"{",
"$",
"eventArgs",
"=",
"new",
"MutableEventArgs",
"(",
"$",
"this",
",",
"$",
"result",
")",
";",
"$",
"this",
"->",
"eventManager",
"->",
"dispatchEvent",
"(",
"Events",
"::",
"postNear",
",",
"$",
"eventArgs",
")",
";",
"$",
"result",
"=",
"$",
"eventArgs",
"->",
"getData",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Invokes the geoNear command.
This method will dispatch preNear and postNear events.
The $near parameter may be a GeoJSON point or a legacy coordinate pair,
which is an array of float values in x, y order (easting, northing for
projected coordinates, longitude, latitude for geographic coordinates).
A GeoJSON point may be a Point object or an array corresponding to the
point's JSON representation.
@see http://docs.mongodb.org/manual/reference/command/geoNear/
@param array|Point $near
@param array $query
@param array $options
@return ArrayIterator
@throws ResultException if the command fails | [
"Invokes",
"the",
"geoNear",
"command",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Collection.php#L706-L721 |
1,652 | cosmow/riak | lib/CosmoW/Riak/Collection.php | Collection.doAggregate | protected function doAggregate(array $pipeline, array $options = array())
{
if (isset($options['cursor']) && ($options['cursor'] || is_array($options['cursor']))) {
return $this->doAggregateCursor($pipeline, $options);
}
unset($options['cursor']);
list($commandOptions, $clientOptions) = isset($options['socketTimeoutMS']) || isset($options['timeout'])
? $this->splitCommandAndClientOptions($options)
: array($options, array());
$command = array();
$command['aggregate'] = $this->riakCollection->getName();
$command['pipeline'] = $pipeline;
$command = array_merge($command, $commandOptions);
$database = $this->database;
$result = $this->retry(function() use ($database, $command, $clientOptions) {
return $database->command($command, $clientOptions);
});
if (empty($result['ok'])) {
throw new ResultException($result);
}
/* If the pipeline ends with an $out operator, return a cursor on that
* collection so a table scan may be performed.
*/
if (isset($pipeline[count($pipeline) - 1]['$out'])) {
$outputCollection = $pipeline[count($pipeline) - 1]['$out'];
return $database->selectCollection($outputCollection)->find();
}
$arrayIterator = new ArrayIterator(isset($result['result']) ? $result['result'] : array());
$arrayIterator->setCommandResult($result);
return $arrayIterator;
} | php | protected function doAggregate(array $pipeline, array $options = array())
{
if (isset($options['cursor']) && ($options['cursor'] || is_array($options['cursor']))) {
return $this->doAggregateCursor($pipeline, $options);
}
unset($options['cursor']);
list($commandOptions, $clientOptions) = isset($options['socketTimeoutMS']) || isset($options['timeout'])
? $this->splitCommandAndClientOptions($options)
: array($options, array());
$command = array();
$command['aggregate'] = $this->riakCollection->getName();
$command['pipeline'] = $pipeline;
$command = array_merge($command, $commandOptions);
$database = $this->database;
$result = $this->retry(function() use ($database, $command, $clientOptions) {
return $database->command($command, $clientOptions);
});
if (empty($result['ok'])) {
throw new ResultException($result);
}
/* If the pipeline ends with an $out operator, return a cursor on that
* collection so a table scan may be performed.
*/
if (isset($pipeline[count($pipeline) - 1]['$out'])) {
$outputCollection = $pipeline[count($pipeline) - 1]['$out'];
return $database->selectCollection($outputCollection)->find();
}
$arrayIterator = new ArrayIterator(isset($result['result']) ? $result['result'] : array());
$arrayIterator->setCommandResult($result);
return $arrayIterator;
} | [
"protected",
"function",
"doAggregate",
"(",
"array",
"$",
"pipeline",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'cursor'",
"]",
")",
"&&",
"(",
"$",
"options",
"[",
"'cursor'",
"]",
"||",
"is_array",
"(",
"$",
"options",
"[",
"'cursor'",
"]",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"doAggregateCursor",
"(",
"$",
"pipeline",
",",
"$",
"options",
")",
";",
"}",
"unset",
"(",
"$",
"options",
"[",
"'cursor'",
"]",
")",
";",
"list",
"(",
"$",
"commandOptions",
",",
"$",
"clientOptions",
")",
"=",
"isset",
"(",
"$",
"options",
"[",
"'socketTimeoutMS'",
"]",
")",
"||",
"isset",
"(",
"$",
"options",
"[",
"'timeout'",
"]",
")",
"?",
"$",
"this",
"->",
"splitCommandAndClientOptions",
"(",
"$",
"options",
")",
":",
"array",
"(",
"$",
"options",
",",
"array",
"(",
")",
")",
";",
"$",
"command",
"=",
"array",
"(",
")",
";",
"$",
"command",
"[",
"'aggregate'",
"]",
"=",
"$",
"this",
"->",
"riakCollection",
"->",
"getName",
"(",
")",
";",
"$",
"command",
"[",
"'pipeline'",
"]",
"=",
"$",
"pipeline",
";",
"$",
"command",
"=",
"array_merge",
"(",
"$",
"command",
",",
"$",
"commandOptions",
")",
";",
"$",
"database",
"=",
"$",
"this",
"->",
"database",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"retry",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"database",
",",
"$",
"command",
",",
"$",
"clientOptions",
")",
"{",
"return",
"$",
"database",
"->",
"command",
"(",
"$",
"command",
",",
"$",
"clientOptions",
")",
";",
"}",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
"[",
"'ok'",
"]",
")",
")",
"{",
"throw",
"new",
"ResultException",
"(",
"$",
"result",
")",
";",
"}",
"/* If the pipeline ends with an $out operator, return a cursor on that\n * collection so a table scan may be performed.\n */",
"if",
"(",
"isset",
"(",
"$",
"pipeline",
"[",
"count",
"(",
"$",
"pipeline",
")",
"-",
"1",
"]",
"[",
"'$out'",
"]",
")",
")",
"{",
"$",
"outputCollection",
"=",
"$",
"pipeline",
"[",
"count",
"(",
"$",
"pipeline",
")",
"-",
"1",
"]",
"[",
"'$out'",
"]",
";",
"return",
"$",
"database",
"->",
"selectCollection",
"(",
"$",
"outputCollection",
")",
"->",
"find",
"(",
")",
";",
"}",
"$",
"arrayIterator",
"=",
"new",
"ArrayIterator",
"(",
"isset",
"(",
"$",
"result",
"[",
"'result'",
"]",
")",
"?",
"$",
"result",
"[",
"'result'",
"]",
":",
"array",
"(",
")",
")",
";",
"$",
"arrayIterator",
"->",
"setCommandResult",
"(",
"$",
"result",
")",
";",
"return",
"$",
"arrayIterator",
";",
"}"
] | Execute the aggregate command.
@see Collection::aggregate()
@param array $pipeline
@param array $options
@return Iterator | [
"Execute",
"the",
"aggregate",
"command",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Collection.php#L889-L928 |
1,653 | cosmow/riak | lib/CosmoW/Riak/Collection.php | Collection.doAggregateCursor | protected function doAggregateCursor(array $pipeline, array $options = array())
{
if ( ! method_exists('RiakCollection', 'aggregateCursor')) {
throw new BadMethodCallException('RiakCollection::aggregateCursor() is not available');
}
list($commandOptions, $clientOptions) = isset($options['socketTimeoutMS']) || isset($options['timeout'])
? $this->splitCommandAndClientOptions($options)
: array($options, array());
if (is_scalar($commandOptions['cursor'])) {
unset($commandOptions['cursor']);
}
$timeout = isset($clientOptions['socketTimeoutMS'])
? $clientOptions['socketTimeoutMS']
: (isset($clientOptions['timeout']) ? $clientOptions['timeout'] : null);
$riakCollection = $this->riakCollection;
$commandCursor = $this->retry(function() use ($riakCollection, $pipeline, $commandOptions) {
return $riakCollection->aggregateCursor($pipeline, $commandOptions);
});
$commandCursor = $this->wrapCommandCursor($commandCursor);
if (isset($timeout)) {
$commandCursor->timeout($timeout);
}
return $commandCursor;
} | php | protected function doAggregateCursor(array $pipeline, array $options = array())
{
if ( ! method_exists('RiakCollection', 'aggregateCursor')) {
throw new BadMethodCallException('RiakCollection::aggregateCursor() is not available');
}
list($commandOptions, $clientOptions) = isset($options['socketTimeoutMS']) || isset($options['timeout'])
? $this->splitCommandAndClientOptions($options)
: array($options, array());
if (is_scalar($commandOptions['cursor'])) {
unset($commandOptions['cursor']);
}
$timeout = isset($clientOptions['socketTimeoutMS'])
? $clientOptions['socketTimeoutMS']
: (isset($clientOptions['timeout']) ? $clientOptions['timeout'] : null);
$riakCollection = $this->riakCollection;
$commandCursor = $this->retry(function() use ($riakCollection, $pipeline, $commandOptions) {
return $riakCollection->aggregateCursor($pipeline, $commandOptions);
});
$commandCursor = $this->wrapCommandCursor($commandCursor);
if (isset($timeout)) {
$commandCursor->timeout($timeout);
}
return $commandCursor;
} | [
"protected",
"function",
"doAggregateCursor",
"(",
"array",
"$",
"pipeline",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"'RiakCollection'",
",",
"'aggregateCursor'",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'RiakCollection::aggregateCursor() is not available'",
")",
";",
"}",
"list",
"(",
"$",
"commandOptions",
",",
"$",
"clientOptions",
")",
"=",
"isset",
"(",
"$",
"options",
"[",
"'socketTimeoutMS'",
"]",
")",
"||",
"isset",
"(",
"$",
"options",
"[",
"'timeout'",
"]",
")",
"?",
"$",
"this",
"->",
"splitCommandAndClientOptions",
"(",
"$",
"options",
")",
":",
"array",
"(",
"$",
"options",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"is_scalar",
"(",
"$",
"commandOptions",
"[",
"'cursor'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"commandOptions",
"[",
"'cursor'",
"]",
")",
";",
"}",
"$",
"timeout",
"=",
"isset",
"(",
"$",
"clientOptions",
"[",
"'socketTimeoutMS'",
"]",
")",
"?",
"$",
"clientOptions",
"[",
"'socketTimeoutMS'",
"]",
":",
"(",
"isset",
"(",
"$",
"clientOptions",
"[",
"'timeout'",
"]",
")",
"?",
"$",
"clientOptions",
"[",
"'timeout'",
"]",
":",
"null",
")",
";",
"$",
"riakCollection",
"=",
"$",
"this",
"->",
"riakCollection",
";",
"$",
"commandCursor",
"=",
"$",
"this",
"->",
"retry",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"riakCollection",
",",
"$",
"pipeline",
",",
"$",
"commandOptions",
")",
"{",
"return",
"$",
"riakCollection",
"->",
"aggregateCursor",
"(",
"$",
"pipeline",
",",
"$",
"commandOptions",
")",
";",
"}",
")",
";",
"$",
"commandCursor",
"=",
"$",
"this",
"->",
"wrapCommandCursor",
"(",
"$",
"commandCursor",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"timeout",
")",
")",
"{",
"$",
"commandCursor",
"->",
"timeout",
"(",
"$",
"timeout",
")",
";",
"}",
"return",
"$",
"commandCursor",
";",
"}"
] | Executes the aggregate command and returns a RiakCommandCursor.
@param array $pipeline
@param array $options
@return CommandCursor
@throws BadMethodCallException if RiakCollection::aggregateCursor() is not available | [
"Executes",
"the",
"aggregate",
"command",
"and",
"returns",
"a",
"RiakCommandCursor",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Collection.php#L938-L968 |
1,654 | cosmow/riak | lib/CosmoW/Riak/Collection.php | Collection.doBatchInsert | protected function doBatchInsert(array &$a, array $options = array())
{
$options = isset($options['safe']) ? $this->convertWriteConcern($options) : $options;
$options = isset($options['wtimeout']) ? $this->convertWriteTimeout($options) : $options;
$options = isset($options['timeout']) ? $this->convertSocketTimeout($options) : $options;
return $this->riakCollection->batchInsert($a, $options);
} | php | protected function doBatchInsert(array &$a, array $options = array())
{
$options = isset($options['safe']) ? $this->convertWriteConcern($options) : $options;
$options = isset($options['wtimeout']) ? $this->convertWriteTimeout($options) : $options;
$options = isset($options['timeout']) ? $this->convertSocketTimeout($options) : $options;
return $this->riakCollection->batchInsert($a, $options);
} | [
"protected",
"function",
"doBatchInsert",
"(",
"array",
"&",
"$",
"a",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"isset",
"(",
"$",
"options",
"[",
"'safe'",
"]",
")",
"?",
"$",
"this",
"->",
"convertWriteConcern",
"(",
"$",
"options",
")",
":",
"$",
"options",
";",
"$",
"options",
"=",
"isset",
"(",
"$",
"options",
"[",
"'wtimeout'",
"]",
")",
"?",
"$",
"this",
"->",
"convertWriteTimeout",
"(",
"$",
"options",
")",
":",
"$",
"options",
";",
"$",
"options",
"=",
"isset",
"(",
"$",
"options",
"[",
"'timeout'",
"]",
")",
"?",
"$",
"this",
"->",
"convertSocketTimeout",
"(",
"$",
"options",
")",
":",
"$",
"options",
";",
"return",
"$",
"this",
"->",
"riakCollection",
"->",
"batchInsert",
"(",
"$",
"a",
",",
"$",
"options",
")",
";",
"}"
] | Execute the batchInsert query.
@see Collection::batchInsert()
@param array $a
@param array $options
@return array|boolean | [
"Execute",
"the",
"batchInsert",
"query",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Collection.php#L978-L984 |
1,655 | cosmow/riak | lib/CosmoW/Riak/Collection.php | Collection.doFindAndUpdate | protected function doFindAndUpdate(array $query, array $newObj, array $options)
{
list($commandOptions, $clientOptions) = isset($options['socketTimeoutMS']) || isset($options['timeout'])
? $this->splitCommandAndClientOptions($options)
: array($options, array());
$command = array();
$command['findandmodify'] = $this->riakCollection->getName();
$command['query'] = (object) $query;
$command['update'] = (object) $newObj;
$command = array_merge($command, $commandOptions);
$result = $this->database->command($command, $clientOptions);
if (empty($result['ok'])) {
throw new ResultException($result);
}
return isset($result['value']) ? $result['value'] : null;
} | php | protected function doFindAndUpdate(array $query, array $newObj, array $options)
{
list($commandOptions, $clientOptions) = isset($options['socketTimeoutMS']) || isset($options['timeout'])
? $this->splitCommandAndClientOptions($options)
: array($options, array());
$command = array();
$command['findandmodify'] = $this->riakCollection->getName();
$command['query'] = (object) $query;
$command['update'] = (object) $newObj;
$command = array_merge($command, $commandOptions);
$result = $this->database->command($command, $clientOptions);
if (empty($result['ok'])) {
throw new ResultException($result);
}
return isset($result['value']) ? $result['value'] : null;
} | [
"protected",
"function",
"doFindAndUpdate",
"(",
"array",
"$",
"query",
",",
"array",
"$",
"newObj",
",",
"array",
"$",
"options",
")",
"{",
"list",
"(",
"$",
"commandOptions",
",",
"$",
"clientOptions",
")",
"=",
"isset",
"(",
"$",
"options",
"[",
"'socketTimeoutMS'",
"]",
")",
"||",
"isset",
"(",
"$",
"options",
"[",
"'timeout'",
"]",
")",
"?",
"$",
"this",
"->",
"splitCommandAndClientOptions",
"(",
"$",
"options",
")",
":",
"array",
"(",
"$",
"options",
",",
"array",
"(",
")",
")",
";",
"$",
"command",
"=",
"array",
"(",
")",
";",
"$",
"command",
"[",
"'findandmodify'",
"]",
"=",
"$",
"this",
"->",
"riakCollection",
"->",
"getName",
"(",
")",
";",
"$",
"command",
"[",
"'query'",
"]",
"=",
"(",
"object",
")",
"$",
"query",
";",
"$",
"command",
"[",
"'update'",
"]",
"=",
"(",
"object",
")",
"$",
"newObj",
";",
"$",
"command",
"=",
"array_merge",
"(",
"$",
"command",
",",
"$",
"commandOptions",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"database",
"->",
"command",
"(",
"$",
"command",
",",
"$",
"clientOptions",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
"[",
"'ok'",
"]",
")",
")",
"{",
"throw",
"new",
"ResultException",
"(",
"$",
"result",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"result",
"[",
"'value'",
"]",
")",
"?",
"$",
"result",
"[",
"'value'",
"]",
":",
"null",
";",
"}"
] | Execute the findAndModify command with the update option.
@see Collection::findAndUpdate()
@param array $query
@param array $newObj
@param array $options
@return array|null
@throws ResultException if the command fails | [
"Execute",
"the",
"findAndModify",
"command",
"with",
"the",
"update",
"option",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Collection.php#L1123-L1142 |
1,656 | cosmow/riak | lib/CosmoW/Riak/Collection.php | Collection.doSave | protected function doSave(array &$a, array $options)
{
$options = isset($options['safe']) ? $this->convertWriteConcern($options) : $options;
$options = isset($options['wtimeout']) ? $this->convertWriteTimeout($options) : $options;
$options = isset($options['timeout']) ? $this->convertSocketTimeout($options) : $options;
return $this->riakCollection->save($a, $options);
} | php | protected function doSave(array &$a, array $options)
{
$options = isset($options['safe']) ? $this->convertWriteConcern($options) : $options;
$options = isset($options['wtimeout']) ? $this->convertWriteTimeout($options) : $options;
$options = isset($options['timeout']) ? $this->convertSocketTimeout($options) : $options;
return $this->riakCollection->save($a, $options);
} | [
"protected",
"function",
"doSave",
"(",
"array",
"&",
"$",
"a",
",",
"array",
"$",
"options",
")",
"{",
"$",
"options",
"=",
"isset",
"(",
"$",
"options",
"[",
"'safe'",
"]",
")",
"?",
"$",
"this",
"->",
"convertWriteConcern",
"(",
"$",
"options",
")",
":",
"$",
"options",
";",
"$",
"options",
"=",
"isset",
"(",
"$",
"options",
"[",
"'wtimeout'",
"]",
")",
"?",
"$",
"this",
"->",
"convertWriteTimeout",
"(",
"$",
"options",
")",
":",
"$",
"options",
";",
"$",
"options",
"=",
"isset",
"(",
"$",
"options",
"[",
"'timeout'",
"]",
")",
"?",
"$",
"this",
"->",
"convertSocketTimeout",
"(",
"$",
"options",
")",
":",
"$",
"options",
";",
"return",
"$",
"this",
"->",
"riakCollection",
"->",
"save",
"(",
"$",
"a",
",",
"$",
"options",
")",
";",
"}"
] | Execute the save query.
@see Collection::save()
@param array $a
@param array $options
@return array|boolean | [
"Execute",
"the",
"save",
"query",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Collection.php#L1372-L1378 |
1,657 | cosmow/riak | lib/CosmoW/Riak/Collection.php | Collection.doUpdate | protected function doUpdate(array $query, array $newObj, array $options)
{
$options = isset($options['safe']) ? $this->convertWriteConcern($options) : $options;
$options = isset($options['wtimeout']) ? $this->convertWriteTimeout($options) : $options;
$options = isset($options['timeout']) ? $this->convertSocketTimeout($options) : $options;
/* Allow "multi" to be used instead of "multiple", as it's accepted in
* the Riak shell and other (non-PHP) drivers.
*/
if (isset($options['multi']) && ! isset($options['multiple'])) {
$options['multiple'] = $options['multi'];
unset($options['multi']);
}
return $this->riakCollection->update($query, $newObj, $options);
} | php | protected function doUpdate(array $query, array $newObj, array $options)
{
$options = isset($options['safe']) ? $this->convertWriteConcern($options) : $options;
$options = isset($options['wtimeout']) ? $this->convertWriteTimeout($options) : $options;
$options = isset($options['timeout']) ? $this->convertSocketTimeout($options) : $options;
/* Allow "multi" to be used instead of "multiple", as it's accepted in
* the Riak shell and other (non-PHP) drivers.
*/
if (isset($options['multi']) && ! isset($options['multiple'])) {
$options['multiple'] = $options['multi'];
unset($options['multi']);
}
return $this->riakCollection->update($query, $newObj, $options);
} | [
"protected",
"function",
"doUpdate",
"(",
"array",
"$",
"query",
",",
"array",
"$",
"newObj",
",",
"array",
"$",
"options",
")",
"{",
"$",
"options",
"=",
"isset",
"(",
"$",
"options",
"[",
"'safe'",
"]",
")",
"?",
"$",
"this",
"->",
"convertWriteConcern",
"(",
"$",
"options",
")",
":",
"$",
"options",
";",
"$",
"options",
"=",
"isset",
"(",
"$",
"options",
"[",
"'wtimeout'",
"]",
")",
"?",
"$",
"this",
"->",
"convertWriteTimeout",
"(",
"$",
"options",
")",
":",
"$",
"options",
";",
"$",
"options",
"=",
"isset",
"(",
"$",
"options",
"[",
"'timeout'",
"]",
")",
"?",
"$",
"this",
"->",
"convertSocketTimeout",
"(",
"$",
"options",
")",
":",
"$",
"options",
";",
"/* Allow \"multi\" to be used instead of \"multiple\", as it's accepted in\n * the Riak shell and other (non-PHP) drivers.\n */",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'multi'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"options",
"[",
"'multiple'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'multiple'",
"]",
"=",
"$",
"options",
"[",
"'multi'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'multi'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"riakCollection",
"->",
"update",
"(",
"$",
"query",
",",
"$",
"newObj",
",",
"$",
"options",
")",
";",
"}"
] | Execute the update query.
@see Collection::update()
@param array $query
@param array $newObj
@param array $options
@return array|boolean | [
"Execute",
"the",
"update",
"query",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Collection.php#L1389-L1404 |
1,658 | cosmow/riak | lib/CosmoW/Riak/Collection.php | Collection.wrapCursor | protected function wrapCursor(\RiakCursor $cursor, $query, $fields)
{
return new Cursor($this, $cursor, $query, $fields, $this->numRetries);
} | php | protected function wrapCursor(\RiakCursor $cursor, $query, $fields)
{
return new Cursor($this, $cursor, $query, $fields, $this->numRetries);
} | [
"protected",
"function",
"wrapCursor",
"(",
"\\",
"RiakCursor",
"$",
"cursor",
",",
"$",
"query",
",",
"$",
"fields",
")",
"{",
"return",
"new",
"Cursor",
"(",
"$",
"this",
",",
"$",
"cursor",
",",
"$",
"query",
",",
"$",
"fields",
",",
"$",
"this",
"->",
"numRetries",
")",
";",
"}"
] | Wraps a RiakCursor instance with a Cursor.
@param \RiakCursor $cursor
@param array $query
@param array $fields
@return Cursor | [
"Wraps",
"a",
"RiakCursor",
"instance",
"with",
"a",
"Cursor",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Collection.php#L1458-L1461 |
1,659 | swoopaholic/Components | Table/TableView.php | TableView.isRendered | public function isRendered()
{
$hasChildren = 0 < count($this->children);
if (true === $this->rendered || !$hasChildren) {
return $this->rendered;
}
if ($hasChildren) {
foreach ($this->children as $child) {
if (!$child->isRendered()) {
return false;
}
}
return $this->rendered = true;
}
return false;
} | php | public function isRendered()
{
$hasChildren = 0 < count($this->children);
if (true === $this->rendered || !$hasChildren) {
return $this->rendered;
}
if ($hasChildren) {
foreach ($this->children as $child) {
if (!$child->isRendered()) {
return false;
}
}
return $this->rendered = true;
}
return false;
} | [
"public",
"function",
"isRendered",
"(",
")",
"{",
"$",
"hasChildren",
"=",
"0",
"<",
"count",
"(",
"$",
"this",
"->",
"children",
")",
";",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"rendered",
"||",
"!",
"$",
"hasChildren",
")",
"{",
"return",
"$",
"this",
"->",
"rendered",
";",
"}",
"if",
"(",
"$",
"hasChildren",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"!",
"$",
"child",
"->",
"isRendered",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"rendered",
"=",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Returns whether the view was already rendered.
@return bool Whether this view's widget is rendered. | [
"Returns",
"whether",
"the",
"view",
"was",
"already",
"rendered",
"."
] | a665248a4d3285dea936579a763b5a7ecfe62c4a | https://github.com/swoopaholic/Components/blob/a665248a4d3285dea936579a763b5a7ecfe62c4a/Table/TableView.php#L52-L71 |
1,660 | stakhanovist/worker | library/ProcessEvent.php | ProcessEvent.getParam | public function getParam($name, $default = null)
{
switch ($name) {
case 'processor':
return $this->getProcessor();
case 'message':
return $this->getMessage();
case 'result':
return $this->getResult();
default:
return parent::getParam($name, $default);
}
} | php | public function getParam($name, $default = null)
{
switch ($name) {
case 'processor':
return $this->getProcessor();
case 'message':
return $this->getMessage();
case 'result':
return $this->getResult();
default:
return parent::getParam($name, $default);
}
} | [
"public",
"function",
"getParam",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"'processor'",
":",
"return",
"$",
"this",
"->",
"getProcessor",
"(",
")",
";",
"case",
"'message'",
":",
"return",
"$",
"this",
"->",
"getMessage",
"(",
")",
";",
"case",
"'result'",
":",
"return",
"$",
"this",
"->",
"getResult",
"(",
")",
";",
"default",
":",
"return",
"parent",
"::",
"getParam",
"(",
"$",
"name",
",",
"$",
"default",
")",
";",
"}",
"}"
] | Get event parameter
@param string $name
@param mixed $default
@return mixed | [
"Get",
"event",
"parameter"
] | 63f6aaeb06986a7c39b5e5c4be742b92942b5d3f | https://github.com/stakhanovist/worker/blob/63f6aaeb06986a7c39b5e5c4be742b92942b5d3f/library/ProcessEvent.php#L144-L156 |
1,661 | stakhanovist/worker | library/ProcessEvent.php | ProcessEvent.getParams | public function getParams()
{
$params = parent::getParams();
$params['processor'] = $this->getProcessor();
$params['message'] = $this->getMessage();
$params['result'] = $this->getResult();
return $params;
} | php | public function getParams()
{
$params = parent::getParams();
$params['processor'] = $this->getProcessor();
$params['message'] = $this->getMessage();
$params['result'] = $this->getResult();
return $params;
} | [
"public",
"function",
"getParams",
"(",
")",
"{",
"$",
"params",
"=",
"parent",
"::",
"getParams",
"(",
")",
";",
"$",
"params",
"[",
"'processor'",
"]",
"=",
"$",
"this",
"->",
"getProcessor",
"(",
")",
";",
"$",
"params",
"[",
"'message'",
"]",
"=",
"$",
"this",
"->",
"getMessage",
"(",
")",
";",
"$",
"params",
"[",
"'result'",
"]",
"=",
"$",
"this",
"->",
"getResult",
"(",
")",
";",
"return",
"$",
"params",
";",
"}"
] | Get all event parameters
@return array|\ArrayAccess | [
"Get",
"all",
"event",
"parameters"
] | 63f6aaeb06986a7c39b5e5c4be742b92942b5d3f | https://github.com/stakhanovist/worker/blob/63f6aaeb06986a7c39b5e5c4be742b92942b5d3f/library/ProcessEvent.php#L163-L170 |
1,662 | stakhanovist/worker | library/ProcessEvent.php | ProcessEvent.setParam | public function setParam($name, $value)
{
switch ($name) {
case 'processor':
$this->setProcessor($value);
break;
case 'message':
$this->setMessage($value);
break;
case 'result':
$this->setResult($value);
break;
default:
parent::setParam($name, $value);
break;
}
return $this;
} | php | public function setParam($name, $value)
{
switch ($name) {
case 'processor':
$this->setProcessor($value);
break;
case 'message':
$this->setMessage($value);
break;
case 'result':
$this->setResult($value);
break;
default:
parent::setParam($name, $value);
break;
}
return $this;
} | [
"public",
"function",
"setParam",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"'processor'",
":",
"$",
"this",
"->",
"setProcessor",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'message'",
":",
"$",
"this",
"->",
"setMessage",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'result'",
":",
"$",
"this",
"->",
"setResult",
"(",
"$",
"value",
")",
";",
"break",
";",
"default",
":",
"parent",
"::",
"setParam",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"break",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set an individual event parameter
@param string $name
@param mixed $value
@return $this | [
"Set",
"an",
"individual",
"event",
"parameter"
] | 63f6aaeb06986a7c39b5e5c4be742b92942b5d3f | https://github.com/stakhanovist/worker/blob/63f6aaeb06986a7c39b5e5c4be742b92942b5d3f/library/ProcessEvent.php#L200-L217 |
1,663 | jamiehannaford/php-opencloud-zf2 | src/Factory/ProviderBuilder.php | ProviderBuilder.build | public function build()
{
switch ($this->provider) {
default:
case Provider::RACKSPACE:
$class = __NAMESPACE__ . '\\RackspaceFactory';
break;
case Provider::OPENSTACK:
$class = __NAMESPACE__ . '\\OpenStackFactory';
break;
}
return $this->buildFactory($class)->buildClient();
} | php | public function build()
{
switch ($this->provider) {
default:
case Provider::RACKSPACE:
$class = __NAMESPACE__ . '\\RackspaceFactory';
break;
case Provider::OPENSTACK:
$class = __NAMESPACE__ . '\\OpenStackFactory';
break;
}
return $this->buildFactory($class)->buildClient();
} | [
"public",
"function",
"build",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"provider",
")",
"{",
"default",
":",
"case",
"Provider",
"::",
"RACKSPACE",
":",
"$",
"class",
"=",
"__NAMESPACE__",
".",
"'\\\\RackspaceFactory'",
";",
"break",
";",
"case",
"Provider",
"::",
"OPENSTACK",
":",
"$",
"class",
"=",
"__NAMESPACE__",
".",
"'\\\\OpenStackFactory'",
";",
"break",
";",
"}",
"return",
"$",
"this",
"->",
"buildFactory",
"(",
"$",
"class",
")",
"->",
"buildClient",
"(",
")",
";",
"}"
] | Will initialize the build process; first the factory is built, then the factory builds the client
@return \Guzzle\Http\ClientInterface | [
"Will",
"initialize",
"the",
"build",
"process",
";",
"first",
"the",
"factory",
"is",
"built",
"then",
"the",
"factory",
"builds",
"the",
"client"
] | 74140adaffc0b46d7bbe1d7b3441c61f2cf6a656 | https://github.com/jamiehannaford/php-opencloud-zf2/blob/74140adaffc0b46d7bbe1d7b3441c61f2cf6a656/src/Factory/ProviderBuilder.php#L53-L66 |
1,664 | jamiehannaford/php-opencloud-zf2 | src/Factory/ProviderBuilder.php | ProviderBuilder.buildFactory | protected function buildFactory($factoryClass)
{
$factory = $factoryClass::newInstance();
$factory->setConfig($this->config);
$factory->validateConfig();
return $factory;
} | php | protected function buildFactory($factoryClass)
{
$factory = $factoryClass::newInstance();
$factory->setConfig($this->config);
$factory->validateConfig();
return $factory;
} | [
"protected",
"function",
"buildFactory",
"(",
"$",
"factoryClass",
")",
"{",
"$",
"factory",
"=",
"$",
"factoryClass",
"::",
"newInstance",
"(",
")",
";",
"$",
"factory",
"->",
"setConfig",
"(",
"$",
"this",
"->",
"config",
")",
";",
"$",
"factory",
"->",
"validateConfig",
"(",
")",
";",
"return",
"$",
"factory",
";",
"}"
] | Build the concrete factory class responsible for creating a concrete client object
@param $factoryClass string FQCN of factory class
@return ProviderFactoryInterface | [
"Build",
"the",
"concrete",
"factory",
"class",
"responsible",
"for",
"creating",
"a",
"concrete",
"client",
"object"
] | 74140adaffc0b46d7bbe1d7b3441c61f2cf6a656 | https://github.com/jamiehannaford/php-opencloud-zf2/blob/74140adaffc0b46d7bbe1d7b3441c61f2cf6a656/src/Factory/ProviderBuilder.php#L74-L81 |
1,665 | FelixOnline/Core | src/FelixOnline/Core/Topic.php | Topic.getStartDate | public function getStartDate()
{
$topic = BaseManager::build('FelixOnline\Core\Topic', 'article_topic', 'topic')
->filter('topic = "%s"', array($this->getSlug()));
$article = BaseManager::build('FelixOnline\Core\Article', 'article', 'id')
->join($topic, 'LEFT', 'id', 'article')
->filter('published > 0')
->order('published', 'ASC')
->limit(0, 1)
->values();
if (!$article) {
throw new \FelixOnline\Exceptions\InternalException('No articles posted in this topic');
}
return($article[0]->getPublished());
} | php | public function getStartDate()
{
$topic = BaseManager::build('FelixOnline\Core\Topic', 'article_topic', 'topic')
->filter('topic = "%s"', array($this->getSlug()));
$article = BaseManager::build('FelixOnline\Core\Article', 'article', 'id')
->join($topic, 'LEFT', 'id', 'article')
->filter('published > 0')
->order('published', 'ASC')
->limit(0, 1)
->values();
if (!$article) {
throw new \FelixOnline\Exceptions\InternalException('No articles posted in this topic');
}
return($article[0]->getPublished());
} | [
"public",
"function",
"getStartDate",
"(",
")",
"{",
"$",
"topic",
"=",
"BaseManager",
"::",
"build",
"(",
"'FelixOnline\\Core\\Topic'",
",",
"'article_topic'",
",",
"'topic'",
")",
"->",
"filter",
"(",
"'topic = \"%s\"'",
",",
"array",
"(",
"$",
"this",
"->",
"getSlug",
"(",
")",
")",
")",
";",
"$",
"article",
"=",
"BaseManager",
"::",
"build",
"(",
"'FelixOnline\\Core\\Article'",
",",
"'article'",
",",
"'id'",
")",
"->",
"join",
"(",
"$",
"topic",
",",
"'LEFT'",
",",
"'id'",
",",
"'article'",
")",
"->",
"filter",
"(",
"'published > 0'",
")",
"->",
"order",
"(",
"'published'",
",",
"'ASC'",
")",
"->",
"limit",
"(",
"0",
",",
"1",
")",
"->",
"values",
"(",
")",
";",
"if",
"(",
"!",
"$",
"article",
")",
"{",
"throw",
"new",
"\\",
"FelixOnline",
"\\",
"Exceptions",
"\\",
"InternalException",
"(",
"'No articles posted in this topic'",
")",
";",
"}",
"return",
"(",
"$",
"article",
"[",
"0",
"]",
"->",
"getPublished",
"(",
")",
")",
";",
"}"
] | Get date that the first article was posted | [
"Get",
"date",
"that",
"the",
"first",
"article",
"was",
"posted"
] | b29f50cd96cee73da83968ee1eb88d8b3ab1c430 | https://github.com/FelixOnline/Core/blob/b29f50cd96cee73da83968ee1eb88d8b3ab1c430/src/FelixOnline/Core/Topic.php#L38-L55 |
1,666 | fortifi/sdk | src/Fortifi.php | Fortifi.setEnvironment | public static function setEnvironment($env = self::ENV_STAGE)
{
$prefix = '';
if($env === self::ENV_STAGE)
{
$prefix = 's';
}
static::$apiHost = $prefix . 'api.fortifi.io';
} | php | public static function setEnvironment($env = self::ENV_STAGE)
{
$prefix = '';
if($env === self::ENV_STAGE)
{
$prefix = 's';
}
static::$apiHost = $prefix . 'api.fortifi.io';
} | [
"public",
"static",
"function",
"setEnvironment",
"(",
"$",
"env",
"=",
"self",
"::",
"ENV_STAGE",
")",
"{",
"$",
"prefix",
"=",
"''",
";",
"if",
"(",
"$",
"env",
"===",
"self",
"::",
"ENV_STAGE",
")",
"{",
"$",
"prefix",
"=",
"'s'",
";",
"}",
"static",
"::",
"$",
"apiHost",
"=",
"$",
"prefix",
".",
"'api.fortifi.io'",
";",
"}"
] | Set the environment to connect to
@param string $env | [
"Set",
"the",
"environment",
"to",
"connect",
"to"
] | 4d0471c72c7954271c692d32265fd42f698392e4 | https://github.com/fortifi/sdk/blob/4d0471c72c7954271c692d32265fd42f698392e4/src/Fortifi.php#L63-L72 |
1,667 | potfur/statemachine | src/StateMachine/Event.php | Event.trigger | public function trigger(Payload $payload)
{
if (!$this->command) {
return $this->targetState();
}
return call_user_func($this->command, $payload) ? $this->targetState() : $this->errorState();
} | php | public function trigger(Payload $payload)
{
if (!$this->command) {
return $this->targetState();
}
return call_user_func($this->command, $payload) ? $this->targetState() : $this->errorState();
} | [
"public",
"function",
"trigger",
"(",
"Payload",
"$",
"payload",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"command",
")",
"{",
"return",
"$",
"this",
"->",
"targetState",
"(",
")",
";",
"}",
"return",
"call_user_func",
"(",
"$",
"this",
"->",
"command",
",",
"$",
"payload",
")",
"?",
"$",
"this",
"->",
"targetState",
"(",
")",
":",
"$",
"this",
"->",
"errorState",
"(",
")",
";",
"}"
] | Triggers event and return next state name or null if there is no state change
@param Payload $payload
@return null|string | [
"Triggers",
"event",
"and",
"return",
"next",
"state",
"name",
"or",
"null",
"if",
"there",
"is",
"no",
"state",
"change"
] | 6b68535e6c94b10bf618a7809a48f6a8f6d30deb | https://github.com/potfur/statemachine/blob/6b68535e6c94b10bf618a7809a48f6a8f6d30deb/src/StateMachine/Event.php#L139-L146 |
1,668 | solo-framework/solo-logger | examples/004-custom-parser.php | WeatherParser.parse | public function parse()
{
// get current weather, just for fun
$data = file_get_contents("http://api.openweathermap.org/data/2.5/weather?zip=420000,ru&units=metric");
$this->record->formatted = str_replace("{weather}", $data, $this->record->formatted);
return $this->record;
} | php | public function parse()
{
// get current weather, just for fun
$data = file_get_contents("http://api.openweathermap.org/data/2.5/weather?zip=420000,ru&units=metric");
$this->record->formatted = str_replace("{weather}", $data, $this->record->formatted);
return $this->record;
} | [
"public",
"function",
"parse",
"(",
")",
"{",
"// get current weather, just for fun",
"$",
"data",
"=",
"file_get_contents",
"(",
"\"http://api.openweathermap.org/data/2.5/weather?zip=420000,ru&units=metric\"",
")",
";",
"$",
"this",
"->",
"record",
"->",
"formatted",
"=",
"str_replace",
"(",
"\"{weather}\"",
",",
"$",
"data",
",",
"$",
"this",
"->",
"record",
"->",
"formatted",
")",
";",
"return",
"$",
"this",
"->",
"record",
";",
"}"
] | Replace macros with useful data
@return \Solo\Logger\LogRecord | [
"Replace",
"macros",
"with",
"useful",
"data"
] | 2f0a9f789479c4e9ab6ee9fe5817f256eb18db70 | https://github.com/solo-framework/solo-logger/blob/2f0a9f789479c4e9ab6ee9fe5817f256eb18db70/examples/004-custom-parser.php#L56-L62 |
1,669 | DiegoSilva94/magento-client-v2 | src/Smalot/V2/Magento/Order/Order.php | Order.addComment | public function addComment($orderIncrementId, $status, $comment = null, $notify = null)
{
return $this->__createAction('salesOrderAddComment', func_get_args());
} | php | public function addComment($orderIncrementId, $status, $comment = null, $notify = null)
{
return $this->__createAction('salesOrderAddComment', func_get_args());
} | [
"public",
"function",
"addComment",
"(",
"$",
"orderIncrementId",
",",
"$",
"status",
",",
"$",
"comment",
"=",
"null",
",",
"$",
"notify",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"__createAction",
"(",
"'salesOrderAddComment'",
",",
"func_get_args",
"(",
")",
")",
";",
"}"
] | Allows you to add a new comment to the order.
@param string $orderIncrementId
@param string $status
@param string $comment
@param string $notify
@return ActionInterface | [
"Allows",
"you",
"to",
"add",
"a",
"new",
"comment",
"to",
"the",
"order",
"."
] | b36e6535f9f8be702043df0e74249b805f8d9b9f | https://github.com/DiegoSilva94/magento-client-v2/blob/b36e6535f9f8be702043df0e74249b805f8d9b9f/src/Smalot/V2/Magento/Order/Order.php#L39-L42 |
1,670 | bkdotcom/Toolbox | src/Cookie.php | Cookie.getRaw | public static function getRaw($name)
{
$value = null;
$rawCookies = !empty($_SERVER['HTTP_COOKIE'])
? explode('; ', $_SERVER['HTTP_COOKIE'])
: array();
foreach ($rawCookies as $kv) {
$pair = explode('=', $kv, 2);
$k = array_shift($pair);
$v = array_shift($pair);
$k = str_replace(' ', '_', urldecode($k));
if ($k == $name) {
$value = urldecode($v);
break;
}
}
return $value;
} | php | public static function getRaw($name)
{
$value = null;
$rawCookies = !empty($_SERVER['HTTP_COOKIE'])
? explode('; ', $_SERVER['HTTP_COOKIE'])
: array();
foreach ($rawCookies as $kv) {
$pair = explode('=', $kv, 2);
$k = array_shift($pair);
$v = array_shift($pair);
$k = str_replace(' ', '_', urldecode($k));
if ($k == $name) {
$value = urldecode($v);
break;
}
}
return $value;
} | [
"public",
"static",
"function",
"getRaw",
"(",
"$",
"name",
")",
"{",
"$",
"value",
"=",
"null",
";",
"$",
"rawCookies",
"=",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'HTTP_COOKIE'",
"]",
")",
"?",
"explode",
"(",
"'; '",
",",
"$",
"_SERVER",
"[",
"'HTTP_COOKIE'",
"]",
")",
":",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"rawCookies",
"as",
"$",
"kv",
")",
"{",
"$",
"pair",
"=",
"explode",
"(",
"'='",
",",
"$",
"kv",
",",
"2",
")",
";",
"$",
"k",
"=",
"array_shift",
"(",
"$",
"pair",
")",
";",
"$",
"v",
"=",
"array_shift",
"(",
"$",
"pair",
")",
";",
"$",
"k",
"=",
"str_replace",
"(",
"' '",
",",
"'_'",
",",
"urldecode",
"(",
"$",
"k",
")",
")",
";",
"if",
"(",
"$",
"k",
"==",
"$",
"name",
")",
"{",
"$",
"value",
"=",
"urldecode",
"(",
"$",
"v",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] | Returns the coocie value that's received in the header
@param name $name name of cookie
@return string
@internal | [
"Returns",
"the",
"coocie",
"value",
"that",
"s",
"received",
"in",
"the",
"header"
] | 2f9d34fd57bd8382baee4c29aac13a6710e3a994 | https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Cookie.php#L99-L116 |
1,671 | bkdotcom/Toolbox | src/Cookie.php | Cookie.cookieParams | protected static function cookieParams($args = array())
{
$params = array();
if (count($args) == 1) {
if (is_array($args[0])) {
$params = $args[0];
} else {
$params['value'] = $args[0];
}
} elseif (count($args) == 2) {
if (is_string($args[1])) {
$params['name'] = $args[1];
} else {
$params = $args[1];
}
$params['value'] = $args[0];
}
$domainRegex = '/([^.]+\.[a-z]{2,})(:\d{1,4})?$/i';
$paramsDefault = array(
// 'name' => 'vars',
'value' => '',
// 'lifetime' => null, // can pass lifetime in lieu of expiry (ala session_set_cookie_params)
// lifetime param takes precedence
'domain' => preg_match($domainRegex, $_SERVER['HTTP_HOST'], $matches)
? '.'.$matches[1]
: '',
/*
'expiry' => time()+60*60*24*30, // 30 Days in future; set to zero to expire when browser closes
'path' => '/',
'secure' => false,
'httponly' => false,
*/
);
$params = array_merge($paramsDefault, self::$cfgStatic, $params);
if (isset($params['lifetime'])) {
$params['expiry'] = time() + $params['lifetime'];
} elseif ($params['expiry'] < time() && $params['expiry'] != 0) {
// treat as TTL
$params['expiry'] += time();
}
return $params;
} | php | protected static function cookieParams($args = array())
{
$params = array();
if (count($args) == 1) {
if (is_array($args[0])) {
$params = $args[0];
} else {
$params['value'] = $args[0];
}
} elseif (count($args) == 2) {
if (is_string($args[1])) {
$params['name'] = $args[1];
} else {
$params = $args[1];
}
$params['value'] = $args[0];
}
$domainRegex = '/([^.]+\.[a-z]{2,})(:\d{1,4})?$/i';
$paramsDefault = array(
// 'name' => 'vars',
'value' => '',
// 'lifetime' => null, // can pass lifetime in lieu of expiry (ala session_set_cookie_params)
// lifetime param takes precedence
'domain' => preg_match($domainRegex, $_SERVER['HTTP_HOST'], $matches)
? '.'.$matches[1]
: '',
/*
'expiry' => time()+60*60*24*30, // 30 Days in future; set to zero to expire when browser closes
'path' => '/',
'secure' => false,
'httponly' => false,
*/
);
$params = array_merge($paramsDefault, self::$cfgStatic, $params);
if (isset($params['lifetime'])) {
$params['expiry'] = time() + $params['lifetime'];
} elseif ($params['expiry'] < time() && $params['expiry'] != 0) {
// treat as TTL
$params['expiry'] += time();
}
return $params;
} | [
"protected",
"static",
"function",
"cookieParams",
"(",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"==",
"1",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"args",
"[",
"0",
"]",
")",
")",
"{",
"$",
"params",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"params",
"[",
"'value'",
"]",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"}",
"}",
"elseif",
"(",
"count",
"(",
"$",
"args",
")",
"==",
"2",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"args",
"[",
"1",
"]",
")",
")",
"{",
"$",
"params",
"[",
"'name'",
"]",
"=",
"$",
"args",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"params",
"=",
"$",
"args",
"[",
"1",
"]",
";",
"}",
"$",
"params",
"[",
"'value'",
"]",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"}",
"$",
"domainRegex",
"=",
"'/([^.]+\\.[a-z]{2,})(:\\d{1,4})?$/i'",
";",
"$",
"paramsDefault",
"=",
"array",
"(",
"// 'name'\t\t=> 'vars',",
"'value'",
"=>",
"''",
",",
"// 'lifetime'\t=> null,\t\t\t\t// can pass lifetime in lieu of expiry (ala session_set_cookie_params)",
"//\t\tlifetime param takes precedence",
"'domain'",
"=>",
"preg_match",
"(",
"$",
"domainRegex",
",",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
",",
"$",
"matches",
")",
"?",
"'.'",
".",
"$",
"matches",
"[",
"1",
"]",
":",
"''",
",",
"/*\n\t\t\t'expiry'\t=> time()+60*60*24*30,\t// 30 Days in future; set to zero to expire when browser closes\n\t\t\t'path'\t\t=> '/',\n\t\t\t'secure'\t=> false,\n\t\t\t'httponly'\t=> false,\n\t\t\t*/",
")",
";",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"paramsDefault",
",",
"self",
"::",
"$",
"cfgStatic",
",",
"$",
"params",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'lifetime'",
"]",
")",
")",
"{",
"$",
"params",
"[",
"'expiry'",
"]",
"=",
"time",
"(",
")",
"+",
"$",
"params",
"[",
"'lifetime'",
"]",
";",
"}",
"elseif",
"(",
"$",
"params",
"[",
"'expiry'",
"]",
"<",
"time",
"(",
")",
"&&",
"$",
"params",
"[",
"'expiry'",
"]",
"!=",
"0",
")",
"{",
"// treat as TTL",
"$",
"params",
"[",
"'expiry'",
"]",
"+=",
"time",
"(",
")",
";",
"}",
"return",
"$",
"params",
";",
"}"
] | return cookie parameters
@param array $args as passed to setCookieValue
@return array | [
"return",
"cookie",
"parameters"
] | 2f9d34fd57bd8382baee4c29aac13a6710e3a994 | https://github.com/bkdotcom/Toolbox/blob/2f9d34fd57bd8382baee4c29aac13a6710e3a994/src/Cookie.php#L211-L252 |
1,672 | frozensheep/synthesize | src/Type/TypeFactory.php | TypeFactory.getType | static public function getType($strType){
//convert reserved names to the actual objects
$arrReservere = array(
'array' => 'ArrayObject',
'bool' => 'BooleanObject',
'boolean' => 'BooleanObject',
'datetime' => 'DateTimeObject',
'dictionary' => 'DictionaryObject',
'enum' => 'EnumObject',
'id' => 'IdObject',
'int' => 'IntObject',
'float' => 'FloatObject',
'string' => 'StringObject',
'resource' => 'ResourceObject',
'object' => 'ObjectObject',
'objectarray' => 'ObjectArrayObject',
'number' => 'NumberObject',
'numeric' => 'NumberObject',
'fixeddictionary' => 'FixedDictionaryObject'
);
if(array_key_exists(strtolower($strType), $arrReservere)){
$strType = $arrReservere[strtolower($strType)];
}
$strType = 'Frozensheep\\Synthesize\\Type\\'.ucfirst($strType);
return $strType;
} | php | static public function getType($strType){
//convert reserved names to the actual objects
$arrReservere = array(
'array' => 'ArrayObject',
'bool' => 'BooleanObject',
'boolean' => 'BooleanObject',
'datetime' => 'DateTimeObject',
'dictionary' => 'DictionaryObject',
'enum' => 'EnumObject',
'id' => 'IdObject',
'int' => 'IntObject',
'float' => 'FloatObject',
'string' => 'StringObject',
'resource' => 'ResourceObject',
'object' => 'ObjectObject',
'objectarray' => 'ObjectArrayObject',
'number' => 'NumberObject',
'numeric' => 'NumberObject',
'fixeddictionary' => 'FixedDictionaryObject'
);
if(array_key_exists(strtolower($strType), $arrReservere)){
$strType = $arrReservere[strtolower($strType)];
}
$strType = 'Frozensheep\\Synthesize\\Type\\'.ucfirst($strType);
return $strType;
} | [
"static",
"public",
"function",
"getType",
"(",
"$",
"strType",
")",
"{",
"//convert reserved names to the actual objects",
"$",
"arrReservere",
"=",
"array",
"(",
"'array'",
"=>",
"'ArrayObject'",
",",
"'bool'",
"=>",
"'BooleanObject'",
",",
"'boolean'",
"=>",
"'BooleanObject'",
",",
"'datetime'",
"=>",
"'DateTimeObject'",
",",
"'dictionary'",
"=>",
"'DictionaryObject'",
",",
"'enum'",
"=>",
"'EnumObject'",
",",
"'id'",
"=>",
"'IdObject'",
",",
"'int'",
"=>",
"'IntObject'",
",",
"'float'",
"=>",
"'FloatObject'",
",",
"'string'",
"=>",
"'StringObject'",
",",
"'resource'",
"=>",
"'ResourceObject'",
",",
"'object'",
"=>",
"'ObjectObject'",
",",
"'objectarray'",
"=>",
"'ObjectArrayObject'",
",",
"'number'",
"=>",
"'NumberObject'",
",",
"'numeric'",
"=>",
"'NumberObject'",
",",
"'fixeddictionary'",
"=>",
"'FixedDictionaryObject'",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"strtolower",
"(",
"$",
"strType",
")",
",",
"$",
"arrReservere",
")",
")",
"{",
"$",
"strType",
"=",
"$",
"arrReservere",
"[",
"strtolower",
"(",
"$",
"strType",
")",
"]",
";",
"}",
"$",
"strType",
"=",
"'Frozensheep\\\\Synthesize\\\\Type\\\\'",
".",
"ucfirst",
"(",
"$",
"strType",
")",
";",
"return",
"$",
"strType",
";",
"}"
] | Get Type Method
Returns a type object based on the options given.
@param string $strType The name of the type.
return string | [
"Get",
"Type",
"Method"
] | 18e4ece4f02ad2fbd5510eac6342b8c2d31ccc51 | https://github.com/frozensheep/synthesize/blob/18e4ece4f02ad2fbd5510eac6342b8c2d31ccc51/src/Type/TypeFactory.php#L50-L78 |
1,673 | tmquang6805/phalex | library/Phalex/Events/Listener/Application.php | Application.setViewService | private function setViewService(Di $di, Config $config, $moduleName)
{
$viewsDir = $config['view'][$moduleName];
$volt = $this->setVoltOptions($config, $moduleName);
$options = [
'di' => $di,
'views_dir' => $viewsDir,
'volt' => $volt
];
$di->set('view', new View($options), true);
return $this;
} | php | private function setViewService(Di $di, Config $config, $moduleName)
{
$viewsDir = $config['view'][$moduleName];
$volt = $this->setVoltOptions($config, $moduleName);
$options = [
'di' => $di,
'views_dir' => $viewsDir,
'volt' => $volt
];
$di->set('view', new View($options), true);
return $this;
} | [
"private",
"function",
"setViewService",
"(",
"Di",
"$",
"di",
",",
"Config",
"$",
"config",
",",
"$",
"moduleName",
")",
"{",
"$",
"viewsDir",
"=",
"$",
"config",
"[",
"'view'",
"]",
"[",
"$",
"moduleName",
"]",
";",
"$",
"volt",
"=",
"$",
"this",
"->",
"setVoltOptions",
"(",
"$",
"config",
",",
"$",
"moduleName",
")",
";",
"$",
"options",
"=",
"[",
"'di'",
"=>",
"$",
"di",
",",
"'views_dir'",
"=>",
"$",
"viewsDir",
",",
"'volt'",
"=>",
"$",
"volt",
"]",
";",
"$",
"di",
"->",
"set",
"(",
"'view'",
",",
"new",
"View",
"(",
"$",
"options",
")",
",",
"true",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set service view for application when module start
@param Di $di
@param Config $config
@param string $moduleName
@return \Phalex\Events\Listener\Application | [
"Set",
"service",
"view",
"for",
"application",
"when",
"module",
"start"
] | 6452b4e695b456838d9d553d96f2b114e1c110b4 | https://github.com/tmquang6805/phalex/blob/6452b4e695b456838d9d553d96f2b114e1c110b4/library/Phalex/Events/Listener/Application.php#L60-L72 |
1,674 | tmquang6805/phalex | library/Phalex/Events/Listener/Application.php | Application.setUrlService | private function setUrlService(Di $di, Config $config, $name)
{
$base = $static = '/';
if (isset($config['url'])) {
$default = isset($config['url']['default']) ? $config['url']['default'] : '/';
if (isset($config['url'][$name])) {
$base = isset($config['url'][$name]['uri']) ? $config['url'][$name]['uri'] : $default;
$static = isset($config['url'][$name]['static']) ? $config['url'][$name]['static'] : $default;
}
}
$url = new UrlService();
$url->setBaseUri($base);
$url->setStaticBaseUri($static);
$di->set('url', $url, true);
return $this;
} | php | private function setUrlService(Di $di, Config $config, $name)
{
$base = $static = '/';
if (isset($config['url'])) {
$default = isset($config['url']['default']) ? $config['url']['default'] : '/';
if (isset($config['url'][$name])) {
$base = isset($config['url'][$name]['uri']) ? $config['url'][$name]['uri'] : $default;
$static = isset($config['url'][$name]['static']) ? $config['url'][$name]['static'] : $default;
}
}
$url = new UrlService();
$url->setBaseUri($base);
$url->setStaticBaseUri($static);
$di->set('url', $url, true);
return $this;
} | [
"private",
"function",
"setUrlService",
"(",
"Di",
"$",
"di",
",",
"Config",
"$",
"config",
",",
"$",
"name",
")",
"{",
"$",
"base",
"=",
"$",
"static",
"=",
"'/'",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"default",
"=",
"isset",
"(",
"$",
"config",
"[",
"'url'",
"]",
"[",
"'default'",
"]",
")",
"?",
"$",
"config",
"[",
"'url'",
"]",
"[",
"'default'",
"]",
":",
"'/'",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'url'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"base",
"=",
"isset",
"(",
"$",
"config",
"[",
"'url'",
"]",
"[",
"$",
"name",
"]",
"[",
"'uri'",
"]",
")",
"?",
"$",
"config",
"[",
"'url'",
"]",
"[",
"$",
"name",
"]",
"[",
"'uri'",
"]",
":",
"$",
"default",
";",
"$",
"static",
"=",
"isset",
"(",
"$",
"config",
"[",
"'url'",
"]",
"[",
"$",
"name",
"]",
"[",
"'static'",
"]",
")",
"?",
"$",
"config",
"[",
"'url'",
"]",
"[",
"$",
"name",
"]",
"[",
"'static'",
"]",
":",
"$",
"default",
";",
"}",
"}",
"$",
"url",
"=",
"new",
"UrlService",
"(",
")",
";",
"$",
"url",
"->",
"setBaseUri",
"(",
"$",
"base",
")",
";",
"$",
"url",
"->",
"setStaticBaseUri",
"(",
"$",
"static",
")",
";",
"$",
"di",
"->",
"set",
"(",
"'url'",
",",
"$",
"url",
",",
"true",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set url service when module start
@param Di $di
@param Config $config
@param string $name Module name
@return \Phalex\Events\Listener\Application | [
"Set",
"url",
"service",
"when",
"module",
"start"
] | 6452b4e695b456838d9d553d96f2b114e1c110b4 | https://github.com/tmquang6805/phalex/blob/6452b4e695b456838d9d553d96f2b114e1c110b4/library/Phalex/Events/Listener/Application.php#L81-L97 |
1,675 | dendevs/plpconfig | src/libs/FileLib.php | FileLib.check_dir | public function check_dir( $need_not_empty = true )
{
$ok = false;
if( is_dir( $this->_dir_path ) && is_readable( $this->_dir_path ) )
{
$ok = true;
if( $need_not_empty )
{
$ok = ( count( scandir( $this->_dir_path ) ) > 0 ) ? true: false;
}
}
return $ok;
} | php | public function check_dir( $need_not_empty = true )
{
$ok = false;
if( is_dir( $this->_dir_path ) && is_readable( $this->_dir_path ) )
{
$ok = true;
if( $need_not_empty )
{
$ok = ( count( scandir( $this->_dir_path ) ) > 0 ) ? true: false;
}
}
return $ok;
} | [
"public",
"function",
"check_dir",
"(",
"$",
"need_not_empty",
"=",
"true",
")",
"{",
"$",
"ok",
"=",
"false",
";",
"if",
"(",
"is_dir",
"(",
"$",
"this",
"->",
"_dir_path",
")",
"&&",
"is_readable",
"(",
"$",
"this",
"->",
"_dir_path",
")",
")",
"{",
"$",
"ok",
"=",
"true",
";",
"if",
"(",
"$",
"need_not_empty",
")",
"{",
"$",
"ok",
"=",
"(",
"count",
"(",
"scandir",
"(",
"$",
"this",
"->",
"_dir_path",
")",
")",
">",
"0",
")",
"?",
"true",
":",
"false",
";",
"}",
"}",
"return",
"$",
"ok",
";",
"}"
] | Verifie la validite du repertoire.
Verifie si il existe, est un repertoire non vide
@param bool $need_not_empty rajoute une condition de validation, le repertoire ne peut etre vide
@return bool true si le repertoire est utilisable | [
"Verifie",
"la",
"validite",
"du",
"repertoire",
"."
] | fa198ed504a248420d1a6b59397438a3cfd83d49 | https://github.com/dendevs/plpconfig/blob/fa198ed504a248420d1a6b59397438a3cfd83d49/src/libs/FileLib.php#L37-L50 |
1,676 | dendevs/plpconfig | src/libs/FileLib.php | FileLib.get_path_files | public function get_path_files()
{
$path_files = array();
$tmp_contents_dir = scandir( $this->_dir_path );
foreach( $tmp_contents_dir as $tmp_content_dir )
{
if( is_file( $this->_dir_path . $tmp_content_dir ) )
{
$service_name = strtolower( preg_replace('/\\.[^.\\s]{3,4}$/', '', $tmp_content_dir ) );
$path_files[$service_name] = $tmp_content_dir;
}
}
return $path_files;
} | php | public function get_path_files()
{
$path_files = array();
$tmp_contents_dir = scandir( $this->_dir_path );
foreach( $tmp_contents_dir as $tmp_content_dir )
{
if( is_file( $this->_dir_path . $tmp_content_dir ) )
{
$service_name = strtolower( preg_replace('/\\.[^.\\s]{3,4}$/', '', $tmp_content_dir ) );
$path_files[$service_name] = $tmp_content_dir;
}
}
return $path_files;
} | [
"public",
"function",
"get_path_files",
"(",
")",
"{",
"$",
"path_files",
"=",
"array",
"(",
")",
";",
"$",
"tmp_contents_dir",
"=",
"scandir",
"(",
"$",
"this",
"->",
"_dir_path",
")",
";",
"foreach",
"(",
"$",
"tmp_contents_dir",
"as",
"$",
"tmp_content_dir",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"this",
"->",
"_dir_path",
".",
"$",
"tmp_content_dir",
")",
")",
"{",
"$",
"service_name",
"=",
"strtolower",
"(",
"preg_replace",
"(",
"'/\\\\.[^.\\\\s]{3,4}$/'",
",",
"''",
",",
"$",
"tmp_content_dir",
")",
")",
";",
"$",
"path_files",
"[",
"$",
"service_name",
"]",
"=",
"$",
"tmp_content_dir",
";",
"}",
"}",
"return",
"$",
"path_files",
";",
"}"
] | Donne le chemin de tout les fichiers contenus dans le repertoire
@return array tabeau des fichiers trouver | [
"Donne",
"le",
"chemin",
"de",
"tout",
"les",
"fichiers",
"contenus",
"dans",
"le",
"repertoire"
] | fa198ed504a248420d1a6b59397438a3cfd83d49 | https://github.com/dendevs/plpconfig/blob/fa198ed504a248420d1a6b59397438a3cfd83d49/src/libs/FileLib.php#L57-L72 |
1,677 | Dhii/tokenizer-abstract | src/ColumnNumberAwareTrait.php | ColumnNumberAwareTrait._setColumnNumber | protected function _setColumnNumber($columnNumber)
{
if ($columnNumber !== null) {
try {
$columnNumber = $this->_normalizeInt($columnNumber);
} catch (RootException $e) {
throw $this->_createInvalidArgumentException($this->__('Invalid column number'), null, $e, $columnNumber);
}
if ($columnNumber < 1) {
throw $this->_createInvalidArgumentException($this->__('Column number must be positive'), null, null, $columnNumber);
}
}
$this->columnNumber = $columnNumber;
} | php | protected function _setColumnNumber($columnNumber)
{
if ($columnNumber !== null) {
try {
$columnNumber = $this->_normalizeInt($columnNumber);
} catch (RootException $e) {
throw $this->_createInvalidArgumentException($this->__('Invalid column number'), null, $e, $columnNumber);
}
if ($columnNumber < 1) {
throw $this->_createInvalidArgumentException($this->__('Column number must be positive'), null, null, $columnNumber);
}
}
$this->columnNumber = $columnNumber;
} | [
"protected",
"function",
"_setColumnNumber",
"(",
"$",
"columnNumber",
")",
"{",
"if",
"(",
"$",
"columnNumber",
"!==",
"null",
")",
"{",
"try",
"{",
"$",
"columnNumber",
"=",
"$",
"this",
"->",
"_normalizeInt",
"(",
"$",
"columnNumber",
")",
";",
"}",
"catch",
"(",
"RootException",
"$",
"e",
")",
"{",
"throw",
"$",
"this",
"->",
"_createInvalidArgumentException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Invalid column number'",
")",
",",
"null",
",",
"$",
"e",
",",
"$",
"columnNumber",
")",
";",
"}",
"if",
"(",
"$",
"columnNumber",
"<",
"1",
")",
"{",
"throw",
"$",
"this",
"->",
"_createInvalidArgumentException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Column number must be positive'",
")",
",",
"null",
",",
"null",
",",
"$",
"columnNumber",
")",
";",
"}",
"}",
"$",
"this",
"->",
"columnNumber",
"=",
"$",
"columnNumber",
";",
"}"
] | Assigns a column number to this instance.
@since [*next-version*]
@param int|string|Stringable|float|null $columnNumber The column number.
Must be a whole positive number. | [
"Assigns",
"a",
"column",
"number",
"to",
"this",
"instance",
"."
] | 45588113b1fca6daf62b776aade8627d08970565 | https://github.com/Dhii/tokenizer-abstract/blob/45588113b1fca6daf62b776aade8627d08970565/src/ColumnNumberAwareTrait.php#L42-L57 |
1,678 | Solve/Solve | SolveConsole/Controllers/DbController.php | DbController.wizardAction | public function wizardAction() {
$this->writeln('DB wizard for a profile');
$profileName = $this->ask('Enter the <underline>profile name</underline> to edit', 'default');
$fields = $this->askArray(array(
'name' => array('DB name',),
'user' => array('DB user', 'root',),
'pass' => array('DB password', 'root',),
'host' => array('DB host', '127.0.0.1',),
));
if ($this->confirm('Write to file', true)) {
$config = DC::getDatabaseConfig();
foreach($fields as $field=>$value) {
$config->set('profiles/' . $profileName . '/' . $field, $value);
}
$config->save();
$this->notify(ConfigService::getConfigsPath() . 'database.yml', 'saved');
} else {
$this->writeln('exiting.');
}
} | php | public function wizardAction() {
$this->writeln('DB wizard for a profile');
$profileName = $this->ask('Enter the <underline>profile name</underline> to edit', 'default');
$fields = $this->askArray(array(
'name' => array('DB name',),
'user' => array('DB user', 'root',),
'pass' => array('DB password', 'root',),
'host' => array('DB host', '127.0.0.1',),
));
if ($this->confirm('Write to file', true)) {
$config = DC::getDatabaseConfig();
foreach($fields as $field=>$value) {
$config->set('profiles/' . $profileName . '/' . $field, $value);
}
$config->save();
$this->notify(ConfigService::getConfigsPath() . 'database.yml', 'saved');
} else {
$this->writeln('exiting.');
}
} | [
"public",
"function",
"wizardAction",
"(",
")",
"{",
"$",
"this",
"->",
"writeln",
"(",
"'DB wizard for a profile'",
")",
";",
"$",
"profileName",
"=",
"$",
"this",
"->",
"ask",
"(",
"'Enter the <underline>profile name</underline> to edit'",
",",
"'default'",
")",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"askArray",
"(",
"array",
"(",
"'name'",
"=>",
"array",
"(",
"'DB name'",
",",
")",
",",
"'user'",
"=>",
"array",
"(",
"'DB user'",
",",
"'root'",
",",
")",
",",
"'pass'",
"=>",
"array",
"(",
"'DB password'",
",",
"'root'",
",",
")",
",",
"'host'",
"=>",
"array",
"(",
"'DB host'",
",",
"'127.0.0.1'",
",",
")",
",",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"'Write to file'",
",",
"true",
")",
")",
"{",
"$",
"config",
"=",
"DC",
"::",
"getDatabaseConfig",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"config",
"->",
"set",
"(",
"'profiles/'",
".",
"$",
"profileName",
".",
"'/'",
".",
"$",
"field",
",",
"$",
"value",
")",
";",
"}",
"$",
"config",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"notify",
"(",
"ConfigService",
"::",
"getConfigsPath",
"(",
")",
".",
"'database.yml'",
",",
"'saved'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"writeln",
"(",
"'exiting.'",
")",
";",
"}",
"}"
] | Using for generating profile for database
@help Using for generating profile for database
@optional [profile name] to specify profile | [
"Using",
"for",
"generating",
"profile",
"for",
"database"
] | b2ac834c37831ba6049dafa28255d32b4ea0bf1d | https://github.com/Solve/Solve/blob/b2ac834c37831ba6049dafa28255d32b4ea0bf1d/SolveConsole/Controllers/DbController.php#L61-L80 |
1,679 | Solve/Solve | SolveConsole/Controllers/DbController.php | DbController.updateAllAction | public function updateAllAction() {
QC::executeSQL('SET FOREIGN_KEY_CHECKS = 0');
ModelOperator::getInstance(DC::getEnvironment()->getUserClassesRoot().'db/')->updateDBForAllModels();
ModelOperator::getInstance()->generateAllModelClasses();
$this->writeln('DB updated');
} | php | public function updateAllAction() {
QC::executeSQL('SET FOREIGN_KEY_CHECKS = 0');
ModelOperator::getInstance(DC::getEnvironment()->getUserClassesRoot().'db/')->updateDBForAllModels();
ModelOperator::getInstance()->generateAllModelClasses();
$this->writeln('DB updated');
} | [
"public",
"function",
"updateAllAction",
"(",
")",
"{",
"QC",
"::",
"executeSQL",
"(",
"'SET FOREIGN_KEY_CHECKS = 0'",
")",
";",
"ModelOperator",
"::",
"getInstance",
"(",
"DC",
"::",
"getEnvironment",
"(",
")",
"->",
"getUserClassesRoot",
"(",
")",
".",
"'db/'",
")",
"->",
"updateDBForAllModels",
"(",
")",
";",
"ModelOperator",
"::",
"getInstance",
"(",
")",
"->",
"generateAllModelClasses",
"(",
")",
";",
"$",
"this",
"->",
"writeln",
"(",
"'DB updated'",
")",
";",
"}"
] | Update database and models | [
"Update",
"database",
"and",
"models"
] | b2ac834c37831ba6049dafa28255d32b4ea0bf1d | https://github.com/Solve/Solve/blob/b2ac834c37831ba6049dafa28255d32b4ea0bf1d/SolveConsole/Controllers/DbController.php#L85-L90 |
1,680 | Solve/Solve | SolveConsole/Controllers/DbController.php | DbController.createDbAction | public function createDbAction() {
$config = DC::getDatabaseConfig('profiles/default');
DatabaseService::configProfile(array(
'user' => $config['user'],
'pass' => $config['pass'],
));
DBOperator::getInstance()->createDB($config['name']);
$this->notify($config['name'], '+Database created:');
} | php | public function createDbAction() {
$config = DC::getDatabaseConfig('profiles/default');
DatabaseService::configProfile(array(
'user' => $config['user'],
'pass' => $config['pass'],
));
DBOperator::getInstance()->createDB($config['name']);
$this->notify($config['name'], '+Database created:');
} | [
"public",
"function",
"createDbAction",
"(",
")",
"{",
"$",
"config",
"=",
"DC",
"::",
"getDatabaseConfig",
"(",
"'profiles/default'",
")",
";",
"DatabaseService",
"::",
"configProfile",
"(",
"array",
"(",
"'user'",
"=>",
"$",
"config",
"[",
"'user'",
"]",
",",
"'pass'",
"=>",
"$",
"config",
"[",
"'pass'",
"]",
",",
")",
")",
";",
"DBOperator",
"::",
"getInstance",
"(",
")",
"->",
"createDB",
"(",
"$",
"config",
"[",
"'name'",
"]",
")",
";",
"$",
"this",
"->",
"notify",
"(",
"$",
"config",
"[",
"'name'",
"]",
",",
"'+Database created:'",
")",
";",
"}"
] | Created database for profile default | [
"Created",
"database",
"for",
"profile",
"default"
] | b2ac834c37831ba6049dafa28255d32b4ea0bf1d | https://github.com/Solve/Solve/blob/b2ac834c37831ba6049dafa28255d32b4ea0bf1d/SolveConsole/Controllers/DbController.php#L95-L104 |
1,681 | cityware/city-utility | src/Recursivity/Tree/Node.php | Node.addChild | public function addChild(Node $child)
{
$this->children[] = $child;
$child->parent = $this;
$child->properties['parent'] = $this->getId();
} | php | public function addChild(Node $child)
{
$this->children[] = $child;
$child->parent = $this;
$child->properties['parent'] = $this->getId();
} | [
"public",
"function",
"addChild",
"(",
"Node",
"$",
"child",
")",
"{",
"$",
"this",
"->",
"children",
"[",
"]",
"=",
"$",
"child",
";",
"$",
"child",
"->",
"parent",
"=",
"$",
"this",
";",
"$",
"child",
"->",
"properties",
"[",
"'parent'",
"]",
"=",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"}"
] | Adds the given node to this node's children
@param Node $child | [
"Adds",
"the",
"given",
"node",
"to",
"this",
"node",
"s",
"children"
] | fadd33233cdaf743d87c3c30e341f2b96e96e476 | https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/Recursivity/Tree/Node.php#L74-L79 |
1,682 | cityware/city-utility | src/Recursivity/Tree/Node.php | Node.getSibling | private function getSibling($offset)
{
$siblingsAndSelf = $this->parent->getChildren();
$pos = array_search($this, $siblingsAndSelf);
if (isset($siblingsAndSelf[$pos + $offset])) {
return $siblingsAndSelf[$pos + $offset]; // Next / prev. node
}
return null;
} | php | private function getSibling($offset)
{
$siblingsAndSelf = $this->parent->getChildren();
$pos = array_search($this, $siblingsAndSelf);
if (isset($siblingsAndSelf[$pos + $offset])) {
return $siblingsAndSelf[$pos + $offset]; // Next / prev. node
}
return null;
} | [
"private",
"function",
"getSibling",
"(",
"$",
"offset",
")",
"{",
"$",
"siblingsAndSelf",
"=",
"$",
"this",
"->",
"parent",
"->",
"getChildren",
"(",
")",
";",
"$",
"pos",
"=",
"array_search",
"(",
"$",
"this",
",",
"$",
"siblingsAndSelf",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"siblingsAndSelf",
"[",
"$",
"pos",
"+",
"$",
"offset",
"]",
")",
")",
"{",
"return",
"$",
"siblingsAndSelf",
"[",
"$",
"pos",
"+",
"$",
"offset",
"]",
";",
"// Next / prev. node",
"}",
"return",
"null",
";",
"}"
] | Returns the sibling with the given offset from this node,
or NULL if there is no such sibling
@param int $offset If 1, the next node is returned, if -1, then
the previous one. Can be called with arbitrary
values, too, if desired.
@return Node|null | [
"Returns",
"the",
"sibling",
"with",
"the",
"given",
"offset",
"from",
"this",
"node",
"or",
"NULL",
"if",
"there",
"is",
"no",
"such",
"sibling"
] | fadd33233cdaf743d87c3c30e341f2b96e96e476 | https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/Recursivity/Tree/Node.php#L111-L119 |
1,683 | cityware/city-utility | src/Recursivity/Tree/Node.php | Node.getSiblings | public function getSiblings($includeSelf = false)
{
$siblings = array();
foreach ($this->parent->getChildren() as $child) {
if ($includeSelf || $child->getId() != $this->getId()) {
$siblings[] = $child;
}
}
return $siblings;
} | php | public function getSiblings($includeSelf = false)
{
$siblings = array();
foreach ($this->parent->getChildren() as $child) {
if ($includeSelf || $child->getId() != $this->getId()) {
$siblings[] = $child;
}
}
return $siblings;
} | [
"public",
"function",
"getSiblings",
"(",
"$",
"includeSelf",
"=",
"false",
")",
"{",
"$",
"siblings",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"parent",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"includeSelf",
"||",
"$",
"child",
"->",
"getId",
"(",
")",
"!=",
"$",
"this",
"->",
"getId",
"(",
")",
")",
"{",
"$",
"siblings",
"[",
"]",
"=",
"$",
"child",
";",
"}",
"}",
"return",
"$",
"siblings",
";",
"}"
] | Returns siblings of the node, optionally including the node itself.
@param bool $includeSelf If true, the node itself will be included in the resulting
array. In either case, the sort order will be correct.
This argument is deprecated and will be removed in v2.0
Note: The argument is deprecated and will be removed in version 2; please
use getSiblingsAndSelf().
@return Node[] | [
"Returns",
"siblings",
"of",
"the",
"node",
"optionally",
"including",
"the",
"node",
"itself",
"."
] | fadd33233cdaf743d87c3c30e341f2b96e96e476 | https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/Recursivity/Tree/Node.php#L133-L142 |
1,684 | cityware/city-utility | src/Recursivity/Tree/Node.php | Node.get | public function get($name)
{
$lowerName = strtolower($name);
if (isset($this->properties[$lowerName])) {
return $this->properties[$lowerName];
}
throw new \InvalidArgumentException(
"Undefined property: $name (Node ID: ".$this->properties['id'].')'
);
} | php | public function get($name)
{
$lowerName = strtolower($name);
if (isset($this->properties[$lowerName])) {
return $this->properties[$lowerName];
}
throw new \InvalidArgumentException(
"Undefined property: $name (Node ID: ".$this->properties['id'].')'
);
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"$",
"lowerName",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"properties",
"[",
"$",
"lowerName",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"properties",
"[",
"$",
"lowerName",
"]",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Undefined property: $name (Node ID: \"",
".",
"$",
"this",
"->",
"properties",
"[",
"'id'",
"]",
".",
"')'",
")",
";",
"}"
] | Returns a single node property by its name.
@param string $name
@throws \InvalidArgumentException
@return mixed | [
"Returns",
"a",
"single",
"node",
"property",
"by",
"its",
"name",
"."
] | fadd33233cdaf743d87c3c30e341f2b96e96e476 | https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/Recursivity/Tree/Node.php#L196-L205 |
1,685 | veridu/idos-sdk-php | src/idOS/Endpoint/Company/Credentials.php | Credentials.createNew | public function createNew(
string $name,
bool $production
) : array {
return $this->sendPost(
sprintf('/companies/%s/credentials', $this->companySlug),
[],
[
'name' => $name,
'production' => $production
]
);
} | php | public function createNew(
string $name,
bool $production
) : array {
return $this->sendPost(
sprintf('/companies/%s/credentials', $this->companySlug),
[],
[
'name' => $name,
'production' => $production
]
);
} | [
"public",
"function",
"createNew",
"(",
"string",
"$",
"name",
",",
"bool",
"$",
"production",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"sendPost",
"(",
"sprintf",
"(",
"'/companies/%s/credentials'",
",",
"$",
"this",
"->",
"companySlug",
")",
",",
"[",
"]",
",",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'production'",
"=>",
"$",
"production",
"]",
")",
";",
"}"
] | Creates a new credential for the given company.
@param string $name
@param bool $production
@return array Response | [
"Creates",
"a",
"new",
"credential",
"for",
"the",
"given",
"company",
"."
] | e56757bed10404756f2f0485a4b7f55794192008 | https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Company/Credentials.php#L33-L46 |
1,686 | sagebind/libnntp | src/server/Server.php | Server.listen | public function listen(int $port = 119, string $address = self::DEFAULT_ADDRESS, array $options = [])
{
// Create a server for the requested address and port.
$server = $this->factory->create($address, $port, $options);
$this->servers[] = $server;
$coroutine = new Coroutine($this->accept($server));
$coroutine->done();
} | php | public function listen(int $port = 119, string $address = self::DEFAULT_ADDRESS, array $options = [])
{
// Create a server for the requested address and port.
$server = $this->factory->create($address, $port, $options);
$this->servers[] = $server;
$coroutine = new Coroutine($this->accept($server));
$coroutine->done();
} | [
"public",
"function",
"listen",
"(",
"int",
"$",
"port",
"=",
"119",
",",
"string",
"$",
"address",
"=",
"self",
"::",
"DEFAULT_ADDRESS",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"// Create a server for the requested address and port.",
"$",
"server",
"=",
"$",
"this",
"->",
"factory",
"->",
"create",
"(",
"$",
"address",
",",
"$",
"port",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"servers",
"[",
"]",
"=",
"$",
"server",
";",
"$",
"coroutine",
"=",
"new",
"Coroutine",
"(",
"$",
"this",
"->",
"accept",
"(",
"$",
"server",
")",
")",
";",
"$",
"coroutine",
"->",
"done",
"(",
")",
";",
"}"
] | Starts the server and begins listening for connections. | [
"Starts",
"the",
"server",
"and",
"begins",
"listening",
"for",
"connections",
"."
] | 4bb81847ec08df89bb77377e5da0b017613a0447 | https://github.com/sagebind/libnntp/blob/4bb81847ec08df89bb77377e5da0b017613a0447/src/server/Server.php#L40-L48 |
1,687 | sagebind/libnntp | src/server/Server.php | Server.getHandler | public function getHandler(string $handler): Handler
{
if (!isset($this->handlers[$handler])) {
if (!class_exists($handler) || !class_implements($handler, Handler::class)) {
throw new \RuntimeException("No handler found for '$handler'.");
}
$instance = new $handler();
$this->handlers[$handler] = $instance;
} else {
$instance = $this->handlers[$handler];
}
return $instance;
} | php | public function getHandler(string $handler): Handler
{
if (!isset($this->handlers[$handler])) {
if (!class_exists($handler) || !class_implements($handler, Handler::class)) {
throw new \RuntimeException("No handler found for '$handler'.");
}
$instance = new $handler();
$this->handlers[$handler] = $instance;
} else {
$instance = $this->handlers[$handler];
}
return $instance;
} | [
"public",
"function",
"getHandler",
"(",
"string",
"$",
"handler",
")",
":",
"Handler",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"handler",
"]",
")",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"handler",
")",
"||",
"!",
"class_implements",
"(",
"$",
"handler",
",",
"Handler",
"::",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"No handler found for '$handler'.\"",
")",
";",
"}",
"$",
"instance",
"=",
"new",
"$",
"handler",
"(",
")",
";",
"$",
"this",
"->",
"handlers",
"[",
"$",
"handler",
"]",
"=",
"$",
"instance",
";",
"}",
"else",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"handlers",
"[",
"$",
"handler",
"]",
";",
"}",
"return",
"$",
"instance",
";",
"}"
] | Gets a command handler instance.
Handler instances are lazy-instantiated. | [
"Gets",
"a",
"command",
"handler",
"instance",
"."
] | 4bb81847ec08df89bb77377e5da0b017613a0447 | https://github.com/sagebind/libnntp/blob/4bb81847ec08df89bb77377e5da0b017613a0447/src/server/Server.php#L65-L79 |
1,688 | sagebind/libnntp | src/server/Server.php | Server.accept | private function accept(SocketServer $server): Generator
{
yield from log()->log(
Log::INFO,
'NNTP server listening on %s:%d',
$server->getAddress(),
$server->getPort()
);
while ($server->isOpen()) {
// Wait for a client to connect.
$socket = yield from $server->accept();
// Handle the client in a separate coroutine.
$coroutine = new Coroutine($this->handleClient($socket));
$coroutine->done();
}
} | php | private function accept(SocketServer $server): Generator
{
yield from log()->log(
Log::INFO,
'NNTP server listening on %s:%d',
$server->getAddress(),
$server->getPort()
);
while ($server->isOpen()) {
// Wait for a client to connect.
$socket = yield from $server->accept();
// Handle the client in a separate coroutine.
$coroutine = new Coroutine($this->handleClient($socket));
$coroutine->done();
}
} | [
"private",
"function",
"accept",
"(",
"SocketServer",
"$",
"server",
")",
":",
"Generator",
"{",
"yield",
"from",
"log",
"(",
")",
"->",
"log",
"(",
"Log",
"::",
"INFO",
",",
"'NNTP server listening on %s:%d'",
",",
"$",
"server",
"->",
"getAddress",
"(",
")",
",",
"$",
"server",
"->",
"getPort",
"(",
")",
")",
";",
"while",
"(",
"$",
"server",
"->",
"isOpen",
"(",
")",
")",
"{",
"// Wait for a client to connect.",
"$",
"socket",
"=",
"yield",
"from",
"$",
"server",
"->",
"accept",
"(",
")",
";",
"// Handle the client in a separate coroutine.",
"$",
"coroutine",
"=",
"new",
"Coroutine",
"(",
"$",
"this",
"->",
"handleClient",
"(",
"$",
"socket",
")",
")",
";",
"$",
"coroutine",
"->",
"done",
"(",
")",
";",
"}",
"}"
] | Accepts incoming connections as they are made. | [
"Accepts",
"incoming",
"connections",
"as",
"they",
"are",
"made",
"."
] | 4bb81847ec08df89bb77377e5da0b017613a0447 | https://github.com/sagebind/libnntp/blob/4bb81847ec08df89bb77377e5da0b017613a0447/src/server/Server.php#L84-L101 |
1,689 | snowiow/cocurl | src/Location.php | Location.create | public static function create(array $data): Location
{
$location = new Location();
parent::fill($data, $location);
return $location;
} | php | public static function create(array $data): Location
{
$location = new Location();
parent::fill($data, $location);
return $location;
} | [
"public",
"static",
"function",
"create",
"(",
"array",
"$",
"data",
")",
":",
"Location",
"{",
"$",
"location",
"=",
"new",
"Location",
"(",
")",
";",
"parent",
"::",
"fill",
"(",
"$",
"data",
",",
"$",
"location",
")",
";",
"return",
"$",
"location",
";",
"}"
] | Creates a location object with the given data
@param array $data an associative array to fill up the members of the
location class
@return Location a location object with the data given as it's members | [
"Creates",
"a",
"location",
"object",
"with",
"the",
"given",
"data"
] | 583df05bd3c8f24fd99f294da9906a3e4b1a9c7b | https://github.com/snowiow/cocurl/blob/583df05bd3c8f24fd99f294da9906a3e4b1a9c7b/src/Location.php#L43-L48 |
1,690 | jayaregalinada/chikka | src/Forms/SenderForm.php | SenderForm.createId | protected function createId($id)
{
if (is_null($id)) {
return md5(join('_', [
$this->config['shortcode'],
$this->mobile,
time(),
]));
}
return $id;
} | php | protected function createId($id)
{
if (is_null($id)) {
return md5(join('_', [
$this->config['shortcode'],
$this->mobile,
time(),
]));
}
return $id;
} | [
"protected",
"function",
"createId",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"id",
")",
")",
"{",
"return",
"md5",
"(",
"join",
"(",
"'_'",
",",
"[",
"$",
"this",
"->",
"config",
"[",
"'shortcode'",
"]",
",",
"$",
"this",
"->",
"mobile",
",",
"time",
"(",
")",
",",
"]",
")",
")",
";",
"}",
"return",
"$",
"id",
";",
"}"
] | Create a message id.
@param mixed $id
@return mixed | [
"Create",
"a",
"message",
"id",
"."
] | eefd52c6a7c0e22fe82cef00c52874865456dddf | https://github.com/jayaregalinada/chikka/blob/eefd52c6a7c0e22fe82cef00c52874865456dddf/src/Forms/SenderForm.php#L93-L104 |
1,691 | lamjack/php-tools | lib/Network/File.php | File.getHeaders | static public function getHeaders($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
curl_exec($ch);
$headers = curl_getinfo($ch);
curl_close($ch);
return $headers;
} | php | static public function getHeaders($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
curl_exec($ch);
$headers = curl_getinfo($ch);
curl_close($ch);
return $headers;
} | [
"static",
"public",
"function",
"getHeaders",
"(",
"$",
"url",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_NOBODY",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"false",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HEADER",
",",
"false",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_FOLLOWLOCATION",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_MAXREDIRS",
",",
"3",
")",
";",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"headers",
"=",
"curl_getinfo",
"(",
"$",
"ch",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"return",
"$",
"headers",
";",
"}"
] | Get Headers function
@param string $url
@return array | [
"Get",
"Headers",
"function"
] | f7d9ffa17312dc2378003e8f917543adc95dddbd | https://github.com/lamjack/php-tools/blob/f7d9ffa17312dc2378003e8f917543adc95dddbd/lib/Network/File.php#L31-L44 |
1,692 | gamernetwork/yolk-core | src/helpers/ArrayHelper.php | ArrayHelper.get | public static function get( $var, $key, $default = null ) {
if( $key === null )
return $var;
elseif( isset($var->$key) )
return $var->$key;
elseif( isset($var[$key]) )
return $var[$key];
else
return $default;
} | php | public static function get( $var, $key, $default = null ) {
if( $key === null )
return $var;
elseif( isset($var->$key) )
return $var->$key;
elseif( isset($var[$key]) )
return $var[$key];
else
return $default;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"var",
",",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"return",
"$",
"var",
";",
"elseif",
"(",
"isset",
"(",
"$",
"var",
"->",
"$",
"key",
")",
")",
"return",
"$",
"var",
"->",
"$",
"key",
";",
"elseif",
"(",
"isset",
"(",
"$",
"var",
"[",
"$",
"key",
"]",
")",
")",
"return",
"$",
"var",
"[",
"$",
"key",
"]",
";",
"else",
"return",
"$",
"default",
";",
"}"
] | Return value of the specified key from an array or object or a default if the key isn't set.
@param array|object $var
@param string|integer $key
@param mixed $default
@return mixed | [
"Return",
"value",
"of",
"the",
"specified",
"key",
"from",
"an",
"array",
"or",
"object",
"or",
"a",
"default",
"if",
"the",
"key",
"isn",
"t",
"set",
"."
] | d9567dd55c51507dd34a55fd335a7b333e3db269 | https://github.com/gamernetwork/yolk-core/blob/d9567dd55c51507dd34a55fd335a7b333e3db269/src/helpers/ArrayHelper.php#L86-L97 |
1,693 | gamernetwork/yolk-core | src/helpers/ArrayHelper.php | ArrayHelper.pluck | public static function pluck( $vars, $field, $preserve_keys = true ) {
$values = [];
foreach( $vars as $k => $v ) {
$values[$k] = static::get($v, $field);
}
return $preserve_keys ? $values : array_values($values);
} | php | public static function pluck( $vars, $field, $preserve_keys = true ) {
$values = [];
foreach( $vars as $k => $v ) {
$values[$k] = static::get($v, $field);
}
return $preserve_keys ? $values : array_values($values);
} | [
"public",
"static",
"function",
"pluck",
"(",
"$",
"vars",
",",
"$",
"field",
",",
"$",
"preserve_keys",
"=",
"true",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"vars",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"values",
"[",
"$",
"k",
"]",
"=",
"static",
"::",
"get",
"(",
"$",
"v",
",",
"$",
"field",
")",
";",
"}",
"return",
"$",
"preserve_keys",
"?",
"$",
"values",
":",
"array_values",
"(",
"$",
"values",
")",
";",
"}"
] | Extract a single field from an array of arrays or objects.
@param array $vars An array or arrays or objects
@param string $field The field to get values from
@param boolean $preserve_keys Whether or not to preserve the array keys
@return array | [
"Extract",
"a",
"single",
"field",
"from",
"an",
"array",
"of",
"arrays",
"or",
"objects",
"."
] | d9567dd55c51507dd34a55fd335a7b333e3db269 | https://github.com/gamernetwork/yolk-core/blob/d9567dd55c51507dd34a55fd335a7b333e3db269/src/helpers/ArrayHelper.php#L116-L122 |
1,694 | webriq/core | module/Core/src/Grid/Core/Model/SubDomain/Model.php | Model.findActual | public function findActual()
{
if ( null === $this->actual )
{
$this->actual = $this->find( $this->getSiteInfo()
->getSubdomainId() );
}
return $this->actual;
} | php | public function findActual()
{
if ( null === $this->actual )
{
$this->actual = $this->find( $this->getSiteInfo()
->getSubdomainId() );
}
return $this->actual;
} | [
"public",
"function",
"findActual",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"actual",
")",
"{",
"$",
"this",
"->",
"actual",
"=",
"$",
"this",
"->",
"find",
"(",
"$",
"this",
"->",
"getSiteInfo",
"(",
")",
"->",
"getSubdomainId",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"actual",
";",
"}"
] | Find the current actual sub-domain
@return \Grid\Core\Model\SubDomain\Structure | [
"Find",
"the",
"current",
"actual",
"sub",
"-",
"domain"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Model/SubDomain/Model.php#L69-L78 |
1,695 | internalsystemerror/ise-module-bootstrap | src/Form/View/Helper/FormButton.php | FormButton.renderElementIcon | protected function renderElementIcon(ElementInterface $element)
{
$render = '';
$icon = $element->getOption('icon');
if ($icon) {
$iconHelper = $this->getIconHelper();
$render = $iconHelper($icon);
}
return $render;
} | php | protected function renderElementIcon(ElementInterface $element)
{
$render = '';
$icon = $element->getOption('icon');
if ($icon) {
$iconHelper = $this->getIconHelper();
$render = $iconHelper($icon);
}
return $render;
} | [
"protected",
"function",
"renderElementIcon",
"(",
"ElementInterface",
"$",
"element",
")",
"{",
"$",
"render",
"=",
"''",
";",
"$",
"icon",
"=",
"$",
"element",
"->",
"getOption",
"(",
"'icon'",
")",
";",
"if",
"(",
"$",
"icon",
")",
"{",
"$",
"iconHelper",
"=",
"$",
"this",
"->",
"getIconHelper",
"(",
")",
";",
"$",
"render",
"=",
"$",
"iconHelper",
"(",
"$",
"icon",
")",
";",
"}",
"return",
"$",
"render",
";",
"}"
] | Render element icon
@param ElementInterface $element
@return string | [
"Render",
"element",
"icon"
] | 289afa531a12e6159568b592b95964374442e850 | https://github.com/internalsystemerror/ise-module-bootstrap/blob/289afa531a12e6159568b592b95964374442e850/src/Form/View/Helper/FormButton.php#L156-L165 |
1,696 | internalsystemerror/ise-module-bootstrap | src/Form/View/Helper/FormButton.php | FormButton.setElementClass | protected function setElementClass(ElementInterface $element)
{
$class = $element->getAttribute('class');
$type = $element->getOption('type') ? : self::TYPE_DEFAULT;
if (!in_array($type, self::TYPES, true)) {
throw new Exception\DomainException(sprintf(
'%s requires that the button type is one of "' . implode('", "', self::TYPES) . '"',
__METHOD__
));
}
if ($class) {
$class .= ' ';
}
$class .= 'btn btn-' . $type;
$element->setAttribute('class', $class);
} | php | protected function setElementClass(ElementInterface $element)
{
$class = $element->getAttribute('class');
$type = $element->getOption('type') ? : self::TYPE_DEFAULT;
if (!in_array($type, self::TYPES, true)) {
throw new Exception\DomainException(sprintf(
'%s requires that the button type is one of "' . implode('", "', self::TYPES) . '"',
__METHOD__
));
}
if ($class) {
$class .= ' ';
}
$class .= 'btn btn-' . $type;
$element->setAttribute('class', $class);
} | [
"protected",
"function",
"setElementClass",
"(",
"ElementInterface",
"$",
"element",
")",
"{",
"$",
"class",
"=",
"$",
"element",
"->",
"getAttribute",
"(",
"'class'",
")",
";",
"$",
"type",
"=",
"$",
"element",
"->",
"getOption",
"(",
"'type'",
")",
"?",
":",
"self",
"::",
"TYPE_DEFAULT",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"type",
",",
"self",
"::",
"TYPES",
",",
"true",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"DomainException",
"(",
"sprintf",
"(",
"'%s requires that the button type is one of \"'",
".",
"implode",
"(",
"'\", \"'",
",",
"self",
"::",
"TYPES",
")",
".",
"'\"'",
",",
"__METHOD__",
")",
")",
";",
"}",
"if",
"(",
"$",
"class",
")",
"{",
"$",
"class",
".=",
"' '",
";",
"}",
"$",
"class",
".=",
"'btn btn-'",
".",
"$",
"type",
";",
"$",
"element",
"->",
"setAttribute",
"(",
"'class'",
",",
"$",
"class",
")",
";",
"}"
] | Set element class
@param ElementInterface $element
@throws Exception\DomainException | [
"Set",
"element",
"class"
] | 289afa531a12e6159568b592b95964374442e850 | https://github.com/internalsystemerror/ise-module-bootstrap/blob/289afa531a12e6159568b592b95964374442e850/src/Form/View/Helper/FormButton.php#L173-L190 |
1,697 | BapCat/Propifier | src/ArrayProperty.php | ArrayProperty.offsetGet | public function offsetGet($offset) {
if($this->get !== null) {
return $this->get->invoke($this->obj, $offset);
}
throw new NoSuchPropertyException($this->name);
} | php | public function offsetGet($offset) {
if($this->get !== null) {
return $this->get->invoke($this->obj, $offset);
}
throw new NoSuchPropertyException($this->name);
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"get",
"->",
"invoke",
"(",
"$",
"this",
"->",
"obj",
",",
"$",
"offset",
")",
";",
"}",
"throw",
"new",
"NoSuchPropertyException",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}"
] | Executes the accessor for a given array property
@throws NoSuchPropertyException If there is no accessor for this array property
@param mixed $offset The index into the array to access
@return mixed The return value of the accessor | [
"Executes",
"the",
"accessor",
"for",
"a",
"given",
"array",
"property"
] | a106b89585a32b2660076b635fb77a3729f8eeda | https://github.com/BapCat/Propifier/blob/a106b89585a32b2660076b635fb77a3729f8eeda/src/ArrayProperty.php#L78-L84 |
1,698 | BapCat/Propifier | src/ArrayProperty.php | ArrayProperty.offsetSet | public function offsetSet($offset, $value): void {
if($this->set !== null) {
$this->set->invoke($this->obj, $offset, $value);
return;
}
throw new NoSuchPropertyException($this->name);
} | php | public function offsetSet($offset, $value): void {
if($this->set !== null) {
$this->set->invoke($this->obj, $offset, $value);
return;
}
throw new NoSuchPropertyException($this->name);
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"set",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"set",
"->",
"invoke",
"(",
"$",
"this",
"->",
"obj",
",",
"$",
"offset",
",",
"$",
"value",
")",
";",
"return",
";",
"}",
"throw",
"new",
"NoSuchPropertyException",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}"
] | Executes the mutator for a given array property
@throws NoSuchPropertyException If there is no mutator for this array property
@param mixed $offset The index into the array to mutate
@param mixed $value The new value | [
"Executes",
"the",
"mutator",
"for",
"a",
"given",
"array",
"property"
] | a106b89585a32b2660076b635fb77a3729f8eeda | https://github.com/BapCat/Propifier/blob/a106b89585a32b2660076b635fb77a3729f8eeda/src/ArrayProperty.php#L94-L101 |
1,699 | BapCat/Propifier | src/ArrayProperty.php | ArrayProperty.getIterator | public function getIterator(): Traversable {
if($this->iterator !== null) {
return $this->iterator->invoke($this->obj);
}
throw new NoSuchPropertyException($this->name);
} | php | public function getIterator(): Traversable {
if($this->iterator !== null) {
return $this->iterator->invoke($this->obj);
}
throw new NoSuchPropertyException($this->name);
} | [
"public",
"function",
"getIterator",
"(",
")",
":",
"Traversable",
"{",
"if",
"(",
"$",
"this",
"->",
"iterator",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"iterator",
"->",
"invoke",
"(",
"$",
"this",
"->",
"obj",
")",
";",
"}",
"throw",
"new",
"NoSuchPropertyException",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}"
] | Returns the iterator for the array
@throws NoSuchPropertyException If there is no iterator for the array
@return Traversable The iterator | [
"Returns",
"the",
"iterator",
"for",
"the",
"array"
] | a106b89585a32b2660076b635fb77a3729f8eeda | https://github.com/BapCat/Propifier/blob/a106b89585a32b2660076b635fb77a3729f8eeda/src/ArrayProperty.php#L132-L138 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.