id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
225,800
|
kaystrobach/FLOW.Custom
|
Classes/Command/MailCommandController.php
|
MailCommandController.sendCommand
|
public function sendCommand(
$recipientMail,
$templateFile = 'resource://KayStrobach.Custom/Private/Templates/Mail/Default.html'
) {
$this->output->output('Sending Mail to ' . $recipientMail);
$mailUtility = new MailUtility();
$mailUtility->send(
$recipientMail,
$templateFile,
[
'values' => []
]
);
$this->output->outputLine(' <success>[DONE]</success>');
}
|
php
|
public function sendCommand(
$recipientMail,
$templateFile = 'resource://KayStrobach.Custom/Private/Templates/Mail/Default.html'
) {
$this->output->output('Sending Mail to ' . $recipientMail);
$mailUtility = new MailUtility();
$mailUtility->send(
$recipientMail,
$templateFile,
[
'values' => []
]
);
$this->output->outputLine(' <success>[DONE]</success>');
}
|
[
"public",
"function",
"sendCommand",
"(",
"$",
"recipientMail",
",",
"$",
"templateFile",
"=",
"'resource://KayStrobach.Custom/Private/Templates/Mail/Default.html'",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"output",
"(",
"'Sending Mail to '",
".",
"$",
"recipientMail",
")",
";",
"$",
"mailUtility",
"=",
"new",
"MailUtility",
"(",
")",
";",
"$",
"mailUtility",
"->",
"send",
"(",
"$",
"recipientMail",
",",
"$",
"templateFile",
",",
"[",
"'values'",
"=>",
"[",
"]",
"]",
")",
";",
"$",
"this",
"->",
"output",
"->",
"outputLine",
"(",
"' <success>[DONE]</success>'",
")",
";",
"}"
] |
An example command
The comment of this command method is also used for TYPO3 Flow's help screens. The first line should give a very short
summary about what the command does. Then, after an empty line, you should explain in more detail what the command
does. You might also give some usage example.
It is important to document the parameters with param tags, because that information will also appear in the help
screen.
@param string $recipientMail
@param string $templateFile
@return void
@throws \Neos\FluidAdaptor\View\Exception\InvalidSectionException
|
[
"An",
"example",
"command"
] |
873001a46fa0dfbc426edd74af1841cfa7bcf1b9
|
https://github.com/kaystrobach/FLOW.Custom/blob/873001a46fa0dfbc426edd74af1841cfa7bcf1b9/Classes/Command/MailCommandController.php#L44-L61
|
225,801
|
cloudcreativity/utils-object
|
src/Obj.php
|
Obj.replicate
|
public static function replicate($data)
{
$copy = clone $data;
foreach ($copy as $key => $value) {
if (is_object($value)) {
$copy->{$key} = static::replicate($value);
}
}
return $copy;
}
|
php
|
public static function replicate($data)
{
$copy = clone $data;
foreach ($copy as $key => $value) {
if (is_object($value)) {
$copy->{$key} = static::replicate($value);
}
}
return $copy;
}
|
[
"public",
"static",
"function",
"replicate",
"(",
"$",
"data",
")",
"{",
"$",
"copy",
"=",
"clone",
"$",
"data",
";",
"foreach",
"(",
"$",
"copy",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"$",
"copy",
"->",
"{",
"$",
"key",
"}",
"=",
"static",
"::",
"replicate",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"copy",
";",
"}"
] |
Clone the object recursively.
@param object $data
@return object
|
[
"Clone",
"the",
"object",
"recursively",
"."
] |
4b12016a0a6e5412d26472b2ffcdeadc5dd43ec2
|
https://github.com/cloudcreativity/utils-object/blob/4b12016a0a6e5412d26472b2ffcdeadc5dd43ec2/src/Obj.php#L86-L97
|
225,802
|
php-xapi/json-test-fixtures
|
src/JsonFixtures.php
|
JsonFixtures.load
|
protected static function load($file)
{
if (null !== static::DIRECTORY) {
return file_get_contents(__DIR__.'/../data/'.static::DIRECTORY.'/'.$file.'.json');
}
return file_get_contents(__DIR__.'/../data/'.$file.'.json');
}
|
php
|
protected static function load($file)
{
if (null !== static::DIRECTORY) {
return file_get_contents(__DIR__.'/../data/'.static::DIRECTORY.'/'.$file.'.json');
}
return file_get_contents(__DIR__.'/../data/'.$file.'.json');
}
|
[
"protected",
"static",
"function",
"load",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"null",
"!==",
"static",
"::",
"DIRECTORY",
")",
"{",
"return",
"file_get_contents",
"(",
"__DIR__",
".",
"'/../data/'",
".",
"static",
"::",
"DIRECTORY",
".",
"'/'",
".",
"$",
"file",
".",
"'.json'",
")",
";",
"}",
"return",
"file_get_contents",
"(",
"__DIR__",
".",
"'/../data/'",
".",
"$",
"file",
".",
"'.json'",
")",
";",
"}"
] |
Loads a JSON encoded fixture from the file system
@param string $file The fixture to load
@return string The JSON encoded fixture
|
[
"Loads",
"a",
"JSON",
"encoded",
"fixture",
"from",
"the",
"file",
"system"
] |
696bb6c4047f4e95e619b8bb31d83517ab009ac5
|
https://github.com/php-xapi/json-test-fixtures/blob/696bb6c4047f4e95e619b8bb31d83517ab009ac5/src/JsonFixtures.php#L30-L37
|
225,803
|
vperyod/vperyod.auth-handler
|
src/AuthHandler.php
|
AuthHandler.process
|
public function process(Request $request, Handler $handler): Response
{
$request = $request->withAttribute(
$this->authAttribute,
$this->resume()
);
return $handler->handle($request);
}
|
php
|
public function process(Request $request, Handler $handler): Response
{
$request = $request->withAttribute(
$this->authAttribute,
$this->resume()
);
return $handler->handle($request);
}
|
[
"public",
"function",
"process",
"(",
"Request",
"$",
"request",
",",
"Handler",
"$",
"handler",
")",
":",
"Response",
"{",
"$",
"request",
"=",
"$",
"request",
"->",
"withAttribute",
"(",
"$",
"this",
"->",
"authAttribute",
",",
"$",
"this",
"->",
"resume",
"(",
")",
")",
";",
"return",
"$",
"handler",
"->",
"handle",
"(",
"$",
"request",
")",
";",
"}"
] |
Resumes Authenticated Session
@param Request $request PSR7 HTTP Request
@param Handler $handler Next handler
@return Response
@access public
|
[
"Resumes",
"Authenticated",
"Session"
] |
7b90b4ca1d8a39f8ea159022046fe898eaae3db7
|
https://github.com/vperyod/vperyod.auth-handler/blob/7b90b4ca1d8a39f8ea159022046fe898eaae3db7/src/AuthHandler.php#L98-L105
|
225,804
|
SetBased/php-abc-form
|
src/RawForm.php
|
RawForm.hasScalars
|
public static function hasScalars(array $array): bool
{
$ret = false;
foreach ($array as $tmp)
{
if (is_object($tmp))
{
$ret = true;
break;
}
}
return $ret;
}
|
php
|
public static function hasScalars(array $array): bool
{
$ret = false;
foreach ($array as $tmp)
{
if (is_object($tmp))
{
$ret = true;
break;
}
}
return $ret;
}
|
[
"public",
"static",
"function",
"hasScalars",
"(",
"array",
"$",
"array",
")",
":",
"bool",
"{",
"$",
"ret",
"=",
"false",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"tmp",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"tmp",
")",
")",
"{",
"$",
"ret",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Returns true if array has one or more scalars. Otherwise, returns false.
@param array $array The array.
@return bool
|
[
"Returns",
"true",
"if",
"array",
"has",
"one",
"or",
"more",
"scalars",
".",
"Otherwise",
"returns",
"false",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/RawForm.php#L96-L109
|
225,805
|
SetBased/php-abc-form
|
src/RawForm.php
|
RawForm.getHtml
|
public function getHtml(): string
{
if (!isset($this->attributes['action']))
{
$this->attributes['action'] = Abc::$request->getRequestUri();
}
$this->prepare();
$html = $this->getHtmlStartTag();
$html .= $this->getHtmlBody();
$html .= $this->getHtmlEndTag();
return $html;
}
|
php
|
public function getHtml(): string
{
if (!isset($this->attributes['action']))
{
$this->attributes['action'] = Abc::$request->getRequestUri();
}
$this->prepare();
$html = $this->getHtmlStartTag();
$html .= $this->getHtmlBody();
$html .= $this->getHtmlEndTag();
return $html;
}
|
[
"public",
"function",
"getHtml",
"(",
")",
":",
"string",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'action'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'action'",
"]",
"=",
"Abc",
"::",
"$",
"request",
"->",
"getRequestUri",
"(",
")",
";",
"}",
"$",
"this",
"->",
"prepare",
"(",
")",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"getHtmlStartTag",
"(",
")",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"getHtmlBody",
"(",
")",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"getHtmlEndTag",
"(",
")",
";",
"return",
"$",
"html",
";",
"}"
] |
Returns the HTML code of this form.
Note: This method will not load submitted values
@return string
@since 1.0.0
@api
|
[
"Returns",
"the",
"HTML",
"code",
"of",
"this",
"form",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/RawForm.php#L214-L230
|
225,806
|
SetBased/php-abc-form
|
src/RawForm.php
|
RawForm.prepare
|
protected function prepare(): void
{
if (!$this->prepared)
{
$this->fieldSets->prepare('');
$this->prepared = true;
}
}
|
php
|
protected function prepare(): void
{
if (!$this->prepared)
{
$this->fieldSets->prepare('');
$this->prepared = true;
}
}
|
[
"protected",
"function",
"prepare",
"(",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"prepared",
")",
"{",
"$",
"this",
"->",
"fieldSets",
"->",
"prepare",
"(",
"''",
")",
";",
"$",
"this",
"->",
"prepared",
"=",
"true",
";",
"}",
"}"
] |
Prepares this form for HTML code generation or loading submitted values.
@since 1.0.0
@api
|
[
"Prepares",
"this",
"form",
"for",
"HTML",
"code",
"generation",
"or",
"loading",
"submitted",
"values",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/RawForm.php#L505-L513
|
225,807
|
SetBased/php-abc-form
|
src/RawForm.php
|
RawForm.searchSubmitHandler
|
protected function searchSubmitHandler(): ?string
{
switch ($this->attributes['method'])
{
case 'post':
$values = &$_POST;
break;
case 'get':
$values = &$_GET;
break;
default:
throw new FallenException('method', $this->attributes['method']);
}
return $this->fieldSets->searchSubmitHandler($values);
}
|
php
|
protected function searchSubmitHandler(): ?string
{
switch ($this->attributes['method'])
{
case 'post':
$values = &$_POST;
break;
case 'get':
$values = &$_GET;
break;
default:
throw new FallenException('method', $this->attributes['method']);
}
return $this->fieldSets->searchSubmitHandler($values);
}
|
[
"protected",
"function",
"searchSubmitHandler",
"(",
")",
":",
"?",
"string",
"{",
"switch",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'method'",
"]",
")",
"{",
"case",
"'post'",
":",
"$",
"values",
"=",
"&",
"$",
"_POST",
";",
"break",
";",
"case",
"'get'",
":",
"$",
"values",
"=",
"&",
"$",
"_GET",
";",
"break",
";",
"default",
":",
"throw",
"new",
"FallenException",
"(",
"'method'",
",",
"$",
"this",
"->",
"attributes",
"[",
"'method'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"fieldSets",
"->",
"searchSubmitHandler",
"(",
"$",
"values",
")",
";",
"}"
] |
If this form has been submitted returns the name of the method for handling this form. Otherwise, returns null.
@since 1.0.0
@api
@return string|null
|
[
"If",
"this",
"form",
"has",
"been",
"submitted",
"returns",
"the",
"name",
"of",
"the",
"method",
"for",
"handling",
"this",
"form",
".",
"Otherwise",
"returns",
"null",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/RawForm.php#L524-L541
|
225,808
|
php-toolkit/sys-utils
|
src/Sys.php
|
Sys.execInBackground
|
public static function execInBackground(string $cmd): void
{
if (self::isWindows()) {
\pclose(\popen('start /B ' . $cmd, 'r'));
} else {
\exec($cmd . ' > /dev/null &');
}
}
|
php
|
public static function execInBackground(string $cmd): void
{
if (self::isWindows()) {
\pclose(\popen('start /B ' . $cmd, 'r'));
} else {
\exec($cmd . ' > /dev/null &');
}
}
|
[
"public",
"static",
"function",
"execInBackground",
"(",
"string",
"$",
"cmd",
")",
":",
"void",
"{",
"if",
"(",
"self",
"::",
"isWindows",
"(",
")",
")",
"{",
"\\",
"pclose",
"(",
"\\",
"popen",
"(",
"'start /B '",
".",
"$",
"cmd",
",",
"'r'",
")",
")",
";",
"}",
"else",
"{",
"\\",
"exec",
"(",
"$",
"cmd",
".",
"' > /dev/null &'",
")",
";",
"}",
"}"
] |
run a command in background
@param string $cmd
|
[
"run",
"a",
"command",
"in",
"background"
] |
cf6ca81efed472ca4457e6f4325fe00398d2d0ca
|
https://github.com/php-toolkit/sys-utils/blob/cf6ca81efed472ca4457e6f4325fe00398d2d0ca/src/Sys.php#L155-L162
|
225,809
|
php-toolkit/sys-utils
|
src/Sys.php
|
Sys.getScreenSize
|
public static function getScreenSize(bool $refresh = false)
{
static $size;
if ($size !== null && !$refresh) {
return $size;
}
if (self::shIsAvailable()) {
// try stty if available
$stty = [];
if (
\exec('stty -a 2>&1', $stty) &&
\preg_match('/rows\s+(\d+);\s*columns\s+(\d+);/mi', implode(' ', $stty), $matches)
) {
return ($size = [$matches[2], $matches[1]]);
}
// fallback to tput, which may not be updated on terminal resize
if (($width = (int)exec('tput cols 2>&1')) > 0 && ($height = (int)exec('tput lines 2>&1')) > 0) {
return ($size = [$width, $height]);
}
// fallback to ENV variables, which may not be updated on terminal resize
if (($width = (int)getenv('COLUMNS')) > 0 && ($height = (int)getenv('LINES')) > 0) {
return ($size = [$width, $height]);
}
}
if (self::isWindows()) {
$output = [];
\exec('mode con', $output);
if (isset($output[1]) && strpos($output[1], 'CON') !== false) {
return ($size = [
(int)\preg_replace('~\D~', '', $output[3]),
(int)\preg_replace('~\D~', '', $output[4])
]);
}
}
return ($size = false);
}
|
php
|
public static function getScreenSize(bool $refresh = false)
{
static $size;
if ($size !== null && !$refresh) {
return $size;
}
if (self::shIsAvailable()) {
// try stty if available
$stty = [];
if (
\exec('stty -a 2>&1', $stty) &&
\preg_match('/rows\s+(\d+);\s*columns\s+(\d+);/mi', implode(' ', $stty), $matches)
) {
return ($size = [$matches[2], $matches[1]]);
}
// fallback to tput, which may not be updated on terminal resize
if (($width = (int)exec('tput cols 2>&1')) > 0 && ($height = (int)exec('tput lines 2>&1')) > 0) {
return ($size = [$width, $height]);
}
// fallback to ENV variables, which may not be updated on terminal resize
if (($width = (int)getenv('COLUMNS')) > 0 && ($height = (int)getenv('LINES')) > 0) {
return ($size = [$width, $height]);
}
}
if (self::isWindows()) {
$output = [];
\exec('mode con', $output);
if (isset($output[1]) && strpos($output[1], 'CON') !== false) {
return ($size = [
(int)\preg_replace('~\D~', '', $output[3]),
(int)\preg_replace('~\D~', '', $output[4])
]);
}
}
return ($size = false);
}
|
[
"public",
"static",
"function",
"getScreenSize",
"(",
"bool",
"$",
"refresh",
"=",
"false",
")",
"{",
"static",
"$",
"size",
";",
"if",
"(",
"$",
"size",
"!==",
"null",
"&&",
"!",
"$",
"refresh",
")",
"{",
"return",
"$",
"size",
";",
"}",
"if",
"(",
"self",
"::",
"shIsAvailable",
"(",
")",
")",
"{",
"// try stty if available",
"$",
"stty",
"=",
"[",
"]",
";",
"if",
"(",
"\\",
"exec",
"(",
"'stty -a 2>&1'",
",",
"$",
"stty",
")",
"&&",
"\\",
"preg_match",
"(",
"'/rows\\s+(\\d+);\\s*columns\\s+(\\d+);/mi'",
",",
"implode",
"(",
"' '",
",",
"$",
"stty",
")",
",",
"$",
"matches",
")",
")",
"{",
"return",
"(",
"$",
"size",
"=",
"[",
"$",
"matches",
"[",
"2",
"]",
",",
"$",
"matches",
"[",
"1",
"]",
"]",
")",
";",
"}",
"// fallback to tput, which may not be updated on terminal resize",
"if",
"(",
"(",
"$",
"width",
"=",
"(",
"int",
")",
"exec",
"(",
"'tput cols 2>&1'",
")",
")",
">",
"0",
"&&",
"(",
"$",
"height",
"=",
"(",
"int",
")",
"exec",
"(",
"'tput lines 2>&1'",
")",
")",
">",
"0",
")",
"{",
"return",
"(",
"$",
"size",
"=",
"[",
"$",
"width",
",",
"$",
"height",
"]",
")",
";",
"}",
"// fallback to ENV variables, which may not be updated on terminal resize",
"if",
"(",
"(",
"$",
"width",
"=",
"(",
"int",
")",
"getenv",
"(",
"'COLUMNS'",
")",
")",
">",
"0",
"&&",
"(",
"$",
"height",
"=",
"(",
"int",
")",
"getenv",
"(",
"'LINES'",
")",
")",
">",
"0",
")",
"{",
"return",
"(",
"$",
"size",
"=",
"[",
"$",
"width",
",",
"$",
"height",
"]",
")",
";",
"}",
"}",
"if",
"(",
"self",
"::",
"isWindows",
"(",
")",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"\\",
"exec",
"(",
"'mode con'",
",",
"$",
"output",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"output",
"[",
"1",
"]",
")",
"&&",
"strpos",
"(",
"$",
"output",
"[",
"1",
"]",
",",
"'CON'",
")",
"!==",
"false",
")",
"{",
"return",
"(",
"$",
"size",
"=",
"[",
"(",
"int",
")",
"\\",
"preg_replace",
"(",
"'~\\D~'",
",",
"''",
",",
"$",
"output",
"[",
"3",
"]",
")",
",",
"(",
"int",
")",
"\\",
"preg_replace",
"(",
"'~\\D~'",
",",
"''",
",",
"$",
"output",
"[",
"4",
"]",
")",
"]",
")",
";",
"}",
"}",
"return",
"(",
"$",
"size",
"=",
"false",
")",
";",
"}"
] |
get screen size
```php
list($width, $height) = Sys::getScreenSize();
```
@from Yii2
@param boolean $refresh whether to force checking and not re-use cached size value.
This is useful to detect changing window size while the application is running but may
not get up to date values on every terminal.
@return array|boolean An array of ($width, $height) or false when it was not able to determine size.
|
[
"get",
"screen",
"size"
] |
cf6ca81efed472ca4457e6f4325fe00398d2d0ca
|
https://github.com/php-toolkit/sys-utils/blob/cf6ca81efed472ca4457e6f4325fe00398d2d0ca/src/Sys.php#L255-L297
|
225,810
|
php-toolkit/file-utils
|
src/File.php
|
File.downBigFile
|
public static function downBigFile($file, $as): void
{
header('Expires: Mon, 1 Apr 1974 05:00:00 GMT');
header('Pragma: no-cache');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Description: File Download');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . trim(shell_exec('stat -c%s "$file"')));
header('Content-Disposition: attachment; filename="' . $as . '"');
header('Content-Transfer-Encoding: binary');
//@readfile( $file );
flush();
$fp = popen('tail -c ' . trim(shell_exec('stat -c%s "$file"')) . ' ' . $file . ' 2>&1', 'r');
while (!feof($fp)) {
// send the current file part to the browser
print fread($fp, 1024);
// flush the content to the browser
flush();
}
fclose($fp);
}
|
php
|
public static function downBigFile($file, $as): void
{
header('Expires: Mon, 1 Apr 1974 05:00:00 GMT');
header('Pragma: no-cache');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Description: File Download');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . trim(shell_exec('stat -c%s "$file"')));
header('Content-Disposition: attachment; filename="' . $as . '"');
header('Content-Transfer-Encoding: binary');
//@readfile( $file );
flush();
$fp = popen('tail -c ' . trim(shell_exec('stat -c%s "$file"')) . ' ' . $file . ' 2>&1', 'r');
while (!feof($fp)) {
// send the current file part to the browser
print fread($fp, 1024);
// flush the content to the browser
flush();
}
fclose($fp);
}
|
[
"public",
"static",
"function",
"downBigFile",
"(",
"$",
"file",
",",
"$",
"as",
")",
":",
"void",
"{",
"header",
"(",
"'Expires: Mon, 1 Apr 1974 05:00:00 GMT'",
")",
";",
"header",
"(",
"'Pragma: no-cache'",
")",
";",
"header",
"(",
"'Cache-Control: must-revalidate, post-check=0, pre-check=0'",
")",
";",
"header",
"(",
"'Content-Description: File Download'",
")",
";",
"header",
"(",
"'Content-Type: application/octet-stream'",
")",
";",
"header",
"(",
"'Content-Length: '",
".",
"trim",
"(",
"shell_exec",
"(",
"'stat -c%s \"$file\"'",
")",
")",
")",
";",
"header",
"(",
"'Content-Disposition: attachment; filename=\"'",
".",
"$",
"as",
".",
"'\"'",
")",
";",
"header",
"(",
"'Content-Transfer-Encoding: binary'",
")",
";",
"//@readfile( $file );",
"flush",
"(",
")",
";",
"$",
"fp",
"=",
"popen",
"(",
"'tail -c '",
".",
"trim",
"(",
"shell_exec",
"(",
"'stat -c%s \"$file\"'",
")",
")",
".",
"' '",
".",
"$",
"file",
".",
"' 2>&1'",
",",
"'r'",
")",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"fp",
")",
")",
"{",
"// send the current file part to the browser",
"print",
"fread",
"(",
"$",
"fp",
",",
"1024",
")",
";",
"// flush the content to the browser",
"flush",
"(",
")",
";",
"}",
"fclose",
"(",
"$",
"fp",
")",
";",
"}"
] |
If you want to download files from a linux server with
a filesize bigger than 2GB you can use the following
@param string $file
@param string $as
|
[
"If",
"you",
"want",
"to",
"download",
"files",
"from",
"a",
"linux",
"server",
"with",
"a",
"filesize",
"bigger",
"than",
"2GB",
"you",
"can",
"use",
"the",
"following"
] |
cf55fa8ce34000731460e8dc705d7006632119a8
|
https://github.com/php-toolkit/file-utils/blob/cf55fa8ce34000731460e8dc705d7006632119a8/src/File.php#L391-L414
|
225,811
|
SlayerBirden/dataflow
|
src/Plumber.php
|
Plumber.pour
|
public function pour(): void
{
$provider = $this->source->getCask();
foreach ($provider as $dataBag) {
try {
$this->pipeLine->rewind();
while ($this->pipeLine->valid()) {
$handler = $this->pipeLine->current();
$dataBag = $handler->pass($dataBag);
$this->pipeLine->next();
}
} catch (FlowTerminationException $exception) {
$this->emitter->emit('valve_closed', $exception->getIdentifier(), $dataBag);
}
}
$this->emitter->emit('empty_cask');
}
|
php
|
public function pour(): void
{
$provider = $this->source->getCask();
foreach ($provider as $dataBag) {
try {
$this->pipeLine->rewind();
while ($this->pipeLine->valid()) {
$handler = $this->pipeLine->current();
$dataBag = $handler->pass($dataBag);
$this->pipeLine->next();
}
} catch (FlowTerminationException $exception) {
$this->emitter->emit('valve_closed', $exception->getIdentifier(), $dataBag);
}
}
$this->emitter->emit('empty_cask');
}
|
[
"public",
"function",
"pour",
"(",
")",
":",
"void",
"{",
"$",
"provider",
"=",
"$",
"this",
"->",
"source",
"->",
"getCask",
"(",
")",
";",
"foreach",
"(",
"$",
"provider",
"as",
"$",
"dataBag",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"pipeLine",
"->",
"rewind",
"(",
")",
";",
"while",
"(",
"$",
"this",
"->",
"pipeLine",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"handler",
"=",
"$",
"this",
"->",
"pipeLine",
"->",
"current",
"(",
")",
";",
"$",
"dataBag",
"=",
"$",
"handler",
"->",
"pass",
"(",
"$",
"dataBag",
")",
";",
"$",
"this",
"->",
"pipeLine",
"->",
"next",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"FlowTerminationException",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"emitter",
"->",
"emit",
"(",
"'valve_closed'",
",",
"$",
"exception",
"->",
"getIdentifier",
"(",
")",
",",
"$",
"dataBag",
")",
";",
"}",
"}",
"$",
"this",
"->",
"emitter",
"->",
"emit",
"(",
"'empty_cask'",
")",
";",
"}"
] |
Pour source into pipeline.
|
[
"Pour",
"source",
"into",
"pipeline",
"."
] |
a9cb826b106e882e43523d39fea319adc4893e00
|
https://github.com/SlayerBirden/dataflow/blob/a9cb826b106e882e43523d39fea319adc4893e00/src/Plumber.php#L33-L49
|
225,812
|
oscarotero/inline-svg
|
src/Sources/FileSystem.php
|
FileSystem.getPath
|
protected function getPath($name)
{
$name = isset($this->map[$name]) ? $this->map[$name] : $name;
return "{$this->basePath}/{$name}.svg";
}
|
php
|
protected function getPath($name)
{
$name = isset($this->map[$name]) ? $this->map[$name] : $name;
return "{$this->basePath}/{$name}.svg";
}
|
[
"protected",
"function",
"getPath",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"isset",
"(",
"$",
"this",
"->",
"map",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"map",
"[",
"$",
"name",
"]",
":",
"$",
"name",
";",
"return",
"\"{$this->basePath}/{$name}.svg\"",
";",
"}"
] |
Returns the path of a svg.
@param string $name
@return string
|
[
"Returns",
"the",
"path",
"of",
"a",
"svg",
"."
] |
9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2
|
https://github.com/oscarotero/inline-svg/blob/9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2/src/Sources/FileSystem.php#L51-L56
|
225,813
|
puli/cli
|
src/Updater/PuliStrategy.php
|
PuliStrategy.setStability
|
public function setStability($stability)
{
if (!in_array($stability, self::$stabilities, true)) {
throw new InvalidArgumentException(
'Invalid stability value. Must be one of "stable", "unstable" or "any".'
);
}
$this->stability = $stability;
}
|
php
|
public function setStability($stability)
{
if (!in_array($stability, self::$stabilities, true)) {
throw new InvalidArgumentException(
'Invalid stability value. Must be one of "stable", "unstable" or "any".'
);
}
$this->stability = $stability;
}
|
[
"public",
"function",
"setStability",
"(",
"$",
"stability",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"stability",
",",
"self",
"::",
"$",
"stabilities",
",",
"true",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid stability value. Must be one of \"stable\", \"unstable\" or \"any\".'",
")",
";",
"}",
"$",
"this",
"->",
"stability",
"=",
"$",
"stability",
";",
"}"
] |
Set target stability.
@param string $stability
|
[
"Set",
"target",
"stability",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Updater/PuliStrategy.php#L121-L130
|
225,814
|
pyrou/morpheus
|
src/Morpheus/Image.php
|
Image.create
|
static function create($im) {
if(is_resource($im) && get_resource_type($im)) {
return new ImageGD($im);
}
if($im instanceof \Imagick) {
return new ImageImagick($im);
}
}
|
php
|
static function create($im) {
if(is_resource($im) && get_resource_type($im)) {
return new ImageGD($im);
}
if($im instanceof \Imagick) {
return new ImageImagick($im);
}
}
|
[
"static",
"function",
"create",
"(",
"$",
"im",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"im",
")",
"&&",
"get_resource_type",
"(",
"$",
"im",
")",
")",
"{",
"return",
"new",
"ImageGD",
"(",
"$",
"im",
")",
";",
"}",
"if",
"(",
"$",
"im",
"instanceof",
"\\",
"Imagick",
")",
"{",
"return",
"new",
"ImageImagick",
"(",
"$",
"im",
")",
";",
"}",
"}"
] |
Create a new Morpheus\Image instance.
@param resource|Imagick GD Resource or Imagick instance
@return Morpheus\Image
|
[
"Create",
"a",
"new",
"Morpheus",
"\\",
"Image",
"instance",
"."
] |
5dc1686651da5cbc4968fcf999b9ee998cc43b25
|
https://github.com/pyrou/morpheus/blob/5dc1686651da5cbc4968fcf999b9ee998cc43b25/src/Morpheus/Image.php#L28-L36
|
225,815
|
pyrou/morpheus
|
src/Morpheus/Image.php
|
Image.parity
|
private function parity($byte) {
$parity = 0;
for($i=7; $i>=0; $i--) {
$parity ^= ($byte >> $i) & 1;
}
return (bool) $parity;
}
|
php
|
private function parity($byte) {
$parity = 0;
for($i=7; $i>=0; $i--) {
$parity ^= ($byte >> $i) & 1;
}
return (bool) $parity;
}
|
[
"private",
"function",
"parity",
"(",
"$",
"byte",
")",
"{",
"$",
"parity",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"7",
";",
"$",
"i",
">=",
"0",
";",
"$",
"i",
"--",
")",
"{",
"$",
"parity",
"^=",
"(",
"$",
"byte",
">>",
"$",
"i",
")",
"&",
"1",
";",
"}",
"return",
"(",
"bool",
")",
"$",
"parity",
";",
"}"
] |
Calculate the XOR parity of the given byte.
@param integer byte between 0x00 and 0xFF
@return bool
|
[
"Calculate",
"the",
"XOR",
"parity",
"of",
"the",
"given",
"byte",
"."
] |
5dc1686651da5cbc4968fcf999b9ee998cc43b25
|
https://github.com/pyrou/morpheus/blob/5dc1686651da5cbc4968fcf999b9ee998cc43b25/src/Morpheus/Image.php#L58-L64
|
225,816
|
pyrou/morpheus
|
src/Morpheus/Image.php
|
Image.writeByte
|
private function writeByte($byte) {
// byte : 0b11010100
// parity : 0b1
// pixel 1 : 110
// pixel 2 : 101
// pixel 3 : 001
list($x, $y) = $this->coordinates->current();
$color = $this->getColor($x, $y);
$color->writeBits(($byte>>5) & 7);
$this->setColor($x, $y, $color);
$this->coordinates->next();
list($x, $y) = $this->coordinates->current();
$color = $this->getColor($x, $y);
$color->writeBits(($byte>>2) & 7);
$this->setColor($x, $y, $color);
$this->coordinates->next();
list($x, $y) = $this->coordinates->current();
$color = $this->getColor($x, $y);
$color->writeBits(($byte<<1) & 7 | $this->parity($byte));
$this->setColor($x, $y, $color);
$this->coordinates->next();
}
|
php
|
private function writeByte($byte) {
// byte : 0b11010100
// parity : 0b1
// pixel 1 : 110
// pixel 2 : 101
// pixel 3 : 001
list($x, $y) = $this->coordinates->current();
$color = $this->getColor($x, $y);
$color->writeBits(($byte>>5) & 7);
$this->setColor($x, $y, $color);
$this->coordinates->next();
list($x, $y) = $this->coordinates->current();
$color = $this->getColor($x, $y);
$color->writeBits(($byte>>2) & 7);
$this->setColor($x, $y, $color);
$this->coordinates->next();
list($x, $y) = $this->coordinates->current();
$color = $this->getColor($x, $y);
$color->writeBits(($byte<<1) & 7 | $this->parity($byte));
$this->setColor($x, $y, $color);
$this->coordinates->next();
}
|
[
"private",
"function",
"writeByte",
"(",
"$",
"byte",
")",
"{",
"// byte : 0b11010100",
"// parity : 0b1",
"// pixel 1 : 110",
"// pixel 2 : 101",
"// pixel 3 : 001",
"list",
"(",
"$",
"x",
",",
"$",
"y",
")",
"=",
"$",
"this",
"->",
"coordinates",
"->",
"current",
"(",
")",
";",
"$",
"color",
"=",
"$",
"this",
"->",
"getColor",
"(",
"$",
"x",
",",
"$",
"y",
")",
";",
"$",
"color",
"->",
"writeBits",
"(",
"(",
"$",
"byte",
">>",
"5",
")",
"&",
"7",
")",
";",
"$",
"this",
"->",
"setColor",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"color",
")",
";",
"$",
"this",
"->",
"coordinates",
"->",
"next",
"(",
")",
";",
"list",
"(",
"$",
"x",
",",
"$",
"y",
")",
"=",
"$",
"this",
"->",
"coordinates",
"->",
"current",
"(",
")",
";",
"$",
"color",
"=",
"$",
"this",
"->",
"getColor",
"(",
"$",
"x",
",",
"$",
"y",
")",
";",
"$",
"color",
"->",
"writeBits",
"(",
"(",
"$",
"byte",
">>",
"2",
")",
"&",
"7",
")",
";",
"$",
"this",
"->",
"setColor",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"color",
")",
";",
"$",
"this",
"->",
"coordinates",
"->",
"next",
"(",
")",
";",
"list",
"(",
"$",
"x",
",",
"$",
"y",
")",
"=",
"$",
"this",
"->",
"coordinates",
"->",
"current",
"(",
")",
";",
"$",
"color",
"=",
"$",
"this",
"->",
"getColor",
"(",
"$",
"x",
",",
"$",
"y",
")",
";",
"$",
"color",
"->",
"writeBits",
"(",
"(",
"$",
"byte",
"<<",
"1",
")",
"&",
"7",
"|",
"$",
"this",
"->",
"parity",
"(",
"$",
"byte",
")",
")",
";",
"$",
"this",
"->",
"setColor",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"color",
")",
";",
"$",
"this",
"->",
"coordinates",
"->",
"next",
"(",
")",
";",
"}"
] |
Store a byte at the current coordinates pointer
@param integer byte between 0x00 and 0xFF
|
[
"Store",
"a",
"byte",
"at",
"the",
"current",
"coordinates",
"pointer"
] |
5dc1686651da5cbc4968fcf999b9ee998cc43b25
|
https://github.com/pyrou/morpheus/blob/5dc1686651da5cbc4968fcf999b9ee998cc43b25/src/Morpheus/Image.php#L70-L95
|
225,817
|
BKWLD/upchuck
|
src/Helpers.php
|
Helpers.path
|
public function path($url) {
$prefix = $this->config['url_prefix'];
// If the url_prefix is absolute-path style but the url isn't, get only the
// path from the URL before comparing against the prefix.
if (preg_match('#^/#', $prefix) && preg_match('#^http#', $url)) {
$url = parse_url($url, PHP_URL_PATH);
}
// Trim the prefix from the URL
return substr($url, strlen($prefix));
}
|
php
|
public function path($url) {
$prefix = $this->config['url_prefix'];
// If the url_prefix is absolute-path style but the url isn't, get only the
// path from the URL before comparing against the prefix.
if (preg_match('#^/#', $prefix) && preg_match('#^http#', $url)) {
$url = parse_url($url, PHP_URL_PATH);
}
// Trim the prefix from the URL
return substr($url, strlen($prefix));
}
|
[
"public",
"function",
"path",
"(",
"$",
"url",
")",
"{",
"$",
"prefix",
"=",
"$",
"this",
"->",
"config",
"[",
"'url_prefix'",
"]",
";",
"// If the url_prefix is absolute-path style but the url isn't, get only the",
"// path from the URL before comparing against the prefix.",
"if",
"(",
"preg_match",
"(",
"'#^/#'",
",",
"$",
"prefix",
")",
"&&",
"preg_match",
"(",
"'#^http#'",
",",
"$",
"url",
")",
")",
"{",
"$",
"url",
"=",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_PATH",
")",
";",
"}",
"// Trim the prefix from the URL",
"return",
"substr",
"(",
"$",
"url",
",",
"strlen",
"(",
"$",
"prefix",
")",
")",
";",
"}"
] |
Get the path on the disk given the URL.
@param string $url
@return string
|
[
"Get",
"the",
"path",
"on",
"the",
"disk",
"given",
"the",
"URL",
"."
] |
2d2202b1bc4a86a0a91ceb319521a263b0c88f54
|
https://github.com/BKWLD/upchuck/blob/2d2202b1bc4a86a0a91ceb319521a263b0c88f54/src/Helpers.php#L38-L49
|
225,818
|
johannesschobel/laravel-revisionable
|
src/JohannesSchobel/Revisionable/Traits/Revisionable.php
|
Revisionable.revisionAtTimestamp
|
public function revisionAtTimestamp($timestamp)
{
$revision = $this->revisions()
->where('created_at', '<=', Carbon::parse($timestamp))
->first();
return $this->wrapRevision($revision);
}
|
php
|
public function revisionAtTimestamp($timestamp)
{
$revision = $this->revisions()
->where('created_at', '<=', Carbon::parse($timestamp))
->first();
return $this->wrapRevision($revision);
}
|
[
"public",
"function",
"revisionAtTimestamp",
"(",
"$",
"timestamp",
")",
"{",
"$",
"revision",
"=",
"$",
"this",
"->",
"revisions",
"(",
")",
"->",
"where",
"(",
"'created_at'",
",",
"'<='",
",",
"Carbon",
"::",
"parse",
"(",
"$",
"timestamp",
")",
")",
"->",
"first",
"(",
")",
";",
"return",
"$",
"this",
"->",
"wrapRevision",
"(",
"$",
"revision",
")",
";",
"}"
] |
Get record version at given timestamp.
@param \DateTime|string $timestamp DateTime|Carbon object or parseable date string @see strtotime()
@return Revision|null
|
[
"Get",
"record",
"version",
"at",
"given",
"timestamp",
"."
] |
f5a1d4c1eff343e76f58b19b97be3007f4584b49
|
https://github.com/johannesschobel/laravel-revisionable/blob/f5a1d4c1eff343e76f58b19b97be3007f4584b49/src/JohannesSchobel/Revisionable/Traits/Revisionable.php#L28-L35
|
225,819
|
johannesschobel/laravel-revisionable
|
src/JohannesSchobel/Revisionable/Traits/Revisionable.php
|
Revisionable.rollbackToRevision
|
private function rollbackToRevision(Revision $revision) {
if ($revision == null) {
return null;
}
$current = $revision->revisioned;
// delete the old revisions for this model if needed
if($this->getConfigRollbackCleanup()) {
$revisionsToDelete = $current->revisions()->where('id', '>=', $revision->id)->delete();
}
$current->fill($revision->old);
$current->save();
// reload the relations
$current = $current->load('revisions');
return $current;
}
|
php
|
private function rollbackToRevision(Revision $revision) {
if ($revision == null) {
return null;
}
$current = $revision->revisioned;
// delete the old revisions for this model if needed
if($this->getConfigRollbackCleanup()) {
$revisionsToDelete = $current->revisions()->where('id', '>=', $revision->id)->delete();
}
$current->fill($revision->old);
$current->save();
// reload the relations
$current = $current->load('revisions');
return $current;
}
|
[
"private",
"function",
"rollbackToRevision",
"(",
"Revision",
"$",
"revision",
")",
"{",
"if",
"(",
"$",
"revision",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"$",
"current",
"=",
"$",
"revision",
"->",
"revisioned",
";",
"// delete the old revisions for this model if needed",
"if",
"(",
"$",
"this",
"->",
"getConfigRollbackCleanup",
"(",
")",
")",
"{",
"$",
"revisionsToDelete",
"=",
"$",
"current",
"->",
"revisions",
"(",
")",
"->",
"where",
"(",
"'id'",
",",
"'>='",
",",
"$",
"revision",
"->",
"id",
")",
"->",
"delete",
"(",
")",
";",
"}",
"$",
"current",
"->",
"fill",
"(",
"$",
"revision",
"->",
"old",
")",
";",
"$",
"current",
"->",
"save",
"(",
")",
";",
"// reload the relations",
"$",
"current",
"=",
"$",
"current",
"->",
"load",
"(",
"'revisions'",
")",
";",
"return",
"$",
"current",
";",
"}"
] |
Rollback to a given revision.
@param Revision $revision
@return Revision|null
|
[
"Rollback",
"to",
"a",
"given",
"revision",
"."
] |
f5a1d4c1eff343e76f58b19b97be3007f4584b49
|
https://github.com/johannesschobel/laravel-revisionable/blob/f5a1d4c1eff343e76f58b19b97be3007f4584b49/src/JohannesSchobel/Revisionable/Traits/Revisionable.php#L80-L99
|
225,820
|
johannesschobel/laravel-revisionable
|
src/JohannesSchobel/Revisionable/Traits/Revisionable.php
|
Revisionable.getConfigRevisionForModel
|
public function getConfigRevisionForModel() {
if(is_null($this->revisionEnabled)) {
// the parameter is not set - default behaviour is to create revisions
return true;
}
if($this->revisionEnabled === false) {
return false;
}
return true;
}
|
php
|
public function getConfigRevisionForModel() {
if(is_null($this->revisionEnabled)) {
// the parameter is not set - default behaviour is to create revisions
return true;
}
if($this->revisionEnabled === false) {
return false;
}
return true;
}
|
[
"public",
"function",
"getConfigRevisionForModel",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"revisionEnabled",
")",
")",
"{",
"// the parameter is not set - default behaviour is to create revisions",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"revisionEnabled",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
checks if revisions for this model shall be created
@return bool
|
[
"checks",
"if",
"revisions",
"for",
"this",
"model",
"shall",
"be",
"created"
] |
f5a1d4c1eff343e76f58b19b97be3007f4584b49
|
https://github.com/johannesschobel/laravel-revisionable/blob/f5a1d4c1eff343e76f58b19b97be3007f4584b49/src/JohannesSchobel/Revisionable/Traits/Revisionable.php#L294-L304
|
225,821
|
johannesschobel/laravel-revisionable
|
src/JohannesSchobel/Revisionable/Traits/Revisionable.php
|
Revisionable.getConfigRevisionLimit
|
public function getConfigRevisionLimit() {
$default = Config::get('revisionable.revisions.limit');
if(is_null($this->revisionLimit)) {
// the parameter is not set - default behaviour is to create revisions
return $default;
}
if(! is_numeric($this->revisionLimit)) {
return $default;
}
return $this->revisionLimit;
}
|
php
|
public function getConfigRevisionLimit() {
$default = Config::get('revisionable.revisions.limit');
if(is_null($this->revisionLimit)) {
// the parameter is not set - default behaviour is to create revisions
return $default;
}
if(! is_numeric($this->revisionLimit)) {
return $default;
}
return $this->revisionLimit;
}
|
[
"public",
"function",
"getConfigRevisionLimit",
"(",
")",
"{",
"$",
"default",
"=",
"Config",
"::",
"get",
"(",
"'revisionable.revisions.limit'",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"revisionLimit",
")",
")",
"{",
"// the parameter is not set - default behaviour is to create revisions",
"return",
"$",
"default",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"this",
"->",
"revisionLimit",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"this",
"->",
"revisionLimit",
";",
"}"
] |
Returns, how many revisions of a model must be kept
@return int
|
[
"Returns",
"how",
"many",
"revisions",
"of",
"a",
"model",
"must",
"be",
"kept"
] |
f5a1d4c1eff343e76f58b19b97be3007f4584b49
|
https://github.com/johannesschobel/laravel-revisionable/blob/f5a1d4c1eff343e76f58b19b97be3007f4584b49/src/JohannesSchobel/Revisionable/Traits/Revisionable.php#L311-L323
|
225,822
|
johannesschobel/laravel-revisionable
|
src/JohannesSchobel/Revisionable/Traits/Revisionable.php
|
Revisionable.getConfigRevisionLimitCleanup
|
public function getConfigRevisionLimitCleanup() {
$default = Config::get('revisionable.revisions.limitCleanup');
if(is_null($this->revisionLimitCleanup)) {
// the parameter is not set - default behaviour is to create revisions
return $default;
}
if($this->revisionLimitCleanup == false) {
return false;
}
return true;
}
|
php
|
public function getConfigRevisionLimitCleanup() {
$default = Config::get('revisionable.revisions.limitCleanup');
if(is_null($this->revisionLimitCleanup)) {
// the parameter is not set - default behaviour is to create revisions
return $default;
}
if($this->revisionLimitCleanup == false) {
return false;
}
return true;
}
|
[
"public",
"function",
"getConfigRevisionLimitCleanup",
"(",
")",
"{",
"$",
"default",
"=",
"Config",
"::",
"get",
"(",
"'revisionable.revisions.limitCleanup'",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"revisionLimitCleanup",
")",
")",
"{",
"// the parameter is not set - default behaviour is to create revisions",
"return",
"$",
"default",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"revisionLimitCleanup",
"==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Returns if older revisions shall be removed
@return bool
|
[
"Returns",
"if",
"older",
"revisions",
"shall",
"be",
"removed"
] |
f5a1d4c1eff343e76f58b19b97be3007f4584b49
|
https://github.com/johannesschobel/laravel-revisionable/blob/f5a1d4c1eff343e76f58b19b97be3007f4584b49/src/JohannesSchobel/Revisionable/Traits/Revisionable.php#L330-L342
|
225,823
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-locator-term.php
|
Carbon_Breadcrumb_Locator_Term.is_included
|
public function is_included() {
$queried_object = get_queried_object();
if ( ! empty( $queried_object->taxonomy ) && $queried_object->taxonomy == $this->get_subtype() ) {
return true;
}
return false;
}
|
php
|
public function is_included() {
$queried_object = get_queried_object();
if ( ! empty( $queried_object->taxonomy ) && $queried_object->taxonomy == $this->get_subtype() ) {
return true;
}
return false;
}
|
[
"public",
"function",
"is_included",
"(",
")",
"{",
"$",
"queried_object",
"=",
"get_queried_object",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"queried_object",
"->",
"taxonomy",
")",
"&&",
"$",
"queried_object",
"->",
"taxonomy",
"==",
"$",
"this",
"->",
"get_subtype",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Whether this the items of this locator should be included in the trail.
@access public
@return bool $is_included Whether the found items should be included.
|
[
"Whether",
"this",
"the",
"items",
"of",
"this",
"locator",
"should",
"be",
"included",
"in",
"the",
"trail",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-locator-term.php#L22-L30
|
225,824
|
xmeltrut/WordSearch
|
src/Utils.php
|
Utils.integerAsOptions
|
public static function integerAsOptions($num)
{
$options = [];
for ($i = 0; $i <= $num; $i++) {
$options[] = $i;
}
shuffle($options);
return $options;
}
|
php
|
public static function integerAsOptions($num)
{
$options = [];
for ($i = 0; $i <= $num; $i++) {
$options[] = $i;
}
shuffle($options);
return $options;
}
|
[
"public",
"static",
"function",
"integerAsOptions",
"(",
"$",
"num",
")",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<=",
"$",
"num",
";",
"$",
"i",
"++",
")",
"{",
"$",
"options",
"[",
"]",
"=",
"$",
"i",
";",
"}",
"shuffle",
"(",
"$",
"options",
")",
";",
"return",
"$",
"options",
";",
"}"
] |
Take an integer and convert it into an array of shuffled options.
@param integer $num Maximum index.
@return array
|
[
"Take",
"an",
"integer",
"and",
"convert",
"it",
"into",
"an",
"array",
"of",
"shuffled",
"options",
"."
] |
a6dd7c96b78045a3d172e3c5b97e9909b32a9fba
|
https://github.com/xmeltrut/WordSearch/blob/a6dd7c96b78045a3d172e3c5b97e9909b32a9fba/src/Utils.php#L13-L24
|
225,825
|
xmeltrut/WordSearch
|
src/Utils.php
|
Utils.stringToArray
|
public static function stringToArray($str)
{
$arr = [];
for ($i = 0; $i < self::stringLength($str); $i++) {
$arr[] = function_exists('mb_substr') ? mb_substr($str, $i, 1) : $str[$i];
}
return $arr;
}
|
php
|
public static function stringToArray($str)
{
$arr = [];
for ($i = 0; $i < self::stringLength($str); $i++) {
$arr[] = function_exists('mb_substr') ? mb_substr($str, $i, 1) : $str[$i];
}
return $arr;
}
|
[
"public",
"static",
"function",
"stringToArray",
"(",
"$",
"str",
")",
"{",
"$",
"arr",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"self",
"::",
"stringLength",
"(",
"$",
"str",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"arr",
"[",
"]",
"=",
"function_exists",
"(",
"'mb_substr'",
")",
"?",
"mb_substr",
"(",
"$",
"str",
",",
"$",
"i",
",",
"1",
")",
":",
"$",
"str",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"$",
"arr",
";",
"}"
] |
Convert a string to an array of letters.
@param string $str String.
@return array
|
[
"Convert",
"a",
"string",
"to",
"an",
"array",
"of",
"letters",
"."
] |
a6dd7c96b78045a3d172e3c5b97e9909b32a9fba
|
https://github.com/xmeltrut/WordSearch/blob/a6dd7c96b78045a3d172e3c5b97e9909b32a9fba/src/Utils.php#L47-L56
|
225,826
|
oscarotero/inline-svg
|
src/Svg.php
|
Svg.withAttributes
|
public function withAttributes(array $attributes)
{
$clone = clone $this;
foreach ($attributes as $name => $value) {
$clone->dom->documentElement->setAttribute($name, $value);
}
return $clone;
}
|
php
|
public function withAttributes(array $attributes)
{
$clone = clone $this;
foreach ($attributes as $name => $value) {
$clone->dom->documentElement->setAttribute($name, $value);
}
return $clone;
}
|
[
"public",
"function",
"withAttributes",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"clone",
"->",
"dom",
"->",
"documentElement",
"->",
"setAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"clone",
";",
"}"
] |
Set new attributes.
@param array $attributes
@return self
|
[
"Set",
"new",
"attributes",
"."
] |
9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2
|
https://github.com/oscarotero/inline-svg/blob/9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2/src/Svg.php#L63-L72
|
225,827
|
oscarotero/inline-svg
|
src/Svg.php
|
Svg.withA11y
|
public function withA11y($title = null, $desc = null)
{
$clone = clone $this;
$clone->dom->documentElement->setAttribute('role', 'img');
$ids = [];
if ($title) {
self::getOrCreateNode($clone->dom->documentElement, 'title', $title)->setAttribute('id', $ids[] = uniqid('svg_title_'));
}
if ($desc) {
self::getOrCreateNode($clone->dom->documentElement, 'desc', $desc)->setAttribute('id', $ids[] = uniqid('svg_desc_'));
}
if ($ids) {
$clone->dom->documentElement->setAttribute('aria-labelledby', implode(' ', $ids));
}
return $clone;
}
|
php
|
public function withA11y($title = null, $desc = null)
{
$clone = clone $this;
$clone->dom->documentElement->setAttribute('role', 'img');
$ids = [];
if ($title) {
self::getOrCreateNode($clone->dom->documentElement, 'title', $title)->setAttribute('id', $ids[] = uniqid('svg_title_'));
}
if ($desc) {
self::getOrCreateNode($clone->dom->documentElement, 'desc', $desc)->setAttribute('id', $ids[] = uniqid('svg_desc_'));
}
if ($ids) {
$clone->dom->documentElement->setAttribute('aria-labelledby', implode(' ', $ids));
}
return $clone;
}
|
[
"public",
"function",
"withA11y",
"(",
"$",
"title",
"=",
"null",
",",
"$",
"desc",
"=",
"null",
")",
"{",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"$",
"clone",
"->",
"dom",
"->",
"documentElement",
"->",
"setAttribute",
"(",
"'role'",
",",
"'img'",
")",
";",
"$",
"ids",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"title",
")",
"{",
"self",
"::",
"getOrCreateNode",
"(",
"$",
"clone",
"->",
"dom",
"->",
"documentElement",
",",
"'title'",
",",
"$",
"title",
")",
"->",
"setAttribute",
"(",
"'id'",
",",
"$",
"ids",
"[",
"]",
"=",
"uniqid",
"(",
"'svg_title_'",
")",
")",
";",
"}",
"if",
"(",
"$",
"desc",
")",
"{",
"self",
"::",
"getOrCreateNode",
"(",
"$",
"clone",
"->",
"dom",
"->",
"documentElement",
",",
"'desc'",
",",
"$",
"desc",
")",
"->",
"setAttribute",
"(",
"'id'",
",",
"$",
"ids",
"[",
"]",
"=",
"uniqid",
"(",
"'svg_desc_'",
")",
")",
";",
"}",
"if",
"(",
"$",
"ids",
")",
"{",
"$",
"clone",
"->",
"dom",
"->",
"documentElement",
"->",
"setAttribute",
"(",
"'aria-labelledby'",
",",
"implode",
"(",
"' '",
",",
"$",
"ids",
")",
")",
";",
"}",
"return",
"$",
"clone",
";",
"}"
] |
Set accessibility information to the svg.
@param string|null $title Short description
@param string|null $desc Long description
@return Svg
|
[
"Set",
"accessibility",
"information",
"to",
"the",
"svg",
"."
] |
9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2
|
https://github.com/oscarotero/inline-svg/blob/9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2/src/Svg.php#L82-L103
|
225,828
|
oscarotero/inline-svg
|
src/Svg.php
|
Svg.getOrCreateNode
|
private static function getOrCreateNode(DOMElement $svg, $tagName, $value)
{
$node = $svg->getElementsByTagName($tagName);
if ($node->length) {
$node = $node->item(0);
$node->nodeValue = $value;
return $node;
}
$newNode = new DOMElement($tagName, $value);
$svg->appendChild($newNode);
return $newNode;
}
|
php
|
private static function getOrCreateNode(DOMElement $svg, $tagName, $value)
{
$node = $svg->getElementsByTagName($tagName);
if ($node->length) {
$node = $node->item(0);
$node->nodeValue = $value;
return $node;
}
$newNode = new DOMElement($tagName, $value);
$svg->appendChild($newNode);
return $newNode;
}
|
[
"private",
"static",
"function",
"getOrCreateNode",
"(",
"DOMElement",
"$",
"svg",
",",
"$",
"tagName",
",",
"$",
"value",
")",
"{",
"$",
"node",
"=",
"$",
"svg",
"->",
"getElementsByTagName",
"(",
"$",
"tagName",
")",
";",
"if",
"(",
"$",
"node",
"->",
"length",
")",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"item",
"(",
"0",
")",
";",
"$",
"node",
"->",
"nodeValue",
"=",
"$",
"value",
";",
"return",
"$",
"node",
";",
"}",
"$",
"newNode",
"=",
"new",
"DOMElement",
"(",
"$",
"tagName",
",",
"$",
"value",
")",
";",
"$",
"svg",
"->",
"appendChild",
"(",
"$",
"newNode",
")",
";",
"return",
"$",
"newNode",
";",
"}"
] |
Returns a node by tagName. Create if it doesn't exist
@param DOMElement $svg
@param string $tagName
@param string $value
@return DOMElement
|
[
"Returns",
"a",
"node",
"by",
"tagName",
".",
"Create",
"if",
"it",
"doesn",
"t",
"exist"
] |
9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2
|
https://github.com/oscarotero/inline-svg/blob/9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2/src/Svg.php#L124-L139
|
225,829
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-item-term.php
|
Carbon_Breadcrumb_Item_Term.setup
|
public function setup() {
// In order to continue, taxonomy term ID must be specified.
if ( ! $this->get_id() ) {
throw new Carbon_Breadcrumb_Exception( 'The term breadcrumb items must have term ID specified.' );
}
// In order to continue, taxonomy must be specified.
if ( ! $this->get_subtype() ) {
throw new Carbon_Breadcrumb_Exception( 'The term breadcrumb items must have taxonomy specified.' );
}
// Retrieve term object.
$subtype = $this->get_subtype();
$this->term_object = get_term_by( 'id', $this->get_id(), $subtype );
parent::setup();
}
|
php
|
public function setup() {
// In order to continue, taxonomy term ID must be specified.
if ( ! $this->get_id() ) {
throw new Carbon_Breadcrumb_Exception( 'The term breadcrumb items must have term ID specified.' );
}
// In order to continue, taxonomy must be specified.
if ( ! $this->get_subtype() ) {
throw new Carbon_Breadcrumb_Exception( 'The term breadcrumb items must have taxonomy specified.' );
}
// Retrieve term object.
$subtype = $this->get_subtype();
$this->term_object = get_term_by( 'id', $this->get_id(), $subtype );
parent::setup();
}
|
[
"public",
"function",
"setup",
"(",
")",
"{",
"// In order to continue, taxonomy term ID must be specified.",
"if",
"(",
"!",
"$",
"this",
"->",
"get_id",
"(",
")",
")",
"{",
"throw",
"new",
"Carbon_Breadcrumb_Exception",
"(",
"'The term breadcrumb items must have term ID specified.'",
")",
";",
"}",
"// In order to continue, taxonomy must be specified.",
"if",
"(",
"!",
"$",
"this",
"->",
"get_subtype",
"(",
")",
")",
"{",
"throw",
"new",
"Carbon_Breadcrumb_Exception",
"(",
"'The term breadcrumb items must have taxonomy specified.'",
")",
";",
"}",
"// Retrieve term object.",
"$",
"subtype",
"=",
"$",
"this",
"->",
"get_subtype",
"(",
")",
";",
"$",
"this",
"->",
"term_object",
"=",
"get_term_by",
"(",
"'id'",
",",
"$",
"this",
"->",
"get_id",
"(",
")",
",",
"$",
"subtype",
")",
";",
"parent",
"::",
"setup",
"(",
")",
";",
"}"
] |
Configure the title and link URL by using the specified term ID.
@access public
@throws Carbon_Breadcrumb_Exception When term ID or taxonomy isn't specified.
|
[
"Configure",
"the",
"title",
"and",
"link",
"URL",
"by",
"using",
"the",
"specified",
"term",
"ID",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-item-term.php#L29-L45
|
225,830
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-item-term.php
|
Carbon_Breadcrumb_Item_Term.setup_link
|
public function setup_link() {
$link = get_term_link( $this->term_object->term_id, $this->term_object->taxonomy );
$this->set_link( $link );
}
|
php
|
public function setup_link() {
$link = get_term_link( $this->term_object->term_id, $this->term_object->taxonomy );
$this->set_link( $link );
}
|
[
"public",
"function",
"setup_link",
"(",
")",
"{",
"$",
"link",
"=",
"get_term_link",
"(",
"$",
"this",
"->",
"term_object",
"->",
"term_id",
",",
"$",
"this",
"->",
"term_object",
"->",
"taxonomy",
")",
";",
"$",
"this",
"->",
"set_link",
"(",
"$",
"link",
")",
";",
"}"
] |
Setup the link of this item.
@access public
|
[
"Setup",
"the",
"link",
"of",
"this",
"item",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-item-term.php#L69-L72
|
225,831
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail-renderer.php
|
Carbon_Breadcrumb_Trail_Renderer.prepare_for_rendering
|
public function prepare_for_rendering( $trail ) {
// Last chance to modify render settings before rendering.
do_action( 'carbon_breadcrumbs_before_render', $this );
// Whether to auto-sort the items.
$auto_sort = apply_filters( 'carbon_breadcrumbs_auto_sort_items', true );
if ( $auto_sort ) {
$trail->sort_items();
}
}
|
php
|
public function prepare_for_rendering( $trail ) {
// Last chance to modify render settings before rendering.
do_action( 'carbon_breadcrumbs_before_render', $this );
// Whether to auto-sort the items.
$auto_sort = apply_filters( 'carbon_breadcrumbs_auto_sort_items', true );
if ( $auto_sort ) {
$trail->sort_items();
}
}
|
[
"public",
"function",
"prepare_for_rendering",
"(",
"$",
"trail",
")",
"{",
"// Last chance to modify render settings before rendering.",
"do_action",
"(",
"'carbon_breadcrumbs_before_render'",
",",
"$",
"this",
")",
";",
"// Whether to auto-sort the items.",
"$",
"auto_sort",
"=",
"apply_filters",
"(",
"'carbon_breadcrumbs_auto_sort_items'",
",",
"true",
")",
";",
"if",
"(",
"$",
"auto_sort",
")",
"{",
"$",
"trail",
"->",
"sort_items",
"(",
")",
";",
"}",
"}"
] |
Prepare for rendering.
Allows renderer to be modified in the last second.
Also autosorts the trail items, if autosorting is enabled.
@access public
@param Carbon_Breadcrumb_Trail $trail Trail object.
|
[
"Prepare",
"for",
"rendering",
".",
"Allows",
"renderer",
"to",
"be",
"modified",
"in",
"the",
"last",
"second",
".",
"Also",
"autosorts",
"the",
"trail",
"items",
"if",
"autosorting",
"is",
"enabled",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail-renderer.php#L386-L395
|
225,832
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail-renderer.php
|
Carbon_Breadcrumb_Trail_Renderer.render
|
public function render( Carbon_Breadcrumb_Trail $trail, $return = false ) {
// If the items are less than the minimum, nothing should be rendered.
if ( $trail->get_total_items() < $this->get_min_items() ) {
return;
}
// Prepare the trail & renderer for rendering.
$this->prepare_for_rendering( $trail );
// Render the items.
$items_output = $this->render_items( $trail );
// Implode the breadcrumb items and wrap them with the configured wrappers.
$output = $this->get_wrapper_before();
$output .= implode( $this->get_glue(), $items_output );
$output .= $this->get_wrapper_after();
if ( $return ) {
return $output;
}
echo wp_kses( $output, wp_kses_allowed_html( 'post' ) );
}
|
php
|
public function render( Carbon_Breadcrumb_Trail $trail, $return = false ) {
// If the items are less than the minimum, nothing should be rendered.
if ( $trail->get_total_items() < $this->get_min_items() ) {
return;
}
// Prepare the trail & renderer for rendering.
$this->prepare_for_rendering( $trail );
// Render the items.
$items_output = $this->render_items( $trail );
// Implode the breadcrumb items and wrap them with the configured wrappers.
$output = $this->get_wrapper_before();
$output .= implode( $this->get_glue(), $items_output );
$output .= $this->get_wrapper_after();
if ( $return ) {
return $output;
}
echo wp_kses( $output, wp_kses_allowed_html( 'post' ) );
}
|
[
"public",
"function",
"render",
"(",
"Carbon_Breadcrumb_Trail",
"$",
"trail",
",",
"$",
"return",
"=",
"false",
")",
"{",
"// If the items are less than the minimum, nothing should be rendered.",
"if",
"(",
"$",
"trail",
"->",
"get_total_items",
"(",
")",
"<",
"$",
"this",
"->",
"get_min_items",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Prepare the trail & renderer for rendering.",
"$",
"this",
"->",
"prepare_for_rendering",
"(",
"$",
"trail",
")",
";",
"// Render the items.",
"$",
"items_output",
"=",
"$",
"this",
"->",
"render_items",
"(",
"$",
"trail",
")",
";",
"// Implode the breadcrumb items and wrap them with the configured wrappers.",
"$",
"output",
"=",
"$",
"this",
"->",
"get_wrapper_before",
"(",
")",
";",
"$",
"output",
".=",
"implode",
"(",
"$",
"this",
"->",
"get_glue",
"(",
")",
",",
"$",
"items_output",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"get_wrapper_after",
"(",
")",
";",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"output",
";",
"}",
"echo",
"wp_kses",
"(",
"$",
"output",
",",
"wp_kses_allowed_html",
"(",
"'post'",
")",
")",
";",
"}"
] |
Render the given breadcrumb trail.
@access public
@param Carbon_Breadcrumb_Trail $trail The trail object.
@param bool $return Whether to return the output.
@return string|void $output The output HTML if $return is true.
|
[
"Render",
"the",
"given",
"breadcrumb",
"trail",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail-renderer.php#L406-L428
|
225,833
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail-renderer.php
|
Carbon_Breadcrumb_Trail_Renderer.render_items
|
public function render_items( $trail ) {
$items_output = array();
$counter = 0;
$all_items = $trail->get_flat_items();
foreach ( $all_items as $item ) {
// Allow each item to be filtered right before rendering.
$item = apply_filters( 'carbon_breadcrumbs_item', $item, $trail, $this, $counter );
// Skip if $item is not a Carbon_Breadcrumb_Item instance.
if ( ! ( $item instanceof Carbon_Breadcrumb_Item ) ) {
continue;
}
// Increase the counter and render the item.
$counter++;
$item_renderer = new Carbon_Breadcrumb_Item_Renderer( $item, $trail, $this, $counter );
$items_output[] = $item_renderer->render();
}
return $items_output;
}
|
php
|
public function render_items( $trail ) {
$items_output = array();
$counter = 0;
$all_items = $trail->get_flat_items();
foreach ( $all_items as $item ) {
// Allow each item to be filtered right before rendering.
$item = apply_filters( 'carbon_breadcrumbs_item', $item, $trail, $this, $counter );
// Skip if $item is not a Carbon_Breadcrumb_Item instance.
if ( ! ( $item instanceof Carbon_Breadcrumb_Item ) ) {
continue;
}
// Increase the counter and render the item.
$counter++;
$item_renderer = new Carbon_Breadcrumb_Item_Renderer( $item, $trail, $this, $counter );
$items_output[] = $item_renderer->render();
}
return $items_output;
}
|
[
"public",
"function",
"render_items",
"(",
"$",
"trail",
")",
"{",
"$",
"items_output",
"=",
"array",
"(",
")",
";",
"$",
"counter",
"=",
"0",
";",
"$",
"all_items",
"=",
"$",
"trail",
"->",
"get_flat_items",
"(",
")",
";",
"foreach",
"(",
"$",
"all_items",
"as",
"$",
"item",
")",
"{",
"// Allow each item to be filtered right before rendering.",
"$",
"item",
"=",
"apply_filters",
"(",
"'carbon_breadcrumbs_item'",
",",
"$",
"item",
",",
"$",
"trail",
",",
"$",
"this",
",",
"$",
"counter",
")",
";",
"// Skip if $item is not a Carbon_Breadcrumb_Item instance.",
"if",
"(",
"!",
"(",
"$",
"item",
"instanceof",
"Carbon_Breadcrumb_Item",
")",
")",
"{",
"continue",
";",
"}",
"// Increase the counter and render the item.",
"$",
"counter",
"++",
";",
"$",
"item_renderer",
"=",
"new",
"Carbon_Breadcrumb_Item_Renderer",
"(",
"$",
"item",
",",
"$",
"trail",
",",
"$",
"this",
",",
"$",
"counter",
")",
";",
"$",
"items_output",
"[",
"]",
"=",
"$",
"item_renderer",
"->",
"render",
"(",
")",
";",
"}",
"return",
"$",
"items_output",
";",
"}"
] |
Render the breadcrumb trail items.
@access public
@param Carbon_Breadcrumb_Trail $trail The trail object.
@return array $output The output elements.
|
[
"Render",
"the",
"breadcrumb",
"trail",
"items",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail-renderer.php#L438-L459
|
225,834
|
xmeltrut/WordSearch
|
src/Transformer/HtmlTransformer.php
|
HtmlTransformer.grid
|
public function grid()
{
$html = "<table class=\"word-search\">\n";
foreach ($this->puzzle->toArray() as $row) {
$html .= "<tr>\n";
foreach ($row as $cell) {
$html .= sprintf("<td>%s</td>\n", $cell);
}
$html .= "</tr>\n";
}
$html .= "</table>\n";
return $html;
}
|
php
|
public function grid()
{
$html = "<table class=\"word-search\">\n";
foreach ($this->puzzle->toArray() as $row) {
$html .= "<tr>\n";
foreach ($row as $cell) {
$html .= sprintf("<td>%s</td>\n", $cell);
}
$html .= "</tr>\n";
}
$html .= "</table>\n";
return $html;
}
|
[
"public",
"function",
"grid",
"(",
")",
"{",
"$",
"html",
"=",
"\"<table class=\\\"word-search\\\">\\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"puzzle",
"->",
"toArray",
"(",
")",
"as",
"$",
"row",
")",
"{",
"$",
"html",
".=",
"\"<tr>\\n\"",
";",
"foreach",
"(",
"$",
"row",
"as",
"$",
"cell",
")",
"{",
"$",
"html",
".=",
"sprintf",
"(",
"\"<td>%s</td>\\n\"",
",",
"$",
"cell",
")",
";",
"}",
"$",
"html",
".=",
"\"</tr>\\n\"",
";",
"}",
"$",
"html",
".=",
"\"</table>\\n\"",
";",
"return",
"$",
"html",
";",
"}"
] |
Transform the grid.
@return string
|
[
"Transform",
"the",
"grid",
"."
] |
a6dd7c96b78045a3d172e3c5b97e9909b32a9fba
|
https://github.com/xmeltrut/WordSearch/blob/a6dd7c96b78045a3d172e3c5b97e9909b32a9fba/src/Transformer/HtmlTransformer.php#L27-L42
|
225,835
|
xmeltrut/WordSearch
|
src/Transformer/HtmlTransformer.php
|
HtmlTransformer.wordList
|
public function wordList()
{
$html = "<ul>\n";
foreach ($this->puzzle->getWordList() as $word) {
$html .= sprintf("<li>%s</li>\n", $word->word);
}
$html .= "</ul>\n";
return $html;
}
|
php
|
public function wordList()
{
$html = "<ul>\n";
foreach ($this->puzzle->getWordList() as $word) {
$html .= sprintf("<li>%s</li>\n", $word->word);
}
$html .= "</ul>\n";
return $html;
}
|
[
"public",
"function",
"wordList",
"(",
")",
"{",
"$",
"html",
"=",
"\"<ul>\\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"puzzle",
"->",
"getWordList",
"(",
")",
"as",
"$",
"word",
")",
"{",
"$",
"html",
".=",
"sprintf",
"(",
"\"<li>%s</li>\\n\"",
",",
"$",
"word",
"->",
"word",
")",
";",
"}",
"$",
"html",
".=",
"\"</ul>\\n\"",
";",
"return",
"$",
"html",
";",
"}"
] |
Transform the words list.
@return string
|
[
"Transform",
"the",
"words",
"list",
"."
] |
a6dd7c96b78045a3d172e3c5b97e9909b32a9fba
|
https://github.com/xmeltrut/WordSearch/blob/a6dd7c96b78045a3d172e3c5b97e9909b32a9fba/src/Transformer/HtmlTransformer.php#L49-L60
|
225,836
|
basvandorst/UberPHP
|
src/Uber/API/Client.php
|
Client.getHeaders
|
private function getHeaders() {
$headers = array('Accept-Language: '.$this->locale);
if($this->user_authorization) {
$headers[] = 'Authorization: Bearer '.$this->token;
} else {
$headers[] ='Authorization: Token '.$this->token;
}
return $headers;
}
|
php
|
private function getHeaders() {
$headers = array('Accept-Language: '.$this->locale);
if($this->user_authorization) {
$headers[] = 'Authorization: Bearer '.$this->token;
} else {
$headers[] ='Authorization: Token '.$this->token;
}
return $headers;
}
|
[
"private",
"function",
"getHeaders",
"(",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
"'Accept-Language: '",
".",
"$",
"this",
"->",
"locale",
")",
";",
"if",
"(",
"$",
"this",
"->",
"user_authorization",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"'Authorization: Bearer '",
".",
"$",
"this",
"->",
"token",
";",
"}",
"else",
"{",
"$",
"headers",
"[",
"]",
"=",
"'Authorization: Token '",
".",
"$",
"this",
"->",
"token",
";",
"}",
"return",
"$",
"headers",
";",
"}"
] |
Return an array of HTTP headers
@return string[]
|
[
"Return",
"an",
"array",
"of",
"HTTP",
"headers"
] |
eed59311657cf0e971d46caf3768a8aff53df8e3
|
https://github.com/basvandorst/UberPHP/blob/eed59311657cf0e971d46caf3768a8aff53df8e3/src/Uber/API/Client.php#L64-L73
|
225,837
|
basvandorst/UberPHP
|
src/Uber/API/Client.php
|
Client.products
|
public function products($latitude, $longitude) {
$path = '/v1/products';
$parameters = array(
'latitude' => $latitude,
'longitude' => $longitude
);
$result = $this->adapter->get($path, $parameters, $this->getHeaders());
return $this->format($result);
}
|
php
|
public function products($latitude, $longitude) {
$path = '/v1/products';
$parameters = array(
'latitude' => $latitude,
'longitude' => $longitude
);
$result = $this->adapter->get($path, $parameters, $this->getHeaders());
return $this->format($result);
}
|
[
"public",
"function",
"products",
"(",
"$",
"latitude",
",",
"$",
"longitude",
")",
"{",
"$",
"path",
"=",
"'/v1/products'",
";",
"$",
"parameters",
"=",
"array",
"(",
"'latitude'",
"=>",
"$",
"latitude",
",",
"'longitude'",
"=>",
"$",
"longitude",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"adapter",
"->",
"get",
"(",
"$",
"path",
",",
"$",
"parameters",
",",
"$",
"this",
"->",
"getHeaders",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"format",
"(",
"$",
"result",
")",
";",
"}"
] |
Returns information about the Uber products offered at a given location.
@see https://developer.uber.com/v1/endpoints/#product-types
@param float $latitude
@param float $longitude
@return array
|
[
"Returns",
"information",
"about",
"the",
"Uber",
"products",
"offered",
"at",
"a",
"given",
"location",
"."
] |
eed59311657cf0e971d46caf3768a8aff53df8e3
|
https://github.com/basvandorst/UberPHP/blob/eed59311657cf0e971d46caf3768a8aff53df8e3/src/Uber/API/Client.php#L83-L91
|
225,838
|
basvandorst/UberPHP
|
src/Uber/API/Client.php
|
Client.estimatesPrice
|
public function estimatesPrice($start_latitude, $start_longitude, $end_latitude, $end_longitude) {
$path = '/v1/estimates/price';
$parameters = array(
'start_latitude' => $start_latitude,
'start_longitude' => $start_longitude,
'end_latitude' => $end_latitude,
'end_longitude' => $end_longitude,
);
$result = $this->adapter->get($path, $parameters, $this->getHeaders());
return $this->format($result);
}
|
php
|
public function estimatesPrice($start_latitude, $start_longitude, $end_latitude, $end_longitude) {
$path = '/v1/estimates/price';
$parameters = array(
'start_latitude' => $start_latitude,
'start_longitude' => $start_longitude,
'end_latitude' => $end_latitude,
'end_longitude' => $end_longitude,
);
$result = $this->adapter->get($path, $parameters, $this->getHeaders());
return $this->format($result);
}
|
[
"public",
"function",
"estimatesPrice",
"(",
"$",
"start_latitude",
",",
"$",
"start_longitude",
",",
"$",
"end_latitude",
",",
"$",
"end_longitude",
")",
"{",
"$",
"path",
"=",
"'/v1/estimates/price'",
";",
"$",
"parameters",
"=",
"array",
"(",
"'start_latitude'",
"=>",
"$",
"start_latitude",
",",
"'start_longitude'",
"=>",
"$",
"start_longitude",
",",
"'end_latitude'",
"=>",
"$",
"end_latitude",
",",
"'end_longitude'",
"=>",
"$",
"end_longitude",
",",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"adapter",
"->",
"get",
"(",
"$",
"path",
",",
"$",
"parameters",
",",
"$",
"this",
"->",
"getHeaders",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"format",
"(",
"$",
"result",
")",
";",
"}"
] |
Returns an estimated price range for each product offered at a given
location.
@see https://developer.uber.com/v1/endpoints/#price-estimates
@param float $start_latitude
@param float $start_longitude
@param float $end_latitude
@param float $end_longitude
@return array
|
[
"Returns",
"an",
"estimated",
"price",
"range",
"for",
"each",
"product",
"offered",
"at",
"a",
"given",
"location",
"."
] |
eed59311657cf0e971d46caf3768a8aff53df8e3
|
https://github.com/basvandorst/UberPHP/blob/eed59311657cf0e971d46caf3768a8aff53df8e3/src/Uber/API/Client.php#L130-L140
|
225,839
|
basvandorst/UberPHP
|
src/Uber/API/Client.php
|
Client.userProfile
|
public function userProfile() {
$path = '/v1/me';
$result = $this->adapter->get($path, array(), $this->getHeaders());
return $this->format($result);
}
|
php
|
public function userProfile() {
$path = '/v1/me';
$result = $this->adapter->get($path, array(), $this->getHeaders());
return $this->format($result);
}
|
[
"public",
"function",
"userProfile",
"(",
")",
"{",
"$",
"path",
"=",
"'/v1/me'",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"adapter",
"->",
"get",
"(",
"$",
"path",
",",
"array",
"(",
")",
",",
"$",
"this",
"->",
"getHeaders",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"format",
"(",
"$",
"result",
")",
";",
"}"
] |
Returns information about the Uber user that has authorized with
the application.
@see https://developer.uber.com/v1/endpoints/#user-profile
@return array
|
[
"Returns",
"information",
"about",
"the",
"Uber",
"user",
"that",
"has",
"authorized",
"with",
"the",
"application",
"."
] |
eed59311657cf0e971d46caf3768a8aff53df8e3
|
https://github.com/basvandorst/UberPHP/blob/eed59311657cf0e971d46caf3768a8aff53df8e3/src/Uber/API/Client.php#L172-L177
|
225,840
|
puli/cli
|
src/Handler/ConfigCommandHandler.php
|
ConfigCommandHandler.handleList
|
public function handleList(Args $args, IO $io)
{
$raw = !$args->isOptionSet('parsed');
$userValues = $this->manager->getConfigKeys(false, false, $raw);
$effectiveValues = $this->manager->getConfigKeys(true, true, $raw);
$table = new Table(PuliTableStyle::borderless());
$table->setHeaderRow(array('Config Key', 'User Value', 'Effective Value'));
foreach ($effectiveValues as $key => $value) {
$table->addRow(array(
sprintf('<c1>%s</c1>', $key),
array_key_exists($key, $userValues)
? StringUtil::formatValue($userValues[$key], false)
: '',
StringUtil::formatValue($value, false),
));
}
$table->render($io);
return 0;
}
|
php
|
public function handleList(Args $args, IO $io)
{
$raw = !$args->isOptionSet('parsed');
$userValues = $this->manager->getConfigKeys(false, false, $raw);
$effectiveValues = $this->manager->getConfigKeys(true, true, $raw);
$table = new Table(PuliTableStyle::borderless());
$table->setHeaderRow(array('Config Key', 'User Value', 'Effective Value'));
foreach ($effectiveValues as $key => $value) {
$table->addRow(array(
sprintf('<c1>%s</c1>', $key),
array_key_exists($key, $userValues)
? StringUtil::formatValue($userValues[$key], false)
: '',
StringUtil::formatValue($value, false),
));
}
$table->render($io);
return 0;
}
|
[
"public",
"function",
"handleList",
"(",
"Args",
"$",
"args",
",",
"IO",
"$",
"io",
")",
"{",
"$",
"raw",
"=",
"!",
"$",
"args",
"->",
"isOptionSet",
"(",
"'parsed'",
")",
";",
"$",
"userValues",
"=",
"$",
"this",
"->",
"manager",
"->",
"getConfigKeys",
"(",
"false",
",",
"false",
",",
"$",
"raw",
")",
";",
"$",
"effectiveValues",
"=",
"$",
"this",
"->",
"manager",
"->",
"getConfigKeys",
"(",
"true",
",",
"true",
",",
"$",
"raw",
")",
";",
"$",
"table",
"=",
"new",
"Table",
"(",
"PuliTableStyle",
"::",
"borderless",
"(",
")",
")",
";",
"$",
"table",
"->",
"setHeaderRow",
"(",
"array",
"(",
"'Config Key'",
",",
"'User Value'",
",",
"'Effective Value'",
")",
")",
";",
"foreach",
"(",
"$",
"effectiveValues",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"table",
"->",
"addRow",
"(",
"array",
"(",
"sprintf",
"(",
"'<c1>%s</c1>'",
",",
"$",
"key",
")",
",",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"userValues",
")",
"?",
"StringUtil",
"::",
"formatValue",
"(",
"$",
"userValues",
"[",
"$",
"key",
"]",
",",
"false",
")",
":",
"''",
",",
"StringUtil",
"::",
"formatValue",
"(",
"$",
"value",
",",
"false",
")",
",",
")",
")",
";",
"}",
"$",
"table",
"->",
"render",
"(",
"$",
"io",
")",
";",
"return",
"0",
";",
"}"
] |
Handles the "config" command.
@param Args $args The console arguments
@param IO $io The I/O
@return int The status code
|
[
"Handles",
"the",
"config",
"command",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/ConfigCommandHandler.php#L53-L75
|
225,841
|
johannesschobel/laravel-revisionable
|
src/JohannesSchobel/Revisionable/RevisionableServiceProvider.php
|
RevisionableServiceProvider.bindUserProvider
|
protected function bindUserProvider()
{
$userProvider = $this->app['config']->get('revisionable.userprovider');
switch ($userProvider) {
case 'sentry':
$this->bindSentryProvider();
break;
case 'sentinel':
$this->bindSentinelProvider();
break;
case 'jwt-auth':
$this->bindJwtAuthProvider();
break;
case 'session':
$this->bindSessionProvider();
break;
default:
$this->bindGuardProvider();
break;
}
$this->app->alias('revisionable.userprovider', UserProvider::class);
}
|
php
|
protected function bindUserProvider()
{
$userProvider = $this->app['config']->get('revisionable.userprovider');
switch ($userProvider) {
case 'sentry':
$this->bindSentryProvider();
break;
case 'sentinel':
$this->bindSentinelProvider();
break;
case 'jwt-auth':
$this->bindJwtAuthProvider();
break;
case 'session':
$this->bindSessionProvider();
break;
default:
$this->bindGuardProvider();
break;
}
$this->app->alias('revisionable.userprovider', UserProvider::class);
}
|
[
"protected",
"function",
"bindUserProvider",
"(",
")",
"{",
"$",
"userProvider",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'revisionable.userprovider'",
")",
";",
"switch",
"(",
"$",
"userProvider",
")",
"{",
"case",
"'sentry'",
":",
"$",
"this",
"->",
"bindSentryProvider",
"(",
")",
";",
"break",
";",
"case",
"'sentinel'",
":",
"$",
"this",
"->",
"bindSentinelProvider",
"(",
")",
";",
"break",
";",
"case",
"'jwt-auth'",
":",
"$",
"this",
"->",
"bindJwtAuthProvider",
"(",
")",
";",
"break",
";",
"case",
"'session'",
":",
"$",
"this",
"->",
"bindSessionProvider",
"(",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"bindGuardProvider",
"(",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"'revisionable.userprovider'",
",",
"UserProvider",
"::",
"class",
")",
";",
"}"
] |
Bind user provider implementation to the IoC.
|
[
"Bind",
"user",
"provider",
"implementation",
"to",
"the",
"IoC",
"."
] |
f5a1d4c1eff343e76f58b19b97be3007f4584b49
|
https://github.com/johannesschobel/laravel-revisionable/blob/f5a1d4c1eff343e76f58b19b97be3007f4584b49/src/JohannesSchobel/Revisionable/RevisionableServiceProvider.php#L38-L64
|
225,842
|
johannesschobel/laravel-revisionable
|
src/JohannesSchobel/Revisionable/RevisionableServiceProvider.php
|
RevisionableServiceProvider.bindSentryProvider
|
protected function bindSentryProvider()
{
$this->app->singleton('revisionable.userprovider', function ($app) {
$field = $app['config']->get('revisionable.userfield');
return new Adapters\Sentry($app['sentry'], $field);
});
}
|
php
|
protected function bindSentryProvider()
{
$this->app->singleton('revisionable.userprovider', function ($app) {
$field = $app['config']->get('revisionable.userfield');
return new Adapters\Sentry($app['sentry'], $field);
});
}
|
[
"protected",
"function",
"bindSentryProvider",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'revisionable.userprovider'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"field",
"=",
"$",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'revisionable.userfield'",
")",
";",
"return",
"new",
"Adapters",
"\\",
"Sentry",
"(",
"$",
"app",
"[",
"'sentry'",
"]",
",",
"$",
"field",
")",
";",
"}",
")",
";",
"}"
] |
Bind adapter for Sentry to the IoC.
|
[
"Bind",
"adapter",
"for",
"Sentry",
"to",
"the",
"IoC",
"."
] |
f5a1d4c1eff343e76f58b19b97be3007f4584b49
|
https://github.com/johannesschobel/laravel-revisionable/blob/f5a1d4c1eff343e76f58b19b97be3007f4584b49/src/JohannesSchobel/Revisionable/RevisionableServiceProvider.php#L69-L75
|
225,843
|
johannesschobel/laravel-revisionable
|
src/JohannesSchobel/Revisionable/RevisionableServiceProvider.php
|
RevisionableServiceProvider.bindSessionProvider
|
protected function bindSessionProvider()
{
$this->app->singleton('revisionable.userprovider', function ($app) {
$field = $app['config']->get('revisionable.userfield');
return new Adapters\Session(session(), $field);
});
}
|
php
|
protected function bindSessionProvider()
{
$this->app->singleton('revisionable.userprovider', function ($app) {
$field = $app['config']->get('revisionable.userfield');
return new Adapters\Session(session(), $field);
});
}
|
[
"protected",
"function",
"bindSessionProvider",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'revisionable.userprovider'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"field",
"=",
"$",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'revisionable.userfield'",
")",
";",
"return",
"new",
"Adapters",
"\\",
"Session",
"(",
"session",
"(",
")",
",",
"$",
"field",
")",
";",
"}",
")",
";",
"}"
] |
Bind adapter for Session to the IoC.
@return void
|
[
"Bind",
"adapter",
"for",
"Session",
"to",
"the",
"IoC",
"."
] |
f5a1d4c1eff343e76f58b19b97be3007f4584b49
|
https://github.com/johannesschobel/laravel-revisionable/blob/f5a1d4c1eff343e76f58b19b97be3007f4584b49/src/JohannesSchobel/Revisionable/RevisionableServiceProvider.php#L115-L121
|
225,844
|
johannesschobel/laravel-revisionable
|
src/JohannesSchobel/Revisionable/RevisionableServiceProvider.php
|
RevisionableServiceProvider.bootModel
|
protected function bootModel()
{
$table = $this->app['config']->get('revisionable.table', 'revisions');
$user = $this->app['config']->get('revisionable.usermodel', 'App\User');
forward_static_call_array([Revision::class, 'setCustomTable'], [$table]);
forward_static_call_array([Revision::class, 'setUserModel'], [$user]);
}
|
php
|
protected function bootModel()
{
$table = $this->app['config']->get('revisionable.table', 'revisions');
$user = $this->app['config']->get('revisionable.usermodel', 'App\User');
forward_static_call_array([Revision::class, 'setCustomTable'], [$table]);
forward_static_call_array([Revision::class, 'setUserModel'], [$user]);
}
|
[
"protected",
"function",
"bootModel",
"(",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'revisionable.table'",
",",
"'revisions'",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'revisionable.usermodel'",
",",
"'App\\User'",
")",
";",
"forward_static_call_array",
"(",
"[",
"Revision",
"::",
"class",
",",
"'setCustomTable'",
"]",
",",
"[",
"$",
"table",
"]",
")",
";",
"forward_static_call_array",
"(",
"[",
"Revision",
"::",
"class",
",",
"'setUserModel'",
"]",
",",
"[",
"$",
"user",
"]",
")",
";",
"}"
] |
Boot the Revision model.
|
[
"Boot",
"the",
"Revision",
"model",
"."
] |
f5a1d4c1eff343e76f58b19b97be3007f4584b49
|
https://github.com/johannesschobel/laravel-revisionable/blob/f5a1d4c1eff343e76f58b19b97be3007f4584b49/src/JohannesSchobel/Revisionable/RevisionableServiceProvider.php#L126-L133
|
225,845
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-locator.php
|
Carbon_Breadcrumb_Locator.factory
|
public static function factory( $type, $subtype = '' ) {
$class = self::verify_class_name( __CLASS__ . '_' . $type, 'Unexisting breadcrumb locator type: "' . $type . '".' );
$locator = new $class( $type, $subtype );
return $locator;
}
|
php
|
public static function factory( $type, $subtype = '' ) {
$class = self::verify_class_name( __CLASS__ . '_' . $type, 'Unexisting breadcrumb locator type: "' . $type . '".' );
$locator = new $class( $type, $subtype );
return $locator;
}
|
[
"public",
"static",
"function",
"factory",
"(",
"$",
"type",
",",
"$",
"subtype",
"=",
"''",
")",
"{",
"$",
"class",
"=",
"self",
"::",
"verify_class_name",
"(",
"__CLASS__",
".",
"'_'",
".",
"$",
"type",
",",
"'Unexisting breadcrumb locator type: \"'",
".",
"$",
"type",
".",
"'\".'",
")",
";",
"$",
"locator",
"=",
"new",
"$",
"class",
"(",
"$",
"type",
",",
"$",
"subtype",
")",
";",
"return",
"$",
"locator",
";",
"}"
] |
Build a new breadcrumb item locator of the selected type.
@static
@access public
@param string $type Type of the breadcrumb item locator.
@param string $subtype Subtype of the breadcrumb item locator.
@return Carbon_Breadcrumb_Locator $locator The new breadcrumb item locator.
|
[
"Build",
"a",
"new",
"breadcrumb",
"item",
"locator",
"of",
"the",
"selected",
"type",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-locator.php#L41-L46
|
225,846
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-locator.php
|
Carbon_Breadcrumb_Locator.generate_items_for_subtypes
|
public function generate_items_for_subtypes( $subtypes ) {
$all_items = array();
foreach ( $subtypes as $subtype ) {
$locator = Carbon_Breadcrumb_Locator::factory( $this->get_type(), $subtype );
if ( $locator->is_included() ) {
$items = $locator->get_items();
$all_items = array_merge( $all_items, $items );
}
}
return $all_items;
}
|
php
|
public function generate_items_for_subtypes( $subtypes ) {
$all_items = array();
foreach ( $subtypes as $subtype ) {
$locator = Carbon_Breadcrumb_Locator::factory( $this->get_type(), $subtype );
if ( $locator->is_included() ) {
$items = $locator->get_items();
$all_items = array_merge( $all_items, $items );
}
}
return $all_items;
}
|
[
"public",
"function",
"generate_items_for_subtypes",
"(",
"$",
"subtypes",
")",
"{",
"$",
"all_items",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"subtypes",
"as",
"$",
"subtype",
")",
"{",
"$",
"locator",
"=",
"Carbon_Breadcrumb_Locator",
"::",
"factory",
"(",
"$",
"this",
"->",
"get_type",
"(",
")",
",",
"$",
"subtype",
")",
";",
"if",
"(",
"$",
"locator",
"->",
"is_included",
"(",
")",
")",
"{",
"$",
"items",
"=",
"$",
"locator",
"->",
"get_items",
"(",
")",
";",
"$",
"all_items",
"=",
"array_merge",
"(",
"$",
"all_items",
",",
"$",
"items",
")",
";",
"}",
"}",
"return",
"$",
"all_items",
";",
"}"
] |
Generate a set of breadcrumb items that found by the current type and the provided subtypes.
@access public
@param array $subtypes The subtypes to generate items for.
@return array $items The items, generated by this locator.
|
[
"Generate",
"a",
"set",
"of",
"breadcrumb",
"items",
"that",
"found",
"by",
"the",
"current",
"type",
"and",
"the",
"provided",
"subtypes",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-locator.php#L71-L83
|
225,847
|
BKWLD/upchuck
|
src/Storage.php
|
Storage.makeNestedAndUniquePath
|
public function makeNestedAndUniquePath($filename, $disk = null) {
// If no disk defined, get it from the current mount mananger
if (empty($disk)) $disk = $this->manager->getFilesystem('disk');
// Remove unsafe characters from the filename
// https://regex101.com/r/mJ3sI5/1
$filename = preg_replace('#[^\w-_\.]#i', '_', $filename);
// Create nested folders to store the file in
$dir = '';
for ($i=0; $i<$this->depth; $i++) {
$dir .= str_pad(mt_rand(0, $this->length - 1), strlen($this->length), '0', STR_PAD_LEFT).'/';
}
// If this file doesn't already exist, return it
$path = $dir.$filename;
if (!$disk->has($path)) return $path;
// Get a unique filename for the file and return it
$file = pathinfo($filename, PATHINFO_FILENAME);
$i = 1;
$ext = pathinfo($filename, PATHINFO_EXTENSION);
while ($disk->has($path = $dir.$file.'-'.$i.'.'.$ext)) { $i++; }
return $path;
}
|
php
|
public function makeNestedAndUniquePath($filename, $disk = null) {
// If no disk defined, get it from the current mount mananger
if (empty($disk)) $disk = $this->manager->getFilesystem('disk');
// Remove unsafe characters from the filename
// https://regex101.com/r/mJ3sI5/1
$filename = preg_replace('#[^\w-_\.]#i', '_', $filename);
// Create nested folders to store the file in
$dir = '';
for ($i=0; $i<$this->depth; $i++) {
$dir .= str_pad(mt_rand(0, $this->length - 1), strlen($this->length), '0', STR_PAD_LEFT).'/';
}
// If this file doesn't already exist, return it
$path = $dir.$filename;
if (!$disk->has($path)) return $path;
// Get a unique filename for the file and return it
$file = pathinfo($filename, PATHINFO_FILENAME);
$i = 1;
$ext = pathinfo($filename, PATHINFO_EXTENSION);
while ($disk->has($path = $dir.$file.'-'.$i.'.'.$ext)) { $i++; }
return $path;
}
|
[
"public",
"function",
"makeNestedAndUniquePath",
"(",
"$",
"filename",
",",
"$",
"disk",
"=",
"null",
")",
"{",
"// If no disk defined, get it from the current mount mananger",
"if",
"(",
"empty",
"(",
"$",
"disk",
")",
")",
"$",
"disk",
"=",
"$",
"this",
"->",
"manager",
"->",
"getFilesystem",
"(",
"'disk'",
")",
";",
"// Remove unsafe characters from the filename",
"// https://regex101.com/r/mJ3sI5/1",
"$",
"filename",
"=",
"preg_replace",
"(",
"'#[^\\w-_\\.]#i'",
",",
"'_'",
",",
"$",
"filename",
")",
";",
"// Create nested folders to store the file in",
"$",
"dir",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"depth",
";",
"$",
"i",
"++",
")",
"{",
"$",
"dir",
".=",
"str_pad",
"(",
"mt_rand",
"(",
"0",
",",
"$",
"this",
"->",
"length",
"-",
"1",
")",
",",
"strlen",
"(",
"$",
"this",
"->",
"length",
")",
",",
"'0'",
",",
"STR_PAD_LEFT",
")",
".",
"'/'",
";",
"}",
"// If this file doesn't already exist, return it",
"$",
"path",
"=",
"$",
"dir",
".",
"$",
"filename",
";",
"if",
"(",
"!",
"$",
"disk",
"->",
"has",
"(",
"$",
"path",
")",
")",
"return",
"$",
"path",
";",
"// Get a unique filename for the file and return it",
"$",
"file",
"=",
"pathinfo",
"(",
"$",
"filename",
",",
"PATHINFO_FILENAME",
")",
";",
"$",
"i",
"=",
"1",
";",
"$",
"ext",
"=",
"pathinfo",
"(",
"$",
"filename",
",",
"PATHINFO_EXTENSION",
")",
";",
"while",
"(",
"$",
"disk",
"->",
"has",
"(",
"$",
"path",
"=",
"$",
"dir",
".",
"$",
"file",
".",
"'-'",
".",
"$",
"i",
".",
"'.'",
".",
"$",
"ext",
")",
")",
"{",
"$",
"i",
"++",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Create a unique directory and filename
@param string $filename
@param League\Flysystem\Filesystem|void $disk
@return string New path and filename
|
[
"Create",
"a",
"unique",
"directory",
"and",
"filename"
] |
2d2202b1bc4a86a0a91ceb319521a263b0c88f54
|
https://github.com/BKWLD/upchuck/blob/2d2202b1bc4a86a0a91ceb319521a263b0c88f54/src/Storage.php#L75-L101
|
225,848
|
BKWLD/upchuck
|
src/Storage.php
|
Storage.delete
|
public function delete($url) {
// Convert to a path
$path = $this->helpers->path($url);
// Delete the path if it still exists
if ($this->manager->has('disk://'.$path)) $this->manager->delete('disk://'.$path);
}
|
php
|
public function delete($url) {
// Convert to a path
$path = $this->helpers->path($url);
// Delete the path if it still exists
if ($this->manager->has('disk://'.$path)) $this->manager->delete('disk://'.$path);
}
|
[
"public",
"function",
"delete",
"(",
"$",
"url",
")",
"{",
"// Convert to a path",
"$",
"path",
"=",
"$",
"this",
"->",
"helpers",
"->",
"path",
"(",
"$",
"url",
")",
";",
"// Delete the path if it still exists",
"if",
"(",
"$",
"this",
"->",
"manager",
"->",
"has",
"(",
"'disk://'",
".",
"$",
"path",
")",
")",
"$",
"this",
"->",
"manager",
"->",
"delete",
"(",
"'disk://'",
".",
"$",
"path",
")",
";",
"}"
] |
Delete an upload
@param string $url A URL like was returned from moveUpload()
@return void
|
[
"Delete",
"an",
"upload"
] |
2d2202b1bc4a86a0a91ceb319521a263b0c88f54
|
https://github.com/BKWLD/upchuck/blob/2d2202b1bc4a86a0a91ceb319521a263b0c88f54/src/Storage.php#L109-L116
|
225,849
|
puli/cli
|
src/Handler/BuildCommandHandler.php
|
BuildCommandHandler.handle
|
public function handle(Args $args)
{
$target = $args->getArgument('target');
if (!in_array($target, self::$targets)) {
throw new RuntimeException(sprintf(
'Invalid build target "%s". Expected one of: "%s"',
$target,
implode('", "', self::$targets)
));
}
if ('all' === $target || 'factory' === $target) {
$this->factoryManager->autoGenerateFactoryClass();
}
if ('all' === $target || 'repository' === $target) {
$this->repoManager->clearRepository();
$this->repoManager->buildRepository();
}
if ('all' === $target || 'discovery' === $target) {
$this->discoveryManager->clearDiscovery();
$this->discoveryManager->buildDiscovery();
$this->discoveryManager->removeObsoleteDisabledBindingDescriptors();
}
return 0;
}
|
php
|
public function handle(Args $args)
{
$target = $args->getArgument('target');
if (!in_array($target, self::$targets)) {
throw new RuntimeException(sprintf(
'Invalid build target "%s". Expected one of: "%s"',
$target,
implode('", "', self::$targets)
));
}
if ('all' === $target || 'factory' === $target) {
$this->factoryManager->autoGenerateFactoryClass();
}
if ('all' === $target || 'repository' === $target) {
$this->repoManager->clearRepository();
$this->repoManager->buildRepository();
}
if ('all' === $target || 'discovery' === $target) {
$this->discoveryManager->clearDiscovery();
$this->discoveryManager->buildDiscovery();
$this->discoveryManager->removeObsoleteDisabledBindingDescriptors();
}
return 0;
}
|
[
"public",
"function",
"handle",
"(",
"Args",
"$",
"args",
")",
"{",
"$",
"target",
"=",
"$",
"args",
"->",
"getArgument",
"(",
"'target'",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"target",
",",
"self",
"::",
"$",
"targets",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Invalid build target \"%s\". Expected one of: \"%s\"'",
",",
"$",
"target",
",",
"implode",
"(",
"'\", \"'",
",",
"self",
"::",
"$",
"targets",
")",
")",
")",
";",
"}",
"if",
"(",
"'all'",
"===",
"$",
"target",
"||",
"'factory'",
"===",
"$",
"target",
")",
"{",
"$",
"this",
"->",
"factoryManager",
"->",
"autoGenerateFactoryClass",
"(",
")",
";",
"}",
"if",
"(",
"'all'",
"===",
"$",
"target",
"||",
"'repository'",
"===",
"$",
"target",
")",
"{",
"$",
"this",
"->",
"repoManager",
"->",
"clearRepository",
"(",
")",
";",
"$",
"this",
"->",
"repoManager",
"->",
"buildRepository",
"(",
")",
";",
"}",
"if",
"(",
"'all'",
"===",
"$",
"target",
"||",
"'discovery'",
"===",
"$",
"target",
")",
"{",
"$",
"this",
"->",
"discoveryManager",
"->",
"clearDiscovery",
"(",
")",
";",
"$",
"this",
"->",
"discoveryManager",
"->",
"buildDiscovery",
"(",
")",
";",
"$",
"this",
"->",
"discoveryManager",
"->",
"removeObsoleteDisabledBindingDescriptors",
"(",
")",
";",
"}",
"return",
"0",
";",
"}"
] |
Handles the "build" command.
@param Args $args The console arguments.
@return int The status code.
|
[
"Handles",
"the",
"build",
"command",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/BuildCommandHandler.php#L70-L98
|
225,850
|
Gaufrette/extras
|
src/Resolvable/Resolver/AwsS3PresignedUrlResolver.php
|
AwsS3PresignedUrlResolver.resolve
|
public function resolve($path)
{
// For AWS SDK v2
if ($this->service instanceof \Aws\Common\Client\AbstractClient) {
return $this->service->getObjectUrl(
$this->bucket,
$this->computePath($path),
$this->expiresAt
);
}
// For AWS SDK v3
$command = $this->service->getCommand('GetObject', [
'Bucket' => $this->bucket,
'Key' => $this->computePath($path),
]);
return (string) $this->service->createPresignedRequest($command, $this->expiresAt)->getUri();
}
|
php
|
public function resolve($path)
{
// For AWS SDK v2
if ($this->service instanceof \Aws\Common\Client\AbstractClient) {
return $this->service->getObjectUrl(
$this->bucket,
$this->computePath($path),
$this->expiresAt
);
}
// For AWS SDK v3
$command = $this->service->getCommand('GetObject', [
'Bucket' => $this->bucket,
'Key' => $this->computePath($path),
]);
return (string) $this->service->createPresignedRequest($command, $this->expiresAt)->getUri();
}
|
[
"public",
"function",
"resolve",
"(",
"$",
"path",
")",
"{",
"// For AWS SDK v2",
"if",
"(",
"$",
"this",
"->",
"service",
"instanceof",
"\\",
"Aws",
"\\",
"Common",
"\\",
"Client",
"\\",
"AbstractClient",
")",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getObjectUrl",
"(",
"$",
"this",
"->",
"bucket",
",",
"$",
"this",
"->",
"computePath",
"(",
"$",
"path",
")",
",",
"$",
"this",
"->",
"expiresAt",
")",
";",
"}",
"// For AWS SDK v3",
"$",
"command",
"=",
"$",
"this",
"->",
"service",
"->",
"getCommand",
"(",
"'GetObject'",
",",
"[",
"'Bucket'",
"=>",
"$",
"this",
"->",
"bucket",
",",
"'Key'",
"=>",
"$",
"this",
"->",
"computePath",
"(",
"$",
"path",
")",
",",
"]",
")",
";",
"return",
"(",
"string",
")",
"$",
"this",
"->",
"service",
"->",
"createPresignedRequest",
"(",
"$",
"command",
",",
"$",
"this",
"->",
"expiresAt",
")",
"->",
"getUri",
"(",
")",
";",
"}"
] |
Resolves given object path into presigned request URI.
@param string $path
@return string
|
[
"Resolves",
"given",
"object",
"path",
"into",
"presigned",
"request",
"URI",
"."
] |
191863b75138a70890f924f5c7cc2772e477667c
|
https://github.com/Gaufrette/extras/blob/191863b75138a70890f924f5c7cc2772e477667c/src/Resolvable/Resolver/AwsS3PresignedUrlResolver.php#L50-L68
|
225,851
|
puli/cli
|
src/Handler/TreeCommandHandler.php
|
TreeCommandHandler.handle
|
public function handle(Args $args, IO $io)
{
$path = Path::makeAbsolute($args->getArgument('path'), $this->currentPath);
$resource = $this->repo->get($path);
$total = 0;
$io->writeLine('<c1>'.$resource->getPath().'</c1>');
$this->printTree($io, $resource, $total);
$io->writeLine('');
$io->writeLine($total.' resources');
return 0;
}
|
php
|
public function handle(Args $args, IO $io)
{
$path = Path::makeAbsolute($args->getArgument('path'), $this->currentPath);
$resource = $this->repo->get($path);
$total = 0;
$io->writeLine('<c1>'.$resource->getPath().'</c1>');
$this->printTree($io, $resource, $total);
$io->writeLine('');
$io->writeLine($total.' resources');
return 0;
}
|
[
"public",
"function",
"handle",
"(",
"Args",
"$",
"args",
",",
"IO",
"$",
"io",
")",
"{",
"$",
"path",
"=",
"Path",
"::",
"makeAbsolute",
"(",
"$",
"args",
"->",
"getArgument",
"(",
"'path'",
")",
",",
"$",
"this",
"->",
"currentPath",
")",
";",
"$",
"resource",
"=",
"$",
"this",
"->",
"repo",
"->",
"get",
"(",
"$",
"path",
")",
";",
"$",
"total",
"=",
"0",
";",
"$",
"io",
"->",
"writeLine",
"(",
"'<c1>'",
".",
"$",
"resource",
"->",
"getPath",
"(",
")",
".",
"'</c1>'",
")",
";",
"$",
"this",
"->",
"printTree",
"(",
"$",
"io",
",",
"$",
"resource",
",",
"$",
"total",
")",
";",
"$",
"io",
"->",
"writeLine",
"(",
"''",
")",
";",
"$",
"io",
"->",
"writeLine",
"(",
"$",
"total",
".",
"' resources'",
")",
";",
"return",
"0",
";",
"}"
] |
Handles the "tree" command.
@param Args $args The console arguments.
@param IO $io The I/O.
@return int The status code.
|
[
"Handles",
"the",
"tree",
"command",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/TreeCommandHandler.php#L85-L100
|
225,852
|
puli/cli
|
src/Handler/TreeCommandHandler.php
|
TreeCommandHandler.printTree
|
private function printTree(IO $io, PuliResource $resource, &$total, $prefix = '')
{
// The root node has an empty name
$children = $resource->listChildren();
$lastIndex = count($children) - 1;
$index = 0;
foreach ($children as $child) {
$isLastChild = $index === $lastIndex;
$childPrefix = $isLastChild ? self::LAST_CHILD_PREFIX : self::CHILD_PREFIX;
$nestingPrefix = $isLastChild ? self::NESTING_CLOSED_PREFIX : self::NESTING_OPEN_PREFIX;
$name = $child->getName() ?: '/';
if ($child->hasChildren()) {
$name = '<c1>'.$name.'</c1>';
}
$io->writeLine($prefix.$childPrefix.$name);
$this->printTree($io, $child, $total, $prefix.$nestingPrefix);
++$index;
++$total;
}
}
|
php
|
private function printTree(IO $io, PuliResource $resource, &$total, $prefix = '')
{
// The root node has an empty name
$children = $resource->listChildren();
$lastIndex = count($children) - 1;
$index = 0;
foreach ($children as $child) {
$isLastChild = $index === $lastIndex;
$childPrefix = $isLastChild ? self::LAST_CHILD_PREFIX : self::CHILD_PREFIX;
$nestingPrefix = $isLastChild ? self::NESTING_CLOSED_PREFIX : self::NESTING_OPEN_PREFIX;
$name = $child->getName() ?: '/';
if ($child->hasChildren()) {
$name = '<c1>'.$name.'</c1>';
}
$io->writeLine($prefix.$childPrefix.$name);
$this->printTree($io, $child, $total, $prefix.$nestingPrefix);
++$index;
++$total;
}
}
|
[
"private",
"function",
"printTree",
"(",
"IO",
"$",
"io",
",",
"PuliResource",
"$",
"resource",
",",
"&",
"$",
"total",
",",
"$",
"prefix",
"=",
"''",
")",
"{",
"// The root node has an empty name",
"$",
"children",
"=",
"$",
"resource",
"->",
"listChildren",
"(",
")",
";",
"$",
"lastIndex",
"=",
"count",
"(",
"$",
"children",
")",
"-",
"1",
";",
"$",
"index",
"=",
"0",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"isLastChild",
"=",
"$",
"index",
"===",
"$",
"lastIndex",
";",
"$",
"childPrefix",
"=",
"$",
"isLastChild",
"?",
"self",
"::",
"LAST_CHILD_PREFIX",
":",
"self",
"::",
"CHILD_PREFIX",
";",
"$",
"nestingPrefix",
"=",
"$",
"isLastChild",
"?",
"self",
"::",
"NESTING_CLOSED_PREFIX",
":",
"self",
"::",
"NESTING_OPEN_PREFIX",
";",
"$",
"name",
"=",
"$",
"child",
"->",
"getName",
"(",
")",
"?",
":",
"'/'",
";",
"if",
"(",
"$",
"child",
"->",
"hasChildren",
"(",
")",
")",
"{",
"$",
"name",
"=",
"'<c1>'",
".",
"$",
"name",
".",
"'</c1>'",
";",
"}",
"$",
"io",
"->",
"writeLine",
"(",
"$",
"prefix",
".",
"$",
"childPrefix",
".",
"$",
"name",
")",
";",
"$",
"this",
"->",
"printTree",
"(",
"$",
"io",
",",
"$",
"child",
",",
"$",
"total",
",",
"$",
"prefix",
".",
"$",
"nestingPrefix",
")",
";",
"++",
"$",
"index",
";",
"++",
"$",
"total",
";",
"}",
"}"
] |
Recursively prints the tree for the given resource.
@param IO $io The I/O.
@param PuliResource $resource The printed resource.
@param int $total Collects the total number of printed resources.
@param string $prefix The prefix for all printed resources.
|
[
"Recursively",
"prints",
"the",
"tree",
"for",
"the",
"given",
"resource",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/TreeCommandHandler.php#L110-L135
|
225,853
|
tyxla/carbon-breadcrumbs
|
admin/class-carbon-breadcrumb-admin-settings-field.php
|
Carbon_Breadcrumb_Admin_Settings_Field.factory
|
public static function factory( $type, $id, $title, $section = '', $args = array() ) {
$class = self::verify_class_name( __CLASS__ . '_' . $type, 'Unknown settings field type "' . $type . '".' );
$field = new $class( $id, $title, $section, $args );
return $field;
}
|
php
|
public static function factory( $type, $id, $title, $section = '', $args = array() ) {
$class = self::verify_class_name( __CLASS__ . '_' . $type, 'Unknown settings field type "' . $type . '".' );
$field = new $class( $id, $title, $section, $args );
return $field;
}
|
[
"public",
"static",
"function",
"factory",
"(",
"$",
"type",
",",
"$",
"id",
",",
"$",
"title",
",",
"$",
"section",
"=",
"''",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"class",
"=",
"self",
"::",
"verify_class_name",
"(",
"__CLASS__",
".",
"'_'",
".",
"$",
"type",
",",
"'Unknown settings field type \"'",
".",
"$",
"type",
".",
"'\".'",
")",
";",
"$",
"field",
"=",
"new",
"$",
"class",
"(",
"$",
"id",
",",
"$",
"title",
",",
"$",
"section",
",",
"$",
"args",
")",
";",
"return",
"$",
"field",
";",
"}"
] |
Register a new administration breadcrumb settings field of a certain type.
@static
@access public
@param string $type Type of the field.
@param string $id The ID of the field.
@param string $title The title of the field.
@param string $section The name of the section.
@param array $args Additional args.
@return Carbon_Breadcrumb_Admin_Settings_Field $field
|
[
"Register",
"a",
"new",
"administration",
"breadcrumb",
"settings",
"field",
"of",
"a",
"certain",
"type",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/admin/class-carbon-breadcrumb-admin-settings-field.php#L75-L80
|
225,854
|
tyxla/carbon-breadcrumbs
|
admin/class-carbon-breadcrumb-admin-settings-field.php
|
Carbon_Breadcrumb_Admin_Settings_Field.get_value
|
public function get_value() {
$original_name = str_replace( 'carbon_breadcrumbs_', '', $this->get_id() );
$field_data = Carbon_Breadcrumb_Admin_Settings::get_field_data();
$default = ! empty( $field_data[ $original_name ]['default'] ) ? $field_data[ $original_name ]['default'] : '';
$value = get_option( $this->get_id() );
if ( false === $value ) {
$value = $default;
}
return $value;
}
|
php
|
public function get_value() {
$original_name = str_replace( 'carbon_breadcrumbs_', '', $this->get_id() );
$field_data = Carbon_Breadcrumb_Admin_Settings::get_field_data();
$default = ! empty( $field_data[ $original_name ]['default'] ) ? $field_data[ $original_name ]['default'] : '';
$value = get_option( $this->get_id() );
if ( false === $value ) {
$value = $default;
}
return $value;
}
|
[
"public",
"function",
"get_value",
"(",
")",
"{",
"$",
"original_name",
"=",
"str_replace",
"(",
"'carbon_breadcrumbs_'",
",",
"''",
",",
"$",
"this",
"->",
"get_id",
"(",
")",
")",
";",
"$",
"field_data",
"=",
"Carbon_Breadcrumb_Admin_Settings",
"::",
"get_field_data",
"(",
")",
";",
"$",
"default",
"=",
"!",
"empty",
"(",
"$",
"field_data",
"[",
"$",
"original_name",
"]",
"[",
"'default'",
"]",
")",
"?",
"$",
"field_data",
"[",
"$",
"original_name",
"]",
"[",
"'default'",
"]",
":",
"''",
";",
"$",
"value",
"=",
"get_option",
"(",
"$",
"this",
"->",
"get_id",
"(",
")",
")",
";",
"if",
"(",
"false",
"===",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"default",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Retrieve the field value. If there is no value, use the default one.
@access public
@return mixed $value The value of this field.
|
[
"Retrieve",
"the",
"field",
"value",
".",
"If",
"there",
"is",
"no",
"value",
"use",
"the",
"default",
"one",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/admin/class-carbon-breadcrumb-admin-settings-field.php#L133-L144
|
225,855
|
tyxla/carbon-breadcrumbs
|
admin/class-carbon-breadcrumb-admin-settings-field.php
|
Carbon_Breadcrumb_Admin_Settings_Field.render_help
|
public function render_help() {
$field_data = Carbon_Breadcrumb_Admin_Settings::get_field_data();
$original_name = str_replace( 'carbon_breadcrumbs_', '', $this->get_id() );
$help = ! empty( $field_data[ $original_name ]['help'] ) ? $field_data[ $original_name ]['help'] : '';
if ( ! $help ) {
return;
}
?>
<p class="description"><?php echo esc_html( $help ); ?></p>
<?php
}
|
php
|
public function render_help() {
$field_data = Carbon_Breadcrumb_Admin_Settings::get_field_data();
$original_name = str_replace( 'carbon_breadcrumbs_', '', $this->get_id() );
$help = ! empty( $field_data[ $original_name ]['help'] ) ? $field_data[ $original_name ]['help'] : '';
if ( ! $help ) {
return;
}
?>
<p class="description"><?php echo esc_html( $help ); ?></p>
<?php
}
|
[
"public",
"function",
"render_help",
"(",
")",
"{",
"$",
"field_data",
"=",
"Carbon_Breadcrumb_Admin_Settings",
"::",
"get_field_data",
"(",
")",
";",
"$",
"original_name",
"=",
"str_replace",
"(",
"'carbon_breadcrumbs_'",
",",
"''",
",",
"$",
"this",
"->",
"get_id",
"(",
")",
")",
";",
"$",
"help",
"=",
"!",
"empty",
"(",
"$",
"field_data",
"[",
"$",
"original_name",
"]",
"[",
"'help'",
"]",
")",
"?",
"$",
"field_data",
"[",
"$",
"original_name",
"]",
"[",
"'help'",
"]",
":",
"''",
";",
"if",
"(",
"!",
"$",
"help",
")",
"{",
"return",
";",
"}",
"?>\n\t\t<p class=\"description\"><?php",
"echo",
"esc_html",
"(",
"$",
"help",
")",
";",
"?></p>\n\t\t<?php",
"}"
] |
Render the help description of this field.
@access public
|
[
"Render",
"the",
"help",
"description",
"of",
"this",
"field",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/admin/class-carbon-breadcrumb-admin-settings-field.php#L151-L161
|
225,856
|
ccottet/ldap
|
Core/NodeAttribute.php
|
NodeAttribute.add
|
public function add($value)
{
if (is_array($value)) {
return $this->handleArray('add', $value);
}
if (is_null($value) || strlen($value) == 0) {
return false;
}
if (false !== array_search($value, $this->values)) {
return false;
}
$this->offsetSet(null, $value);
return true;
}
|
php
|
public function add($value)
{
if (is_array($value)) {
return $this->handleArray('add', $value);
}
if (is_null($value) || strlen($value) == 0) {
return false;
}
if (false !== array_search($value, $this->values)) {
return false;
}
$this->offsetSet(null, $value);
return true;
}
|
[
"public",
"function",
"add",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"handleArray",
"(",
"'add'",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
"||",
"strlen",
"(",
"$",
"value",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"false",
"!==",
"array_search",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"values",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"offsetSet",
"(",
"null",
",",
"$",
"value",
")",
";",
"return",
"true",
";",
"}"
] |
Add a value as an instance of this attribute
@param mixed $value Value to add to the attribute instances
@return boolean true if success
|
[
"Add",
"a",
"value",
"as",
"an",
"instance",
"of",
"this",
"attribute"
] |
0759f17996fbb434ee5155dc527b95d8059c6d41
|
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/NodeAttribute.php#L75-L88
|
225,857
|
ccottet/ldap
|
Core/NodeAttribute.php
|
NodeAttribute.set
|
public function set($values)
{
if (! is_array($values)) {
$values = array($values);
}
$this->values = $values;
$this->snapshot();
$this->tracker->markOverridden();
return true;
}
|
php
|
public function set($values)
{
if (! is_array($values)) {
$values = array($values);
}
$this->values = $values;
$this->snapshot();
$this->tracker->markOverridden();
return true;
}
|
[
"public",
"function",
"set",
"(",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"$",
"values",
"=",
"array",
"(",
"$",
"values",
")",
";",
"}",
"$",
"this",
"->",
"values",
"=",
"$",
"values",
";",
"$",
"this",
"->",
"snapshot",
"(",
")",
";",
"$",
"this",
"->",
"tracker",
"->",
"markOverridden",
"(",
")",
";",
"return",
"true",
";",
"}"
] |
Sets a set of value replacing any existing values registered
@param mixed $values Values to set for the attribute instances
@return boolean true if success
|
[
"Sets",
"a",
"set",
"of",
"value",
"replacing",
"any",
"existing",
"values",
"registered"
] |
0759f17996fbb434ee5155dc527b95d8059c6d41
|
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/NodeAttribute.php#L97-L106
|
225,858
|
ccottet/ldap
|
Core/NodeAttribute.php
|
NodeAttribute.handleArray
|
protected function handleArray($method, array $values)
{
$result = false;
foreach ($values as $value) {
$flag = call_user_func(array($this, $method), $value);
$result = $result || $flag;
}
return $result;
}
|
php
|
protected function handleArray($method, array $values)
{
$result = false;
foreach ($values as $value) {
$flag = call_user_func(array($this, $method), $value);
$result = $result || $flag;
}
return $result;
}
|
[
"protected",
"function",
"handleArray",
"(",
"$",
"method",
",",
"array",
"$",
"values",
")",
"{",
"$",
"result",
"=",
"false",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"flag",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"method",
")",
",",
"$",
"value",
")",
";",
"$",
"result",
"=",
"$",
"result",
"||",
"$",
"flag",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Handle action for an array of values to the attribute
@param string $method Name of the method to use for handling
@param array $values Values to be added
@return boolean True if success
|
[
"Handle",
"action",
"for",
"an",
"array",
"of",
"values",
"to",
"the",
"attribute"
] |
0759f17996fbb434ee5155dc527b95d8059c6d41
|
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/NodeAttribute.php#L126-L134
|
225,859
|
ccottet/ldap
|
Core/NodeAttribute.php
|
NodeAttribute.remove
|
public function remove($value)
{
if (is_array($value)) {
return $this->handleArray('remove', $value);
}
$key = array_search($value, $this->values);
if (false === $key) {
return false;
}
$this->offsetUnset($key);
return true;
}
|
php
|
public function remove($value)
{
if (is_array($value)) {
return $this->handleArray('remove', $value);
}
$key = array_search($value, $this->values);
if (false === $key) {
return false;
}
$this->offsetUnset($key);
return true;
}
|
[
"public",
"function",
"remove",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"handleArray",
"(",
"'remove'",
",",
"$",
"value",
")",
";",
"}",
"$",
"key",
"=",
"array_search",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"values",
")",
";",
"if",
"(",
"false",
"===",
"$",
"key",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"offsetUnset",
"(",
"$",
"key",
")",
";",
"return",
"true",
";",
"}"
] |
Removes a value from the attribute stack
@param mixed $value Value to be removed
@return boolean True if success
|
[
"Removes",
"a",
"value",
"from",
"the",
"attribute",
"stack"
] |
0759f17996fbb434ee5155dc527b95d8059c6d41
|
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Core/NodeAttribute.php#L143-L154
|
225,860
|
okvpn/datadog-symfony
|
src/Services/ExceptionHashService.php
|
ExceptionHashService.hash
|
public function hash(\Throwable $exception): string
{
$hash = '';
$trace = $exception->getTrace();
$trace[] = [
'file' => $exception->getFile(),
'line' => $exception->getLine()
];
foreach ($trace as $place) {
if (isset($place['file'], $place['line']) && $place['file'] && $place['line'] > 0 && strpos($place['file'], $this->cacheDirPrefix) === false) {
$hash .= $place['file'] . ':' . $place['line'] . "\n";
}
}
$hash = sha1($hash);
return $hash;
}
|
php
|
public function hash(\Throwable $exception): string
{
$hash = '';
$trace = $exception->getTrace();
$trace[] = [
'file' => $exception->getFile(),
'line' => $exception->getLine()
];
foreach ($trace as $place) {
if (isset($place['file'], $place['line']) && $place['file'] && $place['line'] > 0 && strpos($place['file'], $this->cacheDirPrefix) === false) {
$hash .= $place['file'] . ':' . $place['line'] . "\n";
}
}
$hash = sha1($hash);
return $hash;
}
|
[
"public",
"function",
"hash",
"(",
"\\",
"Throwable",
"$",
"exception",
")",
":",
"string",
"{",
"$",
"hash",
"=",
"''",
";",
"$",
"trace",
"=",
"$",
"exception",
"->",
"getTrace",
"(",
")",
";",
"$",
"trace",
"[",
"]",
"=",
"[",
"'file'",
"=>",
"$",
"exception",
"->",
"getFile",
"(",
")",
",",
"'line'",
"=>",
"$",
"exception",
"->",
"getLine",
"(",
")",
"]",
";",
"foreach",
"(",
"$",
"trace",
"as",
"$",
"place",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"place",
"[",
"'file'",
"]",
",",
"$",
"place",
"[",
"'line'",
"]",
")",
"&&",
"$",
"place",
"[",
"'file'",
"]",
"&&",
"$",
"place",
"[",
"'line'",
"]",
">",
"0",
"&&",
"strpos",
"(",
"$",
"place",
"[",
"'file'",
"]",
",",
"$",
"this",
"->",
"cacheDirPrefix",
")",
"===",
"false",
")",
"{",
"$",
"hash",
".=",
"$",
"place",
"[",
"'file'",
"]",
".",
"':'",
".",
"$",
"place",
"[",
"'line'",
"]",
".",
"\"\\n\"",
";",
"}",
"}",
"$",
"hash",
"=",
"sha1",
"(",
"$",
"hash",
")",
";",
"return",
"$",
"hash",
";",
"}"
] |
This function returns a unique identifier for the exception.
This id can be used as a hash key for find duplicate exceptions
@param \Throwable $exception
@return string
|
[
"This",
"function",
"returns",
"a",
"unique",
"identifier",
"for",
"the",
"exception",
".",
"This",
"id",
"can",
"be",
"used",
"as",
"a",
"hash",
"key",
"for",
"find",
"duplicate",
"exceptions"
] |
310eb65b648db692fa877dfb5de6005bf4b9b640
|
https://github.com/okvpn/datadog-symfony/blob/310eb65b648db692fa877dfb5de6005bf4b9b640/src/Services/ExceptionHashService.php#L24-L41
|
225,861
|
garf/laravel-conf
|
src/Drivers/DatabaseDriver.php
|
DatabaseDriver.set
|
public function set($key, $value)
{
array_set($this->config, $key, $value);
$this->persist();
return $this;
}
|
php
|
public function set($key, $value)
{
array_set($this->config, $key, $value);
$this->persist();
return $this;
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"array_set",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"persist",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Store config value by key.
@param string $key
@param mixed $value
@return $this
|
[
"Store",
"config",
"value",
"by",
"key",
"."
] |
bca2622a2563b538f400379fbcf3dbd91601da70
|
https://github.com/garf/laravel-conf/blob/bca2622a2563b538f400379fbcf3dbd91601da70/src/Drivers/DatabaseDriver.php#L43-L49
|
225,862
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail.php
|
Carbon_Breadcrumb_Trail.add_item
|
public function add_item( $item ) {
if ( is_array( $item ) ) {
foreach ( $item as $single_item ) {
$this->add_item( $single_item );
}
} else {
$priority = $item->get_priority();
$this->items[ $priority ][] = $item;
}
}
|
php
|
public function add_item( $item ) {
if ( is_array( $item ) ) {
foreach ( $item as $single_item ) {
$this->add_item( $single_item );
}
} else {
$priority = $item->get_priority();
$this->items[ $priority ][] = $item;
}
}
|
[
"public",
"function",
"add_item",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"foreach",
"(",
"$",
"item",
"as",
"$",
"single_item",
")",
"{",
"$",
"this",
"->",
"add_item",
"(",
"$",
"single_item",
")",
";",
"}",
"}",
"else",
"{",
"$",
"priority",
"=",
"$",
"item",
"->",
"get_priority",
"(",
")",
";",
"$",
"this",
"->",
"items",
"[",
"$",
"priority",
"]",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"}"
] |
Add a single Carbon_Breadcrumb_Item or an array of them to the trail.
@access public
@param mixed $item The item or array of items to add.
|
[
"Add",
"a",
"single",
"Carbon_Breadcrumb_Item",
"or",
"an",
"array",
"of",
"them",
"to",
"the",
"trail",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail.php#L104-L113
|
225,863
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail.php
|
Carbon_Breadcrumb_Trail.add_custom_item
|
public function add_custom_item( $title, $link = '', $priority = 1000 ) {
$custom_item = Carbon_Breadcrumb_Item::factory( 'custom', $priority );
$custom_item->set_title( $title );
$custom_item->set_link( $link );
$custom_item->setup();
$this->add_item( $custom_item );
}
|
php
|
public function add_custom_item( $title, $link = '', $priority = 1000 ) {
$custom_item = Carbon_Breadcrumb_Item::factory( 'custom', $priority );
$custom_item->set_title( $title );
$custom_item->set_link( $link );
$custom_item->setup();
$this->add_item( $custom_item );
}
|
[
"public",
"function",
"add_custom_item",
"(",
"$",
"title",
",",
"$",
"link",
"=",
"''",
",",
"$",
"priority",
"=",
"1000",
")",
"{",
"$",
"custom_item",
"=",
"Carbon_Breadcrumb_Item",
"::",
"factory",
"(",
"'custom'",
",",
"$",
"priority",
")",
";",
"$",
"custom_item",
"->",
"set_title",
"(",
"$",
"title",
")",
";",
"$",
"custom_item",
"->",
"set_link",
"(",
"$",
"link",
")",
";",
"$",
"custom_item",
"->",
"setup",
"(",
")",
";",
"$",
"this",
"->",
"add_item",
"(",
"$",
"custom_item",
")",
";",
"}"
] |
Add a custom breadcrumb item to the trail.
@access public
@param string $title Breadcrumb item title.
@param string $link Breadcrumb item link.
@param int $priority Breadcrumb item priority.
|
[
"Add",
"a",
"custom",
"breadcrumb",
"item",
"to",
"the",
"trail",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail.php#L124-L130
|
225,864
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail.php
|
Carbon_Breadcrumb_Trail.remove_item
|
public function remove_item( $title = '', $link = '' ) {
// If both title and link are specified, search for exact match.
$all_items = $this->get_items();
foreach ( $all_items as $items_priority => $items ) {
foreach ( $items as $item_key => $item ) {
if ( 0 === strcasecmp( $item->get_title(), $title ) && 0 === strcasecmp( $item->get_link(), $link ) ) {
// If we have a match, remove that item.
unset( $all_items[ $items_priority ][ $item_key ] );
}
}
}
// Update the items.
$this->set_items( $all_items );
}
|
php
|
public function remove_item( $title = '', $link = '' ) {
// If both title and link are specified, search for exact match.
$all_items = $this->get_items();
foreach ( $all_items as $items_priority => $items ) {
foreach ( $items as $item_key => $item ) {
if ( 0 === strcasecmp( $item->get_title(), $title ) && 0 === strcasecmp( $item->get_link(), $link ) ) {
// If we have a match, remove that item.
unset( $all_items[ $items_priority ][ $item_key ] );
}
}
}
// Update the items.
$this->set_items( $all_items );
}
|
[
"public",
"function",
"remove_item",
"(",
"$",
"title",
"=",
"''",
",",
"$",
"link",
"=",
"''",
")",
"{",
"// If both title and link are specified, search for exact match.",
"$",
"all_items",
"=",
"$",
"this",
"->",
"get_items",
"(",
")",
";",
"foreach",
"(",
"$",
"all_items",
"as",
"$",
"items_priority",
"=>",
"$",
"items",
")",
"{",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item_key",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"0",
"===",
"strcasecmp",
"(",
"$",
"item",
"->",
"get_title",
"(",
")",
",",
"$",
"title",
")",
"&&",
"0",
"===",
"strcasecmp",
"(",
"$",
"item",
"->",
"get_link",
"(",
")",
",",
"$",
"link",
")",
")",
"{",
"// If we have a match, remove that item.",
"unset",
"(",
"$",
"all_items",
"[",
"$",
"items_priority",
"]",
"[",
"$",
"item_key",
"]",
")",
";",
"}",
"}",
"}",
"// Update the items.",
"$",
"this",
"->",
"set_items",
"(",
"$",
"all_items",
")",
";",
"}"
] |
Remove an item from the breadcrumb trail by both title and link.
@access public
@param string $title Title to remove breadcrumb item by.
@param string $link Link URL to remove breadcrumb item by.
|
[
"Remove",
"an",
"item",
"from",
"the",
"breadcrumb",
"trail",
"by",
"both",
"title",
"and",
"link",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail.php#L140-L154
|
225,865
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail.php
|
Carbon_Breadcrumb_Trail.remove_item_by_method
|
public function remove_item_by_method( $method, $data ) {
// Search all items for one with the same title.
$all_items = $this->get_items();
foreach ( $all_items as $priority => $items ) {
foreach ( $items as $item_key => $item ) {
$method_result = call_user_func( array( $item, $method ), $data );
if ( 0 === strcasecmp( $method_result, $data ) ) {
// If we have a match, remove that item.
unset( $all_items[ $priority ][ $item_key ] );
}
}
}
// Update the items.
$this->set_items( $all_items );
}
|
php
|
public function remove_item_by_method( $method, $data ) {
// Search all items for one with the same title.
$all_items = $this->get_items();
foreach ( $all_items as $priority => $items ) {
foreach ( $items as $item_key => $item ) {
$method_result = call_user_func( array( $item, $method ), $data );
if ( 0 === strcasecmp( $method_result, $data ) ) {
// If we have a match, remove that item.
unset( $all_items[ $priority ][ $item_key ] );
}
}
}
// Update the items.
$this->set_items( $all_items );
}
|
[
"public",
"function",
"remove_item_by_method",
"(",
"$",
"method",
",",
"$",
"data",
")",
"{",
"// Search all items for one with the same title.",
"$",
"all_items",
"=",
"$",
"this",
"->",
"get_items",
"(",
")",
";",
"foreach",
"(",
"$",
"all_items",
"as",
"$",
"priority",
"=>",
"$",
"items",
")",
"{",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item_key",
"=>",
"$",
"item",
")",
"{",
"$",
"method_result",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"item",
",",
"$",
"method",
")",
",",
"$",
"data",
")",
";",
"if",
"(",
"0",
"===",
"strcasecmp",
"(",
"$",
"method_result",
",",
"$",
"data",
")",
")",
"{",
"// If we have a match, remove that item.",
"unset",
"(",
"$",
"all_items",
"[",
"$",
"priority",
"]",
"[",
"$",
"item_key",
"]",
")",
";",
"}",
"}",
"}",
"// Update the items.",
"$",
"this",
"->",
"set_items",
"(",
"$",
"all_items",
")",
";",
"}"
] |
Remove an item from the breadcrumb trail by a specified method.
@access public
@param string $method Item method to remove breadcrumb item by.
@param string $data Additional data to pass to the method.
|
[
"Remove",
"an",
"item",
"from",
"the",
"breadcrumb",
"trail",
"by",
"a",
"specified",
"method",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail.php#L164-L179
|
225,866
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail.php
|
Carbon_Breadcrumb_Trail.remove_item_by_priority
|
public function remove_item_by_priority( $priority = 0 ) {
// Search all items for the same priority.
$all_items = $this->get_items();
if ( array_key_exists( $priority, $all_items ) ) {
// Remove all items with that priority.
unset( $all_items[ $priority ] );
}
// Update the items.
$this->set_items( $all_items );
}
|
php
|
public function remove_item_by_priority( $priority = 0 ) {
// Search all items for the same priority.
$all_items = $this->get_items();
if ( array_key_exists( $priority, $all_items ) ) {
// Remove all items with that priority.
unset( $all_items[ $priority ] );
}
// Update the items.
$this->set_items( $all_items );
}
|
[
"public",
"function",
"remove_item_by_priority",
"(",
"$",
"priority",
"=",
"0",
")",
"{",
"// Search all items for the same priority.",
"$",
"all_items",
"=",
"$",
"this",
"->",
"get_items",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"priority",
",",
"$",
"all_items",
")",
")",
"{",
"// Remove all items with that priority.",
"unset",
"(",
"$",
"all_items",
"[",
"$",
"priority",
"]",
")",
";",
"}",
"// Update the items.",
"$",
"this",
"->",
"set_items",
"(",
"$",
"all_items",
")",
";",
"}"
] |
Remove an item from the breadcrumb trail by its priority.
@access public
@param int $priority Priority to remove breadcrumb item by.
|
[
"Remove",
"an",
"item",
"from",
"the",
"breadcrumb",
"trail",
"by",
"its",
"priority",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail.php#L210-L220
|
225,867
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail.php
|
Carbon_Breadcrumb_Trail.get_flat_items
|
public function get_flat_items() {
$flat_items = array();
foreach ( $this->items as $priority => $items ) {
$flat_items = array_merge( $flat_items, $items );
}
return $flat_items;
}
|
php
|
public function get_flat_items() {
$flat_items = array();
foreach ( $this->items as $priority => $items ) {
$flat_items = array_merge( $flat_items, $items );
}
return $flat_items;
}
|
[
"public",
"function",
"get_flat_items",
"(",
")",
"{",
"$",
"flat_items",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"priority",
"=>",
"$",
"items",
")",
"{",
"$",
"flat_items",
"=",
"array_merge",
"(",
"$",
"flat_items",
",",
"$",
"items",
")",
";",
"}",
"return",
"$",
"flat_items",
";",
"}"
] |
Retrieve the breadcrumb items in a flat list.
@access public
@return array $flat_items The breadcrumb items, contained in the trail.
|
[
"Retrieve",
"the",
"breadcrumb",
"items",
"in",
"a",
"flat",
"list",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail.php#L240-L248
|
225,868
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail.php
|
Carbon_Breadcrumb_Trail.render
|
public function render( $return = false ) {
// Get the rendered output.
$output = $this->get_renderer()->render( $this, true );
if ( $return ) {
return $output;
}
echo wp_kses( $output, wp_kses_allowed_html( 'post' ) );
}
|
php
|
public function render( $return = false ) {
// Get the rendered output.
$output = $this->get_renderer()->render( $this, true );
if ( $return ) {
return $output;
}
echo wp_kses( $output, wp_kses_allowed_html( 'post' ) );
}
|
[
"public",
"function",
"render",
"(",
"$",
"return",
"=",
"false",
")",
"{",
"// Get the rendered output.",
"$",
"output",
"=",
"$",
"this",
"->",
"get_renderer",
"(",
")",
"->",
"render",
"(",
"$",
"this",
",",
"true",
")",
";",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"output",
";",
"}",
"echo",
"wp_kses",
"(",
"$",
"output",
",",
"wp_kses_allowed_html",
"(",
"'post'",
")",
")",
";",
"}"
] |
Render the breadcrumb trail.
@access public
@param bool $return Whether to return the output.
@return string|void $output The output HTML if $return is true.
|
[
"Render",
"the",
"breadcrumb",
"trail",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail.php#L292-L302
|
225,869
|
pyrou/morpheus
|
src/Morpheus/Color.php
|
Color.writeBits
|
function writeBits($value) {
$this->r = ($this->r & 0xFE) + ($value >> 2 & 1);
$this->g = ($this->g & 0xFE) + ($value >> 1 & 1);
$this->b = ($this->b & 0xFE) + ($value >> 0 & 1);
/* // debug colors
$this->r = 0;
$this->g = $value << 5;
$this->b = 0;
$this->a = 1;
/**/
}
|
php
|
function writeBits($value) {
$this->r = ($this->r & 0xFE) + ($value >> 2 & 1);
$this->g = ($this->g & 0xFE) + ($value >> 1 & 1);
$this->b = ($this->b & 0xFE) + ($value >> 0 & 1);
/* // debug colors
$this->r = 0;
$this->g = $value << 5;
$this->b = 0;
$this->a = 1;
/**/
}
|
[
"function",
"writeBits",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"r",
"=",
"(",
"$",
"this",
"->",
"r",
"&",
"0xFE",
")",
"+",
"(",
"$",
"value",
">>",
"2",
"&",
"1",
")",
";",
"$",
"this",
"->",
"g",
"=",
"(",
"$",
"this",
"->",
"g",
"&",
"0xFE",
")",
"+",
"(",
"$",
"value",
">>",
"1",
"&",
"1",
")",
";",
"$",
"this",
"->",
"b",
"=",
"(",
"$",
"this",
"->",
"b",
"&",
"0xFE",
")",
"+",
"(",
"$",
"value",
">>",
"0",
"&",
"1",
")",
";",
"/* // debug colors\n\t\t$this->r = 0;\n\t\t$this->g = $value << 5;\n\t\t$this->b = 0;\n\t\t$this->a = 1;\n\t\t/**/",
"}"
] |
Write a 3-bits-length integer in color
@param integer $value Integer value between 0 (0b000) and 7 (0b111)
|
[
"Write",
"a",
"3",
"-",
"bits",
"-",
"length",
"integer",
"in",
"color"
] |
5dc1686651da5cbc4968fcf999b9ee998cc43b25
|
https://github.com/pyrou/morpheus/blob/5dc1686651da5cbc4968fcf999b9ee998cc43b25/src/Morpheus/Color.php#L29-L39
|
225,870
|
pyrou/morpheus
|
src/Morpheus/Color.php
|
Color.readBits
|
function readBits() {
$value = ($this->r & 1) << 2;
$value += ($this->g & 1) << 1;
$value += ($this->b & 1) << 0;
return $value;
}
|
php
|
function readBits() {
$value = ($this->r & 1) << 2;
$value += ($this->g & 1) << 1;
$value += ($this->b & 1) << 0;
return $value;
}
|
[
"function",
"readBits",
"(",
")",
"{",
"$",
"value",
"=",
"(",
"$",
"this",
"->",
"r",
"&",
"1",
")",
"<<",
"2",
";",
"$",
"value",
"+=",
"(",
"$",
"this",
"->",
"g",
"&",
"1",
")",
"<<",
"1",
";",
"$",
"value",
"+=",
"(",
"$",
"this",
"->",
"b",
"&",
"1",
")",
"<<",
"0",
";",
"return",
"$",
"value",
";",
"}"
] |
Read 3-bits-length integer from color
@return integer Integer value between 0 (0b000) and 7 (0b111)
|
[
"Read",
"3",
"-",
"bits",
"-",
"length",
"integer",
"from",
"color"
] |
5dc1686651da5cbc4968fcf999b9ee998cc43b25
|
https://github.com/pyrou/morpheus/blob/5dc1686651da5cbc4968fcf999b9ee998cc43b25/src/Morpheus/Color.php#L45-L51
|
225,871
|
chronon/CakePHP-MobileDetectComponent-Plugin
|
Controller/Component/MobileDetectComponent.php
|
MobileDetectComponent.detect
|
public function detect($method = 'isMobile', $args = null) {
if (!class_exists('Mobile_Detect')) {
// load the vendor class if it hasn't allready been autoloaded.
$loaded = App::import('Vendor', 'MobileDetect.MobileDetect', array(
'file' => 'MobileDetect' . DS . 'Mobile_Detect.php')
);
// abort if vendor class wasn't autoloaded and can't be found.
if (!$loaded) {
throw new CakeException('Mobile_Detect is missing or could not be loaded.');
}
}
// instantiate once per method call
if (!($this->MobileDetect instanceof Mobile_Detect)) {
$this->MobileDetect = new Mobile_Detect();
}
return $this->MobileDetect->{$method}($args);
}
|
php
|
public function detect($method = 'isMobile', $args = null) {
if (!class_exists('Mobile_Detect')) {
// load the vendor class if it hasn't allready been autoloaded.
$loaded = App::import('Vendor', 'MobileDetect.MobileDetect', array(
'file' => 'MobileDetect' . DS . 'Mobile_Detect.php')
);
// abort if vendor class wasn't autoloaded and can't be found.
if (!$loaded) {
throw new CakeException('Mobile_Detect is missing or could not be loaded.');
}
}
// instantiate once per method call
if (!($this->MobileDetect instanceof Mobile_Detect)) {
$this->MobileDetect = new Mobile_Detect();
}
return $this->MobileDetect->{$method}($args);
}
|
[
"public",
"function",
"detect",
"(",
"$",
"method",
"=",
"'isMobile'",
",",
"$",
"args",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"'Mobile_Detect'",
")",
")",
"{",
"// load the vendor class if it hasn't allready been autoloaded.",
"$",
"loaded",
"=",
"App",
"::",
"import",
"(",
"'Vendor'",
",",
"'MobileDetect.MobileDetect'",
",",
"array",
"(",
"'file'",
"=>",
"'MobileDetect'",
".",
"DS",
".",
"'Mobile_Detect.php'",
")",
")",
";",
"// abort if vendor class wasn't autoloaded and can't be found.",
"if",
"(",
"!",
"$",
"loaded",
")",
"{",
"throw",
"new",
"CakeException",
"(",
"'Mobile_Detect is missing or could not be loaded.'",
")",
";",
"}",
"}",
"// instantiate once per method call",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"MobileDetect",
"instanceof",
"Mobile_Detect",
")",
")",
"{",
"$",
"this",
"->",
"MobileDetect",
"=",
"new",
"Mobile_Detect",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"MobileDetect",
"->",
"{",
"$",
"method",
"}",
"(",
"$",
"args",
")",
";",
"}"
] |
Loads the Mobile_Detect class, runs the given Mobile_Detect method. Uses
'isMobile' if no method given.
@param string $method The method to run
@param string $args Optional arguments to the given method
@return mixed
@throws CakeException
|
[
"Loads",
"the",
"Mobile_Detect",
"class",
"runs",
"the",
"given",
"Mobile_Detect",
"method",
".",
"Uses",
"isMobile",
"if",
"no",
"method",
"given",
"."
] |
01be8fbdac64136dd9bc1aa6cf70e361acc238e8
|
https://github.com/chronon/CakePHP-MobileDetectComponent-Plugin/blob/01be8fbdac64136dd9bc1aa6cf70e361acc238e8/Controller/Component/MobileDetectComponent.php#L50-L67
|
225,872
|
puli/cli
|
src/Handler/TypeCommandHandler.php
|
TypeCommandHandler.getBindingTypeStates
|
private function getBindingTypeStates(Args $args)
{
$states = array();
if ($args->isOptionSet('enabled')) {
$states[] = BindingTypeState::ENABLED;
}
if ($args->isOptionSet('duplicate')) {
$states[] = BindingTypeState::DUPLICATE;
}
return $states ?: BindingTypeState::all();
}
|
php
|
private function getBindingTypeStates(Args $args)
{
$states = array();
if ($args->isOptionSet('enabled')) {
$states[] = BindingTypeState::ENABLED;
}
if ($args->isOptionSet('duplicate')) {
$states[] = BindingTypeState::DUPLICATE;
}
return $states ?: BindingTypeState::all();
}
|
[
"private",
"function",
"getBindingTypeStates",
"(",
"Args",
"$",
"args",
")",
"{",
"$",
"states",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"args",
"->",
"isOptionSet",
"(",
"'enabled'",
")",
")",
"{",
"$",
"states",
"[",
"]",
"=",
"BindingTypeState",
"::",
"ENABLED",
";",
"}",
"if",
"(",
"$",
"args",
"->",
"isOptionSet",
"(",
"'duplicate'",
")",
")",
"{",
"$",
"states",
"[",
"]",
"=",
"BindingTypeState",
"::",
"DUPLICATE",
";",
"}",
"return",
"$",
"states",
"?",
":",
"BindingTypeState",
"::",
"all",
"(",
")",
";",
"}"
] |
Returns the binding type states selected in the console arguments.
@param Args $args The console arguments
@return int[] A list of {@link BindingTypeState} constants
|
[
"Returns",
"the",
"binding",
"type",
"states",
"selected",
"in",
"the",
"console",
"arguments",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/TypeCommandHandler.php#L224-L237
|
225,873
|
puli/cli
|
src/Handler/TypeCommandHandler.php
|
TypeCommandHandler.printTypeTable
|
private function printTypeTable(IO $io, array $descriptors, $styleTag = null, $indentation = 0)
{
$table = new Table(PuliTableStyle::borderless());
$table->setHeaderRow(array('Type', 'Description', 'Parameters'));
$paramTag = $styleTag ?: 'c1';
$typeTag = $styleTag ?: 'u';
foreach ($descriptors as $descriptor) {
$type = $descriptor->getType();
$parameters = array();
foreach ($type->getParameters() as $parameter) {
$paramString = $parameter->isRequired()
? $parameter->getName()
: $parameter->getName().'='.StringUtil::formatValue($parameter->getDefaultValue());
$parameters[$parameter->getName()] = "<$paramTag>$paramString</$paramTag>";
}
$description = $descriptor->getDescription();
if ($styleTag) {
$description = "<$styleTag>$description</$styleTag>";
}
ksort($parameters);
$table->addRow(array(
"<$typeTag>".$descriptor->getTypeName()."</$typeTag>",
$description,
implode("\n", $parameters),
));
}
$table->render($io, $indentation);
}
|
php
|
private function printTypeTable(IO $io, array $descriptors, $styleTag = null, $indentation = 0)
{
$table = new Table(PuliTableStyle::borderless());
$table->setHeaderRow(array('Type', 'Description', 'Parameters'));
$paramTag = $styleTag ?: 'c1';
$typeTag = $styleTag ?: 'u';
foreach ($descriptors as $descriptor) {
$type = $descriptor->getType();
$parameters = array();
foreach ($type->getParameters() as $parameter) {
$paramString = $parameter->isRequired()
? $parameter->getName()
: $parameter->getName().'='.StringUtil::formatValue($parameter->getDefaultValue());
$parameters[$parameter->getName()] = "<$paramTag>$paramString</$paramTag>";
}
$description = $descriptor->getDescription();
if ($styleTag) {
$description = "<$styleTag>$description</$styleTag>";
}
ksort($parameters);
$table->addRow(array(
"<$typeTag>".$descriptor->getTypeName()."</$typeTag>",
$description,
implode("\n", $parameters),
));
}
$table->render($io, $indentation);
}
|
[
"private",
"function",
"printTypeTable",
"(",
"IO",
"$",
"io",
",",
"array",
"$",
"descriptors",
",",
"$",
"styleTag",
"=",
"null",
",",
"$",
"indentation",
"=",
"0",
")",
"{",
"$",
"table",
"=",
"new",
"Table",
"(",
"PuliTableStyle",
"::",
"borderless",
"(",
")",
")",
";",
"$",
"table",
"->",
"setHeaderRow",
"(",
"array",
"(",
"'Type'",
",",
"'Description'",
",",
"'Parameters'",
")",
")",
";",
"$",
"paramTag",
"=",
"$",
"styleTag",
"?",
":",
"'c1'",
";",
"$",
"typeTag",
"=",
"$",
"styleTag",
"?",
":",
"'u'",
";",
"foreach",
"(",
"$",
"descriptors",
"as",
"$",
"descriptor",
")",
"{",
"$",
"type",
"=",
"$",
"descriptor",
"->",
"getType",
"(",
")",
";",
"$",
"parameters",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"type",
"->",
"getParameters",
"(",
")",
"as",
"$",
"parameter",
")",
"{",
"$",
"paramString",
"=",
"$",
"parameter",
"->",
"isRequired",
"(",
")",
"?",
"$",
"parameter",
"->",
"getName",
"(",
")",
":",
"$",
"parameter",
"->",
"getName",
"(",
")",
".",
"'='",
".",
"StringUtil",
"::",
"formatValue",
"(",
"$",
"parameter",
"->",
"getDefaultValue",
"(",
")",
")",
";",
"$",
"parameters",
"[",
"$",
"parameter",
"->",
"getName",
"(",
")",
"]",
"=",
"\"<$paramTag>$paramString</$paramTag>\"",
";",
"}",
"$",
"description",
"=",
"$",
"descriptor",
"->",
"getDescription",
"(",
")",
";",
"if",
"(",
"$",
"styleTag",
")",
"{",
"$",
"description",
"=",
"\"<$styleTag>$description</$styleTag>\"",
";",
"}",
"ksort",
"(",
"$",
"parameters",
")",
";",
"$",
"table",
"->",
"addRow",
"(",
"array",
"(",
"\"<$typeTag>\"",
".",
"$",
"descriptor",
"->",
"getTypeName",
"(",
")",
".",
"\"</$typeTag>\"",
",",
"$",
"description",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"parameters",
")",
",",
")",
")",
";",
"}",
"$",
"table",
"->",
"render",
"(",
"$",
"io",
",",
"$",
"indentation",
")",
";",
"}"
] |
Prints the binding types in a table.
@param IO $io The I/O
@param BindingTypeDescriptor[] $descriptors The type descriptors to print
@param string $styleTag The tag used to style the output
@param int $indentation The number of spaces to indent
|
[
"Prints",
"the",
"binding",
"types",
"in",
"a",
"table",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/TypeCommandHandler.php#L247-L284
|
225,874
|
puli/cli
|
src/Handler/TypeCommandHandler.php
|
TypeCommandHandler.printBindingTypeState
|
private function printBindingTypeState(IO $io, $typeState)
{
switch ($typeState) {
case BindingTypeState::ENABLED:
$io->writeLine('The following binding types are currently enabled:');
$io->writeLine('');
return;
case BindingTypeState::DUPLICATE:
$io->writeLine('The following types have duplicate definitions and are disabled:');
$io->writeLine('');
return;
}
}
|
php
|
private function printBindingTypeState(IO $io, $typeState)
{
switch ($typeState) {
case BindingTypeState::ENABLED:
$io->writeLine('The following binding types are currently enabled:');
$io->writeLine('');
return;
case BindingTypeState::DUPLICATE:
$io->writeLine('The following types have duplicate definitions and are disabled:');
$io->writeLine('');
return;
}
}
|
[
"private",
"function",
"printBindingTypeState",
"(",
"IO",
"$",
"io",
",",
"$",
"typeState",
")",
"{",
"switch",
"(",
"$",
"typeState",
")",
"{",
"case",
"BindingTypeState",
"::",
"ENABLED",
":",
"$",
"io",
"->",
"writeLine",
"(",
"'The following binding types are currently enabled:'",
")",
";",
"$",
"io",
"->",
"writeLine",
"(",
"''",
")",
";",
"return",
";",
"case",
"BindingTypeState",
"::",
"DUPLICATE",
":",
"$",
"io",
"->",
"writeLine",
"(",
"'The following types have duplicate definitions and are disabled:'",
")",
";",
"$",
"io",
"->",
"writeLine",
"(",
"''",
")",
";",
"return",
";",
"}",
"}"
] |
Prints the heading for a binding type state.
@param IO $io The I/O
@param int $typeState The {@link BindingTypeState} constant
|
[
"Prints",
"the",
"heading",
"for",
"a",
"binding",
"type",
"state",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/TypeCommandHandler.php#L292-L306
|
225,875
|
puli/cli
|
src/Handler/SelfUpdateCommandHandler.php
|
SelfUpdateCommandHandler.handle
|
public function handle(Args $args, IO $io)
{
$updateStrategy = new PuliStrategy();
$updateStrategy->setStability($this->getStability($args));
// false: disable signed releases, otherwise the updater will look for
// a *.pubkey file for the PHAR
$updater = new Updater(null, false);
$updater->setStrategyObject($updateStrategy);
if ($updater->update()) {
$io->writeLine(sprintf(
'Updated from version %s to version %s.',
$updater->getOldVersion(),
$updater->getNewVersion()
));
return 0;
}
$io->writeLine(sprintf(
'Version %s is the latest version. No update required.',
$updater->getOldVersion()
));
return 0;
}
|
php
|
public function handle(Args $args, IO $io)
{
$updateStrategy = new PuliStrategy();
$updateStrategy->setStability($this->getStability($args));
// false: disable signed releases, otherwise the updater will look for
// a *.pubkey file for the PHAR
$updater = new Updater(null, false);
$updater->setStrategyObject($updateStrategy);
if ($updater->update()) {
$io->writeLine(sprintf(
'Updated from version %s to version %s.',
$updater->getOldVersion(),
$updater->getNewVersion()
));
return 0;
}
$io->writeLine(sprintf(
'Version %s is the latest version. No update required.',
$updater->getOldVersion()
));
return 0;
}
|
[
"public",
"function",
"handle",
"(",
"Args",
"$",
"args",
",",
"IO",
"$",
"io",
")",
"{",
"$",
"updateStrategy",
"=",
"new",
"PuliStrategy",
"(",
")",
";",
"$",
"updateStrategy",
"->",
"setStability",
"(",
"$",
"this",
"->",
"getStability",
"(",
"$",
"args",
")",
")",
";",
"// false: disable signed releases, otherwise the updater will look for",
"// a *.pubkey file for the PHAR",
"$",
"updater",
"=",
"new",
"Updater",
"(",
"null",
",",
"false",
")",
";",
"$",
"updater",
"->",
"setStrategyObject",
"(",
"$",
"updateStrategy",
")",
";",
"if",
"(",
"$",
"updater",
"->",
"update",
"(",
")",
")",
"{",
"$",
"io",
"->",
"writeLine",
"(",
"sprintf",
"(",
"'Updated from version %s to version %s.'",
",",
"$",
"updater",
"->",
"getOldVersion",
"(",
")",
",",
"$",
"updater",
"->",
"getNewVersion",
"(",
")",
")",
")",
";",
"return",
"0",
";",
"}",
"$",
"io",
"->",
"writeLine",
"(",
"sprintf",
"(",
"'Version %s is the latest version. No update required.'",
",",
"$",
"updater",
"->",
"getOldVersion",
"(",
")",
")",
")",
";",
"return",
"0",
";",
"}"
] |
Handles the "self-update" command.
@param Args $args The console arguments.
@param IO $io The I/O.
@return int The status code.
|
[
"Handles",
"the",
"self",
"-",
"update",
"command",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/SelfUpdateCommandHandler.php#L37-L63
|
225,876
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-locator-date.php
|
Carbon_Breadcrumb_Locator_Date.get_archive_item_details
|
public function get_archive_item_details() {
return array(
'year' => array(
'condition' => is_year() || is_month() || is_day(),
'title_format' => 'Y',
'link' => get_year_link( get_query_var( 'year' ) ),
),
'month' => array(
'condition' => is_month() || is_day(),
'title_format' => 'F',
'link' => get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) ),
),
'day' => array(
'condition' => is_day(),
'title_format' => 'd',
'link' => get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) ),
),
);
}
|
php
|
public function get_archive_item_details() {
return array(
'year' => array(
'condition' => is_year() || is_month() || is_day(),
'title_format' => 'Y',
'link' => get_year_link( get_query_var( 'year' ) ),
),
'month' => array(
'condition' => is_month() || is_day(),
'title_format' => 'F',
'link' => get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) ),
),
'day' => array(
'condition' => is_day(),
'title_format' => 'd',
'link' => get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) ),
),
);
}
|
[
"public",
"function",
"get_archive_item_details",
"(",
")",
"{",
"return",
"array",
"(",
"'year'",
"=>",
"array",
"(",
"'condition'",
"=>",
"is_year",
"(",
")",
"||",
"is_month",
"(",
")",
"||",
"is_day",
"(",
")",
",",
"'title_format'",
"=>",
"'Y'",
",",
"'link'",
"=>",
"get_year_link",
"(",
"get_query_var",
"(",
"'year'",
")",
")",
",",
")",
",",
"'month'",
"=>",
"array",
"(",
"'condition'",
"=>",
"is_month",
"(",
")",
"||",
"is_day",
"(",
")",
",",
"'title_format'",
"=>",
"'F'",
",",
"'link'",
"=>",
"get_month_link",
"(",
"get_query_var",
"(",
"'year'",
")",
",",
"get_query_var",
"(",
"'monthnum'",
")",
")",
",",
")",
",",
"'day'",
"=>",
"array",
"(",
"'condition'",
"=>",
"is_day",
"(",
")",
",",
"'title_format'",
"=>",
"'d'",
",",
"'link'",
"=>",
"get_day_link",
"(",
"get_query_var",
"(",
"'year'",
")",
",",
"get_query_var",
"(",
"'monthnum'",
")",
",",
"get_query_var",
"(",
"'day'",
")",
")",
",",
")",
",",
")",
";",
"}"
] |
Prepare the date archive conditions, with the corresponding title format and link.
@access public
@return array $details Date archive details.
|
[
"Prepare",
"the",
"date",
"archive",
"conditions",
"with",
"the",
"corresponding",
"title",
"format",
"and",
"link",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-locator-date.php#L62-L80
|
225,877
|
oscarotero/inline-svg
|
src/Collection.php
|
Collection.transform
|
protected function transform(DOMDocument $element)
{
foreach ($this->transformers as $transformer) {
$transformer($element);
}
return $element;
}
|
php
|
protected function transform(DOMDocument $element)
{
foreach ($this->transformers as $transformer) {
$transformer($element);
}
return $element;
}
|
[
"protected",
"function",
"transform",
"(",
"DOMDocument",
"$",
"element",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"transformers",
"as",
"$",
"transformer",
")",
"{",
"$",
"transformer",
"(",
"$",
"element",
")",
";",
"}",
"return",
"$",
"element",
";",
"}"
] |
Transform an element
@param DOMDocument $element
@return DOMDocument
|
[
"Transform",
"an",
"element"
] |
9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2
|
https://github.com/oscarotero/inline-svg/blob/9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2/src/Collection.php#L70-L77
|
225,878
|
oscarotero/inline-svg
|
src/Collection.php
|
Collection.load
|
protected function load($name)
{
foreach ($this->sources as $source) {
if ($source->has($name)) {
return $this->transform($source->get($name));
}
}
throw new NotFoundException(sprintf('The svg "%s" is not found', $name));
}
|
php
|
protected function load($name)
{
foreach ($this->sources as $source) {
if ($source->has($name)) {
return $this->transform($source->get($name));
}
}
throw new NotFoundException(sprintf('The svg "%s" is not found', $name));
}
|
[
"protected",
"function",
"load",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"sources",
"as",
"$",
"source",
")",
"{",
"if",
"(",
"$",
"source",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"transform",
"(",
"$",
"source",
"->",
"get",
"(",
"$",
"name",
")",
")",
";",
"}",
"}",
"throw",
"new",
"NotFoundException",
"(",
"sprintf",
"(",
"'The svg \"%s\" is not found'",
",",
"$",
"name",
")",
")",
";",
"}"
] |
Load a svg from the sources.
@param string $name The svg name
@throws NotFoundException
@return DOMDocument
|
[
"Load",
"a",
"svg",
"from",
"the",
"sources",
"."
] |
9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2
|
https://github.com/oscarotero/inline-svg/blob/9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2/src/Collection.php#L88-L97
|
225,879
|
oscarotero/inline-svg
|
src/Collection.php
|
Collection.get
|
public function get($name)
{
if (!isset($this->svg[$name])) {
$this->svg[$name] = new Svg($this->load($name));
}
if ($this->svg[$name] !== false) {
return $this->svg[$name];
}
}
|
php
|
public function get($name)
{
if (!isset($this->svg[$name])) {
$this->svg[$name] = new Svg($this->load($name));
}
if ($this->svg[$name] !== false) {
return $this->svg[$name];
}
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"svg",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"svg",
"[",
"$",
"name",
"]",
"=",
"new",
"Svg",
"(",
"$",
"this",
"->",
"load",
"(",
"$",
"name",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"svg",
"[",
"$",
"name",
"]",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"svg",
"[",
"$",
"name",
"]",
";",
"}",
"}"
] |
Returns a clone of a svg.
@param string $name The svg name
@return Svg|null
|
[
"Returns",
"a",
"clone",
"of",
"a",
"svg",
"."
] |
9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2
|
https://github.com/oscarotero/inline-svg/blob/9c2c38166d03bb79a0ae6e1e221ff67efb46e6d2/src/Collection.php#L106-L115
|
225,880
|
xmeltrut/WordSearch
|
src/WordList.php
|
WordList.add
|
public function add($word, $row, $column)
{
$this->words[] = new Word($word, $row, $column);
}
|
php
|
public function add($word, $row, $column)
{
$this->words[] = new Word($word, $row, $column);
}
|
[
"public",
"function",
"add",
"(",
"$",
"word",
",",
"$",
"row",
",",
"$",
"column",
")",
"{",
"$",
"this",
"->",
"words",
"[",
"]",
"=",
"new",
"Word",
"(",
"$",
"word",
",",
"$",
"row",
",",
"$",
"column",
")",
";",
"}"
] |
Add a word.
@param string $word Word.
@param integer $row Row.
@param integer $column Column.
@return void
|
[
"Add",
"a",
"word",
"."
] |
a6dd7c96b78045a3d172e3c5b97e9909b32a9fba
|
https://github.com/xmeltrut/WordSearch/blob/a6dd7c96b78045a3d172e3c5b97e9909b32a9fba/src/WordList.php#L28-L31
|
225,881
|
ccottet/ldap
|
Platform/Native/Entry.php
|
Entry.getAttributes
|
public function getAttributes()
{
$data = @ldap_get_attributes($this->connection, $this->entry);
$result = array();
for ($i = 0; $i < $data['count']; $i++) {
$key = $data[$i];
$result[$key] = array();
for ($j = 0; $j < $data[$key]['count']; $j++) {
$result[$key][] = $data[$key][$j];
}
}
return $result;
}
|
php
|
public function getAttributes()
{
$data = @ldap_get_attributes($this->connection, $this->entry);
$result = array();
for ($i = 0; $i < $data['count']; $i++) {
$key = $data[$i];
$result[$key] = array();
for ($j = 0; $j < $data[$key]['count']; $j++) {
$result[$key][] = $data[$key][$j];
}
}
return $result;
}
|
[
"public",
"function",
"getAttributes",
"(",
")",
"{",
"$",
"data",
"=",
"@",
"ldap_get_attributes",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"this",
"->",
"entry",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"data",
"[",
"'count'",
"]",
";",
"$",
"i",
"++",
")",
"{",
"$",
"key",
"=",
"$",
"data",
"[",
"$",
"i",
"]",
";",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"$",
"data",
"[",
"$",
"key",
"]",
"[",
"'count'",
"]",
";",
"$",
"j",
"++",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"$",
"data",
"[",
"$",
"key",
"]",
"[",
"$",
"j",
"]",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Retrieves entry attributes
@return array(attribute => array(values))
|
[
"Retrieves",
"entry",
"attributes"
] |
0759f17996fbb434ee5155dc527b95d8059c6d41
|
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Platform/Native/Entry.php#L57-L72
|
225,882
|
ccottet/ldap
|
Platform/Native/Driver.php
|
Driver.connect
|
public function connect(
$hostname,
$port = 389,
$withSSL = false,
$withTLS = false
) {
if ($withSSL && $withTLS) {
throw new ConnectionException('Cannot support both TLS & SSL for a given Ldap Connection');
}
if (! extension_loaded('ldap') && ! @dl('ldap.' . PHP_SHLIB_SUFFIX)) {
throw new ConnectionException(
'You do not have the required ldap-extension installed'
);
}
if ($withSSL) {
$hostname = 'ldaps://' . $hostname;
}
$connection = @ldap_connect($hostname, $port);
if (false === $connection) {
throw new ConnectionException('Could not successfully connect to the LDAP server');
}
if ($withTLS) {
if (! (@ldap_start_tls($connection))) {
$code = @ldap_errno($connection);
throw new ConnectionException(
sprintf('Could not start TLS: Ldap Error Code=%s - %s', $code, ldap_err2str($code))
);
}
}
return new Connection($connection);
}
|
php
|
public function connect(
$hostname,
$port = 389,
$withSSL = false,
$withTLS = false
) {
if ($withSSL && $withTLS) {
throw new ConnectionException('Cannot support both TLS & SSL for a given Ldap Connection');
}
if (! extension_loaded('ldap') && ! @dl('ldap.' . PHP_SHLIB_SUFFIX)) {
throw new ConnectionException(
'You do not have the required ldap-extension installed'
);
}
if ($withSSL) {
$hostname = 'ldaps://' . $hostname;
}
$connection = @ldap_connect($hostname, $port);
if (false === $connection) {
throw new ConnectionException('Could not successfully connect to the LDAP server');
}
if ($withTLS) {
if (! (@ldap_start_tls($connection))) {
$code = @ldap_errno($connection);
throw new ConnectionException(
sprintf('Could not start TLS: Ldap Error Code=%s - %s', $code, ldap_err2str($code))
);
}
}
return new Connection($connection);
}
|
[
"public",
"function",
"connect",
"(",
"$",
"hostname",
",",
"$",
"port",
"=",
"389",
",",
"$",
"withSSL",
"=",
"false",
",",
"$",
"withTLS",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"withSSL",
"&&",
"$",
"withTLS",
")",
"{",
"throw",
"new",
"ConnectionException",
"(",
"'Cannot support both TLS & SSL for a given Ldap Connection'",
")",
";",
"}",
"if",
"(",
"!",
"extension_loaded",
"(",
"'ldap'",
")",
"&&",
"!",
"@",
"dl",
"(",
"'ldap.'",
".",
"PHP_SHLIB_SUFFIX",
")",
")",
"{",
"throw",
"new",
"ConnectionException",
"(",
"'You do not have the required ldap-extension installed'",
")",
";",
"}",
"if",
"(",
"$",
"withSSL",
")",
"{",
"$",
"hostname",
"=",
"'ldaps://'",
".",
"$",
"hostname",
";",
"}",
"$",
"connection",
"=",
"@",
"ldap_connect",
"(",
"$",
"hostname",
",",
"$",
"port",
")",
";",
"if",
"(",
"false",
"===",
"$",
"connection",
")",
"{",
"throw",
"new",
"ConnectionException",
"(",
"'Could not successfully connect to the LDAP server'",
")",
";",
"}",
"if",
"(",
"$",
"withTLS",
")",
"{",
"if",
"(",
"!",
"(",
"@",
"ldap_start_tls",
"(",
"$",
"connection",
")",
")",
")",
"{",
"$",
"code",
"=",
"@",
"ldap_errno",
"(",
"$",
"connection",
")",
";",
"throw",
"new",
"ConnectionException",
"(",
"sprintf",
"(",
"'Could not start TLS: Ldap Error Code=%s - %s'",
",",
"$",
"code",
",",
"ldap_err2str",
"(",
"$",
"code",
")",
")",
")",
";",
"}",
"}",
"return",
"new",
"Connection",
"(",
"$",
"connection",
")",
";",
"}"
] |
Connects to a Ldap directory without binding
@param string $hostname Hostname to connect to
@param int $port Port to connect to (Default: 389)
@param boolean $withSSL Whether to connect with SSL support (Default: false)
@param boolean $withTLS Whether to connect with TLS support (Default: false)
@return ConnectionInterface connection instance
@throws ConnectionException if connection fails
|
[
"Connects",
"to",
"a",
"Ldap",
"directory",
"without",
"binding"
] |
0759f17996fbb434ee5155dc527b95d8059c6d41
|
https://github.com/ccottet/ldap/blob/0759f17996fbb434ee5155dc527b95d8059c6d41/Platform/Native/Driver.php#L36-L71
|
225,883
|
puli/cli
|
src/Handler/ModuleCommandHandler.php
|
ModuleCommandHandler.getSelectedStates
|
private function getSelectedStates(Args $args)
{
$states = array();
if ($args->isOptionSet('enabled')) {
$states[] = ModuleState::ENABLED;
}
if ($args->isOptionSet('not-found')) {
$states[] = ModuleState::NOT_FOUND;
}
if ($args->isOptionSet('not-loadable')) {
$states[] = ModuleState::NOT_LOADABLE;
}
return $states ?: ModuleState::all();
}
|
php
|
private function getSelectedStates(Args $args)
{
$states = array();
if ($args->isOptionSet('enabled')) {
$states[] = ModuleState::ENABLED;
}
if ($args->isOptionSet('not-found')) {
$states[] = ModuleState::NOT_FOUND;
}
if ($args->isOptionSet('not-loadable')) {
$states[] = ModuleState::NOT_LOADABLE;
}
return $states ?: ModuleState::all();
}
|
[
"private",
"function",
"getSelectedStates",
"(",
"Args",
"$",
"args",
")",
"{",
"$",
"states",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"args",
"->",
"isOptionSet",
"(",
"'enabled'",
")",
")",
"{",
"$",
"states",
"[",
"]",
"=",
"ModuleState",
"::",
"ENABLED",
";",
"}",
"if",
"(",
"$",
"args",
"->",
"isOptionSet",
"(",
"'not-found'",
")",
")",
"{",
"$",
"states",
"[",
"]",
"=",
"ModuleState",
"::",
"NOT_FOUND",
";",
"}",
"if",
"(",
"$",
"args",
"->",
"isOptionSet",
"(",
"'not-loadable'",
")",
")",
"{",
"$",
"states",
"[",
"]",
"=",
"ModuleState",
"::",
"NOT_LOADABLE",
";",
"}",
"return",
"$",
"states",
"?",
":",
"ModuleState",
"::",
"all",
"(",
")",
";",
"}"
] |
Returns the module states that should be displayed for the given
console arguments.
@param Args $args The console arguments
@return int[] A list of {@link ModuleState} constants
|
[
"Returns",
"the",
"module",
"states",
"that",
"should",
"be",
"displayed",
"for",
"the",
"given",
"console",
"arguments",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/ModuleCommandHandler.php#L169-L186
|
225,884
|
puli/cli
|
src/Handler/ModuleCommandHandler.php
|
ModuleCommandHandler.getSelectedModules
|
private function getSelectedModules(Args $args)
{
$states = $this->getSelectedStates($args);
$expr = Expr::true();
$envs = array();
if ($states !== ModuleState::all()) {
$expr = $expr->andMethod('getState', Expr::in($states));
}
if ($args->isOptionSet('installer')) {
$expr = $expr->andMethod('getInstallInfo', Expr::method('getInstallerName', Expr::same($args->getOption('installer'))));
}
if ($args->isOptionSet('prod')) {
$envs[] = Environment::PROD;
}
if ($args->isOptionSet('dev')) {
$envs[] = Environment::DEV;
}
if (count($envs) > 0) {
$expr = $expr->andMethod('getInstallInfo', Expr::method('getEnvironment', Expr::in($envs)));
}
return $this->moduleManager->findModules($expr);
}
|
php
|
private function getSelectedModules(Args $args)
{
$states = $this->getSelectedStates($args);
$expr = Expr::true();
$envs = array();
if ($states !== ModuleState::all()) {
$expr = $expr->andMethod('getState', Expr::in($states));
}
if ($args->isOptionSet('installer')) {
$expr = $expr->andMethod('getInstallInfo', Expr::method('getInstallerName', Expr::same($args->getOption('installer'))));
}
if ($args->isOptionSet('prod')) {
$envs[] = Environment::PROD;
}
if ($args->isOptionSet('dev')) {
$envs[] = Environment::DEV;
}
if (count($envs) > 0) {
$expr = $expr->andMethod('getInstallInfo', Expr::method('getEnvironment', Expr::in($envs)));
}
return $this->moduleManager->findModules($expr);
}
|
[
"private",
"function",
"getSelectedModules",
"(",
"Args",
"$",
"args",
")",
"{",
"$",
"states",
"=",
"$",
"this",
"->",
"getSelectedStates",
"(",
"$",
"args",
")",
";",
"$",
"expr",
"=",
"Expr",
"::",
"true",
"(",
")",
";",
"$",
"envs",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"states",
"!==",
"ModuleState",
"::",
"all",
"(",
")",
")",
"{",
"$",
"expr",
"=",
"$",
"expr",
"->",
"andMethod",
"(",
"'getState'",
",",
"Expr",
"::",
"in",
"(",
"$",
"states",
")",
")",
";",
"}",
"if",
"(",
"$",
"args",
"->",
"isOptionSet",
"(",
"'installer'",
")",
")",
"{",
"$",
"expr",
"=",
"$",
"expr",
"->",
"andMethod",
"(",
"'getInstallInfo'",
",",
"Expr",
"::",
"method",
"(",
"'getInstallerName'",
",",
"Expr",
"::",
"same",
"(",
"$",
"args",
"->",
"getOption",
"(",
"'installer'",
")",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"args",
"->",
"isOptionSet",
"(",
"'prod'",
")",
")",
"{",
"$",
"envs",
"[",
"]",
"=",
"Environment",
"::",
"PROD",
";",
"}",
"if",
"(",
"$",
"args",
"->",
"isOptionSet",
"(",
"'dev'",
")",
")",
"{",
"$",
"envs",
"[",
"]",
"=",
"Environment",
"::",
"DEV",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"envs",
")",
">",
"0",
")",
"{",
"$",
"expr",
"=",
"$",
"expr",
"->",
"andMethod",
"(",
"'getInstallInfo'",
",",
"Expr",
"::",
"method",
"(",
"'getEnvironment'",
",",
"Expr",
"::",
"in",
"(",
"$",
"envs",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"moduleManager",
"->",
"findModules",
"(",
"$",
"expr",
")",
";",
"}"
] |
Returns the modules that should be displayed for the given console
arguments.
@param Args $args The console arguments
@return ModuleList The modules
|
[
"Returns",
"the",
"modules",
"that",
"should",
"be",
"displayed",
"for",
"the",
"given",
"console",
"arguments",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/ModuleCommandHandler.php#L196-L223
|
225,885
|
puli/cli
|
src/Handler/ModuleCommandHandler.php
|
ModuleCommandHandler.printModulesByState
|
private function printModulesByState(IO $io, ModuleList $modules, array $states)
{
$printStates = count($states) > 1;
foreach ($states as $state) {
$filteredModules = array_filter($modules->toArray(), function (Module $module) use ($state) {
return $state === $module->getState();
});
if (0 === count($filteredModules)) {
continue;
}
if ($printStates) {
$this->printModuleState($io, $state);
}
if (ModuleState::NOT_LOADABLE === $state) {
$this->printNotLoadableModules($io, $filteredModules, $printStates);
} else {
$styleTag = ModuleState::ENABLED === $state ? null : 'bad';
$this->printModuleTable($io, $filteredModules, $styleTag, $printStates);
}
if ($printStates) {
$io->writeLine('');
}
}
}
|
php
|
private function printModulesByState(IO $io, ModuleList $modules, array $states)
{
$printStates = count($states) > 1;
foreach ($states as $state) {
$filteredModules = array_filter($modules->toArray(), function (Module $module) use ($state) {
return $state === $module->getState();
});
if (0 === count($filteredModules)) {
continue;
}
if ($printStates) {
$this->printModuleState($io, $state);
}
if (ModuleState::NOT_LOADABLE === $state) {
$this->printNotLoadableModules($io, $filteredModules, $printStates);
} else {
$styleTag = ModuleState::ENABLED === $state ? null : 'bad';
$this->printModuleTable($io, $filteredModules, $styleTag, $printStates);
}
if ($printStates) {
$io->writeLine('');
}
}
}
|
[
"private",
"function",
"printModulesByState",
"(",
"IO",
"$",
"io",
",",
"ModuleList",
"$",
"modules",
",",
"array",
"$",
"states",
")",
"{",
"$",
"printStates",
"=",
"count",
"(",
"$",
"states",
")",
">",
"1",
";",
"foreach",
"(",
"$",
"states",
"as",
"$",
"state",
")",
"{",
"$",
"filteredModules",
"=",
"array_filter",
"(",
"$",
"modules",
"->",
"toArray",
"(",
")",
",",
"function",
"(",
"Module",
"$",
"module",
")",
"use",
"(",
"$",
"state",
")",
"{",
"return",
"$",
"state",
"===",
"$",
"module",
"->",
"getState",
"(",
")",
";",
"}",
")",
";",
"if",
"(",
"0",
"===",
"count",
"(",
"$",
"filteredModules",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"printStates",
")",
"{",
"$",
"this",
"->",
"printModuleState",
"(",
"$",
"io",
",",
"$",
"state",
")",
";",
"}",
"if",
"(",
"ModuleState",
"::",
"NOT_LOADABLE",
"===",
"$",
"state",
")",
"{",
"$",
"this",
"->",
"printNotLoadableModules",
"(",
"$",
"io",
",",
"$",
"filteredModules",
",",
"$",
"printStates",
")",
";",
"}",
"else",
"{",
"$",
"styleTag",
"=",
"ModuleState",
"::",
"ENABLED",
"===",
"$",
"state",
"?",
"null",
":",
"'bad'",
";",
"$",
"this",
"->",
"printModuleTable",
"(",
"$",
"io",
",",
"$",
"filteredModules",
",",
"$",
"styleTag",
",",
"$",
"printStates",
")",
";",
"}",
"if",
"(",
"$",
"printStates",
")",
"{",
"$",
"io",
"->",
"writeLine",
"(",
"''",
")",
";",
"}",
"}",
"}"
] |
Prints modules with intermediate headers for the module states.
@param IO $io The I/O
@param ModuleList $modules The modules to print
@param int[] $states The states to print
|
[
"Prints",
"modules",
"with",
"intermediate",
"headers",
"for",
"the",
"module",
"states",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/ModuleCommandHandler.php#L232-L260
|
225,886
|
puli/cli
|
src/Handler/ModuleCommandHandler.php
|
ModuleCommandHandler.printModulesWithFormat
|
private function printModulesWithFormat(IO $io, ModuleList $modules, $format)
{
/** @var Module $module */
foreach ($modules as $module) {
$installInfo = $module->getInstallInfo();
$io->writeLine(strtr($format, array(
'%name%' => $module->getName(),
'%installer%' => $installInfo ? $installInfo->getInstallerName() : '',
'%install_path%' => $module->getInstallPath(),
'%state%' => self::$stateStrings[$module->getState()],
'%env%' => $installInfo ? $installInfo->getEnvironment() : Environment::PROD,
)));
}
}
|
php
|
private function printModulesWithFormat(IO $io, ModuleList $modules, $format)
{
/** @var Module $module */
foreach ($modules as $module) {
$installInfo = $module->getInstallInfo();
$io->writeLine(strtr($format, array(
'%name%' => $module->getName(),
'%installer%' => $installInfo ? $installInfo->getInstallerName() : '',
'%install_path%' => $module->getInstallPath(),
'%state%' => self::$stateStrings[$module->getState()],
'%env%' => $installInfo ? $installInfo->getEnvironment() : Environment::PROD,
)));
}
}
|
[
"private",
"function",
"printModulesWithFormat",
"(",
"IO",
"$",
"io",
",",
"ModuleList",
"$",
"modules",
",",
"$",
"format",
")",
"{",
"/** @var Module $module */",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"$",
"installInfo",
"=",
"$",
"module",
"->",
"getInstallInfo",
"(",
")",
";",
"$",
"io",
"->",
"writeLine",
"(",
"strtr",
"(",
"$",
"format",
",",
"array",
"(",
"'%name%'",
"=>",
"$",
"module",
"->",
"getName",
"(",
")",
",",
"'%installer%'",
"=>",
"$",
"installInfo",
"?",
"$",
"installInfo",
"->",
"getInstallerName",
"(",
")",
":",
"''",
",",
"'%install_path%'",
"=>",
"$",
"module",
"->",
"getInstallPath",
"(",
")",
",",
"'%state%'",
"=>",
"self",
"::",
"$",
"stateStrings",
"[",
"$",
"module",
"->",
"getState",
"(",
")",
"]",
",",
"'%env%'",
"=>",
"$",
"installInfo",
"?",
"$",
"installInfo",
"->",
"getEnvironment",
"(",
")",
":",
"Environment",
"::",
"PROD",
",",
")",
")",
")",
";",
"}",
"}"
] |
Prints modules using the given format.
@param IO $io The I/O
@param ModuleList $modules The modules to print
@param string $format The format string
|
[
"Prints",
"modules",
"using",
"the",
"given",
"format",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/ModuleCommandHandler.php#L269-L283
|
225,887
|
puli/cli
|
src/Handler/ModuleCommandHandler.php
|
ModuleCommandHandler.printModuleState
|
private function printModuleState(IO $io, $ModuleState)
{
switch ($ModuleState) {
case ModuleState::ENABLED:
$io->writeLine('The following modules are currently enabled:');
$io->writeLine('');
return;
case ModuleState::NOT_FOUND:
$io->writeLine('The following modules could not be found:');
$io->writeLine(' (use "puli module --clean" to remove)');
$io->writeLine('');
return;
case ModuleState::NOT_LOADABLE:
$io->writeLine('The following modules could not be loaded:');
$io->writeLine('');
return;
}
}
|
php
|
private function printModuleState(IO $io, $ModuleState)
{
switch ($ModuleState) {
case ModuleState::ENABLED:
$io->writeLine('The following modules are currently enabled:');
$io->writeLine('');
return;
case ModuleState::NOT_FOUND:
$io->writeLine('The following modules could not be found:');
$io->writeLine(' (use "puli module --clean" to remove)');
$io->writeLine('');
return;
case ModuleState::NOT_LOADABLE:
$io->writeLine('The following modules could not be loaded:');
$io->writeLine('');
return;
}
}
|
[
"private",
"function",
"printModuleState",
"(",
"IO",
"$",
"io",
",",
"$",
"ModuleState",
")",
"{",
"switch",
"(",
"$",
"ModuleState",
")",
"{",
"case",
"ModuleState",
"::",
"ENABLED",
":",
"$",
"io",
"->",
"writeLine",
"(",
"'The following modules are currently enabled:'",
")",
";",
"$",
"io",
"->",
"writeLine",
"(",
"''",
")",
";",
"return",
";",
"case",
"ModuleState",
"::",
"NOT_FOUND",
":",
"$",
"io",
"->",
"writeLine",
"(",
"'The following modules could not be found:'",
")",
";",
"$",
"io",
"->",
"writeLine",
"(",
"' (use \"puli module --clean\" to remove)'",
")",
";",
"$",
"io",
"->",
"writeLine",
"(",
"''",
")",
";",
"return",
";",
"case",
"ModuleState",
"::",
"NOT_LOADABLE",
":",
"$",
"io",
"->",
"writeLine",
"(",
"'The following modules could not be loaded:'",
")",
";",
"$",
"io",
"->",
"writeLine",
"(",
"''",
")",
";",
"return",
";",
"}",
"}"
] |
Prints the heading for a given module state.
@param IO $io The I/O
@param int $ModuleState The {@link ModuleState} constant
|
[
"Prints",
"the",
"heading",
"for",
"a",
"given",
"module",
"state",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/ModuleCommandHandler.php#L291-L311
|
225,888
|
puli/cli
|
src/Handler/ModuleCommandHandler.php
|
ModuleCommandHandler.printModuleTable
|
private function printModuleTable(IO $io, array $modules, $styleTag = null, $indent = false)
{
$table = new Table(PuliTableStyle::borderless());
$table->setHeaderRow(array('Module Name', 'Installer', 'Env', 'Install Path'));
$installerTag = $styleTag ?: 'c1';
$envTag = $styleTag ?: 'c1';
$pathTag = $styleTag ?: 'c2';
ksort($modules);
foreach ($modules as $module) {
$moduleName = $module->getName();
$installInfo = $module->getInstallInfo();
$installPath = $installInfo ? $installInfo->getInstallPath() : '.';
$installer = $installInfo ? $installInfo->getInstallerName() : '';
$env = $installInfo ? $installInfo->getEnvironment() : Environment::PROD;
$table->addRow(array(
$styleTag ? sprintf('<%s>%s</%s>', $styleTag, $moduleName, $styleTag) : $moduleName,
$installer ? sprintf('<%s>%s</%s>', $installerTag, $installer, $installerTag) : '',
sprintf('<%s>%s</%s>', $envTag, $env, $envTag),
sprintf('<%s>%s</%s>', $pathTag, $installPath, $pathTag),
));
}
$table->render($io, $indent ? 4 : 0);
}
|
php
|
private function printModuleTable(IO $io, array $modules, $styleTag = null, $indent = false)
{
$table = new Table(PuliTableStyle::borderless());
$table->setHeaderRow(array('Module Name', 'Installer', 'Env', 'Install Path'));
$installerTag = $styleTag ?: 'c1';
$envTag = $styleTag ?: 'c1';
$pathTag = $styleTag ?: 'c2';
ksort($modules);
foreach ($modules as $module) {
$moduleName = $module->getName();
$installInfo = $module->getInstallInfo();
$installPath = $installInfo ? $installInfo->getInstallPath() : '.';
$installer = $installInfo ? $installInfo->getInstallerName() : '';
$env = $installInfo ? $installInfo->getEnvironment() : Environment::PROD;
$table->addRow(array(
$styleTag ? sprintf('<%s>%s</%s>', $styleTag, $moduleName, $styleTag) : $moduleName,
$installer ? sprintf('<%s>%s</%s>', $installerTag, $installer, $installerTag) : '',
sprintf('<%s>%s</%s>', $envTag, $env, $envTag),
sprintf('<%s>%s</%s>', $pathTag, $installPath, $pathTag),
));
}
$table->render($io, $indent ? 4 : 0);
}
|
[
"private",
"function",
"printModuleTable",
"(",
"IO",
"$",
"io",
",",
"array",
"$",
"modules",
",",
"$",
"styleTag",
"=",
"null",
",",
"$",
"indent",
"=",
"false",
")",
"{",
"$",
"table",
"=",
"new",
"Table",
"(",
"PuliTableStyle",
"::",
"borderless",
"(",
")",
")",
";",
"$",
"table",
"->",
"setHeaderRow",
"(",
"array",
"(",
"'Module Name'",
",",
"'Installer'",
",",
"'Env'",
",",
"'Install Path'",
")",
")",
";",
"$",
"installerTag",
"=",
"$",
"styleTag",
"?",
":",
"'c1'",
";",
"$",
"envTag",
"=",
"$",
"styleTag",
"?",
":",
"'c1'",
";",
"$",
"pathTag",
"=",
"$",
"styleTag",
"?",
":",
"'c2'",
";",
"ksort",
"(",
"$",
"modules",
")",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"$",
"moduleName",
"=",
"$",
"module",
"->",
"getName",
"(",
")",
";",
"$",
"installInfo",
"=",
"$",
"module",
"->",
"getInstallInfo",
"(",
")",
";",
"$",
"installPath",
"=",
"$",
"installInfo",
"?",
"$",
"installInfo",
"->",
"getInstallPath",
"(",
")",
":",
"'.'",
";",
"$",
"installer",
"=",
"$",
"installInfo",
"?",
"$",
"installInfo",
"->",
"getInstallerName",
"(",
")",
":",
"''",
";",
"$",
"env",
"=",
"$",
"installInfo",
"?",
"$",
"installInfo",
"->",
"getEnvironment",
"(",
")",
":",
"Environment",
"::",
"PROD",
";",
"$",
"table",
"->",
"addRow",
"(",
"array",
"(",
"$",
"styleTag",
"?",
"sprintf",
"(",
"'<%s>%s</%s>'",
",",
"$",
"styleTag",
",",
"$",
"moduleName",
",",
"$",
"styleTag",
")",
":",
"$",
"moduleName",
",",
"$",
"installer",
"?",
"sprintf",
"(",
"'<%s>%s</%s>'",
",",
"$",
"installerTag",
",",
"$",
"installer",
",",
"$",
"installerTag",
")",
":",
"''",
",",
"sprintf",
"(",
"'<%s>%s</%s>'",
",",
"$",
"envTag",
",",
"$",
"env",
",",
"$",
"envTag",
")",
",",
"sprintf",
"(",
"'<%s>%s</%s>'",
",",
"$",
"pathTag",
",",
"$",
"installPath",
",",
"$",
"pathTag",
")",
",",
")",
")",
";",
"}",
"$",
"table",
"->",
"render",
"(",
"$",
"io",
",",
"$",
"indent",
"?",
"4",
":",
"0",
")",
";",
"}"
] |
Prints a list of modules in a table.
@param IO $io The I/O
@param Module[] $modules The modules
@param string|null $styleTag The tag used to style the output. If `null`,
the default colors are used
@param bool $indent Whether to indent the output
|
[
"Prints",
"a",
"list",
"of",
"modules",
"in",
"a",
"table",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/ModuleCommandHandler.php#L322-L349
|
225,889
|
puli/cli
|
src/Handler/ModuleCommandHandler.php
|
ModuleCommandHandler.printNotLoadableModules
|
private function printNotLoadableModules(IO $io, array $modules, $indent = false)
{
$rootDir = $this->moduleManager->getContext()->getRootDirectory();
$table = new Table(PuliTableStyle::borderless());
$table->setHeaderRow(array('Module Name', 'Error'));
ksort($modules);
foreach ($modules as $module) {
$moduleName = $module->getName();
$loadErrors = $module->getLoadErrors();
$errorMessage = '';
foreach ($loadErrors as $loadError) {
$errorMessage .= StringUtil::getShortClassName(get_class($loadError)).': '.$loadError->getMessage()."\n";
}
$errorMessage = rtrim($errorMessage);
if (!$errorMessage) {
$errorMessage = 'Unknown error.';
}
// Remove root directory
$errorMessage = str_replace($rootDir.'/', '', $errorMessage);
$table->addRow(array(
sprintf('<bad>%s</bad>', $moduleName),
sprintf('<bad>%s</bad>', $errorMessage),
));
}
$table->render($io, $indent ? 4 : 0);
}
|
php
|
private function printNotLoadableModules(IO $io, array $modules, $indent = false)
{
$rootDir = $this->moduleManager->getContext()->getRootDirectory();
$table = new Table(PuliTableStyle::borderless());
$table->setHeaderRow(array('Module Name', 'Error'));
ksort($modules);
foreach ($modules as $module) {
$moduleName = $module->getName();
$loadErrors = $module->getLoadErrors();
$errorMessage = '';
foreach ($loadErrors as $loadError) {
$errorMessage .= StringUtil::getShortClassName(get_class($loadError)).': '.$loadError->getMessage()."\n";
}
$errorMessage = rtrim($errorMessage);
if (!$errorMessage) {
$errorMessage = 'Unknown error.';
}
// Remove root directory
$errorMessage = str_replace($rootDir.'/', '', $errorMessage);
$table->addRow(array(
sprintf('<bad>%s</bad>', $moduleName),
sprintf('<bad>%s</bad>', $errorMessage),
));
}
$table->render($io, $indent ? 4 : 0);
}
|
[
"private",
"function",
"printNotLoadableModules",
"(",
"IO",
"$",
"io",
",",
"array",
"$",
"modules",
",",
"$",
"indent",
"=",
"false",
")",
"{",
"$",
"rootDir",
"=",
"$",
"this",
"->",
"moduleManager",
"->",
"getContext",
"(",
")",
"->",
"getRootDirectory",
"(",
")",
";",
"$",
"table",
"=",
"new",
"Table",
"(",
"PuliTableStyle",
"::",
"borderless",
"(",
")",
")",
";",
"$",
"table",
"->",
"setHeaderRow",
"(",
"array",
"(",
"'Module Name'",
",",
"'Error'",
")",
")",
";",
"ksort",
"(",
"$",
"modules",
")",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"$",
"moduleName",
"=",
"$",
"module",
"->",
"getName",
"(",
")",
";",
"$",
"loadErrors",
"=",
"$",
"module",
"->",
"getLoadErrors",
"(",
")",
";",
"$",
"errorMessage",
"=",
"''",
";",
"foreach",
"(",
"$",
"loadErrors",
"as",
"$",
"loadError",
")",
"{",
"$",
"errorMessage",
".=",
"StringUtil",
"::",
"getShortClassName",
"(",
"get_class",
"(",
"$",
"loadError",
")",
")",
".",
"': '",
".",
"$",
"loadError",
"->",
"getMessage",
"(",
")",
".",
"\"\\n\"",
";",
"}",
"$",
"errorMessage",
"=",
"rtrim",
"(",
"$",
"errorMessage",
")",
";",
"if",
"(",
"!",
"$",
"errorMessage",
")",
"{",
"$",
"errorMessage",
"=",
"'Unknown error.'",
";",
"}",
"// Remove root directory",
"$",
"errorMessage",
"=",
"str_replace",
"(",
"$",
"rootDir",
".",
"'/'",
",",
"''",
",",
"$",
"errorMessage",
")",
";",
"$",
"table",
"->",
"addRow",
"(",
"array",
"(",
"sprintf",
"(",
"'<bad>%s</bad>'",
",",
"$",
"moduleName",
")",
",",
"sprintf",
"(",
"'<bad>%s</bad>'",
",",
"$",
"errorMessage",
")",
",",
")",
")",
";",
"}",
"$",
"table",
"->",
"render",
"(",
"$",
"io",
",",
"$",
"indent",
"?",
"4",
":",
"0",
")",
";",
"}"
] |
Prints not-loadable modules in a table.
@param IO $io The I/O
@param Module[] $modules The not-loadable modules
@param bool $indent Whether to indent the output
|
[
"Prints",
"not",
"-",
"loadable",
"modules",
"in",
"a",
"table",
"."
] |
bbd704e8755650f7ab7bb07a7d5ef15fb0d70794
|
https://github.com/puli/cli/blob/bbd704e8755650f7ab7bb07a7d5ef15fb0d70794/src/Handler/ModuleCommandHandler.php#L358-L391
|
225,890
|
tyxla/carbon-breadcrumbs
|
admin/class-carbon-breadcrumb-admin.php
|
Carbon_Breadcrumb_Admin.apply_settings
|
public function apply_settings( $settings = array() ) {
$settings_fields = Carbon_Breadcrumb_Admin_Settings::get_field_data();
foreach ( $settings_fields as $field_id => $field ) {
$settings[ $field_id ] = get_option( 'carbon_breadcrumbs_' . $field_id );
if ( 'checkbox' == $field['type'] ) {
$settings[ $field_id ] = (bool) $settings[ $field_id ];
}
}
return $settings;
}
|
php
|
public function apply_settings( $settings = array() ) {
$settings_fields = Carbon_Breadcrumb_Admin_Settings::get_field_data();
foreach ( $settings_fields as $field_id => $field ) {
$settings[ $field_id ] = get_option( 'carbon_breadcrumbs_' . $field_id );
if ( 'checkbox' == $field['type'] ) {
$settings[ $field_id ] = (bool) $settings[ $field_id ];
}
}
return $settings;
}
|
[
"public",
"function",
"apply_settings",
"(",
"$",
"settings",
"=",
"array",
"(",
")",
")",
"{",
"$",
"settings_fields",
"=",
"Carbon_Breadcrumb_Admin_Settings",
"::",
"get_field_data",
"(",
")",
";",
"foreach",
"(",
"$",
"settings_fields",
"as",
"$",
"field_id",
"=>",
"$",
"field",
")",
"{",
"$",
"settings",
"[",
"$",
"field_id",
"]",
"=",
"get_option",
"(",
"'carbon_breadcrumbs_'",
".",
"$",
"field_id",
")",
";",
"if",
"(",
"'checkbox'",
"==",
"$",
"field",
"[",
"'type'",
"]",
")",
"{",
"$",
"settings",
"[",
"$",
"field_id",
"]",
"=",
"(",
"bool",
")",
"$",
"settings",
"[",
"$",
"field_id",
"]",
";",
"}",
"}",
"return",
"$",
"settings",
";",
"}"
] |
Apply the settings to the breadcrumb trail renderer
@access public
@param array $settings The default settings.
@return array $settings The modified settings.
|
[
"Apply",
"the",
"settings",
"to",
"the",
"breadcrumb",
"trail",
"renderer"
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/admin/class-carbon-breadcrumb-admin.php#L94-L105
|
225,891
|
tyxla/carbon-breadcrumbs
|
admin/class-carbon-breadcrumb-admin.php
|
Carbon_Breadcrumb_Admin.is_enabled
|
public function is_enabled() {
$enabled = false;
// Enabled if this plugin is installed as a regular WordPress plugin.
$plugin_path = untrailingslashit( ABSPATH ) . DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'plugins';
$current_dir = $this->current_dir();
if ( false !== strpos( $current_dir, $plugin_path ) ) {
$enabled = true;
}
// Enabled if the CARBON_BREADCRUMB_ENABLE_ADMIN is defined as `true`.
if ( defined( 'CARBON_BREADCRUMB_ENABLE_ADMIN' ) && CARBON_BREADCRUMB_ENABLE_ADMIN ) {
$enabled = true;
}
// Allow manual enabling/disabling.
return apply_filters( 'carbon_breadcrumb_enable_admin', $enabled );
}
|
php
|
public function is_enabled() {
$enabled = false;
// Enabled if this plugin is installed as a regular WordPress plugin.
$plugin_path = untrailingslashit( ABSPATH ) . DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'plugins';
$current_dir = $this->current_dir();
if ( false !== strpos( $current_dir, $plugin_path ) ) {
$enabled = true;
}
// Enabled if the CARBON_BREADCRUMB_ENABLE_ADMIN is defined as `true`.
if ( defined( 'CARBON_BREADCRUMB_ENABLE_ADMIN' ) && CARBON_BREADCRUMB_ENABLE_ADMIN ) {
$enabled = true;
}
// Allow manual enabling/disabling.
return apply_filters( 'carbon_breadcrumb_enable_admin', $enabled );
}
|
[
"public",
"function",
"is_enabled",
"(",
")",
"{",
"$",
"enabled",
"=",
"false",
";",
"// Enabled if this plugin is installed as a regular WordPress plugin.",
"$",
"plugin_path",
"=",
"untrailingslashit",
"(",
"ABSPATH",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"'wp-content'",
".",
"DIRECTORY_SEPARATOR",
".",
"'plugins'",
";",
"$",
"current_dir",
"=",
"$",
"this",
"->",
"current_dir",
"(",
")",
";",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"current_dir",
",",
"$",
"plugin_path",
")",
")",
"{",
"$",
"enabled",
"=",
"true",
";",
"}",
"// Enabled if the CARBON_BREADCRUMB_ENABLE_ADMIN is defined as `true`.",
"if",
"(",
"defined",
"(",
"'CARBON_BREADCRUMB_ENABLE_ADMIN'",
")",
"&&",
"CARBON_BREADCRUMB_ENABLE_ADMIN",
")",
"{",
"$",
"enabled",
"=",
"true",
";",
"}",
"// Allow manual enabling/disabling.",
"return",
"apply_filters",
"(",
"'carbon_breadcrumb_enable_admin'",
",",
"$",
"enabled",
")",
";",
"}"
] |
Whether the administration interface should be enabled.
@access public
@return bool $is_enabled True if the admin interface is enabled.
|
[
"Whether",
"the",
"administration",
"interface",
"should",
"be",
"enabled",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/admin/class-carbon-breadcrumb-admin.php#L114-L131
|
225,892
|
nztim/queue
|
src/Lock.php
|
Lock.set
|
public function set(int $timeoutMinutes) : bool
{
if ($this->isLocked()) {
return false;
}
$this->setLock($timeoutMinutes);
return true;
}
|
php
|
public function set(int $timeoutMinutes) : bool
{
if ($this->isLocked()) {
return false;
}
$this->setLock($timeoutMinutes);
return true;
}
|
[
"public",
"function",
"set",
"(",
"int",
"$",
"timeoutMinutes",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"isLocked",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"setLock",
"(",
"$",
"timeoutMinutes",
")",
";",
"return",
"true",
";",
"}"
] |
Returns true if exclusive lock obtained
@param int $timeoutMinutes
@return bool
|
[
"Returns",
"true",
"if",
"exclusive",
"lock",
"obtained"
] |
88ca18eed292f6c121b81aa668e1e659c73c6495
|
https://github.com/nztim/queue/blob/88ca18eed292f6c121b81aa668e1e659c73c6495/src/Lock.php#L22-L29
|
225,893
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail-setup.php
|
Carbon_Breadcrumb_Trail_Setup.populate_date_archive_items
|
public function populate_date_archive_items() {
if ( ! is_date() ) {
return;
}
$locator = Carbon_Breadcrumb_Locator::factory( 'date' );
$items = $locator->get_items( 700 );
$this->get_trail()->add_item( $items );
}
|
php
|
public function populate_date_archive_items() {
if ( ! is_date() ) {
return;
}
$locator = Carbon_Breadcrumb_Locator::factory( 'date' );
$items = $locator->get_items( 700 );
$this->get_trail()->add_item( $items );
}
|
[
"public",
"function",
"populate_date_archive_items",
"(",
")",
"{",
"if",
"(",
"!",
"is_date",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"locator",
"=",
"Carbon_Breadcrumb_Locator",
"::",
"factory",
"(",
"'date'",
")",
";",
"$",
"items",
"=",
"$",
"locator",
"->",
"get_items",
"(",
"700",
")",
";",
"$",
"this",
"->",
"get_trail",
"(",
")",
"->",
"add_item",
"(",
"$",
"items",
")",
";",
"}"
] |
Populate date archives.
@access public
|
[
"Populate",
"date",
"archives",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail-setup.php#L68-L76
|
225,894
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail-setup.php
|
Carbon_Breadcrumb_Trail_Setup.populate_post_type_archive_items
|
public function populate_post_type_archive_items() {
if ( is_post_type_archive() ) {
$post_type = get_post_type_object( get_query_var( 'post_type' ) );
} elseif ( is_singular() ) {
$post_type = get_post_type_object( get_post_type() );
if ( ! $post_type->has_archive ) {
return;
}
} else {
return;
}
$title = $post_type->labels->name;
$link = get_post_type_archive_link( $post_type->name );
$this->get_trail()->add_custom_item( $title, $link, 700 );
}
|
php
|
public function populate_post_type_archive_items() {
if ( is_post_type_archive() ) {
$post_type = get_post_type_object( get_query_var( 'post_type' ) );
} elseif ( is_singular() ) {
$post_type = get_post_type_object( get_post_type() );
if ( ! $post_type->has_archive ) {
return;
}
} else {
return;
}
$title = $post_type->labels->name;
$link = get_post_type_archive_link( $post_type->name );
$this->get_trail()->add_custom_item( $title, $link, 700 );
}
|
[
"public",
"function",
"populate_post_type_archive_items",
"(",
")",
"{",
"if",
"(",
"is_post_type_archive",
"(",
")",
")",
"{",
"$",
"post_type",
"=",
"get_post_type_object",
"(",
"get_query_var",
"(",
"'post_type'",
")",
")",
";",
"}",
"elseif",
"(",
"is_singular",
"(",
")",
")",
"{",
"$",
"post_type",
"=",
"get_post_type_object",
"(",
"get_post_type",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"post_type",
"->",
"has_archive",
")",
"{",
"return",
";",
"}",
"}",
"else",
"{",
"return",
";",
"}",
"$",
"title",
"=",
"$",
"post_type",
"->",
"labels",
"->",
"name",
";",
"$",
"link",
"=",
"get_post_type_archive_link",
"(",
"$",
"post_type",
"->",
"name",
")",
";",
"$",
"this",
"->",
"get_trail",
"(",
")",
"->",
"add_custom_item",
"(",
"$",
"title",
",",
"$",
"link",
",",
"700",
")",
";",
"}"
] |
Populate post type archives.
@access public
|
[
"Populate",
"post",
"type",
"archives",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail-setup.php#L83-L98
|
225,895
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail-setup.php
|
Carbon_Breadcrumb_Trail_Setup.populate_search_items
|
public function populate_search_items() {
if ( ! is_search() ) {
return;
}
// Translators: %1$s - search query.
$search_title = sprintf( __( 'Search results for: "%1$s"', 'carbon_breadcrumbs' ), get_search_query() );
$this->get_trail()->add_custom_item( $search_title, '', 700 );
}
|
php
|
public function populate_search_items() {
if ( ! is_search() ) {
return;
}
// Translators: %1$s - search query.
$search_title = sprintf( __( 'Search results for: "%1$s"', 'carbon_breadcrumbs' ), get_search_query() );
$this->get_trail()->add_custom_item( $search_title, '', 700 );
}
|
[
"public",
"function",
"populate_search_items",
"(",
")",
"{",
"if",
"(",
"!",
"is_search",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Translators: %1$s - search query.",
"$",
"search_title",
"=",
"sprintf",
"(",
"__",
"(",
"'Search results for: \"%1$s\"'",
",",
"'carbon_breadcrumbs'",
")",
",",
"get_search_query",
"(",
")",
")",
";",
"$",
"this",
"->",
"get_trail",
"(",
")",
"->",
"add_custom_item",
"(",
"$",
"search_title",
",",
"''",
",",
"700",
")",
";",
"}"
] |
Populate search items.
@access public
|
[
"Populate",
"search",
"items",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail-setup.php#L106-L114
|
225,896
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail-setup.php
|
Carbon_Breadcrumb_Trail_Setup.populate_category_items
|
public function populate_category_items() {
if ( ! ( is_single() && 'post' == get_post_type() ) ) {
return;
}
$taxonomy = 'category';
$categories = wp_get_object_terms( get_the_ID(), $taxonomy, array( 'orderby' => 'term_id' ) );
$last_category = array_pop( $categories );
$locator = Carbon_Breadcrumb_Locator::factory( 'term', $taxonomy );
$items = $locator->get_items( 700, $last_category->term_id );
$this->get_trail()->add_item( $items );
}
|
php
|
public function populate_category_items() {
if ( ! ( is_single() && 'post' == get_post_type() ) ) {
return;
}
$taxonomy = 'category';
$categories = wp_get_object_terms( get_the_ID(), $taxonomy, array( 'orderby' => 'term_id' ) );
$last_category = array_pop( $categories );
$locator = Carbon_Breadcrumb_Locator::factory( 'term', $taxonomy );
$items = $locator->get_items( 700, $last_category->term_id );
$this->get_trail()->add_item( $items );
}
|
[
"public",
"function",
"populate_category_items",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"is_single",
"(",
")",
"&&",
"'post'",
"==",
"get_post_type",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"$",
"taxonomy",
"=",
"'category'",
";",
"$",
"categories",
"=",
"wp_get_object_terms",
"(",
"get_the_ID",
"(",
")",
",",
"$",
"taxonomy",
",",
"array",
"(",
"'orderby'",
"=>",
"'term_id'",
")",
")",
";",
"$",
"last_category",
"=",
"array_pop",
"(",
"$",
"categories",
")",
";",
"$",
"locator",
"=",
"Carbon_Breadcrumb_Locator",
"::",
"factory",
"(",
"'term'",
",",
"$",
"taxonomy",
")",
";",
"$",
"items",
"=",
"$",
"locator",
"->",
"get_items",
"(",
"700",
",",
"$",
"last_category",
"->",
"term_id",
")",
";",
"$",
"this",
"->",
"get_trail",
"(",
")",
"->",
"add_item",
"(",
"$",
"items",
")",
";",
"}"
] |
Populate category hierarchy when on a single post.
@access public
|
[
"Populate",
"category",
"hierarchy",
"when",
"on",
"a",
"single",
"post",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail-setup.php#L135-L146
|
225,897
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail-setup.php
|
Carbon_Breadcrumb_Trail_Setup.populate_page_for_posts_items
|
public function populate_page_for_posts_items() {
$page_for_posts = get_option( 'page_for_posts' );
if ( ! $page_for_posts ) {
return;
}
if ( $this->is_post_context() ) {
$locator = Carbon_Breadcrumb_Locator::factory( 'post', 'page' );
$items = $locator->get_items( 500, $page_for_posts );
$this->get_trail()->add_item( $items );
}
}
|
php
|
public function populate_page_for_posts_items() {
$page_for_posts = get_option( 'page_for_posts' );
if ( ! $page_for_posts ) {
return;
}
if ( $this->is_post_context() ) {
$locator = Carbon_Breadcrumb_Locator::factory( 'post', 'page' );
$items = $locator->get_items( 500, $page_for_posts );
$this->get_trail()->add_item( $items );
}
}
|
[
"public",
"function",
"populate_page_for_posts_items",
"(",
")",
"{",
"$",
"page_for_posts",
"=",
"get_option",
"(",
"'page_for_posts'",
")",
";",
"if",
"(",
"!",
"$",
"page_for_posts",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"is_post_context",
"(",
")",
")",
"{",
"$",
"locator",
"=",
"Carbon_Breadcrumb_Locator",
"::",
"factory",
"(",
"'post'",
",",
"'page'",
")",
";",
"$",
"items",
"=",
"$",
"locator",
"->",
"get_items",
"(",
"500",
",",
"$",
"page_for_posts",
")",
";",
"$",
"this",
"->",
"get_trail",
"(",
")",
"->",
"add_item",
"(",
"$",
"items",
")",
";",
"}",
"}"
] |
Populate page for posts item where necessary.
@access public
|
[
"Populate",
"page",
"for",
"posts",
"item",
"where",
"necessary",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail-setup.php#L153-L164
|
225,898
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail-setup.php
|
Carbon_Breadcrumb_Trail_Setup.populate_home_items
|
public function populate_home_items() {
$trail = $this->get_trail();
$renderer = $trail->get_renderer();
if ( ! $renderer->get_display_home_item() ) {
return;
}
$home_title = $renderer->get_home_item_title();
$home_link = home_url( '/' );
$trail->add_custom_item( $home_title, $home_link, 10 );
}
|
php
|
public function populate_home_items() {
$trail = $this->get_trail();
$renderer = $trail->get_renderer();
if ( ! $renderer->get_display_home_item() ) {
return;
}
$home_title = $renderer->get_home_item_title();
$home_link = home_url( '/' );
$trail->add_custom_item( $home_title, $home_link, 10 );
}
|
[
"public",
"function",
"populate_home_items",
"(",
")",
"{",
"$",
"trail",
"=",
"$",
"this",
"->",
"get_trail",
"(",
")",
";",
"$",
"renderer",
"=",
"$",
"trail",
"->",
"get_renderer",
"(",
")",
";",
"if",
"(",
"!",
"$",
"renderer",
"->",
"get_display_home_item",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"home_title",
"=",
"$",
"renderer",
"->",
"get_home_item_title",
"(",
")",
";",
"$",
"home_link",
"=",
"home_url",
"(",
"'/'",
")",
";",
"$",
"trail",
"->",
"add_custom_item",
"(",
"$",
"home_title",
",",
"$",
"home_link",
",",
"10",
")",
";",
"}"
] |
Populate home item.
@access public
|
[
"Populate",
"home",
"item",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail-setup.php#L194-L204
|
225,899
|
tyxla/carbon-breadcrumbs
|
core/class-carbon-breadcrumb-trail-setup.php
|
Carbon_Breadcrumb_Trail_Setup.generate_locator_items
|
protected function generate_locator_items( $locator_name ) {
$locator = Carbon_Breadcrumb_Locator::factory( $locator_name );
$items = $locator->generate_items();
if ( $items ) {
return $items;
}
return array();
}
|
php
|
protected function generate_locator_items( $locator_name ) {
$locator = Carbon_Breadcrumb_Locator::factory( $locator_name );
$items = $locator->generate_items();
if ( $items ) {
return $items;
}
return array();
}
|
[
"protected",
"function",
"generate_locator_items",
"(",
"$",
"locator_name",
")",
"{",
"$",
"locator",
"=",
"Carbon_Breadcrumb_Locator",
"::",
"factory",
"(",
"$",
"locator_name",
")",
";",
"$",
"items",
"=",
"$",
"locator",
"->",
"generate_items",
"(",
")",
";",
"if",
"(",
"$",
"items",
")",
"{",
"return",
"$",
"items",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
] |
Generate the items of a certain locator.
@access protected
@param string $locator_name Name of the locator.
@return array $items Items generated by this locator.
|
[
"Generate",
"the",
"items",
"of",
"a",
"certain",
"locator",
"."
] |
0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185
|
https://github.com/tyxla/carbon-breadcrumbs/blob/0af5b5dd5b9848fd3e7db7fd0513d4f1faeaf185/core/class-carbon-breadcrumb-trail-setup.php#L214-L223
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.